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.
pull/79/head
Alexander Bakker 6 years ago committed by Michael Schättgen
parent 0fb33744ae
commit 9958f73926

@ -19,15 +19,13 @@
tools:replace="android:theme">
<activity
android:name=".ui.SelectEntriesActivity"
android:label="Select entries"
android:theme="@style/AppTheme.TransparentActionBar"></activity>
android:label="Select entries" />
<activity
android:name=".ui.MainActivity"
android:label="${title}"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
@ -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" />
<activity
android:name=".ui.EditEntryActivity"
android:label="Edit profile"
android:theme="@style/AppTheme.NoActionBar" />
android:label="Edit profile" />
<activity
android:name=".ui.IntroActivity"
android:theme="@style/Theme.Intro" />
@ -48,12 +44,10 @@
<activity android:name=".ui.PreferencesActivity" />
<activity
android:name=".ui.SlotManagerActivity"
android:label="Manage key slots"
android:theme="@style/AppTheme.TransparentActionBar" />
android:label="Manage key slots" />
<activity
android:name=".ui.GroupManagerActivity"
android:label="Manage groups"
android:theme="@style/AppTheme.TransparentActionBar" />
android:label="Manage groups" />
</application>
</manifest>

@ -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();
}

Loading…
Cancel
Save