Loading core/java/android/provider/Settings.java +1 −0 Original line number Diff line number Diff line Loading @@ -14107,6 +14107,7 @@ public final class Settings { * edit_choices_before_sending (boolean) * show_in_heads_up (boolean) * min_num_system_generated_replies (int) * max_num_actions (int) * </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 @@ -463,6 +463,10 @@ show none. --> <integer name="config_smart_replies_in_notifications_min_num_system_generated_replies">0</integer> <!-- Smart replies in notifications: Maximum number of smart actions to show in notifications. --> <integer name="config_smart_replies_in_notifications_max_num_actions">-1</integer> <!-- 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/policy/SmartReplyConstants.java +14 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ public final class SmartReplyConstants extends ContentObserver { "edit_choices_before_sending"; private static final String KEY_SHOW_IN_HEADS_UP = "show_in_heads_up"; private static final String KEY_MIN_NUM_REPLIES = "min_num_system_generated_replies"; private static final String KEY_MAX_NUM_ACTIONS = "max_num_actions"; private final boolean mDefaultEnabled; private final boolean mDefaultRequiresP; Loading @@ -54,6 +55,7 @@ public final class SmartReplyConstants extends ContentObserver { private final boolean mDefaultEditChoicesBeforeSending; private final boolean mDefaultShowInHeadsUp; private final int mDefaultMinNumSystemGeneratedReplies; private final int mDefaultMaxNumActions; private boolean mEnabled; private boolean mRequiresTargetingP; Loading @@ -61,6 +63,7 @@ public final class SmartReplyConstants extends ContentObserver { private boolean mEditChoicesBeforeSending; private boolean mShowInHeadsUp; private int mMinNumSystemGeneratedReplies; private int mMaxNumActions; private final Context mContext; private final KeyValueListParser mParser = new KeyValueListParser(','); Loading @@ -83,6 +86,8 @@ public final class SmartReplyConstants extends ContentObserver { R.bool.config_smart_replies_in_notifications_show_in_heads_up); mDefaultMinNumSystemGeneratedReplies = resources.getInteger( R.integer.config_smart_replies_in_notifications_min_num_system_generated_replies); mDefaultMaxNumActions = resources.getInteger( R.integer.config_smart_replies_in_notifications_max_num_actions); mContext.getContentResolver().registerContentObserver( Settings.Global.getUriFor(Settings.Global.SMART_REPLIES_IN_NOTIFICATIONS_FLAGS), Loading Loading @@ -112,6 +117,7 @@ public final class SmartReplyConstants extends ContentObserver { mShowInHeadsUp = mParser.getBoolean(KEY_SHOW_IN_HEADS_UP, mDefaultShowInHeadsUp); mMinNumSystemGeneratedReplies = mParser.getInt(KEY_MIN_NUM_REPLIES, mDefaultMinNumSystemGeneratedReplies); mMaxNumActions = mParser.getInt(KEY_MAX_NUM_ACTIONS, mDefaultMaxNumActions); } } Loading Loading @@ -170,4 +176,12 @@ public final class SmartReplyConstants extends ContentObserver { public int getMinNumSystemGeneratedReplies() { return mMinNumSystemGeneratedReplies; } /** * Returns the maximum number smart actions to show in a notification, or -1 if there shouldn't * be a limit. */ public int getMaxNumActions() { return mMaxNumActions; } } packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java +12 −0 Original line number Diff line number Diff line Loading @@ -372,8 +372,17 @@ public class SmartReplyView extends ViewGroup { // reply button is added. SmartSuggestionMeasures actionsMeasures = null; final int maxNumActions = mConstants.getMaxNumActions(); int numShownActions = 0; for (View child : smartSuggestions) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (maxNumActions != -1 // -1 means 'no limit' && lp.buttonType == SmartButtonType.ACTION && numShownActions >= maxNumActions) { // We've reached the maximum number of actions, don't add another one! continue; } child.setPadding(accumulatedMeasures.mButtonPaddingHorizontal, child.getPaddingTop(), accumulatedMeasures.mButtonPaddingHorizontal, child.getPaddingBottom()); Loading Loading @@ -457,6 +466,9 @@ public class SmartReplyView extends ViewGroup { lp.show = true; displayedChildCount++; if (lp.buttonType == SmartButtonType.ACTION) { numShownActions++; } } if (mSmartRepliesGeneratedByAssistant) { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyConstantsTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -176,6 +176,19 @@ public class SmartReplyConstantsTest extends SysuiTestCase { assertFalse(mConstants.getShowInHeadsUp()); } @Test public void testMaxNumActionsWithNoConfig() { assertTrue(mConstants.isEnabled()); assertEquals(-1, mConstants.getMaxNumActions()); } @Test public void testMaxNumActionsSet() { overrideSetting("enabled=true,max_num_actions=10"); triggerConstantsOnChange(); assertEquals(10, mConstants.getMaxNumActions()); } 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 @@ -14107,6 +14107,7 @@ public final class Settings { * edit_choices_before_sending (boolean) * show_in_heads_up (boolean) * min_num_system_generated_replies (int) * max_num_actions (int) * </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 @@ -463,6 +463,10 @@ show none. --> <integer name="config_smart_replies_in_notifications_min_num_system_generated_replies">0</integer> <!-- Smart replies in notifications: Maximum number of smart actions to show in notifications. --> <integer name="config_smart_replies_in_notifications_max_num_actions">-1</integer> <!-- 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/policy/SmartReplyConstants.java +14 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ public final class SmartReplyConstants extends ContentObserver { "edit_choices_before_sending"; private static final String KEY_SHOW_IN_HEADS_UP = "show_in_heads_up"; private static final String KEY_MIN_NUM_REPLIES = "min_num_system_generated_replies"; private static final String KEY_MAX_NUM_ACTIONS = "max_num_actions"; private final boolean mDefaultEnabled; private final boolean mDefaultRequiresP; Loading @@ -54,6 +55,7 @@ public final class SmartReplyConstants extends ContentObserver { private final boolean mDefaultEditChoicesBeforeSending; private final boolean mDefaultShowInHeadsUp; private final int mDefaultMinNumSystemGeneratedReplies; private final int mDefaultMaxNumActions; private boolean mEnabled; private boolean mRequiresTargetingP; Loading @@ -61,6 +63,7 @@ public final class SmartReplyConstants extends ContentObserver { private boolean mEditChoicesBeforeSending; private boolean mShowInHeadsUp; private int mMinNumSystemGeneratedReplies; private int mMaxNumActions; private final Context mContext; private final KeyValueListParser mParser = new KeyValueListParser(','); Loading @@ -83,6 +86,8 @@ public final class SmartReplyConstants extends ContentObserver { R.bool.config_smart_replies_in_notifications_show_in_heads_up); mDefaultMinNumSystemGeneratedReplies = resources.getInteger( R.integer.config_smart_replies_in_notifications_min_num_system_generated_replies); mDefaultMaxNumActions = resources.getInteger( R.integer.config_smart_replies_in_notifications_max_num_actions); mContext.getContentResolver().registerContentObserver( Settings.Global.getUriFor(Settings.Global.SMART_REPLIES_IN_NOTIFICATIONS_FLAGS), Loading Loading @@ -112,6 +117,7 @@ public final class SmartReplyConstants extends ContentObserver { mShowInHeadsUp = mParser.getBoolean(KEY_SHOW_IN_HEADS_UP, mDefaultShowInHeadsUp); mMinNumSystemGeneratedReplies = mParser.getInt(KEY_MIN_NUM_REPLIES, mDefaultMinNumSystemGeneratedReplies); mMaxNumActions = mParser.getInt(KEY_MAX_NUM_ACTIONS, mDefaultMaxNumActions); } } Loading Loading @@ -170,4 +176,12 @@ public final class SmartReplyConstants extends ContentObserver { public int getMinNumSystemGeneratedReplies() { return mMinNumSystemGeneratedReplies; } /** * Returns the maximum number smart actions to show in a notification, or -1 if there shouldn't * be a limit. */ public int getMaxNumActions() { return mMaxNumActions; } }
packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java +12 −0 Original line number Diff line number Diff line Loading @@ -372,8 +372,17 @@ public class SmartReplyView extends ViewGroup { // reply button is added. SmartSuggestionMeasures actionsMeasures = null; final int maxNumActions = mConstants.getMaxNumActions(); int numShownActions = 0; for (View child : smartSuggestions) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (maxNumActions != -1 // -1 means 'no limit' && lp.buttonType == SmartButtonType.ACTION && numShownActions >= maxNumActions) { // We've reached the maximum number of actions, don't add another one! continue; } child.setPadding(accumulatedMeasures.mButtonPaddingHorizontal, child.getPaddingTop(), accumulatedMeasures.mButtonPaddingHorizontal, child.getPaddingBottom()); Loading Loading @@ -457,6 +466,9 @@ public class SmartReplyView extends ViewGroup { lp.show = true; displayedChildCount++; if (lp.buttonType == SmartButtonType.ACTION) { numShownActions++; } } if (mSmartRepliesGeneratedByAssistant) { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyConstantsTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -176,6 +176,19 @@ public class SmartReplyConstantsTest extends SysuiTestCase { assertFalse(mConstants.getShowInHeadsUp()); } @Test public void testMaxNumActionsWithNoConfig() { assertTrue(mConstants.isEnabled()); assertEquals(-1, mConstants.getMaxNumActions()); } @Test public void testMaxNumActionsSet() { overrideSetting("enabled=true,max_num_actions=10"); triggerConstantsOnChange(); assertEquals(10, mConstants.getMaxNumActions()); } private void overrideSetting(String flags) { Settings.Global.putString(mContext.getContentResolver(), Settings.Global.SMART_REPLIES_IN_NOTIFICATIONS_FLAGS, flags); Loading