Notification slider changes.
Bug: 27558254 Change-Id: I15635ae19e82a57d6e6fcb2f8f946f31bebf5d0f
This commit is contained in:
@@ -15,47 +15,64 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||||
android:orientation="vertical"
|
android:paddingTop="8dp"
|
||||||
android:clickable="false"
|
android:paddingBottom="8dp"
|
||||||
android:focusable="false" >
|
android:orientation="vertical"
|
||||||
|
android:clickable="false"
|
||||||
|
android:focusable="false" >
|
||||||
|
|
||||||
<FrameLayout
|
<TextView
|
||||||
|
android:id="@android:id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
android:fadingEdge="horizontal" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" >
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/auto_importance"
|
||||||
|
android:src="@drawable/notification_auto_importance"
|
||||||
|
android:layout_gravity="center_vertical|start"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp" />
|
||||||
|
|
||||||
|
<SeekBar
|
||||||
|
android:id="@*android:id/seekbar"
|
||||||
|
android:layout_marginStart="56dp"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" >
|
android:layout_height="48dp"
|
||||||
|
android:focusable="true"
|
||||||
|
android:background="#00ffffff"
|
||||||
|
android:progressBackgroundTint="@color/importance_secondary_slider_color"
|
||||||
|
android:thumbTint="@color/importance_disabled_slider_color"
|
||||||
|
android:progressTint="@color/importance_disabled_slider_color"
|
||||||
|
style="@android:style/Widget.Material.SeekBar.Discrete"
|
||||||
|
android:tickMarkTint="@android:color/black" />
|
||||||
|
|
||||||
<ImageView
|
</FrameLayout>
|
||||||
android:id="@+id/low_importance"
|
|
||||||
android:src="@*android:drawable/ic_notification_block"
|
|
||||||
android:layout_gravity="center_vertical|start"
|
|
||||||
android:layout_width="24dp"
|
|
||||||
android:layout_height="24dp"
|
|
||||||
android:tint="@color/importance_icon_tint" />
|
|
||||||
|
|
||||||
<SeekBar
|
<TextView
|
||||||
android:id="@*android:id/seekbar"
|
android:id="@android:id/summary"
|
||||||
android:layout_marginStart="56dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_marginEnd="56dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_alignStart="@android:id/title"
|
||||||
android:layout_width="match_parent"
|
android:textAlignment="viewStart"
|
||||||
android:layout_height="48dp"
|
android:textAppearance="@android:style/TextAppearance.Material.Body1"
|
||||||
android:focusable="true"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
android:background="#00ffffff"
|
android:maxLines="10"
|
||||||
style="@android:style/Widget.Material.SeekBar.Discrete"
|
android:minLines="3" />
|
||||||
android:tickMarkTint="@android:color/black"/>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/max_importance"
|
|
||||||
android:src="@*android:drawable/ic_notification_alert"
|
|
||||||
android:layout_gravity="center_vertical|end"
|
|
||||||
android:layout_width="24dp"
|
|
||||||
android:layout_height="24dp"
|
|
||||||
android:tint="@color/importance_icon_tint" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@@ -125,6 +125,10 @@
|
|||||||
|
|
||||||
<color name="seek_bar_preference_preview_text">#fff</color>
|
<color name="seek_bar_preference_preview_text">#fff</color>
|
||||||
|
|
||||||
|
<color name="importance_slider_color">@*android:color/material_deep_teal_500</color>
|
||||||
|
<color name="importance_disabled_slider_color">@*android:color/material_grey_300</color>
|
||||||
|
<color name="importance_secondary_slider_color">#858383</color>
|
||||||
|
|
||||||
<color name="usage_graph_dots">#B0BEC5</color>
|
<color name="usage_graph_dots">#B0BEC5</color>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -5979,22 +5979,25 @@
|
|||||||
<string name="notification_importance_none">Not set</string>
|
<string name="notification_importance_none">Not set</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=100] Notification Importance slider: blocked importance level description -->
|
<!-- [CHAR LIMIT=100] Notification Importance slider: blocked importance level description -->
|
||||||
<string name="notification_importance_blocked">Blocked: Never show these notifications</string>
|
<string name="notification_importance_blocked">Never show notifications from this app</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=100] Notification Importance slider: min importance level description -->
|
<!-- [CHAR LIMIT=100] Notification Importance slider: min importance level description -->
|
||||||
<string name="notification_importance_min">Min: Silently show at the bottom of the notification list</string>
|
<string name="notification_importance_min">No full screen interruption, peeking, sound, or vibration. Show at the bottom of the notification list. Hide from lock screen and status bar.</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=100] Notification Importance slider: low importance level description -->
|
<!-- [CHAR LIMIT=100] Notification Importance slider: low importance level description -->
|
||||||
<string name="notification_importance_low">Low: Silently show these notifications</string>
|
<string name="notification_importance_low">No full screen interruption, peeking, sound, or vibration.</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=100] Notification Importance slider: normal importance level description -->
|
<!-- [CHAR LIMIT=100] Notification Importance slider: normal importance level description -->
|
||||||
<string name="notification_importance_default">Normal: Allow these notification to make sounds</string>
|
<string name="notification_importance_default">No full screen interruption or peeking.</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">High: Peek onto the screen and allow sound</string>
|
<string name="notification_importance_high">Always peek. No full screen interruption.</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">Urgent: Show at the top of the notifications list, peek onto the screen and allow sound</string>
|
<string name="notification_importance_max">Always peek, and allow full screen interruption. Show at the top of the notification list.</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=100] Notification Importance slider: max importance level description -->
|
||||||
|
<string name="notification_importance_unspecified">App determines importance for each notification</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=60] Notification importance reset button -->
|
<!-- [CHAR LIMIT=60] Notification importance reset button -->
|
||||||
<string name="importance_reset">Reset</string>
|
<string name="importance_reset">Reset</string>
|
||||||
@@ -6486,6 +6489,8 @@
|
|||||||
<string name="notifications_priority">Do Not Disturb overridden</string>
|
<string name="notifications_priority">Do Not Disturb overridden</string>
|
||||||
<!-- App notification summary divider [CHAR LIMIT=40] -->
|
<!-- App notification summary divider [CHAR LIMIT=40] -->
|
||||||
<string name="notifications_summary_divider">\u00A0/\u00A0</string>
|
<string name="notifications_summary_divider">\u00A0/\u00A0</string>
|
||||||
|
<!-- App notification summary for advanced controls -->
|
||||||
|
<string name="notification_summary_level">Level %d</string>
|
||||||
|
|
||||||
<!-- Permissions preference summary [CHAR LIMIT=40] -->
|
<!-- Permissions preference summary [CHAR LIMIT=40] -->
|
||||||
<plurals name="permissions_summary">
|
<plurals name="permissions_summary">
|
||||||
|
@@ -32,30 +32,22 @@
|
|||||||
android:summary="@string/show_silently_summary"
|
android:summary="@string/show_silently_summary"
|
||||||
android:order="3" />
|
android:order="3" />
|
||||||
<!-- Slider -->
|
<!-- Slider -->
|
||||||
<com.android.settingslib.RestrictedPreference
|
|
||||||
android:key="importance_title"
|
|
||||||
android:title="@string/notification_importance_title"
|
|
||||||
android:order="4"/>
|
|
||||||
<com.android.settings.notification.ImportanceSeekBarPreference
|
<com.android.settings.notification.ImportanceSeekBarPreference
|
||||||
android:key="importance"
|
android:key="importance"
|
||||||
android:order="5"/>
|
android:title="@string/notification_importance_title"
|
||||||
|
android:order="4"/>
|
||||||
<com.android.settings.applications.LayoutPreference
|
|
||||||
android:key="importance_reset_button"
|
|
||||||
android:layout="@layout/two_buttons_panel"
|
|
||||||
android:order="6" />
|
|
||||||
|
|
||||||
<!-- Visibility Override -->
|
<!-- Visibility Override -->
|
||||||
<DropDownPreference
|
<DropDownPreference
|
||||||
android:key="visibility_override"
|
android:key="visibility_override"
|
||||||
android:title="@string/app_notification_visibility_override_title"
|
android:title="@string/app_notification_visibility_override_title"
|
||||||
android:order="7" />
|
android:order="5" />
|
||||||
|
|
||||||
<!-- Bypass DND -->
|
<!-- Bypass DND -->
|
||||||
<com.android.settingslib.RestrictedSwitchPreference
|
<com.android.settingslib.RestrictedSwitchPreference
|
||||||
android:key="bypass_dnd"
|
android:key="bypass_dnd"
|
||||||
android:title="@string/app_notification_override_dnd_title"
|
android:title="@string/app_notification_override_dnd_title"
|
||||||
android:summary="@string/app_notification_override_dnd_summary"
|
android:summary="@string/app_notification_override_dnd_summary"
|
||||||
android:order="8" />
|
android:order="6" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -51,7 +51,9 @@ import android.os.RemoteException;
|
|||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.service.notification.NotificationListenerService;
|
import android.service.notification.NotificationListenerService;
|
||||||
|
import android.service.notification.NotificationListenerService.Ranking;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.Preference.OnPreferenceClickListener;
|
import android.support.v7.preference.Preference.OnPreferenceClickListener;
|
||||||
import android.support.v7.preference.PreferenceCategory;
|
import android.support.v7.preference.PreferenceCategory;
|
||||||
@@ -144,6 +146,8 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
private static final String KEY_BATTERY = "battery";
|
private static final String KEY_BATTERY = "battery";
|
||||||
private static final String KEY_MEMORY = "memory";
|
private static final String KEY_MEMORY = "memory";
|
||||||
|
|
||||||
|
private static final String NOTIFICATION_TUNER_SETTING = "show_importance_slider";
|
||||||
|
|
||||||
private final HashSet<String> mHomePackages = new HashSet<String>();
|
private final HashSet<String> mHomePackages = new HashSet<String>();
|
||||||
|
|
||||||
private boolean mInitialized;
|
private boolean mInitialized;
|
||||||
@@ -1016,13 +1020,22 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static CharSequence getNotificationSummary(AppRow appRow, Context context) {
|
public static CharSequence getNotificationSummary(AppRow appRow, Context context) {
|
||||||
|
boolean showSlider = Settings.Secure.getInt(
|
||||||
|
context.getContentResolver(), NOTIFICATION_TUNER_SETTING, 0) == 1;
|
||||||
List<String> summaryAttributes = new ArrayList<>();
|
List<String> summaryAttributes = new ArrayList<>();
|
||||||
StringBuffer summary = new StringBuffer();
|
StringBuffer summary = new StringBuffer();
|
||||||
if (appRow.banned) {
|
if (showSlider) {
|
||||||
summaryAttributes.add(context.getString(R.string.notifications_disabled));
|
if (appRow.appImportance != Ranking.IMPORTANCE_UNSPECIFIED) {
|
||||||
} else if (appRow.appImportance > NotificationListenerService.Ranking.IMPORTANCE_NONE
|
summaryAttributes.add(context.getString(
|
||||||
&& appRow.appImportance < NotificationListenerService.Ranking.IMPORTANCE_DEFAULT) {
|
R.string.notification_summary_level, appRow.appImportance));
|
||||||
summaryAttributes.add(context.getString(R.string.notifications_silenced));
|
}
|
||||||
|
} else {
|
||||||
|
if (appRow.banned) {
|
||||||
|
summaryAttributes.add(context.getString(R.string.notifications_disabled));
|
||||||
|
} else if (appRow.appImportance > Ranking.IMPORTANCE_NONE
|
||||||
|
&& appRow.appImportance < Ranking.IMPORTANCE_DEFAULT) {
|
||||||
|
summaryAttributes.add(context.getString(R.string.notifications_silenced));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
final boolean lockscreenSecure = new LockPatternUtils(context).isSecure(
|
final boolean lockscreenSecure = new LockPatternUtils(context).isSecure(
|
||||||
UserHandle.myUserId());
|
UserHandle.myUserId());
|
||||||
|
@@ -72,8 +72,6 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
|||||||
|
|
||||||
addPreferencesFromResource(R.xml.app_notification_settings);
|
addPreferencesFromResource(R.xml.app_notification_settings);
|
||||||
mImportance = (ImportanceSeekBarPreference) findPreference(KEY_IMPORTANCE);
|
mImportance = (ImportanceSeekBarPreference) findPreference(KEY_IMPORTANCE);
|
||||||
mImportanceReset = (LayoutPreference) findPreference(KEY_IMPORTANCE_RESET);
|
|
||||||
mImportanceTitle = (RestrictedPreference) findPreference(KEY_IMPORTANCE_TITLE);
|
|
||||||
mPriority =
|
mPriority =
|
||||||
(RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BYPASS_DND);
|
(RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BYPASS_DND);
|
||||||
mVisibilityOverride =
|
mVisibilityOverride =
|
||||||
|
@@ -20,10 +20,16 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.SeekBarPreference;
|
import com.android.settings.SeekBarPreference;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.service.notification.NotificationListenerService;
|
||||||
import android.support.v7.preference.PreferenceViewHolder;
|
import android.support.v7.preference.PreferenceViewHolder;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A slider preference that controls notification importance.
|
* A slider preference that controls notification importance.
|
||||||
@@ -34,12 +40,23 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements
|
|||||||
|
|
||||||
private Callback mCallback;
|
private Callback mCallback;
|
||||||
private int mMinProgress;
|
private int mMinProgress;
|
||||||
private boolean mSystemApp;
|
private TextView mSummaryTextView;
|
||||||
|
private String mSummary;
|
||||||
|
private SeekBar mSeekBar;
|
||||||
|
private ColorStateList mActiveSliderTint;
|
||||||
|
private ColorStateList mInactiveSliderTint;
|
||||||
|
private boolean mAutoOn;
|
||||||
|
private Handler mHandler;
|
||||||
|
|
||||||
public ImportanceSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
|
public ImportanceSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
|
||||||
int defStyleRes) {
|
int defStyleRes) {
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
setLayoutResource(R.layout.preference_importance_slider);
|
setLayoutResource(R.layout.preference_importance_slider);
|
||||||
|
mActiveSliderTint = ColorStateList.valueOf(
|
||||||
|
context.getColor(R.color.importance_slider_color));
|
||||||
|
mInactiveSliderTint = ColorStateList.valueOf(
|
||||||
|
context.getColor(R.color.importance_disabled_slider_color));
|
||||||
|
mHandler = new Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImportanceSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
public ImportanceSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
@@ -63,20 +80,67 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements
|
|||||||
notifyChanged();
|
notifyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSystemApp(boolean systemApp) {
|
@Override
|
||||||
mSystemApp = systemApp;
|
public void setProgress(int progress) {
|
||||||
|
mSummary = getProgressSummary(progress);
|
||||||
|
super.setProgress(progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAutoOn(boolean autoOn) {
|
||||||
|
mAutoOn = autoOn;
|
||||||
notifyChanged();
|
notifyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||||
super.onBindViewHolder(view);
|
super.onBindViewHolder(view);
|
||||||
if (mSystemApp) {
|
mSummaryTextView = (TextView) view.findViewById(com.android.internal.R.id.summary);
|
||||||
((ImageView) view.findViewById(R.id.low_importance)).getDrawable().setTint(
|
mSeekBar = (SeekBar) view.findViewById(
|
||||||
getContext().getColor(R.color.importance_disabled_tint));
|
com.android.internal.R.id.seekbar);
|
||||||
|
|
||||||
|
final ImageView autoButton = (ImageView) view.findViewById(R.id.auto_importance);
|
||||||
|
applyAutoUi(autoButton);
|
||||||
|
autoButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
applyAuto(autoButton);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyAuto(ImageView autoButton) {
|
||||||
|
mAutoOn = !mAutoOn;
|
||||||
|
if (!mAutoOn) {
|
||||||
|
setProgress(NotificationListenerService.Ranking.IMPORTANCE_DEFAULT);
|
||||||
|
mCallback.onImportanceChanged(
|
||||||
|
NotificationListenerService.Ranking.IMPORTANCE_DEFAULT, true);
|
||||||
|
} else {
|
||||||
|
mCallback.onImportanceChanged(
|
||||||
|
NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED, true);
|
||||||
}
|
}
|
||||||
view.setDividerAllowedAbove(false);
|
applyAutoUi(autoButton);
|
||||||
view.setDividerAllowedBelow(false);
|
}
|
||||||
|
|
||||||
|
private void applyAutoUi(ImageView autoButton) {
|
||||||
|
mSeekBar.setEnabled(!mAutoOn);
|
||||||
|
|
||||||
|
final ColorStateList tint = mAutoOn ? mInactiveSliderTint : mActiveSliderTint;
|
||||||
|
Drawable icon = autoButton.getDrawable().mutate();
|
||||||
|
icon.setTintList(tint);
|
||||||
|
autoButton.setImageDrawable(icon);
|
||||||
|
mSeekBar.setProgressTintList(tint);
|
||||||
|
mSeekBar.setThumbTintList(tint);
|
||||||
|
|
||||||
|
if (mAutoOn) {
|
||||||
|
mSummary = getProgressSummary(
|
||||||
|
NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED);
|
||||||
|
}
|
||||||
|
mSummaryTextView.setText(mSummary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharSequence getSummary() {
|
||||||
|
return mSummary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -86,12 +150,49 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements
|
|||||||
seekBar.setProgress(mMinProgress);
|
seekBar.setProgress(mMinProgress);
|
||||||
progress = mMinProgress;
|
progress = mMinProgress;
|
||||||
}
|
}
|
||||||
if (fromTouch) {
|
if (mSummaryTextView != null) {
|
||||||
mCallback.onImportanceChanged(progress);
|
mSummary = getProgressSummary(progress);
|
||||||
|
mSummaryTextView.setText(mSummary);
|
||||||
|
}
|
||||||
|
mCallback.onImportanceChanged(progress, fromTouch);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getProgressSummary(int progress) {
|
||||||
|
switch (progress) {
|
||||||
|
case NotificationListenerService.Ranking.IMPORTANCE_NONE:
|
||||||
|
return getContext().getString(R.string.notification_importance_blocked);
|
||||||
|
case NotificationListenerService.Ranking.IMPORTANCE_MIN:
|
||||||
|
return getContext().getString(R.string.notification_importance_min);
|
||||||
|
case NotificationListenerService.Ranking.IMPORTANCE_LOW:
|
||||||
|
return getContext().getString(R.string.notification_importance_low);
|
||||||
|
case NotificationListenerService.Ranking.IMPORTANCE_DEFAULT:
|
||||||
|
return getContext().getString(R.string.notification_importance_default);
|
||||||
|
case NotificationListenerService.Ranking.IMPORTANCE_HIGH:
|
||||||
|
return getContext().getString(R.string.notification_importance_high);
|
||||||
|
case NotificationListenerService.Ranking.IMPORTANCE_MAX:
|
||||||
|
return getContext().getString(R.string.notification_importance_max);
|
||||||
|
default:
|
||||||
|
return getContext().getString(R.string.notification_importance_unspecified);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void notifyChanged() {
|
||||||
|
mHandler.post(mNotifyChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void postNotifyChanged() {
|
||||||
|
super.notifyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Runnable mNotifyChanged = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
postNotifyChanged();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public interface Callback {
|
public interface Callback {
|
||||||
void onImportanceChanged(int progress);
|
void onImportanceChanged(int progress, boolean fromTouch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,9 +20,7 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
import com.android.settings.applications.AppInfoBase;
|
import com.android.settings.applications.AppInfoBase;
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
import com.android.settingslib.RestrictedPreference;
|
|
||||||
import com.android.settingslib.RestrictedSwitchPreference;
|
import com.android.settingslib.RestrictedSwitchPreference;
|
||||||
import com.android.settings.applications.LayoutPreference;
|
|
||||||
|
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -38,8 +36,6 @@ import android.support.v7.preference.DropDownPreference;
|
|||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -54,8 +50,6 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
|||||||
protected static final String KEY_BYPASS_DND = "bypass_dnd";
|
protected static final String KEY_BYPASS_DND = "bypass_dnd";
|
||||||
protected static final String KEY_VISIBILITY_OVERRIDE = "visibility_override";
|
protected static final String KEY_VISIBILITY_OVERRIDE = "visibility_override";
|
||||||
protected static final String KEY_IMPORTANCE = "importance";
|
protected static final String KEY_IMPORTANCE = "importance";
|
||||||
protected static final String KEY_IMPORTANCE_TITLE = "importance_title";
|
|
||||||
protected static final String KEY_IMPORTANCE_RESET = "importance_reset_button";
|
|
||||||
protected static final String KEY_BLOCK = "block";
|
protected static final String KEY_BLOCK = "block";
|
||||||
protected static final String KEY_SILENT = "silent";
|
protected static final String KEY_SILENT = "silent";
|
||||||
|
|
||||||
@@ -68,8 +62,6 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
|||||||
protected String mPkg;
|
protected String mPkg;
|
||||||
protected PackageInfo mPkgInfo;
|
protected PackageInfo mPkgInfo;
|
||||||
protected ImportanceSeekBarPreference mImportance;
|
protected ImportanceSeekBarPreference mImportance;
|
||||||
protected RestrictedPreference mImportanceTitle;
|
|
||||||
protected LayoutPreference mImportanceReset;
|
|
||||||
protected RestrictedSwitchPreference mPriority;
|
protected RestrictedSwitchPreference mPriority;
|
||||||
protected DropDownPreference mVisibilityOverride;
|
protected DropDownPreference mVisibilityOverride;
|
||||||
protected RestrictedSwitchPreference mBlock;
|
protected RestrictedSwitchPreference mBlock;
|
||||||
@@ -147,9 +139,6 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
|||||||
if (mPriority != null) {
|
if (mPriority != null) {
|
||||||
mPriority.setDisabledByAdmin(mSuspendedAppsAdmin);
|
mPriority.setDisabledByAdmin(mSuspendedAppsAdmin);
|
||||||
}
|
}
|
||||||
if (mImportanceTitle != null) {
|
|
||||||
mImportanceTitle.setDisabledByAdmin(mSuspendedAppsAdmin);
|
|
||||||
}
|
|
||||||
if (mBlock != null) {
|
if (mBlock != null) {
|
||||||
mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
|
mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
|
||||||
}
|
}
|
||||||
@@ -163,54 +152,22 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
|||||||
setVisible(mBlock, false);
|
setVisible(mBlock, false);
|
||||||
setVisible(mSilent, false);
|
setVisible(mSilent, false);
|
||||||
mImportance.setDisabledByAdmin(mSuspendedAppsAdmin);
|
mImportance.setDisabledByAdmin(mSuspendedAppsAdmin);
|
||||||
mImportanceTitle.setDisabledByAdmin(mSuspendedAppsAdmin);
|
|
||||||
if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
|
|
||||||
mImportance.setVisible(false);
|
|
||||||
mImportanceReset.setVisible(false);
|
|
||||||
mImportanceTitle.setOnPreferenceClickListener(showEditableImportance);
|
|
||||||
} else {
|
|
||||||
mImportanceTitle.setOnPreferenceClickListener(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
mImportanceTitle.setSummary(getProgressSummary(importance));
|
|
||||||
mImportance.setSystemApp(isSystemApp);
|
|
||||||
mImportance.setMinimumProgress(
|
mImportance.setMinimumProgress(
|
||||||
isSystemApp ? Ranking.IMPORTANCE_MIN : Ranking.IMPORTANCE_NONE);
|
isSystemApp ? Ranking.IMPORTANCE_MIN : Ranking.IMPORTANCE_NONE);
|
||||||
mImportance.setMax(Ranking.IMPORTANCE_MAX);
|
mImportance.setMax(Ranking.IMPORTANCE_MAX);
|
||||||
mImportance.setProgress(importance);
|
mImportance.setProgress(importance);
|
||||||
|
mImportance.setAutoOn(importance == Ranking.IMPORTANCE_UNSPECIFIED);
|
||||||
mImportance.setCallback(new ImportanceSeekBarPreference.Callback() {
|
mImportance.setCallback(new ImportanceSeekBarPreference.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void onImportanceChanged(int progress) {
|
public void onImportanceChanged(int progress, boolean fromUser) {
|
||||||
mBackend.setImportance(mPkg, mUid, progress);
|
if (fromUser) {
|
||||||
mImportanceTitle.setSummary(getProgressSummary(progress));
|
mBackend.setImportance(mPkg, mUid, progress);
|
||||||
|
}
|
||||||
updateDependents(progress);
|
updateDependents(progress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Button button = (Button) mImportanceReset.findViewById(R.id.left_button);
|
|
||||||
button.setText(R.string.importance_reset);
|
|
||||||
button.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (mSuspendedAppsAdmin != null) {
|
|
||||||
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(
|
|
||||||
getActivity(), mSuspendedAppsAdmin);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mBackend.setImportance(mPkg, mUid, Ranking.IMPORTANCE_UNSPECIFIED);
|
|
||||||
mImportanceReset.setVisible(false);
|
|
||||||
mImportance.setVisible(false);
|
|
||||||
mImportanceTitle.setOnPreferenceClickListener(showEditableImportance);
|
|
||||||
mImportanceTitle.setSummary(getProgressSummary(Ranking.IMPORTANCE_UNSPECIFIED));
|
|
||||||
updateDependents(Ranking.IMPORTANCE_UNSPECIFIED);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mImportanceReset.findViewById(R.id.right_button).setVisibility(View.INVISIBLE);
|
|
||||||
} else {
|
} else {
|
||||||
setVisible(mImportance, false);
|
setVisible(mImportance, false);
|
||||||
setVisible(mImportanceReset, false);
|
|
||||||
setVisible(mImportanceTitle, false);
|
|
||||||
boolean blocked = importance == Ranking.IMPORTANCE_NONE || banned;
|
boolean blocked = importance == Ranking.IMPORTANCE_NONE || banned;
|
||||||
mBlock.setChecked(blocked);
|
mBlock.setChecked(blocked);
|
||||||
mBlock.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
mBlock.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@@ -240,27 +197,6 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getProgressSummary(int progress) {
|
|
||||||
switch (progress) {
|
|
||||||
case Ranking.IMPORTANCE_NONE:
|
|
||||||
return mContext.getString(R.string.notification_importance_blocked);
|
|
||||||
case Ranking.IMPORTANCE_MIN:
|
|
||||||
return mContext.getString(R.string.notification_importance_min);
|
|
||||||
case Ranking.IMPORTANCE_LOW:
|
|
||||||
return mContext.getString(R.string.notification_importance_low);
|
|
||||||
case Ranking.IMPORTANCE_DEFAULT:
|
|
||||||
return mContext.getString(R.string.notification_importance_default);
|
|
||||||
case Ranking.IMPORTANCE_HIGH:
|
|
||||||
return mContext.getString(R.string.notification_importance_high);
|
|
||||||
case Ranking.IMPORTANCE_MAX:
|
|
||||||
return mContext.getString(R.string.notification_importance_max);
|
|
||||||
case Ranking.IMPORTANCE_UNSPECIFIED:
|
|
||||||
return mContext.getString(R.string.notification_importance_none);
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setupPriorityPref(boolean priority) {
|
protected void setupPriorityPref(boolean priority) {
|
||||||
mPriority.setDisabledByAdmin(mSuspendedAppsAdmin);
|
mPriority.setDisabledByAdmin(mSuspendedAppsAdmin);
|
||||||
mPriority.setChecked(priority);
|
mPriority.setChecked(priority);
|
||||||
@@ -363,18 +299,4 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Preference.OnPreferenceClickListener showEditableImportance =
|
|
||||||
new Preference.OnPreferenceClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
mBackend.setImportance(mPkg, mUid, Ranking.IMPORTANCE_DEFAULT);
|
|
||||||
mImportance.setProgress(Ranking.IMPORTANCE_DEFAULT);
|
|
||||||
mImportanceTitle.setSummary(getProgressSummary(Ranking.IMPORTANCE_DEFAULT));
|
|
||||||
mImportance.setVisible(true);
|
|
||||||
mImportanceReset.setVisible(true);
|
|
||||||
mImportanceTitle.setOnPreferenceClickListener(null);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user