aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/ui
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-07-25 14:15:47 +0200
committerChristian Schneppe <christian@pix-art.de>2016-07-25 19:50:19 +0200
commite388c64361a3dad44442dd1f8633e452302188e8 (patch)
treebfc9b12da582a92af1296e04ac032ee8a3263a22 /src/main/java/eu/siacs/conversations/ui
parent3fbee39579b4b2232fc98d50f6b16ec4f9f33022 (diff)
refactored how view intents are handled
processing view intents before saved instance caused troubles when the activity was destroyed fixes #1969
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java33
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java3
2 files changed, 17 insertions, 19 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index 319bfcead..02871a938 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -83,11 +83,9 @@ import eu.siacs.conversations.xmpp.jid.Jid;
public class ConversationActivity extends XmppActivity
implements OnAccountUpdate, OnConversationUpdate, OnRosterUpdate, OnUpdateBlocklist, XmppConnectionService.OnShowErrorToast, View.OnClickListener {
- public static final String ACTION_DOWNLOAD = "eu.siacs.conversations.action.DOWNLOAD";
-
- public static final String VIEW_CONVERSATION = "viewConversation";
+ public static final String ACTION_VIEW_CONVERSATION = "eu.siacs.conversations.action.VIEW";
public static final String CONVERSATION = "conversationUuid";
- public static final String MESSAGE = "messageUuid";
+ public static final String EXTRA_DOWNLOAD_UUID = "eu.siacs.conversations.download_uuid";
public static final String TEXT = "text";
public static final String NICK = "nick";
public static final String PRIVATE_MESSAGE = "pm";
@@ -1241,13 +1239,14 @@ public class ConversationActivity extends XmppActivity
@Override
protected void onNewIntent(final Intent intent) {
- if (xmppConnectionServiceBound) {
- if (intent != null && VIEW_CONVERSATION.equals(intent.getType())) {
+ if (intent != null && ACTION_VIEW_CONVERSATION.equals(intent.getAction())) {
+ mOpenConverstaion = null;
+ if (xmppConnectionServiceBound) {
handleViewConversationIntent(intent);
- setIntent(new Intent());
+ intent.setAction(Intent.ACTION_MAIN);
+ } else {
+ setIntent(intent);
}
- } else {
- setIntent(intent);
}
}
@@ -1355,7 +1354,7 @@ public class ConversationActivity extends XmppActivity
startActivity(intent);
System.exit(0);
}
-
+ final Intent intent = getIntent();
if (xmppConnectionService.getAccounts().size() == 0) {
if (mRedirected.compareAndSet(false, true)) {
if (Config.X509_VERIFICATION) {
@@ -1372,17 +1371,14 @@ public class ConversationActivity extends XmppActivity
if (mRedirected.compareAndSet(false, true)) {
Account pendingAccount = xmppConnectionService.getPendingAccount();
if (pendingAccount == null) {
- Intent intent = new Intent(this, StartConversationActivity.class);
+ Intent startConversationActivity = new Intent(this, StartConversationActivity.class);
intent.putExtra("init", true);
- startActivity(intent);
+ startActivity(startConversationActivity);
} else {
switchToAccount(pendingAccount, true);
}
finish();
}
- } else if (getIntent() != null && VIEW_CONVERSATION.equals(getIntent().getType())) {
- clearPending();
- handleViewConversationIntent(getIntent());
} else if (selectConversationByUuid(mOpenConverstaion)) {
if (mPanelOpen) {
showConversationsOverview();
@@ -1394,6 +1390,10 @@ public class ConversationActivity extends XmppActivity
}
this.mConversationFragment.reInit(getSelectedConversation());
mOpenConverstaion = null;
+ } else if (intent != null && ACTION_VIEW_CONVERSATION.equals(intent.getAction())) {
+ clearPending();
+ handleViewConversationIntent(intent);
+ intent.setAction(Intent.ACTION_MAIN);
} else if (getSelectedConversation() == null) {
showConversationsOverview();
clearPending();
@@ -1439,12 +1439,11 @@ public class ConversationActivity extends XmppActivity
if (!ExceptionHelper.checkForCrash(this, this.xmppConnectionService)) {
openBatteryOptimizationDialogIfNeeded();
}
- setIntent(new Intent());
}
private void handleViewConversationIntent(final Intent intent) {
final String uuid = intent.getStringExtra(CONVERSATION);
- final String downloadUuid = intent.getStringExtra(MESSAGE);
+ final String downloadUuid = intent.getStringExtra(EXTRA_DOWNLOAD_UUID);
final String text = intent.getStringExtra(TEXT);
final String nick = intent.getStringExtra(NICK);
final boolean pm = intent.getBooleanExtra(PRIVATE_MESSAGE, false);
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index 4c83e4f2a..7736bc7be 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -456,7 +456,7 @@ public abstract class XmppActivity extends Activity {
private void switchToConversation(Conversation conversation, String text, String nick, boolean pm, boolean newTask) {
Intent viewConversationIntent = new Intent(this,
ConversationActivity.class);
- viewConversationIntent.setAction(Intent.ACTION_VIEW);
+ viewConversationIntent.setAction(ConversationActivity.ACTION_VIEW_CONVERSATION);
viewConversationIntent.putExtra(ConversationActivity.CONVERSATION,
conversation.getUuid());
if (text != null) {
@@ -466,7 +466,6 @@ public abstract class XmppActivity extends Activity {
viewConversationIntent.putExtra(ConversationActivity.NICK, nick);
viewConversationIntent.putExtra(ConversationActivity.PRIVATE_MESSAGE,pm);
}
- viewConversationIntent.setType(ConversationActivity.VIEW_CONVERSATION);
if (newTask) {
viewConversationIntent.setFlags(viewConversationIntent.getFlags()
| Intent.FLAG_ACTIVITY_NEW_TASK