Loading res/drawable/ic_settings_lock_outline.xml +5 −5 Original line number Diff line number Diff line Loading @@ -16,12 +16,12 @@ --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24.0" android:viewportHeight="22.0" android:width="21dp" android:height="21dp" android:viewportWidth="21.0" android:viewportHeight="21.0" android:tint="?android:attr/colorAccent"> <path android:fillColor="@android:color/white" android:pathData="M12 17c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm6-9h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zM8.9 6c0-1.71 1.39-3.1 3.1-3.1s3.1 1.39 3.1 3.1v2H8.9V6zM18 20H6V10h12v10z" /> android:pathData="M8,16c1.1,0,2-0.9,2-2s-0.9-2-2-2s-2,0.9-2,2S6.9,16,8,16zM14,7h-1V5c0-2.8-2.2-5-5-5S3,2.2,3,5v2H2C0.9,7,0,7.9,0,9v10c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V9C16,7.9,15.1,7,14,7z M4.9,5c0-1.7,1.4-3.1,3.1-3.1s3.1,1.4,3.1,3.1v2H4.9V5z M14,19H2V9h12V19z" /> </vector> res/layout/spinner_dropdown_restricted_item.xml 0 → 100644 +22 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2015 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. --> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" style="?android:attr/spinnerDropDownItemStyle" android:singleLine="true" android:layout_width="wrap_content" android:layout_height="?android:attr/listPreferredItemHeightSmall" android:ellipsize="marquee" /> No newline at end of file res/values/colors.xml +2 −0 Original line number Diff line number Diff line Loading @@ -102,4 +102,6 @@ <!-- Accent color that matches the settings launcher icon --> <color name="icon_accent">#ffabffec</color> <color name="disabled_text_color">#66000000</color> <!-- 38% black --> </resources> res/xml/configure_notification_settings.xml +1 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ android:persistent="false" /> <!-- When device is locked --> <DropDownPreference <com.android.settings.RestrictedDropDownPreference android:key="lock_screen_notifications" android:title="@string/lock_screen_notifications_title" android:summary="%s" Loading src/com/android/settings/RestrictedDropDownPreference.java 0 → 100644 +155 −0 Original line number Diff line number Diff line /* * 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; import android.content.Context; import android.graphics.drawable.Drawable; import android.support.v7.preference.DropDownPreference; import android.support.v7.preference.PreferenceViewHolder; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.TextView; import java.util.ArrayList; import java.util.List; import com.android.settings.RestrictedLockUtils; import static com.android.settings.RestrictedLockUtils.EnforcedAdmin; public class RestrictedDropDownPreference extends DropDownPreference { private Spinner mSpinner; private final Drawable mRestrictedPadlock; private final int mRestrictedPadlockPadding; private List<RestrictedItem> mRestrictedItems = new ArrayList<>(); public RestrictedDropDownPreference(Context context) { this(context, null); } public RestrictedDropDownPreference(Context context, AttributeSet attrs) { super(context, attrs); mRestrictedPadlock = RestrictedLockUtils.getRestrictedPadlock(context); mRestrictedPadlockPadding = context.getResources().getDimensionPixelSize( R.dimen.restricted_lock_icon_padding); } private final OnItemSelectedListener mItemSelectedListener = new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View v, int position, long id) { if (position >= 0) { String value = getEntryValues()[position].toString(); RestrictedItem item = getRestrictedItemForEntryValue(value); if (item != null) { RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(), item.enforcedAdmin); mSpinner.setSelection(findIndexOfValue(getValue())); } else if (!value.equals(getValue()) && callChangeListener(value)) { setValue(value); } } } @Override public void onNothingSelected(AdapterView<?> parent) { // noop } }; @Override protected ArrayAdapter createAdapter() { return new RestrictedArrayItemAdapter(getContext()); } @Override public void setValue(String value) { if (getRestrictedItemForEntryValue(value) != null) { return; } super.setValue(value); } @Override public void onBindViewHolder(PreferenceViewHolder view) { super.onBindViewHolder(view); mSpinner = (Spinner) view.itemView.findViewById(R.id.spinner); mSpinner.setOnItemSelectedListener(mItemSelectedListener); } private class RestrictedArrayItemAdapter extends ArrayAdapter<String> { public RestrictedArrayItemAdapter(Context context) { super(context, R.layout.spinner_dropdown_restricted_item); } @Override public View getDropDownView(int position, View convertView, ViewGroup parent) { TextView view = (TextView) super.getView(position, convertView, parent); CharSequence entry = getItem(position); boolean isEntryRestricted = isRestrictedForEntry(entry); RestrictedLockUtils.setTextViewPadlock(getContext(), view, isEntryRestricted); view.setEnabled(!isEntryRestricted); return view; } } private boolean isRestrictedForEntry(CharSequence entry) { if (entry == null) { return false; } for (RestrictedItem item : mRestrictedItems) { if (entry.equals(item.entry)) { return true; } } return false; } private RestrictedItem getRestrictedItemForEntryValue(CharSequence entryValue) { if (entryValue == null) { return null; } for (RestrictedItem item : mRestrictedItems) { if (entryValue.equals(item.entryValue)) { return item; } } return null; } public void addRestrictedItem(RestrictedItem item) { mRestrictedItems.add(item); } public static class RestrictedItem { public CharSequence entry; public CharSequence entryValue; public EnforcedAdmin enforcedAdmin; public RestrictedItem(CharSequence entry, CharSequence entryValue, EnforcedAdmin enforcedAdmin) { this.entry = entry; this.entryValue = entryValue; this.enforcedAdmin = enforcedAdmin; } } } No newline at end of file Loading
res/drawable/ic_settings_lock_outline.xml +5 −5 Original line number Diff line number Diff line Loading @@ -16,12 +16,12 @@ --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24.0" android:viewportHeight="22.0" android:width="21dp" android:height="21dp" android:viewportWidth="21.0" android:viewportHeight="21.0" android:tint="?android:attr/colorAccent"> <path android:fillColor="@android:color/white" android:pathData="M12 17c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm6-9h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zM8.9 6c0-1.71 1.39-3.1 3.1-3.1s3.1 1.39 3.1 3.1v2H8.9V6zM18 20H6V10h12v10z" /> android:pathData="M8,16c1.1,0,2-0.9,2-2s-0.9-2-2-2s-2,0.9-2,2S6.9,16,8,16zM14,7h-1V5c0-2.8-2.2-5-5-5S3,2.2,3,5v2H2C0.9,7,0,7.9,0,9v10c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V9C16,7.9,15.1,7,14,7z M4.9,5c0-1.7,1.4-3.1,3.1-3.1s3.1,1.4,3.1,3.1v2H4.9V5z M14,19H2V9h12V19z" /> </vector>
res/layout/spinner_dropdown_restricted_item.xml 0 → 100644 +22 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2015 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. --> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" style="?android:attr/spinnerDropDownItemStyle" android:singleLine="true" android:layout_width="wrap_content" android:layout_height="?android:attr/listPreferredItemHeightSmall" android:ellipsize="marquee" /> No newline at end of file
res/values/colors.xml +2 −0 Original line number Diff line number Diff line Loading @@ -102,4 +102,6 @@ <!-- Accent color that matches the settings launcher icon --> <color name="icon_accent">#ffabffec</color> <color name="disabled_text_color">#66000000</color> <!-- 38% black --> </resources>
res/xml/configure_notification_settings.xml +1 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ android:persistent="false" /> <!-- When device is locked --> <DropDownPreference <com.android.settings.RestrictedDropDownPreference android:key="lock_screen_notifications" android:title="@string/lock_screen_notifications_title" android:summary="%s" Loading
src/com/android/settings/RestrictedDropDownPreference.java 0 → 100644 +155 −0 Original line number Diff line number Diff line /* * 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; import android.content.Context; import android.graphics.drawable.Drawable; import android.support.v7.preference.DropDownPreference; import android.support.v7.preference.PreferenceViewHolder; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.TextView; import java.util.ArrayList; import java.util.List; import com.android.settings.RestrictedLockUtils; import static com.android.settings.RestrictedLockUtils.EnforcedAdmin; public class RestrictedDropDownPreference extends DropDownPreference { private Spinner mSpinner; private final Drawable mRestrictedPadlock; private final int mRestrictedPadlockPadding; private List<RestrictedItem> mRestrictedItems = new ArrayList<>(); public RestrictedDropDownPreference(Context context) { this(context, null); } public RestrictedDropDownPreference(Context context, AttributeSet attrs) { super(context, attrs); mRestrictedPadlock = RestrictedLockUtils.getRestrictedPadlock(context); mRestrictedPadlockPadding = context.getResources().getDimensionPixelSize( R.dimen.restricted_lock_icon_padding); } private final OnItemSelectedListener mItemSelectedListener = new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View v, int position, long id) { if (position >= 0) { String value = getEntryValues()[position].toString(); RestrictedItem item = getRestrictedItemForEntryValue(value); if (item != null) { RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(), item.enforcedAdmin); mSpinner.setSelection(findIndexOfValue(getValue())); } else if (!value.equals(getValue()) && callChangeListener(value)) { setValue(value); } } } @Override public void onNothingSelected(AdapterView<?> parent) { // noop } }; @Override protected ArrayAdapter createAdapter() { return new RestrictedArrayItemAdapter(getContext()); } @Override public void setValue(String value) { if (getRestrictedItemForEntryValue(value) != null) { return; } super.setValue(value); } @Override public void onBindViewHolder(PreferenceViewHolder view) { super.onBindViewHolder(view); mSpinner = (Spinner) view.itemView.findViewById(R.id.spinner); mSpinner.setOnItemSelectedListener(mItemSelectedListener); } private class RestrictedArrayItemAdapter extends ArrayAdapter<String> { public RestrictedArrayItemAdapter(Context context) { super(context, R.layout.spinner_dropdown_restricted_item); } @Override public View getDropDownView(int position, View convertView, ViewGroup parent) { TextView view = (TextView) super.getView(position, convertView, parent); CharSequence entry = getItem(position); boolean isEntryRestricted = isRestrictedForEntry(entry); RestrictedLockUtils.setTextViewPadlock(getContext(), view, isEntryRestricted); view.setEnabled(!isEntryRestricted); return view; } } private boolean isRestrictedForEntry(CharSequence entry) { if (entry == null) { return false; } for (RestrictedItem item : mRestrictedItems) { if (entry.equals(item.entry)) { return true; } } return false; } private RestrictedItem getRestrictedItemForEntryValue(CharSequence entryValue) { if (entryValue == null) { return null; } for (RestrictedItem item : mRestrictedItems) { if (entryValue.equals(item.entryValue)) { return item; } } return null; } public void addRestrictedItem(RestrictedItem item) { mRestrictedItems.add(item); } public static class RestrictedItem { public CharSequence entry; public CharSequence entryValue; public EnforcedAdmin enforcedAdmin; public RestrictedItem(CharSequence entry, CharSequence entryValue, EnforcedAdmin enforcedAdmin) { this.entry = entry; this.entryValue = entryValue; this.enforcedAdmin = enforcedAdmin; } } } No newline at end of file