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

Commit 3075023d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix double divider in Apps & notifications page"

parents ff89b713 cfa36dba
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -113,7 +113,8 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
                }
            };

    private ViewGroup mPinnedHeaderFrameLayout;
    @VisibleForTesting
    ViewGroup mPinnedHeaderFrameLayout;
    private ViewGroup mButtonBar;

    private LayoutPreference mHeader;
@@ -186,6 +187,10 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
        mPinnedHeaderFrameLayout.setVisibility(View.VISIBLE);
    }

    public void showPinnedHeader(boolean show) {
        mPinnedHeaderFrameLayout.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
+4 −14
Original line number Diff line number Diff line
@@ -44,8 +44,6 @@ public class AppAndNotificationDashboardFragment extends DashboardFragment

    private static final String TAG = "AppAndNotifDashboard";

    private View mProgressHeader;
    private View mProgressAnimation;
    private RecentAppStatsMixin mRecentAppStatsMixin;
    private RecentAppsPreferenceController mRecentAppsPreferenceController;
    private AllAppsInfoPreferenceController mAllAppsInfoPreferenceController;
@@ -92,20 +90,19 @@ public class AppAndNotificationDashboardFragment extends DashboardFragment
    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mProgressHeader = setPinnedHeaderView(R.layout.progress_header);
        mProgressAnimation = mProgressHeader.findViewById(R.id.progress_bar_animation);
        setLoadingEnabled(false);
        setPinnedHeaderView(R.layout.progress_header);
        showPinnedHeader(false);
    }

    @Override
    public void onStart() {
        super.onStart();
        setLoadingEnabled(true);
        showPinnedHeader(true);
    }

    @Override
    public void onReloadDataCompleted(@NonNull List<UsageStats> recentApps) {
        setLoadingEnabled(false);
        showPinnedHeader(false);
        if (!recentApps.isEmpty()) {
            Utils.setActionBarShadowAnimation(getActivity(), getSettingsLifecycle(),
                    getListView());
@@ -117,13 +114,6 @@ public class AppAndNotificationDashboardFragment extends DashboardFragment
        return buildPreferenceControllers(context);
    }

    private void setLoadingEnabled(boolean enabled) {
        if (mProgressHeader != null && mProgressAnimation != null) {
            mProgressHeader.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
            mProgressAnimation.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
        }
    }

    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
        final List<AbstractPreferenceController> controllers = new ArrayList<>();
        controllers.add(new EmergencyBroadcastPreferenceController(context,
+19 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static org.mockito.Mockito.when;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;

import androidx.fragment.app.FragmentActivity;
import androidx.preference.Preference;
@@ -187,6 +188,24 @@ public class SettingsPreferenceFragmentTest {
        verify(workOnlyCategory).setVisible(false);
    }

    @Test
    public void showPinnedHeader_shouldBeVisible() {
        mFragment.mPinnedHeaderFrameLayout = new FrameLayout(mContext);

        mFragment.showPinnedHeader(true);

        assertThat(mFragment.mPinnedHeaderFrameLayout.getVisibility()).isEqualTo(View.VISIBLE);
    }

    @Test
    public void hidePinnedHeader_shouldBeInvisible() {
        mFragment.mPinnedHeaderFrameLayout = new FrameLayout(mContext);

        mFragment.showPinnedHeader(false);

        assertThat(mFragment.mPinnedHeaderFrameLayout.getVisibility()).isEqualTo(View.INVISIBLE);
    }

    public static class TestFragment extends SettingsPreferenceFragment {

        @Override