diff options
| author | 2016-02-26 14:41:30 +0000 | |
|---|---|---|
| committer | 2016-02-26 14:41:31 +0000 | |
| commit | 3070d75bf3a6a054f299872a602569f3fceee02f (patch) | |
| tree | 8d70409a60ee3e911fc2190b473900339a6f7c0a | |
| parent | 573895bbea7cf349d615606004cdb85ba2ca814d (diff) | |
| parent | 4077945e1b3e0e1b5bcd9f57f8fa3fbeffb29c01 (diff) | |
Merge "Remove inline settings slider." into nyc-dev
5 files changed, 138 insertions, 37 deletions
diff --git a/packages/SystemUI/res/layout/notification_guts.xml b/packages/SystemUI/res/layout/notification_guts.xml index 4d0eb96f4eae..62f2b479cde9 100644 --- a/packages/SystemUI/res/layout/notification_guts.xml +++ b/packages/SystemUI/res/layout/notification_guts.xml @@ -26,7 +26,7 @@ android:orientation="vertical" android:paddingStart="@*android:dimen/notification_content_margin_start" android:paddingEnd="8dp" - android:background="@color/notification_guts_bg_color" > + android:background="@color/notification_guts_bg_color"> <!-- header --> <LinearLayout @@ -58,8 +58,38 @@ android:layout_gravity="bottom|start" android:visibility="gone" /> </LinearLayout> + <!-- Importance radio buttons --> + <RadioGroup + android:id="@+id/importance_buttons" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="8dp" + android:paddingBottom="8dip" + android:paddingEnd="8dp" > + <RadioButton + android:id="@+id/silent_importance" + android:layout_width="wrap_content" + android:layout_height="48dp" + android:text="@string/show_silently" + style="@style/TextAppearance.NotificationGuts.Primary" + android:buttonTint="#858383" /> + <RadioButton + android:id="@+id/block_importance" + android:layout_width="wrap_content" + android:layout_height="48dp" + android:text="@string/block" + style="@style/TextAppearance.NotificationGuts.Primary" + android:buttonTint="#858383" /> + <RadioButton + android:id="@+id/reset_importance" + android:layout_width="wrap_content" + android:layout_height="48dp" + style="@style/TextAppearance.NotificationGuts.Primary" + android:buttonTint="#858383" /> + </RadioGroup> <!-- Importance slider --> <LinearLayout + android:id="@+id/importance_slider" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" @@ -67,7 +97,8 @@ android:clickable="false" android:focusable="false" android:paddingBottom="8dip" - android:paddingEnd="8dp" > + android:paddingEnd="8dp" + android:visibility="gone"> <TextView android:id="@+id/title" android:layout_width="match_parent" diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index ac6e3ac7aae4..8bfd943dcedc 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -1205,10 +1205,18 @@ <!-- Bluetooth enablement ok text [CHAR LIMIT=40] --> <string name="enable_bluetooth_confirmation_ok">Turn on</string> - <!-- Apply notification importance setting to a topic [CHAR LIMIT=NONE] --> - <string name="apply_to_topic">Apply to <xliff:g id="topic_name" example="Friend Request">%1$s</xliff:g> notifications</string> - <!-- Apply notification importance setting to an app [CHAR LIMIT=NONE] --> - <string name="apply_to_app">Apply to all notifications from this app</string> + <!-- [CHAR LIMIT=100] Notification importance option --> + <string name="show_silently">Show notifications silently</string> + <!-- [CHAR LIMIT=100] Notification importance option --> + <string name="block">Block all notifications</string> + <!-- [CHAR LIMIT=100] Notification importance option --> + <string name="do_not_silence">Don\'t silence</string> + <!-- [CHAR LIMIT=100] Notification importance option --> + <string name="do_not_silence_block">Don\'t silence or block</string> + + <!-- [CHAR LIMIT=NONE] Importance Tuner setting title --> + <string name="tuner_full_importance_settings">Show full importance settings</string> + <!-- Notification importance title, blocked status--> <string name="blocked_importance">Blocked</string> <!-- Notification importance title, low status--> @@ -1230,10 +1238,10 @@ <string name="notification_importance_default">Silently show these notifications</string> <!-- [CHAR LIMIT=100] Notification Importance slider: high importance level description --> - <string name="notification_importance_high">Show at the top of the notifications list and make sound</string> + <string name="notification_importance_high">Show at the top of the notifications list and allow sound</string> <!-- [CHAR LIMIT=100] Notification Importance slider: max importance level description --> - <string name="notification_importance_max">Peek onto the screen and make sound</string> + <string name="notification_importance_max">Peek onto the screen and allow sound</string> <!-- Notification: Control panel: Label for button that launches notification settings. [CHAR LIMIT=NONE] --> <string name="notification_more_settings">More settings</string> @@ -1434,6 +1442,9 @@ <item>Don\'t show this icon</item> </string-array> + <!-- SysUI Tuner: Other section --> + <string name="other">Other</string> + <!-- Accessibility label for the divider that separates the windows in split-screen mode [CHAR LIMIT=NONE] --> <string name="accessibility_divider">Split-screen divider</string> @@ -1448,4 +1459,5 @@ <!-- Accessibility action for moving down the docked stack divider [CHAR LIMIT=NONE] --> <string name="accessibility_action_divider_move_right">Move right</string> + </resources> diff --git a/packages/SystemUI/res/xml/tuner_prefs.xml b/packages/SystemUI/res/xml/tuner_prefs.xml index f4a0cc92f30d..ddc03a39d3a7 100644 --- a/packages/SystemUI/res/xml/tuner_prefs.xml +++ b/packages/SystemUI/res/xml/tuner_prefs.xml @@ -134,8 +134,8 @@ --> <PreferenceScreen - android:key="overview" - android:title="@string/overview" > + android:key="other" + android:title="@string/other" > <com.android.systemui.tuner.TunerSwitch android:key="overview_disable_fast_toggle_via_button" @@ -147,6 +147,11 @@ android:title="@string/overview_nav_bar_gesture" android:summary="@string/overview_nav_bar_gesture_desc" /> + <!-- importance --> + <com.android.systemui.tuner.TunerSwitch + android:key="show_importance_slider" + android:title="@string/tuner_full_importance_settings" /> + </PreferenceScreen> <!-- Warning, this goes last. --> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 6be95124ffa6..cd0cd4a3983f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -1007,7 +1007,7 @@ public abstract class BaseStatusBar extends SystemUI implements } }); - guts.bindImportance(sbn, row, mNotificationData.getImportance(sbn.getKey())); + guts.bindImportance(pmUser, sbn, row, mNotificationData.getImportance(sbn.getKey())); } protected GearDisplayedListener getGearDisplayedListener() { @@ -1044,9 +1044,9 @@ public abstract class BaseStatusBar extends SystemUI implements MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTE_CONTROLS); - // ensure that it's layouted but not visible until actually laid out + // ensure that it's laid but not visible until actually laid out guts.setVisibility(View.INVISIBLE); - // Post to ensure the the guts are properly layed out. + // Post to ensure the the guts are properly laid out. guts.post(new Runnable() { public void run() { dismissPopups(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java index fe84d81354dd..4386c3b3379f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java @@ -17,7 +17,6 @@ package com.android.systemui.statusbar; import android.app.INotificationManager; -import android.app.Notification; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; @@ -39,23 +38,31 @@ import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsProto.MetricsEvent; import com.android.settingslib.Utils; import com.android.systemui.R; +import com.android.systemui.tuner.TunerService; /** * The guts of a notification revealed when performing a long press. */ -public class NotificationGuts extends LinearLayout { +public class NotificationGuts extends LinearLayout implements TunerService.Tunable { + public static final String SHOW_SLIDER = "show_importance_slider"; private Drawable mBackground; private int mClipTopAmount; private int mActualHeight; private boolean mExposed; - private SeekBar mSeekBar; private INotificationManager mINotificationManager; private int mStartingImportance; + private boolean mShowSlider; + + private SeekBar mSeekBar; + private RadioButton mBlock; + private RadioButton mSilent; + private RadioButton mReset; public NotificationGuts(Context context, AttributeSet attrs) { super(context, attrs); setWillNotDraw(false); + TunerService.get(mContext).addTunable(this, SHOW_SLIDER); } @Override @@ -102,27 +109,77 @@ public class NotificationGuts extends LinearLayout { } } - void bindImportance(final StatusBarNotification sbn, final ExpandableNotificationRow row, - final int importance) { + void bindImportance(final PackageManager pm, final StatusBarNotification sbn, + final ExpandableNotificationRow row, final int importance) { mStartingImportance = importance; mINotificationManager = INotificationManager.Stub.asInterface( ServiceManager.getService(Context.NOTIFICATION_SERVICE)); - - final TextView importanceSummary = ((TextView) row.findViewById(R.id.summary)); - final TextView importanceTitle = ((TextView) row.findViewById(R.id.title)); - mSeekBar = (SeekBar) row.findViewById(R.id.seekbar); boolean systemApp = false; try { - final PackageManager pm = BaseStatusBar.getPackageManagerForUser( - getContext(), sbn.getUser().getIdentifier()); final PackageInfo info = pm.getPackageInfo(sbn.getPackageName(), PackageManager.GET_SIGNATURES); systemApp = Utils.isSystemPackage(pm, info); } catch (PackageManager.NameNotFoundException e) { // unlikely. } + + final View importanceSlider = row.findViewById(R.id.importance_slider); + final View importanceButtons = row.findViewById(R.id.importance_buttons); + if (mShowSlider) { + bindSlider(importanceSlider, sbn, systemApp); + importanceSlider.setVisibility(View.VISIBLE); + importanceButtons.setVisibility(View.GONE); + } else { + bindToggles(importanceButtons, sbn, systemApp); + importanceButtons.setVisibility(View.VISIBLE); + importanceSlider.setVisibility(View.GONE); + } + } + + void saveImportance(final StatusBarNotification sbn) { + int progress; + if (mSeekBar!= null && mSeekBar.isShown()) { + progress = mSeekBar.getProgress(); + } else { + if (mBlock.isChecked()) { + progress = NotificationListenerService.Ranking.IMPORTANCE_NONE; + } else if (mSilent.isChecked()) { + progress = NotificationListenerService.Ranking.IMPORTANCE_DEFAULT; + } else { + progress = NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED; + } + } + MetricsLogger.action(mContext, MetricsEvent.ACTION_SAVE_IMPORTANCE, + progress - mStartingImportance); + try { + mINotificationManager.setImportance(sbn.getPackageName(), sbn.getUid(), progress); + } catch (RemoteException e) { + // :( + } + } + + private void bindToggles(final View importanceButtons, final StatusBarNotification sbn, + final boolean systemApp) { + mBlock = (RadioButton) importanceButtons.findViewById(R.id.block_importance); + mSilent = (RadioButton) importanceButtons.findViewById(R.id.silent_importance); + mReset = (RadioButton) importanceButtons.findViewById(R.id.reset_importance); if (systemApp) { - ((ImageView) row.findViewById(R.id.low_importance)).getDrawable().setTint( + mBlock.setVisibility(View.GONE); + mReset.setText(mContext.getString(R.string.do_not_silence)); + } else { + mReset.setText(mContext.getString(R.string.do_not_silence_block)); + } + mReset.setChecked(true); + } + + private void bindSlider(final View importanceSlider, final StatusBarNotification sbn, + final boolean systemApp) { + final TextView importanceSummary = ((TextView) importanceSlider.findViewById(R.id.summary)); + final TextView importanceTitle = ((TextView) importanceSlider.findViewById(R.id.title)); + mSeekBar = (SeekBar) importanceSlider.findViewById(R.id.seekbar); + + if (systemApp) { + ((ImageView) importanceSlider.findViewById(R.id.low_importance)).getDrawable().setTint( mContext.getColor(R.color.notification_guts_disabled_icon_tint)); } final int minProgress = systemApp ? @@ -182,18 +239,7 @@ public class NotificationGuts extends LinearLayout { } } }); - mSeekBar.setProgress(importance); - } - - void saveImportance(final StatusBarNotification sbn) { - int progress = mSeekBar.getProgress(); - MetricsLogger.action(mContext, MetricsEvent.ACTION_SAVE_IMPORTANCE, - progress - mStartingImportance); - try { - mINotificationManager.setImportance(sbn.getPackageName(), sbn.getUid(), progress); - } catch (RemoteException e) { - // :( - } + mSeekBar.setProgress(mStartingImportance); } public void setActualHeight(int actualHeight) { @@ -224,4 +270,11 @@ public class NotificationGuts extends LinearLayout { public boolean areGutsExposed() { return mExposed; } + + @Override + public void onTuningChanged(String key, String newValue) { + if (SHOW_SLIDER.equals(key)) { + mShowSlider = newValue != null && Integer.parseInt(newValue) != 0; + } + } } |