improve behavior when changing the theme
This commit is contained in:
@@ -42,6 +42,7 @@ using keepass2android.search;
|
|||||||
using keepass2android_appSdkStyle;
|
using keepass2android_appSdkStyle;
|
||||||
using KeeTrayTOTP.Libraries;
|
using KeeTrayTOTP.Libraries;
|
||||||
using AndroidX.AppCompat.Widget;
|
using AndroidX.AppCompat.Widget;
|
||||||
|
using Google.Android.Material.Dialog;
|
||||||
using SearchView = AndroidX.AppCompat.Widget.SearchView;
|
using SearchView = AndroidX.AppCompat.Widget.SearchView;
|
||||||
|
|
||||||
namespace keepass2android
|
namespace keepass2android
|
||||||
@@ -273,7 +274,11 @@ namespace keepass2android
|
|||||||
protected override void OnResume()
|
protected override void OnResume()
|
||||||
{
|
{
|
||||||
base.OnResume();
|
base.OnResume();
|
||||||
_design.ReapplyTheme();
|
if (IsFinishing)
|
||||||
|
{
|
||||||
|
//can happen e.g. after theme change
|
||||||
|
return;
|
||||||
|
}
|
||||||
AppTask.StartInGroupActivity(this);
|
AppTask.StartInGroupActivity(this);
|
||||||
AppTask.SetupGroupBaseActivityButtons(this);
|
AppTask.SetupGroupBaseActivityButtons(this);
|
||||||
|
|
||||||
@@ -300,7 +305,7 @@ namespace keepass2android
|
|||||||
RunOnUiThread(() =>
|
RunOnUiThread(() =>
|
||||||
{
|
{
|
||||||
var listView = FragmentManager?.FindFragmentById<GroupListFragment>(Resource.Id.list_fragment)
|
var listView = FragmentManager?.FindFragmentById<GroupListFragment>(Resource.Id.list_fragment)
|
||||||
.ListView;
|
?.ListView;
|
||||||
if (listView != null)
|
if (listView != null)
|
||||||
{
|
{
|
||||||
int count = listView.Count;
|
int count = listView.Count;
|
||||||
@@ -510,7 +515,7 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
_design.ApplyTheme();
|
_design.ApplyTheme();
|
||||||
base.OnCreate(savedInstanceState);
|
base.OnCreate(savedInstanceState);
|
||||||
|
|
||||||
Android.Util.Log.Debug("KP2A", "Creating GBA");
|
Android.Util.Log.Debug("KP2A", "Creating GBA");
|
||||||
|
|
||||||
AppTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent);
|
AppTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent);
|
||||||
|
|||||||
@@ -47,9 +47,6 @@ namespace keepass2android
|
|||||||
|
|
||||||
public void ApplyTheme()
|
public void ApplyTheme()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_currentThemeId = NightModePreference;
|
_currentThemeId = NightModePreference;
|
||||||
AppCompatDelegate.DefaultNightMode = _currentThemeId.Value;
|
AppCompatDelegate.DefaultNightMode = _currentThemeId.Value;
|
||||||
_secureWindow = SecureWindowPref();
|
_secureWindow = SecureWindowPref();
|
||||||
@@ -66,7 +63,8 @@ namespace keepass2android
|
|||||||
if (newTheme != _currentThemeId)
|
if (newTheme != _currentThemeId)
|
||||||
{
|
{
|
||||||
Kp2aLog.Log("recreating due to theme change.");
|
Kp2aLog.Log("recreating due to theme change.");
|
||||||
_activity.Recreate();
|
_activity.Recreate();
|
||||||
|
_activity.Finish(); //withouth this, we'll have two GroupActivities on the backstack afterwards
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +74,7 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
Kp2aLog.Log("recreating due to icon set change.");
|
Kp2aLog.Log("recreating due to icon set change.");
|
||||||
_activity.Recreate();
|
_activity.Recreate();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +82,7 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
Kp2aLog.Log("recreating due to secure window change.");
|
Kp2aLog.Log("recreating due to secure window change.");
|
||||||
_activity.Recreate();
|
_activity.Recreate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -535,7 +535,12 @@ namespace keepass2android
|
|||||||
var displayPrefScreen = ((PreferenceScreen)FindPreference(GetString(Resource.String.display_prefs_key)));
|
var displayPrefScreen = ((PreferenceScreen)FindPreference(GetString(Resource.String.display_prefs_key)));
|
||||||
PrepareNoDonationReminderPreference(Activity, displayPrefScreen, FindPreference(GetString(Resource.String.NoDonationReminder_key)));
|
PrepareNoDonationReminderPreference(Activity, displayPrefScreen, FindPreference(GetString(Resource.String.NoDonationReminder_key)));
|
||||||
|
|
||||||
FindPreference(GetString(Resource.String.design_key)).PreferenceChange += (sender, args) => Activity.Recreate();
|
FindPreference(GetString(Resource.String.design_key)).PreferenceChange += (sender, args) =>
|
||||||
|
{
|
||||||
|
//it would be nicer to recreate, but that - for some reason - causes GroupActivity to be twice on the backstack afterwards :-(
|
||||||
|
//So better finish here.
|
||||||
|
Activity.Finish();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
displayPrefScreen.RemovePreference(unlockedNotificationPref);
|
displayPrefScreen.RemovePreference(unlockedNotificationPref);
|
||||||
@@ -1192,6 +1197,8 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
private ActivityDesign _design;
|
private ActivityDesign _design;
|
||||||
|
|
||||||
|
public static bool BeingRecreated = false;
|
||||||
|
|
||||||
public AppSettingsActivity()
|
public AppSettingsActivity()
|
||||||
{
|
{
|
||||||
_design = new ActivityDesign(this);
|
_design = new ActivityDesign(this);
|
||||||
|
|||||||
@@ -159,11 +159,6 @@ namespace keepass2android
|
|||||||
settingsFragmentManager = new SettingsFragmentManager(this);
|
settingsFragmentManager = new SettingsFragmentManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Launch(Context ctx)
|
|
||||||
{
|
|
||||||
ctx.StartActivity(new Intent(ctx, typeof(AppSettingsActivity)));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnCreate(Bundle savedInstanceState)
|
protected override void OnCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
_design.ApplyTheme();
|
_design.ApplyTheme();
|
||||||
|
|||||||
Reference in New Issue
Block a user