Merge "MainSwitchPreference minor fix"
This commit is contained in:
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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) {
|
||||
@@ -117,6 +122,12 @@ public class MainSwitchBar extends LinearLayout implements CompoundButton.OnChec
|
||||
propagateChecked(isChecked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnClickListener(@Nullable OnClickListener l) {
|
||||
super.setOnClickListener(l);
|
||||
mSwitch.setOnClickListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performClick() {
|
||||
return mSwitch.performClick();
|
||||
|
||||
Reference in New Issue
Block a user