samsung: doze: Re-integrate into Settings
authorBruno Martins <bgcngm@gmail.com>
Wed, 18 Oct 2017 01:10:01 +0000 (03:10 +0200)
committerJan Altensen <info@stricted.net>
Fri, 20 Mar 2020 13:56:42 +0000 (14:56 +0100)
* Apply the default Oreo theme and inherit the layouts
  from Google for the Settings app, in order to keep
  UI consistency.

* Get rid of SettingsDrawerActivity as it no longer fits in
  and include the back button in the action bar.

* Kill the icon drawable not only because is a leftover,
  but also doesn't really serve any puropose in the new UI.

Change-Id: I71ea2c118dcfd387904d04516572902babb16e35

doze/Android.mk
doze/AndroidManifest.xml
doze/res/drawable/ic_settings_gestures.xml [deleted file]
doze/res/values/styles.xml
doze/src/org/lineageos/settings/device/SamsungDozeActivity.java
doze/src/org/lineageos/settings/device/TouchscreenGestureSettings.java

index 18fd4c46fcf80b06b7ab755398985a76d93dc308..4f9f9047c9ce8cd31e9f3a98511e694db891a187 100644 (file)
@@ -12,10 +12,12 @@ LOCAL_PRIVILEGED_MODULE := true
 LOCAL_USE_AAPT2 := true
 
 LOCAL_STATIC_ANDROID_LIBRARIES := \
-    android-support-v14-preference \
+    android-support-v4 \
+    android-support-v13 \
     android-support-v7-appcompat \
     android-support-v7-preference \
-    android-support-v7-recyclerview
+    android-support-v7-recyclerview \
+    android-support-v14-preference
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
     org.lineageos.platform.internal
@@ -31,8 +33,6 @@ ifneq ($(INCREMENTAL_BUILDS),)
     LOCAL_JACK_ENABLED := incremental
 endif
 
-include frameworks/base/packages/SettingsLib/common.mk
-
 include $(BUILD_PACKAGE)
 
 include $(call all-makefiles-under,$(LOCAL_PATH))
index e8ad9dec6b50423c218c6f948a9ffa1ff976b01c..060ad2c272b750ca262ba28e16b8fdb181846ee4 100644 (file)
     <protected-broadcast android:name="com.android.systemui.doze.pulse" />
 
     <uses-sdk
-        android:minSdkVersion="21"
-        android:targetSdkVersion="21"/>
+        android:minSdkVersion="24"
+        android:targetSdkVersion="26"/>
 
     <application
         android:label="@string/device_settings_app_name"
         android:persistent="true">
 
-        <receiver android:name="org.lineageos.settings.device.BootCompletedReceiver">
+        <receiver android:name=".BootCompletedReceiver">
             <intent-filter>
                 <action android:name="android.intent.action.BOOT_COMPLETED" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
         </receiver>
 
-        <service android:name="org.lingeageos.settings.device.SamsungDozeService"
+        <service android:name=".SamsungDozeService"
                  android:permission="SamsungDozeService">
         </service>
 
         <activity
             android:name=".SamsungDozeActivity"
             android:label="@string/ambient_display_title"
-            android:theme="@style/SamsungDozeSettings">
+            android:theme="@style/Theme.Main">
             <intent-filter>
                 <action android:name="org.lineageos.settings.device.DOZE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
diff --git a/doze/res/drawable/ic_settings_gestures.xml b/doze/res/drawable/ic_settings_gestures.xml
deleted file mode 100644 (file)
index c0a0282..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-    Copyright (c) 2015 The CyanogenMod 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="@*android:color/material_deep_teal_500"
-        android:pathData="M4.7,6.9c0.7-0.7,1.4-1.4,1.7-1.2c0.5,0.2,0,1-0.3,1.5c-0.2,0.4-2.8,3.9-2.8,6.3c0,1.3,0.5,2.3,1.3,3
-c0.7,0.6,1.7,0.7,2.6,0.5c1.1-0.3,1.9-1.4,3-2.8c1.2-1.5,2.8-3.4,4-3.4c1.6,0,1.6,1,1.7,1.8c-3.7,0.6-5.3,3.7-5.3,5.4
-s1.4,3.1,3.2,3.1c1.6,0,4.3-1.3,4.6-6.1H21v-2.5h-2.4c-0.1-1.7-1.1-4.2-4-4.2c-2.2,0-4.1,1.9-4.9,2.8c-0.6,0.7-2,2.5-2.3,2.7
-c-0.2,0.3-0.7,0.8-1.1,0.8c-0.4,0-0.7-0.8-0.4-1.9c0.3-1.1,1.4-2.9,1.8-3.5C8.5,8,9.1,7.2,9.1,5.9C9.1,3.7,7.4,3,6.6,3
-C5.3,3,4.1,4,3.9,4.3C3.5,4.6,3.2,4.9,3,5.2L4.7,6.9z
-M13.9,18.6c-0.3,0-0.7-0.3-0.7-0.7c0-0.6,0.7-2.2,2.8-2.8
-C15.8,17.8,14.6,18.6,13.9,18.6z" />
-</vector>
index 69e4ff386e267d3e0a24c93629de3697186d4ad1..1ecca6c50febc00e862ff8b0a9720bb157d8ea76 100644 (file)
      limitations under the License.
 -->
 <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <style name="SamsungDozeSettings" parent="@android:style/Theme.Material.Settings">
