DeviceParts: switch to Material3
Change-Id: If8a127bc29f33f9901b1657ad75c91c2b6ac1fba
diff --git a/DeviceParts/Android.bp b/DeviceParts/Android.bp
index a82699f..2bed802 100644
--- a/DeviceParts/Android.bp
+++ b/DeviceParts/Android.bp
@@ -8,6 +8,7 @@
static_libs: [
"androidx.core_core",
"androidx.preference_preference",
+ "com.google.android.material_material",
"OmniLib",
],
diff --git a/DeviceParts/AndroidManifest.xml b/DeviceParts/AndroidManifest.xml
index 924a3a8..f282ebe 100644
--- a/DeviceParts/AndroidManifest.xml
+++ b/DeviceParts/AndroidManifest.xml
@@ -14,7 +14,7 @@
<application
android:icon="@drawable/ic_launcher"
android:label="@string/advanced_settings"
- android:theme="@style/Theme.AppTheme"
+ android:theme="@style/AppTheme"
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
tools:replace="android:appComponentFactory"
android:supportsRtl="true" >
@@ -30,7 +30,6 @@
<activity
android:name="org.omnirom.device.DeviceSettingsActivity"
android:exported="false"
- android:label="@string/advanced_settings"
android:launchMode="singleTask" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -40,7 +39,6 @@
<activity-alias
android:name="org.omnirom.device.DeviceSettings"
android:exported="true"
- android:label="@string/advanced_settings"
android:targetActivity="DeviceSettingsActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
diff --git a/DeviceParts/res/layout/settings_activity.xml b/DeviceParts/res/layout/settings_activity.xml
new file mode 100644
index 0000000..aa6001a
--- /dev/null
+++ b/DeviceParts/res/layout/settings_activity.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/windowBackground">
+
+ <com.google.android.material.appbar.AppBarLayout
+ android:id="@+id/app_bar_layout"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:fitsSystemWindows="true">
+
+ <com.google.android.material.appbar.MaterialToolbar
+ android:id="@+id/toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ android:background="@color/windowBackground"/>
+
+ </com.google.android.material.appbar.AppBarLayout>
+
+ <FrameLayout
+ android:id="@+id/fragment_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
+
+</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/DeviceParts/res/values-night/colors.xml b/DeviceParts/res/values-night/colors.xml
new file mode 100644
index 0000000..0f0d113
--- /dev/null
+++ b/DeviceParts/res/values-night/colors.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014-2020 The OmniROM 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.
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <color name="colorPrimary">@android:color/system_accent1_100</color>
+ <color name="windowBackground">@android:color/system_neutral1_900</color>
+</resources>
\ No newline at end of file
diff --git a/DeviceParts/res/values/colors.xml b/DeviceParts/res/values/colors.xml
new file mode 100644
index 0000000..5ab4682
--- /dev/null
+++ b/DeviceParts/res/values/colors.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014-2022 The OmniROM 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.
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <color name="colorPrimary">@android:color/system_accent1_600</color>
+ <color name="windowBackground">@android:color/system_neutral1_50</color>
+</resources>
diff --git a/DeviceParts/res/values/styles.xml b/DeviceParts/res/values/styles.xml
index 7141b2e..9edf85e 100644
--- a/DeviceParts/res/values/styles.xml
+++ b/DeviceParts/res/values/styles.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014-2017 The OmniROM Project
+<!-- Copyright (C) 2014-2020 The OmniROM Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,10 +14,13 @@
limitations under the License.
-->
<resources>
- <style name="Theme.AppTheme" parent="@android:style/Theme.DeviceDefault.Settings">
- <item name="preferenceTheme">@style/Theme.AppTheme.PreferenceTheme</item>
- </style>
-
- <style name="Theme.AppTheme.PreferenceTheme" parent="@style/PreferenceThemeOverlay.SettingsBase">
+ <style name="AppTheme" parent="Theme.Material3.DayNight.NoActionBar">
+ <item name="colorPrimary">@color/colorPrimary</item>
+ <item name="colorAccent">?attr/colorPrimary</item>
+ <item name="android:navigationBarColor">@android:color/transparent</item>
+ <item name="android:statusBarColor">@android:color/transparent</item>
+ <item name="android:windowLightStatusBar">?attr/isLightTheme</item>
+ <item name="android:windowLightNavigationBar">?attr/isLightTheme</item>
+ <item name="android:windowBackground">@color/windowBackground</item>
</style>
</resources>
diff --git a/DeviceParts/src/org/omnirom/device/DeviceSettings.java b/DeviceParts/src/org/omnirom/device/DeviceSettings.java
index f02c3b6..a4d37ba 100644
--- a/DeviceParts/src/org/omnirom/device/DeviceSettings.java
+++ b/DeviceParts/src/org/omnirom/device/DeviceSettings.java
@@ -28,7 +28,7 @@
import android.os.Parcel;
import android.os.RemoteException;
import android.os.ServiceManager;
-import androidx.preference.PreferenceFragment;
+import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
@@ -44,7 +44,7 @@
import android.util.Log;
import java.util.Map;
-public class DeviceSettings extends PreferenceFragment implements
+public class DeviceSettings extends PreferenceFragmentCompat implements
Preference.OnPreferenceChangeListener {
protected static final String DEFAULT_FPS_VALUE = "60";
diff --git a/DeviceParts/src/org/omnirom/device/DeviceSettingsActivity.java b/DeviceParts/src/org/omnirom/device/DeviceSettingsActivity.java
index 0370685..9fd42a9 100644
--- a/DeviceParts/src/org/omnirom/device/DeviceSettingsActivity.java
+++ b/DeviceParts/src/org/omnirom/device/DeviceSettingsActivity.java
@@ -17,38 +17,38 @@
*/
package org.omnirom.device;
-import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.Fragment;
import android.content.DialogInterface;
import android.os.Bundle;
-import androidx.preference.PreferenceFragment;
+import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
-public class DeviceSettingsActivity extends Activity {
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
- private DeviceSettings mDeviceSettingsFragment;
-
+public class DeviceSettingsActivity extends AppCompatActivity {
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- getActionBar().setDisplayHomeAsUpEnabled(true);
+ setContentView(R.layout.settings_activity);
+ setSupportActionBar(findViewById(R.id.toolbar));
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ }
- Fragment fragment = getFragmentManager().findFragmentById(android.R.id.content);
- if (fragment == null) {
- mDeviceSettingsFragment = new DeviceSettings();
- getFragmentManager().beginTransaction()
- .add(android.R.id.content, mDeviceSettingsFragment)
- .commit();
- } else {
- mDeviceSettingsFragment = (DeviceSettings) fragment;
- }
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ getSupportFragmentManager().beginTransaction()
+ .replace(R.id.fragment_container, new DeviceSettings())
+ .commit();
}
@Override
diff --git a/DeviceParts/src/org/omnirom/device/DozeSettings.java b/DeviceParts/src/org/omnirom/device/DozeSettings.java
index b8be48a..ba9d86c 100644
--- a/DeviceParts/src/org/omnirom/device/DozeSettings.java
+++ b/DeviceParts/src/org/omnirom/device/DozeSettings.java
@@ -22,7 +22,7 @@
import android.content.res.Resources;
import android.content.Intent;
import android.os.Bundle;
-import androidx.preference.PreferenceFragment;
+import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
@@ -39,7 +39,7 @@
import org.omnirom.omnilib.utils.OmniSettings;
-public class DozeSettings extends PreferenceFragment {
+public class DozeSettings extends PreferenceFragmentCompat {
private static final String KEY_WAVE_CHECK = "wave_check";
private static final String KEY_POCKET_CHECK = "pocket_check";
diff --git a/DeviceParts/src/org/omnirom/device/DozeSettingsActivity.java b/DeviceParts/src/org/omnirom/device/DozeSettingsActivity.java
index eed2e24..7244373 100644
--- a/DeviceParts/src/org/omnirom/device/DozeSettingsActivity.java
+++ b/DeviceParts/src/org/omnirom/device/DozeSettingsActivity.java
@@ -17,38 +17,38 @@
*/
package org.omnirom.device;
-import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.Fragment;
import android.content.DialogInterface;
import android.os.Bundle;
-import androidx.preference.PreferenceFragment;
+import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
-public class DozeSettingsActivity extends Activity {
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
- private DozeSettings mDozeSettingsFragment;
-
+public class DozeSettingsActivity extends AppCompatActivity {
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- getActionBar().setDisplayHomeAsUpEnabled(true);
+ setContentView(R.layout.settings_activity);
+ setSupportActionBar(findViewById(R.id.toolbar));
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ }
- Fragment fragment = getFragmentManager().findFragmentById(android.R.id.content);
- if (fragment == null) {
- mDozeSettingsFragment = new DozeSettings();
- getFragmentManager().beginTransaction()
- .add(android.R.id.content, mDozeSettingsFragment)
- .commit();
- } else {
- mDozeSettingsFragment = (DozeSettings) fragment;
- }
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ getSupportFragmentManager().beginTransaction()
+ .replace(R.id.fragment_container, new DozeSettings())
+ .commit();
}
@Override
diff --git a/DeviceParts/src/org/omnirom/device/GestureSettings.java b/DeviceParts/src/org/omnirom/device/GestureSettings.java
index f63bbf1..404c5a1 100644
--- a/DeviceParts/src/org/omnirom/device/GestureSettings.java
+++ b/DeviceParts/src/org/omnirom/device/GestureSettings.java
@@ -29,7 +29,7 @@
import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Bundle;
-import androidx.preference.PreferenceFragment;
+import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
@@ -52,7 +52,7 @@
import java.util.LinkedList;
import java.util.List;
-public class GestureSettings extends PreferenceFragment implements
+public class GestureSettings extends PreferenceFragmentCompat implements
Preference.OnPreferenceChangeListener {
public static final String KEY_PROXI_SWITCH = "proxi";
diff --git a/DeviceParts/src/org/omnirom/device/GestureSettingsActivity.java b/DeviceParts/src/org/omnirom/device/GestureSettingsActivity.java
index d0a9917..4b630e5 100644
--- a/DeviceParts/src/org/omnirom/device/GestureSettingsActivity.java
+++ b/DeviceParts/src/org/omnirom/device/GestureSettingsActivity.java
@@ -17,39 +17,38 @@
*/
package org.omnirom.device;
-import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.Fragment;
import android.content.DialogInterface;
import android.os.Bundle;
-import androidx.preference.PreferenceFragment;
-import androidx.preference.Preference;
+import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
-public class GestureSettingsActivity extends Activity {
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
- private GestureSettings mGestureSettingsFragment;
+public class GestureSettingsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- getActionBar().setDisplayHomeAsUpEnabled(true);
+ setContentView(R.layout.settings_activity);
+ setSupportActionBar(findViewById(R.id.toolbar));
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ }
- Fragment fragment = getFragmentManager().findFragmentById(android.R.id.content);
- if (fragment == null) {
- mGestureSettingsFragment = new GestureSettings();
- getFragmentManager().beginTransaction()
- .add(android.R.id.content, mGestureSettingsFragment)
- .commit();
- } else {
- mGestureSettingsFragment = (GestureSettings) fragment;
- }
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ getSupportFragmentManager().beginTransaction()
+ .replace(R.id.fragment_container, new GestureSettings())
+ .commit();
}
@Override
diff --git a/DeviceParts/src/org/omnirom/device/TileActivity.java b/DeviceParts/src/org/omnirom/device/TileActivity.java
index 480ec2a..3de9bdd 100644
--- a/DeviceParts/src/org/omnirom/device/TileActivity.java
+++ b/DeviceParts/src/org/omnirom/device/TileActivity.java
@@ -16,12 +16,13 @@
package org.omnirom.device;
-import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
-public class TileActivity extends Activity {
+import androidx.appcompat.app.AppCompatActivity;
+
+public class TileActivity extends AppCompatActivity {
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
Intent intent = new Intent();