Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use device defaults for notification features #283

Merged
merged 1 commit into from
Apr 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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