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

Commit 730a573d authored by Kevin Han's avatar Kevin Han
Browse files

Update "Unused apps" load-in UI

Update the UI for the "Unused apps" preference to update with the loaded
number of unused apps instead of having the entire preference animate
in.

Bug: 187996287
Test: manual
Test: atest HibernatedAppsPreferenceControllerTest
Change-Id: I1c6998de4daaf4d8678a3ffdaf83f5d2417fa68d
parent 35e1f0d1
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ public final class HibernatedAppsPreferenceController extends BasePreferenceCont
    private PreferenceScreen mScreen;
    private int mUnusedCount = 0;
    private boolean mLoadingUnusedApps;
    private boolean mLoadedUnusedCount;
    private final Executor mBackgroundExecutor;
    private final Executor mMainExecutor;

@@ -79,14 +80,15 @@ public final class HibernatedAppsPreferenceController extends BasePreferenceCont

    @Override
    public int getAvailabilityStatus() {
        return isHibernationEnabled() && mUnusedCount > 0
                ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
        return isHibernationEnabled() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
    }

    @Override
    public CharSequence getSummary() {
        return mContext.getResources().getQuantityString(
                R.plurals.unused_apps_summary, mUnusedCount, mUnusedCount);
        return mLoadedUnusedCount
                ? mContext.getResources().getQuantityString(
                        R.plurals.unused_apps_summary, mUnusedCount, mUnusedCount)
                : mContext.getResources().getString(R.string.summary_placeholder);
    }

    @Override
@@ -111,8 +113,8 @@ public final class HibernatedAppsPreferenceController extends BasePreferenceCont
            loadUnusedCount(unusedCount -> {
                mUnusedCount = unusedCount;
                mLoadingUnusedApps = false;
                mLoadedUnusedCount = true;
                mMainExecutor.execute(() -> {
                    super.displayPreference(mScreen);
                    Preference pref = mScreen.findPreference(mPreferenceKey);
                    refreshSummary(pref);
                });