Skip to content

Commit

Permalink
configurable defaults for notification features
Browse files Browse the repository at this point in the history
  • Loading branch information
Grayson Wendell committed Feb 8, 2016
1 parent c7c747f commit a9be5bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/main/java/com/mixpanel/android/mpmetrics/GCMReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/com/mixpanel/android/mpmetrics/MPConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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"
);
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a9be5bd

Please sign in to comment.