Revamp SD card UX
Improve the SD card setup flow so that each formatting option is provided in a separate screen with clear description and illustration.Also make sure that guest users do not have any access to formatting options. Test: Manual testing on Pixel Device Screenshot1: https://screenshot.googleplex.com/WJwyxFkBtbSfZmN.png Screenshot2: https://screenshot.googleplex.com/3oBcrrgRsKTxNPC.png Bug: 201252175 Change-Id: I77df55c40fd99cabcfc6128084be035bb5b19531 Change-Id: I757abc6076fcc8f467d8faed9f090bcdd5774ff3
This commit is contained in:
@@ -18,21 +18,27 @@ package com.android.settings.deviceinfo;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserManager;
|
||||
import android.os.storage.DiskInfo;
|
||||
import android.os.storage.VolumeInfo;
|
||||
import android.text.Html;
|
||||
import android.text.Spannable;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.TypefaceSpan;
|
||||
import android.text.style.URLSpan;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ViewFlipper;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
public class StorageWizardInit extends StorageWizardBase {
|
||||
private Button mInternal;
|
||||
|
||||
private boolean mIsPermittedToAdopt;
|
||||
private boolean mPortable;
|
||||
|
||||
private ViewFlipper mFlipper;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -41,63 +47,119 @@ public class StorageWizardInit extends StorageWizardBase {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
setContentView(R.layout.storage_wizard_init);
|
||||
|
||||
mIsPermittedToAdopt = UserManager.get(this).isAdminUser()
|
||||
&& !ActivityManager.isUserAMonkey();
|
||||
&& !ActivityManager.isUserAMonkey();
|
||||
|
||||
setHeaderText(R.string.storage_wizard_init_v2_title, getDiskShortDescription());
|
||||
if (!mIsPermittedToAdopt) {
|
||||
//Notify guest users as to why formatting is disallowed
|
||||
Toast.makeText(getApplicationContext(),
|
||||
R.string.storage_wizard_guest, Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
mInternal = requireViewById(R.id.storage_wizard_init_internal);
|
||||
setContentView(R.layout.storage_wizard_init);
|
||||
setupHyperlink();
|
||||
mPortable = true;
|
||||
|
||||
setBackButtonText(R.string.storage_wizard_init_v2_later);
|
||||
setNextButtonVisibility(View.INVISIBLE);
|
||||
mFlipper = (ViewFlipper) findViewById(R.id.viewFlipper);
|
||||
mFlipper.setDisplayedChild(0);
|
||||
setHeaderText(R.string.storage_wizard_init_v2_external_title,
|
||||
getDiskShortDescription());
|
||||
|
||||
setNextButtonText(R.string.storage_wizard_init_v2_external_action);
|
||||
setBackButtonText(R.string.wizard_back_adoptable);
|
||||
setNextButtonVisibility(View.VISIBLE);
|
||||
if (!mDisk.isAdoptable()) {
|
||||
// If not adoptable, we only have one choice
|
||||
mInternal.setEnabled(false);
|
||||
onNavigateExternal(null);
|
||||
} else if (!mIsPermittedToAdopt) {
|
||||
// TODO: Show a message about why this is disabled for guest and
|
||||
// that only an admin user can adopt an sd card.
|
||||
mInternal.setEnabled(false);
|
||||
setBackButtonVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigateBack(View view) {
|
||||
finish();
|
||||
public void onBackPressed() {
|
||||
if (mPortable) {
|
||||
super.onBackPressed();
|
||||
} else {
|
||||
mFlipper.showPrevious();
|
||||
setBackButtonText(R.string.wizard_back_adoptable);
|
||||
setHeaderText(R.string.storage_wizard_init_v2_external_title,
|
||||
getDiskShortDescription());
|
||||
setNextButtonText(R.string.storage_wizard_init_v2_external_action);
|
||||
mPortable = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigateBack(View v) {
|
||||
if (mPortable == false) {
|
||||
return;
|
||||
}
|
||||
if (!mIsPermittedToAdopt) {
|
||||
// TODO: Show a message about why this is disabled for guest and
|
||||
// that only an admin user can adopt an sd card.
|
||||
|
||||
v.setEnabled(false);
|
||||
} else {
|
||||
mFlipper.showNext();
|
||||
setHeaderText(R.string.storage_wizard_init_v2_internal_title,
|
||||
getDiskShortDescription());
|
||||
setNextButtonText(R.string.storage_wizard_init_v2_internal_action);
|
||||
setBackButtonVisibility(View.INVISIBLE);
|
||||
mPortable = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigateNext(View v) {
|
||||
if (mPortable) {
|
||||
onNavigateExternal(v);
|
||||
} else {
|
||||
onNavigateInternal(v);
|
||||
}
|
||||
}
|
||||
|
||||
public void onNavigateExternal(View view) {
|
||||
if (view != null) {
|
||||
// User made an explicit choice for external
|
||||
FeatureFactory.getFactory(this).getMetricsFeatureProvider().action(this,
|
||||
SettingsEnums.ACTION_STORAGE_INIT_EXTERNAL);
|
||||
}
|
||||
|
||||
if (mVolume != null && mVolume.getType() == VolumeInfo.TYPE_PUBLIC
|
||||
&& mVolume.getState() != VolumeInfo.STATE_UNMOUNTABLE) {
|
||||
// Remember that user made decision
|
||||
mStorage.setVolumeInited(mVolume.getFsUuid(), true);
|
||||
|
||||
final Intent intent = new Intent(this, StorageWizardReady.class);
|
||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
||||
} else {
|
||||
// Gotta format to get there
|
||||
StorageWizardFormatConfirm.showPublic(this, mDisk.getId());
|
||||
SettingsEnums.ACTION_STORAGE_INIT_EXTERNAL);
|
||||
}
|
||||
StorageWizardFormatConfirm.showPublic(this, mDisk.getId());
|
||||
}
|
||||
|
||||
public void onNavigateInternal(View view) {
|
||||
if (view != null) {
|
||||
// User made an explicit choice for internal
|
||||
FeatureFactory.getFactory(this).getMetricsFeatureProvider().action(this,
|
||||
SettingsEnums.ACTION_STORAGE_INIT_INTERNAL);
|
||||
SettingsEnums.ACTION_STORAGE_INIT_INTERNAL);
|
||||
}
|
||||
|
||||
StorageWizardFormatConfirm.showPrivate(this, mDisk.getId());
|
||||
}
|
||||
|
||||
private void setupHyperlink() {
|
||||
TextView external_storage_textview = findViewById(R.id.storage_wizard_init_external_text);
|
||||
TextView internal_storage_textview = findViewById(R.id.storage_wizard_init_internal_text);
|
||||
String external_storage_text = getResources().getString(R.string.
|
||||
storage_wizard_init_v2_external_summary);
|
||||
String internal_storage_text = getResources().getString(R.string.
|
||||
storage_wizard_init_v2_internal_summary);
|
||||
|
||||
Spannable external_storage_spannable = styleFont(external_storage_text);
|
||||
Spannable internal_storage_spannable = styleFont(internal_storage_text);
|
||||
external_storage_textview.setText(external_storage_spannable);
|
||||
internal_storage_textview.setText(internal_storage_spannable);
|
||||
|
||||
external_storage_textview.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
internal_storage_textview.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
|
||||
private Spannable styleFont(String text) {
|
||||
Spannable s = (Spannable) Html.fromHtml(text);
|
||||
for (URLSpan span : s.getSpans(0, s.length(), URLSpan.class)) {
|
||||
TypefaceSpan typefaceSpan = new TypefaceSpan("sans-serif-medium");
|
||||
s.setSpan(typefaceSpan, s.getSpanStart(span), s.getSpanEnd(span), 0);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user