diff options
| author | Joey <joey@lineageos.org> | 2018-12-28 11:33:30 +0100 |
|---|---|---|
| committer | Bruno Martins <bgcngm@gmail.com> | 2019-01-14 19:53:49 +0000 |
| commit | 827ec3e4a58144118b785ad668ba53b07a8cf6c4 (patch) | |
| tree | 0d67af4d50d014ef93c38a37a3693a0a1b1d30b2 | |
| parent | 4063e1c5fc2ace84858f1b2819faef9a8927c866 (diff) | |
| download | android_packages_apps_FlipFlap-827ec3e4a58144118b785ad668ba53b07a8cf6c4.tar.gz android_packages_apps_FlipFlap-827ec3e4a58144118b785ad668ba53b07a8cf6c4.tar.bz2 android_packages_apps_FlipFlap-827ec3e4a58144118b785ad668ba53b07a8cf6c4.zip | |
FlipFlap: Match Pie settings UI
Change-Id: Ib9f85d1bf432413c82a9f4ca30464c222c6bbc97
| -rw-r--r-- | res/color/switch_bar_bg.xml | 20 | ||||
| -rw-r--r-- | res/color/switchbar_switch_thumb_tint.xml | 20 | ||||
| -rw-r--r-- | res/color/switchbar_switch_track_tint.xml | 20 | ||||
| -rw-r--r-- | res/drawable/switchbar_background.xml | 10 | ||||
| -rw-r--r-- | res/layout/switch_bar.xml | 10 | ||||
| -rw-r--r-- | res/values/styles.xml | 5 | ||||
| -rw-r--r-- | src/org/lineageos/flipflap/FlipFlapSettingsFragment.java | 21 |
7 files changed, 85 insertions, 21 deletions
diff --git a/res/color/switch_bar_bg.xml b/res/color/switch_bar_bg.xml new file mode 100644 index 0000000..ba2dae1 --- /dev/null +++ b/res/color/switch_bar_bg.xml @@ -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> diff --git a/res/color/switchbar_switch_thumb_tint.xml b/res/color/switchbar_switch_thumb_tint.xml new file mode 100644 index 0000000..d4bf9b3 --- /dev/null +++ b/res/color/switchbar_switch_thumb_tint.xml @@ -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> diff --git a/res/color/switchbar_switch_track_tint.xml b/res/color/switchbar_switch_track_tint.xml new file mode 100644 index 0000000..35bb22a --- /dev/null +++ b/res/color/switchbar_switch_track_tint.xml @@ -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="#BFFFFFFF" /> +</selector> diff --git a/res/drawable/switchbar_background.xml b/res/drawable/switchbar_background.xml index 314ed12..f210707 100644 --- a/res/drawable/switchbar_background.xml +++ b/res/drawable/switchbar_background.xml @@ -1,5 +1,5 @@ <?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"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ limitations under the License. --> -<ripple xmlns:android="http://schemas.android.com/apk/res/android" - android:color="?android:attr/colorControlHighlight"> - <item android:drawable="?android:attr/colorSecondary" /> -</ripple> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> + <solid android:color="@color/switch_bar_bg" /> +</shape> diff --git a/res/layout/switch_bar.xml b/res/layout/switch_bar.xml index 5395fee..3662032 100644 --- a/res/layout/switch_bar.xml +++ b/res/layout/switch_bar.xml @@ -29,13 +29,13 @@ android:layout_width="0dp" android:layout_weight="1" android:layout_gravity="center_vertical" - android:paddingStart="48dp" + android:paddingStart="56dp" android:maxLines="2" android:ellipsize="end" android:textAppearance="@android:style/TextAppearance.Material.Title" - android:textColor="?android:attr/textColorPrimary" - android:textAlignment="viewStart" - android:text="@string/switch_bar_on" /> + android:textColor="@android:color/white" + android:textSize="18sp" + android:textAlignment="viewStart" /> <Switch android:id="@android:id/switch_widget" @@ -43,6 +43,6 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:background="@null" - android:theme="@style/FlipFlapSettingsTheme.SwitchBar" /> + android:theme="@style/FlipFlapSettingsTheme.SwitchBar.Switch" /> </LinearLayout> diff --git a/res/values/styles.xml b/res/values/styles.xml index eec4fd1..1569c3d 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -150,4 +150,9 @@ <style name="FlipFlapSettingsTheme.SwitchBar" parent="@android:style/ThemeOverlay.Material.ActionBar"> </style> + + <style name="FlipFlapSettingsTheme.SwitchBar.Switch"> + <item name="android:trackTint">@color/switchbar_switch_track_tint</item> + <item name="android:thumbTint">@color/switchbar_switch_thumb_tint</item> + </style> </resources> diff --git a/src/org/lineageos/flipflap/FlipFlapSettingsFragment.java b/src/org/lineageos/flipflap/FlipFlapSettingsFragment.java index aabbed9..fd0351f 100644 --- a/src/org/lineageos/flipflap/FlipFlapSettingsFragment.java +++ b/src/org/lineageos/flipflap/FlipFlapSettingsFragment.java @@ -52,8 +52,8 @@ public class FlipFlapSettingsFragment extends PreferenceFragment private final String KEY_DESIGN_CATEGORY = "category_design"; private final String KEY_TOUCH_SENSITIVITY = "use_high_touch_sensitivity"; - private Switch mSwitch; private TextView mTextView; + private View mSwitchBar; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -69,20 +69,18 @@ public class FlipFlapSettingsFragment extends PreferenceFragment public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - final View switchBar = view.findViewById(R.id.switch_bar); - switchBar.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - mSwitch.setChecked(!mSwitch.isChecked()); - } + mSwitchBar = view.findViewById(R.id.switch_bar); + Switch switchWidget = mSwitchBar.findViewById(android.R.id.switch_widget); + switchWidget.setChecked(isEventReceiverEnabled()); + switchWidget.setOnCheckedChangeListener(this); + mSwitchBar.setOnClickListener(v -> { + switchWidget.setChecked(!switchWidget.isChecked()); + mSwitchBar.setActivated(switchWidget.isChecked()); }); mTextView = (TextView) view.findViewById(R.id.switch_text); - mSwitch = (Switch) switchBar.findViewById(android.R.id.switch_widget); - mSwitch.setChecked(isEventReceiverEnabled()); - mSwitch.setOnCheckedChangeListener(this); - updateEnableStates(mSwitch.isChecked()); + updateEnableStates(switchWidget.isChecked()); } @Override @@ -164,6 +162,7 @@ public class FlipFlapSettingsFragment extends PreferenceFragment mTextView.setText(getString(masterSwitchEnabled ? R.string.switch_bar_on : R.string.switch_bar_off)); + mSwitchBar.setActivated(masterSwitchEnabled); } private boolean isEventReceiverEnabled() { |
