Loading res/xml/legacy_channel_notification_settings.xml→res/xml/app_notification_settings.xml +26 −16 Original line number Diff line number Diff line Loading @@ -17,6 +17,14 @@ <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"> <com.android.settings.applications.LayoutPreference android:key="pref_app_header" android:layout="@layout/settings_entity_header" /> <com.android.settings.applications.LayoutPreference android:key="block" android:layout="@layout/styled_switch_bar" /> <!-- Show badge --> <com.android.settingslib.RestrictedSwitchPreference android:key="badge" Loading @@ -24,22 +32,24 @@ settings:useAdditionalSummary="true" settings:restrictedSwitchSummary="@string/enabled_by_admin" /> <!-- Importance toggle --> <com.android.settingslib.RestrictedSwitchPreference android:key="allow_sound" android:title="@string/allow_interruption" android:summary="@string/allow_interruption_summary"/> <!-- Channels/Channel groups added here --> <!-- Visibility Override --> <com.android.settings.notification.RestrictedDropDownPreference android:key="visibility_override" android:title="@string/app_notification_visibility_override_title" /> <Preference android:key="app_link" android:title="@string/app_settings_link" android:order="500" settings:allowDividerAbove="true"/> <!-- Bypass DND --> <com.android.settingslib.RestrictedSwitchPreference android:key="bypass_dnd" android:title="@string/app_notification_override_dnd_title" android:summary="@string/app_notification_override_dnd_summary" settings:useAdditionalSummary="true" /> <com.android.settings.notification.NotificationFooterPreference android:key="block_desc" android:order="1000" /> <com.android.settings.notification.NotificationFooterPreference android:key="desc" android:order="5000" /> <com.android.settings.notification.NotificationFooterPreference android:key="deleted" android:order="8000" /> </PreferenceScreen> res/xml/upgraded_channel_notification_settings.xml→res/xml/channel_notification_settings.xml +90 −0 Original line number Diff line number Diff line Loading @@ -17,11 +17,25 @@ <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res/com.android.settings" > <com.android.settings.applications.LayoutPreference android:key="pref_app_header" android:layout="@layout/settings_entity_header" /> <com.android.settings.applications.LayoutPreference android:key="block" android:layout="@layout/styled_switch_bar" /> <!-- Importance --> <Preference android:key="importance" android:title="@string/notification_importance_title" /> <!-- Importance toggle --> <com.android.settingslib.RestrictedSwitchPreference android:key="allow_sound" android:title="@string/allow_interruption" android:summary="@string/allow_interruption_summary" /> <!-- Default ringtone --> <com.android.settings.notification.NotificationSoundPreference android:key="ringtone" Loading @@ -37,10 +51,6 @@ android:title="@string/notification_vibrate_title" settings:useAdditionalSummary="true" /> <PreferenceCategory android:key="advanced" android:title="@string/advanced_apps"> <!-- Visibility Override --> <com.android.settings.notification.RestrictedDropDownPreference android:key="visibility_override" Loading @@ -66,6 +76,15 @@ android:summary="@string/app_notification_override_dnd_summary" settings:useAdditionalSummary="true"/> </PreferenceCategory> <Preference android:key="app_link" android:title="@string/app_settings_link" settings:allowDividerAbove="true"/> <com.android.settings.notification.NotificationFooterPreference android:key="desc" /> <com.android.settings.notification.NotificationFooterPreference android:key="block_desc" /> </PreferenceScreen> res/xml/upgraded_app_notification_settings.xml→res/xml/notification_group_settings.xml +19 −6 Original line number Diff line number Diff line Loading @@ -17,11 +17,24 @@ <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"> <!-- Show badge --> <com.android.settingslib.RestrictedSwitchPreference android:key="badge" android:title="@string/notification_badge_title" settings:useAdditionalSummary="true" settings:restrictedSwitchSummary="@string/enabled_by_admin" /> <com.android.settings.applications.LayoutPreference android:key="pref_app_header" android:layout="@layout/settings_entity_header" /> <com.android.settings.applications.LayoutPreference android:key="block" android:layout="@layout/styled_switch_bar" /> <!-- Channels added here --> <Preference android:key="app_link" android:title="@string/app_settings_link" settings:allowDividerAbove="true"/> <com.android.settings.notification.NotificationFooterPreference android:key="desc" /> <com.android.settings.notification.NotificationFooterPreference android:key="block_desc" /> </PreferenceScreen> src/com/android/settings/notification/AllowSoundPreferenceController.java 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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 static android.app.NotificationManager.IMPORTANCE_DEFAULT; import static android.app.NotificationManager.IMPORTANCE_LOW; import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED; import android.app.NotificationChannel; import android.content.Context; import android.support.v7.preference.Preference; import android.util.Log; import com.android.settings.core.PreferenceControllerMixin; import com.android.settingslib.RestrictedSwitchPreference; public class AllowSoundPreferenceController extends NotificationPreferenceController implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener { private static final String TAG = "AllowSoundPrefContr"; private static final String KEY_IMPORTANCE = "allow_sound"; private NotificationSettingsBase.ImportanceListener mImportanceListener; public AllowSoundPreferenceController(Context context, NotificationSettingsBase.ImportanceListener importanceListener, NotificationBackend backend) { super(context, backend); mImportanceListener = importanceListener; } @Override public String getPreferenceKey() { return KEY_IMPORTANCE; } @Override public boolean isAvailable() { if (!super.isAvailable()) { return false; } return mChannel != null && NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId()); } public void updateState(Preference preference) { if (mChannel != null) { RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference; pref.setDisabledByAdmin(mAdmin); pref.setEnabled(isChannelConfigurable() && !pref.isDisabledByAdmin()); pref.setChecked(mChannel.getImportance() >= IMPORTANCE_DEFAULT || mChannel.getImportance() == IMPORTANCE_UNSPECIFIED); } else { Log.i(TAG, "tried to updatestate on a null channel?!"); } } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (mChannel != null) { final int importance = ((Boolean) newValue ? IMPORTANCE_UNSPECIFIED : IMPORTANCE_LOW); mChannel.setImportance(importance); mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE); saveChannel(); mImportanceListener.onImportanceChanged(); } return true; } } src/com/android/settings/notification/AppLinkPreferenceController.java 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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 android.content.Context; import android.support.v7.preference.Preference; import com.android.settings.core.PreferenceControllerMixin; /** * Controls link to reach more preference settings inside the app. */ public class AppLinkPreferenceController extends NotificationPreferenceController implements PreferenceControllerMixin { private static final String TAG = "AppLinkPrefContr"; private static final String KEY_APP_LINK = "app_link"; public AppLinkPreferenceController(Context context) { super(context, null); } @Override public String getPreferenceKey() { return KEY_APP_LINK; } @Override public boolean isAvailable() { if (!super.isAvailable()) { return false; } return mAppRow.settingsIntent != null; } public void updateState(Preference preference) { if (mAppRow != null) { preference.setIntent(mAppRow.settingsIntent); } } } Loading
res/xml/legacy_channel_notification_settings.xml→res/xml/app_notification_settings.xml +26 −16 Original line number Diff line number Diff line Loading @@ -17,6 +17,14 @@ <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"> <com.android.settings.applications.LayoutPreference android:key="pref_app_header" android:layout="@layout/settings_entity_header" /> <com.android.settings.applications.LayoutPreference android:key="block" android:layout="@layout/styled_switch_bar" /> <!-- Show badge --> <com.android.settingslib.RestrictedSwitchPreference android:key="badge" Loading @@ -24,22 +32,24 @@ settings:useAdditionalSummary="true" settings:restrictedSwitchSummary="@string/enabled_by_admin" /> <!-- Importance toggle --> <com.android.settingslib.RestrictedSwitchPreference android:key="allow_sound" android:title="@string/allow_interruption" android:summary="@string/allow_interruption_summary"/> <!-- Channels/Channel groups added here --> <!-- Visibility Override --> <com.android.settings.notification.RestrictedDropDownPreference android:key="visibility_override" android:title="@string/app_notification_visibility_override_title" /> <Preference android:key="app_link" android:title="@string/app_settings_link" android:order="500" settings:allowDividerAbove="true"/> <!-- Bypass DND --> <com.android.settingslib.RestrictedSwitchPreference android:key="bypass_dnd" android:title="@string/app_notification_override_dnd_title" android:summary="@string/app_notification_override_dnd_summary" settings:useAdditionalSummary="true" /> <com.android.settings.notification.NotificationFooterPreference android:key="block_desc" android:order="1000" /> <com.android.settings.notification.NotificationFooterPreference android:key="desc" android:order="5000" /> <com.android.settings.notification.NotificationFooterPreference android:key="deleted" android:order="8000" /> </PreferenceScreen>
res/xml/upgraded_channel_notification_settings.xml→res/xml/channel_notification_settings.xml +90 −0 Original line number Diff line number Diff line Loading @@ -17,11 +17,25 @@ <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res/com.android.settings" > <com.android.settings.applications.LayoutPreference android:key="pref_app_header" android:layout="@layout/settings_entity_header" /> <com.android.settings.applications.LayoutPreference android:key="block" android:layout="@layout/styled_switch_bar" /> <!-- Importance --> <Preference android:key="importance" android:title="@string/notification_importance_title" /> <!-- Importance toggle --> <com.android.settingslib.RestrictedSwitchPreference android:key="allow_sound" android:title="@string/allow_interruption" android:summary="@string/allow_interruption_summary" /> <!-- Default ringtone --> <com.android.settings.notification.NotificationSoundPreference android:key="ringtone" Loading @@ -37,10 +51,6 @@ android:title="@string/notification_vibrate_title" settings:useAdditionalSummary="true" /> <PreferenceCategory android:key="advanced" android:title="@string/advanced_apps"> <!-- Visibility Override --> <com.android.settings.notification.RestrictedDropDownPreference android:key="visibility_override" Loading @@ -66,6 +76,15 @@ android:summary="@string/app_notification_override_dnd_summary" settings:useAdditionalSummary="true"/> </PreferenceCategory> <Preference android:key="app_link" android:title="@string/app_settings_link" settings:allowDividerAbove="true"/> <com.android.settings.notification.NotificationFooterPreference android:key="desc" /> <com.android.settings.notification.NotificationFooterPreference android:key="block_desc" /> </PreferenceScreen>
res/xml/upgraded_app_notification_settings.xml→res/xml/notification_group_settings.xml +19 −6 Original line number Diff line number Diff line Loading @@ -17,11 +17,24 @@ <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"> <!-- Show badge --> <com.android.settingslib.RestrictedSwitchPreference android:key="badge" android:title="@string/notification_badge_title" settings:useAdditionalSummary="true" settings:restrictedSwitchSummary="@string/enabled_by_admin" /> <com.android.settings.applications.LayoutPreference android:key="pref_app_header" android:layout="@layout/settings_entity_header" /> <com.android.settings.applications.LayoutPreference android:key="block" android:layout="@layout/styled_switch_bar" /> <!-- Channels added here --> <Preference android:key="app_link" android:title="@string/app_settings_link" settings:allowDividerAbove="true"/> <com.android.settings.notification.NotificationFooterPreference android:key="desc" /> <com.android.settings.notification.NotificationFooterPreference android:key="block_desc" /> </PreferenceScreen>
src/com/android/settings/notification/AllowSoundPreferenceController.java 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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 static android.app.NotificationManager.IMPORTANCE_DEFAULT; import static android.app.NotificationManager.IMPORTANCE_LOW; import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED; import android.app.NotificationChannel; import android.content.Context; import android.support.v7.preference.Preference; import android.util.Log; import com.android.settings.core.PreferenceControllerMixin; import com.android.settingslib.RestrictedSwitchPreference; public class AllowSoundPreferenceController extends NotificationPreferenceController implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener { private static final String TAG = "AllowSoundPrefContr"; private static final String KEY_IMPORTANCE = "allow_sound"; private NotificationSettingsBase.ImportanceListener mImportanceListener; public AllowSoundPreferenceController(Context context, NotificationSettingsBase.ImportanceListener importanceListener, NotificationBackend backend) { super(context, backend); mImportanceListener = importanceListener; } @Override public String getPreferenceKey() { return KEY_IMPORTANCE; } @Override public boolean isAvailable() { if (!super.isAvailable()) { return false; } return mChannel != null && NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId()); } public void updateState(Preference preference) { if (mChannel != null) { RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference; pref.setDisabledByAdmin(mAdmin); pref.setEnabled(isChannelConfigurable() && !pref.isDisabledByAdmin()); pref.setChecked(mChannel.getImportance() >= IMPORTANCE_DEFAULT || mChannel.getImportance() == IMPORTANCE_UNSPECIFIED); } else { Log.i(TAG, "tried to updatestate on a null channel?!"); } } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (mChannel != null) { final int importance = ((Boolean) newValue ? IMPORTANCE_UNSPECIFIED : IMPORTANCE_LOW); mChannel.setImportance(importance); mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE); saveChannel(); mImportanceListener.onImportanceChanged(); } return true; } }
src/com/android/settings/notification/AppLinkPreferenceController.java 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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 android.content.Context; import android.support.v7.preference.Preference; import com.android.settings.core.PreferenceControllerMixin; /** * Controls link to reach more preference settings inside the app. */ public class AppLinkPreferenceController extends NotificationPreferenceController implements PreferenceControllerMixin { private static final String TAG = "AppLinkPrefContr"; private static final String KEY_APP_LINK = "app_link"; public AppLinkPreferenceController(Context context) { super(context, null); } @Override public String getPreferenceKey() { return KEY_APP_LINK; } @Override public boolean isAvailable() { if (!super.isAvailable()) { return false; } return mAppRow.settingsIntent != null; } public void updateState(Preference preference) { if (mAppRow != null) { preference.setIntent(mAppRow.settingsIntent); } } }