doze: Match Pie settings UI
Change-Id: Ia1cde37923c55faf057189f7085b69522e2802ef
This commit is contained in:
parent
56a25429aa
commit
673e03d926
7 changed files with 84 additions and 11 deletions
20
doze/res/color/switch_bar_bg.xml
Normal file
20
doze/res/color/switch_bar_bg.xml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2019 The LineageOS Project
|
||||||
|
|
||||||
|
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.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:color="#ff80868B" android:state_activated="false" />
|
||||||
|
<item android:color="?android:attr/colorAccent" android:state_activated="true" />
|
||||||
|
</selector>
|
20
doze/res/color/switchbar_switch_thumb_tint.xml
Normal file
20
doze/res/color/switchbar_switch_thumb_tint.xml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2018 The Android Open Source Project
|
||||||
|
|
||||||
|
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.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:color="#FFFFFF" />
|
||||||
|
</selector>
|
21
doze/res/color/switchbar_switch_track_tint.xml
Normal file
21
doze/res/color/switchbar_switch_track_tint.xml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2018 The Android Open Source Project
|
||||||
|
|
||||||
|
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.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<selector
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:color="#BFFFFFFF" />
|
||||||
|
</selector>
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- Copyright (C) 2014 The Android Open Source Project
|
<!-- Copyright (C) 2019 The LineageOS Project
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:color="?android:attr/colorControlHighlight">
|
android:shape="rectangle">
|
||||||
<item android:drawable="?android:attr/colorSecondary" />
|
<solid android:color="@color/switch_bar_bg" />
|
||||||
</ripple>
|
</shape>
|
||||||
|
|
|
@ -29,11 +29,12 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:paddingStart="48dp"
|
android:paddingStart="56dp"
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:textAppearance="@android:style/TextAppearance.Material.Title"
|
android:textAppearance="@android:style/TextAppearance.Material.Title"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="18sp"
|
||||||
android:textAlignment="viewStart" />
|
android:textAlignment="viewStart" />
|
||||||
|
|
||||||
<Switch
|
<Switch
|
||||||
|
@ -42,6 +43,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:background="@null"
|
android:background="@null"
|
||||||
android:theme="@style/Theme.Main.SwitchBar" />
|
android:theme="@style/Theme.Main.SwitchBar.Switch" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -54,4 +54,9 @@
|
||||||
|
|
||||||
<style name="Theme.Main.SwitchBar" parent="@android:style/ThemeOverlay.Material.ActionBar">
|
<style name="Theme.Main.SwitchBar" parent="@android:style/ThemeOverlay.Material.ActionBar">
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.Main.SwitchBar.Switch">
|
||||||
|
<item name="android:trackTint">@color/switchbar_switch_track_tint</item>
|
||||||
|
<item name="android:thumbTint">@color/switchbar_switch_thumb_tint</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -43,6 +43,7 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer
|
||||||
CompoundButton.OnCheckedChangeListener {
|
CompoundButton.OnCheckedChangeListener {
|
||||||
|
|
||||||
private TextView mTextView;
|
private TextView mTextView;
|
||||||
|
private View mSwitchBar;
|
||||||
|
|
||||||
private SwitchPreference mPickUpPreference;
|
private SwitchPreference mPickUpPreference;
|
||||||
private SwitchPreference mHandwavePreference;
|
private SwitchPreference mHandwavePreference;
|
||||||
|
@ -101,11 +102,15 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer
|
||||||
mTextView.setText(getString(dozeEnabled ?
|
mTextView.setText(getString(dozeEnabled ?
|
||||||
R.string.switch_bar_on : R.string.switch_bar_off));
|
R.string.switch_bar_on : R.string.switch_bar_off));
|
||||||
|
|
||||||
View switchBar = view.findViewById(R.id.switch_bar);
|
mSwitchBar = view.findViewById(R.id.switch_bar);
|
||||||
Switch switchWidget = switchBar.findViewById(android.R.id.switch_widget);
|
Switch switchWidget = mSwitchBar.findViewById(android.R.id.switch_widget);
|
||||||
switchWidget.setChecked(dozeEnabled);
|
switchWidget.setChecked(dozeEnabled);
|
||||||
switchWidget.setOnCheckedChangeListener(this);
|
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
|
@Override
|
||||||
|
@ -121,6 +126,7 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer
|
||||||
Utils.checkDozeService(getActivity());
|
Utils.checkDozeService(getActivity());
|
||||||
|
|
||||||
mTextView.setText(getString(isChecked ? R.string.switch_bar_on : R.string.switch_bar_off));
|
mTextView.setText(getString(isChecked ? R.string.switch_bar_on : R.string.switch_bar_off));
|
||||||
|
mSwitchBar.setActivated(isChecked);
|
||||||
|
|
||||||
mPickUpPreference.setEnabled(isChecked);
|
mPickUpPreference.setEnabled(isChecked);
|
||||||
mHandwavePreference.setEnabled(isChecked);
|
mHandwavePreference.setEnabled(isChecked);
|
||||||
|
|
Loading…
Reference in a new issue