Remove inline settings slider.

Bug: 22451710
Change-Id: Ia4f85569f878531102d91564d0728a94783cc79d
This commit is contained in:
Julia Reynolds
2016-02-23 13:43:32 -05:00
parent f4b50a3aa8
commit 4077945e1b
5 changed files with 138 additions and 37 deletions

View File

@@ -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"

View File

@@ -1201,10 +1201,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-->
@@ -1226,10 +1234,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>
@@ -1430,6 +1438,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>
@@ -1444,4 +1455,5 @@
<!-- Accessibility action for moving down the docked stack divider [CHAR LIMIT=NONE] -->
<string name="accessibility_action_divider_move_right">Move right</string>
</resources>

View File

@@ -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. -->

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() {
@@ -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();

View File

@@ -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;
}
}
}