summaryrefslogtreecommitdiffstats
path: root/src/com/android/packageinstaller/permission/ui/ManualLayoutFrame.java
diff options
context:
space:
mode:
authorSvet Ganov <svetoslavganov@google.com>2016-01-13 09:10:41 -0800
committerSvet Ganov <svetoslavganov@google.com>2016-01-13 10:31:28 -0800
commitecaeae17f52d6562d23dfec91e44bc3c0b4a6d13 (patch)
treef1a058b907d3beb7999089d10a4d0067af59d2ad /src/com/android/packageinstaller/permission/ui/ManualLayoutFrame.java
parent5bf65a7c43509ca6ab927db489d51aa1291a29eb (diff)
downloadandroid_packages_apps_PackageInstaller-ecaeae17f52d6562d23dfec91e44bc3c0b4a6d13.tar.gz
android_packages_apps_PackageInstaller-ecaeae17f52d6562d23dfec91e44bc3c0b4a6d13.tar.bz2
android_packages_apps_PackageInstaller-ecaeae17f52d6562d23dfec91e44bc3c0b4a6d13.zip
Make request permissions dialog layout robost
If the min width of a dialog changes in portrait vs landscape it was possible that a part of the request permissions dialog is chopped off. The custom content layout manager was using a fixed width and changing orientation may lead to a dialog width lesser than the fixed width of the layout manager. Another problem was that if the above occurs and the window width changes then the window may not be tall enough to fit the content. To address this we have to do a gross move and re-add the window to the window manager, so it can be resized. Another issue was that if the "Don't ask again" checkbox is shown not for the first but say the second permission request (in the case of multi-permission request in one API call) the content was chopped off as the height measurement for how much the content needs to be was restricted by the parent measure spec. Now we measure with no restrictions to accommodate the whole content. The way reqeust permissions dialog is implemented is problematic as it is a dialog styled activity which means we may need to resize its window. It is better to implement it as a fullscreen activity that has a custom content layout mangar that makes the content look like a dialog. Since this is risky at this point we do targeted fixes to address the above issues. bug:24679384 Change-Id: If51a360ba17dfb71b66dcf841ea47c17606eba27
Diffstat (limited to 'src/com/android/packageinstaller/permission/ui/ManualLayoutFrame.java')
-rw-r--r--src/com/android/packageinstaller/permission/ui/ManualLayoutFrame.java25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/com/android/packageinstaller/permission/ui/ManualLayoutFrame.java b/src/com/android/packageinstaller/permission/ui/ManualLayoutFrame.java
index c9ccf9c1..1af400b3 100644
--- a/src/com/android/packageinstaller/permission/ui/ManualLayoutFrame.java
+++ b/src/com/android/packageinstaller/permission/ui/ManualLayoutFrame.java
@@ -17,7 +17,6 @@ package com.android.packageinstaller.permission.ui;
import android.content.Context;
import android.util.AttributeSet;
-import android.view.View;
import android.widget.FrameLayout;
/**
@@ -27,13 +26,10 @@ import android.widget.FrameLayout;
* but allows the view to grow downwards for animation.
*/
public class ManualLayoutFrame extends FrameLayout {
-
private int mDesiredHeight;
private int mHeight;
private int mWidth;
- private View mOffsetView;
-
public ManualLayoutFrame(Context context, AttributeSet attrs) {
super(context, attrs);
setClipChildren(false);
@@ -47,10 +43,29 @@ public class ManualLayoutFrame extends FrameLayout {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mWidth != 0) {
- // Keep the width constant to avoid weirdness.
+ int newWidth = mWidth;
+ final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
+ switch (widthMode) {
+ case MeasureSpec.AT_MOST: {
+ newWidth = Math.min(mWidth, MeasureSpec.getSize(widthMeasureSpec));
+ } break;
+ case MeasureSpec.EXACTLY: {
+ newWidth = MeasureSpec.getSize(widthMeasureSpec);
+ } break;
+ }
+ // If the width changes we have to re-evaluate the height
+ if (newWidth != mWidth) {
+ mWidth = newWidth;
+ mHeight = 0;
+ }
widthMeasureSpec = MeasureSpec.makeMeasureSpec(mWidth, MeasureSpec.EXACTLY);
}
+
+ // Let the content measure how much it needs to be fully shown
+ heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
mDesiredHeight = getMeasuredHeight();
if (mHeight == 0 && mDesiredHeight != 0) {
// Record the first non-zero width and height, this will be the height henceforth.