samsung: doze: Integrate with Settings
authorZhao Wei Liew <zhaoweiliew@gmail.com>
Wed, 7 Sep 2016 10:20:51 +0000 (18:20 +0800)
committerJan Altensen <info@stricted.net>
Fri, 20 Mar 2020 13:56:36 +0000 (14:56 +0100)
Bring this up to speed on the Settings changes in N:
 * Use support libs for preferences
 * Hook up to Settings drawer through SettingsDrawerActivity

Change-Id: I9365b3ebd1bbfed2936302e30da50e3f9af06665

doze/Android.mk
doze/AndroidManifest.xml
doze/proguard.flags
doze/res/values/styles.xml [new file with mode: 0644]
doze/src/com/cyanogenmod/settings/device/SamsungDozeActivity.java [new file with mode: 0644]
doze/src/com/cyanogenmod/settings/device/TouchscreenGestureSettings.java

index 015d8019cf57f591bca8b6eba1402cf6eb76279b..07b7cac0502caf3ea9eb3ad68a72674b8da1c5ca 100644 (file)
@@ -10,10 +10,31 @@ LOCAL_CERTIFICATE := platform
 LOCAL_PRIVILEGED_MODULE := true
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
+    android-support-v14-preference \
+    android-support-v7-appcompat \
+    android-support-v7-preference \
+    android-support-v7-recyclerview \
     org.cyanogenmod.platform.internal
 
 LOCAL_PROGUARD_FLAG_FILES := proguard.flags
 
+LOCAL_RESOURCE_DIR := \
+    $(LOCAL_PATH)/res \
+    frameworks/support/v14/preference/res \
+    frameworks/support/v7/appcompat/res \
+    frameworks/support/v7/preference/res \
+    frameworks/support/v7/recyclerview/res
+
+LOCAL_AAPT_FLAGS := --auto-add-overlay \
+    --extra-packages android.support.v14.preference:android.support.v7.appcompat:android.support.v7.preference:android.support.v7.recyclerview
+
+ifneq ($(INCREMENTAL_BUILDS),)
+    LOCAL_PROGUARD_ENABLED := disabled
+    LOCAL_JACK_ENABLED := incremental
+endif
+
+include frameworks/base/packages/SettingsLib/common.mk
+
 include $(BUILD_PACKAGE)
 
 include $(call all-makefiles-under,$(LOCAL_PATH))
index fe2cfe46557843963b9371bd8db294d706f5c7f5..b14e9e032360effcab6dc4523b5defa9724445de 100644 (file)
@@ -30,9 +30,9 @@
         </service>
 
         <activity
-            android:name=".TouchscreenGestureSettings"
+            android:name=".SamsungDozeActivity"
             android:label="@string/screen_gestures_panel_title"
-            android:theme="@android:style/Theme.Material.Settings">
+            android:theme="@style/SamsungDozeSettings">
             <intent-filter>
                 <action android:name="com.android.settings.action.EXTRA_SETTINGS" />
             </intent-filter>
index 3bb1f2c2f4f548543995ef25f80dda3689cffa99..0a629417fe5045e511e4bd55161f781ca2efb291 100644 (file)
@@ -1,3 +1,9 @@
 -keep class com.cyanogenmod.settings.device.* {
   *;
 }
+
+-keepclasseswithmembers class * {
+    public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keep class ** extends android.support.v14.preference.PreferenceFragment
diff --git a/doze/res/values/styles.xml b/doze/res/values/styles.xml
new file mode 100644 (file)
index 0000000..69e4ff3
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2016 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.
+-->
+<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>
+</resources>
diff --git a/doze/src/com/cyanogenmod/settings/device/SamsungDozeActivity.java b/doze/src/com/cyanogenmod/settings/device/SamsungDozeActivity.java
new file mode 100644 (file)
index 0000000..45ac530
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2016 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.
+ */
+package com.cyanogenmod.settings.device;
+
+import android.app.Fragment;
+import android.app.FragmentTransaction;
+import android.os.Bundle;
+
+import com.android.settingslib.drawer.SettingsDrawerActivity;
+
+public class SamsungDozeActivity extends SettingsDrawerActivity {
+
+    private static final String TAG = "samsung_doze";
+
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        getFragmentManager().beginTransaction().replace(R.id.content_frame,
+                new TouchscreenGestureSettings(), TAG).commit();
+    }
+}
index 30bbcf42033cd68395273fbe51e2dadc52823385..c9ffce0ae2712f2cac40b5ed8082c4ba2abf03e0 100644 (file)
 package com.cyanogenmod.settings.device;
 
 import android.os.Bundle;
-import android.preference.Preference;
-import android.preference.PreferenceActivity;
-import android.preference.SwitchPreference;
+import android.support.v14.preference.PreferenceFragment;
+import android.support.v14.preference.SwitchPreference;
+import android.support.v7.preference.Preference;
 import android.provider.Settings;
 
 import org.cyanogenmod.internal.util.ScreenType;
 
-public class TouchscreenGestureSettings extends PreferenceActivity {
+public class TouchscreenGestureSettings extends PreferenceFragment {
 
     private static final String KEY_AMBIENT_DISPLAY_ENABLE = "ambient_display_enable";
     private static final String KEY_HAND_WAVE = "gesture_hand_wave";
@@ -37,8 +37,7 @@ public class TouchscreenGestureSettings extends PreferenceActivity {
     private SwitchPreference mProximityWakePreference;
 
     @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
+    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
         addPreferencesFromResource(R.xml.gesture_panel);
         boolean dozeEnabled = isDozeEnabled();
         mAmbientDisplayPreference =
@@ -59,22 +58,22 @@ public class TouchscreenGestureSettings extends PreferenceActivity {
     }
 
     @Override
-    protected void onResume() {
+    public void onResume() {
         super.onResume();
 
         // If running on a phone, remove padding around the listview
-        if (!ScreenType.isTablet(this)) {
+        if (!ScreenType.isTablet(getContext())) {
             getListView().setPadding(0, 0, 0, 0);
         }
     }
 
     private boolean enableDoze(boolean enable) {
-        return Settings.Secure.putInt(getContentResolver(),
+        return Settings.Secure.putInt(getContext().getContentResolver(),
                 Settings.Secure.DOZE_ENABLED, enable ? 1 : 0);
     }
 
     private boolean isDozeEnabled() {
-        return Settings.Secure.getInt(getContentResolver(),
+        return Settings.Secure.getInt(getContext().getContentResolver(),
                 Settings.Secure.DOZE_ENABLED, 1) != 0;
     }