165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane/* 265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Copyright (C) 2014 The Android Open Source Project 365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * 465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Licensed under the Apache License, Version 2.0 (the "License"); 565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * you may not use this file except in compliance with the License. 665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * You may obtain a copy of the License at 765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * 865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * http://www.apache.org/licenses/LICENSE-2.0 965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * 1065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Unless required by applicable law or agreed to in writing, software 1165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * distributed under the License is distributed on an "AS IS" BASIS, 1265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * See the License for the specific language governing permissions and 1465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * limitations under the License. 1565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane */ 1665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 1765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lanepackage com.android.tv.settings.device.display; 1865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 1965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.content.ComponentName; 2065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.content.Context; 2165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.content.Intent; 2265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.support.v17.leanback.widget.ArrayObjectAdapter; 2365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport android.support.v17.leanback.widget.HeaderItem; 2465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 2565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport com.android.tv.settings.BrowseInfoBase; 2665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport com.android.tv.settings.MenuItem; 2765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport com.android.tv.settings.R; 2865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Laneimport com.android.tv.settings.SettingsConstant; 2965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 3065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane/** 3165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane * Gets the list of browse headers and browse items. 3265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane */ 3365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lanepublic class DisplayBrowseInfo extends BrowseInfoBase { 3465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 3565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private static final boolean WIFI_DISPLAY_SUPPORTED = false; 3665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private static final int HEADER_ID = 1; 3765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private final Context mContext; 3865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private final ArrayObjectAdapter mRow = new ArrayObjectAdapter(); 3965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private int mNextItemId; 4065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 4165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane DisplayBrowseInfo(Context context) { 4265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mContext = context; 4365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mNextItemId = 0; 4465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mHeaderItems.add(new HeaderItem(HEADER_ID, mContext.getString(R.string.device_display), null)); 4565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mRows.put(HEADER_ID, mRow); 4665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 4765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 4865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane @Override 4965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane public void refreshContent() { 5065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane init(); 5165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 5265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 5365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane void init() { 5465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mRow.clear(); 5565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 5665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mRow.add(new MenuItem.Builder().id(mNextItemId++) 5765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane .title(mContext.getString(R.string.device_daydream)) 5865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane .imageResourceId(mContext, R.drawable.ic_settings_daydream) 5965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane .intent(getIntent(SettingsConstant.PACKAGE, 6065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane SettingsConstant.PACKAGE + ".device.display.daydream.DaydreamActivity")) 6165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane .build()); 6265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 6365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane if (WIFI_DISPLAY_SUPPORTED) { 6465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mRow.add(new MenuItem.Builder().id(mNextItemId++) 6565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane .title(mContext.getString(R.string.accessories_wifi_display)) 6665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane .imageResourceId(mContext, R.drawable.ic_settings_widi) 6765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane .intent(getIntent(SettingsConstant.PACKAGE, 6865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane SettingsConstant.PACKAGE + ".device.display.widi.WifiDisplayActivity")) 6965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane .build()); 7065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 7165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 7265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane mRow.add(new MenuItem.Builder().id(mNextItemId++) 7365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane .title(mContext.getString(R.string.device_calibration)) 7465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane .imageResourceId(mContext, R.drawable.ic_settings_overscan) 7565a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane .intent(new Intent("com.google.android.athome.overscan.CALIBRATE")).build()); 7665a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 7765a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane 7865a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane private Intent getIntent(String targetPackage, String targetClass) { 7965a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane ComponentName componentName = new ComponentName(targetPackage, targetClass); 8065a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane Intent i = new Intent(); 8165a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane i.setComponent(componentName); 8265a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane return i; 8365a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane } 8465a5a7d84ad9b5324ae53eda526e39e513473af7Christopher Lane} 85