Add PrefController in XML support
Add the ability to define a Preference Controller in xml using the 'controller' tag. This is useful for two reasons: - It allows the controllers to be instantiated via reflection for Slices and Dashboard fragment - Removes the requirement that controllers be defined manually in Fragments In order to be instantiable, they must have a unified construction following either: ClassName(Context) ClassName(Context, String) Also added a robotest that verifies that all controllers defined in XML follow the constructor schema, and extend BasePreferenceController. Test: robotests Bug: 67996923 Change-Id: I304b35dc666daebecf0c9e286696f3f2a510704a
This commit is contained in:
@@ -22,31 +22,29 @@ import android.os.UserManager;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
public class BackupSettingsActivityPreferenceController extends
|
||||
AbstractPreferenceController implements PreferenceControllerMixin {
|
||||
public class BackupSettingsActivityPreferenceController extends BasePreferenceController {
|
||||
private static final String TAG = "BackupSettingActivityPC";
|
||||
|
||||
private static final String KEY_BACKUP_SETTINGS = "backup_settings";
|
||||
private static final String TAG = "BackupSettingActivityPC" ;
|
||||
|
||||
private final UserManager mUm;
|
||||
private final BackupManager mBackupManager;
|
||||
|
||||
public BackupSettingsActivityPreferenceController(Context context) {
|
||||
super(context);
|
||||
super(context, KEY_BACKUP_SETTINGS);
|
||||
mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
mBackupManager = new BackupManager(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return mUm.isAdminUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_BACKUP_SETTINGS;
|
||||
public int getAvailabilityStatus() {
|
||||
return mUm.isAdminUser()
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,4 +55,4 @@ public class BackupSettingsActivityPreferenceController extends
|
||||
? R.string.accessibility_feature_state_on
|
||||
: R.string.accessibility_feature_state_off);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user