MediaControlView2: Add UX for Settings

This CL adds the UX for Settings by using ListView. The next CL
will include updating the data dynamically.

Bug: 73703113
Test: manually run VideoViewTest.apk
Change-Id: Iff0677cbabc2965ccc72275b58592355557e4ac0
diff --git a/packages/MediaComponents/res/drawable/ic_audiotrack.xml b/packages/MediaComponents/res/drawable/ic_audiotrack.xml
new file mode 100644
index 0000000..27c12b5
--- /dev/null
+++ b/packages/MediaComponents/res/drawable/ic_audiotrack.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24.0"
+    android:viewportHeight="24.0">
+    <path
+        android:fillColor="#FFFFFF"
+        android:pathData="M12,3v9.28c-0.47,-0.17 -0.97,-0.28 -1.5,-0.28C8.01,12 6,14.01 6,16.5S8.01,21 10.5,21c2.31,0 4.2,-1.75 4.45,-4H15V6h4V3h-7z"/>
+</vector>
diff --git a/packages/MediaComponents/res/drawable/ic_check.xml b/packages/MediaComponents/res/drawable/ic_check.xml
new file mode 100644
index 0000000..32f720b
--- /dev/null
+++ b/packages/MediaComponents/res/drawable/ic_check.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+
+    <path
+        android:pathData="M0 0h24v24H0z" />
+    <path
+        android:fillColor="#FFFFFF"
+        android:pathData="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z" />
+</vector>
\ No newline at end of file
diff --git a/packages/MediaComponents/res/drawable/ic_closed_caption_off.xml b/packages/MediaComponents/res/drawable/ic_closed_caption_off.xml
new file mode 100644
index 0000000..a79cd11
--- /dev/null
+++ b/packages/MediaComponents/res/drawable/ic_closed_caption_off.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+
+    <path
+        android:pathData="M0,0h24v24H0V0z" />
+    <path
+        android:fillColor="#FFFFFF"
+        android:pathData="M19,5.5c0.27,0,0.5,0.23,0.5,0.5v12c0,0.27-0.23,0.5-0.5,0.5H5c-0.28,0-0.5-0.22-0.5-0.5V6c0-0.28,0.22-0.5,0.5-0.5H19
+M19,4H5C3.89,4,3,4.9,3,6v12c0,1.1,0.89,2,2,2h14c1.1,0,2-0.9,2-2V6C21,4.9,20.1,4,19,4L19,4z" />
+    <path
+        android:fillColor="#FFFFFF"
+        android:pathData="M11,11H9.5v-0.5h-2v3h2V13H11v1c0,0.55-0.45,1-1,1H7c-0.55,0-1-0.45-1-1v-4c0-0.55,0.45-1,1-1h3c0.55,0,1,0.45,1,1V11z" />
+    <path
+        android:fillColor="#FFFFFF"
+        android:pathData="M18,11h-1.5v-0.5h-2v3h2V13H18v1c0,0.55-0.45,1-1,1h-3c-0.55,0-1-0.45-1-1v-4c0-0.55,0.45-1,1-1h3c0.55,0,1,0.45,1,1V11z" />
+</vector>
\ No newline at end of file
diff --git a/packages/MediaComponents/res/drawable/ic_help.xml b/packages/MediaComponents/res/drawable/ic_help.xml
new file mode 100644
index 0000000..4d1d75d
--- /dev/null
+++ b/packages/MediaComponents/res/drawable/ic_help.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+
+    <path
+        android:pathData="M0 0h24v24H0z" />
+    <path
+        android:fillColor="#FFFFFF"
+        android:pathData="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1
+17h-2v-2h2v2zm2.07-7.75l-.9 .92 C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1 .45 -2.1
+1.17-2.83l1.24-1.26c.37-.36 .59 -.86 .59 -1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21
+1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z" />
+</vector>
\ No newline at end of file
diff --git a/packages/MediaComponents/res/drawable/ic_high_quality.xml b/packages/MediaComponents/res/drawable/ic_high_quality.xml
new file mode 100644
index 0000000..e27d3e2
--- /dev/null
+++ b/packages/MediaComponents/res/drawable/ic_high_quality.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24.0"
+    android:viewportHeight="24.0">
+    <path
+        android:fillColor="#FFFFFF"
+        android:pathData="M19,4L5,4c-1.11,0 -2,0.9 -2,2v12c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,6c0,-1.1 -0.9,-2 -2,-2zM11,15L9.5,15v-2h-2v2L6,15L6,9h1.5v2.5h2L9.5,9L11,9v6zM18,14c0,0.55 -0.45,1 -1,1h-0.75v1.5h-1.5L14.75,15L14,15c-0.55,0 -1,-0.45 -1,-1v-4c0,-0.55 0.45,-1 1,-1h3c0.55,0 1,0.45 1,1v4zM14.5,13.5h2v-3h-2v3z"/>
+</vector>
\ No newline at end of file
diff --git a/packages/MediaComponents/res/drawable/ic_replay.xml b/packages/MediaComponents/res/drawable/ic_replay.xml
deleted file mode 100644
index 2bde120..0000000
--- a/packages/MediaComponents/res/drawable/ic_replay.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<vector android:height="40dp" android:viewportHeight="48.0"
-    android:viewportWidth="48.0" android:width="40dp" xmlns:android="http://schemas.android.com/apk/res/android">
-    <path android:fillColor="#FFFFFF" android:pathData="M24,10V2L14,12l10,10v-8c6.63,0 12,5.37 12,12s-5.37,12 -12,12 -12,-5.37 -12,-12H8c0,8.84 7.16,16 16,16s16,-7.16 16,-16 -7.16,-16 -16,-16z"/>
-</vector>
diff --git a/packages/MediaComponents/res/drawable/ic_replay_circle_filled.xml b/packages/MediaComponents/res/drawable/ic_replay_circle_filled.xml
new file mode 100644
index 0000000..389396b
--- /dev/null
+++ b/packages/MediaComponents/res/drawable/ic_replay_circle_filled.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+
+    <path
+        android:pathData="M0,0h24v24H0V0z" />
+    <path
+        android:fillColor="#FFFFFF"
+        android:fillType="evenOdd"
+        android:pathData="M12,2C6.48,2,2,6.48,2,12c0,5.52,4.48,10,10,10c5.52,0,10-4.48,10-10
+C22,6.48,17.52,2,12,2z
+M18,12c0,3.31-2.69,6-6,6c-3.31,0-6-2.69-6-6h2c0,2.21,1.79,4,4,4s4-1.79,4-4s-1.79-4-4-4v3L8,7l4-4v3
+C15.31,6,18,8.69,18,12z" />
+</vector>
\ No newline at end of file
diff --git a/packages/MediaComponents/res/drawable/ic_sd.xml b/packages/MediaComponents/res/drawable/ic_sd.xml
new file mode 100644
index 0000000..decb6d2
--- /dev/null
+++ b/packages/MediaComponents/res/drawable/ic_sd.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+
+    <path
+        android:pathData="M0,0h24v24H0V0z" />
+    <path
+        android:fillColor="#FFFFFF"
+        android:pathData="M19,3H5C3.89,3,3,3.9,3,5v14c0,1.1,0.89,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z
+M13,9h4c0.55,0,1,0.45,1,1v4 c0,0.55-0.45,1-1,1h-4V9z
+M9.5,13.5v-1H7c-0.55,0-1-0.45-1-1V10c0-0.55,0.45-1,1-1h3c0.55,0,1,0.45,1,1v1H9.5v-0.5h-2v1H10
+c0.55,0,1,0.45,1,1V14c0,0.55-0.45,1-1,1H7c-0.55,0-1-0.45-1-1v-1h1.5v0.5H9.5z
+M14.5,13.5h2v-3h-2V13.5z" />
+</vector>
\ No newline at end of file
diff --git a/packages/MediaComponents/res/layout/media_controller.xml b/packages/MediaComponents/res/layout/media_controller.xml
index 73c1b38..38f139d 100644
--- a/packages/MediaComponents/res/layout/media_controller.xml
+++ b/packages/MediaComponents/res/layout/media_controller.xml
@@ -136,7 +136,7 @@
 
     <RelativeLayout
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
+        android:layout_height="44dp"
         android:paddingLeft="15dp"
         android:orientation="horizontal">
 
