From 59f32c4fca48b226fc13b649a7f6a635aeaa9041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sat, 6 Sep 2014 16:36:58 +0200 Subject: [PATCH] Drawer nav method cleanup --- .../keychain/remote/ui/AppsListActivity.java | 2 +- .../org/sufficientlysecure/keychain/ui/DecryptActivity.java | 2 +- .../org/sufficientlysecure/keychain/ui/DrawerActivity.java | 6 +++++- .../sufficientlysecure/keychain/ui/EncryptFileActivity.java | 5 ++--- .../sufficientlysecure/keychain/ui/EncryptTextActivity.java | 5 ++--- .../org/sufficientlysecure/keychain/ui/KeyListActivity.java | 5 +---- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListActivity.java index 3fb166abd..11b0deb33 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListActivity.java @@ -30,7 +30,7 @@ public class AppsListActivity extends DrawerActivity { setContentView(R.layout.api_apps_list_activity); - setupDrawerNavigation(savedInstanceState); + activateDrawerNavigation(savedInstanceState); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java index 830b9a279..998412d0b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java @@ -67,7 +67,7 @@ public class DecryptActivity extends DrawerActivity { initView(); - setupDrawerNavigation(savedInstanceState); + activateDrawerNavigation(savedInstanceState); // Handle intent actions, maybe changes the bundles handleActions(getIntent()); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java index b9251cad1..9e82f48f4 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java @@ -56,7 +56,11 @@ public class DrawerActivity extends ActionBarActivity { private static final int MENU_ID_PREFERENCE = 222; private static final int MENU_ID_HELP = 223; - protected void setupDrawerNavigation(Bundle savedInstanceState) { + protected void deactivateDrawerNavigation() { + ((DrawerLayout) findViewById(R.id.drawer_layout)).setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); + } + + protected void activateDrawerNavigation(Bundle savedInstanceState) { mDrawerTitle = getString(R.string.app_name); mDrawerLayout = (FixedDrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileActivity.java index 0b37efd7a..8fc72ca89 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileActivity.java @@ -26,7 +26,6 @@ import android.os.Handler; import android.os.Message; import android.os.Messenger; import android.support.v4.app.Fragment; -import android.support.v4.widget.DrawerLayout; import android.view.Menu; import android.view.MenuItem; @@ -428,10 +427,10 @@ public class EncryptFileActivity extends DrawerActivity implements EncryptActivi // if called with an intent action, do not init drawer navigation if (ACTION_ENCRYPT_FILE.equals(getIntent().getAction())) { // lock drawer - ((DrawerLayout) findViewById(R.id.drawer_layout)).setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); + deactivateDrawerNavigation(); // TODO: back button to key? } else { - setupDrawerNavigation(savedInstanceState); + activateDrawerNavigation(savedInstanceState); } // Handle intent actions diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java index fb79a1ee9..d1bdfe14b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java @@ -26,7 +26,6 @@ import android.os.Handler; import android.os.Message; import android.os.Messenger; import android.support.v4.app.Fragment; -import android.support.v4.widget.DrawerLayout; import android.view.Menu; import android.view.MenuItem; @@ -396,10 +395,10 @@ public class EncryptTextActivity extends DrawerActivity implements EncryptActivi // if called with an intent action, do not init drawer navigation if (ACTION_ENCRYPT_TEXT.equals(getIntent().getAction())) { // lock drawer - ((DrawerLayout) findViewById(R.id.drawer_layout)).setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); + deactivateDrawerNavigation(); // TODO: back button to key? } else { - setupDrawerNavigation(savedInstanceState); + activateDrawerNavigation(savedInstanceState); } // Handle intent actions diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java index 67880fbff..65c4b8605 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java @@ -19,15 +19,12 @@ package org.sufficientlysecure.keychain.ui; import android.app.ProgressDialog; -import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.Message; import android.os.Messenger; -import android.util.AttributeSet; import android.view.Menu; import android.view.MenuItem; -import android.view.View; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; @@ -65,7 +62,7 @@ public class KeyListActivity extends DrawerActivity { setContentView(R.layout.key_list_activity); // now setup navigation drawer in DrawerActivity... - setupDrawerNavigation(savedInstanceState); + activateDrawerNavigation(savedInstanceState); } @Override