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.app.ApplicationErrorReport; 22 import android.content.Intent; 23 import android.support.annotation.NonNull; 24 import android.util.Log; 25 import android.widget.Toast; 26 27 import com.android.tv.R; 28 import com.android.tv.TvApplication; 29 import com.android.tv.common.BuildConfig; 30 import com.android.tv.data.epg.EpgFetcher; 31 import com.android.tv.experiments.Experiments; 32 import com.android.tv.tuner.TunerPreferences; 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 getTitle()45 protected String getTitle() { 46 return getString(R.string.menu_developer_options); 47 } 48 49 @Override getTrackerLabel()50 public String getTrackerLabel() { 51 return TRACKER_LABEL; 52 } 53 54 @Override getItemList()55 protected List<Item> getItemList() { 56 List<Item> items = new ArrayList<>(); 57 if (BuildConfig.ENG) { 58 items.add(new ActionItem(getString(R.string.dev_item_watch_history)) { 59 @Override 60 protected void onSelected() { 61 getMainActivity().getOverlayManager().showRecentlyWatchedDialog(); 62 } 63 }); 64 } 65 items.add(new ActionItem(getString(R.string.dev_item_send_feedback)) { 66 @Override 67 protected void onSelected() { 68 Intent intent = new Intent(Intent.ACTION_APP_ERROR); 69 ApplicationErrorReport report = new ApplicationErrorReport(); 70 report.packageName = report.processName = getContext().getPackageName(); 71 report.time = System.currentTimeMillis(); 72 report.type = ApplicationErrorReport.TYPE_NONE; 73 intent.putExtra(Intent.EXTRA_BUG_REPORT, report); 74 startActivityForResult(intent, 0); 75 } 76 }); 77 items.add(new SwitchItem(getString(R.string.dev_item_store_ts_on), 78 getString(R.string.dev_item_store_ts_off), 79 getString(R.string.dev_item_store_ts_description)) { 80 @Override 81 protected void onUpdate() { 82 super.onUpdate(); 83 setChecked(TunerPreferences.getStoreTsStream(getContext())); 84 } 85 86 @Override 87 protected void onSelected() { 88 super.onSelected(); 89 TunerPreferences.setStoreTsStream(getContext(), isChecked()); 90 } 91 }); 92 return items; 93 } 94 95 96 /** True if there is the dev options menu */ shouldShow()97 public static boolean shouldShow() { 98 return Experiments.ENABLE_DEVELOPER_FEATURES.get() || BuildConfig.ENG; 99 } 100 101 } 102