@@ -69,8 +69,8 @@ public class GCMMessageService extends GcmListenerService {
6969 private static final String PUSH_TYPE_PUSH_AUTH = "push_auth" ;
7070
7171 // Add to the analytics properties map a subset of the push notification payload.
72- private static String [] propertiesToCopyIntoAnalytics = { PUSH_ARG_NOTE_ID , PUSH_ARG_TYPE , "blog_id" , "post_id" ,
73- "comment_id" };
72+ private static String [] propertiesToCopyIntoAnalytics = {PUSH_ARG_NOTE_ID , PUSH_ARG_TYPE , "blog_id" , "post_id" ,
73+ "comment_id" };
7474
7575 private void synchronizedHandleDefaultPush (String from , @ NonNull Bundle data ) {
7676 // sActiveNotificationsMap being static, we can't just synchronize the method
@@ -295,9 +295,16 @@ private void showNotificationForBuilder(NotificationCompat.Builder builder, Cont
295295 boolean shouldPlaySound = prefs .getBoolean ("wp_pref_notification_sound" , false );
296296 boolean shouldVibrate = prefs .getBoolean ("wp_pref_notification_vibrate" , false );
297297 boolean shouldBlinkLight = prefs .getBoolean ("wp_pref_notification_light" , false );
298- if (shouldPlaySound ) {
299- builder .setSound (Uri .parse ("android.resource://" + getPackageName () + "/" + R .raw .notification ));
298+ String notificationSound = prefs .getString ("wp_pref_custom_notification_sound" , null ); //"" if None is selected
299+
300+
301+ // use default sound if the legacy sound preference was ON but the custom sound was not selected (null)
302+ if (shouldPlaySound && notificationSound == null ) {
303+ builder .setSound (Uri .parse ("content://settings/system/notification_sound" ));
304+ } else if (!TextUtils .isEmpty (notificationSound )) {
305+ builder .setSound (Uri .parse (notificationSound ));
300306 }
307+
301308 if (shouldVibrate ) {
302309 builder .setVibrate (new long []{500 , 500 , 500 });
303310 }
@@ -475,7 +482,7 @@ public static synchronized void bumpPushNotificationsTappedAllAnalytics() {
475482 }
476483
477484 private static void bumpPushNotificationsAnalytics (Stat stat , Bundle noteBundle ,
478- Map <String , Object > properties ) {
485+ Map <String , Object > properties ) {
479486 // Bump Analytics for PNs if "Show notifications" setting is checked (default). Skip otherwise.
480487 if (!NotificationsUtils .isNotificationsEnabled (WordPress .getContext ())) {
481488 return ;
@@ -486,9 +493,9 @@ private static void bumpPushNotificationsAnalytics(Stat stat, Bundle noteBundle,
486493
487494 String notificationID = noteBundle .getString (PUSH_ARG_NOTE_ID , "" );
488495 if (!TextUtils .isEmpty (notificationID )) {
489- for (String currentPropertyToCopy : propertiesToCopyIntoAnalytics ) {
496+ for (String currentPropertyToCopy : propertiesToCopyIntoAnalytics ) {
490497 if (noteBundle .containsKey (currentPropertyToCopy )) {
491- properties .put ("push_notification_" + currentPropertyToCopy , noteBundle .get (currentPropertyToCopy ));
498+ properties .put ("push_notification_" + currentPropertyToCopy , noteBundle .get (currentPropertyToCopy ));
492499 }
493500 }
494501 SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences (WordPress .getContext ());
0 commit comments