Merge "Work on issue #63937884: Heavyweight Apps/Game Mode"
diff --git a/core/java/com/android/internal/app/HeavyWeightSwitcherActivity.java b/core/java/com/android/internal/app/HeavyWeightSwitcherActivity.java
index 459071b..4f41875 100644
--- a/core/java/com/android/internal/app/HeavyWeightSwitcherActivity.java
+++ b/core/java/com/android/internal/app/HeavyWeightSwitcherActivity.java
@@ -62,7 +62,7 @@
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         
-        requestWindowFeature(Window.FEATURE_LEFT_ICON);
+        requestWindowFeature(Window.FEATURE_NO_TITLE);
         
         mStartIntent = (IntentSender)getIntent().getParcelableExtra(KEY_INTENT);
         mHasResult = getIntent().getBooleanExtra(KEY_HAS_RESULT, false);
@@ -72,22 +72,15 @@
         
         setContentView(com.android.internal.R.layout.heavy_weight_switcher);
         
-        setIconAndText(R.id.old_app_icon, R.id.old_app_action, R.id.old_app_description,
-                mCurApp, R.string.old_app_action, R.string.old_app_description);
+        setIconAndText(R.id.old_app_icon, R.id.old_app_action, 0,
+                mCurApp, mNewApp, R.string.old_app_action, 0);
         setIconAndText(R.id.new_app_icon, R.id.new_app_action, R.id.new_app_description,
-                mNewApp, R.string.new_app_action, R.string.new_app_description);
+                mNewApp, mCurApp, R.string.new_app_action, R.string.new_app_description);
             
         View button = findViewById((R.id.switch_old));
         button.setOnClickListener(mSwitchOldListener);
         button = findViewById((R.id.switch_new));
         button.setOnClickListener(mSwitchNewListener);
