Merge "Add "incrementEventCountBy" function to OnboardingPrefs." into tm-dev am: 218703d5a9 am: bfc82b027e

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/18500283

Change-Id: I4017a49fc4ca802e668cc057735d1e033b3a7527
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Anushree Ganjam
2022-05-24 01:21:40 +00:00
committed by Automerger Merge Worker
@@ -140,4 +140,19 @@ public class OnboardingPrefs<T extends ActivityContext> {
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);
}
}