summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/drawable/dialog_background.xml22
-rw-r--r--res/layout-television/header.xml47
-rw-r--r--res/layout-television/permissions_frame.xml98
-rw-r--r--res/layout/grant_permissions.xml25
-rw-r--r--res/layout/permission_description.xml7
-rw-r--r--res/values-television/colors.xml2
-rw-r--r--res/values-television/strings.xml7
-rw-r--r--res/values-television/themes.xml6
-rwxr-xr-xsrc/com/android/packageinstaller/UninstallAppProgress.java2
-rw-r--r--src/com/android/packageinstaller/permission/ui/handheld/AppPermissionsFragment.java14
-rw-r--r--src/com/android/packageinstaller/permission/ui/handheld/ManagePermissionsFragment.java17
-rw-r--r--src/com/android/packageinstaller/permission/ui/handheld/PermissionAppsFragment.java16
-rw-r--r--src/com/android/packageinstaller/permission/ui/television/AllAppPermissionsFragment.java2
-rw-r--r--src/com/android/packageinstaller/permission/ui/television/AppPermissionsFragment.java53
-rw-r--r--src/com/android/packageinstaller/permission/ui/television/ManagePermissionsFragment.java39
-rw-r--r--src/com/android/packageinstaller/permission/ui/television/PermissionAppsFragment.java36
-rw-r--r--src/com/android/packageinstaller/permission/ui/television/PermissionsFrameFragment.java49
-rw-r--r--src/com/android/packageinstaller/permission/ui/television/SettingsWithHeader.java37
18 files changed, 218 insertions, 261 deletions
diff --git a/res/drawable/dialog_background.xml b/res/drawable/dialog_background.xml
new file mode 100644
index 00000000..80049529
--- /dev/null
+++ b/res/drawable/dialog_background.xml
@@ -0,0 +1,22 @@
+<?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.
+-->
+
+<inset xmlns:android="http://schemas.android.com/apk/res/android">
+ <shape android:shape="rectangle">
+ <corners android:radius="2dp" />
+ <solid android:color="?android:attr/colorBackground" />
+ </shape>
+</inset>
diff --git a/res/layout-television/header.xml b/res/layout-television/header.xml
new file mode 100644
index 00000000..56e35db7
--- /dev/null
+++ b/res/layout-television/header.xml
@@ -0,0 +1,47 @@
+<!--
+ 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="?attr/defaultBrandColor"
+ android:elevation="@dimen/lb_preference_decor_title_container_elevation"
+ android:orientation="vertical">
+
+ <FrameLayout
+ android:id="@+id/decor_title_container"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="?attr/defaultBrandColor"
+ android:elevation="@dimen/lb_preference_decor_title_container_elevation"
+ android:transitionGroup="false"
+ >
+ <TextView
+ android:id="@+id/decor_title"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/lb_preference_decor_title_text_height"
+ android:layout_marginTop="@dimen/lb_preference_decor_title_margin_top"
+ android:layout_marginStart="@dimen/lb_preference_decor_title_margin_start"
+ android:layout_marginEnd="@dimen/lb_preference_decor_title_margin_end"
+ android:fontFamily="sans-serif-condensed"
+ android:gravity="center_vertical"
+ android:singleLine="true"
+ android:textSize="@dimen/lb_preference_decor_title_text_size"
+ android:textColor="?android:attr/textColorPrimary"
+ />
+ </FrameLayout>
+
+</LinearLayout>
diff --git a/res/layout-television/permissions_frame.xml b/res/layout-television/permissions_frame.xml
index da0b2555..1dcda8d4 100644
--- a/res/layout-television/permissions_frame.xml
+++ b/res/layout-television/permissions_frame.xml
@@ -15,99 +15,33 @@
~ limitations under the License
-->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout 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"
android:filterTouchesWhenObscured="true">
<FrameLayout
- android:layout_width="@dimen/lb_action_section_width"
- android:layout_height="match_parent"
- android:layout_alignParentEnd="true"
- android:background="@color/lb_action_fragment_background">
+ android:layout_width="@dimen/lb_settings_pane_width"
+ android:layout_height="match_parent"
+ android:background="@color/lb_preference_decor_list_background"
+ android:layout_gravity="end">
<FrameLayout
- android:id="@+id/prefs_container"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:id="@+id/prefs_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
<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"
- />
+ 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>
</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="@dimen/lb_content_fragment_icon_width"
- 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>
+</FrameLayout>
diff --git a/res/layout/grant_permissions.xml b/res/layout/grant_permissions.xml
index 185bade5..82823a03 100644
--- a/res/layout/grant_permissions.xml
+++ b/res/layout/grant_permissions.xml
@@ -24,16 +24,16 @@
android:id="@+id/dialog_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:orientation="vertical">
+ android:orientation="vertical"
+ android:background="@drawable/dialog_background">
<FrameLayout
android:id="@+id/desc_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingTop="24dip"
- android:paddingStart="22dip"
- android:paddingEnd="16dip"
- android:background="?android:attr/colorBackgroundFloating">
+ android:paddingTop="18dip"
+ android:paddingStart="20dip"
+ android:paddingEnd="16dip">
<include
layout="@layout/permission_description" />
</FrameLayout>
@@ -42,8 +42,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:paddingBottom="8dip"
- android:paddingStart="22dip"
+ android:paddingStart="20dip"
android:paddingEnd="16dip"
android:background="?android:attr/colorBackgroundFloating">
@@ -52,7 +51,9 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dip"
+ android:layout_marginBottom="-4dp"
android:text="@string/never_ask_again"
+ android:textColor="?android:attr/textColorPrimary"
style="?android:attr/textAppearanceSmall"
android:visibility="gone">
</CheckBox>
@@ -62,15 +63,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
- android:paddingStart="2dip"
- android:paddingTop="16dip">
+ android:paddingStart="6dip"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp"
+ android:gravity="bottom">
<TextView
android:id="@+id/current_page_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:paddingTop="4dp"
- android:paddingBottom="4dp"
+ android:layout_gravity="center_vertical"
android:paddingEnd="12dp"
android:singleLine="true"
style="?android:attr/textAppearanceSmall"
@@ -99,7 +101,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle"
- android:layout_marginStart="8dip"
android:text="@string/grant_dialog_button_allow" >
</Button>
diff --git a/res/layout/permission_description.xml b/res/layout/permission_description.xml
index 2a00e9bf..46b0e7cb 100644
--- a/res/layout/permission_description.xml
+++ b/res/layout/permission_description.xml
@@ -24,7 +24,6 @@
android:id="@+id/permission_icon"
android:layout_width="36dip"
android:layout_height="36dip"
- android:layout_marginTop="3dp"
android:tint="?android:attr/colorAccent"
android:scaleType="fitCenter" >
</ImageView>
@@ -33,11 +32,9 @@
android:id="@+id/permission_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_toRightOf="@id/permission_icon"
- android:layout_marginTop="3dp"
android:paddingStart="16dip"
- android:paddingEnd="8dip"
- style="?android:attr/textAppearanceMedium">
+ android:textSize="20sp"
+ style="@android:style/TextAppearance.Material.Subhead">
</TextView>
</LinearLayout>
diff --git a/res/values-television/colors.xml b/res/values-television/colors.xml
index 08209600..6afe2483 100644
--- a/res/values-television/colors.xml
+++ b/res/values-television/colors.xml
@@ -22,6 +22,8 @@
<color name="lb_action_fragment_background">#FF111111</color>
<color name="lb_dialog_activity_background">#77000000</color>
+ <color name="lb_header_banner_color">#1f292d</color>
+
<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>
diff --git a/res/values-television/strings.xml b/res/values-television/strings.xml
index f1d17469..c11d865c 100644
--- a/res/values-television/strings.xml
+++ b/res/values-television/strings.xml
@@ -28,4 +28,11 @@
<!-- Preference row title for showing system apps. -->
<string name="preference_show_system_apps">Show system apps</string>
+
+ <!--decor title displayed as the page title for different TV permission screens-->
+ <string name="app_permissions_decor_title">App permissions</string>
+ <string name="manage_permissions_decor_title">App permissions</string>
+ <string name="permission_apps_decor_title"><xliff:g id="permission" example="Camera">%1$s</xliff:g> permissions</string>
+ <string name="additional_permissions_decor_title">Additional permissions</string>
+ <string name="system_apps_decor_title"><xliff:g id="permission" example="Camera">%1$s</xliff:g> permissions</string>
</resources>
diff --git a/res/values-television/themes.xml b/res/values-television/themes.xml
index f6946f68..f778fad2 100644
--- a/res/values-television/themes.xml
+++ b/res/values-television/themes.xml
@@ -17,7 +17,11 @@
<resources>
<style name="Settings" parent="Theme.Leanback">
- <item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Permissions</item>
+ <item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Leanback</item>
+ <item name="android:windowBackground">@android:color/transparent</item>
+ <item name="android:windowIsTranslucent">true</item>
+ <item name="android:backgroundDimEnabled">true</item>
+ <item name="android:backgroundDimAmount">0.8</item>
</style>
<style name="GrantPermissions" parent="Theme.Leanback">
diff --git a/src/com/android/packageinstaller/UninstallAppProgress.java b/src/com/android/packageinstaller/UninstallAppProgress.java
index e9c058f6..3a178273 100755
--- a/src/com/android/packageinstaller/UninstallAppProgress.java
+++ b/src/com/android/packageinstaller/UninstallAppProgress.java
@@ -262,7 +262,7 @@ public class UninstallAppProgress extends Activity implements OnClickListener {
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
getPackageManager().deletePackageAsUser(mAppInfo.packageName, observer,
- mUser.getIdentifier(), mAllUsers ? PackageManager.DELETE_ALL_USERS : 0);
+ mAllUsers ? PackageManager.DELETE_ALL_USERS : 0, mUser.getIdentifier());
mHandler.sendMessageDelayed(mHandler.obtainMessage(UNINSTALL_IS_SLOW),
QUICK_INSTALL_DELAY_MILLIS);
diff --git a/src/com/android/packageinstaller/permission/ui/handheld/AppPermissionsFragment.java b/src/com/android/packageinstaller/permission/ui/handheld/AppPermissionsFragment.java
index 7ff01fb8..3716293e 100644
--- a/src/com/android/packageinstaller/permission/ui/handheld/AppPermissionsFragment.java
+++ b/src/com/android/packageinstaller/permission/ui/handheld/AppPermissionsFragment.java
@@ -177,20 +177,6 @@ public final class AppPermissionsFragment extends SettingsWithHeader
if (ab != null) {
ab.setTitle(R.string.app_permissions);
}
-
- ViewGroup rootView = (ViewGroup) fragment.getView();
- ImageView iconView = (ImageView) rootView.findViewById(R.id.lb_icon);
- if (iconView != null) {
- iconView.setImageDrawable(icon);
- }
- TextView titleView = (TextView) rootView.findViewById(R.id.lb_title);
- if (titleView != null) {
- titleView.setText(R.string.app_permissions);
- }
- TextView breadcrumbView = (TextView) rootView.findViewById(R.id.lb_breadcrumb);
- if (breadcrumbView != null) {
- breadcrumbView.setText(label);
- }
}
private void loadPreferences() {
diff --git a/src/com/android/packageinstaller/permission/ui/handheld/ManagePermissionsFragment.java b/src/com/android/packageinstaller/permission/ui/handheld/ManagePermissionsFragment.java
index f5d7020e..8994cf5d 100644
--- a/src/com/android/packageinstaller/permission/ui/handheld/ManagePermissionsFragment.java
+++ b/src/com/android/packageinstaller/permission/ui/handheld/ManagePermissionsFragment.java
@@ -124,23 +124,6 @@ public final class ManagePermissionsFragment extends PermissionsFrameFragment
if (context == null || rootView == null) {
return;
}
-
- ImageView iconView = (ImageView) rootView.findViewById(R.id.lb_icon);
- if (iconView != null) {
- // Set the icon as the background instead of the image because ImageView
- // doesn't properly scale vector drawables beyond their intrinsic size
- Drawable icon = context.getDrawable(R.drawable.ic_lock);
- icon.setTint(context.getColor(R.color.off_white));
- iconView.setBackground(icon);
- }
- TextView titleView = (TextView) rootView.findViewById(R.id.lb_title);
- if (titleView != null) {
- titleView.setText(R.string.app_permissions);
- }
- TextView breadcrumbView = (TextView) rootView.findViewById(R.id.lb_breadcrumb);
- if (breadcrumbView != null) {
- breadcrumbView.setText(R.string.app_permissions_breadcrumb);
- }
}
private void updatePermissionsUi() {
diff --git a/src/com/android/packageinstaller/permission/ui/handheld/PermissionAppsFragment.java b/src/com/android/packageinstaller/permission/ui/handheld/PermissionAppsFragment.java
index 25689006..1502fcbc 100644
--- a/src/com/android/packageinstaller/permission/ui/handheld/PermissionAppsFragment.java
+++ b/src/com/android/packageinstaller/permission/ui/handheld/PermissionAppsFragment.java
@@ -155,22 +155,6 @@ public final class PermissionAppsFragment extends PermissionsFrameFragment imple
if (ab != null) {
ab.setTitle(fragment.getString(R.string.permission_title, label));
}
-
- final ViewGroup rootView = (ViewGroup) fragment.getView();
- final ImageView iconView = (ImageView) rootView.findViewById(R.id.lb_icon);
- if (iconView != null) {
- // Set the icon as the background instead of the image because ImageView
- // doesn't properly scale vector drawables beyond their intrinsic size
- iconView.setBackground(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);
- }
}
private void setOnPermissionsLoadedListener(Callback callback) {
diff --git a/src/com/android/packageinstaller/permission/ui/television/AllAppPermissionsFragment.java b/src/com/android/packageinstaller/permission/ui/television/AllAppPermissionsFragment.java
index db99538c..7a40856f 100644
--- a/src/com/android/packageinstaller/permission/ui/television/AllAppPermissionsFragment.java
+++ b/src/com/android/packageinstaller/permission/ui/television/AllAppPermissionsFragment.java
@@ -139,7 +139,7 @@ public final class AllAppPermissionsFragment extends SettingsWithHeader {
infoIntent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
.setData(Uri.fromParts("package", mPackageInfo.packageName, null));
}
- setHeader(icon, label, infoIntent);
+ setHeader(icon, label, infoIntent, null);
if (mPackageInfo.requestedPermissions != null) {
for (int i = 0; i < mPackageInfo.requestedPermissions.length; i++) {
diff --git a/src/com/android/packageinstaller/permission/ui/television/AppPermissionsFragment.java b/src/com/android/packageinstaller/permission/ui/television/AppPermissionsFragment.java
index 53b23a21..7b2ff566 100644
--- a/src/com/android/packageinstaller/permission/ui/television/AppPermissionsFragment.java
+++ b/src/com/android/packageinstaller/permission/ui/television/AppPermissionsFragment.java
@@ -28,25 +28,27 @@ import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
+import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
+import android.support.v17.leanback.widget.VerticalGridView;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
import android.support.v7.preference.Preference.OnPreferenceClickListener;
import android.support.v7.preference.PreferenceScreen;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
-
import com.android.packageinstaller.R;
import com.android.packageinstaller.permission.model.AppPermissionGroup;
import com.android.packageinstaller.permission.model.AppPermissions;
@@ -103,6 +105,7 @@ public final class AppPermissionsFragment extends SettingsWithHeader
return;
}
+
mAppPermissions = new AppPermissions(activity, packageInfo, null, true, new Runnable() {
@Override
public void run() {
@@ -176,25 +179,18 @@ public final class AppPermissionsFragment extends SettingsWithHeader
Drawable icon = appInfo.loadIcon(pm);
CharSequence label = appInfo.loadLabel(pm);
- fragment.setHeader(icon, label, infoIntent);
+ fragment.setHeader(icon, label, infoIntent, fragment.getString(
+ R.string.app_permissions_decor_title));
+ }
- ActionBar ab = activity.getActionBar();
- if (ab != null) {
- ab.setTitle(R.string.app_permissions);
- }
+ @Override
+ protected void updateHeader() {
- ViewGroup rootView = (ViewGroup) fragment.getView();
- ImageView iconView = (ImageView) rootView.findViewById(R.id.lb_icon);
- if (iconView != null) {
- iconView.setImageDrawable(icon);
- }
- TextView titleView = (TextView) rootView.findViewById(R.id.lb_title);
- if (titleView != null) {
- titleView.setText(R.string.app_permissions);
- }
- TextView breadcrumbView = (TextView) rootView.findViewById(R.id.lb_breadcrumb);
- if (breadcrumbView != null) {
- breadcrumbView.setText(label);
+ super.updateHeader();
+ Preference headerLineTwo = getPreferenceScreen().findPreference(HEADER_PREFERENCE_KEY);
+ if (headerLineTwo != null) {
+ headerLineTwo.setTitle(mLabel);
+ headerLineTwo.setIcon(mIcon);
}
}
@@ -207,6 +203,22 @@ public final class AppPermissionsFragment extends SettingsWithHeader
PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
+ // Setting the second-line header that contains the app banner icon and its name.
+ // The styling used is the same as a leanback preference with a customized background color.
+ Preference headerLineTwo = new Preference(context) {
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder holder) {
+ super.onBindViewHolder(holder);
+ holder.itemView.setBackgroundColor(
+ getResources().getColor(R.color.lb_header_banner_color));
+ }
+ };
+ headerLineTwo.setKey(HEADER_PREFERENCE_KEY);
+ headerLineTwo.setSelectable(false);
+ headerLineTwo.setTitle(mLabel);
+ headerLineTwo.setIcon(mIcon);
+ screen.addPreference(headerLineTwo);
+
if (mExtraScreen != null) {
mExtraScreen.removeAll();
}
@@ -379,7 +391,8 @@ public final class AppPermissionsFragment extends SettingsWithHeader
public void onCreate(Bundle savedInstanceState) {
mOuterFragment = (AppPermissionsFragment) getTargetFragment();
super.onCreate(savedInstanceState);
- setHeader(mOuterFragment.mIcon, mOuterFragment.mLabel, mOuterFragment.mInfoIntent);
+ setHeader(mOuterFragment.mIcon, mOuterFragment.mLabel, mOuterFragment.mInfoIntent,
+ null);
setHasOptionsMenu(true);
}
diff --git a/src/com/android/packageinstaller/permission/ui/television/ManagePermissionsFragment.java b/src/com/android/packageinstaller/permission/ui/television/ManagePermissionsFragment.java
index 81550337..fd84edd7 100644
--- a/src/com/android/packageinstaller/permission/ui/television/ManagePermissionsFragment.java
+++ b/src/com/android/packageinstaller/permission/ui/television/ManagePermissionsFragment.java
@@ -42,7 +42,7 @@ import com.android.packageinstaller.util.Utils;
import java.util.List;
-public final class ManagePermissionsFragment extends PermissionsFrameFragment
+public final class ManagePermissionsFragment extends SettingsWithHeader
implements PermissionGroups.PermissionsGroupsChangeCallback, OnPreferenceClickListener {
private static final String LOG_TAG = "ManagePermissionsFragment";
@@ -117,30 +117,15 @@ public final class ManagePermissionsFragment extends PermissionsFrameFragment
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- bindPermissionUi(getActivity(), getView());
+ bindPermissionUi(this, getView());
}
- private static void bindPermissionUi(@Nullable Context context, @Nullable View rootView) {
- if (context == null || rootView == null) {
+ private static void bindPermissionUi(SettingsWithHeader fragment, @Nullable View rootView) {
+ if (fragment == null || rootView == null) {
return;
}
-
- ImageView iconView = (ImageView) rootView.findViewById(R.id.lb_icon);
- if (iconView != null) {
- // Set the icon as the background instead of the image because ImageView
- // doesn't properly scale vector drawables beyond their intrinsic size
- Drawable icon = context.getDrawable(R.drawable.ic_lock);
- icon.setTint(context.getColor(R.color.off_white));
- iconView.setBackground(icon);
- }
- TextView titleView = (TextView) rootView.findViewById(R.id.lb_title);
- if (titleView != null) {
- titleView.setText(R.string.app_permissions);
- }
- TextView breadcrumbView = (TextView) rootView.findViewById(R.id.lb_breadcrumb);
- if (breadcrumbView != null) {
- breadcrumbView.setText(R.string.app_permissions_breadcrumb);
- }
+ fragment.setHeader(null, null, null, fragment.getString(
+ R.string.manage_permissions_decor_title));
}
private void updatePermissionsUi() {
@@ -227,7 +212,7 @@ public final class ManagePermissionsFragment extends PermissionsFrameFragment
}
}
- public static class AdditionalPermissionsFragment extends PermissionsFrameFragment {
+ public static class AdditionalPermissionsFragment extends SettingsWithHeader {
@Override
public void onCreate(Bundle icicle) {
setLoading(true /* loading */, false /* animate */);
@@ -255,7 +240,15 @@ public final class ManagePermissionsFragment extends PermissionsFrameFragment
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- bindPermissionUi(getActivity(), getView());
+ bindPermissionUi(this, getView());
+ }
+
+ private static void bindPermissionUi(SettingsWithHeader fragment, @Nullable View rootView) {
+ if (fragment == null || rootView == null) {
+ return;
+ }
+ fragment.setHeader(null, null, null,
+ fragment.getString(R.string.additional_permissions_decor_title));
}
@Override
diff --git a/src/com/android/packageinstaller/permission/ui/television/PermissionAppsFragment.java b/src/com/android/packageinstaller/permission/ui/television/PermissionAppsFragment.java
index 5a3346fc..4fde4756 100644
--- a/src/com/android/packageinstaller/permission/ui/television/PermissionAppsFragment.java
+++ b/src/com/android/packageinstaller/permission/ui/television/PermissionAppsFragment.java
@@ -15,6 +15,7 @@
*/
package com.android.packageinstaller.permission.ui.television;
+import android.annotation.Nullable;
import android.app.ActionBar;
import android.app.AlertDialog;
import android.app.Fragment;
@@ -53,7 +54,7 @@ import com.android.packageinstaller.util.Utils;
import java.util.ArrayList;
import java.util.List;
-public final class PermissionAppsFragment extends PermissionsFrameFragment implements Callback,
+public final class PermissionAppsFragment extends SettingsWithHeader implements Callback,
OnPreferenceChangeListener {
private static final int MENU_SHOW_SYSTEM = Menu.FIRST;
@@ -150,29 +151,12 @@ public final class PermissionAppsFragment extends PermissionsFrameFragment imple
bindUi(this, mPermissionApps);
}
- private static void bindUi(Fragment fragment, PermissionApps permissionApps) {
+ private static void bindUi(SettingsWithHeader fragment, PermissionApps permissionApps) {
final Drawable icon = permissionApps.getIcon();
final CharSequence label = permissionApps.getLabel();
- final ActionBar ab = fragment.getActivity().getActionBar();
- if (ab != null) {
- ab.setTitle(fragment.getString(R.string.permission_title, label));
- }
- final ViewGroup rootView = (ViewGroup) fragment.getView();
- final ImageView iconView = (ImageView) rootView.findViewById(R.id.lb_icon);
- if (iconView != null) {
- // Set the icon as the background instead of the image because ImageView
- // doesn't properly scale vector drawables beyond their intrinsic size
- iconView.setBackground(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);
- }
+ fragment.setHeader(null, null, null,
+ fragment.getString(R.string.permission_apps_decor_title, label));
}
private void setOnPermissionsLoadedListener(Callback callback) {
@@ -397,7 +381,7 @@ public final class PermissionAppsFragment extends PermissionsFrameFragment imple
}
}
- public static class SystemAppsFragment extends PermissionsFrameFragment implements Callback {
+ public static class SystemAppsFragment extends SettingsWithHeader implements Callback {
PermissionAppsFragment mOuterFragment;
@Override
@@ -424,6 +408,14 @@ public final class PermissionAppsFragment extends PermissionsFrameFragment imple
bindUi(this, permissionApps);
}
+
+ private static void bindUi(SettingsWithHeader fragment, PermissionApps permissionApps) {
+ final CharSequence label = permissionApps.getLabel();
+ fragment.setHeader(null, null, null,
+ fragment.getString(R.string.system_apps_decor_title, label));
+ }
+
+
@Override
public void onPermissionsLoaded(PermissionApps permissionApps) {
setPreferenceScreen();
diff --git a/src/com/android/packageinstaller/permission/ui/television/PermissionsFrameFragment.java b/src/com/android/packageinstaller/permission/ui/television/PermissionsFrameFragment.java
index 2c7b91e9..953cde4e 100644
--- a/src/com/android/packageinstaller/permission/ui/television/PermissionsFrameFragment.java
+++ b/src/com/android/packageinstaller/permission/ui/television/PermissionsFrameFragment.java
@@ -22,7 +22,6 @@ import android.support.v14.preference.PreferenceFragment;
import android.support.v17.leanback.widget.VerticalGridView;
import android.support.v7.preference.PreferenceScreen;
import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.RecyclerView.AdapterDataObserver;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -30,18 +29,19 @@ import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
-
import com.android.packageinstaller.DeviceUtils;
import com.android.packageinstaller.R;
public abstract class PermissionsFrameFragment extends PreferenceFragment {
- private static final float WINDOW_ALIGNMENT_OFFSET_PERCENT = 50;
+ // Key identifying the preference used on TV as the extra header in a permission fragment.
+ // This is to distinguish it from the rest of the preferences
+ protected static final String HEADER_PREFERENCE_KEY = "HeaderPreferenceKey";
private ViewGroup mPreferencesContainer;
- // TV-specific instance variables
- @Nullable private VerticalGridView mGridView;
+ // TV-specific instance variable
+ @Nullable private RecyclerView mGridView;
private View mLoadingView;
private ViewGroup mPrefsView;
@@ -132,18 +132,13 @@ public abstract class PermissionsFrameFragment extends PreferenceFragment {
@Override
public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent,
- Bundle savedInstanceState) {
- if (DeviceUtils.isTelevision(getContext())) {
- mGridView = (VerticalGridView) inflater.inflate(
- R.layout.leanback_preferences_list, parent, false);
- mGridView.setWindowAlignmentOffset(0);
- mGridView.setWindowAlignmentOffsetPercent(WINDOW_ALIGNMENT_OFFSET_PERCENT);
- mGridView.setWindowAlignment(VerticalGridView.WINDOW_ALIGN_NO_EDGE);
- mGridView.setFocusScrollStrategy(VerticalGridView.FOCUS_SCROLL_ALIGNED);
- return mGridView;
- } else {
- return super.onCreateRecyclerView(inflater, parent, savedInstanceState);
- }
+ Bundle savedInstanceState) {
+ VerticalGridView verticalGridView = (VerticalGridView) inflater.inflate(
+ R.layout.leanback_preferences_list, parent, false);
+ verticalGridView.setWindowAlignment(VerticalGridView.WINDOW_ALIGN_BOTH_EDGE);
+ verticalGridView.setFocusScrollStrategy(VerticalGridView.FOCUS_SCROLL_ALIGNED);
+ mGridView = verticalGridView;
+ return mGridView;
}
@Override
@@ -154,7 +149,7 @@ public abstract class PermissionsFrameFragment extends PreferenceFragment {
final TextView emptyView = (TextView) getView().findViewById(R.id.no_permissions);
onSetEmptyText(emptyView);
final RecyclerView recyclerView = getListView();
- adapter.registerAdapterDataObserver(new AdapterDataObserver() {
+ adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
@Override
public void onChanged() {
checkEmpty();
@@ -171,18 +166,20 @@ public abstract class PermissionsFrameFragment extends PreferenceFragment {
}
private void checkEmpty() {
- boolean isEmpty = adapter.getItemCount() == 0;
+ boolean isEmpty = isPreferenceListEmpty();
emptyView.setVisibility(isEmpty ? View.VISIBLE : View.GONE);
- recyclerView.setVisibility(isEmpty ? View.GONE : View.VISIBLE);
+ recyclerView.setVisibility(isEmpty && adapter.getItemCount() == 0 ?
+ View.GONE : View.VISIBLE);
if (!isEmpty && mGridView != null) {
mGridView.requestFocus();
}
}
});
- boolean isEmpty = adapter.getItemCount() == 0;
+ boolean isEmpty = isPreferenceListEmpty();
emptyView.setVisibility(isEmpty ? View.VISIBLE : View.GONE);
- recyclerView.setVisibility(isEmpty ? View.GONE : View.VISIBLE);
+ recyclerView.setVisibility(isEmpty && adapter.getItemCount() == 0 ?
+ View.GONE : View.VISIBLE);
if (!isEmpty && mGridView != null) {
mGridView.requestFocus();
}
@@ -191,6 +188,13 @@ public abstract class PermissionsFrameFragment extends PreferenceFragment {
return adapter;
}
+ private boolean isPreferenceListEmpty() {
+ PreferenceScreen screen = getPreferenceScreen();
+ return screen.getPreferenceCount() == 0 || (
+ screen.getPreferenceCount() == 1 &&
+ (screen.findPreference(HEADER_PREFERENCE_KEY) != null));
+ }
+
/**
* Hook for subclasses to change the default text of the empty view.
* Base implementation leaves the default empty view text.
@@ -200,4 +204,3 @@ public abstract class PermissionsFrameFragment extends PreferenceFragment {
protected void onSetEmptyText(TextView textView) {
}
}
-
diff --git a/src/com/android/packageinstaller/permission/ui/television/SettingsWithHeader.java b/src/com/android/packageinstaller/permission/ui/television/SettingsWithHeader.java
index a401426d..06f7c142 100644
--- a/src/com/android/packageinstaller/permission/ui/television/SettingsWithHeader.java
+++ b/src/com/android/packageinstaller/permission/ui/television/SettingsWithHeader.java
@@ -25,7 +25,6 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
-
import com.android.packageinstaller.DeviceUtils;
import com.android.packageinstaller.R;
@@ -36,50 +35,40 @@ public abstract class SettingsWithHeader extends PermissionsFrameFragment
protected Intent mInfoIntent;
protected Drawable mIcon;
protected CharSequence mLabel;
+ protected CharSequence mDecorTitle;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ViewGroup root = (ViewGroup) super.onCreateView(inflater, container, savedInstanceState);
- if (!DeviceUtils.isTelevision(getContext())) {
- mHeader = inflater.inflate(R.layout.header, root, false);
- getPreferencesContainer().addView(mHeader, 0);
- updateHeader();
- }
+ mHeader = inflater.inflate(R.layout.header, root, false);
+ getPreferencesContainer().addView(mHeader, 0);
+ updateHeader();
return root;
}
- public void setHeader(Drawable icon, CharSequence label, Intent infoIntent) {
+ public void setHeader(Drawable icon, CharSequence label, Intent infoIntent,
+ CharSequence decorTitle) {
mIcon = icon;
mLabel = label;
mInfoIntent = infoIntent;
+ mDecorTitle = decorTitle;
updateHeader();
}
- private void updateHeader() {
- if (mHeader != null) {
- final ImageView appIcon = (ImageView) mHeader.findViewById(R.id.icon);
- appIcon.setImageDrawable(mIcon);
-
- final TextView appName = (TextView) mHeader.findViewById(R.id.name);
- appName.setText(mLabel);
+ public View getHeader() {
+ return mHeader;
+ }
- final View info = mHeader.findViewById(R.id.info);
- if (mInfoIntent == null) {
- info.setVisibility(View.GONE);
- } else {
- info.setVisibility(View.VISIBLE);
- info.setClickable(true);
- info.setOnClickListener(this);
- }
- }
+ protected void updateHeader() {
+ final TextView decorTitle = (TextView) mHeader.findViewById(R.id.decor_title);
+ decorTitle.setText(mDecorTitle);
}
@Override
public void onClick(View v) {
getActivity().startActivity(mInfoIntent);
}
-
}