Migrate to DashboardFragment in ToggleFeaturePreferenceFragment
Root Cause: ToggleFeaturePrefreferenceFragment becomes heavy when more and more features come in. Solution: Mirgrate to DashboardFragment, a plugin-style preference controllers, can help us separate the preference and its logic into its own controller. * This is the first step for the whole migration. Change to extend DashboardFragment and fill up the missing override functions. * Reorder fields and functions to the recommended general approach. Bug: 171272809 Test: make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.accessibility Change-Id: I852091700a4b3b3c7bbdbc82f0b5dc47c087d61c
This commit is contained in:
@@ -49,9 +49,11 @@ import java.util.List;
|
||||
|
||||
/** Fragment for providing open activity button. */
|
||||
public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeaturePreferenceFragment {
|
||||
private static final String TAG = "LaunchA11yActivity";
|
||||
|
||||
private static final String TAG = "LaunchAccessibilityActivityPreferenceFragment";
|
||||
private static final String EMPTY_STRING = "";
|
||||
protected static final String KEY_LAUNCH_PREFERENCE = "launch_preference";
|
||||
|
||||
private ComponentName mTileComponentName;
|
||||
|
||||
@Override
|
||||
@@ -70,10 +72,10 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
// Init new preference to replace the switch preference instead.
|
||||
initLaunchPreference();
|
||||
|
||||
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
removePreference(KEY_USE_SERVICE_PREFERENCE);
|
||||
return view;
|
||||
}
|
||||
@@ -173,6 +175,7 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
|
||||
/** Customizes the order by preference key. */
|
||||
protected List<String> getPreferenceOrderList() {
|
||||
final List<String> lists = new ArrayList<>();
|
||||
lists.add(KEY_TOP_INTRO_PREFERENCE);
|
||||
lists.add(KEY_ANIMATED_IMAGE);
|
||||
lists.add(KEY_LAUNCH_PREFERENCE);
|
||||
lists.add(KEY_GENERAL_CATEGORY);
|
||||
@@ -230,4 +233,15 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
|
||||
|
||||
return settingsIntent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
// TODO(b/171272809): Add back when controllers move to static type
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user