restart app after theme change

This commit is contained in:
Kyle Spearrin 2019-05-29 23:02:30 -04:00
parent 6e91d66b2c
commit cc8b8f9ceb
6 changed files with 47 additions and 4 deletions

View file

@ -99,7 +99,7 @@ namespace Bit.Droid
}
else if(message.Command == "updatedTheme")
{
Recreate();
RestartApp();
}
});
}
@ -273,5 +273,15 @@ namespace Bit.Droid
SetTheme(Resource.Style.MainTheme);
}
}
private void RestartApp()
{
var intent = new Intent(this, typeof(SplashActivity));
var pendingIntent = PendingIntent.GetActivity(this, 5923650, intent, PendingIntentFlags.CancelCurrent);
var alarmManager = GetSystemService(AlarmService) as AlarmManager;
var triggerMs = Java.Lang.JavaSystem.CurrentTimeMillis() + 500;
alarmManager.Set(AlarmType.Rtc, triggerMs, pendingIntent);
Java.Lang.JavaSystem.Exit(0);
}
}
}

View file

@ -86,8 +86,9 @@
StyleClass="box-value" />
</StackLayout>
<Label
StyleClass="box-footer-label"
Text="{u:I18n ThemeDescription}"
StyleClass="box-footer-label" />
x:Name="_themeDescriptionLabel" />
</StackLayout>
</StackLayout>
</ScrollView>

View file

@ -1,4 +1,5 @@
using System;
using Bit.App.Resources;
using System;
using Xamarin.Forms;
namespace Bit.App.Pages
@ -15,6 +16,11 @@ namespace Bit.App.Pages
_themePicker.ItemDisplayBinding = new Binding("Value");
_uriMatchPicker.ItemDisplayBinding = new Binding("Value");
_clearClipboardPicker.ItemDisplayBinding = new Binding("Value");
if(Device.RuntimePlatform == Device.Android)
{
_themeDescriptionLabel.Text = string.Concat(_themeDescriptionLabel.Text, " ",
AppResources.RestartIsRequired);
}
}
protected async override void OnAppearing()

View file

@ -177,7 +177,8 @@ namespace Bit.App.Pages
await _storageService.SaveAsync(Constants.ThemeKey, theme);
if(Device.RuntimePlatform == Device.Android)
{
await _deviceActionService.ShowLoadingAsync(AppResources.Saving);
await _deviceActionService.ShowLoadingAsync(AppResources.Restarting);
await Task.Delay(1000);
}
_messagingService.Send("updatedTheme", theme);
}

View file

@ -3057,6 +3057,24 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Restarting....
/// </summary>
public static string Restarting {
get {
return ResourceManager.GetString("Restarting", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Restart is required..
/// </summary>
public static string RestartIsRequired {
get {
return ResourceManager.GetString("RestartIsRequired", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Re-type Master Password.
/// </summary>

View file

@ -1557,4 +1557,11 @@
<data name="ThemeDescription" xml:space="preserve">
<value>Change the application's color theme.</value>
</data>
<data name="RestartIsRequired" xml:space="preserve">
<value>Restart is required.</value>
<comment>Referring to restarting the application.</comment>
</data>
<data name="Restarting" xml:space="preserve">
<value>Restarting...</value>
</data>
</root>