Loading src/com/android/settings/notification/app/BlockPreferenceController.java +5 −2 Original line number Diff line number Diff line Loading @@ -106,8 +106,11 @@ public class BlockPreferenceController extends NotificationPreferenceController // It's always safe to override the importance if it's meant to be blocked or if // it was blocked and we are unblocking it. if (blocked || originalImportance == IMPORTANCE_NONE) { final int importance = blocked ? IMPORTANCE_NONE : isDefaultChannel() ? IMPORTANCE_UNSPECIFIED : IMPORTANCE_DEFAULT; final int importance = blocked ? IMPORTANCE_NONE : isDefaultChannel() ? IMPORTANCE_UNSPECIFIED : mChannel.getOriginalImportance(); mChannel.setImportance(importance); saveChannel(); } Loading src/com/android/settings/notification/app/ChannelListPreferenceController.java +2 −23 Original line number Diff line number Diff line Loading @@ -207,17 +207,14 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr channelPref.setOnPreferenceChangeListener( (preference, o) -> { boolean value = (Boolean) o; int importance = value ? IMPORTANCE_LOW : IMPORTANCE_NONE; int importance = value ? channel.getOriginalImportance() : IMPORTANCE_NONE; channel.setImportance(importance); channel.lockFields( NotificationChannel.USER_LOCKED_IMPORTANCE); channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE); MasterSwitchPreference channelPref1 = (MasterSwitchPreference) preference; channelPref1.setIcon(null); if (channel.getImportance() > IMPORTANCE_LOW) { channelPref1.setIcon(getAlertingIcon()); } toggleBehaviorIconState(channelPref1.getIcon(), importance != IMPORTANCE_NONE); mBackend.updateChannel(mAppRow.pkg, mAppRow.uid, channel); return true; Loading @@ -234,24 +231,6 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr return icon; } private void toggleBehaviorIconState(Drawable icon, boolean enabled) { if (icon == null) return; LayerDrawable layerDrawable = (LayerDrawable) icon; GradientDrawable background = (GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.back); if (background == null) return; if (enabled) { background.clearColorFilter(); } else { background.setColorFilter(new BlendModeColorFilter( mContext.getColor(R.color.material_grey_300), BlendMode.SRC_IN)); } } protected void onGroupBlockStateChanged(NotificationChannelGroup group) { if (group == null) { return; Loading tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -368,6 +368,7 @@ public class BlockPreferenceControllerTest { public void testOnSwitchChanged_channel_nonDefault() { NotificationBackend.AppRow appRow = new NotificationBackend.AppRow(); NotificationChannel channel = new NotificationChannel("a", "a", IMPORTANCE_HIGH); channel.setOriginalImportance(IMPORTANCE_HIGH); mController.onResume(appRow, channel, null, null, null, null); mController.updateState(mPreference); Loading @@ -375,7 +376,7 @@ public class BlockPreferenceControllerTest { assertEquals(IMPORTANCE_NONE, channel.getImportance()); mController.onSwitchChanged(null, true); assertEquals(IMPORTANCE_DEFAULT, channel.getImportance()); assertEquals(IMPORTANCE_HIGH, channel.getImportance()); verify(mBackend, times(2)).updateChannel(any(), anyInt(), any()); } Loading Loading
src/com/android/settings/notification/app/BlockPreferenceController.java +5 −2 Original line number Diff line number Diff line Loading @@ -106,8 +106,11 @@ public class BlockPreferenceController extends NotificationPreferenceController // It's always safe to override the importance if it's meant to be blocked or if // it was blocked and we are unblocking it. if (blocked || originalImportance == IMPORTANCE_NONE) { final int importance = blocked ? IMPORTANCE_NONE : isDefaultChannel() ? IMPORTANCE_UNSPECIFIED : IMPORTANCE_DEFAULT; final int importance = blocked ? IMPORTANCE_NONE : isDefaultChannel() ? IMPORTANCE_UNSPECIFIED : mChannel.getOriginalImportance(); mChannel.setImportance(importance); saveChannel(); } Loading
src/com/android/settings/notification/app/ChannelListPreferenceController.java +2 −23 Original line number Diff line number Diff line Loading @@ -207,17 +207,14 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr channelPref.setOnPreferenceChangeListener( (preference, o) -> { boolean value = (Boolean) o; int importance = value ? IMPORTANCE_LOW : IMPORTANCE_NONE; int importance = value ? channel.getOriginalImportance() : IMPORTANCE_NONE; channel.setImportance(importance); channel.lockFields( NotificationChannel.USER_LOCKED_IMPORTANCE); channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE); MasterSwitchPreference channelPref1 = (MasterSwitchPreference) preference; channelPref1.setIcon(null); if (channel.getImportance() > IMPORTANCE_LOW) { channelPref1.setIcon(getAlertingIcon()); } toggleBehaviorIconState(channelPref1.getIcon(), importance != IMPORTANCE_NONE); mBackend.updateChannel(mAppRow.pkg, mAppRow.uid, channel); return true; Loading @@ -234,24 +231,6 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr return icon; } private void toggleBehaviorIconState(Drawable icon, boolean enabled) { if (icon == null) return; LayerDrawable layerDrawable = (LayerDrawable) icon; GradientDrawable background = (GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.back); if (background == null) return; if (enabled) { background.clearColorFilter(); } else { background.setColorFilter(new BlendModeColorFilter( mContext.getColor(R.color.material_grey_300), BlendMode.SRC_IN)); } } protected void onGroupBlockStateChanged(NotificationChannelGroup group) { if (group == null) { return; Loading
tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -368,6 +368,7 @@ public class BlockPreferenceControllerTest { public void testOnSwitchChanged_channel_nonDefault() { NotificationBackend.AppRow appRow = new NotificationBackend.AppRow(); NotificationChannel channel = new NotificationChannel("a", "a", IMPORTANCE_HIGH); channel.setOriginalImportance(IMPORTANCE_HIGH); mController.onResume(appRow, channel, null, null, null, null); mController.updateState(mPreference); Loading @@ -375,7 +376,7 @@ public class BlockPreferenceControllerTest { assertEquals(IMPORTANCE_NONE, channel.getImportance()); mController.onSwitchChanged(null, true); assertEquals(IMPORTANCE_DEFAULT, channel.getImportance()); assertEquals(IMPORTANCE_HIGH, channel.getImportance()); verify(mBackend, times(2)).updateChannel(any(), anyInt(), any()); } Loading