summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Mantler <nicoya@google.com>2015-04-21 14:23:07 -0700
committerTony Mantler <nicoya@google.com>2015-04-22 10:08:01 -0700
commitbbc9216d829bf95ea718d430b8b7909c5a259b9b (patch)
tree483174d0c8df0b9c5aa2276134c9c66e953e5a16
parentaaf084f3f9bc3e89660791f83b5425bd70484be8 (diff)
downloadandroid_packages_apps_PackageInstaller-bbc9216d829bf95ea718d430b8b7909c5a259b9b.tar.gz
android_packages_apps_PackageInstaller-bbc9216d829bf95ea718d430b8b7909c5a259b9b.tar.bz2
android_packages_apps_PackageInstaller-bbc9216d829bf95ea718d430b8b7909c5a259b9b.zip
Add leanback-looking UI to permissions screens
Change-Id: Ib77227dc0ae4d02f96efff95f67a359310b5547c
-rw-r--r--Android.mk9
-rw-r--r--AndroidManifest.xml2
-rw-r--r--res/layout-television/permissions_frame.xml106
-rw-r--r--res/layout/permissions_frame.xml1
-rw-r--r--res/values-television/themes.xml20
-rwxr-xr-xres/values/colors.xml7
-rw-r--r--res/values/dimens.xml15
-rw-r--r--res/values/themes.xml20
-rw-r--r--src/com/android/packageinstaller/permission/ManagePermissionsFragment.java47
-rw-r--r--src/com/android/packageinstaller/permission/PermissionManagementFragment.java60
10 files changed, 273 insertions, 14 deletions
diff --git a/Android.mk b/Android.mk
index ce7d67d7..4657dfee 100644
--- a/Android.mk
+++ b/Android.mk
@@ -7,7 +7,14 @@ LOCAL_SRC_FILES := \
$(call all-java-files-under, src) \
src/com/android/packageinstaller/EventLogTags.logtags
-LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
+LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4 \
+ android-support-v17-leanback
+
+LOCAL_RESOURCE_DIR := \
+ $(TOP)/frameworks/support/v17/leanback/res \
+ $(LOCAL_PATH)/res
+
+LOCAL_AAPT_FLAGS := --auto-add-overlay --extra-packages android.support.v17.leanback
LOCAL_PACKAGE_NAME := PackageInstaller
LOCAL_CERTIFICATE := platform
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 8b7ba2f9..705a6198 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -76,7 +76,7 @@
android:configChanges="orientation|keyboardHidden|screenSize"
android:excludeFromRecents="true"
android:label="@string/app_permissions"
- android:theme="@android:style/Theme.Material.Settings"
+ android:theme="@style/Settings"
android:permission="android.permission.GRANT_REVOKE_PERMISSIONS">
<intent-filter>
<action android:name="android.intent.action.MANAGE_APP_PERMISSIONS" />
diff --git a/res/layout-television/permissions_frame.xml b/res/layout-television/permissions_frame.xml
new file mode 100644
index 00000000..c203ce69
--- /dev/null
+++ b/res/layout-television/permissions_frame.xml
@@ -0,0 +1,106 @@
+<?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
+ -->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <FrameLayout
+ android:id="@+id/prefs_container"
+ android:layout_width="@dimen/lb_action_section_width"
+ android:layout_height="match_parent"
+ android:layout_alignParentEnd="true"
+ android:background="@color/lb_action_fragment_background">
+
+ <TextView
+ android:id="@+id/no_permissions"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:text="@string/no_permissions"
+ android:gravity="center"
+ android:textAppearance="@android:style/TextAppearance.Large"
+ />
+
+ </FrameLayout>
+
+ <RelativeLayout
+ android:layout_width="@dimen/lb_content_section_width"
+ android:layout_height="match_parent"
+ android:layout_alignParentStart="true"
+ android:background="@color/lb_dialog_activity_background"
+ android:paddingStart="@dimen/lb_content_fragment_start_padding"
+ android:paddingEnd="@dimen/lb_content_fragment_delimiter_padding" >
+
+ <ImageView
+ android:id="@+id/lb_icon"
+ android:layout_width="@dimen/lb_content_fragment_icon_width"
+ android:layout_height="wrap_content"
+ android:layout_alignParentEnd="true"
+ android:layout_centerVertical="true"
+ android:layout_marginStart="@dimen/lb_content_fragment_delimiter_padding"
+ android:maxHeight="@dimen/lb_content_fragment_max_icon_height"
+ android:minHeight="@dimen/lb_content_fragment_icon_width"
+ android:scaleType="fitCenter"
+ tools:ignore="ContentDescription" />
+
+ <TextView
+ android:id="@+id/lb_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignWithParentIfMissing="true"
+ android:layout_centerVertical="true"
+ android:layout_toStartOf="@id/lb_icon"
+ android:ellipsize="end"
+ android:fontFamily="sans-serif-light"
+ android:gravity="end"
+ android:maxLines="2"
+ android:paddingBottom="@dimen/lb_content_fragment_title_text_bottom_padding"
+ android:paddingTop="@dimen/lb_content_fragment_title_text_top_padding"
+ android:textColor="@color/lb_content_title_text_color"
+ android:textSize="@dimen/lb_content_fragment_title_text_size"/>
+
+ <TextView
+ android:id="@+id/lb_breadcrumb"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_above="@id/lb_title"
+ android:layout_alignWithParentIfMissing="true"
+ android:layout_toStartOf="@id/lb_icon"
+ android:ellipsize="end"
+ android:fontFamily="sans-serif-condensed"
+ android:singleLine="true"
+ android:textColor="@color/lb_content_breadcrumb_text_color"
+ android:textSize="@dimen/lb_content_fragment_breadcrumb_text_size" />
+
+ <TextView
+ android:id="@+id/lb_description"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignWithParentIfMissing="true"
+ android:layout_below="@id/lb_title"
+ android:layout_toStartOf="@id/lb_icon"
+ android:ellipsize="end"
+ android:fontFamily="sans-serif"
+ android:gravity="end"
+ android:maxLines="6"
+ android:textColor="@color/lb_content_description_text_color"
+ android:textSize="@dimen/lb_content_fragment_description_text_size"
+ android:lineSpacingExtra="3dp"/>
+ </RelativeLayout>
+
+</RelativeLayout>
diff --git a/res/layout/permissions_frame.xml b/res/layout/permissions_frame.xml
index e70aaf63..e82ac51e 100644
--- a/res/layout/permissions_frame.xml
+++ b/res/layout/permissions_frame.xml
@@ -16,6 +16,7 @@
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/prefs_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
diff --git a/res/values-television/themes.xml b/res/values-television/themes.xml
new file mode 100644
index 00000000..04855490
--- /dev/null
+++ b/res/values-television/themes.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
+ -->
+
+<resources>
+ <style name="Settings" parent="Theme.Leanback" />
+</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index ae10cb28..549f55fd 100755
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -20,5 +20,12 @@
<color name="header_background_color">#ff37474f</color>
<color name="grant_permissions_app_color">@*android:color/primary_text_default_material_light</color>
<color name="grant_permissions_progress_color">#60000000</color>
+
+ <color name="lb_content_title_text_color">#FFF1F1F1</color>
+ <color name="lb_content_breadcrumb_text_color">#88F1F1F1</color>
+ <color name="lb_content_description_text_color">#88F1F1F1</color>
+ <color name="lb_action_fragment_background">#FF111111</color>
+ <color name="lb_dialog_activity_background">#77000000</color>
+
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 028def55..05845021 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -22,4 +22,19 @@
<!-- Header margin start / end -->
<dimen name="header_margin_start">16dp</dimen>
<dimen name="header_margin_end">16dp</dimen>
+
+ <dimen name="lb_action_section_width">384dp</dimen>
+
+ <dimen name="lb_content_section_width">576dp</dimen>
+ <dimen name="lb_content_fragment_start_padding">48dp</dimen>
+ <dimen name="lb_content_fragment_delimiter_padding">16dp</dimen>
+ <dimen name="lb_content_fragment_max_icon_height">280dp</dimen>
+ <dimen name="lb_content_fragment_title_text_top_padding">2dp</dimen>
+ <dimen name="lb_content_fragment_title_text_size">36sp</dimen>
+ <dimen name="lb_content_fragment_icon_width">140dp</dimen>
+
+ <dimen name="lb_content_fragment_breadcrumb_text_size">18sp</dimen>
+ <dimen name="lb_content_fragment_description_text_size">14sp</dimen>
+ <dimen name="lb_content_fragment_title_text_bottom_padding">4dp</dimen>
+
</resources>
diff --git a/res/values/themes.xml b/res/values/themes.xml
new file mode 100644
index 00000000..0ae7eb84
--- /dev/null
+++ b/res/values/themes.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
+ -->
+
+<resources>
+ <style name="Settings" parent="@android:style/Theme.Material.Settings" />
+</resources>
diff --git a/src/com/android/packageinstaller/permission/ManagePermissionsFragment.java b/src/com/android/packageinstaller/permission/ManagePermissionsFragment.java
index e93ba314..7ce13f83 100644
--- a/src/com/android/packageinstaller/permission/ManagePermissionsFragment.java
+++ b/src/com/android/packageinstaller/permission/ManagePermissionsFragment.java
@@ -16,11 +16,14 @@
package com.android.packageinstaller.permission;
+import android.annotation.Nullable;
+import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
@@ -31,14 +34,16 @@ import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
import android.widget.ListView;
+import android.widget.TextView;
import android.widget.Toast;
import com.android.packageinstaller.R;
public final class ManagePermissionsFragment extends SettingsWithHeader
implements OnPreferenceChangeListener {
- private static final String LOG_TAG = "ManagePermissionsFragment";
+ private static final String LOG_TAG = "ManagePermsFragment";
private AppPermissions mAppPermissions;
@@ -54,8 +59,10 @@ public final class ManagePermissionsFragment extends SettingsWithHeader
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
- getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
- bindUi();
+ final ActionBar ab = getActivity().getActionBar();
+ if (ab != null) {
+ ab.setDisplayHomeAsUpEnabled(true);
+ }
}
@Override
@@ -77,14 +84,24 @@ public final class ManagePermissionsFragment extends SettingsWithHeader
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- ViewGroup rootView = (ViewGroup)
- LayoutInflater.from(getActivity()).inflate(R.layout.permissions_frame, null);
- rootView.addView(super.onCreateView(inflater, container, savedInstanceState));
+ ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.permissions_frame, container,
+ false);
+ ViewGroup prefsContainer = (ViewGroup) rootView.findViewById(R.id.prefs_container);
+ if (prefsContainer == null) {
+ prefsContainer = rootView;
+ }
+ prefsContainer.addView(super.onCreateView(inflater, prefsContainer, savedInstanceState));
View emptyView = rootView.findViewById(R.id.no_permissions);
((ListView) rootView.findViewById(android.R.id.list)).setEmptyView(emptyView);
return rootView;
}
+ @Override
+ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ bindUi();
+ }
+
private void bindUi() {
String packageName = getArguments().getString(Intent.EXTRA_PACKAGE_NAME);
@@ -98,7 +115,23 @@ public final class ManagePermissionsFragment extends SettingsWithHeader
}
final PackageManager pm = activity.getPackageManager();
ApplicationInfo appInfo = packageInfo.applicationInfo;
- setHeader(appInfo.loadIcon(pm), appInfo.loadLabel(pm), null);
+ final Drawable icon = appInfo.loadIcon(pm);
+ final CharSequence label = appInfo.loadLabel(pm);
+ setHeader(icon, label, null);
+
+ final ViewGroup rootView = (ViewGroup) getView();
+ final ImageView iconView = (ImageView) rootView.findViewById(R.id.lb_icon);
+ if (iconView != null) {
+ iconView.setImageDrawable(icon);
+ }
+ final TextView titleView = (TextView) rootView.findViewById(R.id.lb_title);
+ if (titleView != null) {
+ titleView.setText(R.string.app_permissions);
+ }
+ final TextView breadcrumbView = (TextView) rootView.findViewById(R.id.lb_breadcrumb);
+ if (breadcrumbView != null) {
+ breadcrumbView.setText(label);
+ }
PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(activity);
mAppPermissions = new AppPermissions(activity, packageInfo, null);
diff --git a/src/com/android/packageinstaller/permission/PermissionManagementFragment.java b/src/com/android/packageinstaller/permission/PermissionManagementFragment.java
index ab1f1919..fbefdc68 100644
--- a/src/com/android/packageinstaller/permission/PermissionManagementFragment.java
+++ b/src/com/android/packageinstaller/permission/PermissionManagementFragment.java
@@ -15,17 +15,26 @@
*/
package com.android.packageinstaller.permission;
+import android.annotation.Nullable;
+import android.app.ActionBar;
import android.content.Context;
import android.content.Intent;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceScreen;
import android.preference.SwitchPreference;
+import android.view.LayoutInflater;
import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
-import com.android.packageinstaller.permission.PermissionApps.PermissionApp;
+import com.android.packageinstaller.R;
import com.android.packageinstaller.permission.PermissionApps.Callback;
+import com.android.packageinstaller.permission.PermissionApps.PermissionApp;
public class PermissionManagementFragment extends SettingsWithHeader implements Callback, OnPreferenceChangeListener {
@@ -43,8 +52,10 @@ public class PermissionManagementFragment extends SettingsWithHeader implements
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
- getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
- bindUi();
+ final ActionBar ab = getActivity().getActionBar();
+ if (ab != null) {
+ ab.setDisplayHomeAsUpEnabled(true);
+ }
}
@Override
@@ -63,10 +74,49 @@ public class PermissionManagementFragment extends SettingsWithHeader implements
return super.onOptionsItemSelected(item);
}
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.permissions_frame, container,
+ false);
+ ViewGroup prefsContainer = (ViewGroup) rootView.findViewById(R.id.prefs_container);
+ if (prefsContainer == null) {
+ prefsContainer = rootView;
+ }
+ prefsContainer.addView(super.onCreateView(inflater, prefsContainer, savedInstanceState));
+ View emptyView = rootView.findViewById(R.id.no_permissions);
+ if (emptyView != null) {
+ emptyView.setVisibility(View.GONE);
+ }
+ return rootView;
+ }
+
+ @Override
+ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ bindUi();
+ }
+
private void bindUi() {
String groupName = getArguments().getString(Intent.EXTRA_PERMISSION_NAME);
mPermissionGroup = new PermissionApps(getActivity(), groupName, this);
- setHeader(mPermissionGroup.getIcon(), mPermissionGroup.getLabel(), null);
+ final Drawable icon = mPermissionGroup.getIcon();
+ final CharSequence label = mPermissionGroup.getLabel();
+ setHeader(icon, label, null);
+
+ final ViewGroup rootView = (ViewGroup) getView();
+ final ImageView iconView = (ImageView) rootView.findViewById(R.id.lb_icon);
+ if (iconView != null) {
+ iconView.setImageDrawable(icon);
+ }
+ final TextView titleView = (TextView) rootView.findViewById(R.id.lb_title);
+ if (titleView != null) {
+ titleView.setText(label);
+ }
+ final TextView breadcrumbView = (TextView) rootView.findViewById(R.id.lb_breadcrumb);
+ if (breadcrumbView != null) {
+ breadcrumbView.setText(R.string.app_permissions);
+ }
}
@Override