NewSourcesFragment.java revision 919e1ed7e914029a1a0054237d86dc7b19ced898
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 17package com.android.tv.onboarding; 18 19import android.app.Fragment; 20import android.os.Bundle; 21import android.transition.Slide; 22import android.view.Gravity; 23import android.view.LayoutInflater; 24import android.view.View; 25import android.view.ViewGroup; 26 27import com.android.tv.R; 28import com.android.tv.TvApplication; 29import com.android.tv.common.ui.setup.SetupActionHelper; 30import com.android.tv.util.SetupUtils; 31 32/** 33 * A fragment for new channel source info/setup. 34 */ 35public class NewSourcesFragment extends Fragment { 36 /** 37 * The action category. 38 */ 39 public static final String ACTION_CATEOGRY = 40 "com.android.tv.onboarding.NewSourcesFragment"; 41 /** 42 * An action to show the setup screen. 43 */ 44 public static final int ACTION_SETUP = 1; 45 /** 46 * An action to close this fragment. 47 */ 48 public static final int ACTION_SKIP = 2; 49 50 public NewSourcesFragment() { 51 setAllowEnterTransitionOverlap(false); 52 setAllowReturnTransitionOverlap(false); 53 setEnterTransition(new Slide(Gravity.BOTTOM)); 54 setExitTransition(new Slide(Gravity.BOTTOM)); 55 setReenterTransition(new Slide(Gravity.BOTTOM)); 56 setReturnTransition(new Slide(Gravity.BOTTOM)); 57 } 58 59 @Override 60 public View onCreateView(LayoutInflater inflater, ViewGroup container, 61 Bundle savedInstanceState) { 62 View view = inflater.inflate(R.layout.fragment_new_sources, container, false); 63 initializeButton(view.findViewById(R.id.setup), ACTION_SETUP); 64 initializeButton(view.findViewById(R.id.skip), ACTION_SKIP); 65 SetupUtils.getInstance(getActivity()).markAllInputsRecognized(TvApplication 66 .getSingletons(getActivity()).getTvInputManagerHelper()); 67 view.requestFocus(); 68 return view; 69 } 70 71 private void initializeButton(View view, int actionId) { 72 view.setOnClickListener(SetupActionHelper.createOnClickListenerForAction(this, 73 ACTION_CATEOGRY, actionId, null)); 74 } 75} 76