Loading core/java/android/provider/Settings.java +1 −0 Original line number Diff line number Diff line Loading @@ -13772,6 +13772,7 @@ public final class Settings { * requires_targeting_p (boolean) * max_squeeze_remeasure_attempts (int) * edit_choices_before_sending (boolean) * show_in_heads_up (boolean) * </pre> * @see com.android.systemui.statusbar.policy.SmartReplyConstants * @hide packages/SystemUI/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -454,6 +454,10 @@ RemoteInput.Builder.setEditChoicesBeforeSending. --> <bool name="config_smart_replies_in_notifications_edit_choices_before_sending">false</bool> <!-- Smart replies in notifications: Whether smart suggestions in notifications are enabled in heads-up notifications. --> <bool name="config_smart_replies_in_notifications_show_in_heads_up">true</bool> <!-- Screenshot editing default activity. Must handle ACTION_EDIT image/png intents. Blank sends the user to the Chooser first. This name is in the ComponentName flattened format (package/class) --> Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java +1 −1 Original line number Diff line number Diff line Loading @@ -1489,7 +1489,7 @@ public class NotificationContentView extends FrameLayout { } } } if (mHeadsUpChild != null) { if (mHeadsUpChild != null && mSmartReplyConstants.getShowInHeadsUp()) { mHeadsUpSmartReplyView = applySmartReplyView(mHeadsUpChild, smartRepliesAndActions, entry); } Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java +13 −0 Original line number Diff line number Diff line Loading @@ -45,16 +45,19 @@ public final class SmartReplyConstants extends ContentObserver { "max_squeeze_remeasure_attempts"; private static final String KEY_EDIT_CHOICES_BEFORE_SENDING = "edit_choices_before_sending"; private static final String KEY_SHOW_IN_HEADS_UP = "show_in_heads_up"; private final boolean mDefaultEnabled; private final boolean mDefaultRequiresP; private final int mDefaultMaxSqueezeRemeasureAttempts; private final boolean mDefaultEditChoicesBeforeSending; private final boolean mDefaultShowInHeadsUp; private boolean mEnabled; private boolean mRequiresTargetingP; private int mMaxSqueezeRemeasureAttempts; private boolean mEditChoicesBeforeSending; private boolean mShowInHeadsUp; private final Context mContext; private final KeyValueListParser mParser = new KeyValueListParser(','); Loading @@ -73,6 +76,8 @@ public final class SmartReplyConstants extends ContentObserver { R.integer.config_smart_replies_in_notifications_max_squeeze_remeasure_attempts); mDefaultEditChoicesBeforeSending = resources.getBoolean( R.bool.config_smart_replies_in_notifications_edit_choices_before_sending); mDefaultShowInHeadsUp = resources.getBoolean( R.bool.config_smart_replies_in_notifications_show_in_heads_up); mContext.getContentResolver().registerContentObserver( Settings.Global.getUriFor(Settings.Global.SMART_REPLIES_IN_NOTIFICATIONS_FLAGS), Loading @@ -99,6 +104,7 @@ public final class SmartReplyConstants extends ContentObserver { KEY_MAX_SQUEEZE_REMEASURE_ATTEMPTS, mDefaultMaxSqueezeRemeasureAttempts); mEditChoicesBeforeSending = mParser.getBoolean( KEY_EDIT_CHOICES_BEFORE_SENDING, mDefaultEditChoicesBeforeSending); mShowInHeadsUp = mParser.getBoolean(KEY_SHOW_IN_HEADS_UP, mDefaultShowInHeadsUp); } } Loading Loading @@ -142,4 +148,11 @@ public final class SmartReplyConstants extends ContentObserver { return mEditChoicesBeforeSending; } } /** * Returns whether smart suggestions should be enabled in heads-up notifications. */ public boolean getShowInHeadsUp() { return mShowInHeadsUp; } } packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyConstantsTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ public class SmartReplyConstantsTest extends SysuiTestCase { R.integer.config_smart_replies_in_notifications_max_squeeze_remeasure_attempts, 7); resources.addOverride( R.bool.config_smart_replies_in_notifications_edit_choices_before_sending, false); resources.addOverride(R.bool.config_smart_replies_in_notifications_show_in_heads_up, true); mConstants = new SmartReplyConstants(Handler.createAsync(Looper.myLooper()), mContext); } Loading Loading @@ -152,6 +153,26 @@ public class SmartReplyConstantsTest extends SysuiTestCase { RemoteInput.EDIT_CHOICES_BEFORE_SENDING_DISABLED)); } @Test public void testShowInHeadsUpWithNoConfig() { assertTrue(mConstants.isEnabled()); assertTrue(mConstants.getShowInHeadsUp()); } @Test public void testShowInHeadsUpEnabled() { overrideSetting("enabled=true,show_in_heads_up=true"); triggerConstantsOnChange(); assertTrue(mConstants.getShowInHeadsUp()); } @Test public void testShowInHeadsUpDisabled() { overrideSetting("enabled=true,show_in_heads_up=false"); triggerConstantsOnChange(); assertFalse(mConstants.getShowInHeadsUp()); } private void overrideSetting(String flags) { Settings.Global.putString(mContext.getContentResolver(), Settings.Global.SMART_REPLIES_IN_NOTIFICATIONS_FLAGS, flags); Loading Loading
core/java/android/provider/Settings.java +1 −0 Original line number Diff line number Diff line Loading @@ -13772,6 +13772,7 @@ public final class Settings { * requires_targeting_p (boolean) * max_squeeze_remeasure_attempts (int) * edit_choices_before_sending (boolean) * show_in_heads_up (boolean) * </pre> * @see com.android.systemui.statusbar.policy.SmartReplyConstants * @hide
packages/SystemUI/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -454,6 +454,10 @@ RemoteInput.Builder.setEditChoicesBeforeSending. --> <bool name="config_smart_replies_in_notifications_edit_choices_before_sending">false</bool> <!-- Smart replies in notifications: Whether smart suggestions in notifications are enabled in heads-up notifications. --> <bool name="config_smart_replies_in_notifications_show_in_heads_up">true</bool> <!-- Screenshot editing default activity. Must handle ACTION_EDIT image/png intents. Blank sends the user to the Chooser first. This name is in the ComponentName flattened format (package/class) --> Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java +1 −1 Original line number Diff line number Diff line Loading @@ -1489,7 +1489,7 @@ public class NotificationContentView extends FrameLayout { } } } if (mHeadsUpChild != null) { if (mHeadsUpChild != null && mSmartReplyConstants.getShowInHeadsUp()) { mHeadsUpSmartReplyView = applySmartReplyView(mHeadsUpChild, smartRepliesAndActions, entry); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyConstants.java +13 −0 Original line number Diff line number Diff line Loading @@ -45,16 +45,19 @@ public final class SmartReplyConstants extends ContentObserver { "max_squeeze_remeasure_attempts"; private static final String KEY_EDIT_CHOICES_BEFORE_SENDING = "edit_choices_before_sending"; private static final String KEY_SHOW_IN_HEADS_UP = "show_in_heads_up"; private final boolean mDefaultEnabled; private final boolean mDefaultRequiresP; private final int mDefaultMaxSqueezeRemeasureAttempts; private final boolean mDefaultEditChoicesBeforeSending; private final boolean mDefaultShowInHeadsUp; private boolean mEnabled; private boolean mRequiresTargetingP; private int mMaxSqueezeRemeasureAttempts; private boolean mEditChoicesBeforeSending; private boolean mShowInHeadsUp; private final Context mContext; private final KeyValueListParser mParser = new KeyValueListParser(','); Loading @@ -73,6 +76,8 @@ public final class SmartReplyConstants extends ContentObserver { R.integer.config_smart_replies_in_notifications_max_squeeze_remeasure_attempts); mDefaultEditChoicesBeforeSending = resources.getBoolean( R.bool.config_smart_replies_in_notifications_edit_choices_before_sending); mDefaultShowInHeadsUp = resources.getBoolean( R.bool.config_smart_replies_in_notifications_show_in_heads_up); mContext.getContentResolver().registerContentObserver( Settings.Global.getUriFor(Settings.Global.SMART_REPLIES_IN_NOTIFICATIONS_FLAGS), Loading @@ -99,6 +104,7 @@ public final class SmartReplyConstants extends ContentObserver { KEY_MAX_SQUEEZE_REMEASURE_ATTEMPTS, mDefaultMaxSqueezeRemeasureAttempts); mEditChoicesBeforeSending = mParser.getBoolean( KEY_EDIT_CHOICES_BEFORE_SENDING, mDefaultEditChoicesBeforeSending); mShowInHeadsUp = mParser.getBoolean(KEY_SHOW_IN_HEADS_UP, mDefaultShowInHeadsUp); } } Loading Loading @@ -142,4 +148,11 @@ public final class SmartReplyConstants extends ContentObserver { return mEditChoicesBeforeSending; } } /** * Returns whether smart suggestions should be enabled in heads-up notifications. */ public boolean getShowInHeadsUp() { return mShowInHeadsUp; } }
packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyConstantsTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ public class SmartReplyConstantsTest extends SysuiTestCase { R.integer.config_smart_replies_in_notifications_max_squeeze_remeasure_attempts, 7); resources.addOverride( R.bool.config_smart_replies_in_notifications_edit_choices_before_sending, false); resources.addOverride(R.bool.config_smart_replies_in_notifications_show_in_heads_up, true); mConstants = new SmartReplyConstants(Handler.createAsync(Looper.myLooper()), mContext); } Loading Loading @@ -152,6 +153,26 @@ public class SmartReplyConstantsTest extends SysuiTestCase { RemoteInput.EDIT_CHOICES_BEFORE_SENDING_DISABLED)); } @Test public void testShowInHeadsUpWithNoConfig() { assertTrue(mConstants.isEnabled()); assertTrue(mConstants.getShowInHeadsUp()); } @Test public void testShowInHeadsUpEnabled() { overrideSetting("enabled=true,show_in_heads_up=true"); triggerConstantsOnChange(); assertTrue(mConstants.getShowInHeadsUp()); } @Test public void testShowInHeadsUpDisabled() { overrideSetting("enabled=true,show_in_heads_up=false"); triggerConstantsOnChange(); assertFalse(mConstants.getShowInHeadsUp()); } private void overrideSetting(String flags) { Settings.Global.putString(mContext.getContentResolver(), Settings.Global.SMART_REPLIES_IN_NOTIFICATIONS_FLAGS, flags); Loading