• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package com.android.tv.ui.sidepanel;
18 
19 import android.accounts.Account;
20 import android.app.Activity;
21 import android.support.annotation.NonNull;
22 import android.util.Log;
23 import android.widget.Toast;
24 import com.android.tv.R;
25 import com.android.tv.TvSingletons;
26 import com.android.tv.common.CommonPreferences;
27 import com.android.tv.common.feature.CommonFeatures;
28 import com.android.tv.common.util.CommonUtils;
29 
30 
31 
32 
33 
34 import java.util.ArrayList;
35 import java.util.List;
36 
37 /** Options for developers only */
38 public class DeveloperOptionFragment extends SideFragment {
39     private static final String TAG = "DeveloperOptionFragment";
40     private static final String TRACKER_LABEL = "debug options";
41 
42     @Override
getTitle()43     protected String getTitle() {
44         return getString(R.string.menu_developer_options);
45     }
46 
47     @Override
getTrackerLabel()48     public String getTrackerLabel() {
49         return TRACKER_LABEL;
50     }
51 
52     @Override
getItemList()53     protected List<Item> getItemList() {
54         List<Item> items = new ArrayList<>();
55         if (CommonFeatures.DVR.isEnabled(getContext())) {
56             items.add(
57                     new ActionItem(getString(R.string.dev_item_dvr_history)) {
58                         @Override
59                         protected void onSelected() {
60                             getMainActivity().getOverlayManager().showDvrHistoryDialog();
61                         }
62                     });
63         }
64         if (CommonUtils.isDeveloper()) {
65             items.add(
66                     new ActionItem(getString(R.string.dev_item_watch_history)) {
67                         @Override
68                         protected void onSelected() {
69                             getMainActivity().getOverlayManager().showRecentlyWatchedDialog();
70                         }
71                     });
72         }
73         items.add(
74                 new SwitchItem(
75                         getString(R.string.dev_item_store_ts_on),
76                         getString(R.string.dev_item_store_ts_off),
77                         getString(R.string.dev_item_store_ts_description)) {
78                     @Override
79                     protected void onUpdate() {
80                         super.onUpdate();
81                         setChecked(CommonPreferences.getStoreTsStream(getContext()));
82                     }
83 
84                     @Override
85                     protected void onSelected() {
86                         super.onSelected();
87                         CommonPreferences.setStoreTsStream(getContext(), isChecked());
88                     }
89                 });
90         if (CommonUtils.isDeveloper()) {
91             items.add(
92                     new ActionItem(getString(R.string.dev_item_show_performance_monitor_log)) {
93                         @Override
94                         protected void onSelected() {
95                             TvSingletons.getSingletons(getContext())
96                                     .getPerformanceMonitor()
97                                     .startPerformanceMonitorEventDebugActivity(getContext());
98                         }
99                     });
100         }
101         return items;
102     }
103 }
104