Remove restricted icon
Bug: 195401182 Test: robotest Change-Id: I6b22b3b9b62812eb08f10492bd2d7908cce89d39
This commit is contained in:
@@ -1,46 +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
|
|
||||||
-->
|
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<CheckBox
|
|
||||||
android:id="@+id/lockscreen_remote_input"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_marginStart="20dp"
|
|
||||||
android:paddingStart="20dp"
|
|
||||||
android:paddingEnd="?android:attr/dialogPreferredPadding"
|
|
||||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
|
||||||
android:textColor="?android:attr/textColorAlertDialogListItem"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:text="@string/lockscreen_remote_input"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/restricted_lock_icon_remote_input"
|
|
||||||
android:layout_width="@*android:dimen/config_restrictedIconSize"
|
|
||||||
android:layout_height="@*android:dimen/config_restrictedIconSize"
|
|
||||||
android:tint="?android:attr/colorAccent"
|
|
||||||
android:src="@*android:drawable/ic_info"
|
|
||||||
android:layout_marginEnd="?android:attr/dialogPreferredPadding"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:scaleType="centerInside" />
|
|
||||||
</LinearLayout>
|
|
@@ -35,14 +35,4 @@
|
|||||||
android:drawableStart="?android:attr/listChoiceIndicatorSingle"
|
android:drawableStart="?android:attr/listChoiceIndicatorSingle"
|
||||||
android:drawablePadding="20dp"
|
android:drawablePadding="20dp"
|
||||||
android:ellipsize="marquee" />
|
android:ellipsize="marquee" />
|
||||||
<ImageView
|
|
||||||
android:id="@+id/restricted_lock_icon"
|
|
||||||
android:layout_width="@*android:dimen/config_restrictedIconSize"
|
|
||||||
android:layout_height="@*android:dimen/config_restrictedIconSize"
|
|
||||||
android:tint="?android:attr/colorAccent"
|
|
||||||
android:src="@*android:drawable/ic_info"
|
|
||||||
android:layout_marginLeft="@dimen/restricted_icon_padding"
|
|
||||||
android:baselineAlignBottom="true"
|
|
||||||
android:scaleType="centerInside"
|
|
||||||
android:visibility="gone" />
|
|
||||||
</com.android.settings.CheckableLinearLayout>
|
</com.android.settings.CheckableLinearLayout>
|
||||||
|
@@ -1,31 +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
|
|
||||||
-->
|
|
||||||
<FrameLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<view android:id="@+id/spinner"
|
|
||||||
class="com.android.settings.notification.RestrictedDropDownPreference$ReselectionSpinner"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:visibility="invisible"
|
|
||||||
android:layout_marginStart="@dimen/preference_no_icon_padding_start"/>
|
|
||||||
|
|
||||||
<include layout="@layout/settingslib_preference" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
@@ -1,63 +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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<com.android.settings.CheckableLinearLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:background="?android:attr/selectableItemBackground"
|
|
||||||
android:minHeight="?android:attr/listPreferredItemHeightSmall">
|
|
||||||
|
|
||||||
<com.android.settings.CheckableLinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:paddingStart="20dp"
|
|
||||||
android:paddingEnd="?android:attr/dialogPreferredPadding">
|
|
||||||
<CheckedTextView
|
|
||||||
android:id="@android:id/title"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
|
||||||
android:textColor="?android:attr/textColorAlertDialogListItem"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:drawableStart="?android:attr/listChoiceIndicatorSingle"
|
|
||||||
android:ellipsize="marquee" />
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/restricted_icon"
|
|
||||||
android:layout_width="@*android:dimen/config_restrictedIconSize"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:scaleType="centerInside"
|
|
||||||
android:tint="?android:attr/colorAccent"
|
|
||||||
android:src="@*android:drawable/ic_info"
|
|
||||||
android:layout_marginLeft="@dimen/restricted_icon_padding"
|
|
||||||
android:visibility="gone" />
|
|
||||||
</com.android.settings.CheckableLinearLayout>
|
|
||||||
|
|
||||||
|
|
||||||
<TextView android:id="@android:id/summary"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingBottom="8dp"
|
|
||||||
android:paddingStart="52dp"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
android:maxLines="10" />
|
|
||||||
|
|
||||||
</com.android.settings.CheckableLinearLayout>
|
|
@@ -1,37 +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.
|
|
||||||
-->
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:gravity="center_vertical">
|
|
||||||
<TextView android:id="@android:id/text1"
|
|
||||||
style="?android:attr/spinnerDropDownItemStyle"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_height="?android:attr/listPreferredItemHeightSmall"
|
|
||||||
android:ellipsize="marquee" />
|
|
||||||
<ImageView android:id="@+id/restricted_icon"
|
|
||||||
android:layout_width="@*android:dimen/config_restrictedIconSize"
|
|
||||||
android:layout_height="@*android:dimen/config_restrictedIconSize"
|
|
||||||
android:tint="?android:attr/colorAccent"
|
|
||||||
android:src="@*android:drawable/ic_info"
|
|
||||||
android:baselineAlignBottom="true"
|
|
||||||
android:layout_marginEnd="@dimen/restricted_icon_padding"
|
|
||||||
android:gravity="end|center_vertical"
|
|
||||||
android:visibility="gone" />
|
|
||||||
</LinearLayout>
|
|
@@ -30,7 +30,6 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.CheckedTextView;
|
import android.widget.CheckedTextView;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.ListAdapter;
|
import android.widget.ListAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
@@ -53,7 +52,6 @@ public class RestrictedListPreference extends CustomListPreference {
|
|||||||
|
|
||||||
public RestrictedListPreference(Context context, AttributeSet attrs) {
|
public RestrictedListPreference(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
setWidgetLayoutResource(R.layout.restricted_icon);
|
|
||||||
mHelper = new RestrictedPreferenceHelper(context, this, attrs);
|
mHelper = new RestrictedPreferenceHelper(context, this, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,10 +65,6 @@ public class RestrictedListPreference extends CustomListPreference {
|
|||||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||||
super.onBindViewHolder(holder);
|
super.onBindViewHolder(holder);
|
||||||
mHelper.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
|
@Override
|
||||||
@@ -187,11 +181,9 @@ public class RestrictedListPreference extends CustomListPreference {
|
|||||||
View root = super.getView(position, convertView, parent);
|
View root = super.getView(position, convertView, parent);
|
||||||
CharSequence entry = getItem(position);
|
CharSequence entry = getItem(position);
|
||||||
CheckedTextView text = (CheckedTextView) root.findViewById(R.id.text1);
|
CheckedTextView text = (CheckedTextView) root.findViewById(R.id.text1);
|
||||||
ImageView padlock = (ImageView) root.findViewById(R.id.restricted_lock_icon);
|
|
||||||
if (isRestrictedForEntry(entry)) {
|
if (isRestrictedForEntry(entry)) {
|
||||||
text.setEnabled(false);
|
text.setEnabled(false);
|
||||||
text.setChecked(false);
|
text.setChecked(false);
|
||||||
padlock.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
} else {
|
||||||
if (mSelectedIndex != -1) {
|
if (mSelectedIndex != -1) {
|
||||||
text.setChecked(position == mSelectedIndex);
|
text.setChecked(position == mSelectedIndex);
|
||||||
@@ -199,7 +191,6 @@ public class RestrictedListPreference extends CustomListPreference {
|
|||||||
if (!text.isEnabled()) {
|
if (!text.isEnabled()) {
|
||||||
text.setEnabled(true);
|
text.setEnabled(true);
|
||||||
}
|
}
|
||||||
padlock.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
@@ -48,7 +48,6 @@ public class UnrestrictedDataAccessPreference extends AppSwitchPreference implem
|
|||||||
ApplicationsState applicationsState, DataSaverBackend dataSaverBackend,
|
ApplicationsState applicationsState, DataSaverBackend dataSaverBackend,
|
||||||
DashboardFragment parentFragment) {
|
DashboardFragment parentFragment) {
|
||||||
super(context);
|
super(context);
|
||||||
setWidgetLayoutResource(R.layout.restricted_switch_widget);
|
|
||||||
mHelper = new RestrictedPreferenceHelper(context, this, null);
|
mHelper = new RestrictedPreferenceHelper(context, this, null);
|
||||||
mEntry = entry;
|
mEntry = entry;
|
||||||
mDataUsageState = (AppStateDataUsageBridge.DataUsageState) mEntry.extraInfo;
|
mDataUsageState = (AppStateDataUsageBridge.DataUsageState) mEntry.extraInfo;
|
||||||
@@ -131,10 +130,6 @@ public class UnrestrictedDataAccessPreference extends AppSwitchPreference implem
|
|||||||
super.onBindViewHolder(holder);
|
super.onBindViewHolder(holder);
|
||||||
|
|
||||||
mHelper.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
|
@Override
|
||||||
|
@@ -97,23 +97,19 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
|
|||||||
|
|
||||||
public PrivateDnsModeDialogPreference(Context context) {
|
public PrivateDnsModeDialogPreference(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrivateDnsModeDialogPreference(Context context, AttributeSet attrs) {
|
public PrivateDnsModeDialogPreference(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrivateDnsModeDialogPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
public PrivateDnsModeDialogPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrivateDnsModeDialogPreference(Context context, AttributeSet attrs, int defStyleAttr,
|
public PrivateDnsModeDialogPreference(Context context, AttributeSet attrs, int defStyleAttr,
|
||||||
int defStyleRes) {
|
int defStyleRes) {
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final AnnotationSpan.LinkInfo mUrlLinkInfo = new AnnotationSpan.LinkInfo(
|
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
|
@Override
|
||||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||||
super.onBindViewHolder(holder);
|
super.onBindViewHolder(holder);
|
||||||
@@ -146,13 +136,6 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
|
|||||||
// by the controller.
|
// by the controller.
|
||||||
holder.itemView.setEnabled(true);
|
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
|
@Override
|
||||||
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -20,12 +20,10 @@ import android.content.Context;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
import androidx.preference.PreferenceViewHolder;
|
import androidx.preference.PreferenceViewHolder;
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
import com.android.settingslib.RestrictedPreferenceHelper;
|
import com.android.settingslib.RestrictedPreferenceHelper;
|
||||||
import com.android.settingslib.widget.AppPreference;
|
import com.android.settingslib.widget.AppPreference;
|
||||||
@@ -55,7 +53,6 @@ public class RestrictedAppPreference extends AppPreference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initialize(AttributeSet attrs, String userRestriction) {
|
private void initialize(AttributeSet attrs, String userRestriction) {
|
||||||
setWidgetLayoutResource(R.layout.restricted_icon);
|
|
||||||
mHelper = new RestrictedPreferenceHelper(getContext(), this, attrs);
|
mHelper = new RestrictedPreferenceHelper(getContext(), this, attrs);
|
||||||
this.userRestriction = userRestriction;
|
this.userRestriction = userRestriction;
|
||||||
}
|
}
|
||||||
@@ -64,10 +61,6 @@ public class RestrictedAppPreference extends AppPreference {
|
|||||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||||
super.onBindViewHolder(holder);
|
super.onBindViewHolder(holder);
|
||||||
mHelper.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
|
@Override
|
||||||
|
Reference in New Issue
Block a user