Home | History | Annotate | Download | only in sidepanel
      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 
     25 import com.android.tv.R;
     26 import com.android.tv.TvApplication;
     27 import com.android.tv.common.BuildConfig;
     28 import com.android.tv.common.feature.CommonFeatures;
     29 import com.android.tv.data.epg.EpgFetcher;
     30 import com.android.tv.experiments.Experiments;
     31 import com.android.tv.tuner.TunerPreferences;
     32 import com.android.tv.util.Utils;
     33 
     34 import java.util.ArrayList;
     35 import java.util.List;
     36 
     37 /**
     38  * Options for developers only
     39  */
     40 public class DeveloperOptionFragment extends SideFragment {
     41     private static final String TAG = "DeveloperOptionFragment";
     42     private static final String TRACKER_LABEL = "debug options";
     43 
     44     @Override
     45     protected String getTitle() {
     46         return getString(R.string.menu_developer_options);
     47     }
     48 
     49     @Override
     50     public String getTrackerLabel() {
     51         return TRACKER_LABEL;
     52     }
     53 
     54     @Override
     55     protected List<Item> getItemList() {
     56         List<Item> items = new ArrayList<>();
     57         if (CommonFeatures.DVR.isEnabled(getContext())) {
     58             items.add(new ActionItem(getString(R.string.dev_item_dvr_history)) {
     59                 @Override
     60                 protected void onSelected() {
     61                     getMainActivity().getOverlayManager().showDvrHistoryDialog();
     62                 }
     63             });
     64         }
     65         if (Utils.isDeveloper()) {
     66             items.add(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(new SwitchItem(getString(R.string.dev_item_store_ts_on),
     74                 getString(R.string.dev_item_store_ts_off),
     75                 getString(R.string.dev_item_store_ts_description)) {
     76             @Override
     77             protected void onUpdate() {
     78                 super.onUpdate();
     79                 setChecked(TunerPreferences.getStoreTsStream(getContext()));
     80             }
     81 
     82             @Override
     83             protected void onSelected() {
     84                 super.onSelected();
     85                 TunerPreferences.setStoreTsStream(getContext(), isChecked());
     86             }
     87         });
     88         if (Utils.isDeveloper()) {
     89             items.add(
     90                     new ActionItem(getString(R.string.dev_item_show_performance_monitor_log)) {
     91                         @Override
     92                         protected void onSelected() {
     93                             TvApplication.getSingletons(getContext())
     94                                     .getPerformanceMonitor()
     95                                     .startPerformanceMonitorEventDebugActivity(getContext());
     96                         }
     97                     });
     98         }
     99         return items;
    100     }
    101 
    102 }