Light and dark themes for the launcher and settings

This commit is contained in:
RetrogisusDEV 2024-01-17 09:18:10 -04:00 committed by Jules Aguillon
parent b3dcd61c28
commit a55506e607
6 changed files with 12 additions and 15 deletions

View File

@ -7,12 +7,12 @@
</intent-filter>
<meta-data android:name="android.view.im" android:resource="@xml/method"/>
</service>
<activity android:name="juloo.keyboard2.SettingsActivity" android:icon="@mipmap/ic_launcher" android:label="@string/settings_activity_label" android:theme="@style/android:Theme.DeviceDefault" android:exported="true" android:directBootAware="true">
<activity android:name="juloo.keyboard2.SettingsActivity" android:icon="@mipmap/ic_launcher" android:label="@string/settings_activity_label" android:theme="@style/appTheme" android:exported="true" android:directBootAware="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<activity android:name="juloo.keyboard2.LauncherActivity" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/android:Theme.DeviceDefault" android:exported="true" android:directBootAware="true">
<activity android:name="juloo.keyboard2.LauncherActivity" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/appTheme" android:exported="true" android:directBootAware="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="appTheme" parent="@android:style/Theme.Material"/>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="appTheme" parent="@android:style/Theme.Material.Light"/>
</resources>

View File

@ -22,4 +22,5 @@
<item name="android:layout_marginHorizontal">16dp</item>
<item name="android:layout_gravity">center</item>
</style>
<style name="appTheme" parent="@android:style/Theme.DeviceDefault.DayNight"/>
</resources>

View File

@ -25,6 +25,7 @@ public class LauncherActivity extends Activity
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.launcher_activity);
_intro_video = (VideoView)findViewById(R.id.launcher_intro_video);

View File

@ -12,7 +12,6 @@ public class SettingsActivity extends PreferenceActivity
@Override
public void onCreate(Bundle savedInstanceState)
{
detectSystemTheme();
super.onCreate(savedInstanceState);
// The preferences can't be read when in direct-boot mode. Avoid crashing
// and don't allow changing the settings.
@ -26,18 +25,6 @@ public class SettingsActivity extends PreferenceActivity
addPreferencesFromResource(R.xml.settings);
}
/** The default theme is [Theme.DeviceDefault], which is dark. Detect if the
system is using light theme. */
void detectSystemTheme()
{
if (Build.VERSION.SDK_INT >= 14)
{
int ui_mode = getResources().getConfiguration().uiMode;
if ((ui_mode & Configuration.UI_MODE_NIGHT_NO) != 0)
setTheme(android.R.style.Theme_DeviceDefault_Light);
}
}
void fallbackEncrypted()
{
// Can't communicate with the user here.