aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2015-12-29 19:57:01 +0100
committerDominik Schürmann <dominik@dominikschuermann.de>2015-12-29 19:57:01 +0100
commit621f8c2c70183bdb44c4adb6f6a507a192af58a3 (patch)
treee5fd14a50ebac9cd17c09423dfd281441262e240 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java
parentea3b25846946e96e124cd5635e710f8ece77eceb (diff)
downloadopen-keychain-621f8c2c70183bdb44c4adb6f6a507a192af58a3.tar.gz
open-keychain-621f8c2c70183bdb44c4adb6f6a507a192af58a3.tar.bz2
open-keychain-621f8c2c70183bdb44c4adb6f6a507a192af58a3.zip
Load key data in tabs independently from advanced activity. This decouples the fragments from the activity and allows to init the tabs before loading key data in the advanced activity. Fixes switching to the first tab when key has been edited.
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java22
1 files changed, 6 insertions, 16 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java
index c2f63fa4e..b10e5f8d4 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java
@@ -25,7 +25,6 @@ import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
-import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
@@ -41,6 +40,7 @@ import android.view.animation.OvershootInterpolator;
import android.widget.Toast;
import com.astuetz.PagerSlidingTabStrip;
+
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.operations.results.OperationResult;
@@ -113,6 +113,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements
// or start new ones.
getSupportLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this);
+ initTabs(mDataUri);
}
@Override
@@ -120,10 +121,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements
setContentView(R.layout.view_key_adv_activity);
}
- private void initTabs(Uri dataUri, boolean hasSecret, long masterKeyId, byte[] fingerprint) {
-
- mHasSecret = hasSecret;
-
+ private void initTabs(Uri dataUri) {
mTabAdapter = new PagerTabStripAdapter(this);
mViewPager.setAdapter(mTabAdapter);
@@ -138,18 +136,12 @@ public class ViewKeyAdvActivity extends BaseActivity implements
Bundle userIdsBundle = new Bundle();
userIdsBundle.putParcelable(ViewKeyAdvUserIdsFragment.ARG_DATA_URI, dataUri);
- userIdsBundle.putBoolean(ViewKeyAdvUserIdsFragment.ARG_HAS_SECRET, hasSecret);
- userIdsBundle.putLong(ViewKeyAdvUserIdsFragment.ARG_MASTER_KEY_ID, masterKeyId);
- userIdsBundle.putByteArray(ViewKeyAdvUserIdsFragment.ARG_FINGERPRINT, fingerprint);
mTabAdapter.addTab(ViewKeyAdvUserIdsFragment.class,
userIdsBundle, getString(R.string.section_user_ids));
mTabsWithActionMode[1] = true;
Bundle keysBundle = new Bundle();
keysBundle.putParcelable(ViewKeyAdvSubkeysFragment.ARG_DATA_URI, dataUri);
- keysBundle.putBoolean(ViewKeyAdvSubkeysFragment.ARG_HAS_SECRET, hasSecret);
- keysBundle.putLong(ViewKeyAdvSubkeysFragment.ARG_MASTER_KEY_ID, masterKeyId);
- keysBundle.putByteArray(ViewKeyAdvSubkeysFragment.ARG_FINGERPRINT, fingerprint);
mTabAdapter.addTab(ViewKeyAdvSubkeysFragment.class,
keysBundle, getString(R.string.key_view_tab_keys));
mTabsWithActionMode[2] = true;
@@ -229,7 +221,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements
long masterKeyId = data.getLong(INDEX_MASTER_KEY_ID);
getSupportActionBar().setSubtitle(KeyFormattingUtils.beautifyKeyIdWithPrefix(this, masterKeyId));
- boolean isSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0;
+ mHasSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0;
boolean isRevoked = data.getInt(INDEX_IS_REVOKED) > 0;
boolean isExpired = data.getInt(INDEX_IS_EXPIRED) != 0;
boolean isVerified = data.getInt(INDEX_VERIFIED) > 0;
@@ -238,7 +230,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements
int color;
if (isRevoked || isExpired) {
color = getResources().getColor(R.color.key_flag_red);
- } else if (isSecret) {
+ } else if (mHasSecret) {
color = getResources().getColor(R.color.android_green_light);
} else {
if (isVerified) {
@@ -251,8 +243,6 @@ public class ViewKeyAdvActivity extends BaseActivity implements
mStatusBar.setBackgroundColor(ViewKeyActivity.getStatusBarBackgroundColor(color));
mSlidingTabLayout.setBackgroundColor(color);
- initTabs(mDataUri, isSecret, masterKeyId, fingerprint);
-
break;
}
}
@@ -284,7 +274,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements
// always add the item, switch its visibility depending on fragment
getMenuInflater().inflate(R.menu.action_mode_edit, menu);
- final MenuItem vActionModeItem = menu.findItem(R.id.menu_action_mode_edit);
+ final MenuItem vActionModeItem = menu.findItem(R.id.menu_action_mode_edit);
boolean isCurrentActionFragment = mTabsWithActionMode[mViewPager.getCurrentItem()];