Home | History | Annotate | Download | only in accessories
      1 /*
      2  * Copyright (C) 2014 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.settings.accessories;
     18 
     19 import android.app.Fragment;
     20 import android.os.Bundle;
     21 import android.view.LayoutInflater;
     22 import android.view.View;
     23 import android.view.ViewGroup;
     24 import android.widget.TextView;
     25 
     26 import com.android.tv.settings.R;
     27 import com.android.tv.settings.util.AccessibilityHelper;
     28 
     29 /**
     30  * Custom Content Fragment for the Bluetooth settings activity.
     31  */
     32 public class AddAccessoryContentFragment extends Fragment {
     33 
     34     public View mView;
     35     private boolean mMultiple;
     36 
     37     public static AddAccessoryContentFragment newInstance(boolean multiple) {
     38         AddAccessoryContentFragment fragment = new AddAccessoryContentFragment(multiple);
     39         return fragment;
     40     }
     41 
     42     public AddAccessoryContentFragment(boolean multiple) {
     43         super();
     44         mMultiple = multiple;
     45     }
     46 
     47     @Override
     48     public View onCreateView(LayoutInflater inflater, ViewGroup container,
     49             Bundle savedInstanceState) {
     50         mView = inflater.inflate(mMultiple ? R.layout.add_accessory_multiple_content_fragment :
     51                 R.layout.add_accessory_content_fragment, container, false);
     52 
     53         // Enable focusability of text views if accessibility is enabled.
     54         if (AccessibilityHelper.forceFocusableViews(getActivity())) {
     55             TextView title = (TextView) mView.findViewById(
     56                     mMultiple ? R.id.multiple_title : R.id.title);
     57             if (title != null) {
     58                 title.setFocusable(true);
     59                 title.setFocusableInTouchMode(true);
     60             }
     61             TextView instructions = (TextView) mView.findViewById(
     62                     mMultiple ? R.id.multiple_instructions : R.id.bluetooth_instructions);
     63             if (instructions != null) {
     64                 instructions.setFocusable(true);
     65                 instructions.setFocusableInTouchMode(true);
     66             }
     67             TextView autopair = (TextView) mView.findViewById(
     68                     mMultiple ? R.id.select_instructions : R.id.autopair_message);
     69             if (autopair != null) {
     70                 autopair.setFocusable(true);
     71                 autopair.setFocusableInTouchMode(true);
     72             }
     73         }
     74         return mView;
     75     }
     76 }
     77