Merge "Remove inline settings slider." into nyc-dev

This commit is contained in:
Julia Reynolds
2016-02-26 14:41:30 +00:00
committed by Android (Google) Code Review
5 changed files with 138 additions and 37 deletions

View File

@@ -26,7 +26,7 @@
android:orientation="vertical" android:orientation="vertical"
android:paddingStart="@*android:dimen/notification_content_margin_start" android:paddingStart="@*android:dimen/notification_content_margin_start"
android:paddingEnd="8dp" android:paddingEnd="8dp"
android:background="@color/notification_guts_bg_color" > android:background="@color/notification_guts_bg_color">
<!-- header --> <!-- header -->
<LinearLayout <LinearLayout
@@ -58,8 +58,38 @@
android:layout_gravity="bottom|start" android:layout_gravity="bottom|start"
android:visibility="gone" /> android:visibility="gone" />
</LinearLayout> </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 --> <!-- Importance slider -->
<LinearLayout <LinearLayout
android:id="@+id/importance_slider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
@@ -67,7 +97,8 @@
android:clickable="false" android:clickable="false"
android:focusable="false" android:focusable="false"
android:paddingBottom="8dip" android:paddingBottom="8dip"
android:paddingEnd="8dp" > android:paddingEnd="8dp"
android:visibility="gone">
<TextView <TextView
android:id="@+id/title" android:id="@+id/title"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -1205,10 +1205,18 @@
<!-- Bluetooth enablement ok text [CHAR LIMIT=40] --> <!-- Bluetooth enablement ok text [CHAR LIMIT=40] -->
<string name="enable_bluetooth_confirmation_ok">Turn on</string> <string name="enable_bluetooth_confirmation_ok">Turn on</string>
<!-- Apply notification importance setting to a topic [CHAR LIMIT=NONE] --> <!-- [CHAR LIMIT=100] Notification importance option -->
<string name="apply_to_topic">Apply to <xliff:g id="topic_name" example="Friend Request">%1$s</xliff:g> notifications</string> <string name="show_silently">Show notifications silently</string>
<!-- Apply notification importance setting to an app [CHAR LIMIT=NONE] --> <!-- [CHAR LIMIT=100] Notification importance option -->
<string name="apply_to_app">Apply to all notifications from this app</string> <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--> <!-- Notification importance title, blocked status-->
<string name="blocked_importance">Blocked</string> <string name="blocked_importance">Blocked</string>
<!-- Notification importance title, low status--> <!-- Notification importance title, low status-->
@@ -1230,10 +1238,10 @@
<string name="notification_importance_default">Silently show these notifications</string> <string name="notification_importance_default">Silently show these notifications</string>
<!-- [CHAR LIMIT=100] Notification Importance slider: high importance level description --> <!-- [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 --> <!-- [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] --> <!-- Notification: Control panel: Label for button that launches notification settings. [CHAR LIMIT=NONE] -->
<string name="notification_more_settings">More settings</string> <string name="notification_more_settings">More settings</string>
@@ -1434,6 +1442,9 @@
<item>Don\'t show this icon</item> <item>Don\'t show this icon</item>
</string-array> </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] --> <!-- Accessibility label for the divider that separates the windows in split-screen mode [CHAR LIMIT=NONE] -->
<string name="accessibility_divider">Split-screen divider</string> <string name="accessibility_divider">Split-screen divider</string>
@@ -1448,4 +1459,5 @@
<!-- Accessibility action for moving down the docked stack divider [CHAR LIMIT=NONE] --> <!-- Accessibility action for moving down the docked stack divider [CHAR LIMIT=NONE] -->
<string name="accessibility_action_divider_move_right">Move right</string> <string name="accessibility_action_divider_move_right">Move right</string>
</resources> </resources>

View File

