From 860266e24f3c33720e5b558633a40ac77146ff43 Mon Sep 17 00:00:00 2001 From: TheScarastic Date: Wed, 6 Oct 2021 07:25:13 +0000 Subject: [PATCH] MotoActions: Adapt to S style * Use Theme.SubSettingsBase for theme * Replace PreferenceActivity with CollapsingToolbarBaseActivity * Add Titles to preference screen * Remove onOptionsItemSelected and where necessary move to activity Co-authored-by: Erfan Abdi Change-Id: I87af15f5e165aa7bcd556eb2b716c0ce624ca4e7 --- MotoActions/AndroidManifest.xml | 4 +- MotoActions/res/layout/doze.xml | 28 -------- MotoActions/res/xml/actions_panel.xml | 9 +-- MotoActions/res/xml/doze_panel.xml | 13 +++- .../device/ActionsPreferenceActivity.java | 8 ++- .../device/ActionsPreferenceFragment.java | 3 - .../device/DozePreferenceActivity.java | 10 +-- .../device/DozePreferenceFragment.java | 67 +++---------------- .../settings/device/MotoActionsSettings.java | 1 + 9 files changed, 42 insertions(+), 101 deletions(-) delete mode 100644 MotoActions/res/layout/doze.xml diff --git a/MotoActions/AndroidManifest.xml b/MotoActions/AndroidManifest.xml index 5d206d9..5ae8f64 100644 --- a/MotoActions/AndroidManifest.xml +++ b/MotoActions/AndroidManifest.xml @@ -37,7 +37,7 @@ android:name=".DozePreferenceActivity" android:exported="false" android:label="@string/ambient_display_gestures_title" - android:theme="@style/Theme.Main"> + android:theme="@style/Theme.SubSettingsBase"> @@ -48,7 +48,7 @@ android:name=".ActionsPreferenceActivity" android:exported="false" android:label="@string/moto_gestures_panel_title" - android:theme="@style/Theme.Main"> + android:theme="@style/Theme.SubSettingsBase"> diff --git a/MotoActions/res/layout/doze.xml b/MotoActions/res/layout/doze.xml deleted file mode 100644 index e9f3c0f..0000000 --- a/MotoActions/res/layout/doze.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - diff --git a/MotoActions/res/xml/actions_panel.xml b/MotoActions/res/xml/actions_panel.xml index f366ea4..c4ced85 100644 --- a/MotoActions/res/xml/actions_panel.xml +++ b/MotoActions/res/xml/actions_panel.xml @@ -1,7 +1,7 @@ - + + android:key="actions_key"> - + + + + + { - switchWidget.setChecked(!switchWidget.isChecked()); - mSwitchBar.setActivated(switchWidget.isChecked()); - }); - } - @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (MotoActionsSettings.ALWAYS_ON_DISPLAY.equals(preference.getKey())) { @@ -132,11 +97,10 @@ public class DozePreferenceFragment extends PreferenceFragment } @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { + public void onSwitchChanged(Switch switchView, boolean isChecked) { MotoActionsSettings.enableDoze(getActivity(), isChecked); - mTextView.setText(getString(isChecked ? R.string.switch_bar_on : R.string.switch_bar_off)); - mSwitchBar.setActivated(isChecked); + mSwitchBar.setChecked(isChecked); if (!isChecked) { MotoActionsSettings.enableAlwaysOn(getActivity(), false); @@ -149,15 +113,6 @@ public class DozePreferenceFragment extends PreferenceFragment mPocketPreference.setEnabled(isChecked); } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - if (item.getItemId() == android.R.id.home) { - getActivity().onBackPressed(); - return true; - } - return false; - } - public static class HelpDialogFragment extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { diff --git a/MotoActions/src/org/lineageos/settings/device/MotoActionsSettings.java b/MotoActions/src/org/lineageos/settings/device/MotoActionsSettings.java index d1e2e50..5f654fd 100644 --- a/MotoActions/src/org/lineageos/settings/device/MotoActionsSettings.java +++ b/MotoActions/src/org/lineageos/settings/device/MotoActionsSettings.java @@ -43,6 +43,7 @@ public class MotoActionsSettings { static final String GESTURE_PICK_UP_KEY = "gesture_pick_up"; static final String GESTURE_POCKET_KEY = "gesture_pocket"; + static final String DOZE_ENABLE = "doze_enable"; static final String ALWAYS_ON_DISPLAY = "always_on_display"; private final Context mContext; -- 2.20.1