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.usbtuner.setup; 18 19 import android.os.Bundle; 20 import android.support.annotation.NonNull; 21 import android.support.v17.leanback.widget.GuidanceStylist.Guidance; 22 import android.support.v17.leanback.widget.GuidedAction; 23 24 import com.android.tv.common.ui.setup.SetupGuidedStepFragment; 25 import com.android.tv.common.ui.setup.SetupMultiPaneFragment; 26 import com.android.usbtuner.R; 27 28 import java.util.List; 29 import java.util.TimeZone; 30 31 /** 32 * A fragment for connection type selection. 33 */ 34 public class ConnectionTypeFragment extends SetupMultiPaneFragment { 35 public static final String ACTION_CATEGORY = 36 "com.android.usbtuner.setup.ConnectionTypeFragment"; 37 38 @Override onCreateContentFragment()39 protected SetupGuidedStepFragment onCreateContentFragment() { 40 return new ContentFragment(); 41 } 42 43 @Override getActionCategory()44 protected String getActionCategory() { 45 return ACTION_CATEGORY; 46 } 47 48 @Override needsDoneButton()49 protected boolean needsDoneButton() { 50 return false; 51 } 52 53 public static class ContentFragment extends SetupGuidedStepFragment { 54 55 @NonNull 56 @Override onCreateGuidance(Bundle savedInstanceState)57 public Guidance onCreateGuidance(Bundle savedInstanceState) { 58 return new Guidance(getString(R.string.ut_connection_title), 59 getString(R.string.ut_connection_description), 60 getString(R.string.ut_setup_breadcrumb), null); 61 } 62 63 @Override onCreateActions(@onNull List<GuidedAction> actions, Bundle savedInstanceState)64 public void onCreateActions(@NonNull List<GuidedAction> actions, 65 Bundle savedInstanceState) { 66 String[] choices = getResources().getStringArray(R.array.ut_connection_choices); 67 int length = choices.length - 1; 68 int startOffset = 0; 69 for (int i = 0; i < length; ++i) { 70 actions.add(new GuidedAction.Builder(getActivity()) 71 .id(startOffset + i) 72 .title(choices[i]) 73 .build()); 74 } 75 } 76 77 @Override getActionCategory()78 protected String getActionCategory() { 79 return ACTION_CATEGORY; 80 } 81 } 82 } 83