summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Severson <evanseverson@google.com>2019-04-17 10:51:33 -0700
committerEvan Severson <evanseverson@google.com>2019-04-23 11:08:02 -0700
commitc04ff2e3f25b4c2bafd2098a99f634f3f23e0185 (patch)
treea8f8ff6c197c859c3127a4326b92169b097d17c9
parent1a16b978631d6455e1dabf215e89742a376dc81d (diff)
downloadandroid_packages_apps_PackageInstaller-c04ff2e3f25b4c2bafd2098a99f634f3f23e0185.tar.gz
android_packages_apps_PackageInstaller-c04ff2e3f25b4c2bafd2098a99f634f3f23e0185.tar.bz2
android_packages_apps_PackageInstaller-c04ff2e3f25b4c2bafd2098a99f634f3f23e0185.zip
Make it so that the grant dialog's position can be changed
The vertical position of a floating window is unable to be changed so now we have the window occupy the entire screen and add a new layout inside the scrollview so that position can be set. Doing this made animations for the dialog vanish, probably because the root is now transparent. So animations had to be added for the dialog. This also fixes the weird behavior where scrolling the dialog was inside the bounds of the rounded rectangle. Now the whole dialog moves as a single rectangle and can scroll off screen. Bug: 120435328 Test: atest CtsAppSecurityHostTestCases:android.appsecurity.cts.PermissionsHostTest Looked at dark theme, various display sizes, font sizes, landscape, portrait. All cases looked the same as before Change-Id: I1d85d89711f9e5404d2eeeb60f77d77c5eb01340
-rw-r--r--res/layout/grant_permissions.xml4
-rw-r--r--res/values-night/themes.xml5
-rw-r--r--res/values/overlayable.xml1
-rw-r--r--res/values/styles.xml13
-rw-r--r--res/values/themes.xml1
-rw-r--r--src/com/android/packageinstaller/permission/ui/handheld/GrantPermissionsViewHandlerImpl.java14
6 files changed, 35 insertions, 3 deletions
diff --git a/res/layout/grant_permissions.xml b/res/layout/grant_permissions.xml
index 611b5d0c..a93552c8 100644
--- a/res/layout/grant_permissions.xml
+++ b/res/layout/grant_permissions.xml
@@ -21,6 +21,9 @@
android:layout_height="match_parent"
style="@style/PermissionGrantScrollView">
+ <LinearLayout
+ style="@style/PermissionGrantSingleton">
+
<!-- The dialog -->
<LinearLayout
android:theme="@style/Theme.PermissionGrantDialog"
@@ -83,4 +86,5 @@
</LinearLayout>
</LinearLayout>
+ </LinearLayout>
</ScrollView> \ No newline at end of file
diff --git a/res/values-night/themes.xml b/res/values-night/themes.xml
index 8f6ae351..0d82b0d2 100644
--- a/res/values-night/themes.xml
+++ b/res/values-night/themes.xml
@@ -20,6 +20,9 @@
<style name="GrantPermissions"
parent="@android:style/Theme.DeviceDefault.Dialog.Alert">
<item name="android:windowNoTitle">true</item>
+ <item name="android:windowBackground">@android:color/transparent</item>
+ <item name="*android:windowFixedHeightMajor">100%</item>
+ <item name="*android:windowFixedHeightMinor">100%</item>
<!-- The following attributes change the behavior of the dialog, hence they should not be
themed -->
<item name="android:windowIsTranslucent">true</item>
@@ -28,7 +31,7 @@
<style name="Theme.PermissionGrantDialog"
parent="@android:style/Theme.DeviceDefault.Dialog">
- <item name="android:background">@color/google_grey_800</item>
+ <item name="android:colorBackground">@color/google_grey_800</item>
</style>
<style name="PermissionDialog"
diff --git a/res/values/overlayable.xml b/res/values/overlayable.xml
index 59dfd210..4021e618 100644
--- a/res/values/overlayable.xml
+++ b/res/values/overlayable.xml
@@ -22,6 +22,7 @@
<!-- START PERMISSION GRANT DIALOG -->
<item type="style" name="PermissionGrantScrollView" />
+ <item type="style" name="PermissionGrantSingleton" />
<item type="style" name="PermissionGrantDialog" />
<item type="style" name="PermissionGrantContent" />
diff --git a/res/values/styles.xml b/res/values/styles.xml
index af4954e1..bc91f0dd 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -17,15 +17,24 @@
<resources>
- <!-- PERMISSION GRANT DIALOG -->
+ <!-- START PERMISSION GRANT DIALOG -->
<style name="PermissionGrantScrollView">
<item name="android:scrollbars">none</item>
+ <item name="android:fillViewport">true</item>
+ <item name="android:clipChildren">false</item>
+ </style>
+
+ <style name="PermissionGrantSingleton">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:gravity">center</item>
</style>
<style name="PermissionGrantDialog">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
+ <item name="android:background">?android:attr/windowBackground</item>
<item name="android:orientation">vertical</item>
<item name="android:divider">@*android:drawable/list_divider_material</item>
<item name="android:showDividers">middle</item>
@@ -359,7 +368,7 @@
<!-- END APP PERMISSION SCREEN -->
- <!-- BEGIN PERMISSION FILTER SCREEN -->
+ <!-- START PERMISSION FILTER SCREEN -->
<style name="PermissionFilterDialogContainer">
<item name="android:layout_width">match_parent</item>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index a64d7d34..3eb00b4e 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -45,6 +45,7 @@
<style name="GrantPermissions"
parent="@android:style/Theme.DeviceDefault.Light.Dialog.Alert">
<item name="android:windowNoTitle">true</item>
+ <item name="android:windowBackground">@android:color/transparent</item>
<!-- The following attributes change the behavior of the dialog, hence they should not be
themed -->
<item name="android:windowIsTranslucent">true</item>
diff --git a/src/com/android/packageinstaller/permission/ui/handheld/GrantPermissionsViewHandlerImpl.java b/src/com/android/packageinstaller/permission/ui/handheld/GrantPermissionsViewHandlerImpl.java
index ff082a33..03ca1eee 100644
--- a/src/com/android/packageinstaller/permission/ui/handheld/GrantPermissionsViewHandlerImpl.java
+++ b/src/com/android/packageinstaller/permission/ui/handheld/GrantPermissionsViewHandlerImpl.java
@@ -26,12 +26,15 @@ import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Icon;
import android.os.Bundle;
+import android.transition.ChangeBounds;
+import android.transition.TransitionManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager.LayoutParams;
import android.view.accessibility.AccessibilityNodeInfo;
+import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
@@ -139,6 +142,14 @@ public class GrantPermissionsViewHandlerImpl implements GrantPermissionsViewHand
updateDescription();
updateDetailDescription();
updateButtons();
+
+// Animate change in size
+// Grow or shrink the content container to size of new content
+ ChangeBounds growShrinkToNewContentSize = new ChangeBounds();
+ growShrinkToNewContentSize.setDuration(ANIMATION_DURATION_MILLIS);
+ growShrinkToNewContentSize.setInterpolator(AnimationUtils.loadInterpolator(mActivity,
+ android.R.interpolator.fast_out_slow_in));
+ TransitionManager.beginDelayedTransition(mRootView, growShrinkToNewContentSize);
}
@Override
@@ -146,6 +157,9 @@ public class GrantPermissionsViewHandlerImpl implements GrantPermissionsViewHand
mRootView = (ViewGroup) LayoutInflater.from(mActivity)
.inflate(R.layout.grant_permissions, null);
+ int h = mActivity.getResources().getDisplayMetrics().heightPixels;
+ mRootView.setMinimumHeight(h);
+
mMessageView = (TextView) mRootView.findViewById(R.id.permission_message);
mDetailMessageView = (TextView) mRootView.findViewById(R.id.detail_message);
mIconView = (ImageView) mRootView.findViewById(R.id.permission_icon);