diff --git a/OpenKeychain/src/main/java/android/support/v4/widget/FixedDrawerLayout.java b/OpenKeychain/src/main/java/android/support/v4/widget/FixedDrawerLayout.java new file mode 100644 index 000000000..1151818b6 --- /dev/null +++ b/OpenKeychain/src/main/java/android/support/v4/widget/FixedDrawerLayout.java @@ -0,0 +1,33 @@ +package android.support.v4.widget; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.View; + +/** + * Fix for NullPointerException at android.support.v4.widget.DrawerLayout.isContentView(DrawerLayout.java:840) + *

+ * http://stackoverflow.com/a/18107942 + */ +public class FixedDrawerLayout extends DrawerLayout { + public FixedDrawerLayout(Context context) { + super(context); + } + + public FixedDrawerLayout(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public FixedDrawerLayout(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + @Override + boolean isContentView(View child) { + if (child == null) { + return false; + } + return ((LayoutParams) child.getLayoutParams()).gravity == Gravity.NO_GRAVITY; + } +} 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 088f593d4..9a5050eba 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java @@ -26,6 +26,7 @@ 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.v4.widget.FixedDrawerLayout; import android.support.v7.app.ActionBarActivity; import android.view.LayoutInflater; import android.view.Menu; @@ -43,7 +44,7 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; public class DrawerActivity extends ActionBarActivity { - private DrawerLayout mDrawerLayout; + private FixedDrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBarDrawerToggle mDrawerToggle; @@ -58,7 +59,7 @@ public class DrawerActivity extends ActionBarActivity { protected void setupDrawerNavigation(Bundle savedInstanceState) { mDrawerTitle = getString(R.string.app_name); - mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); + mDrawerLayout = (FixedDrawerLayout) 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; diff --git a/OpenKeychain/src/main/res/layout-large/api_apps_list_activity.xml b/OpenKeychain/src/main/res/layout-large/api_apps_list_activity.xml index c0021261e..88686bbbc 100644 --- a/OpenKeychain/src/main/res/layout-large/api_apps_list_activity.xml +++ b/OpenKeychain/src/main/res/layout-large/api_apps_list_activity.xml @@ -4,7 +4,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > - - + diff --git a/OpenKeychain/src/main/res/layout-large/decrypt_activity.xml b/OpenKeychain/src/main/res/layout-large/decrypt_activity.xml index 26aed0831..9e9f37391 100644 --- a/OpenKeychain/src/main/res/layout-large/decrypt_activity.xml +++ b/OpenKeychain/src/main/res/layout-large/decrypt_activity.xml @@ -4,7 +4,7 @@ android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> - - + diff --git a/OpenKeychain/src/main/res/layout-large/encrypt_activity.xml b/OpenKeychain/src/main/res/layout-large/encrypt_activity.xml index 7d0d44074..355580fad 100644 --- a/OpenKeychain/src/main/res/layout-large/encrypt_activity.xml +++ b/OpenKeychain/src/main/res/layout-large/encrypt_activity.xml @@ -4,7 +4,7 @@ android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> - - + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout-large/key_list_activity.xml b/OpenKeychain/src/main/res/layout-large/key_list_activity.xml index 6636f12ff..6abbea13f 100644 --- a/OpenKeychain/src/main/res/layout-large/key_list_activity.xml +++ b/OpenKeychain/src/main/res/layout-large/key_list_activity.xml @@ -4,14 +4,14 @@ android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> - - + diff --git a/OpenKeychain/src/main/res/layout/api_apps_list_activity.xml b/OpenKeychain/src/main/res/layout/api_apps_list_activity.xml index 9f95e9f3b..df187e0a5 100644 --- a/OpenKeychain/src/main/res/layout/api_apps_list_activity.xml +++ b/OpenKeychain/src/main/res/layout/api_apps_list_activity.xml @@ -1,5 +1,5 @@ - @@ -8,4 +8,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/decrypt_activity.xml b/OpenKeychain/src/main/res/layout/decrypt_activity.xml index c4709a67e..94d82fe1d 100644 --- a/OpenKeychain/src/main/res/layout/decrypt_activity.xml +++ b/OpenKeychain/src/main/res/layout/decrypt_activity.xml @@ -1,5 +1,5 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/encrypt_activity.xml b/OpenKeychain/src/main/res/layout/encrypt_activity.xml index 6484c9b7b..65c2ee8fd 100644 --- a/OpenKeychain/src/main/res/layout/encrypt_activity.xml +++ b/OpenKeychain/src/main/res/layout/encrypt_activity.xml @@ -1,5 +1,5 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/key_list_activity.xml b/OpenKeychain/src/main/res/layout/key_list_activity.xml index fcb376fa8..c4c2c35cb 100644 --- a/OpenKeychain/src/main/res/layout/key_list_activity.xml +++ b/OpenKeychain/src/main/res/layout/key_list_activity.xml @@ -1,5 +1,5 @@ - @@ -8,4 +8,4 @@ - \ No newline at end of file + \ No newline at end of file