@@ -235,6 +235,4 @@
         </LinearLayout>
 
     </RelativeLayout>
-
-</LinearLayout>
-
+</LinearLayout>
\ No newline at end of file
diff --git a/packages/MediaComponents/res/layout/settings_list.xml b/packages/MediaComponents/res/layout/settings_list.xml
new file mode 100644
index 0000000..37a3a60
--- /dev/null
+++ b/packages/MediaComponents/res/layout/settings_list.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2018 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<ListView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="@dimen/MediaControlView2_settings_width"
+    android:layout_height="@dimen/MediaControlView2_settings_height"
+    android:divider="@null"
+    android:dividerHeight="0dp">
+</ListView>
\ No newline at end of file
diff --git a/packages/MediaComponents/res/layout/settings_list_item.xml b/packages/MediaComponents/res/layout/settings_list_item.xml
new file mode 100644
index 0000000..e7522b7
--- /dev/null
+++ b/packages/MediaComponents/res/layout/settings_list_item.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2018 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="@dimen/MediaControlView2_settings_width"
+    android:layout_height="@dimen/MediaControlView2_settings_height"
+    android:orientation="horizontal"
+    android:background="@color/black_transparent_70">
+
+    <LinearLayout
+        android:layout_width="wrap_content"
+        android:layout_height="@dimen/MediaControlView2_settings_height"
+        android:paddingRight="2dp"
+        android:gravity="center"
+        android:orientation="horizontal">
+
+        <ImageView
+            android:id="@+id/check"
+            android:layout_width="@dimen/MediaControlView2_settings_icon_size"
+            android:layout_height="@dimen/MediaControlView2_settings_icon_size"
+            android:gravity="center"
+            android:paddingLeft="2dp"
+            android:src="@drawable/ic_check"/>
+
+        <ImageView
+            android:id="@+id/icon"
+            android:layout_width="@dimen/MediaControlView2_settings_icon_size"
+            android:layout_height="@dimen/MediaControlView2_settings_icon_size"
+            android:gravity="center"
+            android:paddingLeft="2dp"/>
+    </LinearLayout>
+
+    <RelativeLayout
+        android:layout_width="wrap_content"
+        android:layout_height="@dimen/MediaControlView2_settings_height"
+        android:gravity="center"
+        android:orientation="vertical">
+
+        <TextView
+            android:id="@+id/main_text"
+            android:layout_width="wrap_content"
+            android:layout_height="@dimen/MediaControlView2_text_width"
+            android:paddingLeft="2dp"
+            android:textColor="@color/white"
+            android:textSize="@dimen/MediaControlView2_settings_main_text_size"/>
+
+        <TextView
+            android:id="@+id/sub_text"
+            android:layout_width="wrap_content"
+            android:layout_height="@dimen/MediaControlView2_text_width"
+            android:layout_below="@id/main_text"
+            android:paddingLeft="2dp"
+            android:textColor="@color/white_transparent_70"
+            android:textSize="@dimen/MediaControlView2_settings_sub_text_size"/>
+    </RelativeLayout>
+
+</LinearLayout>
+
diff --git a/packages/MediaComponents/res/values/colors.xml b/packages/MediaComponents/res/values/colors.xml
index 9e071d7..8ba069c 100644
--- a/packages/MediaComponents/res/values/colors.xml
+++ b/packages/MediaComponents/res/values/colors.xml
@@ -15,5 +15,8 @@
 -->
 
 <resources>
