Changes default value of NotificationCompat.Action.mAllowGeneratedReplies
Changes the default from false to true and adds tests for same
Bug:31935223
Fixes:31935223
Test: Wrote and ran new tests for behavior
Change-Id: Iee3c512b943dc8650bc7b6a214d6db49d82dd229
diff --git a/compat/java/android/support/v4/app/NotificationCompat.java b/compat/java/android/support/v4/app/NotificationCompat.java
index 49bbf9a..82e51e0 100644
--- a/compat/java/android/support/v4/app/NotificationCompat.java
+++ b/compat/java/android/support/v4/app/NotificationCompat.java
@@ -2417,7 +2417,7 @@
public static class Action extends NotificationCompatBase.Action {
final Bundle mExtras;
private final RemoteInput[] mRemoteInputs;
- private boolean mAllowGeneratedReplies = false;
+ private boolean mAllowGeneratedReplies;
/**
* Small icon representing the action.
@@ -2434,7 +2434,7 @@
public PendingIntent actionIntent;
public Action(int icon, CharSequence title, PendingIntent intent) {
- this(icon, title, intent, new Bundle(), null, false);
+ this(icon, title, intent, new Bundle(), null, true);
}
Action(int icon, CharSequence title, PendingIntent intent, Bundle extras,
@@ -2495,7 +2495,7 @@
private final int mIcon;
private final CharSequence mTitle;
private final PendingIntent mIntent;
- private boolean mAllowGeneratedReplies;
+ private boolean mAllowGeneratedReplies = true;
private final Bundle mExtras;
private ArrayList<RemoteInput> mRemoteInputs;
@@ -2506,7 +2506,7 @@
* @param intent the {@link PendingIntent} to fire when users trigger this action
*/
public Builder(int icon, CharSequence title, PendingIntent intent) {
- this(icon, title, intent, new Bundle(), null, false);
+ this(icon, title, intent, new Bundle(), null, true);
}
/**
@@ -2575,7 +2575,7 @@
* @param allowGeneratedReplies {@code true} to allow generated replies, {@code false}
* otherwise
* @return this object for method chaining
- * The default value is {@code false}
+ * The default value is {@code true}
*/
public Builder setAllowGeneratedReplies(boolean allowGeneratedReplies) {
mAllowGeneratedReplies = allowGeneratedReplies;
diff --git a/compat/tests/java/android/support/v4/app/NotificationCompatTest.java b/compat/tests/java/android/support/v4/app/NotificationCompatTest.java
index 12b3ab0..19ab555 100644
--- a/compat/tests/java/android/support/v4/app/NotificationCompatTest.java
+++ b/compat/tests/java/android/support/v4/app/NotificationCompatTest.java
@@ -11,18 +11,22 @@
* 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
+ * limitations under the License.
*/
package android.support.v4.app;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
-import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
@RunWith(AndroidJUnit4.class)
public class NotificationCompatTest {
@@ -49,7 +53,32 @@
assertEquals(a.getAllowGeneratedReplies(), aCopy.getAllowGeneratedReplies());
}
+ @SmallTest
+ @Test
+ public void testNotificationActionBuilder_defaultAllowGeneratedRepliesTrue() throws Throwable {
+ NotificationCompat.Action a = newActionBuilder().build();
+
+ assertTrue(a.getAllowGeneratedReplies());
+ }
+
+ @SmallTest
+ @Test
+ public void testNotificationAction_defaultAllowGeneratedRepliesTrue() throws Throwable {
+ NotificationCompat.Action a = new NotificationCompat.Action(0, null, null);
+
+ assertTrue(a.getAllowGeneratedReplies());
+ }
+
+ @SmallTest
+ @Test
+ public void testNotificationActionBuilder_setAllowGeneratedRepliesFalse() throws Throwable {
+ NotificationCompat.Action a = newActionBuilder()
+ .setAllowGeneratedReplies(false).build();
+
+ assertFalse(a.getAllowGeneratedReplies());
+ }
+
private NotificationCompat.Action.Builder newActionBuilder() {
return new NotificationCompat.Action.Builder(0, "title", null);
}
-}
\ No newline at end of file
+}