Renaming disallowEmoji function to setEmojisAllowed

Previous function was adding extra with value true for DISALLOW_EMOJI.
This commit is renaming that function to setEmojisAllowed with parameter
whether the option to draw emojis will be shown or not.

Bug: 199152090
Test: Existing ones and added a new one
Relnote: "Refactoring disallowEmoji function to setEmojisAllowed in `WearableRemoteInputExtender` to use to set whether the option to draw emojis will be shown."
Change-Id: I28393933d8c178c6f39bcc6ec0c571edf0ade471
diff --git a/wear/wear-input/api/current.txt b/wear/wear-input/api/current.txt
index a0b3172..456a8fd 100644
--- a/wear/wear-input/api/current.txt
+++ b/wear/wear-input/api/current.txt
@@ -94,8 +94,8 @@
 
   public final class WearableRemoteInputExtender {
     ctor public WearableRemoteInputExtender(android.app.RemoteInput.Builder remoteInput);
-    method public androidx.wear.input.WearableRemoteInputExtender disallowEmoji();
     method public android.app.RemoteInput.Builder get();
+    method public androidx.wear.input.WearableRemoteInputExtender setEmojisAllowed(boolean emojisAllowed);
     method public androidx.wear.input.WearableRemoteInputExtender setInputActionType(int imeActionType);
   }
 
diff --git a/wear/wear-input/api/public_plus_experimental_current.txt b/wear/wear-input/api/public_plus_experimental_current.txt
index a0b3172..456a8fd 100644
--- a/wear/wear-input/api/public_plus_experimental_current.txt
+++ b/wear/wear-input/api/public_plus_experimental_current.txt
@@ -94,8 +94,8 @@
 
   public final class WearableRemoteInputExtender {
     ctor public WearableRemoteInputExtender(android.app.RemoteInput.Builder remoteInput);
-    method public androidx.wear.input.WearableRemoteInputExtender disallowEmoji();
     method public android.app.RemoteInput.Builder get();
+    method public androidx.wear.input.WearableRemoteInputExtender setEmojisAllowed(boolean emojisAllowed);
     method public androidx.wear.input.WearableRemoteInputExtender setInputActionType(int imeActionType);
   }
 
diff --git a/wear/wear-input/api/restricted_current.txt b/wear/wear-input/api/restricted_current.txt
index a0b3172..456a8fd 100644
--- a/wear/wear-input/api/restricted_current.txt
+++ b/wear/wear-input/api/restricted_current.txt
@@ -94,8 +94,8 @@
 
   public final class WearableRemoteInputExtender {
     ctor public WearableRemoteInputExtender(android.app.RemoteInput.Builder remoteInput);
-    method public androidx.wear.input.WearableRemoteInputExtender disallowEmoji();
     method public android.app.RemoteInput.Builder get();
+    method public androidx.wear.input.WearableRemoteInputExtender setEmojisAllowed(boolean emojisAllowed);
     method public androidx.wear.input.WearableRemoteInputExtender setInputActionType(int imeActionType);
   }
 
diff --git a/wear/wear-input/samples/src/main/java/androidx/wear/input/samples/WearableRemoteInputExtenderSample.kt b/wear/wear-input/samples/src/main/java/androidx/wear/input/samples/WearableRemoteInputExtenderSample.kt
index 4dcf433..9d18a11 100644
--- a/wear/wear-input/samples/src/main/java/androidx/wear/input/samples/WearableRemoteInputExtenderSample.kt
+++ b/wear/wear-input/samples/src/main/java/androidx/wear/input/samples/WearableRemoteInputExtenderSample.kt
@@ -26,7 +26,7 @@
     RemoteInput.Builder("resultKey")
         .setAllowFreeFormInput(true)
         .wearableExtender {
-            disallowEmoji()
+            setEmojisAllowed(false)
             setInputActionType(EditorInfo.IME_ACTION_GO)
         }.build()
 }
