From 4077945e1b3e0e1b5bcd9f57f8fa3fbeffb29c01 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Tue, 23 Feb 2016 13:43:32 -0500 Subject: [PATCH] Remove inline settings slider. Bug: 22451710 Change-Id: Ia4f85569f878531102d91564d0728a94783cc79d --- packages/SystemUI/res/layout/notification_guts.xml | 35 ++++++- packages/SystemUI/res/values/strings.xml | 24 +++-- packages/SystemUI/res/xml/tuner_prefs.xml | 9 +- .../android/systemui/statusbar/BaseStatusBar.java | 6 +- .../systemui/statusbar/NotificationGuts.java | 101 ++++++++++++++++----- 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"> + + + + + + + android:paddingEnd="8dp" + android:visibility="gone"> Turn on - - Apply to %1$s notifications - - Apply to all notifications from this app + + Show notifications silently + + Block all notifications + + Don\'t silence + + Don\'t silence or block + + + Show full importance settings + Blocked @@ -1226,10 +1234,10 @@ Silently show these notifications - Show at the top of the notifications list and make sound + Show at the top of the notifications list and allow sound - Peek onto the screen and make sound + Peek onto the screen and allow sound More settings @@ -1430,6 +1438,9 @@ Don\'t show this icon + + Other + Split-screen divider @@ -1444,4 +1455,5 @@ Move right + 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 @@ --> + android:key="other" + android:title="@string/other" > + + + diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index afee8468aa07..13b7c8b2e82c 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; + } + } } -- 2.11.0