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
This commit is contained in:
@@ -20,16 +20,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
<ScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical">
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical">
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -44,6 +35,17 @@
|
|||||||
android:shadowColor="?android:attr/colorBackground"
|
android:shadowColor="?android:attr/colorBackground"
|
||||||
android:shadowRadius="2" />
|
android:shadowRadius="2" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dip"
|
||||||
|
android:layout_weight="1.0"
|
||||||
|
android:gravity="top">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -66,28 +68,49 @@
|
|||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:ellipsize="marquee" />
|
android:ellipsize="marquee" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<TextView android:id="@+id/admin_warning"
|
|
||||||
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<TextView android:id="@+id/admin_description"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="0dip"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:padding="0dip" />
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
<ImageView android:id="@+id/add_msg_expander"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical" />
|
||||||
|
<TextView android:id="@+id/add_msg"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:padding="10dip" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView android:id="@+id/admin_warning"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
android:padding="10dip" />
|
android:padding="10dip" />
|
||||||
<LinearLayout android:id="@+id/admin_policies"
|
<LinearLayout android:id="@+id/admin_policies"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="16dip"
|
android:paddingLeft="16dip"
|
||||||
android:paddingRight="12dip" />
|
android:paddingRight="12dip" />
|
||||||
<TextView android:id="@+id/admin_description"
|
</LinearLayout>
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:padding="10dip" />
|
|
||||||
<TextView android:id="@+id/add_msg"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:padding="10dip" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<LinearLayout style="@android:style/ButtonBar"
|
<LinearLayout style="@android:style/ButtonBar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -114,4 +137,5 @@
|
|||||||
android:layout_height="0dip"
|
android:layout_height="0dip"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@@ -35,9 +35,12 @@ import android.content.res.Resources;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.RemoteCallback;
|
import android.os.RemoteCallback;
|
||||||
|
import android.text.TextUtils.TruncateAt;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Display;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.WindowManager;
|
||||||
import android.widget.AppSecurityPermissions;
|
import android.widget.AppSecurityPermissions;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@@ -51,6 +54,10 @@ public class DeviceAdminAdd extends Activity {
|
|||||||
|
|
||||||
static final int DIALOG_WARNING = 1;
|
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;
|
Handler mHandler;
|
||||||
|
|
||||||
DevicePolicyManager mDPM;
|
DevicePolicyManager mDPM;
|
||||||
@@ -62,6 +69,7 @@ public class DeviceAdminAdd extends Activity {
|
|||||||
TextView mAdminName;
|
TextView mAdminName;
|
||||||
TextView mAdminDescription;
|
TextView mAdminDescription;
|
||||||
TextView mAddMsg;
|
TextView mAddMsg;
|
||||||
|
boolean mAddMsgEllipsized = true;
|
||||||
TextView mAdminWarning;
|
TextView mAdminWarning;
|
||||||
ViewGroup mAdminPolicies;
|
ViewGroup mAdminPolicies;
|
||||||
Button mActionButton;
|
Button mActionButton;
|
||||||
@@ -138,7 +146,17 @@ public class DeviceAdminAdd extends Activity {
|
|||||||
mAdminIcon = (ImageView)findViewById(R.id.admin_icon);
|
mAdminIcon = (ImageView)findViewById(R.id.admin_icon);
|
||||||
mAdminName = (TextView)findViewById(R.id.admin_name);
|
mAdminName = (TextView)findViewById(R.id.admin_name);
|
||||||
mAdminDescription = (TextView)findViewById(R.id.admin_description);
|
mAdminDescription = (TextView)findViewById(R.id.admin_description);
|
||||||
|
|
||||||
mAddMsg = (TextView)findViewById(R.id.add_msg);
|
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);
|
mAdminWarning = (TextView)findViewById(R.id.admin_warning);
|
||||||
mAdminPolicies = (ViewGroup)findViewById(R.id.admin_policies);
|
mAdminPolicies = (ViewGroup)findViewById(R.id.admin_policies);
|
||||||
mCancelButton = (Button)findViewById(R.id.cancel_button);
|
mCancelButton = (Button)findViewById(R.id.cancel_button);
|
||||||
@@ -281,4 +299,26 @@ public class DeviceAdminAdd extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user