\ No newline at end of file
diff --git a/wear/wear-input/src/main/java/androidx/wear/input/WearableRemoteInputExtender.kt b/wear/wear-input/src/main/java/androidx/wear/input/WearableRemoteInputExtender.kt
index 10b8a43..0b27c43 100644
--- a/wear/wear-input/src/main/java/androidx/wear/input/WearableRemoteInputExtender.kt
+++ b/wear/wear-input/src/main/java/androidx/wear/input/WearableRemoteInputExtender.kt
@@ -33,15 +33,16 @@
     private var extras = Bundle()
 
     /**
-     * Adding extra to a [RemoteInput] that causes emoji-only options (e.g. the Draw Emoji option)
-     * to not be shown.
+     * Adding extra to a [RemoteInput] for allowing or disallowing showing emoji-only options (e.g.
+     * the Draw Emoji option).
      *
-     * If it is set, the Draw Emoji option will not be shown. If it is not set, the Draw Emoji
-     * option will be shown as long as the [RemoteInput] allows free form input.
+     * If set to false, the Draw Emoji option will not be shown. If set to true or not set, the
+     * Draw Emoji option will be shown as long as the [RemoteInput] allows free form input.
+     *
+     * @param emojisAllowed Whether the emoji-only options is shown. If not set, it will be allowed.
      */
-    public fun disallowEmoji(): WearableRemoteInputExtender = apply {
-        extras.putBoolean(EXTRA_DISALLOW_EMOJI, true)
-    }
+    public fun setEmojisAllowed(emojisAllowed: Boolean): WearableRemoteInputExtender =
+        apply { extras.putBoolean(EXTRA_DISALLOW_EMOJI, !emojisAllowed) }
 
     /**
      * Adding specified input action type to a [RemoteInput] to modify the action type of the
diff --git a/wear/wear-input/src/test/java/androidx/wear/input/WearableRemoteInputExtenderTest.kt b/wear/wear-input/src/test/java/androidx/wear/input/WearableRemoteInputExtenderTest.kt
index ccc0560..6028816 100644
--- a/wear/wear-input/src/test/java/androidx/wear/input/WearableRemoteInputExtenderTest.kt
+++ b/wear/wear-input/src/test/java/androidx/wear/input/WearableRemoteInputExtenderTest.kt
@@ -35,10 +35,10 @@
 @RunWith(WearInputTestRunner::class)
 class WearableRemoteInputExtenderTest {
     @Test
-    fun testDisallowEmoji_setTrue() {
+    fun testDisallowEmoji() {
         val remoteInput = RemoteInput.Builder("resultKey")
             .wearableExtender {
-                disallowEmoji()
+                setEmojisAllowed(false)
             }.build()
 
         assertTrue(
@@ -51,7 +51,23 @@
     }
 
     @Test
-    fun testDisallowEmoji_notSet() {
+    fun testSetEmojisAllowed() {
+        val remoteInput: RemoteInput = RemoteInput.Builder("resultKey")
+            .wearableExtender {
+                setEmojisAllowed(true)
+            }.build()
+
+        assertFalse(
+            remoteInput.extras.getBoolean(WearableRemoteInputExtender.EXTRA_DISALLOW_EMOJI)
+        )
+        // Test that input action type is not set.
+        assertEquals(
+            -1, remoteInput.extras.getInt(WearableRemoteInputExtender.EXTRA_INPUT_ACTION_TYPE, -1)
+        )
+    }
+
+    @Test
+    fun testSetEmojisAllowed_notSet() {
         val remoteInput: RemoteInput = RemoteInput.Builder("resultKey")
             .wearableExtender {
                 // empty
@@ -90,7 +106,7 @@
     fun testDisallowEmoji_SetInputActionType() {
         val remoteInput = RemoteInput.Builder("resultKey")
             .wearableExtender {
-                disallowEmoji()
+                setEmojisAllowed(false)
                 setInputActionType(IME_ACTION_GO)
             }.build()