AdvancedDisplay: Re-integrate into Settings
authorBruno Martins <bgcngm@gmail.com>
Thu, 28 Dec 2017 01:20:44 +0000 (02:20 +0100)
committerLukasz Patron <priv.luk@gmail.com>
Thu, 18 Jan 2018 12:30:35 +0000 (12:30 +0000)
 * 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.

 * Add required appcompat and preference support libraries.

 * Integrate into display settings category using IA.

Change-Id: I8438e0ebec27085df2be4668f8f7170d2010fb20

AdvancedDisplay/Android.mk
AdvancedDisplay/AndroidManifest.xml
AdvancedDisplay/res/values/dimens.xml
AdvancedDisplay/res/values/strings.xml
AdvancedDisplay/res/values/styles.xml
AdvancedDisplay/src/org/lineageos/settings/device/AdvancedDisplayActivity.java
lineage.dependencies [new file with mode: 0644]

index d972dc4fe176eaed05963fdf7ba93de2e77b9333..e0d82fa07ece5491cfa52539547812c62b705e15 100644 (file)
@@ -9,16 +9,19 @@ LOCAL_PACKAGE_NAME := AdvancedDisplay
 LOCAL_CERTIFICATE := platform
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
-    android-support-v14-preference \
+    android-support-v4 \
     android-support-v7-appcompat \
     android-support-v7-preference \
     android-support-v7-recyclerview \
+    android-support-v13 \
+    android-support-v14-preference \
     org.lineageos.platform.internal
 
 LOCAL_PROGUARD_FLAG_FILES := proguard.flags
 
 LOCAL_RESOURCE_DIR := \
     $(LOCAL_PATH)/res \
+    $(TOP)/packages/resources/devicesettings/res \
     frameworks/support/v14/preference/res \
     frameworks/support/v7/appcompat/res \
     frameworks/support/v7/preference/res \
@@ -31,8 +34,6 @@ LOCAL_AAPT_FLAGS := \
     --extra-packages android.support.v7.preference \
     --extra-packages android.support.v7.recyclerview
 
-include frameworks/base/packages/SettingsLib/common.mk
-
 include $(BUILD_PACKAGE)
 
 include $(call all-makefiles-under,$(LOCAL_PATH))
index 241b105595e0810abd52513594814d8f932b4fbf..71b93b041f9312cced7beaf519b6ff7181a12cbc 100644 (file)
@@ -6,7 +6,8 @@
     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
 
     <application
-        android:label="@string/app_name">
+        android:label="@string/app_name"
+        android:theme="@style/Theme.Main">
         <receiver android:name="org.lineageos.settings.device.BootCompletedReceiver">
             <intent-filter>
                 <action android:name="android.intent.action.BOOT_COMPLETED" />
 
         <activity
             android:name=".AdvancedDisplayActivity"
-            android:label="@string/app_name"
-            android:theme="@style/AdvancedDisplay">
+            android:label="@string/app_name">
             <intent-filter>
                 <action android:name="com.android.settings.action.EXTRA_SETTINGS" />
             </intent-filter>
-            <meta-data
-                android:name="com.android.settings.icon"
-                android:resource="@drawable/ic_settings_advanced_display" />
             <meta-data
                 android:name="com.android.settings.category"
-                android:value="com.android.settings.category.device" />
+                android:value="com.android.settings.category.ia.display" />
+            <meta-data
+                android:name="com.android.settings.summary"
+                android:value="@string/summary_empty" />
         </activity>
     </application>
 </manifest>
index 62f1899dfa5d2a27877bd788e5382d94f4c1979c..077adea10446082ea0f5f92c741423972203c6b4 100644 (file)
@@ -17,4 +17,6 @@
 <resources>
     <!-- ActionBar contentInsetStart -->
     <dimen name="actionbar_subsettings_contentInsetStart">72dp</dimen>
+
+    <dimen name="settings_side_margin">0dip</dimen>
 </resources>
index 42cdc6c54cb917cb3726b9dad72b709b8a04bc2b..89f55a984f298a9a0fbc8282914fa150b7839604 100644 (file)
@@ -26,4 +26,7 @@
     <string name="mdnie_scenario_summary_head">Set the mDNIe scenario</string>
     <string name="mdnie_negative_title_head">Negative mode</string>
     <string name="mdnie_negative_summary_head">Enable/disable inverted colors</string>
+
+    <!-- DO NOT TRANSLATE Empty summary for dynamic preferences -->
+    <string name="summary_empty" translatable="false"></string>
 </resources>
index ee2d0a57e2d6c33d72c6a82992ed9357a87b1dc8..01f8dae81da9629c60659468dd958f7a36de6b58 100644 (file)
      limitations under the License.
 -->
 <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <style name="AdvancedDisplay" 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="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="dialogPreferenceStyle">@style/Theme.Main.DialogPreferenceStyle</item>
+        <item name="switchPreferenceStyle">@style/Theme.Main.SwitchPreferenceStyle</item>
+    </style>
+
+    <style name="Theme.Main.PreferenceCategoryStyle" parent="@*android:style/Preference.DeviceDefault.Category">
+        <item name="allowDividerAbove">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.DialogPreferenceStyle" parent="@*android:style/Preference.DeviceDefault.DialogPreference">
+        <item name="allowDividerAbove">false</item>
+        <item name="allowDividerBelow">true</item>
+        <item name="singleLineTitle">false</item>
+        <item name="android:iconSpaceReserved">true</item>
+    </style>
+
+    <style name="Theme.Main.SwitchPreferenceStyle" parent="@style/Theme.Main.PreferenceStyle">
+        <item name="widgetLayout">@*android:layout/preference_widget_switch</item>
     </style>
 </resources>
index 82ce158e282e1bac28367e13ebcc5921b8924218..92397c38c028124a1bb011e39b22459e85d09d82 100644 (file)
 package org.lineageos.settings.device;
 
 import android.os.Bundle;
+import android.preference.PreferenceActivity;
 
-import com.android.settingslib.drawer.SettingsDrawerActivity;
-
-public class AdvancedDisplayActivity extends SettingsDrawerActivity {
+public class AdvancedDisplayActivity extends PreferenceActivity {
 
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        getFragmentManager().beginTransaction().replace(R.id.content_frame,
+        getFragmentManager().beginTransaction().replace(android.R.id.content,
                 new AdvancedDisplayFragment()).commit();
     }
 }
diff --git a/lineage.dependencies b/lineage.dependencies
new file mode 100644 (file)
index 0000000..c423969
--- /dev/null
@@ -0,0 +1,6 @@
+[
+  {
+    "repository": "android_packages_resources_devicesettings",
+    "target_path": "packages/resources/devicesettings"
+  }
+]