-        <item name="preferenceTheme">@android:style/Theme.Material.Settings</item>
+    <style name="Theme.Main" parent="@android:style/Theme.DeviceDefault.Settings">
+        <item name="dialogPreferenceStyle">@style/Theme.Main.DialogPreferenceStyle</item>
+        <item name="preferenceCategoryStyle">@style/Theme.Main.PreferenceCategoryStyle</item>
+        <item name="preferenceFragmentStyle">@style/Theme.Main.PreferenceFragmentStyle</item>
+        <item name="preferenceStyle">@style/Theme.Main.PreferenceStyle</item>
+        <item name="preferenceTheme">@style/Theme.Main.PreferenceTheme</item>
+        <item name="switchPreferenceStyle">@style/Theme.Main.SwitchPreferenceStyle</item>
+    </style>
+
+    <style name="Theme.Main.DialogPreferenceStyle" parent="@style/Theme.Main.PreferenceStyle">
+    </style>
+
+    <style name="Theme.Main.PreferenceCategoryStyle" parent="@*android:style/Preference.DeviceDefault.Category">
+        <item name="allowDividerAbove">true</item>
+        <item name="allowDividerBelow">true</item>
+        <item name="android:layout">@layout/preference_category_material_settings</item>
+    </style>
+
+    <style name="Theme.Main.PreferenceFragmentStyle" parent="@*android:style/PreferenceFragment.Material">
+        <item name="allowDividerAfterLastItem">false</item>
+    </style>
+
+    <style name="Theme.Main.PreferenceStyle" parent="@*android:style/Preference.DeviceDefault">
+        <item name="allowDividerAbove">false</item>
+        <item name="allowDividerBelow">true</item>
+        <item name="singleLineTitle">false</item>
+        <item name="android:layout">@layout/preference_material_settings</item>
+    </style>
+
+    <style name="Theme.Main.PreferenceTheme">
+    </style>
+
+    <style name="Theme.Main.SwitchPreferenceStyle" parent="@style/Theme.Main.PreferenceStyle">
+        <item name="widgetLayout">@*android:layout/preference_widget_switch</item>
+    </style>
+
+    <style name="Theme.Main.SwitchBar" parent="@android:style/ThemeOverlay.Material.ActionBar">
     </style>
 </resources>
index 7ea9853c762f5f612d1c5e3afa99d5a848a8e8c8..571f34a60534133949f3a44e8787936df34dd7bc 100644 (file)
  */
 package org.lineageos.settings.device;
 
-import android.app.Fragment;
-import android.app.FragmentTransaction;
 import android.os.Bundle;
-import android.view.MenuItem;
+import android.preference.PreferenceActivity;
 
-import com.android.settingslib.drawer.SettingsDrawerActivity;
-
-public class SamsungDozeActivity extends SettingsDrawerActivity {
+public class SamsungDozeActivity extends PreferenceActivity {
 
     private static final String TAG = "samsung_doze";
 
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        getFragmentManager().beginTransaction().replace(R.id.content_frame,
+        getFragmentManager().beginTransaction().replace(android.R.id.content,
                 new TouchscreenGestureSettings(), TAG).commit();
-
-        getActionBar().setDisplayHomeAsUpEnabled(true);
-    }
-
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        if (item.getItemId() == android.R.id.home) {
-            onBackPressed();
-            return true;
-        }
-        return false;
     }
 }
index 4bf29004d2b82bb22fa0c2ef965ba8eb30c5ba41..44c9b9427fc1b95eefa6b27a98d54302130ef9fe 100644 (file)
 
 package org.lineageos.settings.device;
 
+import android.app.ActionBar;
 import android.os.Bundle;
 import android.support.v14.preference.PreferenceFragment;
 import android.support.v14.preference.SwitchPreference;
 import android.support.v7.preference.Preference;
 import android.provider.Settings;
+import android.view.MenuItem;
 
 import org.lineageos.internal.util.ScreenType;
 
@@ -35,6 +37,8 @@ public class TouchscreenGestureSettings extends PreferenceFragment {
     @Override
     public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
         addPreferencesFromResource(R.xml.gesture_panel);
+        final ActionBar actionBar = getActivity().getActionBar();
+        actionBar.setDisplayHomeAsUpEnabled(true);
 
         mHandwavePreference =
             (SwitchPreference) findPreference(KEY_HAND_WAVE);
@@ -68,4 +72,13 @@ public class TouchscreenGestureSettings extends PreferenceFragment {
             return true;
         }
     };
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        if (item.getItemId() == android.R.id.home) {
+            getActivity().onBackPressed();
+            return true;
+        }
+        return false;
+    }
 }