aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-08-26 09:10:59 +0200
committerChristian Schneppe <christian@pix-art.de>2016-08-26 22:36:58 +0200
commitcf32b40d53be0d22c225b77fd0f2fb1db05dae68 (patch)
tree511807c2558f3206e69a568dba39051592919332 /src
parentb7052b70f25367668f627aea712b97d8872c94df (diff)
survive rotation in editaccount
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationActivity.java22
-rw-r--r--src/main/java/de/pixart/messenger/ui/EditAccountActivity.java59
2 files changed, 49 insertions, 32 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
index 484e9326b..6442acaa3 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
@@ -137,24 +137,6 @@ public class ConversationActivity extends XmppActivity
long FirstStartTime = -1;
- @SuppressLint("NewApi")
- private static List<Uri> extractUriFromIntent(final Intent intent) {
- List<Uri> uris = new ArrayList<>();
- if (intent == null) {
- return uris;
- }
- Uri uri = intent.getData();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && uri == null) {
- ClipData clipData = intent.getClipData();
- for (int i = 0; i < clipData.getItemCount(); ++i) {
- uris.add(clipData.getItemAt(i).getUri());
- }
- } else {
- uris.add(uri);
- }
- return uris;
- }
-
public Conversation getSelectedConversation() {
return this.mSelectedConversation;
}
@@ -1367,7 +1349,9 @@ public class ConversationActivity extends XmppActivity
Log.d(Config.LOGTAG, "First start time: " + FirstStartTime);
startActivity(new Intent(this, WelcomeActivity.class));
} else {
- startActivity(new Intent(this, EditAccountActivity.class));
+ Intent editAccount = new Intent(this, EditAccountActivity.class);
+ editAccount.putExtra("init",true);
+ startActivity(editAccount);
}
finish();
}
diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
index c2be5663e..e26cfdaed 100644
--- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
@@ -1,5 +1,6 @@
package de.pixart.messenger.ui;
+import android.app.ActionBar;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.PendingIntent;
@@ -239,6 +240,8 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
};
private Toast mFetchingMamPrefsToast;
private TableRow mPushRow;
+ private String mSavedInstanceAccount;
+ private boolean mSavedInstanceInit = false;
public void refreshUiReal() {
invalidateOptionsMenu();
@@ -447,6 +450,10 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if (savedInstanceState != null) {
+ this.mSavedInstanceAccount = savedInstanceState.getString("account");
+ this.mSavedInstanceInit = savedInstanceState.getBoolean("initMode", false);
+ }
setContentView(R.layout.activity_edit_account);
this.mAccountJid = (AutoCompleteTextView) findViewById(R.id.account_jid);
this.mAccountJid.addTextChangedListener(this.mTextWatcher);
@@ -579,7 +586,8 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
} catch (final InvalidJidException | NullPointerException ignored) {
this.jidToEdit = null;
}
- this.mInitMode = getIntent().getBooleanExtra("init", false) || this.jidToEdit == null;
+ boolean init = getIntent().getBooleanExtra("init", false);
+ this.mInitMode = init || this.jidToEdit == null;
this.messageFingerprint = getIntent().getStringExtra("fingerprint");
if (!mInitMode) {
this.mRegisterNew.setVisibility(View.GONE);
@@ -588,8 +596,13 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
}
} else {
this.mAvatar.setVisibility(View.GONE);
- if (getActionBar() != null) {
- getActionBar().setTitle(R.string.action_add_account);
+ ActionBar ab = getActionBar();
+ if (ab != null) {
+ if (init && Config.MAGIC_CREATE_DOMAIN == null) {
+ ab.setDisplayShowHomeEnabled(false);
+ ab.setDisplayHomeAsUpEnabled(false);
+ }
+ ab.setTitle(R.string.action_add_account);
}
}
}
@@ -601,21 +614,41 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
}
@Override
+ public void onSaveInstanceState(final Bundle savedInstanceState) {
+ if (mAccount != null) {
+ savedInstanceState.putString("account", mAccount.getJid().toBareJid().toString());
+ savedInstanceState.putBoolean("initMode", mInitMode);
+ }
+ super.onSaveInstanceState(savedInstanceState);
+ }
+
+ @Override
protected void onBackendConnected() {
- if (this.jidToEdit != null) {
+ if (mSavedInstanceAccount != null) {
+ try {
+ this.mAccount = xmppConnectionService.findAccountByJid(Jid.fromString(mSavedInstanceAccount));
+ this.mInitMode = mSavedInstanceInit;
+ } catch (InvalidJidException e) {
+ this.mAccount = null;
+ }
+
+ } else if (this.jidToEdit != null) {
this.mAccount = xmppConnectionService.findAccountByJid(jidToEdit);
- if (this.mAccount != null) {
- this.mInitMode |= this.mAccount.isOptionSet(Account.OPTION_REGISTER);
- this.mUsernameMode |= mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) && mAccount.isOptionSet(Account.OPTION_REGISTER);
- if (this.mAccount.getPrivateKeyAlias() != null) {
- this.mPassword.setHint(R.string.authenticate_with_certificate);
- if (this.mInitMode) {
- this.mPassword.requestFocus();
- }
+ }
+
+ if (mAccount != null) {
+ this.mInitMode |= this.mAccount.isOptionSet(Account.OPTION_REGISTER);
+ this.mUsernameMode |= mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) && mAccount.isOptionSet(Account.OPTION_REGISTER);
+ if (this.mAccount.getPrivateKeyAlias() != null) {
+ this.mPassword.setHint(R.string.authenticate_with_certificate);
+ if (this.mInitMode) {
+ this.mPassword.requestFocus();
}
- updateAccountInformation(true);
}
+ updateAccountInformation(true);
}
+
+
if (Config.MAGIC_CREATE_DOMAIN == null && this.xmppConnectionService.getAccounts().size() == 0) {
this.mCancelButton.setEnabled(false);
this.mCancelButton.setTextColor(getSecondaryTextColor());