From 13b3922af9f042726729844ceed9f4ec653f548e Mon Sep 17 00:00:00 2001 From: Anushree Ganjam Date: Tue, 24 May 2022 02:19:57 +0000 Subject: [PATCH] Revert "Revert "Add "incrementEventCountBy" function to Onboardi..." Revert submission 18568158-revert-18500283-dismissEduCard-SCFTOPONPS Reason for revert: b/233680944 , This is a build merger issue. Reverted Changes: Ia39781c78:Revert "Add "incrementEventCountBy" function to On... Ibba14f7c2:Revert "Save the value to sharedPreference When ed... Change-Id: I1c0e4be10cf7e9b21623a056604618cbea2639d4 --- .../android/launcher3/util/OnboardingPrefs.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/com/android/launcher3/util/OnboardingPrefs.java b/src/com/android/launcher3/util/OnboardingPrefs.java index c1e4fa889c..64aeceb359 100644 --- a/src/com/android/launcher3/util/OnboardingPrefs.java +++ b/src/com/android/launcher3/util/OnboardingPrefs.java @@ -140,4 +140,19 @@ public class OnboardingPrefs { mSharedPrefs.edit().putInt(eventKey, count).apply(); return hasReachedMaxCount(count, eventKey); } + + /** + * Add "incCountBy" to the given event count, if we haven't already reached the max count. + * + * @return Whether we have now reached the max count. + */ + public boolean incrementEventCountBy(int incCountBy, @EventCountKey String eventKey) { + int count = getCount(eventKey); + if (hasReachedMaxCount(count, eventKey)) { + return true; + } + count += incCountBy; + mSharedPrefs.edit().putInt(eventKey, count).apply(); + return hasReachedMaxCount(count, eventKey); + } }