Merge "Remove restricted icon"

This commit is contained in:
TreeHugger Robot
2022-02-15 07:26:25 +00:00
committed by Android (Google) Code Review
8 changed files with 3 additions and 98 deletions

View File

@@ -50,7 +50,7 @@
android:tint="?android:attr/colorAccent"
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

View File

@@ -34,14 +34,4 @@
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="?android:attr/textColorAlertDialogListItem" />
<ImageView
android:id="@+id/restricted_icon"
android:layout_width="@*android:dimen/config_restrictedIconSize"
android:layout_height="@*android:dimen/config_restrictedIconSize"
android:layout_alignParentRight="true"
android:scaleType="centerInside"
android:src="@*android:drawable/ic_info"
android:tint="?android:attr/colorAccent"
android:visibility="gone" />
</RelativeLayout>

View File

@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<include layout="@layout/restricted_icon"/>
<include layout="@layout/preference_widget_primary_switch"/>
</merge>

View File

@@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 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.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/restricted_icon"
android:layout_width="@dimen/two_target_min_width"
android:layout_height="@*android:dimen/config_restrictedIconSize"
android:tint="?android:attr/colorAccent"
android:src="@*android:drawable/ic_info"
android:gravity="center" />
<!-- Based off frameworks/base/core/res/res/layout/preference_widget_switch.xml -->
<Switch xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/switch_widget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:clickable="false"
android:background="@null" />
</merge>

View File

@@ -59,7 +59,7 @@ public class PrimarySwitchPreference extends RestrictedPreference {
@Override
protected int getSecondTargetResId() {
return R.layout.restricted_preference_widget_primary_switch;
return R.layout.preference_widget_primary_switch;
}
@Override
@@ -67,7 +67,6 @@ public class PrimarySwitchPreference extends RestrictedPreference {
super.onBindViewHolder(holder);
final View switchWidget = holder.findViewById(R.id.switchWidget);
if (switchWidget != null) {
switchWidget.setVisibility(isDisabledByAdmin() ? View.GONE : View.VISIBLE);
switchWidget.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {

View File

@@ -22,7 +22,6 @@ import android.content.Context;
import android.os.Process;
import android.os.UserHandle;
import android.util.AttributeSet;
import android.view.View;
import androidx.core.content.res.TypedArrayUtils;
import androidx.preference.PreferenceManager;
@@ -66,24 +65,10 @@ public class RestrictedPreference extends TwoTargetPreference {
android.R.attr.preferenceStyle), 0, packageName, uid);
}
@Override
protected int getSecondTargetResId() {
return R.layout.restricted_icon;
}
@Override
protected boolean shouldHideSecondTarget() {
return !isDisabledByAdmin();
}
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
mHelper.onBindViewHolder(holder);
final View restrictedIcon = holder.findViewById(R.id.restricted_icon);
if (restrictedIcon != null) {
restrictedIcon.setVisibility(isDisabledByAdmin() ? View.VISIBLE : View.GONE);
}
}
@Override

View File

@@ -46,7 +46,6 @@ public class RestrictedSwitchPreference extends SwitchPreference {
public RestrictedSwitchPreference(Context context, AttributeSet attrs,
int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
setWidgetLayoutResource(R.layout.restricted_switch_widget);
mHelper = new RestrictedPreferenceHelper(context, this, attrs);
if (attrs != null) {
final TypedArray attributes = context.obtainStyledAttributes(attrs,
@@ -108,15 +107,6 @@ public class RestrictedSwitchPreference extends SwitchPreference {
switchSummary = mRestrictedSwitchSummary;
}
final View restrictedIcon = holder.findViewById(R.id.restricted_icon);
final View switchWidget = holder.findViewById(android.R.id.switch_widget);
if (restrictedIcon != null) {
restrictedIcon.setVisibility(isDisabledByAdmin() ? View.VISIBLE : View.GONE);
}
if (switchWidget != null) {
switchWidget.setVisibility(isDisabledByAdmin() ? View.GONE : View.VISIBLE);
}
final ImageView icon = holder.itemView.findViewById(android.R.id.icon);
if (mIconSize > 0) {

View File

@@ -53,13 +53,7 @@ public class PrimarySwitchPreferenceTest {
mHolder = PreferenceViewHolder.createInstanceForTests(inflater.inflate(
com.android.settingslib.R.layout.preference_two_target, null));
mWidgetView = mHolder.itemView.findViewById(android.R.id.widget_frame);
inflater.inflate(R.layout.restricted_preference_widget_primary_switch, mWidgetView, true);
}
@Test
public void createNewPreference_shouldSetLayout() {
assertThat(mPreference.getWidgetLayoutResource())
.isEqualTo(R.layout.restricted_preference_widget_primary_switch);
inflater.inflate(R.layout.preference_widget_primary_switch, mWidgetView, true);
}
@Test