OSDN Git Service

Implement new manage apps UI for compat mode.
authorDianne Hackborn <hackbod@google.com>
Thu, 26 May 2011 08:04:44 +0000 (01:04 -0700)
committerDianne Hackborn <hackbod@google.com>
Thu, 26 May 2011 08:06:11 +0000 (01:06 -0700)
Change-Id: Ia8db7f534b7294fbbb34e0acdedab3a96cea59e9

res/layout/installed_app_details.xml
res/layout/two_buttons_panel.xml
res/values/strings.xml
src/com/android/settings/applications/InstalledAppDetails.java

index 0b68d47..6392ee9 100644 (file)
@@ -52,6 +52,7 @@
 
         <TextView
             style="?android:attr/listSeparatorTextViewStyle"
+            android:layout_marginTop="8dip"
             android:text="@string/storage_label" />
 
         <LinearLayout
             <TextView
                 android:id="@+id/cache_header"
                 style="?android:attr/listSeparatorTextViewStyle"
+                android:layout_marginTop="8dip"
                 android:text="@string/cache_header_label" />
             <LinearLayout
                 android:id="@+id/cache_size"
                 android:layout_alignParentRight="true"
                 android:layout_below="@id/cache_size"
                 android:layout_centerHorizontal="true"
-                android:layout_width="150dip"
+                android:layout_width="200dip"
                 android:text="@string/clear_cache_btn_text"
                 android:layout_height="wrap_content" />
         </RelativeLayout>
         <!-- Prefered activities section -->
         <TextView
             style="?android:attr/listSeparatorTextViewStyle"
+            android:layout_marginTop="8dip"
             android:text="@string/auto_launch_label" />
 
         <RelativeLayout 
                 android:layout_alignParentRight="true"
                 android:layout_below="@id/auto_launch"
                 android:layout_centerHorizontal="true"
-                android:layout_width="150dip"
+                android:layout_width="200dip"
                 android:text="@string/clear_activities"
                 android:layout_height="wrap_content" />
         </RelativeLayout>
 
+        <!-- Screen compatibility section -->
+        <LinearLayout android:id="@+id/screen_compatibility_section"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical">
+            <TextView
+                style="?android:attr/listSeparatorTextViewStyle"
+                android:layout_marginTop="8dip"
+                android:text="@string/screen_compatibility_label" />
+
+            <TextView android:textAppearance="?android:attr/textAppearanceSmall"
+                android:layout_alignParentLeft="true"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:paddingTop="6dip"
+                android:paddingRight="6dip"
+                android:paddingLeft="6dip"
+                android:text="@string/screen_compatibility_text"/>
+            <CheckBox android:id="@+id/ask_compatibility_cb"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="12dip"
+                android:layout_gravity="left"
+                android:text="@string/ask_compatibility" />
+            <CheckBox android:id="@+id/enable_compatibility_cb"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="12dip"
+                android:layout_gravity="left"
+                android:text="@string/enable_compatibility" />
+        </LinearLayout>
+
         <!-- Permissions section -->
         <LinearLayout
             android:id="@+id/permissions_section"
             android:orientation="vertical">
             <TextView
                 style="?android:attr/listSeparatorTextViewStyle"
+                android:layout_marginTop="8dip"
                 android:text="@string/permissions_label" />
             <TextView
                 android:text="@string/security_settings_desc"
index d76855c..05ad35d 100755 (executable)
@@ -39,7 +39,7 @@
             android:id="@+id/buttons_spacer_left"
             android:layout_width="0dip"
             android:layout_height="wrap_content"
-            android:visibility="gone"
+            android:visibility="invisible"
             android:layout_weight="0.2" />
         <Button
             android:id="@+id/right_button"
index bb9360d..03b4a05 100644 (file)
     <string name="storage_label">Storage</string>
     <!-- Manage applications, individual application info screen,  heading for settings related to controlling whether this app is the default for some actions -->
     <string name="auto_launch_label">Launch by default</string>
+    <!-- Manage applications, individual application info screen,  heading for settings related to controlling application screen compatibility -->
+    <string name="screen_compatibility_label">Screen compatibility</string>
     <!-- Manage applications, individual application info screen, heading for settings related to the app's permissions. for example, it may list all the permissions the app has. -->
     <string name="permissions_label">Permissions</string>
     <!-- Manage applications, Header name used for cache information -->
     <string name="auto_launch_disable_text">No defaults set.</string>
     <!-- Manage applications, individual application screen, button label under Launch by default heading.  This is used to clear any default actions that may be assigned to this app.  -->
     <string name="clear_activities">Clear defaults</string>
