1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings.deviceinfo; 18 19 import static android.os.storage.DiskInfo.EXTRA_DISK_ID; 20 21 import static com.android.settings.deviceinfo.StorageWizardBase.EXTRA_FORMAT_FORGET_UUID; 22 import static com.android.settings.deviceinfo.StorageWizardBase.EXTRA_FORMAT_PRIVATE; 23 24 import android.app.settings.SettingsEnums; 25 import android.content.Intent; 26 import android.os.Bundle; 27 import android.os.storage.DiskInfo; 28 import android.os.storage.StorageManager; 29 import android.os.storage.VolumeInfo; 30 import android.text.TextUtils; 31 import android.view.LayoutInflater; 32 import android.view.View; 33 import android.view.View.OnClickListener; 34 import android.view.ViewGroup; 35 import android.widget.Button; 36 import android.widget.TextView; 37 38 import com.android.settings.R; 39 import com.android.settings.core.InstrumentedFragment; 40 41 public class PrivateVolumeFormat extends InstrumentedFragment { 42 private VolumeInfo mVolume; 43 private DiskInfo mDisk; 44 45 @Override getMetricsCategory()46 public int getMetricsCategory() { 47 return SettingsEnums.DEVICEINFO_STORAGE; 48 } 49 50 @Override onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)51 public View onCreateView(LayoutInflater inflater, ViewGroup container, 52 Bundle savedInstanceState) { 53 final StorageManager storage = getActivity().getSystemService(StorageManager.class); 54 final String volumeId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID); 55 mVolume = storage.findVolumeById(volumeId); 56 mDisk = storage.findDiskById(mVolume.getDiskId()); 57 58 final View view = inflater.inflate(R.layout.storage_internal_format, container, false); 59 final TextView body = (TextView) view.findViewById(R.id.body); 60 final Button confirm = (Button) view.findViewById(R.id.confirm); 61 62 body.setText(TextUtils.expandTemplate(getText(R.string.storage_internal_format_details), 63 mDisk.getDescription())); 64 confirm.setOnClickListener(mConfirmListener); 65 66 return view; 67 } 68 69 private final OnClickListener mConfirmListener = new OnClickListener() { 70 @Override 71 public void onClick(View v) { 72 final Intent intent = new Intent(getActivity(), StorageWizardFormatProgress.class); 73 intent.putExtra(EXTRA_DISK_ID, mDisk.getId()); 74 intent.putExtra(EXTRA_FORMAT_PRIVATE, false); 75 intent.putExtra(EXTRA_FORMAT_FORGET_UUID, mVolume.getFsUuid()); 76 startActivity(intent); 77 getActivity().finish(); 78 } 79 }; 80 } 81