-    <integer name="gray">0xff444444</integer>
+    <color name="gray">#808080</color>
+    <color name="white">#ffffff</color>
+    <color name="white_transparent_70">#B3ffffff</color>
+    <color name="black_transparent_70">#B3000000</color>
 </resources>
\ No newline at end of file
diff --git a/packages/MediaComponents/res/values/dimens.xml b/packages/MediaComponents/res/values/dimens.xml
index 91241cd..b5ef626 100644
--- a/packages/MediaComponents/res/values/dimens.xml
+++ b/packages/MediaComponents/res/values/dimens.xml
@@ -40,4 +40,13 @@
     <integer name="mr_controller_volume_group_list_fade_in_duration_ms">400</integer>
     <!-- Group list fade out animation duration. -->
     <integer name="mr_controller_volume_group_list_fade_out_duration_ms">200</integer>
+
+    <dimen name="MediaControlView2_settings_width">200dp</dimen>
+    <dimen name="MediaControlView2_settings_height">36dp</dimen>
+    <dimen name="MediaControlView2_settings_icon_size">28dp</dimen>
+    <dimen name="MediaControlView2_settings_offset">8dp</dimen>
+    <dimen name="MediaControlView2_text_width">18dp</dimen>
+
+    <dimen name="MediaControlView2_settings_main_text_size">12sp</dimen>
+    <dimen name="MediaControlView2_settings_sub_text_size">10sp</dimen>
 </resources>
