diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-10-05 07:30:20 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-10-05 07:30:20 +0000 |
commit | bb2e798ef4d546dd54cd9e95796403062b860c15 (patch) | |
tree | d31e2adc1f9cce4f27ca07d30bee921032e33a3c /src/com/android/tv/TvOptionsManager.java | |
parent | bc7f430decab0bc34a533811efe457d4615f28aa (diff) | |
parent | 6ebde20b03db4c0d57f67acaac11832b610b966b (diff) | |
download | TV-bb2e798ef4d546dd54cd9e95796403062b860c15.tar.gz |
Snap for 4378450 from 6ebde20b03db4c0d57f67acaac11832b610b966b to oc-mr1-releaseandroid-wear-8.1.0_r1android-vts-8.1_r9android-vts-8.1_r8android-vts-8.1_r7android-vts-8.1_r6android-vts-8.1_r5android-vts-8.1_r4android-vts-8.1_r3android-vts-8.1_r14android-vts-8.1_r13android-vts-8.1_r12android-vts-8.1_r11android-vts-8.1_r10android-security-8.1.0_r93android-security-8.1.0_r92android-security-8.1.0_r91android-security-8.1.0_r90android-security-8.1.0_r89android-security-8.1.0_r88android-security-8.1.0_r87android-security-8.1.0_r86android-security-8.1.0_r85android-security-8.1.0_r84android-security-8.1.0_r83android-security-8.1.0_r82android-cts-8.1_r9android-cts-8.1_r8android-cts-8.1_r7android-cts-8.1_r6android-cts-8.1_r5android-cts-8.1_r4android-cts-8.1_r3android-cts-8.1_r25android-cts-8.1_r24android-cts-8.1_r23android-cts-8.1_r22android-cts-8.1_r21android-cts-8.1_r20android-cts-8.1_r2android-cts-8.1_r19android-cts-8.1_r18android-cts-8.1_r17android-cts-8.1_r16android-cts-8.1_r15android-cts-8.1_r14android-cts-8.1_r13android-cts-8.1_r12android-cts-8.1_r11android-cts-8.1_r10android-cts-8.1_r1android-8.1.0_r81android-8.1.0_r80android-8.1.0_r79android-8.1.0_r78android-8.1.0_r77android-8.1.0_r76android-8.1.0_r75android-8.1.0_r74android-8.1.0_r73android-8.1.0_r72android-8.1.0_r71android-8.1.0_r70android-8.1.0_r69android-8.1.0_r68android-8.1.0_r66android-8.1.0_r6android-8.1.0_r5android-8.1.0_r4android-8.1.0_r3android-8.1.0_r23android-8.1.0_r19android-8.1.0_r16android-8.1.0_r15android-8.1.0_r12android-8.1.0_r11android-8.1.0_r10android-8.1.0_r1security-oc-mr1-releaseoreo-mr1-wear-releaseoreo-mr1-vts-releaseoreo-mr1-security-releaseoreo-mr1-s1-releaseoreo-mr1-releaseoreo-mr1-cuttlefish-testingoreo-mr1-cts-releaseoreo-m4-s1-release
Change-Id: I07f19344c030a9c2b0fd7ba425f7bf7462575f92
Diffstat (limited to 'src/com/android/tv/TvOptionsManager.java')
-rw-r--r-- | src/com/android/tv/TvOptionsManager.java | 133 |
1 files changed, 37 insertions, 96 deletions
diff --git a/src/com/android/tv/TvOptionsManager.java b/src/com/android/tv/TvOptionsManager.java index 7871cbe7..493e039c 100644 --- a/src/com/android/tv/TvOptionsManager.java +++ b/src/com/android/tv/TvOptionsManager.java @@ -18,14 +18,13 @@ package com.android.tv; import android.content.Context; import android.media.tv.TvTrackInfo; +import android.support.annotation.IntDef; import android.util.SparseArray; import com.android.tv.data.DisplayMode; -import com.android.tv.util.TvSettings; -import com.android.tv.util.TvSettings.PipLayout; -import com.android.tv.util.TvSettings.PipSize; -import com.android.tv.util.TvSettings.PipSound; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.Locale; /** @@ -33,39 +32,34 @@ import java.util.Locale; * captions and display mode. Can be also used to create MenuAction items to control such options. */ public class TvOptionsManager { + @Retention(RetentionPolicy.SOURCE) + @IntDef({OPTION_CLOSED_CAPTIONS, OPTION_DISPLAY_MODE, OPTION_SYSTEMWIDE_PIP, OPTION_MULTI_AUDIO, + OPTION_MORE_CHANNELS, OPTION_DEVELOPER, OPTION_SETTINGS}) + public @interface OptionType {} public static final int OPTION_CLOSED_CAPTIONS = 0; public static final int OPTION_DISPLAY_MODE = 1; - public static final int OPTION_IN_APP_PIP = 2; - public static final int OPTION_SYSTEMWIDE_PIP = 3; - public static final int OPTION_MULTI_AUDIO = 4; - public static final int OPTION_MORE_CHANNELS = 5; - public static final int OPTION_DEVELOPER = 6; - public static final int OPTION_SETTINGS = 7; - - public static final int OPTION_PIP_INPUT = 100; - public static final int OPTION_PIP_SWAP = 101; - public static final int OPTION_PIP_SOUND = 102; - public static final int OPTION_PIP_LAYOUT = 103 ; - public static final int OPTION_PIP_SIZE = 104; + public static final int OPTION_SYSTEMWIDE_PIP = 2; + public static final int OPTION_MULTI_AUDIO = 3; + public static final int OPTION_MORE_CHANNELS = 4; + public static final int OPTION_DEVELOPER = 5; + public static final int OPTION_SETTINGS = 6; private final Context mContext; private final SparseArray<OptionChangedListener> mOptionChangedListeners = new SparseArray<>(); private String mClosedCaptionsLanguage; private int mDisplayMode; - private boolean mPip; private String mMultiAudio; - private String mPipInput; - private boolean mPipSwap; - @PipSound private int mPipSound; - @PipLayout private int mPipLayout; - @PipSize private int mPipSize; public TvOptionsManager(Context context) { mContext = context; } - public String getOptionString(int option) { + /** + * Returns a suitable displayed string for the given option type under current settings. + * @param option the type of option, should be one of {@link OptionType}. + */ + public String getOptionString(@OptionType int option) { switch (option) { case OPTION_CLOSED_CAPTIONS: if (mClosedCaptionsLanguage == null) { @@ -77,101 +71,48 @@ public class TvOptionsManager { .isDisplayModeAvailable(mDisplayMode) ? DisplayMode.getLabel(mDisplayMode, mContext) : DisplayMode.getLabel(DisplayMode.MODE_NORMAL, mContext); - case OPTION_IN_APP_PIP: - return mContext.getString( - mPip ? R.string.options_item_pip_on : R.string.options_item_pip_off); case OPTION_MULTI_AUDIO: return mMultiAudio; - case OPTION_PIP_INPUT: - return mPipInput; - case OPTION_PIP_SWAP: - return mContext.getString(mPipSwap ? R.string.pip_options_item_swap_on - : R.string.pip_options_item_swap_off); - case OPTION_PIP_SOUND: - if (mPipSound == TvSettings.PIP_SOUND_MAIN) { - return mContext.getString(R.string.pip_options_item_sound_main); - } else if (mPipSound == TvSettings.PIP_SOUND_PIP_WINDOW) { - return mContext.getString(R.string.pip_options_item_sound_pip_window); - } - break; - case OPTION_PIP_LAYOUT: - if (mPipLayout == TvSettings.PIP_LAYOUT_BOTTOM_RIGHT) { - return mContext.getString(R.string.pip_options_item_layout_bottom_right); - } else if (mPipLayout == TvSettings.PIP_LAYOUT_TOP_RIGHT) { - return mContext.getString(R.string.pip_options_item_layout_top_right); - } else if (mPipLayout == TvSettings.PIP_LAYOUT_TOP_LEFT) { - return mContext.getString(R.string.pip_options_item_layout_top_left); - } else if (mPipLayout == TvSettings.PIP_LAYOUT_BOTTOM_LEFT) { - return mContext.getString(R.string.pip_options_item_layout_bottom_left); - } else if (mPipLayout == TvSettings.PIP_LAYOUT_SIDE_BY_SIDE) { - return mContext.getString(R.string.pip_options_item_layout_side_by_side); - } - break; - case OPTION_PIP_SIZE: - if (mPipSize == TvSettings.PIP_SIZE_BIG) { - return mContext.getString(R.string.pip_options_item_size_big); - } else if (mPipSize == TvSettings.PIP_SIZE_SMALL) { - return mContext.getString(R.string.pip_options_item_size_small); - } - break; } return ""; } - public void onClosedCaptionsChanged(TvTrackInfo track) { - mClosedCaptionsLanguage = (track == null) ? null - : (track.getLanguage() != null) ? track.getLanguage() - : mContext.getString(R.string.default_language); + /** + * Handles changing selection of closed caption. + */ + public void onClosedCaptionsChanged(TvTrackInfo track, int trackIndex) { + mClosedCaptionsLanguage = (track == null) ? + null : (track.getLanguage() != null) ? track.getLanguage() + : mContext.getString(R.string.closed_caption_unknown_language, trackIndex + 1); notifyOptionChanged(OPTION_CLOSED_CAPTIONS); } + /** + * Handles changing selection of display mode. + */ public void onDisplayModeChanged(int displayMode) { mDisplayMode = displayMode; notifyOptionChanged(OPTION_DISPLAY_MODE); } - public void onPipChanged(boolean pip) { - mPip = pip; - notifyOptionChanged(OPTION_IN_APP_PIP); - } - + /** + * Handles changing selection of multi-audio. + */ public void onMultiAudioChanged(String multiAudio) { mMultiAudio = multiAudio; notifyOptionChanged(OPTION_MULTI_AUDIO); } - public void onPipInputChanged(String pipInput) { - mPipInput = pipInput; - notifyOptionChanged(OPTION_PIP_INPUT); - } - - public void onPipSwapChanged(boolean pipSwap) { - mPipSwap = pipSwap; - notifyOptionChanged(OPTION_PIP_SWAP); - } - - public void onPipSoundChanged(@PipSound int pipSound) { - mPipSound = pipSound; - notifyOptionChanged(OPTION_PIP_SOUND); - } - - public void onPipLayoutChanged(@PipLayout int pipLayout) { - mPipLayout = pipLayout; - notifyOptionChanged(OPTION_PIP_LAYOUT); - } - - public void onPipSizeChanged(@PipSize int pipSize) { - mPipSize = pipSize; - notifyOptionChanged(OPTION_PIP_SIZE); - } - - private void notifyOptionChanged(int option) { + private void notifyOptionChanged(@OptionType int option) { OptionChangedListener listener = mOptionChangedListeners.get(option); if (listener != null) { - listener.onOptionChanged(getOptionString(option)); + listener.onOptionChanged(option, getOptionString(option)); } } + /** + * Sets listeners to changes of the given option type. + */ public void setOptionChangedListener(int option, OptionChangedListener listener) { mOptionChangedListeners.put(option, listener); } @@ -180,6 +121,6 @@ public class TvOptionsManager { * An interface used to monitor option changes. */ public interface OptionChangedListener { - void onOptionChanged(String newOption); + void onOptionChanged(@OptionType int optionType, String newString); } -} +}
\ No newline at end of file |