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