Home | History | Annotate | Download | only in display
      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.device.display;
     18 
     19 import android.content.ComponentName;
     20 import android.content.Context;
     21 import android.content.Intent;
     22 import android.support.v17.leanback.widget.ArrayObjectAdapter;
     23 import android.support.v17.leanback.widget.HeaderItem;
     24 
     25 import com.android.tv.settings.BrowseInfoBase;
     26 import com.android.tv.settings.MenuItem;
     27 import com.android.tv.settings.R;
     28 import com.android.tv.settings.SettingsConstant;
     29 
     30 /**
     31  * Gets the list of browse headers and browse items.
     32  */
     33 public class DisplayBrowseInfo extends BrowseInfoBase {
     34 
     35     private static final boolean WIFI_DISPLAY_SUPPORTED = false;
     36     private static final int HEADER_ID = 1;
     37     private final Context mContext;
     38     private final ArrayObjectAdapter mRow = new ArrayObjectAdapter();
     39     private int mNextItemId;
     40 
     41     DisplayBrowseInfo(Context context) {
     42         mContext = context;
     43         mNextItemId = 0;
     44         mHeaderItems.add(new HeaderItem(HEADER_ID, mContext.getString(R.string.device_display)));
     45         mRows.put(HEADER_ID, mRow);
     46     }
     47 
     48     void init() {
     49         mRow.clear();
     50 
     51         mRow.add(new MenuItem.Builder().id(mNextItemId++)
     52                 .title(mContext.getString(R.string.device_daydream))
     53                 .imageResourceId(mContext, R.drawable.ic_settings_daydream)
     54                 .intent(getIntent(SettingsConstant.PACKAGE,
     55                         SettingsConstant.PACKAGE + ".device.display.daydream.DaydreamActivity"))
     56                 .build());
     57 
     58         if (WIFI_DISPLAY_SUPPORTED) {
     59             mRow.add(new MenuItem.Builder().id(mNextItemId++)
     60                     .title(mContext.getString(R.string.accessories_wifi_display))
     61                     .imageResourceId(mContext, R.drawable.ic_settings_widi)
     62                     .intent(getIntent(SettingsConstant.PACKAGE,
     63                             SettingsConstant.PACKAGE + ".device.display.widi.WifiDisplayActivity"))
     64                     .build());
     65         }
     66 
     67         mRow.add(new MenuItem.Builder().id(mNextItemId++)
     68                 .title(mContext.getString(R.string.device_calibration))
     69                 .imageResourceId(mContext, R.drawable.ic_settings_overscan)
     70                 .intent(new Intent("com.google.android.athome.overscan.CALIBRATE")).build());
     71     }
     72 
     73     private Intent getIntent(String targetPackage, String targetClass) {
     74         ComponentName componentName = new ComponentName(targetPackage, targetClass);
     75         Intent i = new Intent();
     76         i.setComponent(componentName);
     77         return i;
     78     }
     79 }
     80