Migrate more settings to use SubSettingsLauncher

Bug: 73250851
Test: robotests
Change-Id: I08f6f380489646231d6d8ceb1488e2efb036bf69
This commit is contained in:
Fan Zhang
2018-02-16 10:37:37 -08:00
parent 6f367a79ce
commit 7cf99f5f12
26 changed files with 260 additions and 197 deletions

View File

@@ -27,22 +27,21 @@ import android.widget.Button;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.password.ChooseLockSettingsHelper;
/* Class to prompt for conversion of userdata to file based encryption
*/
public class ConvertToFbe extends InstrumentedFragment {
static final String TAG = "ConvertToFBE";
static final String CONVERT_FBE_EXTRA = "ConvertFBE";
private static final int KEYGUARD_REQUEST = 55;
private boolean runKeyguardConfirmation(int request) {
Resources res = getActivity().getResources();
return new ChooseLockSettingsHelper(getActivity(), this)
.launchConfirmationActivity(request,
res.getText(R.string.convert_to_file_encryption));
.launchConfirmationActivity(request,
res.getText(R.string.convert_to_file_encryption));
}
@Override
@@ -53,15 +52,13 @@ public class ConvertToFbe extends InstrumentedFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.convert_fbe, null);
final Button button = (Button) rootView.findViewById(R.id.button_convert_fbe);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(!runKeyguardConfirmation(KEYGUARD_REQUEST)) {
convert();
}
final Button button = rootView.findViewById(R.id.button_convert_fbe);
button.setOnClickListener(v -> {
if (!runKeyguardConfirmation(KEYGUARD_REQUEST)) {
convert();
}
});
@@ -84,9 +81,11 @@ public class ConvertToFbe extends InstrumentedFragment {
}
private void convert() {
SettingsActivity sa = (SettingsActivity) getActivity();
sa.startPreferencePanel(this, ConfirmConvertToFbe.class.getName(), null,
R.string.convert_to_file_encryption, null, null, 0);
new SubSettingLauncher(getContext())
.setDestination(ConfirmConvertToFbe.class.getName())
.setTitle(R.string.convert_to_file_encryption)
.setSourceMetricsCategory(getMetricsCategory())
.launch();
}
@Override