Remove getCategoryKey() from DashboardFragment children.
Use the centralized registry to look up category key instead. Bug: 32936784 Test: make RunSettingsRoboTests -j40 Change-Id: I0b8c72d70f93e4b5c58871ac90de41f69ad15653
This commit is contained in:
@@ -194,7 +194,10 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
||||
/**
|
||||
* Returns the CategoryKey for loading {@link DashboardCategory} for this fragment.
|
||||
*/
|
||||
protected abstract String getCategoryKey();
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
public String getCategoryKey() {
|
||||
return DashboardFragmentRegistry.PARENT_TO_CATEGORY_KEY_MAP.get(getClass().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tag string for logging.
|
||||
@@ -302,9 +305,9 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
||||
final Context context = getContext();
|
||||
mSummaryLoader = new SummaryLoader(getActivity(), getCategoryKey());
|
||||
mSummaryLoader.setSummaryConsumer(this);
|
||||
final TypedArray a = context.obtainStyledAttributes(new int[] {
|
||||
mDashboardFeatureProvider.isEnabled() ? android.R.attr.colorControlNormal
|
||||
: android.R.attr.colorAccent});
|
||||
final TypedArray a = context.obtainStyledAttributes(new int[]{
|
||||
mDashboardFeatureProvider.isEnabled() ? android.R.attr.colorControlNormal
|
||||
: android.R.attr.colorAccent});
|
||||
final int tintColor = a.getColor(0, context.getColor(android.R.color.white));
|
||||
a.recycle();
|
||||
final String pkgName = context.getPackageName();
|
||||
@@ -319,7 +322,7 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
||||
continue;
|
||||
}
|
||||
if (pkgName != null && tile.intent != null
|
||||
&& !pkgName.equals(tile.intent.getComponent().getPackageName())) {
|
||||
&& !pkgName.equals(tile.intent.getComponent().getPackageName())) {
|
||||
// If this drawable is coming from outside Settings, tint it to match the color.
|
||||
tile.icon.setTint(tintColor);
|
||||
}
|
||||
|
||||
@@ -21,13 +21,16 @@ import android.util.ArrayMap;
|
||||
import com.android.settings.DevelopmentSettings;
|
||||
import com.android.settings.DisplaySettings;
|
||||
import com.android.settings.SecuritySettings;
|
||||
import com.android.settings.accounts.AccountDetailDashboardFragment;
|
||||
import com.android.settings.accounts.UserAndAccountDashboardFragment;
|
||||
import com.android.settings.applications.AdvancedAppSettings;
|
||||
import com.android.settings.applications.AppAndNotificationDashboardFragment;
|
||||
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
|
||||
import com.android.settings.deviceinfo.StorageDashboardFragment;
|
||||
import com.android.settings.fuelgauge.PowerUsageSummary;
|
||||
import com.android.settings.inputmethod.InputAndGestureSettings;
|
||||
import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
|
||||
import com.android.settings.language.LanguageAndRegionSettings;
|
||||
import com.android.settings.network.NetworkDashboardFragment;
|
||||
import com.android.settings.notification.SoundSettings;
|
||||
import com.android.settings.system.SystemDashboardFragment;
|
||||
@@ -37,7 +40,6 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* A registry to keep track of which page hosts which category.
|
||||
* TODO: Remove DashboardFragment#getCategoryKey() and just use this registry instead.
|
||||
*/
|
||||
public class DashboardFragmentRegistry {
|
||||
|
||||
@@ -61,6 +63,8 @@ public class DashboardFragmentRegistry {
|
||||
CategoryKey.CATEGORY_DEVICE);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(AppAndNotificationDashboardFragment.class.getName(),
|
||||
CategoryKey.CATEGORY_APPS);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(PowerUsageSummary.class.getName(),
|
||||
CategoryKey.CATEGORY_BATTERY);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(AdvancedAppSettings.class.getName(),
|
||||
CategoryKey.CATEGORY_APPS_DEFAULT);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(DisplaySettings.class.getName(),
|
||||
@@ -71,7 +75,7 @@ public class DashboardFragmentRegistry {
|
||||
CategoryKey.CATEGORY_STORAGE);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(SecuritySettings.class.getName(),
|
||||
CategoryKey.CATEGORY_SECURITY);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(UserAndAccountDashboardFragment.class.getName(),
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(AccountDetailDashboardFragment.class.getName(),
|
||||
CategoryKey.CATEGORY_ACCOUNT);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(UserAndAccountDashboardFragment.class.getName(),
|
||||
CategoryKey.CATEGORY_ACCOUNT);
|
||||
@@ -81,6 +85,8 @@ public class DashboardFragmentRegistry {
|
||||
InputAndGestureSettings.class.getName(), CategoryKey.CATEGORY_SYSTEM_INPUT);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(InputMethodAndLanguageSettings.class.getName(),
|
||||
CategoryKey.CATEGORY_SYSTEM_LANGUAGE);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(LanguageAndRegionSettings.class.getName(),
|
||||
CategoryKey.CATEGORY_SYSTEM_LANGUAGE);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(DevelopmentSettings.class.getName(),
|
||||
CategoryKey.CATEGORY_SYSTEM_DEVELOPMENT);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user