From b3b442059acc0a14269c72ab4d485de8fa7e95c4 Mon Sep 17 00:00:00 2001 From: TheScarastic Date: Fri, 6 Dec 2019 16:44:18 +0530 Subject: sdm660-common: doze: Refactor whole code Change-Id: I14303556c66ea6bd3d111b5ce7e176711a676824 --- doze/AndroidManifest.xml | 13 +++++++------ doze/res/layout/doze.xml | 6 +++--- doze/res/layout/switch_bar.xml | 19 ++++++++++--------- doze/res/values-night/colors.xml | 2 +- doze/res/values/colors.xml | 2 +- doze/res/values/styles.xml | 15 +++++++-------- doze/res/xml/doze_settings.xml | 12 ++++++------ .../org/lineageos/settings/doze/DozeService.java | 21 ++++++++++----------- .../settings/doze/DozeSettingsFragment.java | 12 ++++++------ 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 @@ --> + android:versionName="1.0"> - + + android:targetSdkVersion="24" /> - + + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> 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"> - + android:textSize="18sp" /> - #82000000 @android:color/black + #82000000 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 @@ @*android:color/material_grey_600 - #BFFFFFFF @android:color/white + #BFFFFFFF 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. --> + - + - + 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"> @@ -34,17 +34,17 @@ android:title="@string/proximity_sensor_title"> 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"); -- cgit v1.2.3