@@ -134,8 +134,8 @@
--> -->
<PreferenceScreen <PreferenceScreen
android:key="overview" android:key="other"
android:title="@string/overview" > android:title="@string/other" >
<com.android.systemui.tuner.TunerSwitch <com.android.systemui.tuner.TunerSwitch
android:key="overview_disable_fast_toggle_via_button" android:key="overview_disable_fast_toggle_via_button"
@@ -147,6 +147,11 @@
android:title="@string/overview_nav_bar_gesture" android:title="@string/overview_nav_bar_gesture"
android:summary="@string/overview_nav_bar_gesture_desc" /> 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> </PreferenceScreen>
<!-- Warning, this goes last. --> <!-- Warning, this goes last. -->

View File

@@ -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() { protected GearDisplayedListener getGearDisplayedListener() {
@@ -1044,9 +1044,9 @@ public abstract class BaseStatusBar extends SystemUI implements
MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTE_CONTROLS); 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); 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() { guts.post(new Runnable() {
public void run() { public void run() {
dismissPopups(); dismissPopups();

View File

@@ -17,7 +17,6 @@
package com.android.systemui.statusbar; package com.android.systemui.statusbar;
import android.app.INotificationManager; import android.app.INotificationManager;
import android.app.Notification;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; 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.internal.logging.MetricsProto.MetricsEvent;
import com.android.settingslib.Utils; import com.android.settingslib.Utils;
import com.android.systemui.R; import com.android.systemui.R;
import com.android.systemui.tuner.TunerService;
/** /**
* The guts of a notification revealed when performing a long press. * 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 Drawable mBackground;
private int mClipTopAmount; private int mClipTopAmount;
private int mActualHeight; private int mActualHeight;
private boolean mExposed; private boolean mExposed;
private SeekBar mSeekBar;
private INotificationManager mINotificationManager; private INotificationManager mINotificationManager;
private int mStartingImportance; private int mStartingImportance;
private boolean mShowSlider;
private SeekBar mSeekBar;
private RadioButton mBlock;
private RadioButton mSilent;
private RadioButton mReset;
public NotificationGuts(Context context, AttributeSet attrs) { public NotificationGuts(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
setWillNotDraw(false); setWillNotDraw(false);
TunerService.get(mContext).addTunable(this, SHOW_SLIDER);
} }
@Override @Override
@@ -102,27 +109,77 @@ public class NotificationGuts extends LinearLayout {
} }
} }
void bindImportance(final StatusBarNotification sbn, final ExpandableNotificationRow row, void bindImportance(final PackageManager pm, final StatusBarNotification sbn,
final int importance) { final ExpandableNotificationRow row, final int importance) {
mStartingImportance = importance; mStartingImportance = importance;
mINotificationManager = INotificationManager.Stub.asInterface( mINotificationManager = INotificationManager.Stub.asInterface(
ServiceManager.getService(Context.NOTIFICATION_SERVICE)); 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; boolean systemApp = false;
try { try {
final PackageManager pm = BaseStatusBar.getPackageManagerForUser(
getContext(), sbn.getUser().getIdentifier());
final PackageInfo info = final PackageInfo info =
pm.getPackageInfo(sbn.getPackageName(), PackageManager.GET_SIGNATURES); pm.getPackageInfo(sbn.getPackageName(), PackageManager.GET_SIGNATURES);
systemApp = Utils.isSystemPackage(pm, info); systemApp = Utils.isSystemPackage(pm, info);
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
// unlikely. // 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) { 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)); mContext.getColor(R.color.notification_guts_disabled_icon_tint));
} }
final int minProgress = systemApp ? final int minProgress = systemApp ?
@@ -182,18 +239,7 @@ public class NotificationGuts extends LinearLayout {
} }
} }
}); });
mSeekBar.setProgress(importance); mSeekBar.setProgress(mStartingImportance);
}
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) {
// :(
}
} }
public void setActualHeight(int actualHeight) { public void setActualHeight(int actualHeight) {
@@ -224,4 +270,11 @@ public class NotificationGuts extends LinearLayout {
public boolean areGutsExposed() { public boolean areGutsExposed() {
return mExposed; return mExposed;
} }
@Override
public void onTuningChanged(String key, String newValue) {
if (SHOW_SLIDER.equals(key)) {
mShowSlider = newValue != null && Integer.parseInt(newValue) != 0;
}
}
} }