diff --git a/packages/MediaComponents/res/values/strings.xml b/packages/MediaComponents/res/values/strings.xml
index 333d400..5f9c78d 100644
--- a/packages/MediaComponents/res/values/strings.xml
+++ b/packages/MediaComponents/res/values/strings.xml
@@ -105,4 +105,11 @@
     </string>
     <!-- Placeholder text indicating that the user can press the button to go to an external website. -->
     <string name="MediaControlView2_ad_text">Visit Advertiser</string>
+    <string name="MediaControlView2_cc_text">Closed caption</string>
+    <string name="MediaControlView2_audio_track_text">Audio track</string>
+    <string name="MediaControlView2_video_quality_text">Video quality</string>
+    <string name="MediaControlView2_video_quality_auto_text">Auto</string>
+    <string name="MediaControlView2_playback_speed_text">Playback speed</string>
+    <string name="MediaControlView2_playback_speed_normal_text">Normal</string>
+    <string name="MediaControlView2_help_text">Help &amp; feedback</string>
 </resources>
diff --git a/packages/MediaComponents/res/values/style.xml b/packages/MediaComponents/res/values/style.xml
index db5e8f3..299f16b 100644
--- a/packages/MediaComponents/res/values/style.xml
+++ b/packages/MediaComponents/res/values/style.xml
@@ -81,5 +81,4 @@
     <style name="BottomBarButton.Mute">
         <item name="android:src">@drawable/ic_mute</item>
     </style>
-
 </resources>
diff --git a/packages/MediaComponents/src/com/android/widget/MediaControlView2Impl.java b/packages/MediaComponents/src/com/android/widget/MediaControlView2Impl.java
index e937659..f440ad6 100644
--- a/packages/MediaComponents/src/com/android/widget/MediaControlView2Impl.java
+++ b/packages/MediaComponents/src/com/android/widget/MediaControlView2Impl.java
@@ -26,13 +26,19 @@
 import android.support.annotation.Nullable;
 import android.util.AttributeSet;
 import android.util.Log;
+import android.view.Gravity;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.BaseAdapter;
 import android.widget.Button;
 import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ListView;
 import android.widget.MediaControlView2;
 import android.widget.ProgressBar;
+import android.widget.PopupWindow;
 import android.widget.RelativeLayout;
 import android.widget.SeekBar;
 import android.widget.SeekBar.OnSeekBarChangeListener;
@@ -44,6 +50,7 @@
 import com.android.support.mediarouter.media.MediaRouter;
 import com.android.support.mediarouter.media.MediaRouteSelector;
 
+import java.util.ArrayList;
 import java.util.Formatter;
 import java.util.List;
 import java.util.Locale;
@@ -68,7 +75,9 @@
     private static final int REWIND_TIME_MS = 10000;
     private static final int FORWARD_TIME_MS = 30000;
     private static final int AD_SKIP_WAIT_TIME_MS = 5000;
+    private static final int RESOURCE_NON_EXISTENT = -1;
 
+    private Resources mResources;
     private MediaController mController;
     private MediaController.TransportControls mControls;
     private PlaybackState mPlaybackState;
@@ -109,6 +118,12 @@
     private ImageButton mAspectRationButton;
     private ImageButton mSettingsButton;
 
