From b1a48df4f71a2445cf3511b63a722c84befaee66 Mon Sep 17 00:00:00 2001 From: Edgar Wang Date: Fri, 7 Jan 2022 21:34:25 +0800 Subject: [PATCH] Remove restricted icon Bug: 195401182 Test: robotest Change-Id: I6b22b3b9b62812eb08f10492bd2d7908cce89d39 --- res/layout/lockscreen_remote_input.xml | 46 ----- res/layout/restricted_dialog_singlechoice.xml | 10 - res/layout/restricted_preference_dropdown.xml | 31 ---- res/layout/restricted_radio_with_summary.xml | 63 ------- .../spinner_dropdown_restricted_item.xml | 37 ---- .../settings/RestrictedListPreference.java | 9 - .../UnrestrictedDataAccessPreference.java | 5 - .../PrivateDnsModeDialogPreference.java | 17 -- .../NotificationLockscreenPreference.java | 175 ------------------ .../widget/RestrictedAppPreference.java | 7 - 10 files changed, 400 deletions(-) delete mode 100644 res/layout/lockscreen_remote_input.xml delete mode 100644 res/layout/restricted_preference_dropdown.xml delete mode 100644 res/layout/restricted_radio_with_summary.xml delete mode 100644 res/layout/spinner_dropdown_restricted_item.xml delete mode 100644 src/com/android/settings/notification/NotificationLockscreenPreference.java diff --git a/res/layout/lockscreen_remote_input.xml b/res/layout/lockscreen_remote_input.xml deleted file mode 100644 index 4fa44ce1b2e..00000000000 --- a/res/layout/lockscreen_remote_input.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - diff --git a/res/layout/restricted_dialog_singlechoice.xml b/res/layout/restricted_dialog_singlechoice.xml index a9984a84fc3..9b19884aa9f 100644 --- a/res/layout/restricted_dialog_singlechoice.xml +++ b/res/layout/restricted_dialog_singlechoice.xml @@ -35,14 +35,4 @@ android:drawableStart="?android:attr/listChoiceIndicatorSingle" android:drawablePadding="20dp" android:ellipsize="marquee" /> - diff --git a/res/layout/restricted_preference_dropdown.xml b/res/layout/restricted_preference_dropdown.xml deleted file mode 100644 index 8930e24bb28..00000000000 --- a/res/layout/restricted_preference_dropdown.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/res/layout/restricted_radio_with_summary.xml b/res/layout/restricted_radio_with_summary.xml deleted file mode 100644 index 5e7fcd82fe6..00000000000 --- a/res/layout/restricted_radio_with_summary.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - diff --git a/res/layout/spinner_dropdown_restricted_item.xml b/res/layout/spinner_dropdown_restricted_item.xml deleted file mode 100644 index d95e4be3894..00000000000 --- a/res/layout/spinner_dropdown_restricted_item.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - diff --git a/src/com/android/settings/RestrictedListPreference.java b/src/com/android/settings/RestrictedListPreference.java index bd3cd17432f..d75f1b8fae9 100644 --- a/src/com/android/settings/RestrictedListPreference.java +++ b/src/com/android/settings/RestrictedListPreference.java @@ -30,7 +30,6 @@ import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.CheckedTextView; -import android.widget.ImageView; import android.widget.ListAdapter; import android.widget.ListView; @@ -53,7 +52,6 @@ public class RestrictedListPreference extends CustomListPreference { public RestrictedListPreference(Context context, AttributeSet attrs) { super(context, attrs); - setWidgetLayoutResource(R.layout.restricted_icon); mHelper = new RestrictedPreferenceHelper(context, this, attrs); } @@ -67,10 +65,6 @@ public class RestrictedListPreference extends CustomListPreference { 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 @@ -187,11 +181,9 @@ public class RestrictedListPreference extends CustomListPreference { View root = super.getView(position, convertView, parent); CharSequence entry = getItem(position); CheckedTextView text = (CheckedTextView) root.findViewById(R.id.text1); - ImageView padlock = (ImageView) root.findViewById(R.id.restricted_lock_icon); if (isRestrictedForEntry(entry)) { text.setEnabled(false); text.setChecked(false); - padlock.setVisibility(View.VISIBLE); } else { if (mSelectedIndex != -1) { text.setChecked(position == mSelectedIndex); @@ -199,7 +191,6 @@ public class RestrictedListPreference extends CustomListPreference { if (!text.isEnabled()) { text.setEnabled(true); } - padlock.setVisibility(View.GONE); } return root; } diff --git a/src/com/android/settings/datausage/UnrestrictedDataAccessPreference.java b/src/com/android/settings/datausage/UnrestrictedDataAccessPreference.java index cd26ed16e8f..244ffc69e74 100644 --- a/src/com/android/settings/datausage/UnrestrictedDataAccessPreference.java +++ b/src/com/android/settings/datausage/UnrestrictedDataAccessPreference.java @@ -48,7 +48,6 @@ public class UnrestrictedDataAccessPreference extends AppSwitchPreference implem ApplicationsState applicationsState, DataSaverBackend dataSaverBackend, DashboardFragment parentFragment) { super(context); - setWidgetLayoutResource(R.layout.restricted_switch_widget); mHelper = new RestrictedPreferenceHelper(context, this, null); mEntry = entry; mDataUsageState = (AppStateDataUsageBridge.DataUsageState) mEntry.extraInfo; @@ -131,10 +130,6 @@ public class UnrestrictedDataAccessPreference extends AppSwitchPreference implem super.onBindViewHolder(holder); mHelper.onBindViewHolder(holder); - holder.findViewById(R.id.restricted_icon).setVisibility( - disabledByAdmin ? View.VISIBLE : View.GONE); - holder.findViewById(android.R.id.switch_widget).setVisibility( - disabledByAdmin ? View.GONE : View.VISIBLE); } @Override diff --git a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java index 442af3803c5..5c7c54eda37 100644 --- a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java +++ b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java @@ -97,23 +97,19 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat public PrivateDnsModeDialogPreference(Context context) { super(context); - initialize(); } public PrivateDnsModeDialogPreference(Context context, AttributeSet attrs) { super(context, attrs); - initialize(); } public PrivateDnsModeDialogPreference(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - initialize(); } public PrivateDnsModeDialogPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); - initialize(); } private final AnnotationSpan.LinkInfo mUrlLinkInfo = new AnnotationSpan.LinkInfo( @@ -131,12 +127,6 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat } }); - private void initialize() { - // Add the "Restricted" icon resource so that if the preference is disabled by the - // admin, an information button will be shown. - setWidgetLayoutResource(R.layout.restricted_icon); - } - @Override public void onBindViewHolder(PreferenceViewHolder holder) { super.onBindViewHolder(holder); @@ -146,13 +136,6 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat // by the controller. holder.itemView.setEnabled(true); } - - final View restrictedIcon = holder.findViewById(R.id.restricted_icon); - if (restrictedIcon != null) { - // Show the "Restricted" icon if, and only if, the preference was disabled by - // the admin. - restrictedIcon.setVisibility(isDisabledByAdmin() ? View.VISIBLE : View.GONE); - } } @Override diff --git a/src/com/android/settings/notification/NotificationLockscreenPreference.java b/src/com/android/settings/notification/NotificationLockscreenPreference.java deleted file mode 100644 index b2360148022..00000000000 --- a/src/com/android/settings/notification/NotificationLockscreenPreference.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * 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 - */ - -package com.android.settings.notification; - -import android.app.Dialog; -import android.content.Context; -import android.content.DialogInterface; -import android.os.Bundle; -import android.os.UserHandle; -import android.os.UserManager; -import android.provider.Settings; -import android.util.AttributeSet; -import android.view.View; -import android.widget.CheckBox; -import android.widget.CompoundButton; -import android.widget.ListView; - -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.app.AlertDialog.Builder; - -import com.android.settings.R; -import com.android.settings.RestrictedListPreference; -import com.android.settings.Utils; -import com.android.settingslib.RestrictedLockUtils; - -public class NotificationLockscreenPreference extends RestrictedListPreference { - - private boolean mAllowRemoteInput; - private Listener mListener; - private boolean mShowRemoteInput; - private boolean mRemoteInputCheckBoxEnabled = true; - private int mUserId = UserHandle.myUserId(); - private RestrictedLockUtils.EnforcedAdmin mAdminRestrictingRemoteInput; - - public NotificationLockscreenPreference(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public void setRemoteInputCheckBoxEnabled(boolean enabled) { - mRemoteInputCheckBoxEnabled = enabled; - } - - public void setRemoteInputRestricted(RestrictedLockUtils.EnforcedAdmin admin) { - mAdminRestrictingRemoteInput = admin; - } - - @Override - protected void onClick() { - final Context context = getContext(); - if (!Utils.startQuietModeDialogIfNecessary(context, UserManager.get(context), mUserId)) { - // Call super to create preference dialog only when work mode is on - // startQuietModeDialogIfNecessary will return false if mUserId is not a managed user - super.onClick(); - } - } - - public void setUserId(int userId) { - mUserId = userId; - } - - @Override - protected void onPrepareDialogBuilder(Builder builder, - DialogInterface.OnClickListener innerListener) { - - mListener = new Listener(innerListener); - builder.setSingleChoiceItems(createListAdapter(builder.getContext()), getSelectedValuePos(), - mListener); - mShowRemoteInput = getEntryValues().length == 3; - mAllowRemoteInput = Settings.Secure.getInt(getContext().getContentResolver(), - Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT, 0) != 0; - builder.setView(R.layout.lockscreen_remote_input); - } - - @Override - protected void onDialogCreated(Dialog dialog) { - super.onDialogCreated(dialog); - dialog.create(); - CheckBox checkbox = (CheckBox) dialog.findViewById(R.id.lockscreen_remote_input); - checkbox.setChecked(!mAllowRemoteInput); - checkbox.setOnCheckedChangeListener(mListener); - checkbox.setEnabled(mAdminRestrictingRemoteInput == null); - - View restricted = dialog.findViewById(R.id.restricted_lock_icon_remote_input); - restricted.setVisibility(mAdminRestrictingRemoteInput == null ? View.GONE : View.VISIBLE); - - if (mAdminRestrictingRemoteInput != null) { - checkbox.setClickable(false); - dialog.findViewById(com.android.internal.R.id.customPanel) - .setOnClickListener(mListener); - } - } - - @Override - protected void onDialogStateRestored(Dialog dialog, Bundle savedInstanceState) { - super.onDialogStateRestored(dialog, savedInstanceState); - ListView listView = ((AlertDialog) dialog).getListView(); - int selectedPosition = listView.getCheckedItemPosition(); - - View panel = dialog.findViewById(com.android.internal.R.id.customPanel); - panel.setVisibility(checkboxVisibilityForSelectedIndex(selectedPosition, - mShowRemoteInput)); - mListener.setView(panel); - } - - @Override - protected void onDialogClosed(boolean positiveResult) { - super.onDialogClosed(positiveResult); - Settings.Secure.putInt(getContext().getContentResolver(), - Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT, mAllowRemoteInput ? 1 : 0); - } - - @Override - protected boolean isAutoClosePreference() { - return false; - } - - private int checkboxVisibilityForSelectedIndex(int selected, - boolean showRemoteAtAll) { - return selected == 1 && showRemoteAtAll && mRemoteInputCheckBoxEnabled ? View.VISIBLE - : View.GONE; - } - - private class Listener implements DialogInterface.OnClickListener, - CompoundButton.OnCheckedChangeListener, View.OnClickListener { - - private final DialogInterface.OnClickListener mInner; - private View mView; - - public Listener(DialogInterface.OnClickListener inner) { - mInner = inner; - } - - @Override - public void onClick(DialogInterface dialog, int which) { - mInner.onClick(dialog, which); - ListView listView = ((AlertDialog) dialog).getListView(); - int selectedPosition = listView.getCheckedItemPosition(); - if (mView != null) { - mView.setVisibility( - checkboxVisibilityForSelectedIndex(selectedPosition, mShowRemoteInput)); - } - } - - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - mAllowRemoteInput = !isChecked; - } - - public void setView(View view) { - mView = view; - } - - @Override - public void onClick(View v) { - if (v.getId() == com.android.internal.R.id.customPanel) { - RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(), - mAdminRestrictingRemoteInput); - } - } - } -} diff --git a/src/com/android/settings/widget/RestrictedAppPreference.java b/src/com/android/settings/widget/RestrictedAppPreference.java index cd953571ab6..f93b935d5b0 100644 --- a/src/com/android/settings/widget/RestrictedAppPreference.java +++ b/src/com/android/settings/widget/RestrictedAppPreference.java @@ -20,12 +20,10 @@ import android.content.Context; import android.os.UserHandle; import android.text.TextUtils; import android.util.AttributeSet; -import android.view.View; import androidx.preference.PreferenceManager; import androidx.preference.PreferenceViewHolder; -import com.android.settings.R; import com.android.settingslib.RestrictedLockUtils; import com.android.settingslib.RestrictedPreferenceHelper; import com.android.settingslib.widget.AppPreference; @@ -55,7 +53,6 @@ public class RestrictedAppPreference extends AppPreference { } private void initialize(AttributeSet attrs, String userRestriction) { - setWidgetLayoutResource(R.layout.restricted_icon); mHelper = new RestrictedPreferenceHelper(getContext(), this, attrs); this.userRestriction = userRestriction; } @@ -64,10 +61,6 @@ public class RestrictedAppPreference extends AppPreference { 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