1 /* 2 * Copyright (C) 2018 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.dvr.ui; 18 19 import android.app.Activity; 20 import android.content.res.Resources; 21 import android.os.Bundle; 22 import android.support.v17.leanback.widget.GuidanceStylist; 23 import android.support.v17.leanback.widget.GuidedAction; 24 25 import com.android.tv.R; 26 27 import java.util.List; 28 29 /** 30 * A fragment which shows the rationale when requesting android.permission.WRITE_EXTERNAL_STORAGE. 31 */ 32 public class DvrWriteStoragePermissionRationaleFragment extends DvrGuidedStepFragment { 33 @Override onCreateGuidance(Bundle savedInstanceState)34 public GuidanceStylist.Guidance onCreateGuidance(Bundle savedInstanceState) { 35 Resources res = getContext().getResources(); 36 String title = res.getString(R.string.write_storage_permission_rationale_title); 37 String description = res.getString(R.string.write_storage_permission_rationale_description); 38 return new GuidanceStylist.Guidance(title, description, null, null); 39 } 40 41 @Override onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState)42 public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) { 43 Activity activity = getActivity(); 44 actions.add( 45 new GuidedAction.Builder(activity) 46 .id(GuidedAction.ACTION_ID_OK) 47 .title(android.R.string.ok) 48 .build()); 49 } 50 51 @Override onTrackedGuidedActionClicked(GuidedAction action)52 public void onTrackedGuidedActionClicked(GuidedAction action) { 53 dismissDialog(); 54 } 55 56 @Override getTrackerPrefix()57 public String getTrackerPrefix() { 58 return "DvrWriteStoragePermissionRationaleFragment"; 59 } 60 } 61