Turn the eject menu into a button.
BUG=21897892 Change-Id: Icd0db7907b990447c99c4ae65816e85777df0f8e
This commit is contained in:
@@ -249,4 +249,7 @@
|
|||||||
|
|
||||||
<dimen name="shortcut_size">40dp</dimen>
|
<dimen name="shortcut_size">40dp</dimen>
|
||||||
<dimen name="badge_size">10dp</dimen>
|
<dimen name="badge_size">10dp</dimen>
|
||||||
|
|
||||||
|
<!-- Button bar padding for unmount button. -->
|
||||||
|
<dimen name="unmount_button_padding">8dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -83,6 +83,7 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
|||||||
|
|
||||||
private ViewGroup mPinnedHeaderFrameLayout;
|
private ViewGroup mPinnedHeaderFrameLayout;
|
||||||
private FloatingActionButton mFloatingActionButton;
|
private FloatingActionButton mFloatingActionButton;
|
||||||
|
private ViewGroup mButtonBar;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
@@ -105,6 +106,7 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
|||||||
final View root = super.onCreateView(inflater, container, savedInstanceState);
|
final View root = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
mPinnedHeaderFrameLayout = (ViewGroup) root.findViewById(R.id.pinned_header);
|
mPinnedHeaderFrameLayout = (ViewGroup) root.findViewById(R.id.pinned_header);
|
||||||
mFloatingActionButton = (FloatingActionButton) root.findViewById(R.id.fab);
|
mFloatingActionButton = (FloatingActionButton) root.findViewById(R.id.fab);
|
||||||
|
mButtonBar = (ViewGroup) root.findViewById(R.id.button_bar);
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,6 +114,10 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
|||||||
return mFloatingActionButton;
|
return mFloatingActionButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ViewGroup getButtonBar() {
|
||||||
|
return mButtonBar;
|
||||||
|
}
|
||||||
|
|
||||||
public View setPinnedHeaderView(int layoutResId) {
|
public View setPinnedHeaderView(int layoutResId) {
|
||||||
final LayoutInflater inflater = getActivity().getLayoutInflater();
|
final LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
final View pinnedHeader =
|
final View pinnedHeader =
|
||||||
|
@@ -18,6 +18,7 @@ package com.android.settings.deviceinfo;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
@@ -32,6 +33,9 @@ import android.provider.DocumentsContract;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.text.format.Formatter.BytesResult;
|
import android.text.format.Formatter.BytesResult;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.internal.util.Preconditions;
|
import com.android.internal.util.Preconditions;
|
||||||
@@ -59,9 +63,9 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
private StorageSummaryPreference mSummary;
|
private StorageSummaryPreference mSummary;
|
||||||
|
|
||||||
private Preference mMount;
|
private Preference mMount;
|
||||||
private Preference mUnmount;
|
|
||||||
private Preference mFormatPublic;
|
private Preference mFormatPublic;
|
||||||
private Preference mFormatPrivate;
|
private Preference mFormatPrivate;
|
||||||
|
private Button mUnmount;
|
||||||
|
|
||||||
private boolean mIsPermittedToAdopt;
|
private boolean mIsPermittedToAdopt;
|
||||||
|
|
||||||
@@ -111,13 +115,29 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
mSummary = new StorageSummaryPreference(context);
|
mSummary = new StorageSummaryPreference(context);
|
||||||
|
|
||||||
mMount = buildAction(R.string.storage_menu_mount);
|
mMount = buildAction(R.string.storage_menu_mount);
|
||||||
mUnmount = buildAction(R.string.storage_menu_unmount);
|
mUnmount = new Button(getActivity());
|
||||||
|
mUnmount.setText(R.string.storage_menu_unmount);
|
||||||
|
mUnmount.setOnClickListener(mUnmountListener);
|
||||||
mFormatPublic = buildAction(R.string.storage_menu_format);
|
mFormatPublic = buildAction(R.string.storage_menu_format);
|
||||||
if (mIsPermittedToAdopt) {
|
if (mIsPermittedToAdopt) {
|
||||||
mFormatPrivate = buildAction(R.string.storage_menu_format_private);
|
mFormatPrivate = buildAction(R.string.storage_menu_format_private);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
final Resources resources = getResources();
|
||||||
|
final int padding = resources.getDimensionPixelSize(
|
||||||
|
R.dimen.unmount_button_padding);
|
||||||
|
final ViewGroup buttonBar = getButtonBar();
|
||||||
|
buttonBar.removeAllViews();
|
||||||
|
buttonBar.setPadding(padding, padding, padding, padding);
|
||||||
|
buttonBar.addView(mUnmount, new ViewGroup.LayoutParams(
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
if (!isVolumeValid()) {
|
if (!isVolumeValid()) {
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
@@ -151,7 +171,7 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
addPreference(mMount);
|
addPreference(mMount);
|
||||||
}
|
}
|
||||||
if (mVolume.isMountedReadable()) {
|
if (mVolume.isMountedReadable()) {
|
||||||
addPreference(mUnmount);
|
getButtonBar().setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
addPreference(mFormatPublic);
|
addPreference(mFormatPublic);
|
||||||
if (mDisk.isAdoptable() && mIsPermittedToAdopt) {
|
if (mDisk.isAdoptable() && mIsPermittedToAdopt) {
|
||||||
@@ -196,8 +216,6 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
final Context context = getActivity();
|
final Context context = getActivity();
|
||||||
if (pref == mMount) {
|
if (pref == mMount) {
|
||||||
new MountTask(context, mVolume).execute();
|
new MountTask(context, mVolume).execute();
|
||||||
} else if (pref == mUnmount) {
|
|
||||||
new UnmountTask(context, mVolume).execute();
|
|
||||||
} else if (pref == mFormatPublic) {
|
} else if (pref == mFormatPublic) {
|
||||||
final Intent intent = new Intent(context, StorageWizardFormatConfirm.class);
|
final Intent intent = new Intent(context, StorageWizardFormatConfirm.class);
|
||||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
@@ -213,6 +231,13 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
return super.onPreferenceTreeClick(preferenceScreen, pref);
|
return super.onPreferenceTreeClick(preferenceScreen, pref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final View.OnClickListener mUnmountListener = new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
new UnmountTask(getActivity(), mVolume).execute();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private final StorageEventListener mStorageListener = new StorageEventListener() {
|
private final StorageEventListener mStorageListener = new StorageEventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
|
public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
|
||||||
|
Reference in New Issue
Block a user