-        button = findViewById((R.id.cancel));
-        button.setOnClickListener(mCancelListener);
-        
-        TypedValue out = new TypedValue();
-        getTheme().resolveAttribute(android.R.attr.alertDialogIcon, out, true);
-        getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, 
-                out.resourceId);
     }
 
     void setText(int id, CharSequence text) {
@@ -101,10 +94,10 @@
     }
     
     void setIconAndText(int iconId, int actionId, int descriptionId,
-            String packageName, int actionStr, int descriptionStr) {
-        CharSequence appName = "";
+            String packageName, String otherPackageName, int actionStr, int descriptionStr) {
+        CharSequence appName = packageName;
         Drawable appIcon = null;
-        if (mCurApp != null) {
+        if (packageName != null) {
             try {
                 ApplicationInfo info = getPackageManager().getApplicationInfo(
                         packageName, 0);
@@ -116,7 +109,18 @@
         
         setDrawable(iconId, appIcon);
         setText(actionId, getString(actionStr, appName));
-        setText(descriptionId, getText(descriptionStr));
+        if (descriptionId != 0) {
+            CharSequence otherAppName = otherPackageName;
+            if (otherPackageName != null) {
+                try {
+                    ApplicationInfo info = getPackageManager().getApplicationInfo(
+                            otherPackageName, 0);
+                    otherAppName = info.loadLabel(getPackageManager());
+                } catch (PackageManager.NameNotFoundException e) {
+                }
+            }
+            setText(descriptionId, getString(descriptionStr, otherAppName));
+        }
     }
     
     private OnClickListener mSwitchOldListener = new OnClickListener() {
@@ -149,10 +153,4 @@
             finish();
         }
     };
-    
-    private OnClickListener mCancelListener = new OnClickListener() {
-        public void onClick(View v) {
-            finish();
-        }
-    };
 }
diff --git a/core/res/res/layout/heavy_weight_switcher.xml b/core/res/res/layout/heavy_weight_switcher.xml
index c17e555..dbd8ece 100644
--- a/core/res/res/layout/heavy_weight_switcher.xml
+++ b/core/res/res/layout/heavy_weight_switcher.xml
@@ -15,31 +15,30 @@
 -->
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical" android:padding="4dp"
+    android:orientation="vertical" android:padding="24dp"
     android:gravity="center_horizontal"
     android:layout_width="wrap_content" android:layout_height="wrap_content">
 
     <TextView
         android:layout_width="match_parent" android:layout_height="wrap_content"
         android:layout_weight="0"
-        android:paddingBottom="8dp"
+        android:paddingBottom="20dp"
+        android:textAppearance="?android:attr/textAppearanceLarge"
+        android:text="@string/heavy_weight_switcher_title"/>
+
+    <TextView
+        android:layout_width="match_parent" android:layout_height="wrap_content"
+        android:layout_weight="0"
+        android:paddingBottom="16dp"
+        android:textAppearance="?android:attr/textAppearanceMedium"
         android:text="@string/heavy_weight_switcher_text"/>
 
-    <ImageView android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:scaleType="fitXY"
-        android:src="?android:listDivider" />
-            
     <LinearLayout android:id="@+id/switch_old"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:minHeight="?android:attr/listPreferredItemHeight"
+        android:minHeight="72dp"
         android:orientation="horizontal"
         android:background="@android:drawable/list_selector_background"
-        android:paddingEnd="3dip"
-        android:paddingStart="3dip"
-        android:paddingTop="5dip"
-        android:paddingBottom="14dip"
         android:gravity="center_vertical"
         android:focusable="true" >
     
@@ -61,33 +60,16 @@
                 android:textAppearance="?android:attr/textAppearanceMedium"
                 android:textStyle="bold"
                 android:singleLine="true"
-                android:layout_marginBottom="2dip"
-                android:duplicateParentState="true" />
-            <TextView android:id="@+id/old_app_description"
-                android:layout_marginTop="-4dip"
-                android:layout_gravity="center_vertical"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textAppearance="?android:attr/textAppearanceSmall"
                 android:duplicateParentState="true" />
         </LinearLayout>
     </LinearLayout>
 
-    <ImageView android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:scaleType="fitXY"
-        android:src="?android:listDivider" />
-            
     <LinearLayout android:id="@+id/switch_new"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:minHeight="?android:attr/listPreferredItemHeight"
+        android:minHeight="88dp"
         android:orientation="horizontal"
         android:background="@android:drawable/list_selector_background"
-        android:paddingEnd="3dip"
-        android:paddingStart="3dip"
-        android:paddingTop="5dip"
-        android:paddingBottom="8dip"
         android:gravity="center_vertical"
         android:focusable="true" >
     
@@ -109,10 +91,10 @@
                 android:textAppearance="?android:attr/textAppearanceMedium"
                 android:textStyle="bold"
                 android:singleLine="true"
-                android:layout_marginBottom="2dip"
+                android:layout_marginBottom="2dp"
                 android:duplicateParentState="true" />
             <TextView android:id="@+id/new_app_description"
-                android:layout_marginTop="-4dip"
+                android:layout_marginTop="-4dp"
                 android:layout_gravity="center_vertical"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
@@ -121,25 +103,4 @@
         </LinearLayout>
     </LinearLayout>
 
-    <ImageView android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:scaleType="fitXY"
-        android:src="?android:listDivider" />
-
-    <TextView android:id="@+id/cancel"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:minHeight="?android:attr/listPreferredItemHeight"
-        android:textAppearance="?android:attr/textAppearanceMedium"
-        android:background="@android:drawable/list_selector_background"
-        android:paddingEnd="6dip"
-        android:paddingStart="6dip"
-        android:paddingTop="5dip"
-        android:paddingBottom="8dip"
-        android:textStyle="bold"
-        android:singleLine="true"
-        android:gravity="center"
-        android:focusable="true"
-        android:text="@string/cancel" />
-
 </LinearLayout>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 837113d..e6186023 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2954,20 +2954,20 @@
     <string name="heavy_weight_notification"><xliff:g id="app">%1$s</xliff:g> running</string>
 
     <!-- Notification details to tell the user that a heavy-weight application is running. -->
-    <string name="heavy_weight_notification_detail">Tap to switch to app</string>
+    <string name="heavy_weight_notification_detail">Tap to return to game</string>
 
     <!-- Title of dialog prompting whether user wants to switch between heavy-weight apps. -->
-    <string name="heavy_weight_switcher_title">Switch apps?</string>
+    <string name="heavy_weight_switcher_title">Choose game</string>
 
     <!-- Descriptive text for switching to a new heavy-weight application. -->
-    <string name="heavy_weight_switcher_text">Another app is already running
-    that must be stopped before you can start a new one.</string>
+    <string name="heavy_weight_switcher_text">For better performance, only one of these
+        games can be open at a time.</string>
 
-    <string name="old_app_action">Return to <xliff:g id="old_app">%1$s</xliff:g></string>
-    <string name="old_app_description">Don\'t start the new app.</string>
+    <string name="old_app_action">Go back to <xliff:g id="old_app">%1$s</xliff:g></string>
 
-    <string name="new_app_action">Start <xliff:g id="old_app">%1$s</xliff:g></string>
-    <string name="new_app_description">Stop the old app without saving.</string>
+    <string name="new_app_action">Open <xliff:g id="new_app">%1$s</xliff:g></string>
+    <string name="new_app_description"><xliff:g id="old_app">%1$s</xliff:g> will close
+        without saving</string>
 
     <!-- Notification text to tell the user that a process has exceeded its memory limit. -->
     <string name="dump_heap_notification"><xliff:g id="proc">%1$s</xliff:g> exceeded memory
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 91ef3b4..863a8cd 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -109,7 +109,6 @@
   <java-symbol type="id" name="no_permissions" />
   <java-symbol type="id" name="numberpicker_input" />
   <java-symbol type="id" name="old_app_action" />
-  <java-symbol type="id" name="old_app_description" />
   <java-symbol type="id" name="old_app_icon" />
   <java-symbol type="id" name="overlay_display_window_texture" />
   <java-symbol type="id" name="overlay_display_window_title" />