diff options
author | Christofer Ã…kersten <akersten@google.com> | 2014-07-22 17:45:58 +0900 |
---|---|---|
committer | Christofer Ã…kersten <akersten@google.com> | 2014-07-28 16:18:18 +0900 |
commit | 8e3442aa16192119629b1eafd9e63091157413b3 (patch) | |
tree | bbf90f456a1c5716cf478ab15d2a60580eff9b5d /src/com/android/tv | |
parent | 566736d0b5ab334cdebb289c5b251710d1d4ad09 (diff) | |
download | TV-8e3442aa16192119629b1eafd9e63091157413b3.tar.gz |
Add TV input selection in the Debug menu.
Bug: 16355902
Change-Id: I6783cbc3220a08d5adcf30ef6f00db7ce3b237f2
Diffstat (limited to 'src/com/android/tv')
-rw-r--r-- | src/com/android/tv/TvActivity.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/com/android/tv/TvActivity.java b/src/com/android/tv/TvActivity.java index 98efdcf0..04d13da8 100644 --- a/src/com/android/tv/TvActivity.java +++ b/src/com/android/tv/TvActivity.java @@ -83,6 +83,8 @@ import com.android.tv.util.TvSettings; import com.android.tv.util.Utils; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.HashSet; import java.util.List; @@ -565,6 +567,12 @@ public class TvActivity extends Activity implements AudioManager.OnAudioFocusCha @Override protected List<Item> buildItems() { List<Item> items = new ArrayList<>(); + items.add(new SubMenuItem(getString(R.string.item_tv_input), getFragmentManager()) { + @Override + protected List<Item> buildItems() { + return getTvInputMenu(); + } + }); items.add(new ActionItem(getString(R.string.item_watch_history)) { @Override protected void onSelected() { @@ -574,6 +582,64 @@ public class TvActivity extends Activity implements AudioManager.OnAudioFocusCha }); return items; } + + private List<Item> getTvInputMenu() { + ArrayList<Item> items = new ArrayList<>(); + + items.add(new TvInputItem( + new UnifiedTvInput(mTvInputManagerHelper, getActivity()))); + + mTvInputManagerHelper.update(); + List<TvInputInfo> infos = new ArrayList<>( + mTvInputManagerHelper.getTvInputInfos(false)); + Collections.sort(infos, new Comparator<TvInputInfo>() { + @Override + public int compare(TvInputInfo lhs, TvInputInfo rhs) { + String a = Utils.getDisplayNameForInput(getActivity(), lhs); + String b = Utils.getDisplayNameForInput(getActivity(), rhs); + return a.compareTo(b); + } + }); + for (TvInputInfo inputInfo : infos) { + if (inputInfo.getType() == TvInputInfo.TYPE_TUNER) { + items.add(new TvInputItem( + new TisTvInput(mTvInputManagerHelper, inputInfo, getActivity()))); + } + } + + TvInput selected = getSelectedTvInput(); + if (selected == null) { + ((TvInputItem) items.get(0)).setChecked(true); + } else { + for (Item item : items) { + if (((TvInputItem) item).getTvInput().equals(selected)) { + ((TvInputItem) item).setChecked(true); + break; + } + } + } + + return items; + } + + class TvInputItem extends RadioButtonItem { + private TvInput mTvInput; + + private TvInputItem(TvInput tvInput) { + super(tvInput.getDisplayName()); + mTvInput = tvInput; + } + + public TvInput getTvInput() { + return mTvInput; + } + + @Override + protected void onSelected() { + super.onSelected(); + onInputPicked(mTvInput); + } + } }, initiator); } |