diff options
author | Chris Palmer <palmer@google.com> | 2010-09-13 15:14:55 -0700 |
---|---|---|
committer | Chris Palmer <palmer@google.com> | 2010-09-28 10:32:49 -0700 |
commit | 51794a05ad044ad87efd8291b8decb71a9b5455e (patch) | |
tree | 7b217852dc51abd16a5b280ef411b6cb98934e82 /src/com/android/settings/DeviceAdminAdd.java | |
parent | 54e21852f221c183eba12e1706650cdc7e0a395f (diff) | |
download | packages_apps_Settings-51794a05ad044ad87efd8291b8decb71a9b5455e.tar.gz packages_apps_Settings-51794a05ad044ad87efd8291b8decb71a9b5455e.tar.bz2 packages_apps_Settings-51794a05ad044ad87efd8291b8decb71a9b5455e.zip |
Improve the add-device-admin layout.
Make it so that the app's explanation comes before the list of possible
policies. This gives the app a chance to explain itself instead of having
the explanation hidden below the fold. To avoid situations in which one
bunch of text items can obscure the other, use an expandable/ellipsizable
TextView with an indicator image. This resolves b/2992594.
Change-Id: I0eb0d0c46bb4be2ec2e019d741915537e1fcc592
Diffstat (limited to 'src/com/android/settings/DeviceAdminAdd.java')
-rw-r--r-- | src/com/android/settings/DeviceAdminAdd.java | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/com/android/settings/DeviceAdminAdd.java b/src/com/android/settings/DeviceAdminAdd.java index 476027704..005196e2f 100644 --- a/src/com/android/settings/DeviceAdminAdd.java +++ b/src/com/android/settings/DeviceAdminAdd.java @@ -35,9 +35,12 @@ import android.content.res.Resources; import android.os.Bundle; import android.os.Handler; import android.os.RemoteCallback; +import android.text.TextUtils.TruncateAt; import android.util.Log; +import android.view.Display; import android.view.View; import android.view.ViewGroup; +import android.view.WindowManager; import android.widget.AppSecurityPermissions; import android.widget.Button; import android.widget.ImageView; @@ -50,6 +53,10 @@ public class DeviceAdminAdd extends Activity { static final String TAG = "DeviceAdminAdd"; static final int DIALOG_WARNING = 1; + + private static final int MAX_ADD_MSG_LINES_PORTRAIT = 5; + private static final int MAX_ADD_MSG_LINES_LANDSCAPE = 2; + private static final int MAX_ADD_MSG_LINES = 15; Handler mHandler; @@ -62,6 +69,7 @@ public class DeviceAdminAdd extends Activity { TextView mAdminName; TextView mAdminDescription; TextView mAddMsg; + boolean mAddMsgEllipsized = true; TextView mAdminWarning; ViewGroup mAdminPolicies; Button mActionButton; @@ -138,7 +146,17 @@ public class DeviceAdminAdd extends Activity { mAdminIcon = (ImageView)findViewById(R.id.admin_icon); mAdminName = (TextView)findViewById(R.id.admin_name); mAdminDescription = (TextView)findViewById(R.id.admin_description); + mAddMsg = (TextView)findViewById(R.id.add_msg); + mAddMsg.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + toggleMessageEllipsis(v); + } + }); + + // toggleMessageEllipsis also handles initial layout: + toggleMessageEllipsis(mAddMsg); + mAdminWarning = (TextView)findViewById(R.id.admin_warning); mAdminPolicies = (ViewGroup)findViewById(R.id.admin_policies); mCancelButton = (Button)findViewById(R.id.cancel_button); @@ -280,5 +298,27 @@ public class DeviceAdminAdd extends Activity { mAdding = true; } } - + + + void toggleMessageEllipsis(View v) { + TextView tv = (TextView) v; + + mAddMsgEllipsized = ! mAddMsgEllipsized; + tv.setEllipsize(mAddMsgEllipsized ? TruncateAt.END : null); + tv.setMaxLines(mAddMsgEllipsized ? getEllipsizedLines() : MAX_ADD_MSG_LINES); + + ImageView iv = (ImageView) findViewById(R.id.add_msg_expander); + iv.setImageResource(mAddMsgEllipsized ? + com.android.internal.R.drawable.expander_ic_minimized : + com.android.internal.R.drawable.expander_ic_maximized); + } + + int getEllipsizedLines() { + Display d = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)) + .getDefaultDisplay(); + + return d.getHeight() > d.getWidth() ? + MAX_ADD_MSG_LINES_PORTRAIT : MAX_ADD_MSG_LINES_LANDSCAPE; + } + } |