diff options
3 files changed, 40 insertions, 1 deletions
diff --git a/packages/SettingsLib/MainSwitchPreference/res/drawable/settingslib_ic_info.xml b/packages/SettingsLib/MainSwitchPreference/res/drawable/settingslib_ic_info.xml new file mode 100644 index 000000000000..c8037c85c850 --- /dev/null +++ b/packages/SettingsLib/MainSwitchPreference/res/drawable/settingslib_ic_info.xml @@ -0,0 +1,26 @@ +<!-- + Copyright (C) 2021 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. +--> +<!-- copy from frameworks/base/core/res/res/drawable/ic_info.xml--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24" + android:tint="?attr/colorControlNormal"> + <path + android:fillColor="@android:color/white" + android:pathData="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/> +</vector>
\ No newline at end of file diff --git a/packages/SettingsLib/MainSwitchPreference/res/layout/settingslib_main_switch_bar.xml b/packages/SettingsLib/MainSwitchPreference/res/layout/settingslib_main_switch_bar.xml index d0c2d0b5937d..59ae1221ddd3 100644 --- a/packages/SettingsLib/MainSwitchPreference/res/layout/settingslib_main_switch_bar.xml +++ b/packages/SettingsLib/MainSwitchPreference/res/layout/settingslib_main_switch_bar.xml @@ -42,7 +42,7 @@ android:theme="@android:style/Theme.Material" android:layout_gravity="center_vertical" android:layout_marginEnd="@dimen/settingslib_restricted_icon_margin_end" - android:src="@android:drawable/ic_info" + android:src="@drawable/settingslib_ic_info" android:visibility="gone"/> <Switch @@ -51,6 +51,8 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginEnd="@dimen/settingslib_switchbar_subsettings_margin_end" + android:focusable="false" + android:clickable="false" android:theme="@style/SwitchBar.Switch.Settingslib"/> </LinearLayout> diff --git a/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java b/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java index 6d5615dfe52f..383bf8eaf2e7 100644 --- a/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java +++ b/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java @@ -30,6 +30,7 @@ import android.widget.Switch; import android.widget.TextView; import androidx.annotation.ColorInt; +import androidx.annotation.Nullable; import com.android.settingslib.utils.BuildCompatUtils; @@ -97,6 +98,10 @@ public class MainSwitchBar extends LinearLayout implements CompoundButton.OnChec } addOnSwitchChangeListener((switchView, isChecked) -> setChecked(isChecked)); + if (mSwitch.getVisibility() == VISIBLE) { + mSwitch.setOnCheckedChangeListener(this); + } + setChecked(mSwitch.isChecked()); if (attrs != null) { @@ -118,6 +123,12 @@ public class MainSwitchBar extends LinearLayout implements CompoundButton.OnChec } @Override + public void setOnClickListener(@Nullable OnClickListener l) { + super.setOnClickListener(l); + mSwitch.setOnClickListener(l); + } + + @Override public boolean performClick() { return mSwitch.performClick(); } |