diff options
author | TheScarastic <warabhishek@gmail.com> | 2019-12-06 16:44:18 +0530 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2020-12-20 18:55:01 +0200 |
commit | b3b442059acc0a14269c72ab4d485de8fa7e95c4 (patch) | |
tree | 4b80a7b4d72dc9ff41905de86f8d7f9b24dcbb99 | |
parent | a4a4a9e4296bd8891d67f8bf4e362239772f9859 (diff) |
sdm660-common: doze: Refactor whole code
Change-Id: I14303556c66ea6bd3d111b5ce7e176711a676824
-rw-r--r-- | doze/AndroidManifest.xml | 13 | ||||
-rw-r--r-- | doze/res/layout/doze.xml | 6 | ||||
-rw-r--r-- | doze/res/layout/switch_bar.xml | 19 | ||||
-rw-r--r-- | doze/res/values-night/colors.xml | 2 | ||||
-rw-r--r-- | doze/res/values/colors.xml | 2 | ||||
-rw-r--r-- | doze/res/values/styles.xml | 15 | ||||
-rw-r--r-- | doze/res/xml/doze_settings.xml | 12 | ||||
-rw-r--r-- | doze/src/org/lineageos/settings/doze/DozeService.java | 21 | ||||
-rw-r--r-- | doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java | 12 | ||||
-rw-r--r-- | doze/src/org/lineageos/settings/doze/Utils.java | 10 |
10 files changed, 55 insertions, 57 deletions
diff --git a/doze/AndroidManifest.xml b/doze/AndroidManifest.xml index 93f5a3b..ed56846 100644 --- a/doze/AndroidManifest.xml +++ b/doze/AndroidManifest.xml @@ -17,18 +17,18 @@ --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.lineageos.settings.doze" + android:sharedUserId="android.uid.system" android:versionCode="1" - android:versionName="1.0" - android:sharedUserId="android.uid.system"> + android:versionName="1.0"> - <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> + <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <protected-broadcast android:name="com.android.systemui.doze.pulse" /> <uses-sdk android:minSdkVersion="24" - android:targetSdkVersion="24"/> + android:targetSdkVersion="24" /> <application android:label="@string/device_settings_app_name" @@ -41,8 +41,9 @@ </intent-filter> </receiver> - <service android:name=".DozeService" - android:permission="XiaomiDozeService"> + <service + android:name=".DozeService" + android:permission="XiaomiDozeService"> </service> <activity diff --git a/doze/res/layout/doze.xml b/doze/res/layout/doze.xml index 941cdf6..e9f3c0f 100644 --- a/doze/res/layout/doze.xml +++ b/doze/res/layout/doze.xml @@ -18,9 +18,9 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_height="match_parent" - android:layout_width="match_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> <include layout="@layout/switch_bar" /> diff --git a/doze/res/layout/switch_bar.xml b/doze/res/layout/switch_bar.xml index 1bf6f6c..e02f196 100644 --- a/doze/res/layout/switch_bar.xml +++ b/doze/res/layout/switch_bar.xml @@ -19,24 +19,25 @@ android:layout_width="match_parent" android:layout_height="?android:attr/actionBarSize" android:background="@drawable/switchbar_background" - android:paddingStart="16dp" - android:paddingEnd="16dp" android:clickable="true" android:gravity="center" + android:paddingStart="16dp" + android:paddingEnd="16dp" android:theme="@*android:style/ThemeOverlay.DeviceDefault.Accent"> - <TextView android:id="@+id/switch_text" - android:layout_height="wrap_content" + <TextView + android:id="@+id/switch_text" android:layout_width="0dp" - android:layout_weight="1" + android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:paddingStart="56dp" - android:maxLines="2" + android:layout_weight="1" android:ellipsize="end" + android:maxLines="2" + android:paddingStart="56dp" + android:textAlignment="viewStart" android:textAppearance="@android:style/TextAppearance.Material.Title" android:textColor="?android:attr/textColorPrimaryInverse" - android:textSize="18sp" - android:textAlignment="viewStart" /> + android:textSize="18sp" /> <Switch android:id="@android:id/switch_widget" diff --git a/doze/res/values-night/colors.xml b/doze/res/values-night/colors.xml index 5aa9c8e..6d9d63e 100644 --- a/doze/res/values-night/colors.xml +++ b/doze/res/values-night/colors.xml @@ -15,6 +15,6 @@ --> <resources> - <color name="switchbar_switch_track_tint">#82000000</color> <color name="switchbar_switch_thumb_tint">@android:color/black</color> + <color name="switchbar_switch_track_tint">#82000000</color> </resources> diff --git a/doze/res/values/colors.xml b/doze/res/values/colors.xml index bb85f62..ac4c4c3 100644 --- a/doze/res/values/colors.xml +++ b/doze/res/values/colors.xml @@ -16,6 +16,6 @@ <resources> <color name="switchbar_background_color">@*android:color/material_grey_600</color> - <color name="switchbar_switch_track_tint">#BFFFFFFF</color> <color name="switchbar_switch_thumb_tint">@android:color/white</color> + <color name="switchbar_switch_track_tint">#BFFFFFFF</color> </resources> diff --git a/doze/res/values/styles.xml b/doze/res/values/styles.xml index 314665d..4ee4de4 100644 --- a/doze/res/values/styles.xml +++ b/doze/res/values/styles.xml @@ -6,9 +6,9 @@ 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. @@ -16,6 +16,7 @@ limitations under the License. --> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <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> @@ -25,8 +26,7 @@ <item name="switchPreferenceStyle">@style/Theme.Main.SwitchPreferenceStyle</item> </style> - <style name="Theme.Main.DialogPreferenceStyle" parent="@style/Theme.Main.PreferenceStyle"> - </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> @@ -55,8 +55,7 @@ <item name="widgetLayout">@*android:layout/preference_widget_switch</item> </style> - <style name="Theme.Main.SwitchBar" parent="@android:style/ThemeOverlay.Material.ActionBar"> - </style> + <style name="Theme.Main.SwitchBar" parent="@android:style/ThemeOverlay.Material.ActionBar"></style> <style name="Theme.Main.SwitchBar.Switch"> <item name="android:trackTint">@color/switchbar_switch_track_tint</item> @@ -65,9 +64,9 @@ <style name="Theme.Main.TextAppearance.CategoryTitle" parent="@*android:style/TextAppearance.DeviceDefault.Body2"> - <item name="android:textAllCaps">true</item> - <item name="android:textSize">11sp</item> <!-- 0.8 Spacing, 0.8/11 = 0.072727273 --> <item name="android:letterSpacing">0.072727273</item> + <item name="android:textAllCaps">true</item> + <item name="android:textSize">11sp</item> </style> </resources> diff --git a/doze/res/xml/doze_settings.xml b/doze/res/xml/doze_settings.xml index 43a3c2d..dd6e19b 100644 --- a/doze/res/xml/doze_settings.xml +++ b/doze/res/xml/doze_settings.xml @@ -21,10 +21,10 @@ android:title="@string/tilt_sensor_title"> <SwitchPreference - android:key="gesture_pick_up" android:defaultValue="false" - android:title="@string/pick_up_gesture_title" + android:key="gesture_pick_up" android:summary="@string/pick_up_gesture_summary" + android:title="@string/pick_up_gesture_title" android:icon="@drawable/ic_pickup" /> </PreferenceCategory> @@ -34,17 +34,17 @@ android:title="@string/proximity_sensor_title"> <SwitchPreference - android:key="gesture_hand_wave" android:defaultValue="false" - android:title="@string/hand_wave_gesture_title" + android:key="gesture_hand_wave" android:summary="@string/hand_wave_gesture_summary" + android:title="@string/hand_wave_gesture_title" android:icon="@drawable/ic_hand" /> <SwitchPreference - android:key="gesture_pocket" android:defaultValue="false" - android:title="@string/pocket_gesture_title" + android:key="gesture_pocket" android:summary="@string/pocket_gesture_summary" + android:title="@string/pocket_gesture_title" android:icon="@drawable/ic_pocket" /> </PreferenceCategory> diff --git a/doze/src/org/lineageos/settings/doze/DozeService.java b/doze/src/org/lineageos/settings/doze/DozeService.java index 5b161e2..be28aee 100644 --- a/doze/src/org/lineageos/settings/doze/DozeService.java +++ b/doze/src/org/lineageos/settings/doze/DozeService.java @@ -31,6 +31,16 @@ public class DozeService extends Service { private ProximitySensor mProximitySensor; private TiltSensor mTiltSensor; + private BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) { + onDisplayOn(); + } else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { + onDisplayOff(); + } + } + }; @Override public void onCreate() { @@ -84,15 +94,4 @@ public class DozeService extends Service { mProximitySensor.enable(); } } - - private BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) { - onDisplayOn(); - } else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { - onDisplayOff(); - } - } - }; } diff --git a/doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java b/doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java index 2af38a8..52458d1 100644 --- a/doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java +++ b/doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java @@ -22,7 +22,6 @@ import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; -import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.Bundle; @@ -34,6 +33,7 @@ import android.view.ViewGroup; import android.widget.CompoundButton; import android.widget.Switch; import android.widget.TextView; + import androidx.preference.Preference; import androidx.preference.Preference.OnPreferenceChangeListener; import androidx.preference.PreferenceCategory; @@ -144,6 +144,11 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer return false; } + private void showHelp() { + HelpDialogFragment fragment = new HelpDialogFragment(); + fragment.show(getFragmentManager(), "help_dialog"); + } + private static class HelpDialogFragment extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { @@ -162,9 +167,4 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer .commit(); } } - - private void showHelp() { - HelpDialogFragment fragment = new HelpDialogFragment(); - fragment.show(getFragmentManager(), "help_dialog"); - } } diff --git a/doze/src/org/lineageos/settings/doze/Utils.java b/doze/src/org/lineageos/settings/doze/Utils.java index 8c333f2..490095e 100644 --- a/doze/src/org/lineageos/settings/doze/Utils.java +++ b/doze/src/org/lineageos/settings/doze/Utils.java @@ -23,22 +23,20 @@ import android.content.pm.PackageManager; import android.os.UserHandle; import android.provider.Settings; import android.util.Log; + import androidx.preference.PreferenceManager; import static android.provider.Settings.Secure.DOZE_ENABLED; public final class Utils { - private static final String TAG = "DozeUtils"; - private static final boolean DEBUG = false; - - private static final String DOZE_INTENT = "com.android.systemui.doze.pulse"; - protected static final String CATEG_PROX_SENSOR = "proximity_sensor"; - protected static final String GESTURE_PICK_UP_KEY = "gesture_pick_up"; protected static final String GESTURE_HAND_WAVE_KEY = "gesture_hand_wave"; protected static final String GESTURE_POCKET_KEY = "gesture_pocket"; + private static final String TAG = "DozeUtils"; + private static final boolean DEBUG = false; + private static final String DOZE_INTENT = "com.android.systemui.doze.pulse"; protected static void startService(Context context) { if (DEBUG) Log.d(TAG, "Starting service"); |