Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e7907220 authored by Stephen Bird's avatar Stephen Bird
Browse files

Fix nudge counts

Nudges were only showing when they were not supposed to.

Change-Id: I73ff46f5753c9a74cf42723f45a201398c537edf
Ticket: CD-570
parent 6167f428
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ public class DiscoveryEventHandler {

                            Bundle b = theEntry.getValue();

                            if (validateShouldShowNudge(key, b) && !isTesting) {
                            if (!validateShouldShowNudge(key, b) && !isTesting) {
                                // Nudge not yet ready for this item.
                                continue;
                            }
@@ -225,6 +225,13 @@ public class DiscoveryEventHandler {
        return PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_ONE_SHOT);
    }

    /**
     * Validates if a nudge should be shown.
     *
     * @param key the nudge key we're validating
     * @param b bundle with nudge data
     * @return true if the nudge is good to go, false if the nudge should not show.
     */
    private boolean validateShouldShowNudge(String key, Bundle b) {
        boolean checkCount;

@@ -240,9 +247,8 @@ public class DiscoveryEventHandler {
            count = preferences.getInt(CallMethodUtils.PREF_WIFI_CALL, 1);
        }

        checkCount =
                count == b.getInt(NudgeKey.NOTIFICATION_PARAM_EVENTS_FIRST_NUDGE, 0) ||
                count == b.getInt(NudgeKey.NOTIFICATION_PARAM_EVENTS_SECOND_NUDGE, 0);
        checkCount = (count == b.getInt(NudgeKey.NOTIFICATION_PARAM_EVENTS_FIRST_NUDGE, 0)) ||
                (count == b.getInt(NudgeKey.NOTIFICATION_PARAM_EVENTS_SECOND_NUDGE, 0));

        // return true if nudge should be shown
        return checkCount;