+    <!-- Manage applications, individual application info screen, screen, message text under screen compatibility heading -->
+    <string name="screen_compatibility_text">This application may not be designed for your screen; you can control how it
+            adjusts to your screen here.</string>
+    <!-- Manage applications, individual application screen, checkbox to control asking for compatibility mode.  -->
+    <string name="ask_compatibility">Ask when launched</string>
+    <!-- Manage applications, individual application screen, checkbox to control compatibility mode.  -->
+    <string name="enable_compatibility">Scale application</string>
     <!-- Manage apps, individual app screen, substituted for the application's label when the app's label CAN NOT be determined.-->
     <string name="unknown">Unknown</string>
     <!-- [CHAR LIMIT=25] Manage applications screen, menu item.  Sorts all of the apps in the list alphabetically. -->
index ae27d00..a0a568b 100644 (file)
@@ -60,6 +60,8 @@ import android.view.View;
 import android.view.ViewGroup;
 import android.widget.AppSecurityPermissions;
 import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
@@ -74,7 +76,8 @@ import android.widget.TextView;
  * uninstall the application.
  */
 public class InstalledAppDetails extends Fragment
-        implements View.OnClickListener, ApplicationsState.Callbacks {
+        implements View.OnClickListener, CompoundButton.OnCheckedChangeListener,
+        ApplicationsState.Callbacks {
     private static final String TAG="InstalledAppDetails";
     static final boolean SUPPORT_DISABLE_APPS = false;
     private static final boolean localLOGV = false;
@@ -92,6 +95,9 @@ public class InstalledAppDetails extends Fragment
     private boolean mMoveInProgress = false;
     private boolean mUpdatedSysApp = false;
     private Button mActivitiesButton;
+    private View mScreenCompatSection;
+    private CheckBox mAskCompatibilityCB;
+    private CheckBox mEnableCompatibilityCB;
     private boolean mCanClearData = true;
     private TextView mAppVersion;
     private TextView mTotalSize;
@@ -345,6 +351,11 @@ public class InstalledAppDetails extends Fragment
 
         mActivitiesButton = (Button)view.findViewById(R.id.clear_activities_button);
         
+        // Screen compatibility control
+        mScreenCompatSection = view.findViewById(R.id.screen_compatibility_section);
+        mAskCompatibilityCB = (CheckBox)view.findViewById(R.id.ask_compatibility_cb);
+        mEnableCompatibilityCB = (CheckBox)view.findViewById(R.id.enable_compatibility_cb);
+
         return view;
     }
 
@@ -466,7 +477,22 @@ public class InstalledAppDetails extends Fragment
             mActivitiesButton.setEnabled(true);
             mActivitiesButton.setOnClickListener(this);
         }
-         
+
+        // Screen compatibility section.
+        ActivityManager am = (ActivityManager)
+                getActivity().getSystemService(Context.ACTIVITY_SERVICE);
+        int compatMode = am.getPackageScreenCompatMode(packageName);
+        if (compatMode == ActivityManager.COMPAT_MODE_DISABLED
+                || compatMode == ActivityManager.COMPAT_MODE_ENABLED) {
+            mScreenCompatSection.setVisibility(View.VISIBLE);
+            mAskCompatibilityCB.setChecked(am.getPackageAskScreenCompat(packageName));
+            mAskCompatibilityCB.setOnCheckedChangeListener(this);
+            mEnableCompatibilityCB.setChecked(compatMode == ActivityManager.COMPAT_MODE_ENABLED);
+            mEnableCompatibilityCB.setOnCheckedChangeListener(this);
+        } else {
+            mScreenCompatSection.setVisibility(View.GONE);
+        }
+
         // Security permissions section
         LinearLayout permsView = (LinearLayout) mRootView.findViewById(R.id.permissions_section);
         AppSecurityPermissions asp = new AppSecurityPermissions(getActivity(), packageName);
@@ -846,5 +872,18 @@ public class InstalledAppDetails extends Fragment
             mPm.movePackage(mAppEntry.info.packageName, mPackageMoveObserver, moveFlags);
         }
     }
+
+    @Override
+    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+        String packageName = mAppEntry.info.packageName;
+        ActivityManager am = (ActivityManager)
+                getActivity().getSystemService(Context.ACTIVITY_SERVICE);
+        if (buttonView == mAskCompatibilityCB) {
+            am.setPackageAskScreenCompat(packageName, isChecked);
+        } else if (buttonView == mEnableCompatibilityCB) {
+            am.setPackageScreenCompatMode(packageName, isChecked ?
+                    ActivityManager.COMPAT_MODE_ENABLED : ActivityManager.COMPAT_MODE_DISABLED);
+        }
+    }
 }