From 9958f73926f6122e126bd4328b2c29a9fd8e08f1 Mon Sep 17 00:00:00 2001 From: Alexander Bakker Date: Wed, 15 May 2019 22:01:00 +0200 Subject: [PATCH] Set the Activity theme before calling super.onCreate (#84) This fixes a NullPointerException that would occur when restoring from savedInstanceState due to getSupportActionBar returning null. It also removes the theme definitions from AndroidManifest as we override those anyway. --- app/src/main/AndroidManifest.xml | 16 +++++----------- .../beemdevelopment/aegis/ui/AegisActivity.java | 8 ++++---- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1d358590..aa37da4d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,15 +19,13 @@ tools:replace="android:theme"> + android:label="Select entries" /> - @@ -35,12 +33,10 @@ android:name=".ui.ScannerActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:label="Scan a QR code" - android:screenOrientation="portrait" - android:theme="@style/AppTheme.Fullscreen" /> + android:screenOrientation="portrait" /> + android:label="Edit profile" /> @@ -48,12 +44,10 @@ + android:label="Manage key slots" /> + android:label="Manage groups" /> \ No newline at end of file diff --git a/app/src/main/java/com/beemdevelopment/aegis/ui/AegisActivity.java b/app/src/main/java/com/beemdevelopment/aegis/ui/AegisActivity.java index 316250ca..f0dedab6 100644 --- a/app/src/main/java/com/beemdevelopment/aegis/ui/AegisActivity.java +++ b/app/src/main/java/com/beemdevelopment/aegis/ui/AegisActivity.java @@ -20,9 +20,12 @@ public abstract class AegisActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); _app = (AegisApplication) getApplication(); + // set the theme and create the activity + setPreferredTheme(Theme.fromInteger(getPreferences().getCurrentTheme())); + super.onCreate(savedInstanceState); + // if the app was killed, relaunch MainActivity and close everything else if (!(this instanceof MainActivity) && !(this instanceof AuthActivity) && _app.getDatabaseManager().isLocked()) { Intent intent = new Intent(this, MainActivity.class); @@ -37,9 +40,6 @@ public abstract class AegisActivity extends AppCompatActivity { getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); } - // set the theme - setPreferredTheme(getPreferences().getCurrentTheme()); - // apply a dirty hack to make progress bars work even if animations are disabled setGlobalAnimationDurationScale(); }