private ViewGroup mPinnedHeaderFrameLayout;
private FloatingActionButton mFloatingActionButton;
+ private ViewGroup mButtonBar;
@Override
public void onCreate(Bundle icicle) {
final View root = super.onCreateView(inflater, container, savedInstanceState);
mPinnedHeaderFrameLayout = (ViewGroup) root.findViewById(R.id.pinned_header);
mFloatingActionButton = (FloatingActionButton) root.findViewById(R.id.fab);
+ mButtonBar = (ViewGroup) root.findViewById(R.id.button_bar);
return root;
}
return mFloatingActionButton;
}
+ public ViewGroup getButtonBar() {
+ return mButtonBar;
+ }
+
public View setPinnedHeaderView(int layoutResId) {
final LayoutInflater inflater = getActivity().getLayoutInflater();
final View pinnedHeader =
import android.content.Context;
import android.content.Intent;
+import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.os.UserManager;
import android.text.TextUtils;
import android.text.format.Formatter;
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.util.Preconditions;
private StorageSummaryPreference mSummary;
private Preference mMount;
- private Preference mUnmount;
private Preference mFormatPublic;
private Preference mFormatPrivate;
+ private Button mUnmount;
private boolean mIsPermittedToAdopt;
mSummary = new StorageSummaryPreference(context);
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);
if (mIsPermittedToAdopt) {
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() {
if (!isVolumeValid()) {
getActivity().finish();
addPreference(mMount);
}
if (mVolume.isMountedReadable()) {
- addPreference(mUnmount);
+ getButtonBar().setVisibility(View.VISIBLE);
}
addPreference(mFormatPublic);
if (mDisk.isAdoptable() && mIsPermittedToAdopt) {
final Context context = getActivity();
if (pref == mMount) {
new MountTask(context, mVolume).execute();
- } else if (pref == mUnmount) {
- new UnmountTask(context, mVolume).execute();
} else if (pref == mFormatPublic) {
final Intent intent = new Intent(context, StorageWizardFormatConfirm.class);
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
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() {
@Override
public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {