Layout refinement for app lists
Make all app lists (or at least all current app lists) use the same base layout for icon, label, and sizing/padding. This way they should look the same. Bug: 21727125 Bug: 21726922 Bug: 21853632 Change-Id: I3cffadb9e7b5184d4209deacd4ea70ec1d4f71b4
This commit is contained in:
@@ -17,19 +17,19 @@
|
|||||||
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
android:minHeight="72dp"
|
||||||
android:paddingTop="14dp"
|
android:paddingTop="16dp"
|
||||||
android:paddingBottom="14dp"
|
android:paddingBottom="16dp"
|
||||||
android:columnCount="3">
|
android:columnCount="3">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@android:id/icon"
|
android:id="@android:id/icon"
|
||||||
android:layout_width="40dp"
|
android:layout_width="@dimen/app_icon_size"
|
||||||
android:layout_height="40dp"
|
android:layout_height="@dimen/app_icon_size"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:scaleType="fitXY"
|
android:scaleType="fitXY"
|
||||||
android:layout_rowSpan="3"
|
android:layout_rowSpan="3"
|
||||||
android:layout_marginEnd="8dip"
|
android:layout_marginEnd="16dip"
|
||||||
android:contentDescription="@null" />
|
android:contentDescription="@null" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -44,30 +44,18 @@
|
|||||||
android:textAlignment="viewStart" />
|
android:textAlignment="viewStart" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@android:id/text1"
|
android:id="@android:id/summary"
|
||||||
android:layout_marginStart="6dip"
|
android:layout_marginStart="6dip"
|
||||||
android:layout_marginTop="2dip"
|
android:layout_marginTop="2dip"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="marquee"
|
||||||
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
|
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
|
||||||
android:textColor="?android:attr/textColorSecondary" />
|
android:textColor="?android:attr/textColorSecondary" />
|
||||||
|
|
||||||
<ProgressBar
|
<FrameLayout
|
||||||
android:id="@android:id/progress"
|
android:id="@android:id/widget_frame"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_columnSpan="2"
|
android:layout_columnSpan="2"
|
||||||
android:layout_gravity="fill_horizontal|top"
|
android:layout_gravity="fill_horizontal|top" />
|
||||||
android:layout_marginTop="4dip"
|
|
||||||
android:max="100"
|
|
||||||
android:progressBackgroundTint="@android:color/transparent"
|
|
||||||
style="?android:attr/progressBarStyleHorizontal" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@android:id/summary"
|
|
||||||
android:layout_width="0dip"
|
|
||||||
android:layout_gravity="fill_horizontal|top"
|
|
||||||
android:layout_columnSpan="2"
|
|
||||||
android:layout_marginTop="6dip"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:maxLines="2"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
|
||||||
|
|
||||||
</GridLayout>
|
</GridLayout>
|
@@ -1,79 +0,0 @@
|
|||||||
<?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"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
|
||||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
|
||||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
|
||||||
android:paddingTop="8dip"
|
|
||||||
android:paddingBottom="8dip">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@android:id/icon"
|
|
||||||
android:layout_width="@android:dimen/app_icon_size"
|
|
||||||
android:layout_height="@android:dimen/app_icon_size"
|
|
||||||
android:layout_marginEnd="8dip"
|
|
||||||
android:scaleType="centerInside"
|
|
||||||
android:contentDescription="@null"
|
|
||||||
android:duplicateParentState="true" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/text_area"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_toEndOf="@android:id/icon"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:duplicateParentState="true">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@android:id/title"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_marginTop="2dip"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:ellipsize="marquee"
|
|
||||||
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
|
|
||||||
android:textAlignment="viewStart"
|
|
||||||
android:duplicateParentState="true" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@android:id/summary"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:textAppearance="@android:style/TextAppearance.Material.Body1"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
android:gravity="end|bottom"
|
|
||||||
android:duplicateParentState="true" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<com.android.settings.applications.LinearColorBar
|
|
||||||
android:id="@+id/linear_color_bar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="10dp"
|
|
||||||
android:layout_marginTop="7dp"
|
|
||||||
android:layout_marginBottom="5dp"
|
|
||||||
android:layout_toEndOf="@android:id/icon"
|
|
||||||
android:layout_below="@id/text_area"
|
|
||||||
android:duplicateParentState="true" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
<!-- Application snippet label, version and icon -->
|
<!-- Application snippet label, version and icon -->
|
||||||
<include
|
<include
|
||||||
layout="@layout/manage_applications_item"
|
layout="@layout/app_item"
|
||||||
android:id="@+id/app_snippet" />
|
android:id="@+id/app_snippet" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@@ -20,6 +20,6 @@
|
|||||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||||
|
|
||||||
<include layout="@layout/app_percentage_item" />
|
<include layout="@layout/app_item" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
<!-- Application snippet label, version and icon -->
|
<!-- Application snippet label, version and icon -->
|
||||||
<include
|
<include
|
||||||
layout="@layout/manage_applications_item"
|
layout="@layout/app_item"
|
||||||
android:id="@+id/app_snippet" />
|
android:id="@+id/app_snippet" />
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
|
@@ -1,85 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
/*
|
|
||||||
** Copyright 2008, 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.
|
|
||||||
*/
|
|
||||||
-->
|
|
||||||
|
|
||||||
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:minHeight="72dp"
|
|
||||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
|
||||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
|
||||||
android:paddingTop="16dip"
|
|
||||||
android:paddingBottom="16dip"
|
|
||||||
android:columnCount="4">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/app_icon"
|
|
||||||
android:layout_width="@dimen/app_icon_size"
|
|
||||||
android:layout_height="@dimen/app_icon_size"
|
|
||||||
android:layout_rowSpan="2"
|
|
||||||
android:layout_marginEnd="16dip"
|
|
||||||
android:scaleType="centerInside"
|
|
||||||
android:contentDescription="@null"
|
|
||||||
android:duplicateParentState="true" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/app_name"
|
|
||||||
android:layout_width="0dip"
|
|
||||||
android:layout_columnSpan="2"
|
|
||||||
android:layout_gravity="fill_horizontal"
|
|
||||||
android:layout_marginTop="2dip"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:ellipsize="marquee"
|
|
||||||
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
|
|
||||||
android:textAlignment="viewStart"
|
|
||||||
android:duplicateParentState="true" />
|
|
||||||
|
|
||||||
<CheckBox android:id="@+id/app_on_sdcard"
|
|
||||||
android:layout_marginStart="8dip"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_rowSpan="2"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:clickable="false"
|
|
||||||
android:focusable="false"
|
|
||||||
android:duplicateParentState="true" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/app_summary"
|
|
||||||
android:layout_column="1"
|
|
||||||
android:layout_row="1"
|
|
||||||
android:layout_gravity="fill_horizontal|top"
|
|
||||||
android:textAppearance="@android:style/TextAppearance.Material.Body1"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
android:textAlignment="viewStart"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:ellipsize="marquee"
|
|
||||||
android:duplicateParentState="true" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/app_disabled"
|
|
||||||
android:layout_width="0dip"
|
|
||||||
android:layout_marginStart="8dip"
|
|
||||||
android:layout_gravity="fill_horizontal|top"
|
|
||||||
android:textAppearance="@android:style/TextAppearance.Material.Body1"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
android:textAlignment="viewEnd"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:ellipsize="marquee"
|
|
||||||
android:duplicateParentState="true" />
|
|
||||||
|
|
||||||
</GridLayout>
|
|
@@ -20,6 +20,6 @@
|
|||||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||||
|
|
||||||
<include layout="@layout/app_percentage_item" />
|
<include layout="@layout/app_item" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
80
res/layout/preference_material_settings.xml
Normal file
80
res/layout/preference_material_settings.xml
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Based off frameworks/base/core/res/res/layout/preference_material.xml
|
||||||
|
except that this has the negative margin on the image removed. -->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||||
|
android:background="?android:attr/activatedBackgroundIndicator"
|
||||||
|
android:clipToPadding="false">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@*android:id/icon_frame"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minWidth="60dp"
|
||||||
|
android:gravity="start|center_vertical"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingEnd="12dp"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
android:paddingBottom="4dp">
|
||||||
|
<com.android.internal.widget.PreferenceImageView
|
||||||
|
android:id="@android:id/icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:maxWidth="48dp"
|
||||||
|
android:maxHeight="48dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:paddingBottom="16dp">
|
||||||
|
|
||||||
|
<TextView android:id="@android:id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||||
|
android:ellipsize="marquee" />
|
||||||
|
|
||||||
|
<TextView android:id="@android:id/summary"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@android:id/title"
|
||||||
|
android:layout_alignStart="@android:id/title"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:maxLines="10" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<!-- Preference should place its actual preference widget here. -->
|
||||||
|
<LinearLayout android:id="@android:id/widget_frame"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="end|center_vertical"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:orientation="vertical" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
23
res/layout/widget_progress_bar.xml
Normal file
23
res/layout/widget_progress_bar.xml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@android:id/progress"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:max="100"
|
||||||
|
style="?android:attr/progressBarStyleHorizontal" />
|
49
res/layout/widget_text_views.xml
Normal file
49
res/layout/widget_text_views.xml
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?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:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/widget_text1"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_gravity="fill_horizontal|top"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Body1"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
android:duplicateParentState="true" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/widget_text2"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginStart="8dip"
|
||||||
|
android:layout_gravity="fill_horizontal|top"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Body1"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:textAlignment="viewEnd"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
android:duplicateParentState="true" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@@ -93,6 +93,10 @@
|
|||||||
<item name="android:windowContentOverlay">@null</item>
|
<item name="android:windowContentOverlay">@null</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Preference">
|
||||||
|
<item name="android:layout">@layout/preference_material_settings</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="PreferenceHeaderPanelSinglePane">
|
<style name="PreferenceHeaderPanelSinglePane">
|
||||||
<item name="android:layout_marginStart">0dp</item>
|
<item name="android:layout_marginStart">0dp</item>
|
||||||
<item name="android:layout_marginEnd">0dp</item>
|
<item name="android:layout_marginEnd">0dp</item>
|
||||||
|
@@ -80,6 +80,7 @@
|
|||||||
<style name="Theme.SettingsBase" parent="@android:style/Theme.Material.Settings" />
|
<style name="Theme.SettingsBase" parent="@android:style/Theme.Material.Settings" />
|
||||||
|
|
||||||
<style name="Theme.Settings" parent="Theme.SettingsBase">
|
<style name="Theme.Settings" parent="Theme.SettingsBase">
|
||||||
|
<item name="@*android:preferenceStyle">@style/Preference</item>
|
||||||
<item name="@*android:preferenceHeaderPanelStyle">@style/PreferenceHeaderPanelSinglePane</item>
|
<item name="@*android:preferenceHeaderPanelStyle">@style/PreferenceHeaderPanelSinglePane</item>
|
||||||
<item name="@*android:preferencePanelStyle">@style/PreferencePanelSinglePane</item>
|
<item name="@*android:preferencePanelStyle">@style/PreferencePanelSinglePane</item>
|
||||||
<item name="@*android:preferenceListStyle">@style/PreferenceHeaderListSinglePane</item>
|
<item name="@*android:preferenceListStyle">@style/PreferenceHeaderListSinglePane</item>
|
||||||
|
@@ -164,7 +164,6 @@ public class AppPicker extends ListActivity {
|
|||||||
holder.summary.setText("");
|
holder.summary.setText("");
|
||||||
}
|
}
|
||||||
holder.disabled.setVisibility(View.GONE);
|
holder.disabled.setVisibility(View.GONE);
|
||||||
holder.checkBox.setVisibility(View.GONE);
|
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
45
src/com/android/settings/AppProgressPreference.java
Normal file
45
src/com/android/settings/AppProgressPreference.java
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
package com.android.settings;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
|
||||||
|
public class AppProgressPreference extends TintablePreference {
|
||||||
|
|
||||||
|
private int mProgress;
|
||||||
|
|
||||||
|
public AppProgressPreference(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
setLayoutResource(R.layout.preference_app);
|
||||||
|
setWidgetLayoutResource(R.layout.widget_progress_bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProgress(int amount) {
|
||||||
|
mProgress = amount;
|
||||||
|
notifyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onBindView(View view) {
|
||||||
|
super.onBindView(view);
|
||||||
|
|
||||||
|
final ProgressBar progress = (ProgressBar) view.findViewById(android.R.id.progress);
|
||||||
|
progress.setProgress(mProgress);
|
||||||
|
}
|
||||||
|
}
|
@@ -1882,10 +1882,10 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
|||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
final AppItem item = mItems.get(position);
|
final AppItem item = mItems.get(position);
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||||
if (getItemViewType(position) == 1) {
|
if (getItemViewType(position) == 1) {
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = Utils.inflateCategoryHeader(LayoutInflater.from(
|
convertView = Utils.inflateCategoryHeader(inflater, parent);
|
||||||
parent.getContext()), parent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final TextView title = (TextView) convertView.findViewById(android.R.id.title);
|
final TextView title = (TextView) convertView.findViewById(android.R.id.title);
|
||||||
@@ -1893,8 +1893,9 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = LayoutInflater.from(parent.getContext()).inflate(
|
convertView = inflater.inflate(R.layout.data_usage_item, parent, false);
|
||||||
R.layout.data_usage_item, parent, false);
|
inflater.inflate(R.layout.widget_progress_bar,
|
||||||
|
(ViewGroup) convertView.findViewById(android.R.id.widget_frame));
|
||||||
|
|
||||||
if (mInsetSide > 0) {
|
if (mInsetSide > 0) {
|
||||||
convertView.setPaddingRelative(mInsetSide, 0, mInsetSide, 0);
|
convertView.setPaddingRelative(mInsetSide, 0, mInsetSide, 0);
|
||||||
@@ -1903,7 +1904,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
|||||||
|
|
||||||
final Context context = parent.getContext();
|
final Context context = parent.getContext();
|
||||||
|
|
||||||
final TextView text1 = (TextView) convertView.findViewById(android.R.id.text1);
|
final TextView summary = (TextView) convertView.findViewById(android.R.id.summary);
|
||||||
final ProgressBar progress = (ProgressBar) convertView.findViewById(
|
final ProgressBar progress = (ProgressBar) convertView.findViewById(
|
||||||
android.R.id.progress);
|
android.R.id.progress);
|
||||||
|
|
||||||
@@ -1911,10 +1912,10 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
|||||||
UidDetailTask.bindView(mProvider, item, convertView);
|
UidDetailTask.bindView(mProvider, item, convertView);
|
||||||
|
|
||||||
if (item.restricted && item.total <= 0) {
|
if (item.restricted && item.total <= 0) {
|
||||||
text1.setText(R.string.data_usage_app_restricted);
|
summary.setText(R.string.data_usage_app_restricted);
|
||||||
progress.setVisibility(View.GONE);
|
progress.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
text1.setText(Formatter.formatFileSize(context, item.total));
|
summary.setText(Formatter.formatFileSize(context, item.total));
|
||||||
progress.setVisibility(View.VISIBLE);
|
progress.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -73,6 +73,7 @@ import com.android.settings.accounts.AccountSyncSettings;
|
|||||||
import com.android.settings.applications.InstalledAppDetails;
|
import com.android.settings.applications.InstalledAppDetails;
|
||||||
import com.android.settings.applications.ManageApplications;
|
import com.android.settings.applications.ManageApplications;
|
||||||
import com.android.settings.applications.ManageAssist;
|
import com.android.settings.applications.ManageAssist;
|
||||||
|
import com.android.settings.applications.ProcessStatsSummary;
|
||||||
import com.android.settings.applications.ProcessStatsUi;
|
import com.android.settings.applications.ProcessStatsUi;
|
||||||
import com.android.settings.applications.UsageAccessDetails;
|
import com.android.settings.applications.UsageAccessDetails;
|
||||||
import com.android.settings.bluetooth.BluetoothSettings;
|
import com.android.settings.bluetooth.BluetoothSettings;
|
||||||
@@ -346,6 +347,7 @@ public class SettingsActivity extends Activity
|
|||||||
ZenModeExternalRuleSettings.class.getName(),
|
ZenModeExternalRuleSettings.class.getName(),
|
||||||
ProcessStatsUi.class.getName(),
|
ProcessStatsUi.class.getName(),
|
||||||
PowerUsageDetail.class.getName(),
|
PowerUsageDetail.class.getName(),
|
||||||
|
ProcessStatsSummary.class.getName(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||||||
import android.content.pm.PermissionGroupInfo;
|
import android.content.pm.PermissionGroupInfo;
|
||||||
import android.content.pm.PermissionInfo;
|
import android.content.pm.PermissionInfo;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -57,29 +58,15 @@ public class AppOpsDetails extends InstrumentedFragment {
|
|||||||
private PackageInfo mPackageInfo;
|
private PackageInfo mPackageInfo;
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private View mRootView;
|
private View mRootView;
|
||||||
private TextView mAppVersion;
|
|
||||||
private LinearLayout mOperationsSection;
|
private LinearLayout mOperationsSection;
|
||||||
|
|
||||||
// Utility method to set application label and icon.
|
// Utility method to set application label and icon.
|
||||||
private void setAppLabelAndIcon(PackageInfo pkgInfo) {
|
private void setAppLabelAndIcon(PackageInfo pkgInfo) {
|
||||||
final View appSnippet = mRootView.findViewById(R.id.app_snippet);
|
final View appSnippet = mRootView.findViewById(R.id.app_snippet);
|
||||||
appSnippet.setPaddingRelative(0, appSnippet.getPaddingTop(), 0, appSnippet.getPaddingBottom());
|
CharSequence label = mPm.getApplicationLabel(pkgInfo.applicationInfo);
|
||||||
|
Drawable icon = mPm.getApplicationIcon(pkgInfo.applicationInfo);
|
||||||
ImageView icon = (ImageView) appSnippet.findViewById(R.id.app_icon);
|
InstalledAppDetails.setupAppSnippet(appSnippet, label, icon,
|
||||||
icon.setImageDrawable(mPm.getApplicationIcon(pkgInfo.applicationInfo));
|
pkgInfo != null ? pkgInfo.versionName : null);
|
||||||
// Set application name.
|
|
||||||
TextView label = (TextView) appSnippet.findViewById(R.id.app_name);
|
|
||||||
label.setText(mPm.getApplicationLabel(pkgInfo.applicationInfo));
|
|
||||||
// Version number of application
|
|
||||||
mAppVersion = (TextView) appSnippet.findViewById(R.id.app_summary);
|
|
||||||
|
|
||||||
if (pkgInfo.versionName != null) {
|
|
||||||
mAppVersion.setVisibility(View.VISIBLE);
|
|
||||||
mAppVersion.setText(getActivity().getString(R.string.version_text,
|
|
||||||
String.valueOf(pkgInfo.versionName)));
|
|
||||||
} else {
|
|
||||||
mAppVersion.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String retrieveAppEntry() {
|
private String retrieveAppEntry() {
|
||||||
|
@@ -19,6 +19,7 @@ package com.android.settings.applications;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -34,21 +35,21 @@ public class AppViewHolder {
|
|||||||
public ImageView appIcon;
|
public ImageView appIcon;
|
||||||
public TextView summary;
|
public TextView summary;
|
||||||
public TextView disabled;
|
public TextView disabled;
|
||||||
public CheckBox checkBox;
|
|
||||||
|
|
||||||
static public AppViewHolder createOrRecycle(LayoutInflater inflater, View convertView) {
|
static public AppViewHolder createOrRecycle(LayoutInflater inflater, View convertView) {
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = inflater.inflate(R.layout.manage_applications_item, null);
|
convertView = inflater.inflate(R.layout.preference_app, null);
|
||||||
|
inflater.inflate(R.layout.widget_text_views,
|
||||||
|
(ViewGroup) convertView.findViewById(android.R.id.widget_frame));
|
||||||
|
|
||||||
// Creates a ViewHolder and store references to the two children views
|
// Creates a ViewHolder and store references to the two children views
|
||||||
// we want to bind data to.
|
// we want to bind data to.
|
||||||
AppViewHolder holder = new AppViewHolder();
|
AppViewHolder holder = new AppViewHolder();
|
||||||
holder.rootView = convertView;
|
holder.rootView = convertView;
|
||||||
holder.appName = (TextView) convertView.findViewById(R.id.app_name);
|
holder.appName = (TextView) convertView.findViewById(android.R.id.title);
|
||||||
holder.appIcon = (ImageView) convertView.findViewById(R.id.app_icon);
|
holder.appIcon = (ImageView) convertView.findViewById(android.R.id.icon);
|
||||||
holder.summary = (TextView) convertView.findViewById(R.id.app_summary);
|
holder.summary = (TextView) convertView.findViewById(R.id.widget_text1);
|
||||||
holder.disabled = (TextView) convertView.findViewById(R.id.app_disabled);
|
holder.disabled = (TextView) convertView.findViewById(R.id.widget_text2);
|
||||||
holder.checkBox = (CheckBox) convertView.findViewById(R.id.app_on_sdcard);
|
|
||||||
convertView.setTag(holder);
|
convertView.setTag(holder);
|
||||||
return holder;
|
return holder;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -36,6 +36,7 @@ import android.content.pm.ResolveInfo;
|
|||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.icu.text.ListFormatter;
|
import android.icu.text.ListFormatter;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.INetworkStatsService;
|
import android.net.INetworkStatsService;
|
||||||
import android.net.INetworkStatsSession;
|
import android.net.INetworkStatsSession;
|
||||||
import android.net.NetworkTemplate;
|
import android.net.NetworkTemplate;
|
||||||
@@ -49,13 +50,16 @@ import android.os.ServiceManager;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -130,7 +134,6 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
private LayoutPreference mHeader;
|
private LayoutPreference mHeader;
|
||||||
private Button mUninstallButton;
|
private Button mUninstallButton;
|
||||||
private boolean mUpdatedSysApp = false;
|
private boolean mUpdatedSysApp = false;
|
||||||
private TextView mAppVersion;
|
|
||||||
private Button mForceStopButton;
|
private Button mForceStopButton;
|
||||||
private Preference mNotificationPreference;
|
private Preference mNotificationPreference;
|
||||||
private Preference mStoragePreference;
|
private Preference mStoragePreference;
|
||||||
@@ -424,25 +427,9 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
// Utility method to set application label and icon.
|
// Utility method to set application label and icon.
|
||||||
private void setAppLabelAndIcon(PackageInfo pkgInfo) {
|
private void setAppLabelAndIcon(PackageInfo pkgInfo) {
|
||||||
final View appSnippet = mHeader.findViewById(R.id.app_snippet);
|
final View appSnippet = mHeader.findViewById(R.id.app_snippet);
|
||||||
appSnippet.setPaddingRelative(0, appSnippet.getPaddingTop(), 0,
|
|
||||||
appSnippet.getPaddingBottom());
|
|
||||||
|
|
||||||
ImageView icon = (ImageView) appSnippet.findViewById(R.id.app_icon);
|
|
||||||
mState.ensureIcon(mAppEntry);
|
mState.ensureIcon(mAppEntry);
|
||||||
icon.setImageDrawable(mAppEntry.icon);
|
setupAppSnippet(appSnippet, mAppEntry.label, mAppEntry.icon,
|
||||||
// Set application name.
|
pkgInfo != null ? pkgInfo.versionName : null);
|
||||||
TextView label = (TextView) appSnippet.findViewById(R.id.app_name);
|
|
||||||
label.setText(mAppEntry.label);
|
|
||||||
// Version number of application
|
|
||||||
mAppVersion = (TextView) appSnippet.findViewById(R.id.app_summary);
|
|
||||||
|
|
||||||
if (pkgInfo != null && pkgInfo.versionName != null) {
|
|
||||||
mAppVersion.setVisibility(View.VISIBLE);
|
|
||||||
mAppVersion.setText(getActivity().getString(R.string.version_text,
|
|
||||||
String.valueOf(pkgInfo.versionName)));
|
|
||||||
} else {
|
|
||||||
mAppVersion.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean signaturesMatch(String pkg1, String pkg2) {
|
private boolean signaturesMatch(String pkg1, String pkg2) {
|
||||||
@@ -757,6 +744,28 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setupAppSnippet(View appSnippet, CharSequence label, Drawable icon,
|
||||||
|
CharSequence versionName) {
|
||||||
|
LayoutInflater.from(appSnippet.getContext()).inflate(R.layout.widget_text_views,
|
||||||
|
(ViewGroup) appSnippet.findViewById(android.R.id.widget_frame));
|
||||||
|
|
||||||
|
ImageView iconView = (ImageView) appSnippet.findViewById(android.R.id.icon);
|
||||||
|
iconView.setImageDrawable(icon);
|
||||||
|
// Set application name.
|
||||||
|
TextView labelView = (TextView) appSnippet.findViewById(android.R.id.title);
|
||||||
|
labelView.setText(label);
|
||||||
|
// Version number of application
|
||||||
|
TextView appVersion = (TextView) appSnippet.findViewById(R.id.widget_text1);
|
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(versionName)) {
|
||||||
|
appVersion.setVisibility(View.VISIBLE);
|
||||||
|
appVersion.setText(appSnippet.getContext().getString(R.string.version_text,
|
||||||
|
String.valueOf(versionName)));
|
||||||
|
} else {
|
||||||
|
appVersion.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static NetworkTemplate getTemplate(Context context) {
|
private static NetworkTemplate getTemplate(Context context) {
|
||||||
if (DataUsageSummary.hasReadyMobileRadio(context)) {
|
if (DataUsageSummary.hasReadyMobileRadio(context)) {
|
||||||
return NetworkTemplate.buildTemplateMobileWildcard();
|
return NetworkTemplate.buildTemplateMobileWildcard();
|
||||||
|
@@ -58,6 +58,11 @@ public class LayoutPreference extends Preference {
|
|||||||
return mRootView;
|
return mRootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onBindView(View view) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
|
||||||
public View findViewById(int id) {
|
public View findViewById(int id) {
|
||||||
return mRootView.findViewById(id);
|
return mRootView.findViewById(id);
|
||||||
}
|
}
|
||||||
|
@@ -984,7 +984,6 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
} else {
|
} else {
|
||||||
holder.disabled.setVisibility(View.GONE);
|
holder.disabled.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
holder.checkBox.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
mActive.remove(convertView);
|
mActive.remove(convertView);
|
||||||
mActive.add(convertView);
|
mActive.add(convertView);
|
||||||
|
@@ -105,8 +105,9 @@ public class ProcessStatsMemDetail extends InstrumentedFragment {
|
|||||||
private void addDetailsItem(ViewGroup parent, CharSequence title,
|
private void addDetailsItem(ViewGroup parent, CharSequence title,
|
||||||
float level, CharSequence value) {
|
float level, CharSequence value) {
|
||||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
ViewGroup item = (ViewGroup) inflater.inflate(R.layout.app_percentage_item,
|
ViewGroup item = (ViewGroup) inflater.inflate(R.layout.app_item, null);
|
||||||
null);
|
inflater.inflate(R.layout.widget_progress_bar,
|
||||||
|
(ViewGroup) item.findViewById(android.R.id.widget_frame));
|
||||||
parent.addView(item);
|
parent.addView(item);
|
||||||
item.findViewById(android.R.id.icon).setVisibility(View.GONE);
|
item.findViewById(android.R.id.icon).setVisibility(View.GONE);
|
||||||
TextView titleView = (TextView) item.findViewById(android.R.id.title);
|
TextView titleView = (TextView) item.findViewById(android.R.id.title);
|
||||||
|
@@ -19,40 +19,17 @@ package com.android.settings.applications;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.preference.Preference;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.AppProgressPreference;
|
||||||
|
|
||||||
public class ProcessStatsPreference extends Preference {
|
public class ProcessStatsPreference extends AppProgressPreference {
|
||||||
|
|
||||||
private ProcStatsPackageEntry mEntry;
|
private ProcStatsPackageEntry mEntry;
|
||||||
private final int mColor;
|
|
||||||
private final int mRemainingColor;
|
|
||||||
private float mRatio;
|
|
||||||
private float mRemainingRatio;
|
|
||||||
|
|
||||||
public ProcessStatsPreference(Context context) {
|
public ProcessStatsPreference(Context context) {
|
||||||
this(context, null);
|
super(context, null);
|
||||||
}
|
|
||||||
|
|
||||||
public ProcessStatsPreference(Context context, AttributeSet attrs) {
|
|
||||||
this(context, attrs, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProcessStatsPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
||||||
this(context, attrs, defStyleAttr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProcessStatsPreference(Context context, AttributeSet attrs, int defStyleAttr,
|
|
||||||
int defStyleRes) {
|
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
|
||||||
setLayoutResource(R.layout.app_item_linear_color);
|
|
||||||
mColor = context.getColor(R.color.memory_max_use);
|
|
||||||
mRemainingColor = context.getColor(R.color.memory_remaining);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(ProcStatsPackageEntry entry, PackageManager pm, double maxMemory,
|
public void init(ProcStatsPackageEntry entry, PackageManager pm, double maxMemory,
|
||||||
@@ -68,20 +45,10 @@ public class ProcessStatsPreference extends Preference {
|
|||||||
double amount = avg ? (statsForeground ? entry.mRunWeight : entry.mBgWeight) * weightToRam
|
double amount = avg ? (statsForeground ? entry.mRunWeight : entry.mBgWeight) * weightToRam
|
||||||
: (statsForeground ? entry.mMaxRunMem : entry.mMaxBgMem) * totalScale * 1024;
|
: (statsForeground ? entry.mMaxRunMem : entry.mMaxBgMem) * totalScale * 1024;
|
||||||
setSummary(Formatter.formatShortFileSize(getContext(), (long) amount));
|
setSummary(Formatter.formatShortFileSize(getContext(), (long) amount));
|
||||||
mRatio = (float) (amount / maxMemory);
|
setProgress((int) (100 * amount / maxMemory));
|
||||||
mRemainingRatio = 1 - mRatio;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProcStatsPackageEntry getEntry() {
|
public ProcStatsPackageEntry getEntry() {
|
||||||
return mEntry;
|
return mEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onBindView(View view) {
|
|
||||||
super.onBindView(view);
|
|
||||||
|
|
||||||
LinearColorBar linearColorBar = (LinearColorBar) view.findViewById(R.id.linear_color_bar);
|
|
||||||
linearColorBar.setColors(mColor, mColor, mRemainingColor);
|
|
||||||
linearColorBar.setRatios(mRatio, 0, mRemainingRatio);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -19,38 +19,31 @@ package com.android.settings.fuelgauge;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.preference.Preference;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.AppProgressPreference;
|
||||||
import com.android.settings.TintablePreference;
|
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom preference for displaying power consumption as a bar and an icon on
|
* Custom preference for displaying power consumption as a bar and an icon on
|
||||||
* the left for the subsystem/app type.
|
* the left for the subsystem/app type.
|
||||||
*/
|
*/
|
||||||
public class PowerGaugePreference extends TintablePreference {
|
public class PowerGaugePreference extends AppProgressPreference {
|
||||||
private BatteryEntry mInfo;
|
private BatteryEntry mInfo;
|
||||||
private int mProgress;
|
|
||||||
private CharSequence mProgressText;
|
|
||||||
private final CharSequence mContentDescription;
|
private final CharSequence mContentDescription;
|
||||||
|
|
||||||
public PowerGaugePreference(Context context, Drawable icon, CharSequence contentDescription,
|
public PowerGaugePreference(Context context, Drawable icon, CharSequence contentDescription,
|
||||||
BatteryEntry info) {
|
BatteryEntry info) {
|
||||||
super(context, null);
|
super(context, null);
|
||||||
setLayoutResource(R.layout.preference_app_percentage);
|
|
||||||
setIcon(icon != null ? icon : new ColorDrawable(0));
|
setIcon(icon != null ? icon : new ColorDrawable(0));
|
||||||
mInfo = info;
|
mInfo = info;
|
||||||
mContentDescription = contentDescription;
|
mContentDescription = contentDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPercent(double percentOfMax, double percentOfTotal) {
|
public void setPercent(double percentOfMax, double percentOfTotal) {
|
||||||
mProgress = (int) Math.ceil(percentOfMax);
|
setProgress((int) Math.ceil(percentOfMax));
|
||||||
mProgressText = Utils.formatPercentage((int) (percentOfTotal + 0.5));
|
setSummary(Utils.formatPercentage((int) (percentOfTotal + 0.5)));
|
||||||
notifyChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BatteryEntry getInfo() {
|
BatteryEntry getInfo() {
|
||||||
@@ -61,12 +54,6 @@ public class PowerGaugePreference extends TintablePreference {
|
|||||||
protected void onBindView(View view) {
|
protected void onBindView(View view) {
|
||||||
super.onBindView(view);
|
super.onBindView(view);
|
||||||
|
|
||||||
final ProgressBar progress = (ProgressBar) view.findViewById(android.R.id.progress);
|
|
||||||
progress.setProgress(mProgress);
|
|
||||||
|
|
||||||
final TextView text1 = (TextView) view.findViewById(android.R.id.text1);
|
|
||||||
text1.setText(mProgressText);
|
|
||||||
|
|
||||||
if (mContentDescription != null) {
|
if (mContentDescription != null) {
|
||||||
final TextView titleView = (TextView) view.findViewById(android.R.id.title);
|
final TextView titleView = (TextView) view.findViewById(android.R.id.title);
|
||||||
titleView.setContentDescription(mContentDescription);
|
titleView.setContentDescription(mContentDescription);
|
||||||
|
Reference in New Issue
Block a user