summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip P. Moltmann <moltmann@google.com>2016-08-12 15:21:26 -0700
committerPhilip P. Moltmann <moltmann@google.com>2016-08-12 15:57:02 -0700
commit0bbd04b3b5995c96fc268713bdfbebe153251bbd (patch)
treef80e49e1925d4aa4e8acc325f30ec74966127afb
parent4b362e58a764cfb74898ed7fb86c553de8f0c938 (diff)
downloadandroid_packages_apps_PackageInstaller-0bbd04b3b5995c96fc268713bdfbebe153251bbd.tar.gz
android_packages_apps_PackageInstaller-0bbd04b3b5995c96fc268713bdfbebe153251bbd.tar.bz2
android_packages_apps_PackageInstaller-0bbd04b3b5995c96fc268713bdfbebe153251bbd.zip
Make ReviewPermissions a MD full screen dialog
Change-Id: I5a800cc80d436a1ece35a326deeb80c7c302b1f6
-rw-r--r--AndroidManifest.xml3
-rw-r--r--res/drawable/ic_close.xml26
-rw-r--r--res/layout/review_permissions.xml93
-rw-r--r--res/values/strings.xml10
-rw-r--r--res/values/themes.xml6
-rw-r--r--src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java86
6 files changed, 102 insertions, 122 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 83364bd6..7486065e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -99,7 +99,8 @@
<activity android:name=".permission.ui.ReviewPermissionsActivity"
android:excludeFromRecents="true"
- android:theme="@style/Settings.NoActionBar"
+ android:label="@string/permission_review_title"
+ android:theme="@style/ReviewPermissions"
android:permission="android.permission.GRANT_RUNTIME_PERMISSIONS">
<intent-filter>
<action android:name="android.intent.action.REVIEW_PERMISSIONS" />
diff --git a/res/drawable/ic_close.xml b/res/drawable/ic_close.xml
new file mode 100644
index 00000000..0a590c64
--- /dev/null
+++ b/res/drawable/ic_close.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
+</vector>
+
diff --git a/res/layout/review_permissions.xml b/res/layout/review_permissions.xml
index 71d31917..ad00094c 100644
--- a/res/layout/review_permissions.xml
+++ b/res/layout/review_permissions.xml
@@ -14,77 +14,36 @@
limitations under the License.
-->
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_marginTop="32dip"
- android:layout_marginBottom="8dip"
- android:orientation="vertical">
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="16dip"
- android:layout_marginEnd="16dip"
- android:orientation="horizontal">
-
- <ImageView
- android:id="@+id/app_icon"
- android:layout_width="36dip"
- android:layout_height="36dip"
- android:tint="?android:attr/colorAccent"
- android:scaleType="fitCenter">
- </ImageView>
-
- <TextView
- android:id="@+id/permissions_message"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="16dip"
- style="?android:attr/textAppearanceMedium">
- </TextView>
-
- </LinearLayout>
-
- <FrameLayout
- android:id="@+id/preferences_frame"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_marginStart="2dip"
- android:layout_marginEnd="2dip"
- android:layout_weight="1">
- </FrameLayout>
-
- <com.android.packageinstaller.permission.ui.ButtonBarLayout
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:paddingStart="2dip"
- android:paddingTop="16dip">
-
- <Space
- android:id="@+id/spacer"
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1"
- android:visibility="invisible" />
+ android:layout_height="match_parent"
+ android:fitsSystemWindows="true"
+ android:orientation="vertical">
- <Button
- android:id="@+id/cancel_button"
- android:layout_width="wrap_content"
+ <android.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- style="?android:attr/buttonBarButtonStyle"
- android:text="@string/review_button_cancel" />
-
- <Button
- android:id="@+id/continue_button"
- android:layout_width="wrap_content"
+ android:background="?android:attr/colorPrimary"
+ android:paddingEnd="8dp"
+ android:elevation="4dp"
+ android:theme="@android:style/ThemeOverlay.Material.Dark.ActionBar" />
+
+ <TextView
+ android:id="@+id/message"
+ style="?android:attr/textAppearanceMedium"
+ android:textColor="?android:attr/textColorPrimary"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- style="?android:attr/buttonBarButtonStyle"
- android:layout_marginStart="8dip"
- android:text="@string/review_button_continue" />
+ android:layout_margin="16dp" />
- </com.android.packageinstaller.permission.ui.ButtonBarLayout>
+ <FrameLayout
+ android:id="@+id/preferences_frame"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_marginStart="2dip"
+ android:layout_marginEnd="2dip"
+ android:layout_weight="1">
+ </FrameLayout>
</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 12ad5f12..8946b3b5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -278,12 +278,14 @@
Allow <xliff:g id="app_name" example="Gmail">%1$s</xliff:g> to
access the following?</string>
- <!-- Template for the screen title when app permissions are reviewed on install. -->
- <string name="permission_review_title_template_install">Choose what to allow
+ <string name="permission_review_title">Permissions</string>
+
+ <!-- Template for the message when app permissions are reviewed on install. -->
+ <string name="permission_review_message_template_install">Choose what to allow
<xliff:g id="app_name" example="Gmail">%1$s</xliff:g> to access</string>
- <!-- Template for the screen title when app permissions are reviewed on update. -->
- <string name="permission_review_title_template_update">
+ <!-- Template for the message when app permissions are reviewed on update. -->
+ <string name="permission_review_message_template_update">
<xliff:g id="app_name" example="Gmail">%1$s</xliff:g> has been updated.
Choose what to allow this app to access.</string>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index db4b744e..93108791 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -33,4 +33,10 @@
<item name="android:windowBackground">@android:color/transparent</item>
</style>
+ <style name="ReviewPermissions"
+ parent="@android:style/Theme.DeviceDefault.Light.DarkActionBar">
+ <item name="android:windowActionBar">false</item>
+ <item name="android:windowNoTitle">true</item>
+ </style>
+
</resources>
diff --git a/src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java b/src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java
index 6bc251ae..206a30b7 100644
--- a/src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java
+++ b/src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java
@@ -34,14 +34,13 @@ import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.preference.SwitchPreference;
import android.preference.TwoStatePreference;
-import android.text.SpannableString;
import android.text.TextUtils;
-import android.text.style.ForegroundColorSpan;
-import android.util.TypedValue;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
-import android.widget.Button;
-import android.widget.ImageView;
import android.widget.TextView;
+import android.widget.Toolbar;
import com.android.packageinstaller.R;
import com.android.packageinstaller.permission.model.AppPermissionGroup;
import com.android.packageinstaller.permission.model.AppPermissions;
@@ -92,16 +91,13 @@ public final class ReviewPermissionsActivity extends Activity
}
public static final class ReviewPermissionsFragment extends PreferenceFragment
- implements View.OnClickListener, Preference.OnPreferenceChangeListener,
+ implements Preference.OnPreferenceChangeListener,
ConfirmActionDialogFragment.OnActionConfirmedListener {
public static final String EXTRA_PACKAGE_INFO =
"com.android.packageinstaller.permission.ui.extra.PACKAGE_INFO";
private AppPermissions mAppPermissions;
- private Button mContinueButton;
- private Button mCancelButton;
-
private PreferenceCategory mNewPermissionsCategory;
private boolean mHasConfirmedRevoke;
@@ -170,22 +166,6 @@ public final class ReviewPermissionsActivity extends Activity
}
@Override
- public void onClick(View view) {
- Activity activity = getActivity();
- if (activity == null) {
- return;
- }
- if (view == mContinueButton) {
- confirmPermissionsReview();
- executeCallback(true);
- } else if (view == mCancelButton) {
- executeCallback(false);
- activity.setResult(Activity.RESULT_CANCELED);
- }
- activity.finish();
- }
-
- @Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (mHasConfirmedRevoke) {
return true;
@@ -244,41 +224,47 @@ public final class ReviewPermissionsActivity extends Activity
return;
}
- // Set icon
- Drawable icon = mAppPermissions.getPackageInfo().applicationInfo.loadIcon(
- activity.getPackageManager());
- ImageView iconView = (ImageView) activity.findViewById(R.id.app_icon);
- iconView.setImageDrawable(icon);
-
// Set message
String appLabel = mAppPermissions.getAppLabel().toString();
final int labelTemplateResId = isPackageUpdated()
- ? R.string.permission_review_title_template_update
- : R.string.permission_review_title_template_install;
- SpannableString message = new SpannableString(getString(labelTemplateResId, appLabel));
+ ? R.string.permission_review_message_template_update
+ : R.string.permission_review_message_template_install;
+ String message = getString(labelTemplateResId, appLabel);
+
// Set the permission message as the title so it can be announced.
- activity.setTitle(message);
+ ((TextView)activity.findViewById(R.id.message)).setText(message);
- // Color the app name.
- final int appLabelStart = message.toString().indexOf(appLabel, 0);
- final int appLabelLength = appLabel.length();
+ Toolbar toolbar = (Toolbar) activity.findViewById(R.id.toolbar);
+ toolbar.setNavigationIcon(R.drawable.ic_close);
+ toolbar.setNavigationOnClickListener(view -> {
+ executeCallback(false);
+ activity.setResult(Activity.RESULT_CANCELED);
+ activity.finish();
+ });
+ activity.setActionBar(toolbar);
- TypedValue typedValue = new TypedValue();
- activity.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true);
- final int color = activity.getColor(typedValue.resourceId);
+ setHasOptionsMenu(true);
+ }
- message.setSpan(new ForegroundColorSpan(color), appLabelStart,
- appLabelStart + appLabelLength, 0);
- TextView permissionsMessageView = (TextView) activity.findViewById(
- R.id.permissions_message);
- permissionsMessageView.setText(message);
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ menu.clear();
+ menu.add(R.string.review_button_continue);
+ menu.getItem(0).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
+ }
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ Activity activity = getActivity();
+ if (activity == null) {
+ return false;
+ }
- mContinueButton = (Button) getActivity().findViewById(R.id.continue_button);
- mContinueButton.setOnClickListener(this);
+ confirmPermissionsReview();
+ executeCallback(true);
+ activity.finish();
- mCancelButton = (Button) getActivity().findViewById(R.id.cancel_button);
- mCancelButton.setOnClickListener(this);
+ return true;
}
private void loadPreferences() {