aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui
diff options
context:
space:
mode:
authoruberspot <onexemailx@gmail.com>2014-03-17 00:27:52 +0200
committeruberspot <onexemailx@gmail.com>2014-03-17 00:27:52 +0200
commite01c99a193528df717d5cf5bd9fe20c649297375 (patch)
treed2638120393a590bc05c19931f2da755be18da3d /OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui
parentcea62b1857a9b5dbade8dcff6009f72e309b7469 (diff)
downloadopen-keychain-e01c99a193528df717d5cf5bd9fe20c649297375.tar.gz
open-keychain-e01c99a193528df717d5cf5bd9fe20c649297375.tar.bz2
open-keychain-e01c99a193528df717d5cf5bd9fe20c649297375.zip
make loading of drawer items a bit more dynamic
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui')
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java27
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java6
2 files changed, 14 insertions, 19 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java
index 985f6c309..f01e67449 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java
@@ -30,9 +30,8 @@ import android.support.v7.app.ActionBarActivity;
import android.view.*;
import android.widget.*;
import com.beardedhen.androidbootstrap.FontAwesomeText;
+import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.helper.ActionBarHelper;
-import org.sufficientlysecure.keychain.service.remote.RegisteredAppsListActivity;
public class DrawerActivity extends ActionBarActivity {
private DrawerLayout mDrawerLayout;
@@ -43,9 +42,6 @@ public class DrawerActivity extends ActionBarActivity {
private CharSequence mTitle;
private boolean mIsDrawerLocked = false;
- private static Class[] mItemsClass = new Class[]{KeyListActivity.class,
- EncryptActivity.class, DecryptActivity.class, ImportKeysActivity.class,
- RegisteredAppsListActivity.class};
private Class mSelectedItem;
private static final int MENU_ID_PREFERENCE = 222;
@@ -102,7 +98,7 @@ public class DrawerActivity extends ActionBarActivity {
public void onDrawerClosed(View view) {
getSupportActionBar().setTitle(mTitle);
- callIntentForSelectedItem();
+ callIntentForDrawerItem(mSelectedItem);
}
public void onDrawerOpened(View drawerView) {
@@ -112,11 +108,10 @@ public class DrawerActivity extends ActionBarActivity {
supportInvalidateOptionsMenu();
}
};
+
if ( !mIsDrawerLocked ) {
mDrawerLayout.setDrawerListener(mDrawerToggle);
- }
-
- if ( mIsDrawerLocked ) {
+ } else {
// If the drawer is locked open make it un-focusable
// so that it doesn't consume all the Back button presses
mDrawerLayout.setFocusableInTouchMode(false);
@@ -126,16 +121,20 @@ public class DrawerActivity extends ActionBarActivity {
// }
}
- private void callIntentForSelectedItem() {
+ /**
+ * Uses startActivity to call the Intent of the given class
+ * @param drawerItem the class of the drawer item you want to load. Based on Constants.DrawerItems.*
+ */
+ public void callIntentForDrawerItem(Class drawerItem) {
// creates call to onPrepareOptionsMenu()
supportInvalidateOptionsMenu();
// call intent activity if selected
- if (mSelectedItem != null) {
+ if (drawerItem != null) {
finish();
overridePendingTransition(0, 0);
- Intent intent = new Intent(this, mSelectedItem);
+ Intent intent = new Intent(this, drawerItem);
startActivity(intent);
// disable animation of activity start
@@ -214,7 +213,7 @@ public class DrawerActivity extends ActionBarActivity {
// update selected item and title, then close the drawer
mDrawerList.setItemChecked(position, true);
// set selected class
- mSelectedItem = mItemsClass[position];
+ mSelectedItem = Constants.DrawerItems.ARRAY[position];
// setTitle(mDrawerTitles[position]);
// If drawer isn't locked just close the drawer and
@@ -223,7 +222,7 @@ public class DrawerActivity extends ActionBarActivity {
mDrawerLayout.closeDrawer(mDrawerList);
// else move to the selected item yourself
} else {
- callIntentForSelectedItem();
+ callIntentForDrawerItem(mSelectedItem);
}
}
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java
index 57709350e..06df6f12d 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java
@@ -53,11 +53,7 @@ public class KeyListActivity extends DrawerActivity {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_key_list_import:
-
- overridePendingTransition(0, 0);
- Intent intentImport = new Intent(this, ImportKeysActivity.class);
- startActivityForResult(intentImport, 0);
- overridePendingTransition(0, 0);
+ callIntentForDrawerItem(Constants.DrawerItems.IMPORT_KEYS);
return true;
case R.id.menu_key_list_export: