Notification settings: update lockscreen option language.
When device is locked: - Show all notification content - Hide sensitive notification content Change-Id: I641bca5f1b5f0ab1b2dc381fc0af7f32a9f2bc6d
This commit is contained in:
@@ -5030,15 +5030,15 @@
|
||||
<!-- Notifications on lockscreen -->
|
||||
<!-- Label for checkbox controlling the contents of notifications shown on
|
||||
the secure lockscreen [CHAR LIMIT=25] -->
|
||||
<string name="lock_screen_notifications">Show on lock screen</string>
|
||||
<string name="lock_screen_notifications">When device is locked</string>
|
||||
<!-- Summary for lock_screen_notifications: sensitive information will be
|
||||
hidden or redacted from notifications shown on a secure lock screen
|
||||
[CHAR LIMIT=50] -->
|
||||
<string name="lock_screen_notifications_summary_off">Unless content is sensitive</string>
|
||||
<string name="lock_screen_notifications_summary_hide">Hide sensitive notification content</string>
|
||||
<!-- Summary for lock_screen_notifications: all information will be
|
||||
shown in notifications shown on a secure lock screen
|
||||
[CHAR LIMIT=50] -->
|
||||
<string name="lock_screen_notifications_summary_on">All notifications</string>
|
||||
<string name="lock_screen_notifications_summary_show">Show all notification content</string>
|
||||
|
||||
<!-- [CHAR LIMIT=30] Notification settings screen, setting option name -->
|
||||
<string name="title_zen_mode">Do not disturb</string>
|
||||
|
@@ -36,11 +36,9 @@
|
||||
android:title="@string/heads_up_enabled_title"
|
||||
android:persistent="false" />
|
||||
|
||||
<CheckBoxPreference
|
||||
<com.android.settings.notification.DropDownPreference
|
||||
android:key="toggle_lock_screen_notifications"
|
||||
android:title="@string/lock_screen_notifications"
|
||||
android:summaryOff="@string/lock_screen_notifications_summary_off"
|
||||
android:summaryOn="@string/lock_screen_notifications_summary_on"
|
||||
android:persistent="false" />
|
||||
|
||||
<PreferenceScreen
|
||||
|
110
src/com/android/settings/notification/DropDownPreference.java
Normal file
110
src/com/android/settings/notification/DropDownPreference.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (C) 2014 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.content.Context;
|
||||
import android.preference.Preference;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
|
||||
public class DropDownPreference extends Preference {
|
||||
private final Context mContext;
|
||||
private final ArrayAdapter<String> mAdapter;
|
||||
private final Spinner mSpinner;
|
||||
|
||||
private Callback mCallback;
|
||||
|
||||
public DropDownPreference(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public DropDownPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mContext = context;
|
||||
mAdapter = new ArrayAdapter<String>(mContext,
|
||||
android.R.layout.simple_spinner_dropdown_item);
|
||||
|
||||
mSpinner = new Spinner(mContext);
|
||||
|
||||
mSpinner.setVisibility(View.INVISIBLE);
|
||||
mSpinner.setAdapter(mAdapter);
|
||||
mSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
|
||||
setSelectedItem(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
// noop
|
||||
}
|
||||
});
|
||||
setPersistent(false);
|
||||
setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
mSpinner.performClick();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setDropDownWidth(int dimenResId) {
|
||||
mSpinner.setDropDownWidth(mContext.getResources().getDimensionPixelSize(dimenResId));
|
||||
}
|
||||
|
||||
public void setCallback(Callback callback) {
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
public void setSelectedItem(int position) {
|
||||
if (mCallback != null && !mCallback.onItemSelected(position)) {
|
||||
return;
|
||||
}
|
||||
mSpinner.setSelection(position);
|
||||
setSummary(mAdapter.getItem(position));
|
||||
final boolean disableDependents = position == 0;
|
||||
notifyDependencyChange(disableDependents);
|
||||
}
|
||||
|
||||
public void addItem(int resId) {
|
||||
mAdapter.add(mContext.getResources().getString(resId));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindView(View view) {
|
||||
super.onBindView(view);
|
||||
if (view.equals(mSpinner.getParent())) return;
|
||||
if (mSpinner.getParent() != null) {
|
||||
((ViewGroup)mSpinner.getParent()).removeView(mSpinner);
|
||||
}
|
||||
final ViewGroup vg = (ViewGroup)view;
|
||||
vg.addView(mSpinner, 0);
|
||||
final ViewGroup.LayoutParams lp = mSpinner.getLayoutParams();
|
||||
lp.width = 0;
|
||||
mSpinner.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
public interface Callback {
|
||||
boolean onItemSelected(int pos);
|
||||
}
|
||||
}
|
@@ -57,7 +57,7 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
||||
|
||||
private Preference mNotificationSoundPreference;
|
||||
private Preference mNotificationAccess;
|
||||
private TwoStatePreference mLockscreenNotifications;
|
||||
private DropDownPreference mLockscreenNotifications;
|
||||
private TwoStatePreference mHeadsUp;
|
||||
private TwoStatePreference mNotificationPulse;
|
||||
|
||||
@@ -113,12 +113,24 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
||||
refreshNotificationListeners();
|
||||
|
||||
mLockscreenNotifications
|
||||
= (TwoStatePreference) root.findPreference(KEY_LOCK_SCREEN_NOTIFICATIONS);
|
||||
= (DropDownPreference) root.findPreference(KEY_LOCK_SCREEN_NOTIFICATIONS);
|
||||
if (mLockscreenNotifications != null) {
|
||||
if (!getDeviceLockscreenNotificationsEnabled()) {
|
||||
root.removePreference(mLockscreenNotifications);
|
||||
} else {
|
||||
mLockscreenNotifications.setChecked(getLockscreenAllowPrivateNotifications());
|
||||
mLockscreenNotifications.addItem(R.string.lock_screen_notifications_summary_show);
|
||||
mLockscreenNotifications.addItem(R.string.lock_screen_notifications_summary_hide);
|
||||
final int pos = getLockscreenAllowPrivateNotifications() ? 0 : 1;
|
||||
mLockscreenNotifications.setSelectedItem(pos);
|
||||
mLockscreenNotifications.setCallback(new DropDownPreference.Callback() {
|
||||
@Override
|
||||
public boolean onItemSelected(int pos) {
|
||||
final int val = pos == 0 ? 1 : 0;
|
||||
Settings.Secure.putInt(getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, val);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,11 +176,7 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
||||
final String key = preference.getKey();
|
||||
|
||||
if (KEY_LOCK_SCREEN_NOTIFICATIONS.equals(key)) {
|
||||
Settings.Secure.putInt(getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
|
||||
mLockscreenNotifications.isChecked() ? 1 : 0);
|
||||
} else if (KEY_HEADS_UP.equals(key)) {
|
||||
if (KEY_HEADS_UP.equals(key)) {
|
||||
setHeadsUpMode(getContentResolver(), mHeadsUp.isChecked());
|
||||
} else if (KEY_NOTIFICATION_PULSE.equals(key)) {
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
|
@@ -47,12 +47,8 @@ import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
@@ -144,6 +140,7 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
|
||||
mStarred = new DropDownPreference(mContext);
|
||||
mStarred.setEnabled(false);
|
||||
mStarred.setTitle(R.string.zen_mode_from);
|
||||
mStarred.setDropDownWidth(R.dimen.zen_mode_dropdown_width);
|
||||
mStarred.addItem(R.string.zen_mode_from_anyone);
|
||||
mStarred.addItem(R.string.zen_mode_from_starred);
|
||||
mStarred.addItem(R.string.zen_mode_from_contacts);
|
||||
@@ -168,6 +165,7 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
|
||||
mWhen = new DropDownPreference(mContext);
|
||||
mWhen.setKey(KEY_WHEN);
|
||||
mWhen.setTitle(R.string.zen_mode_when);
|
||||
mWhen.setDropDownWidth(R.dimen.zen_mode_dropdown_width);
|
||||
mWhen.addItem(R.string.zen_mode_when_never);
|
||||
mWhen.addItem(R.string.zen_mode_when_every_night);
|
||||
mWhen.addItem(R.string.zen_mode_when_weeknights);
|
||||
@@ -462,80 +460,4 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
|
||||
boolean onSetTime(int hour, int minute);
|
||||
}
|
||||
}
|
||||
|
||||
private static class DropDownPreference extends Preference {
|
||||
private final Context mContext;
|
||||
private final ArrayAdapter<String> mAdapter;
|
||||
private final Spinner mSpinner;
|
||||
|
||||
private Callback mCallback;
|
||||
|
||||
public DropDownPreference(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
mAdapter = new ArrayAdapter<String>(mContext,
|
||||
android.R.layout.simple_spinner_dropdown_item);
|
||||
|
||||
mSpinner = new Spinner(mContext);
|
||||
mSpinner.setDropDownWidth(mContext.getResources()
|
||||
.getDimensionPixelSize(R.dimen.zen_mode_dropdown_width));
|
||||
mSpinner.setVisibility(View.INVISIBLE);
|
||||
mSpinner.setAdapter(mAdapter);
|
||||
mSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
|
||||
setSelectedItem(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
// noop
|
||||
}
|
||||
});
|
||||
setPersistent(false);
|
||||
setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
mSpinner.performClick();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setCallback(Callback callback) {
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
public void setSelectedItem(int position) {
|
||||
if (mCallback != null && !mCallback.onItemSelected(position)) {
|
||||
return;
|
||||
}
|
||||
mSpinner.setSelection(position);
|
||||
setSummary(mAdapter.getItem(position));
|
||||
final boolean disableDependents = position == 0;
|
||||
notifyDependencyChange(disableDependents);
|
||||
}
|
||||
|
||||
public void addItem(int resId) {
|
||||
mAdapter.add(mContext.getResources().getString(resId));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindView(View view) {
|
||||
super.onBindView(view);
|
||||
if (view.equals(mSpinner.getParent())) return;
|
||||
if (mSpinner.getParent() != null) {
|
||||
((ViewGroup)mSpinner.getParent()).removeView(mSpinner);
|
||||
}
|
||||
final ViewGroup vg = (ViewGroup)view;
|
||||
vg.addView(mSpinner, 0);
|
||||
final ViewGroup.LayoutParams lp = mSpinner.getLayoutParams();
|
||||
lp.width = 0;
|
||||
mSpinner.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
public interface Callback {
|
||||
boolean onItemSelected(int pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user