From 8330d437f89b8c0cdec11370ba1292ffe19532fb Mon Sep 17 00:00:00 2001 From: Joey Date: Fri, 28 Dec 2018 11:33:30 +0100 Subject: wayne-common: doze: Match Pie settings UI Change-Id: Ia1cde37923c55faf057189f7085b69522e2802ef Signed-off-by: PIPIPIG233666 <2212848813@qq.com> --- .../org/lineageos/settings/doze/DozeSettingsFragment.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'doze/src') diff --git a/doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java b/doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java index 3770b5e..fd1756e 100644 --- a/doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java +++ b/doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java @@ -43,6 +43,7 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer CompoundButton.OnCheckedChangeListener { private TextView mTextView; + private View mSwitchBar; private SwitchPreference mPickUpPreference; private SwitchPreference mHandwavePreference; @@ -101,11 +102,15 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer mTextView.setText(getString(dozeEnabled ? R.string.switch_bar_on : R.string.switch_bar_off)); - View switchBar = view.findViewById(R.id.switch_bar); - Switch switchWidget = switchBar.findViewById(android.R.id.switch_widget); + mSwitchBar = view.findViewById(R.id.switch_bar); + Switch switchWidget = mSwitchBar.findViewById(android.R.id.switch_widget); switchWidget.setChecked(dozeEnabled); switchWidget.setOnCheckedChangeListener(this); - switchBar.setOnClickListener(v -> switchWidget.setChecked(!switchWidget.isChecked())); + mSwitchBar.setActivated(dozeEnabled); + mSwitchBar.setOnClickListener(v -> { + switchWidget.setChecked(!switchWidget.isChecked()); + mSwitchBar.setActivated(switchWidget.isChecked()); + }); } @Override @@ -121,6 +126,7 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer Utils.checkDozeService(getActivity()); mTextView.setText(getString(isChecked ? R.string.switch_bar_on : R.string.switch_bar_off)); + mSwitchBar.setActivated(isChecked); mPickUpPreference.setEnabled(isChecked); mHandwavePreference.setEnabled(isChecked); -- cgit v1.2.3