Orarend/OrarendAndroidApp/ActivityBase.cs
NorbiPeti e5915c8082 A/B hét javítva, 09.01-től számolja már, egyéb jav.
- Kódanalízis, biztonsági attribútumok
- Hibakezelés javítva (internethiba, stb.)
2017-09-24 21:45:05 +02:00

28 lines
No EOL
821 B
C#

using Android.App;
using Android.OS;
using Android.Preferences;
using System.Security;
namespace OrarendAndroidApp
{
public class ActivityBase : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetTheme(this);
}
public static void SetTheme(Activity activity)
{
var settings = PreferenceManager.GetDefaultSharedPreferences(activity);
bool darktheme = settings.GetBoolean("pref_theme", false);
if (activity is ActivityBase ab)
ab.DarkTheme = darktheme;
activity.SetTheme(darktheme ? Android.Resource.Style.ThemeDeviceDefault : Android.Resource.Style.ThemeDeviceDefaultLight);
}
public bool DarkTheme;
}
}