From a9be5bdc68a47453ac9fe4cbb47b97230151636c Mon Sep 17 00:00:00 2001 From: Grayson Wendell Date: Mon, 8 Feb 2016 11:30:33 -0800 Subject: [PATCH] configurable defaults for notification features --- .../java/com/mixpanel/android/mpmetrics/GCMReceiver.java | 9 ++++++--- .../java/com/mixpanel/android/mpmetrics/MPConfig.java | 9 ++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/mixpanel/android/mpmetrics/GCMReceiver.java b/src/main/java/com/mixpanel/android/mpmetrics/GCMReceiver.java index 262e35f53..dfc7e77bd 100644 --- a/src/main/java/com/mixpanel/android/mpmetrics/GCMReceiver.java +++ b/src/main/java/com/mixpanel/android/mpmetrics/GCMReceiver.java @@ -263,7 +263,8 @@ private Notification makeNotificationSDKLessThan11(Context context, PendingInten setWhen(System.currentTimeMillis()). setContentTitle(notificationData.title). setContentText(notificationData.message). - setContentIntent(intent); + setContentIntent(intent). + setDefaults(MPConfig.getInstance(context).getNotificationDefaults()); final Notification n = builder.getNotification(); n.flags |= Notification.FLAG_AUTO_CANCEL; return n; @@ -278,7 +279,8 @@ private Notification makeNotificationSDK11OrHigher(Context context, PendingInten setWhen(System.currentTimeMillis()). setContentTitle(notificationData.title). setContentText(notificationData.message). - setContentIntent(intent); + setContentIntent(intent). + setDefaults(MPConfig.getInstance(context).getNotificationDefaults()); final Notification n = builder.getNotification(); n.flags |= Notification.FLAG_AUTO_CANCEL; @@ -295,7 +297,8 @@ private Notification makeNotificationSDK16OrHigher(Context context, PendingInten setContentTitle(notificationData.title). setContentText(notificationData.message). setContentIntent(intent). - setStyle(new Notification.BigTextStyle().bigText(notificationData.message)); + setStyle(new Notification.BigTextStyle().bigText(notificationData.message)). + setDefaults(MPConfig.getInstance(context).getNotificationDefaults()); final Notification n = builder.build(); n.flags |= Notification.FLAG_AUTO_CANCEL; diff --git a/src/main/java/com/mixpanel/android/mpmetrics/MPConfig.java b/src/main/java/com/mixpanel/android/mpmetrics/MPConfig.java index 61c17d9ea..bfdadbe01 100644 --- a/src/main/java/com/mixpanel/android/mpmetrics/MPConfig.java +++ b/src/main/java/com/mixpanel/android/mpmetrics/MPConfig.java @@ -178,6 +178,7 @@ public synchronized void setSSLSocketFactory(SSLSocketFactory factory) { mDisableAppOpenEvent = metaData.getBoolean("com.mixpanel.android.MPConfig.DisableAppOpenEvent", true); mDisableViewCrawler = metaData.getBoolean("com.mixpanel.android.MPConfig.DisableViewCrawler", false); mDisableDecideChecker = metaData.getBoolean("com.mixpanel.android.MPConfig.DisableDecideChecker", false); + mNotificationDefaults = metaData.getInt("com.mixpanel.android.MPConfig.NotificationDefaults", 0); // Disable if EITHER of these is present and false, otherwise enable final boolean surveysAutoCheck = metaData.getBoolean("com.mixpanel.android.MPConfig.AutoCheckForSurveys", true); @@ -250,7 +251,8 @@ public synchronized void setSSLSocketFactory(SSLSocketFactory factory) { " PeopleFallbackEndpoint " + getPeopleFallbackEndpoint() + "\n" + " DecideFallbackEndpoint " + getDecideFallbackEndpoint() + "\n" + " EditorUrl " + getEditorUrl() + "\n" + - " DisableDecideChecker " + getDisableDecideChecker() + "\n" + " DisableDecideChecker " + getDisableDecideChecker() + "\n" + + " NotificationDefaults " + getNotificationDefaults() + "\n" ); } } @@ -349,6 +351,10 @@ public boolean getDisableDecideChecker() { return mDisableDecideChecker; } + public int getNotificationDefaults() { + return mNotificationDefaults; + } + // Pre-configured package name for resources, if they differ from the application package name // // mContext.getPackageName() actually returns the "application id", which @@ -408,6 +414,7 @@ public synchronized SSLSocketFactory getSSLSocketFactory() { private final String mEditorUrl; private final String mResourcePackageName; private final boolean mDisableDecideChecker; + private final int mNotificationDefaults; // Mutable, with synchronized accessor and mutator private SSLSocketFactory mSSLSocketFactory;