refactored toasts shown when adhoc creating mucs

This commit is contained in:
Daniel Gultsch 2016-05-27 20:05:40 +02:00
parent a241ab66de
commit 29bd1103c0
3 changed files with 23 additions and 5 deletions

View File

@ -1122,6 +1122,8 @@ public class ConversationActivity extends XmppActivity
if (mPendingConferenceInvite != null) { if (mPendingConferenceInvite != null) {
mPendingConferenceInvite.execute(this); mPendingConferenceInvite.execute(this);
mToast = Toast.makeText(this, R.string.creating_conference,Toast.LENGTH_LONG);
mToast.show();
mPendingConferenceInvite = null; mPendingConferenceInvite = null;
} }

View File

@ -117,6 +117,20 @@ public abstract class XmppActivity extends Activity {
protected int mTheme; protected int mTheme;
protected boolean mUsingEnterKey = false; protected boolean mUsingEnterKey = false;
protected Toast mToast;
protected void hideToast() {
if (mToast != null) {
mToast.cancel();
}
}
protected void replaceToast(String msg) {
hideToast();
mToast = Toast.makeText(this, msg ,Toast.LENGTH_LONG);
mToast.show();
}
protected Runnable onOpenPGPKeyPublished = new Runnable() { protected Runnable onOpenPGPKeyPublished = new Runnable() {
@Override @Override
public void run() { public void run() {
@ -940,19 +954,22 @@ public abstract class XmppActivity extends Activity {
mPendingConferenceInvite = ConferenceInvite.parse(data); mPendingConferenceInvite = ConferenceInvite.parse(data);
if (xmppConnectionServiceBound && mPendingConferenceInvite != null) { if (xmppConnectionServiceBound && mPendingConferenceInvite != null) {
mPendingConferenceInvite.execute(this); mPendingConferenceInvite.execute(this);
mToast = Toast.makeText(this, R.string.creating_conference,Toast.LENGTH_LONG);
mToast.show();
mPendingConferenceInvite = null; mPendingConferenceInvite = null;
} }
} }
} }
private UiCallback<Conversation> adhocCallback = new UiCallback<Conversation>() { private UiCallback<Conversation> adhocCallback = new UiCallback<Conversation>() {
@Override @Override
public void success(final Conversation conversation) { public void success(final Conversation conversation) {
switchToConversation(conversation);
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
Toast.makeText(XmppActivity.this,R.string.conference_created,Toast.LENGTH_LONG).show(); switchToConversation(conversation);
hideToast();
} }
}); });
} }
@ -962,7 +979,7 @@ public abstract class XmppActivity extends Activity {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
Toast.makeText(XmppActivity.this,errorCode,Toast.LENGTH_LONG).show(); replaceToast(getString(errorCode));
} }
}); });
} }

View File

@ -412,8 +412,7 @@
<string name="enable_notifications">Enable notifications</string> <string name="enable_notifications">Enable notifications</string>
<string name="conference_with">Create conference with…</string> <string name="conference_with">Create conference with…</string>
<string name="no_conference_server_found">No conference server found</string> <string name="no_conference_server_found">No conference server found</string>
<string name="conference_creation_failed">Conference creation failed!</string> <string name="conference_creation_failed">Conference creation failed!</string>s
<string name="conference_created">Conference created!</string>
<string name="secret_accepted">Secret accepted!</string> <string name="secret_accepted">Secret accepted!</string>
<string name="reset">Reset</string> <string name="reset">Reset</string>
<string name="account_image_description">Account avatar</string> <string name="account_image_description">Account avatar</string>