+    private PopupWindow mSettingsWindow;
+    private SettingsAdapter mSettingsAdapter;
+    private List<Integer> mSettingsMainTextIdsList;
+    private List<Integer> mSettingsSubTextIdsList;
+    private List<Integer> mSettingsIconIdsList;
+
     private CharSequence mPlayDescription;
     private CharSequence mPauseDescription;
     private CharSequence mReplayDescription;
@@ -127,6 +142,7 @@
 
     @Override
     public void initialize(@Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+        mResources = ApiHelper.getLibResources();
         // Inflate MediaControlView2 from XML
         mRoot = makeControllerView();
         mRoot.addOnLayoutChangeListener(mTitleBarLayoutChangeListener);
@@ -356,10 +372,11 @@
     }
 
     private void initControllerView(View v) {
-        Resources res = ApiHelper.getLibResources();
-        mPlayDescription = res.getText(R.string.lockscreen_play_button_content_description);
-        mPauseDescription = res.getText(R.string.lockscreen_pause_button_content_description);
-        mReplayDescription = res.getText(R.string.lockscreen_replay_button_content_description);
+        mPlayDescription = mResources.getText(R.string.lockscreen_play_button_content_description);
+        mPauseDescription =
+                mResources.getText(R.string.lockscreen_pause_button_content_description);
+        mReplayDescription =
+                mResources.getText(R.string.lockscreen_replay_button_content_description);
 
         mRouteButton = v.findViewById(R.id.cast);
 
@@ -367,19 +384,19 @@
         if (mPlayPauseButton != null) {
             mPlayPauseButton.requestFocus();
             mPlayPauseButton.setOnClickListener(mPlayPauseListener);
-            mPlayPauseButton.setColorFilter(R.integer.gray);
+            mPlayPauseButton.setColorFilter(R.color.gray);
             mPlayPauseButton.setEnabled(false);
         }
         mFfwdButton = v.findViewById(R.id.ffwd);
         if (mFfwdButton != null) {
             mFfwdButton.setOnClickListener(mFfwdListener);
-            mFfwdButton.setColorFilter(R.integer.gray);
+            mFfwdButton.setColorFilter(R.color.gray);
             mFfwdButton.setEnabled(false);
         }
         mRewButton = v.findViewById(R.id.rew);
         if (mRewButton != null) {
             mRewButton.setOnClickListener(mRewListener);
-            mRewButton.setColorFilter(R.integer.gray);
+            mRewButton.setColorFilter(R.color.gray);
             mRewButton.setEnabled(false);
         }
         mNextButton = v.findViewById(R.id.next);
@@ -395,7 +412,7 @@
         mSubtitleButton = v.findViewById(R.id.subtitle);
         if (mSubtitleButton != null) {
             mSubtitleButton.setOnClickListener(mSubtitleListener);
-            mSubtitleButton.setColorFilter(R.integer.gray);
+            mSubtitleButton.setColorFilter(R.color.gray);
             mSubtitleButton.setEnabled(false);
         }
         mFullScreenButton = v.findViewById(R.id.fullscreen);
@@ -418,6 +435,9 @@
         mMuteButton = v.findViewById(R.id.mute);
         mAspectRationButton = v.findViewById(R.id.aspect_ratio);
         mSettingsButton = v.findViewById(R.id.settings);
+        if (mSettingsButton != null) {
+            mSettingsButton.setOnClickListener(mSettingsButtonListener);
+        }
 
         mProgress = v.findViewById(R.id.mediacontroller_progress);
         if (mProgress != null) {
@@ -438,6 +458,18 @@
         mAdSkipView = v.findViewById(R.id.ad_skip_time);
         mAdRemainingView = v.findViewById(R.id.ad_remaining);
         mAdExternalLink = v.findViewById(R.id.ad_external_link);
+
+        populateResourceIds();
+        ListView settingsListView = (ListView) ApiHelper.inflateLibLayout(mInstance.getContext(),
+                R.layout.settings_list);
+        mSettingsAdapter = new SettingsAdapter(mSettingsMainTextIdsList, mSettingsSubTextIdsList,
+                mSettingsIconIdsList, true);
+        settingsListView.setAdapter(mSettingsAdapter);
+
+        int width = mResources.getDimensionPixelSize(R.dimen.MediaControlView2_settings_width);
+        mSettingsWindow = new PopupWindow(settingsListView, width,
+                ViewGroup.LayoutParams.WRAP_CONTENT, true);
+        // TODO: add listener to list view to allow each item to be selected.
     }
 
     /**
@@ -530,7 +562,7 @@
                     if (mAdSkipView.getVisibility() == View.GONE) {
                         mAdSkipView.setVisibility(View.VISIBLE);
                     }
-                    String skipTimeText = ApiHelper.getLibResources().getString(
+                    String skipTimeText = mResources.getString(
                             R.string.MediaControlView2_ad_skip_wait_time,
                             ((AD_SKIP_WAIT_TIME_MS - currentPosition) / 1000 + 1));
                     mAdSkipView.setText(skipTimeText);
@@ -546,7 +578,7 @@
             if (mAdRemainingView != null) {
                 int remainingTime =
                         (mDuration - currentPosition < 0) ? 0 : (mDuration - currentPosition);
-                String remainingTimeText = ApiHelper.getLibResources().getString(
+                String remainingTimeText = mResources.getString(
                         R.string.MediaControlView2_ad_remaining_time,
                         stringForTime(remainingTime));
                 mAdRemainingView.setText(remainingTimeText);
@@ -559,14 +591,12 @@
         if (isPlaying()) {
             mControls.pause();
             mPlayPauseButton.setImageDrawable(
-                    ApiHelper.getLibResources().getDrawable(
-                            R.drawable.ic_play_circle_filled, null));
+                    mResources.getDrawable(R.drawable.ic_play_circle_filled, null));
             mPlayPauseButton.setContentDescription(mPlayDescription);
         } else {
             mControls.play();
             mPlayPauseButton.setImageDrawable(
-                    ApiHelper.getLibResources().getDrawable(
-                            R.drawable.ic_pause_circle_filled, null));
+                    mResources.getDrawable(R.drawable.ic_pause_circle_filled, null));
             mPlayPauseButton.setContentDescription(mPauseDescription);
         }
     }
@@ -602,8 +632,7 @@
             // show the play image instead of the replay image.
             if (mIsStopped) {
                 mPlayPauseButton.setImageDrawable(
-                        ApiHelper.getLibResources().getDrawable(
-                                R.drawable.ic_play_circle_filled, null));
+                        mResources.getDrawable(R.drawable.ic_play_circle_filled, null));
                 mPlayPauseButton.setContentDescription(mPlayDescription);
                 mIsStopped = false;
             }
@@ -689,14 +718,12 @@
         public void onClick(View v) {
             if (!mSubtitleIsEnabled) {
                 mSubtitleButton.setImageDrawable(
-                        ApiHelper.getLibResources().getDrawable(
-                                R.drawable.ic_media_subtitle_enabled, null));
+                        mResources.getDrawable(R.drawable.ic_media_subtitle_enabled, null));
                 mController.sendCommand(MediaControlView2.COMMAND_SHOW_SUBTITLE, null, null);
                 mSubtitleIsEnabled = true;
             } else {
                 mSubtitleButton.setImageDrawable(
-                        ApiHelper.getLibResources().getDrawable(
-                                R.drawable.ic_media_subtitle_disabled, null));
+                        mResources.getDrawable(R.drawable.ic_media_subtitle_disabled, null));
                 mController.sendCommand(MediaControlView2.COMMAND_HIDE_SUBTITLE, null, null);
                 mSubtitleIsEnabled = false;
             }
@@ -710,11 +737,10 @@
             // TODO: Re-arrange the button layouts according to the UX.
             if (isEnteringFullScreen) {
                 mFullScreenButton.setImageDrawable(
-                        ApiHelper.getLibResources().getDrawable(
-                                R.drawable.ic_fullscreen_exit, null));
+                        mResources.getDrawable(R.drawable.ic_fullscreen_exit, null));
             } else {
                 mFullScreenButton.setImageDrawable(
-                        ApiHelper.getLibResources().getDrawable(R.drawable.ic_fullscreen, null));
+                        mResources.getDrawable(R.drawable.ic_fullscreen, null));
             }
             Bundle args = new Bundle();
             args.putBoolean(ARGUMENT_KEY_FULLSCREEN, isEnteringFullScreen);
@@ -740,6 +766,19 @@
         }
     };
 
+    private final View.OnClickListener mSettingsButtonListener = new View.OnClickListener() {
+        @Override
+        public void onClick(View v) {
+            int itemHeight = mResources.getDimensionPixelSize(
+                    R.dimen.MediaControlView2_settings_height);
+            int totalHeight = mSettingsAdapter.getCount() * itemHeight;
+            int margin = (-1) * mResources.getDimensionPixelSize(
+                    R.dimen.MediaControlView2_settings_offset);
+            mSettingsWindow.showAsDropDown(mInstance, margin, margin - totalHeight,
+                    Gravity.BOTTOM | Gravity.RIGHT);
+        }
+    };
+
     // The title bar is made up of two separate LinearLayouts. If the sum of the two bars are
     // greater than the length of the title bar, reduce the size of the left bar (which makes the
     // TextView that contains the title of the media file shrink).
@@ -802,7 +841,7 @@
 
             mProgress.setEnabled(false);
             mNextButton.setEnabled(false);
-            mNextButton.setColorFilter(R.integer.gray);
+            mNextButton.setColorFilter(R.color.gray);
         } else {
             mRewButton.setVisibility(View.VISIBLE);
             mFfwdButton.setVisibility(View.VISIBLE);
@@ -821,6 +860,31 @@
         }
     }
 
+    private void populateResourceIds() {
+        // TODO: create record class for storing this info
+        mSettingsMainTextIdsList = new ArrayList<Integer>();
+        mSettingsMainTextIdsList.add(R.string.MediaControlView2_cc_text);
+        mSettingsMainTextIdsList.add(R.string.MediaControlView2_audio_track_text);
+        mSettingsMainTextIdsList.add(R.string.MediaControlView2_video_quality_text);
+        mSettingsMainTextIdsList.add(R.string.MediaControlView2_playback_speed_text);
+        mSettingsMainTextIdsList.add(R.string.MediaControlView2_help_text);
+
+        // TODO: Update the following code to be dynamic.
+        mSettingsSubTextIdsList = new ArrayList<Integer>();
+        mSettingsSubTextIdsList.add(R.string.MediaControlView2_cc_text);
+        mSettingsSubTextIdsList.add(R.string.MediaControlView2_audio_track_text);
+        mSettingsSubTextIdsList.add(R.string.MediaControlView2_video_quality_text);
+        mSettingsSubTextIdsList.add(R.string.MediaControlView2_playback_speed_text);
+        mSettingsSubTextIdsList.add(RESOURCE_NON_EXISTENT);
+
+        mSettingsIconIdsList = new ArrayList<Integer>();
+        mSettingsIconIdsList.add(R.drawable.ic_closed_caption_off);
+        mSettingsIconIdsList.add(R.drawable.ic_audiotrack);
+        mSettingsIconIdsList.add(R.drawable.ic_high_quality);
+        mSettingsIconIdsList.add(R.drawable.ic_play_circle_filled);
+        mSettingsIconIdsList.add(R.drawable.ic_help);
+    }
+
     private class MediaControllerCallback extends MediaController.Callback {
         @Override
         public void onPlaybackStateChanged(PlaybackState state) {
@@ -834,22 +898,19 @@
                 switch (mPlaybackState.getState()) {
                     case PlaybackState.STATE_PLAYING:
                         mPlayPauseButton.setImageDrawable(
-                                ApiHelper.getLibResources().getDrawable(
-                                        R.drawable.ic_pause_circle_filled, null));
+                                mResources.getDrawable(R.drawable.ic_pause_circle_filled, null));
                         mPlayPauseButton.setContentDescription(mPauseDescription);
                         mInstance.removeCallbacks(mUpdateProgress);
                         mInstance.post(mUpdateProgress);
                         break;
                     case PlaybackState.STATE_PAUSED:
                         mPlayPauseButton.setImageDrawable(
-                                ApiHelper.getLibResources().getDrawable(
-                                        R.drawable.ic_play_circle_filled, null));
+                                mResources.getDrawable(R.drawable.ic_play_circle_filled, null));
                         mPlayPauseButton.setContentDescription(mPlayDescription);
                         break;
                     case PlaybackState.STATE_STOPPED:
                         mPlayPauseButton.setImageDrawable(
-                                ApiHelper.getLibResources().getDrawable(
-                                        R.drawable.ic_replay, null));
+                                mResources.getDrawable(R.drawable.ic_replay_circle_filled, null));
                         mPlayPauseButton.setContentDescription(mReplayDescription);
                         mIsStopped = true;
                         break;
@@ -923,7 +984,7 @@
                         mSubtitleButton.clearColorFilter();
                         mSubtitleButton.setEnabled(true);
                     } else {
-                        mSubtitleButton.setColorFilter(R.integer.gray);
+                        mSubtitleButton.setColorFilter(R.color.gray);
                         mSubtitleButton.setEnabled(false);
                     }
                     mContainsSubtitle = newSubtitleStatus;
@@ -937,4 +998,76 @@
             }
         }
     }
+
+    private class SettingsAdapter extends BaseAdapter {
+        List<Integer> mMainTextIds;
+        List<Integer> mSubTextIds;
+        List<Integer> mIconIds;
+        boolean mIsCheckable;
+
+        public SettingsAdapter(List<Integer> mainTextIds, @Nullable List<Integer> subTextIds,
+                @Nullable List<Integer> iconIds, boolean isCheckable) {
+            mMainTextIds = mainTextIds;
+            mSubTextIds = subTextIds;
+            mIconIds = iconIds;
+            mIsCheckable = isCheckable;
+        }
+
+        @Override
+        public int getCount() {
+            return (mMainTextIds == null) ? 0 : mMainTextIds.size();
+        }
+
+        @Override
+        public long getItemId(int position) {
+            // Auto-generated method stub--does not have any purpose here
+            // TODO: implement this.
+            return 0;
+        }
+
+        @Override
+        public Object getItem(int position) {
+            // Auto-generated method stub--does not have any purpose here
+            // TODO: implement this.
+            return null;
+        }
+
+        @Override
+        public View getView(int position, View convertView, ViewGroup container) {
+            View row = ApiHelper.inflateLibLayout(mInstance.getContext(),
+                    R.layout.settings_list_item);
+            TextView mainTextView = (TextView) row.findViewById(R.id.main_text);
+            TextView subTextView = (TextView) row.findViewById(R.id.sub_text);
+            ImageView iconView = (ImageView) row.findViewById(R.id.icon);
+            ImageView checkView = (ImageView) row.findViewById(R.id.check);
+
+            // Set main text
+            mainTextView.setText(mResources.getString(mMainTextIds.get(position)));
+
+            // Remove sub text and center the main text if sub texts do not exist at all or the sub
+            // text at this particular position is set to RESOURCE_NON_EXISTENT.
+            if (mSubTextIds == null || mSubTextIds.get(position) == RESOURCE_NON_EXISTENT) {
+                subTextView.setVisibility(View.GONE);
+            } else {
+                // Otherwise, set sub text.
+                subTextView.setText(mResources.getString(mSubTextIds.get(position)));
+            }
+
+            // Remove main icon and set visibility to gone if icons are set to null or the icon at
+            // this particular position is set to RESOURCE_NON_EXISTENT.
+            if (mIconIds == null || mIconIds.get(position) == RESOURCE_NON_EXISTENT) {
+                iconView.setVisibility(View.GONE);
+            } else {
+                // Otherwise, set main icon.
+                iconView.setImageDrawable(mResources.getDrawable(mIconIds.get(position), null));
+            }
+
+            // Set check icon
+            // TODO: make the following code dynamic
+            if (!mIsCheckable) {
+                checkView.setVisibility(View.GONE);
+            }
+            return row;
+        }
+    }
 }