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.tv.settings.device.storage; 18 19 import android.os.Bundle; 20 import android.os.storage.StorageManager; 21 import android.os.storage.VolumeRecord; 22 import android.support.annotation.NonNull; 23 import android.support.v17.leanback.app.GuidedStepFragment; 24 import android.support.v17.leanback.widget.GuidanceStylist; 25 import android.support.v17.leanback.widget.GuidedAction; 26 27 import com.android.tv.settings.R; 28 29 import java.util.List; 30 31 public class ForgetPrivateConfirmFragment extends GuidedStepFragment { 32 33 private static final int ACTION_ID_FORGET = 1; 34 35 public static void prepareArgs(Bundle b, String fsUuid) { 36 b.putString(VolumeRecord.EXTRA_FS_UUID, fsUuid); 37 } 38 39 @Override 40 public @NonNull GuidanceStylist.Guidance onCreateGuidance(Bundle savedInstanceState) { 41 return new GuidanceStylist.Guidance( 42 getString(R.string.storage_wizard_forget_confirm_title), 43 getString(R.string.storage_wizard_forget_confirm_description), "", 44 getActivity().getDrawable(R.drawable.ic_warning_132dp)); 45 } 46 47 @Override 48 public void onCreateActions(@NonNull List<GuidedAction> actions, Bundle savedInstanceState) { 49 actions.add(new GuidedAction.Builder(getContext()) 50 .clickAction(GuidedAction.ACTION_ID_CANCEL) 51 .build()); 52 actions.add(new GuidedAction.Builder(getContext()) 53 .id(ACTION_ID_FORGET) 54 .title(getString(R.string.storage_wizard_forget_action)) 55 .build()); 56 } 57 58 @Override 59 public void onGuidedActionClicked(GuidedAction action) { 60 final long id = action.getId(); 61 62 if (id == GuidedAction.ACTION_ID_CANCEL) { 63 getFragmentManager().popBackStack(); 64 } else if (id == ACTION_ID_FORGET) { 65 getContext().getSystemService(StorageManager.class) 66 .forgetVolume(getArguments().getString(VolumeRecord.EXTRA_FS_UUID)); 67 getFragmentManager().popBackStack(); 68 } 69 } 70 } 71