SetupWizard: Add step for changing theme
Change-Id: Ib28e752583926e9740dd7e954d208d4fe62e3c08
This commit is contained in:
committed by
Michael Bestas
parent
04c9f463d5
commit
554f63530a
@@ -292,6 +292,19 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".ThemeSettingsActivity"
|
||||
android:label="@string/activity_label_empty"
|
||||
android:excludeFromRecents="true"
|
||||
android:configChanges="mcc|mnc"
|
||||
android:immersive="true"
|
||||
android:exported="true"
|
||||
android:windowSoftInputMode="stateAlwaysHidden">
|
||||
<intent-filter>
|
||||
<action android:name="org.lineageos.setupwizard.THEME_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".FinishActivity"
|
||||
android:label="@string/activity_label_empty"
|
||||
android:excludeFromRecents="true"
|
||||
|
25
res/drawable/ic_theme.xml
Normal file
25
res/drawable/ic_theme.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (c) 2019 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/black"
|
||||
android:pathData="M4,2v9c0,1.65 1.35,3 3,3h2v6c0,1.1 0.9,2 2,2h2c1.1,0 2,-0.9 2,-2v-6h2c1.65,0 3,-1.35 3,-3V2C20,2 4,2 4,2zM11,20v-6h2v6H11zM18,11c0,0.55 -0.45,1 -1,1h-2H9H7c-0.55,0 -1,-0.45 -1,-1v-0.93h12V11zM18,8.07H6V4h2.81v2.15h2V4h2.38v2.15h2V4H18V8.07z"/>
|
||||
</vector>
|
67
res/layout/setup_theme.xml
Normal file
67
res/layout/setup_theme.xml
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2023 The LineageOS Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.setupdesign.GlifLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/setup_wizard_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
style="@style/SudContentFrame"
|
||||
android:layout_marginTop="@dimen/base_margin_top">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/page"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/theme_radio_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radio_dark"
|
||||
android:text="@string/dark"
|
||||
style="@style/SudRadioButton" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radio_light"
|
||||
android:text="@string/light"
|
||||
style="@style/SudRadioButton" />
|
||||
|
||||
</RadioGroup>
|
||||
</ScrollView>
|
||||
</FrameLayout>
|
||||
|
||||
<org.lineageos.setupwizard.NavigationLayout
|
||||
android:id="@+id/navigation_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
</com.google.android.setupdesign.GlifLayout>
|
@@ -69,6 +69,10 @@
|
||||
</WizardAction>
|
||||
|
||||
<WizardAction wizard:uri="intent:#Intent;action=org.lineageos.setupwizard.LINEAGE_RESTORE_BACKUP;end" id="restore">
|
||||
<result wizard:action="theme_settings" />
|
||||
</WizardAction>
|
||||
|
||||
<WizardAction wizard:uri="intent:#Intent;action=org.lineageos.setupwizard.THEME_SETTINGS;end" id="theme_settings">
|
||||
<result wizard:action="navigation_settings" />
|
||||
</WizardAction>
|
||||
|
||||
|
@@ -36,6 +36,10 @@
|
||||
</WizardAction>
|
||||
|
||||
<WizardAction wizard:uri="intent:#Intent;action=org.lineageos.setupwizard.LINEAGE_RESTORE_BACKUP;end" id="restore">
|
||||
<result wizard:action="theme_settings" />
|
||||
</WizardAction>
|
||||
|
||||
<WizardAction wizard:uri="intent:#Intent;action=org.lineageos.setupwizard.THEME_SETTINGS;end" id="theme_settings">
|
||||
<result wizard:action="navigation_settings" />
|
||||
</WizardAction>
|
||||
|
||||
|
@@ -122,6 +122,9 @@
|
||||
<result wizard:action="lineage_settings" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;package=org.lineageos.setupwizard;action=org.lineageos.setupwizard.LINEAGE_SETTINGS;end" id="lineage_settings">
|
||||
<result wizard:action="theme_settings" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;package=org.lineageos.setupwizard;action=org.lineageos.setupwizard.THEME_SETTINGS;end" id="theme_settings">
|
||||
<result wizard:action="navigation_settings" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;package=org.lineageos.setupwizard;action=org.lineageos.setupwizard.NAVIGATION_SETTINGS;end" id="navigation_settings">
|
||||
|
@@ -100,4 +100,10 @@
|
||||
|
||||
<!-- Assisted GPS -->
|
||||
<string name="location_agps_access_summary">When location is on, <b>download satellite assistance data from the internet</b>, which can greatly improve the GPS startup performance.</string>
|
||||
|
||||
<!-- Theme page -->
|
||||
<string name="setup_theme">Theme</string>
|
||||
<string name="theme_summary">Dark theme uses a black background to help keep battery alive longer on some screens</string>
|
||||
<string name="dark">Dark</string>
|
||||
<string name="light">Light</string>
|
||||
</resources>
|
||||
|
65
src/org/lineageos/setupwizard/ThemeSettingsActivity.java
Normal file
65
src/org/lineageos/setupwizard/ThemeSettingsActivity.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2023 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.lineageos.setupwizard;
|
||||
|
||||
import android.app.UiModeManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class ThemeSettingsActivity extends BaseSetupWizardActivity {
|
||||
public static final String TAG = ThemeSettingsActivity.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getGlifLayout().setDescriptionText(getString(R.string.theme_summary));
|
||||
|
||||
UiModeManager uiModeManager = getSystemService(UiModeManager.class);
|
||||
final RadioGroup radioGroup = findViewById(R.id.theme_radio_group);
|
||||
radioGroup.check(((getResources().getConfiguration().uiMode
|
||||
& Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES)
|
||||
? R.id.radio_dark : R.id.radio_light);
|
||||
radioGroup.setOnCheckedChangeListener((group, checkedId) -> {
|
||||
switch (checkedId) {
|
||||
case R.id.radio_dark:
|
||||
uiModeManager.setNightModeActivated(true);
|
||||
break;
|
||||
case R.id.radio_light:
|
||||
uiModeManager.setNightModeActivated(false);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.setup_theme;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getTitleResId() {
|
||||
return R.string.setup_theme;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getIconResId() {
|
||||
return R.drawable.ic_theme;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user