• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
27 import com.android.tv.R;
28 import com.android.tv.TvApplication;
29 import com.android.tv.common.ui.setup.SetupActionHelper;
30 import com.android.tv.util.SetupUtils;
31 
32 /**
33  * A fragment for new channel source info/setup.
34  */
35 public 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 
NewSourcesFragment()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
onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)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 
initializeButton(View view, int actionId)71     private void initializeButton(View view, int actionId) {
72         view.setOnClickListener(SetupActionHelper.createOnClickListenerForAction(this,
73                 ACTION_CATEOGRY, actionId, null));
74     }
75 }
76