diff options
-rw-r--r-- | AndroidManifest.xml | 2 | ||||
-rw-r--r-- | res/anim/snackbar_enter.xml | 28 | ||||
-rw-r--r-- | res/anim/snackbar_exit.xml | 27 | ||||
-rw-r--r-- | res/drawable-television/grant_permissions_action_item.xml | 20 | ||||
-rw-r--r-- | res/drawable-television/grant_permissions_action_item_background.xml | 21 | ||||
-rw-r--r-- | res/drawable-television/grant_permissions_action_item_shape.xml | 28 | ||||
-rw-r--r-- | res/layout-television/grant_permissions.xml | 90 | ||||
-rw-r--r-- | res/values-television/colors.xml | 28 | ||||
-rw-r--r-- | res/values-television/dimens.xml | 43 | ||||
-rw-r--r-- | res/values-television/strings.xml | 28 | ||||
-rw-r--r-- | res/values-television/themes.xml | 45 | ||||
-rw-r--r-- | res/values/themes.xml | 3 | ||||
-rw-r--r-- | src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java | 12 | ||||
-rw-r--r-- | src/com/android/packageinstaller/permission/ui/GrantPermissionsDefaultViewHandler.java | 6 | ||||
-rw-r--r-- | src/com/android/packageinstaller/permission/ui/GrantPermissionsTvViewHandler.java | 123 | ||||
-rw-r--r-- | src/com/android/packageinstaller/permission/ui/GrantPermissionsViewHandler.java | 8 |
16 files changed, 508 insertions, 4 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index dd19bc04..4d2df2bd 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -67,7 +67,7 @@ <activity android:name=".permission.ui.GrantPermissionsActivity" android:configChanges="orientation|keyboardHidden|screenSize" android:excludeFromRecents="true" - android:theme="@android:style/Theme.Material.DayNight.Dialog.NoActionBar"> + android:theme="@style/GrantPermissions"> <intent-filter> <action android:name="android.content.pm.action.REQUEST_PERMISSIONS" /> <category android:name="android.intent.category.DEFAULT" /> diff --git a/res/anim/snackbar_enter.xml b/res/anim/snackbar_enter.xml new file mode 100644 index 00000000..96bf4d25 --- /dev/null +++ b/res/anim/snackbar_enter.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +** +** Copyright 2015, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<set xmlns:android="http://schemas.android.com/apk/res/android" + android:shareInterpolator="false"> + <translate android:fromYDelta="100%" android:toYDelta="0" + android:interpolator="@android:interpolator/decelerate_quint" + android:duration="250"/> + <alpha android:fromAlpha="0.0" android:toAlpha="1.0" + android:interpolator="@android:interpolator/decelerate_quint" + android:duration="250" /> +</set> diff --git a/res/anim/snackbar_exit.xml b/res/anim/snackbar_exit.xml new file mode 100644 index 00000000..9aee1778 --- /dev/null +++ b/res/anim/snackbar_exit.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* Copyright 2015, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<set xmlns:android="http://schemas.android.com/apk/res/android" + android:shareInterpolator="false"> + <translate android:fromYDelta="0" android:toYDelta="100%" + android:interpolator="@android:interpolator/accelerate_quint" + android:duration="250"/> + <alpha android:fromAlpha="1.0" android:toAlpha="0.0" + android:interpolator="@android:interpolator/accelerate_quint" + android:duration="250"/> +</set> diff --git a/res/drawable-television/grant_permissions_action_item.xml b/res/drawable-television/grant_permissions_action_item.xml new file mode 100644 index 00000000..96bf582c --- /dev/null +++ b/res/drawable-television/grant_permissions_action_item.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<ripple xmlns:android="http://schemas.android.com/apk/res/android" + android:color="@color/grant_permissions_white_text_alpha_100"> + <item android:drawable="@drawable/grant_permissions_action_item_background" /> +</ripple> diff --git a/res/drawable-television/grant_permissions_action_item_background.xml b/res/drawable-television/grant_permissions_action_item_background.xml new file mode 100644 index 00000000..86d6b1f4 --- /dev/null +++ b/res/drawable-television/grant_permissions_action_item_background.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_pressed="true" android:drawable="@drawable/grant_permissions_action_item_shape" /> + <item android:state_focused="true" android:drawable="@drawable/grant_permissions_action_item_shape" /> + <!-- no default background is specified, making the button transparent when not active --> +</selector> diff --git a/res/drawable-television/grant_permissions_action_item_shape.xml b/res/drawable-television/grant_permissions_action_item_shape.xml new file mode 100644 index 00000000..08cd3455 --- /dev/null +++ b/res/drawable-television/grant_permissions_action_item_shape.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2015 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<inset xmlns:android="http://schemas.android.com/apk/res/android" + android:insetRight="1dp" + android:insetBottom="1dp"> + <shape android:shape="rectangle"> + <corners android:radius="2dp" /> + <solid android:color="@color/grant_permissions_focus_highlight" /> + <padding android:left="8dp" + android:top="4dp" + android:right="8dp" + android:bottom="4dp" /> + </shape> +</inset> diff --git a/res/layout-television/grant_permissions.xml b/res/layout-television/grant_permissions.xml new file mode 100644 index 00000000..94584c1d --- /dev/null +++ b/res/layout-television/grant_permissions.xml @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="horizontal" + android:paddingLeft="@dimen/action_dialog_padding_left" + android:paddingRight="@dimen/action_dialog_padding_right" + android:paddingTop="@dimen/action_dialog_padding_top" + android:paddingBottom="@dimen/action_dialog_padding_bottom" + android:background="@color/grant_permissions_background_color"> + + <ImageView + android:id="@+id/permission_icon" + android:layout_width="@dimen/grant_permissions_app_icon_size" + android:layout_height="@dimen/grant_permissions_app_icon_size" + android:layout_marginTop="@dimen/grant_permissions_app_icon_margin_top"/> + + <LinearLayout + android:orientation="vertical" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:layout_marginLeft="@dimen/action_dialog_content_margin_left" + android:layout_marginRight="@dimen/action_dialog_content_margin_right"> + <TextView + android:id="@+id/current_page_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="@dimen/grant_permissions_app_breadcrumb_margin_bottom" + android:textAppearance="@style/GrantPermissions.BreadcrumbText" /> + + <TextView + android:id="@+id/permission_message" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="@dimen/grant_permissions_app_title_margin_bottom" + android:textAppearance="@style/GrantPermissions.TitleText"/> + + <TextView + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_marginBottom="@dimen/grant_permissions_app_details_margin_bottom" + android:layout_weight="1" + android:text="@string/grant_dialog_how_to_change" + android:textAppearance="@style/GrantPermissions.BodyText" /> + </LinearLayout> + + <LinearLayout + android:orientation="vertical" + android:layout_width="@dimen/action_dialog_actions_width" + android:layout_height="wrap_content" + android:layout_marginLeft="@dimen/action_dialog_actions_margin_left" + android:layout_marginTop="@dimen/action_dialog_actions_margin_top"> + <Button + android:id="@+id/permission_allow_button" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/grant_dialog_button_allow" + style="@style/GrantPermissions.ActionItem" /> + + <Button + android:id="@+id/permission_deny_button" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/grant_dialog_button_deny" + style="@style/GrantPermissions.ActionItem" /> + + <Button + android:id="@+id/permission_deny_dont_ask_again_button" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/grant_dialog_button_deny_dont_ask_again" + style="@style/GrantPermissions.ActionItem" /> + </LinearLayout> + +</LinearLayout> diff --git a/res/values-television/colors.xml b/res/values-television/colors.xml new file mode 100644 index 00000000..1fe60dc7 --- /dev/null +++ b/res/values-television/colors.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <color name="grant_permissions_background_color">#ff263238</color> + <color name="grant_permissions_app_color">@color/grant_permissions_white_text_alpha_100</color> + <color name="grant_permissions_progress_color">@color/grant_permissions_white_text_alpha_100</color> + <color name="grant_permissions_title_color">@color/grant_permissions_white_text_alpha_70</color> + <color name="grant_permissions_body_color">@color/grant_permissions_white_text_alpha_70</color> + <color name="grant_permissions_button_color">@color/grant_permissions_white_text_alpha_100</color> + <color name="grant_permissions_focus_highlight">#26eeeeee</color> + + <color name="grant_permissions_white_text_alpha_100">#ffeeeeee</color> + <color name="grant_permissions_white_text_alpha_70">#b2eeeeee</color> +</resources> diff --git a/res/values-television/dimens.xml b/res/values-television/dimens.xml new file mode 100644 index 00000000..03038386 --- /dev/null +++ b/res/values-television/dimens.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <dimen name="grant_permissions_app_icon_size">64dp</dimen> + <dimen name="grant_permissions_app_icon_margin_top">19dp</dimen> + + <dimen name="grant_permissions_app_breadcrumb_margin_bottom">3dp</dimen> + <dimen name="grant_permissions_app_title_margin_bottom">18dp</dimen> + <dimen name="grant_permissions_app_details_margin_bottom">8dp</dimen> + + <dimen name="action_dialog_z">16dp</dimen> + <dimen name="action_dialog_padding_left">52dp</dimen> + <dimen name="action_dialog_padding_right">40dp</dimen> + <dimen name="action_dialog_padding_top">41dp</dimen> + <dimen name="action_dialog_padding_bottom">27dp</dimen> + + <dimen name="action_dialog_content_margin_left">24dp</dimen> + <dimen name="action_dialog_content_margin_right">32dp</dimen> + + <dimen name="action_dialog_actions_width">304dp</dimen> + <dimen name="action_dialog_actions_margin_left">24dp</dimen> + <dimen name="action_dialog_actions_margin_top">18dp</dimen> + + <dimen name="action_dialog_button_padding_left">16dp</dimen> + <dimen name="action_dialog_button_padding_right">16dp</dimen> + <dimen name="action_dialog_button_padding_top">14dp</dimen> + <dimen name="action_dialog_button_padding_bottom">15dp</dimen> + <dimen name="action_dialog_button_min_height">48dp</dimen> +</resources> diff --git a/res/values-television/strings.xml b/res/values-television/strings.xml new file mode 100644 index 00000000..32517c67 --- /dev/null +++ b/res/values-television/strings.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- Title for the dialog button to deny a permission grant and never ask the user again. --> + <string name="grant_dialog_button_deny_dont_ask_again">Deny and don\'t ask again</string> + + <!-- Instructional text telling the user how to change permission grants later. --> + <string name="grant_dialog_how_to_change">You can change this later in Settings > Apps</string> + + <!-- Template for the current permission from the total number of permissions. --> + <string name="current_permission_template"> + <xliff:g id="current_permission_index" example="1">%1$s</xliff:g> / + <xliff:g id="permission_count" example="2">%2$s</xliff:g></string> +</resources> diff --git a/res/values-television/themes.xml b/res/values-television/themes.xml index 04855490..de4ff092 100644 --- a/res/values-television/themes.xml +++ b/res/values-television/themes.xml @@ -17,4 +17,49 @@ <resources> <style name="Settings" parent="Theme.Leanback" /> + + <style name="GrantPermissions" parent="Theme.Leanback"> + <item name="android:windowIsFloating">true</item> + <item name="android:windowAnimationStyle">@style/Animation.Snackbar</item> + <item name="android:windowElevation">@dimen/action_dialog_z</item> + </style> + + <style name="GrantPermissions.BreadcrumbText"> + <item name="android:fontFamily">sans-serif-condensed</item> + <item name="android:textSize">14sp</item> + <item name="android:textColor">@color/grant_permissions_progress_color</item> + </style> + + <style name="GrantPermissions.TitleText"> + <item name="android:fontFamily">sans-serif-light</item> + <item name="android:textSize">24sp</item> + <item name="android:textColor">@color/grant_permissions_title_color</item> + <item name="android:lineSpacingMultiplier">1.221</item> + </style> + + <style name="GrantPermissions.BodyText"> + <item name="android:fontFamily">sans-serif</item> + <item name="android:textSize">14sp</item> + <item name="android:textColor">@color/grant_permissions_body_color</item> + <item name="android:lineSpacingMultiplier">1.465</item> + </style> + + <style name="GrantPermissions.ActionItem"> + <item name="android:gravity">left|center_vertical</item> + <item name="android:fontFamily">sans-serif-condensed</item> + <item name="android:textSize">14sp</item> + <item name="android:textColor">@color/grant_permissions_button_color</item> + <item name="android:lineSpacingMultiplier">1</item> + <item name="android:background">@drawable/grant_permissions_action_item</item> + <item name="android:paddingLeft">@dimen/action_dialog_button_padding_left</item> + <item name="android:paddingRight">@dimen/action_dialog_button_padding_right</item> + <item name="android:paddingTop">@dimen/action_dialog_button_padding_top</item> + <item name="android:paddingBottom">@dimen/action_dialog_button_padding_bottom</item> + <item name="android:minHeight">@dimen/action_dialog_button_min_height</item> + </style> + + <style name="Animation.Snackbar" parent="@android:style/Animation"> + <item name="android:windowEnterAnimation">@anim/snackbar_enter</item> + <item name="android:windowExitAnimation">@anim/snackbar_exit</item> + </style> </resources> diff --git a/res/values/themes.xml b/res/values/themes.xml index 0ae7eb84..9e8f0298 100644 --- a/res/values/themes.xml +++ b/res/values/themes.xml @@ -17,4 +17,7 @@ <resources> <style name="Settings" parent="@android:style/Theme.Material.Settings" /> + + <style name="GrantPermissions" + parent="@android:style/Theme.Material.DayNight.Dialog.NoActionBar" /> </resources> diff --git a/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java b/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java index fca3d138..8c548834 100644 --- a/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java +++ b/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java @@ -36,6 +36,8 @@ import android.text.SpannableString; import android.text.style.ForegroundColorSpan; import android.util.ArrayMap; import android.util.Log; +import android.view.Window; +import android.view.WindowManager; import com.android.packageinstaller.R; import com.android.packageinstaller.permission.model.AppPermissionGroup; @@ -66,8 +68,7 @@ public class GrantPermissionsActivity extends Activity int uiMode = getResources().getConfiguration().uiMode & UI_MODE_TYPE_MASK; if (uiMode == UI_MODE_TYPE_TELEVISION) { - // TODO(tvolkert): Create GrantPermissionsTvViewHandler - mViewHandler = new GrantPermissionsDefaultViewHandler(this).setResultListener(this); + mViewHandler = new GrantPermissionsTvViewHandler(this).setResultListener(this); } else { mViewHandler = new GrantPermissionsDefaultViewHandler(this).setResultListener(this); } @@ -131,6 +132,11 @@ public class GrantPermissionsActivity extends Activity setContentView(mViewHandler.createView()); + Window window = getWindow(); + WindowManager.LayoutParams layoutParams = window.getAttributes(); + mViewHandler.updateWindowAttributes(layoutParams); + window.setAttributes(layoutParams); + if (!showNextPermissionGroupGrantRequest()) { setResultAndFinish(); } @@ -159,7 +165,7 @@ public class GrantPermissionsActivity extends Activity SpannableString message = new SpannableString(getString( R.string.permission_warning_template, appLabel, groupState.mGroup.getDescription())); - // Bold/color the app name. + // Color the app name. int appLabelStart = message.toString().indexOf(appLabel.toString(), 0); int appLabelLength = appLabel.length(); int color = getColor(R.color.grant_permissions_app_color); diff --git a/src/com/android/packageinstaller/permission/ui/GrantPermissionsDefaultViewHandler.java b/src/com/android/packageinstaller/permission/ui/GrantPermissionsDefaultViewHandler.java index 0d8bd6cd..d755feeb 100644 --- a/src/com/android/packageinstaller/permission/ui/GrantPermissionsDefaultViewHandler.java +++ b/src/com/android/packageinstaller/permission/ui/GrantPermissionsDefaultViewHandler.java @@ -28,6 +28,7 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnLayoutChangeListener; import android.view.ViewGroup; +import android.view.WindowManager.LayoutParams; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; import android.widget.Button; @@ -284,6 +285,11 @@ final class GrantPermissionsDefaultViewHandler return mRootView; } + @Override + public void updateWindowAttributes(LayoutParams outLayoutParams) { + // No-op + } + private void updateDescription() { mIconView.setImageDrawable(mGroupIcon.loadDrawable(mContext)); mMessageView.setText(mGroupMessage); diff --git a/src/com/android/packageinstaller/permission/ui/GrantPermissionsTvViewHandler.java b/src/com/android/packageinstaller/permission/ui/GrantPermissionsTvViewHandler.java new file mode 100644 index 00000000..244c282f --- /dev/null +++ b/src/com/android/packageinstaller/permission/ui/GrantPermissionsTvViewHandler.java @@ -0,0 +1,123 @@ +package com.android.packageinstaller.permission.ui; + +import android.content.Context; +import android.graphics.PixelFormat; +import android.graphics.drawable.Icon; +import android.os.Bundle; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.WindowManager; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.android.packageinstaller.R; + +/** + * TV-specific view handler for the grant permissions activity. + */ +final class GrantPermissionsTvViewHandler implements GrantPermissionsViewHandler, OnClickListener { + + private static final String ARG_GROUP_NAME = "ARG_GROUP_NAME"; + + private final Context mContext; + + private ResultListener mResultListener; + + private String mGroupName; + + private LinearLayout mRootView; + private TextView mMessageView; + private ImageView mIconView; + private TextView mCurrentGroupView; + private Button mAllowButton; + private Button mSoftDenyButton; + private Button mHardDenyButton; + + GrantPermissionsTvViewHandler(Context context) { + mContext = context; + } + + @Override + public GrantPermissionsTvViewHandler setResultListener(ResultListener listener) { + mResultListener = listener; + return this; + } + + @Override + public View createView() { + mRootView = (LinearLayout) LayoutInflater.from(mContext) + .inflate(R.layout.grant_permissions, null); + + mMessageView = (TextView) mRootView.findViewById(R.id.permission_message); + mIconView = (ImageView) mRootView.findViewById(R.id.permission_icon); + mCurrentGroupView = (TextView) mRootView.findViewById(R.id.current_page_text); + mAllowButton = (Button) mRootView.findViewById(R.id.permission_allow_button); + mSoftDenyButton = (Button) mRootView.findViewById(R.id.permission_deny_button); + mHardDenyButton = (Button) mRootView.findViewById( + R.id.permission_deny_dont_ask_again_button); + + mAllowButton.setOnClickListener(this); + mSoftDenyButton.setOnClickListener(this); + mHardDenyButton.setOnClickListener(this); + + return mRootView; + } + + @Override + public void updateWindowAttributes(WindowManager.LayoutParams outLayoutParams) { + outLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; + outLayoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT; + outLayoutParams.format = PixelFormat.OPAQUE; + outLayoutParams.gravity = Gravity.BOTTOM; + outLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG; + outLayoutParams.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; + } + + @Override + public void updateUi(String groupName, int groupCount, int groupIndex, Icon icon, + CharSequence message, boolean showDoNotAsk) { + mGroupName = groupName; + + mMessageView.setText(message); + mIconView.setImageIcon(icon); + mHardDenyButton.setVisibility(showDoNotAsk ? View.VISIBLE : View.GONE); + if (groupCount > 1) { + mCurrentGroupView.setVisibility(View.VISIBLE); + mCurrentGroupView.setText(mContext.getString(R.string.current_permission_template, + groupIndex + 1, groupCount)); + } else { + mCurrentGroupView.setVisibility(View.INVISIBLE); + } + } + + @Override + public void saveInstanceState(Bundle outState) { + outState.putString(ARG_GROUP_NAME, mGroupName); + } + + @Override + public void loadInstanceState(Bundle savedInstanceState) { + mGroupName = savedInstanceState.getString(ARG_GROUP_NAME); + } + + @Override + public void onClick(View view) { + boolean granted = false; + boolean doNotAskAgain = false; + switch (view.getId()) { + case R.id.permission_allow_button: + granted = true; + break; + case R.id.permission_deny_dont_ask_again_button: + doNotAskAgain = true; + break; + } + if (mResultListener != null) { + mResultListener.onPermissionGrantResult(mGroupName, granted, doNotAskAgain); + } + } +} diff --git a/src/com/android/packageinstaller/permission/ui/GrantPermissionsViewHandler.java b/src/com/android/packageinstaller/permission/ui/GrantPermissionsViewHandler.java index 36ba4e4f..118a6773 100644 --- a/src/com/android/packageinstaller/permission/ui/GrantPermissionsViewHandler.java +++ b/src/com/android/packageinstaller/permission/ui/GrantPermissionsViewHandler.java @@ -19,6 +19,7 @@ package com.android.packageinstaller.permission.ui; import android.graphics.drawable.Icon; import android.os.Bundle; import android.view.View; +import android.view.WindowManager; /** * Class for managing the presentation and user interaction of the "grant @@ -41,6 +42,13 @@ interface GrantPermissionsViewHandler { View createView(); /** + * Updates the layout attributes of the current window. This is an optional + * operation; implementations only need to do work in this method if they + * need to alter the default styles provided by the activity's theme. + */ + void updateWindowAttributes(WindowManager.LayoutParams outLayoutParams); + + /** * Updates the view hierarchy to reflect the specified state. * <p> * Note that this must be called at least once before showing the UI to |