diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java index 91e50637e..a26df556d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java @@ -37,7 +37,6 @@ public class ActionBarHelper { * @param activity */ public static void setBackButton(ActionBarActivity activity) { - // set actionbar without home button if called from another app final ActionBar actionBar = activity.getSupportActionBar(); Log.d(Constants.TAG, "calling package (only set when using startActivityForResult)=" + activity.getCallingPackage()); 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 c0fd53007..985f6c309 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 @@ -21,18 +21,17 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.res.Configuration; +import android.graphics.Color; import android.os.Bundle; import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarActivity; import android.view.*; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.ListView; -import android.widget.TextView; +import android.widget.*; import com.beardedhen.androidbootstrap.FontAwesomeText; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.ActionBarHelper; import org.sufficientlysecure.keychain.service.remote.RegisteredAppsListActivity; public class DrawerActivity extends ActionBarActivity { @@ -42,6 +41,7 @@ public class DrawerActivity extends ActionBarActivity { private CharSequence mDrawerTitle; private CharSequence mTitle; + private boolean mIsDrawerLocked = false; private static Class[] mItemsClass = new Class[]{KeyListActivity.class, EncryptActivity.class, DecryptActivity.class, ImportKeysActivity.class, @@ -55,10 +55,22 @@ public class DrawerActivity extends ActionBarActivity { mDrawerTitle = getString(R.string.app_name); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); + ViewGroup viewGroup = (ViewGroup) findViewById(R.id.content_frame); + int leftMarginLoaded = ((ViewGroup.MarginLayoutParams) viewGroup.getLayoutParams()).leftMargin; + int leftMarginInTablets = (int) getResources().getDimension(R.dimen.drawer_size); + int errorInMarginAllowed = 5; - // set a custom shadow that overlays the main content when the drawer - // opens - mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); + // if the left margin of the loaded layout is close to the + // one used in tablets then set drawer as open and locked + if( Math.abs(leftMarginLoaded - leftMarginInTablets) < errorInMarginAllowed) { + mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerList); + mDrawerLayout.setScrimColor(Color.TRANSPARENT); + mIsDrawerLocked = true; + } else { + // set a custom shadow that overlays the main content when the drawer opens + mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); + mIsDrawerLocked = false; + } NavItem mItemIconTexts[] = new NavItem[]{ new NavItem("fa-user", getString(R.string.nav_contacts)), @@ -73,8 +85,11 @@ public class DrawerActivity extends ActionBarActivity { mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // enable ActionBar app icon to behave as action to toggle nav drawer - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setHomeButtonEnabled(true); + // if the drawer is not locked + if ( !mIsDrawerLocked ) { + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeButtonEnabled(true); + } // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon @@ -86,19 +101,8 @@ public class DrawerActivity extends ActionBarActivity { ) { public void onDrawerClosed(View view) { getSupportActionBar().setTitle(mTitle); - // creates call to onPrepareOptionsMenu() - supportInvalidateOptionsMenu(); - // call intent activity if selected - if (mSelectedItem != null) { - finish(); - overridePendingTransition(0, 0); - - Intent intent = new Intent(DrawerActivity.this, mSelectedItem); - startActivity(intent); - // disable animation of activity start - overridePendingTransition(0, 0); - } + callIntentForSelectedItem(); } public void onDrawerOpened(View drawerView) { @@ -108,13 +112,37 @@ public class DrawerActivity extends ActionBarActivity { supportInvalidateOptionsMenu(); } }; - mDrawerLayout.setDrawerListener(mDrawerToggle); + if ( !mIsDrawerLocked ) { + mDrawerLayout.setDrawerListener(mDrawerToggle); + } + if ( mIsDrawerLocked ) { + // If the drawer is locked open make it un-focusable + // so that it doesn't consume all the Back button presses + mDrawerLayout.setFocusableInTouchMode(false); + } // if (savedInstanceState == null) { // selectItem(0); // } } + private void callIntentForSelectedItem() { + // creates call to onPrepareOptionsMenu() + supportInvalidateOptionsMenu(); + + // call intent activity if selected + if (mSelectedItem != null) { + finish(); + overridePendingTransition(0, 0); + + Intent intent = new Intent(this, mSelectedItem); + startActivity(intent); + + // disable animation of activity start + overridePendingTransition(0, 0); + } + } + @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(42, MENU_ID_PREFERENCE, 100, R.string.menu_preferences); @@ -185,10 +213,18 @@ public class DrawerActivity extends ActionBarActivity { private void selectItem(int position) { // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); - // setTitle(mDrawerTitles[position]); - mDrawerLayout.closeDrawer(mDrawerList); // set selected class mSelectedItem = mItemsClass[position]; + + // setTitle(mDrawerTitles[position]); + // If drawer isn't locked just close the drawer and + // it will move to the selected item by itself (via drawer toggle listener) + if ( !mIsDrawerLocked ) { + mDrawerLayout.closeDrawer(mDrawerList); + // else move to the selected item yourself + } else { + callIntentForSelectedItem(); + } } /** 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 5ff4dbdeb..57709350e 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,8 +53,11 @@ 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); return true; case R.id.menu_key_list_export: diff --git a/OpenPGP-Keychain/src/main/res/layout-large/api_apps_list_activity.xml b/OpenPGP-Keychain/src/main/res/layout-large/api_apps_list_activity.xml new file mode 100644 index 000000000..c0021261e --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout-large/api_apps_list_activity.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout-large/decrypt_activity.xml b/OpenPGP-Keychain/src/main/res/layout-large/decrypt_activity.xml new file mode 100644 index 000000000..26aed0831 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout-large/decrypt_activity.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout-large/encrypt_activity.xml b/OpenPGP-Keychain/src/main/res/layout-large/encrypt_activity.xml new file mode 100644 index 000000000..7d0d44074 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout-large/encrypt_activity.xml @@ -0,0 +1,19 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout-large/import_keys_activity.xml b/OpenPGP-Keychain/src/main/res/layout-large/import_keys_activity.xml new file mode 100644 index 000000000..2cb408441 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout-large/import_keys_activity.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout-large/key_list_activity.xml b/OpenPGP-Keychain/src/main/res/layout-large/key_list_activity.xml new file mode 100644 index 000000000..6636f12ff --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout-large/key_list_activity.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/api_apps_list_activity.xml b/OpenPGP-Keychain/src/main/res/layout/api_apps_list_activity.xml index 71fbcfb12..9f95e9f3b 100644 --- a/OpenPGP-Keychain/src/main/res/layout/api_apps_list_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/api_apps_list_activity.xml @@ -4,16 +4,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" > - - - - + diff --git a/OpenPGP-Keychain/src/main/res/layout/api_apps_list_content.xml b/OpenPGP-Keychain/src/main/res/layout/api_apps_list_content.xml new file mode 100644 index 000000000..b8606b929 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/api_apps_list_content.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml index 25c7c000c..c4709a67e 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml @@ -5,206 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_content.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_content.xml new file mode 100644 index 000000000..a847d9e46 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_content.xml @@ -0,0 +1,205 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/drawer_list.xml b/OpenPGP-Keychain/src/main/res/layout/drawer_list.xml index 81ceba20c..ab00c0073 100644 --- a/OpenPGP-Keychain/src/main/res/layout/drawer_list.xml +++ b/OpenPGP-Keychain/src/main/res/layout/drawer_list.xml @@ -9,7 +9,7 @@ --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml new file mode 100644 index 000000000..d6a05f0d4 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml @@ -0,0 +1,398 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/import_keys_activity.xml b/OpenPGP-Keychain/src/main/res/layout/import_keys_activity.xml index d7794ace3..b11f99757 100644 --- a/OpenPGP-Keychain/src/main/res/layout/import_keys_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/import_keys_activity.xml @@ -5,58 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" > - - - - - - - - - - - - - - - - - - - + diff --git a/OpenPGP-Keychain/src/main/res/layout/import_keys_content.xml b/OpenPGP-Keychain/src/main/res/layout/import_keys_content.xml new file mode 100644 index 000000000..fae8147e5 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/import_keys_content.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/key_list_activity.xml b/OpenPGP-Keychain/src/main/res/layout/key_list_activity.xml index 65d246d7b..fcb376fa8 100644 --- a/OpenPGP-Keychain/src/main/res/layout/key_list_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/key_list_activity.xml @@ -4,16 +4,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" > - - - - + diff --git a/OpenPGP-Keychain/src/main/res/layout/key_list_content.xml b/OpenPGP-Keychain/src/main/res/layout/key_list_content.xml new file mode 100644 index 000000000..e58e42961 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/key_list_content.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/values-large/dimens.xml b/OpenPGP-Keychain/src/main/res/values-large/dimens.xml new file mode 100644 index 000000000..192a4bb99 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/values-large/dimens.xml @@ -0,0 +1,4 @@ + + + 240dp + diff --git a/OpenPGP-Keychain/src/main/res/values/dimens.xml b/OpenPGP-Keychain/src/main/res/values/dimens.xml new file mode 100644 index 000000000..e1a7749f0 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ + + + 240dp + 0dp + \ No newline at end of file