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