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

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

Merge "Fix null pointer in dashboard fragment test."

parents 1c6f9de1 fd83b2eb
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -299,15 +299,15 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
        if (mSummaryLoader != null) {
            mSummaryLoader.release();
        }
        final Activity activity = getActivity();
        mSummaryLoader = new SummaryLoader(activity, getCategoryKey());
        final Context context = getContext();
        mSummaryLoader = new SummaryLoader(getActivity(), getCategoryKey());
        mSummaryLoader.setSummaryConsumer(this);
        final TypedArray a = activity.obtainStyledAttributes(new int[] {
        final TypedArray a = context.obtainStyledAttributes(new int[] {
            mDashboardFeatureProvider.isEnabled() ? android.R.attr.colorControlNormal
                : android.R.attr.colorAccent});
        final int tintColor = a.getColor(0, activity.getColor(android.R.color.white));
        final int tintColor = a.getColor(0, context.getColor(android.R.color.white));
        a.recycle();
        final String pkgName = activity.getPackageName();
        final String pkgName = context.getPackageName();
        // Install dashboard tiles.
        for (Tile tile : tiles) {
            final String key = mDashboardFeatureProvider.getDashboardKeyForTile(tile);
@@ -318,7 +318,8 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
            if (!displayTile(tile)) {
                continue;
            }
            if (!pkgName.equals(tile.intent.getComponent().getPackageName())) {
            if (pkgName != null && tile.intent != null
                && !pkgName.equals(tile.intent.getComponent().getPackageName())) {
                // If this drawable is coming from outside Settings, tint it to match the color.
                tile.icon.setTint(tintColor);
            }
@@ -326,12 +327,12 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
                // Have the key already, will rebind.
                final Preference preference = mProgressiveDisclosureMixin.findPreference(
                        screen, key);
                mDashboardFeatureProvider.bindPreferenceToTile(activity, preference, tile, key,
                mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), preference, tile, key,
                        mPlaceholderPreferenceController.getOrder());
            } else {
                // Don't have this key, add it.
                final Preference pref = new Preference(getPrefContext());
                mDashboardFeatureProvider.bindPreferenceToTile(activity, pref, tile, key,
                mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), pref, tile, key,
                        mPlaceholderPreferenceController.getOrder());
                mProgressiveDisclosureMixin.addPreference(screen, pref);
                mDashboardTilePrefKeys.add(key);
+1 −0
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ public class DashboardFragmentTest {
        when(mFakeFeatureFactory.dashboardFeatureProvider.getTilesForCategory(anyString()))
                .thenReturn(mDashboardCategory);
        mTestFragment.onAttach(ShadowApplication.getInstance().getApplicationContext());
        when(mContext.getPackageName()).thenReturn("TestPackage");
    }

    @Test