-
Notifications
You must be signed in to change notification settings - Fork 0
/
SystemThemeListPreference.cs
40 lines (33 loc) · 1.41 KB
/
SystemThemeListPreference.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Android.Content;
using Android.Util;
using AndroidX.Preference;
namespace com.companyname.NavigationGraph6
{
public class SystemThemeListPreference : ListPreference
{
internal readonly string DefaultSystemThemeValue = "Android 10, 11 - use Quick Settings Theme button";
internal string[] themeEntries = { "System Default", "Light", "Dark" };
internal string[] themeValues = { "1", "2", "3" }; // equivelent to UiNightMode.Auto, No and Yes, we manipulate it and subtract 1 to match 0,1,2 instead of 1,2,3
#region Ctors
public SystemThemeListPreference(Context context) : base(context, null)
{
}
public SystemThemeListPreference(Context context, IAttributeSet attrs) : base(context, attrs)
{
}
#endregion
#region Init
public void Init()
{
// This is called from the SettingsFragment, just to update the Summary. It wont be called again each time OnCreateDialogview is called.
// Therefore we need to call FindIndexByValue again in OnCreateDialogView
SetEntries(themeEntries);
SetEntryValues(themeValues);
if (!string.IsNullOrEmpty(Value))
Summary = themeEntries[FindIndexOfValue(Value)]; // Get the current theme
else
Summary = DefaultSystemThemeValue;
}
#endregion
}
}