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), null)); 45 mRows.put(HEADER_ID, mRow); 46 } 47 48 @Override 49 public void refreshContent() { 50 init(); 51 } 52 53 void init() { 54 mRow.clear(); 55 56 mRow.add(new MenuItem.Builder().id(mNextItemId++) 57 .title(mContext.getString(R.string.device_daydream)) 58 .imageResourceId(mContext, R.drawable.ic_settings_daydream) 59 .intent(getIntent(SettingsConstant.PACKAGE, 60 SettingsConstant.PACKAGE + ".device.display.daydream.DaydreamActivity")) 61 .build()); 62 63 if (WIFI_DISPLAY_SUPPORTED) { 64 mRow.add(new MenuItem.Builder().id(mNextItemId++) 65 .title(mContext.getString(R.string.accessories_wifi_display)) 66 .imageResourceId(mContext, R.drawable.ic_settings_widi) 67 .intent(getIntent(SettingsConstant.PACKAGE, 68 SettingsConstant.PACKAGE + ".device.display.widi.WifiDisplayActivity")) 69 .build()); 70 } 71 72 mRow.add(new MenuItem.Builder().id(mNextItemId++) 73 .title(mContext.getString(R.string.device_calibration)) 74 .imageResourceId(mContext, R.drawable.ic_settings_overscan) 75 .intent(new Intent("com.google.android.athome.overscan.CALIBRATE")).build()); 76 } 77 78 private Intent getIntent(String targetPackage, String targetClass) { 79 ComponentName componentName = new ComponentName(targetPackage, targetClass); 80 Intent i = new Intent(); 81 i.setComponent(componentName); 82 return i; 83 } 84 } 85