From 0d345e5e0479f3b254dfc072b31f8cc3f4832629 Mon Sep 17 00:00:00 2001 From: Anushree Ganjam Date: Thu, 19 May 2022 23:07:06 +0000 Subject: [PATCH] Add "incrementEventCountBy" function to OnboardingPrefs. This will help to increment the count by a value rather than just by 1. Bug: 231659198 Test: Manual Change-Id: I180ab3bd622df3bee2a6cb2b0cd8793e07a4f114 --- .../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); + } }