diff options
| author | 2022-02-15 07:26:25 +0000 | |
|---|---|---|
| committer | 2022-02-15 07:26:25 +0000 | |
| commit | 1fd7efc75dfb066d3d331d5f8e263f5c8421fc3a (patch) | |
| tree | 39661a8399678bd79409a0d2158423de608b4d45 | |
| parent | 1f93f1232277bc474fff88d672d097e6b71d8b13 (diff) | |
| parent | e3ce6a703c3b11e6659b6109903e427300199a09 (diff) | |
Merge "Remove restricted icon"
8 files changed, 3 insertions, 98 deletions
diff --git a/packages/SettingsLib/MainSwitchPreference/res/layout-v31/settingslib_main_switch_bar.xml b/packages/SettingsLib/MainSwitchPreference/res/layout-v31/settingslib_main_switch_bar.xml index 30748e6244cb..d2a4de4aa86f 100644 --- a/packages/SettingsLib/MainSwitchPreference/res/layout-v31/settingslib_main_switch_bar.xml +++ b/packages/SettingsLib/MainSwitchPreference/res/layout-v31/settingslib_main_switch_bar.xml @@ -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 diff --git a/packages/SettingsLib/res/layout/restricted_popup_menu_item.xml b/packages/SettingsLib/res/layout/restricted_popup_menu_item.xml index 923d022aea68..52d77758051f 100644 --- a/packages/SettingsLib/res/layout/restricted_popup_menu_item.xml +++ b/packages/SettingsLib/res/layout/restricted_popup_menu_item.xml @@ -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> diff --git a/packages/SettingsLib/res/layout/restricted_preference_widget_primary_switch.xml b/packages/SettingsLib/res/layout/restricted_preference_widget_primary_switch.xml deleted file mode 100644 index 69df7516a82a..000000000000 --- a/packages/SettingsLib/res/layout/restricted_preference_widget_primary_switch.xml +++ /dev/null @@ -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>
\ No newline at end of file diff --git a/packages/SettingsLib/res/layout/restricted_switch_widget.xml b/packages/SettingsLib/res/layout/restricted_switch_widget.xml deleted file mode 100644 index 1520ac88f5db..000000000000 --- a/packages/SettingsLib/res/layout/restricted_switch_widget.xml +++ /dev/null @@ -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> diff --git a/packages/SettingsLib/src/com/android/settingslib/PrimarySwitchPreference.java b/packages/SettingsLib/src/com/android/settingslib/PrimarySwitchPreference.java index 246fc8ddd466..b43b44421fb8 100644 --- a/packages/SettingsLib/src/com/android/settingslib/PrimarySwitchPreference.java +++ b/packages/SettingsLib/src/com/android/settingslib/PrimarySwitchPreference.java @@ -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) { diff --git a/packages/SettingsLib/src/com/android/settingslib/RestrictedPreference.java b/packages/SettingsLib/src/com/android/settingslib/RestrictedPreference.java index 81146fa9ffd1..db2a6ec2da68 100644 --- a/packages/SettingsLib/src/com/android/settingslib/RestrictedPreference.java +++ b/packages/SettingsLib/src/com/android/settingslib/RestrictedPreference.java @@ -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; @@ -67,23 +66,9 @@ public class RestrictedPreference extends TwoTargetPreference { } @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 diff --git a/packages/SettingsLib/src/com/android/settingslib/RestrictedSwitchPreference.java b/packages/SettingsLib/src/com/android/settingslib/RestrictedSwitchPreference.java index 342189d8aa4c..c607d742938a 100644 --- a/packages/SettingsLib/src/com/android/settingslib/RestrictedSwitchPreference.java +++ b/packages/SettingsLib/src/com/android/settingslib/RestrictedSwitchPreference.java @@ -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) { diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/PrimarySwitchPreferenceTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/PrimarySwitchPreferenceTest.java index 4e2b63b6be57..9c16740061fe 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/PrimarySwitchPreferenceTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/PrimarySwitchPreferenceTest.java @@ -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 |