Loading res/layout/preference_importance_slider.xml 0 → 100644 +81 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2015 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" android:gravity="center_vertical" android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:orientation="vertical" android:clickable="false" android:focusable="false" android:paddingTop="8dip" android:paddingBottom="8dip"> <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" /> <TextView android:id="@android:id/summary" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignStart="@android:id/title" android:textAlignment="viewStart" android:textAppearance="@android:style/TextAppearance.Material.Body1" android:textColor="?android:attr/textColorSecondary" android:maxLines="10" android:minLines="2" /> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="6dp"> <ImageView android:id="@+id/low_importance" android:src="@android:drawable/ic_menu_close_clear_cancel" android:layout_gravity="center_vertical|start" android:layout_width="24dp" android:layout_height="24dp" /> <SeekBar android:id="@*android:id/seekbar" android:layout_marginStart="24dp" android:layout_marginEnd="24dp" android:layout_gravity="center_vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:focusable="true"/> <ImageView android:id="@+id/max_importance" android:src="@android:drawable/ic_popup_reminder" android:layout_gravity="center_vertical|end" android:layout_width="24dp" android:layout_height="24dp" /> </FrameLayout> </LinearLayout> res/layout/preference_volume_slider.xml +2 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,8 @@ android:minHeight="?android:attr/listPreferredItemHeight" android:gravity="center_vertical" android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"> android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:clickable="false" > <LinearLayout android:layout_width="match_parent" Loading res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -5770,6 +5770,9 @@ <!-- [CHAR LIMIT=20] Notification settings: App notifications dialog dismiss button caption --> <string name="app_notifications_dialog_done">Done</string> <!-- [CHAR LIMIT=150] App notification settings: App notifications Importance title --> <string name="app_notification_importance_title">Importance</string> <!-- [CHAR LIMIT=40] Zen mode settings: Rule name option and edit dialog title --> <string name="zen_mode_rule_name">Rule name</string> Loading res/xml/topic_notification_settings.xml +7 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,13 @@ android:title="@string/topic_notifications_title" android:key="topic_notification_settings"> <!-- Importance --> <com.android.settings.notification.ImportanceSeekBarPreference android:key="importance" android:title="@string/app_notification_importance_title" android:order="1" android:persistent="false" /> <!-- Bypass DND --> <SwitchPreference android:key="bypass_dnd" Loading src/com/android/settings/notification/ImportanceSeekBarPreference.java 0 → 100644 +118 −0 Original line number Diff line number Diff line /** * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.notification; import com.android.settings.R; import com.android.settings.SeekBarPreference; import android.content.Context; import android.service.notification.NotificationListenerService; import android.support.v7.preference.PreferenceViewHolder; import android.util.AttributeSet; import android.widget.SeekBar; import android.widget.TextView; /** * A slider preference that controls notification importance. **/ public class ImportanceSeekBarPreference extends SeekBarPreference implements SeekBar.OnSeekBarChangeListener { private static final String TAG = "ImportanceSeekBarPref"; public static final int IMPORTANCE_PROGRESS_OFFSET = 2; private Callback mCallback; private TextView mSummaryTextView; private String mSummary; public ImportanceSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); setLayoutResource(R.layout.preference_importance_slider); } public ImportanceSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } public ImportanceSeekBarPreference(Context context, AttributeSet attrs) { this(context, attrs, 0); } public ImportanceSeekBarPreference(Context context) { this(context, null); } public void setCallback(Callback callback) { mCallback = callback; } @Override public void onBindViewHolder(PreferenceViewHolder view) { super.onBindViewHolder(view); mSummaryTextView = (TextView) view.findViewById(com.android.internal.R.id.summary); } @Override public void setProgress(int progress) { mSummary = getProgressSummary(progress); super.setProgress(progress); } @Override public void onProgressChanged(SeekBar seekBar, final int progress, boolean fromTouch) { super.onProgressChanged(seekBar, progress, fromTouch); if (mSummaryTextView != null) { mSummaryTextView.setText(getProgressSummary(progress)); } if (fromTouch) { mCallback.onImportanceChanged(progress); } } @Override public CharSequence getSummary() { return mSummary; } private String getProgressSummary(int progress) { // Map progress 0-4 values to Importance's -2-2. progress = progress - IMPORTANCE_PROGRESS_OFFSET; switch (progress) { case NotificationListenerService.Ranking.IMPORTANCE_NONE: return getContext().getString( com.android.internal.R.string.notification_importance_blocked); case NotificationListenerService.Ranking.IMPORTANCE_LOW: return getContext().getString( com.android.internal.R.string.notification_importance_low); case NotificationListenerService.Ranking.IMPORTANCE_DEFAULT: return getContext().getString( com.android.internal.R.string.notification_importance_default); case NotificationListenerService.Ranking.IMPORTANCE_HIGH: return getContext().getString( com.android.internal.R.string.notification_importance_high); case NotificationListenerService.Ranking.IMPORTANCE_MAX: return getContext().getString( com.android.internal.R.string.notification_importance_max); default: return ""; } } public interface Callback { void onImportanceChanged(int progress); } } Loading
res/layout/preference_importance_slider.xml 0 → 100644 +81 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2015 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" android:gravity="center_vertical" android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:orientation="vertical" android:clickable="false" android:focusable="false" android:paddingTop="8dip" android:paddingBottom="8dip"> <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" /> <TextView android:id="@android:id/summary" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignStart="@android:id/title" android:textAlignment="viewStart" android:textAppearance="@android:style/TextAppearance.Material.Body1" android:textColor="?android:attr/textColorSecondary" android:maxLines="10" android:minLines="2" /> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="6dp"> <ImageView android:id="@+id/low_importance" android:src="@android:drawable/ic_menu_close_clear_cancel" android:layout_gravity="center_vertical|start" android:layout_width="24dp" android:layout_height="24dp" /> <SeekBar android:id="@*android:id/seekbar" android:layout_marginStart="24dp" android:layout_marginEnd="24dp" android:layout_gravity="center_vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:focusable="true"/> <ImageView android:id="@+id/max_importance" android:src="@android:drawable/ic_popup_reminder" android:layout_gravity="center_vertical|end" android:layout_width="24dp" android:layout_height="24dp" /> </FrameLayout> </LinearLayout>
res/layout/preference_volume_slider.xml +2 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,8 @@ android:minHeight="?android:attr/listPreferredItemHeight" android:gravity="center_vertical" android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"> android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:clickable="false" > <LinearLayout android:layout_width="match_parent" Loading
res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -5770,6 +5770,9 @@ <!-- [CHAR LIMIT=20] Notification settings: App notifications dialog dismiss button caption --> <string name="app_notifications_dialog_done">Done</string> <!-- [CHAR LIMIT=150] App notification settings: App notifications Importance title --> <string name="app_notification_importance_title">Importance</string> <!-- [CHAR LIMIT=40] Zen mode settings: Rule name option and edit dialog title --> <string name="zen_mode_rule_name">Rule name</string> Loading
res/xml/topic_notification_settings.xml +7 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,13 @@ android:title="@string/topic_notifications_title" android:key="topic_notification_settings"> <!-- Importance --> <com.android.settings.notification.ImportanceSeekBarPreference android:key="importance" android:title="@string/app_notification_importance_title" android:order="1" android:persistent="false" /> <!-- Bypass DND --> <SwitchPreference android:key="bypass_dnd" Loading
src/com/android/settings/notification/ImportanceSeekBarPreference.java 0 → 100644 +118 −0 Original line number Diff line number Diff line /** * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.notification; import com.android.settings.R; import com.android.settings.SeekBarPreference; import android.content.Context; import android.service.notification.NotificationListenerService; import android.support.v7.preference.PreferenceViewHolder; import android.util.AttributeSet; import android.widget.SeekBar; import android.widget.TextView; /** * A slider preference that controls notification importance. **/ public class ImportanceSeekBarPreference extends SeekBarPreference implements SeekBar.OnSeekBarChangeListener { private static final String TAG = "ImportanceSeekBarPref"; public static final int IMPORTANCE_PROGRESS_OFFSET = 2; private Callback mCallback; private TextView mSummaryTextView; private String mSummary; public ImportanceSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); setLayoutResource(R.layout.preference_importance_slider); } public ImportanceSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } public ImportanceSeekBarPreference(Context context, AttributeSet attrs) { this(context, attrs, 0); } public ImportanceSeekBarPreference(Context context) { this(context, null); } public void setCallback(Callback callback) { mCallback = callback; } @Override public void onBindViewHolder(PreferenceViewHolder view) { super.onBindViewHolder(view); mSummaryTextView = (TextView) view.findViewById(com.android.internal.R.id.summary); } @Override public void setProgress(int progress) { mSummary = getProgressSummary(progress); super.setProgress(progress); } @Override public void onProgressChanged(SeekBar seekBar, final int progress, boolean fromTouch) { super.onProgressChanged(seekBar, progress, fromTouch); if (mSummaryTextView != null) { mSummaryTextView.setText(getProgressSummary(progress)); } if (fromTouch) { mCallback.onImportanceChanged(progress); } } @Override public CharSequence getSummary() { return mSummary; } private String getProgressSummary(int progress) { // Map progress 0-4 values to Importance's -2-2. progress = progress - IMPORTANCE_PROGRESS_OFFSET; switch (progress) { case NotificationListenerService.Ranking.IMPORTANCE_NONE: return getContext().getString( com.android.internal.R.string.notification_importance_blocked); case NotificationListenerService.Ranking.IMPORTANCE_LOW: return getContext().getString( com.android.internal.R.string.notification_importance_low); case NotificationListenerService.Ranking.IMPORTANCE_DEFAULT: return getContext().getString( com.android.internal.R.string.notification_importance_default); case NotificationListenerService.Ranking.IMPORTANCE_HIGH: return getContext().getString( com.android.internal.R.string.notification_importance_high); case NotificationListenerService.Ranking.IMPORTANCE_MAX: return getContext().getString( com.android.internal.R.string.notification_importance_max); default: return ""; } } public interface Callback { void onImportanceChanged(int progress); } }