From d2be882d8f2e5acd8a5806c649ba4640249cf4ba Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Wed, 20 Oct 2010 16:01:50 -0700 Subject: [PATCH] Fix issue #3114356: Storage visualization in Manage Apps is confusing Also fixes issue #3097388: If you launch Manage Applications when SD card app info isn't available, incomplete information gets cached Change-Id: If3377a965653590e5bc1df25e38764a83e96b820 --- res/layout/manage_applications.xml | 11 ++- res/layout/running_processes_view.xml | 11 ++- .../applications/ApplicationsState.java | 96 +++++++++++++++---- .../settings/applications/LinearColorBar.java | 32 +++++-- .../applications/ManageApplications.java | 21 +++- .../fuelgauge/BatteryHistoryChart.java | 2 + 6 files changed, 135 insertions(+), 38 deletions(-) diff --git a/res/layout/manage_applications.xml b/res/layout/manage_applications.xml index 078322ace63..2d6678a958f 100755 --- a/res/layout/manage_applications.xml +++ b/res/layout/manage_applications.xml @@ -43,9 +43,11 @@ android:layout_height="wrap_content" android:layout_marginTop="-5dp" android:orientation="horizontal" + android:clipChildren="false" + android:clipToPadding="false" android:paddingTop="30dp" - android:paddingLeft="2dp" - android:paddingRight="2dp" + android:paddingLeft="4dp" + android:paddingRight="4dp" android:paddingBottom="1dp"> diff --git a/res/layout/running_processes_view.xml b/res/layout/running_processes_view.xml index 9f01eda3cf3..2e62c487f0e 100644 --- a/res/layout/running_processes_view.xml +++ b/res/layout/running_processes_view.xml @@ -41,9 +41,11 @@ android:layout_height="wrap_content" android:layout_marginTop="-5dp" android:orientation="horizontal" + android:clipChildren="false" + android:clipToPadding="false" android:paddingTop="30dp" - android:paddingLeft="2dp" - android:paddingRight="2dp" + android:paddingLeft="4dp" + android:paddingRight="4dp" android:paddingBottom="1dp"> diff --git a/src/com/android/settings/applications/ApplicationsState.java b/src/com/android/settings/applications/ApplicationsState.java index 95156249313..c08ae5a6502 100644 --- a/src/com/android/settings/applications/ApplicationsState.java +++ b/src/com/android/settings/applications/ApplicationsState.java @@ -21,6 +21,7 @@ import android.os.SystemClock; import android.text.format.Formatter; import android.util.Log; +import java.io.File; import java.text.Collator; import java.text.Normalizer; import java.text.Normalizer.Form; @@ -66,14 +67,17 @@ public class ApplicationsState { } public static class AppEntry { - final String label; + final File apkFile; final long id; + String label; long size; long cacheSize; long codeSize; long dataSize; + boolean mounted; + String getNormalizedLabel() { if (normalizedLabel != null) { return normalizedLabel; @@ -92,12 +96,47 @@ public class ApplicationsState { String normalizedLabel; AppEntry(Context context, ApplicationInfo info, long id) { - CharSequence label = info.loadLabel(context.getPackageManager()); - this.label = label != null ? label.toString() : info.packageName; + apkFile = new File(info.sourceDir); this.id = id; this.info = info; this.size = SIZE_UNKNOWN; this.sizeStale = true; + ensureLabel(context); + } + + void ensureLabel(Context context) { + if (this.label == null || !this.mounted) { + if (!this.apkFile.exists()) { + this.mounted = false; + this.label = info.packageName; + } else { + this.mounted = true; + CharSequence label = info.loadLabel(context.getPackageManager()); + this.label = label != null ? label.toString() : info.packageName; + } + } + } + + boolean ensureIconLocked(Context context, PackageManager pm) { + if (this.icon == null) { + if (this.apkFile.exists()) { + this.icon = this.info.loadIcon(pm); + return true; + } else { + this.mounted = false; + this.icon = context.getResources().getDrawable( + com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon); + } + } else if (!this.mounted) { + // If the app wasn't mounted but is now mounted, reload + // its icon. + if (this.apkFile.exists()) { + this.mounted = true; + this.icon = this.info.loadIcon(pm); + return true; + } + } + return false; } } @@ -217,9 +256,11 @@ public class ApplicationsState { return; } boolean avail = Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE.equals(actionStr); - for (String pkgName : pkgList) { - if (avail) addPackage(pkgName); - else removePackage(pkgName); + if (avail) { + for (String pkgName : pkgList) { + removePackage(pkgName); + addPackage(pkgName); + } } } } @@ -312,6 +353,13 @@ public class ApplicationsState { for (int i=0; i=0; i--) { + sum += mAppEntries.get(i).cacheSize; + } + } + return sum; + } + int indexOfApplicationInfoLocked(String pkgName) { for (int i=mApplications.size()-1; i>=0; i--) { if (mApplications.get(i).packageName.equals(pkgName)) { @@ -630,16 +687,17 @@ public class ApplicationsState { synchronized (mEntriesMap) { for (int i=0; i parent, View view, int position, long id) { @@ -738,8 +751,8 @@ public class ManageApplications extends TabActivity implements for (int i=0; i