1 /* 2 * Copyright (C) 2016 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.packageinstaller.television; 18 19 import android.app.Activity; 20 import android.os.Bundle; 21 import android.support.v17.leanback.app.GuidedStepFragment; 22 import android.support.v17.leanback.widget.GuidanceStylist; 23 import android.support.v17.leanback.widget.GuidedAction; 24 25 import com.android.packageinstaller.R; 26 import com.android.packageinstaller.UninstallerActivity; 27 28 import java.util.List; 29 30 public class ErrorFragment extends GuidedStepFragment { 31 public static final String TITLE = "com.android.packageinstaller.arg.title"; 32 public static final String TEXT = "com.android.packageinstaller.arg.text"; 33 34 @Override 35 public int onProvideTheme() { 36 return R.style.Theme_Leanback_GuidedStep; 37 } 38 39 @Override 40 public GuidanceStylist.Guidance onCreateGuidance(Bundle savedInstanceState) { 41 return new GuidanceStylist.Guidance( 42 getString(getArguments().getInt(TITLE)), 43 getString(getArguments().getInt(TEXT)), 44 null, 45 null); 46 } 47 48 @Override 49 public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) { 50 actions.add(new GuidedAction.Builder(getContext()) 51 .clickAction(GuidedAction.ACTION_ID_OK) 52 .build()); 53 } 54 55 @Override 56 public void onGuidedActionClicked(GuidedAction action) { 57 if (isAdded()) { 58 if (getActivity() instanceof UninstallerActivity) { 59 ((UninstallerActivity) getActivity()).dispatchAborted(); 60 } 61 62 getActivity().setResult(Activity.RESULT_FIRST_USER); 63 getActivity().finish(); 64 } 65 } 66 } 67