summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip P. Moltmann <moltmann@google.com>2016-10-20 16:57:12 -0700
committerPhilip P. Moltmann <moltmann@google.com>2016-10-28 12:38:51 -0700
commit2bac5c43beddd4717cf9a362a9c0d22c83d3e60e (patch)
treed1683db17f5b7d94bbc939d2a04cc7164132f200
parent03c6b224b93910624759a97343e81786df6b9ee8 (diff)
downloadandroid_packages_apps_PackageInstaller-2bac5c43beddd4717cf9a362a9c0d22c83d3e60e.tar.gz
android_packages_apps_PackageInstaller-2bac5c43beddd4717cf9a362a9c0d22c83d3e60e.tar.bz2
android_packages_apps_PackageInstaller-2bac5c43beddd4717cf9a362a9c0d22c83d3e60e.zip
Add progress bars and make them show something
In the staging activity show a progress bar and make the layout of the activity match the other activities (with a big center icon). Update the progress bar while installing and show the same icon as used by app stores (download icon). Test: Only UI changes, hence I looked at the UIs. Change-Id: I47eec806370eb0404851f5d7aee31f4626cd7af7
-rw-r--r--res/drawable/ic_android_92.xml2
-rw-r--r--res/drawable/ic_done_92.xml2
-rw-r--r--res/drawable/ic_report_problem_92.xml2
-rw-r--r--res/layout/install_failed.xml1
-rw-r--r--res/layout/install_installing.xml11
-rw-r--r--res/layout/install_staging.xml46
-rw-r--r--res/layout/install_success.xml1
-rw-r--r--res/layout/uninstall_progress.xml1
-rw-r--r--res/values/colors.xml20
-rwxr-xr-xsrc/com/android/packageinstaller/InstallInstalling.java53
10 files changed, 115 insertions, 24 deletions
diff --git a/res/drawable/ic_android_92.xml b/res/drawable/ic_android_92.xml
index 7d527377..1d3791c1 100644
--- a/res/drawable/ic_android_92.xml
+++ b/res/drawable/ic_android_92.xml
@@ -20,6 +20,6 @@
android:viewportWidth="92.0"
android:viewportHeight="92.0">
<path
- android:fillColor="#C8CCCE"
+ android:fillColor="#000000"
android:pathData="m23,69c0,2.11 1.72,3.83 3.83,3.83h3.83v13.42c0,3.18 2.57,5.75 5.75,5.75 3.18,0 5.75,-2.57 5.75,-5.75L42.17,72.83h7.67v13.42c0,3.18 2.57,5.75 5.75,5.75 3.18,0 5.75,-2.57 5.75,-5.75L61.33,72.83h3.83c2.11,0 3.83,-1.72 3.83,-3.83L69,30.67L23,30.67L23,69zM13.42,30.67c-3.18,0 -5.75,2.57 -5.75,5.75v26.83c0,3.18 2.57,5.75 5.75,5.75 3.18,0 5.75,-2.57 5.75,-5.75L19.17,36.42c0,-3.18 -2.57,-5.75 -5.75,-5.75zM78.58,30.67c-3.18,0 -5.75,2.57 -5.75,5.75v26.83c0,3.18 2.57,5.75 5.75,5.75 3.18,0 5.75,-2.57 5.75,-5.75L84.33,36.42c0,-3.18 -2.57,-5.75 -5.75,-5.75zM59.53,8.28 L64.53,3.28c0.75,-0.75 0.75,-1.95 0,-2.7 -0.75,-0.75 -1.95,-0.75 -2.7,0L56.16,6.23C53.09,4.72 49.66,3.84 46,3.84c-3.68,0 -7.13,0.88 -10.22,2.41L30.09,0.56c-0.75,-0.75 -1.95,-0.75 -2.7,0 -0.75,0.75 -0.75,1.95 0,2.7l5.02,5.02C26.72,12.48 23,19.23 23,26.84h46c0,-7.63 -3.74,-14.37 -9.47,-18.55zM38.33,19.17h-3.83v-3.83h3.83v3.83zM57.5,19.17h-3.83v-3.83h3.83v3.83z"/>
</vector>
diff --git a/res/drawable/ic_done_92.xml b/res/drawable/ic_done_92.xml
index 396338d3..185b274d 100644
--- a/res/drawable/ic_done_92.xml
+++ b/res/drawable/ic_done_92.xml
@@ -20,6 +20,6 @@
android:viewportWidth="92.0"
android:viewportHeight="92.0">
<path
- android:fillColor="#C8CCCE"
+ android:fillColor="#000000"
android:pathData="M34.5,61.99 L18.51,46 13.09,51.42 34.5,72.83l46,-46 -5.42,-5.42z"/>
</vector>
diff --git a/res/drawable/ic_report_problem_92.xml b/res/drawable/ic_report_problem_92.xml
index f262601f..c90a33ed 100644
--- a/res/drawable/ic_report_problem_92.xml
+++ b/res/drawable/ic_report_problem_92.xml
@@ -20,6 +20,6 @@
android:viewportWidth="92.0"
android:viewportHeight="92.0">
<path
- android:fillColor="#C8CCCE"
+ android:fillColor="#000000"
android:pathData="M2,84H90L46,8 2,84zM50,72h-8v-8h8v8zM50,56H42V40h8v16z"/>
</vector>
diff --git a/res/layout/install_failed.xml b/res/layout/install_failed.xml
index 2a1c4022..98800b6d 100644
--- a/res/layout/install_failed.xml
+++ b/res/layout/install_failed.xml
@@ -59,6 +59,7 @@
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:src="@drawable/ic_report_problem_92"
+ android:tint="@color/bigIconColor"
android:contentDescription="@null" />
<TextView android:id="@+id/simple_status"
diff --git a/res/layout/install_installing.xml b/res/layout/install_installing.xml
index 1db8a7f9..a043a014 100644
--- a/res/layout/install_installing.xml
+++ b/res/layout/install_installing.xml
@@ -48,7 +48,6 @@
</LinearLayout>
<LinearLayout
- android:id="@+id/center_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@@ -58,19 +57,19 @@
android:paddingRight="16dip">
<ImageView
- android:id="@+id/center_icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_width="92dp"
+ android:layout_height="92dp"
android:layout_marginBottom="12dp"
android:contentDescription="@null"
- android:src="@drawable/ic_android_92" />
+ android:tint="@color/bigIconColor"
+ android:src="@drawable/ic_file_download" />
<ProgressBar
android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="250dp"
android:layout_height="wrap_content"
- android:indeterminate="true" />
+ android:indeterminate="false" />
<TextView
android:id="@+id/center_text"
diff --git a/res/layout/install_staging.xml b/res/layout/install_staging.xml
index 8f9d2441..e3022e7a 100644
--- a/res/layout/install_staging.xml
+++ b/res/layout/install_staging.xml
@@ -40,7 +40,7 @@
android:layout_marginLeft="16dp"
android:scaleType="fitCenter"
android:src="@drawable/ic_file_download"
- android:tint="?android:attr/colorControlNormal" />
+ android:tint="?android:attr/colorAccent" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -53,21 +53,39 @@
</LinearLayout>
- <!-- header comment -->
- <TextView android:layout_width="match_parent"
+ <!-- content -->
+ <LinearLayout
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="?android:attr/colorPrimary"
- android:elevation="@dimen/headerElevation"
- android:paddingBottom="16dp"
- android:paddingLeft="16dp"
- android:paddingRight="16dp"
- android:text="@string/message_staging"
- android:textAppearance="?android:attr/textAppearanceMedium" />
+ android:layout_weight="1"
+ android:gravity="center"
+ android:orientation="vertical"
+ android:paddingLeft="16dip"
+ android:paddingRight="16dip">
+
+ <ImageView
+ android:layout_width="92dp"
+ android:layout_height="92dp"
+ android:scaleType="fitCenter"
+ android:layout_marginBottom="12dp"
+ android:contentDescription="@null"
+ android:tint="@color/bigIconColor"
+ android:src="@drawable/ic_file_download" />
+
+ <ProgressBar
+ style="?android:attr/progressBarStyleHorizontal"
+ android:layout_width="250dp"
+ android:layout_height="wrap_content"
+ android:indeterminate="true" />
- <!-- content -->
- <View android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1" />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:text="@string/message_staging"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ </LinearLayout>
<!-- Bottom buttons -->
<LinearLayout style="?android:attr/buttonBarStyle"
diff --git a/res/layout/install_success.xml b/res/layout/install_success.xml
index 7f24f41d..fee6bede 100644
--- a/res/layout/install_success.xml
+++ b/res/layout/install_success.xml
@@ -57,6 +57,7 @@
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:src="@drawable/ic_done_92"
+ android:tint="@color/bigIconColor"
android:contentDescription="@null" />
<TextView android:layout_width="wrap_content"
diff --git a/res/layout/uninstall_progress.xml b/res/layout/uninstall_progress.xml
index cc12408f..e24f63b5 100644
--- a/res/layout/uninstall_progress.xml
+++ b/res/layout/uninstall_progress.xml
@@ -34,6 +34,7 @@
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:src="@drawable/ic_android_92"
+ android:tint="@color/bigIconColor"
android:contentDescription="@null" />
<ProgressBar android:id="@+id/progress_bar"
diff --git a/res/values/colors.xml b/res/values/colors.xml
new file mode 100644
index 00000000..01a0c9a8
--- /dev/null
+++ b/res/values/colors.xml
@@ -0,0 +1,20 @@
+<?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.
+ -->
+
+<resources>
+ <color name="bigIconColor">#C8CCCE</color>
+</resources>
diff --git a/src/com/android/packageinstaller/InstallInstalling.java b/src/com/android/packageinstaller/InstallInstalling.java
index 943db28d..b97a547d 100755
--- a/src/com/android/packageinstaller/InstallInstalling.java
+++ b/src/com/android/packageinstaller/InstallInstalling.java
@@ -32,6 +32,7 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.Button;
+import android.widget.ProgressBar;
import com.android.internal.content.PackageHelper;
import java.io.File;
@@ -62,6 +63,9 @@ public class InstallInstalling extends Activity {
/** Receiver receiving the results of the installation */
private BroadcastReceiver mBroadcastReceiver;
+ /** Listens to changed to the session and updates progress bar */
+ private PackageInstaller.SessionCallback mSessionCallback;
+
/** Task that sends the package to the package installer */
private InstallingAsyncTask mInstallingTask;
@@ -150,12 +154,13 @@ public class InstallInstalling extends Activity {
finish();
});
-
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(BROADCAST_ACTION);
mBroadcastReceiver = new InstallResultReceiver();
registerReceiver(mBroadcastReceiver, intentFilter, BROADCAST_SENDER_PERMISSION,
null);
+
+ mSessionCallback = new InstallSessionCallback();
}
}
@@ -193,6 +198,13 @@ public class InstallInstalling extends Activity {
}
@Override
+ protected void onStart() {
+ super.onStart();
+
+ getPackageManager().getPackageInstaller().registerSessionCallback(mSessionCallback);
+ }
+
+ @Override
protected void onResume() {
super.onResume();
@@ -219,6 +231,13 @@ public class InstallInstalling extends Activity {
}
@Override
+ protected void onStop() {
+ super.onStop();
+
+ getPackageManager().getPackageInstaller().unregisterSessionCallback(mSessionCallback);
+ }
+
+ @Override
protected void onDestroy() {
if (mInstallingTask != null) {
mInstallingTask.cancel(true);
@@ -267,6 +286,38 @@ public class InstallInstalling extends Activity {
}
}
+
+ private class InstallSessionCallback extends PackageInstaller.SessionCallback {
+ @Override
+ public void onCreated(int sessionId) {
+ // empty
+ }
+
+ @Override
+ public void onBadgingChanged(int sessionId) {
+ // empty
+ }
+
+ @Override
+ public void onActiveChanged(int sessionId, boolean active) {
+ // empty
+ }
+
+ @Override
+ public void onProgressChanged(int sessionId, float progress) {
+ if (sessionId == mSessionId) {
+ ProgressBar progressBar = (ProgressBar)findViewById(R.id.progress_bar);
+ progressBar.setMax(Integer.MAX_VALUE);
+ progressBar.setProgress((int) (Integer.MAX_VALUE * progress));
+ }
+ }
+
+ @Override
+ public void onFinished(int sessionId, boolean success) {
+ // empty, finish is handled by InstallResultReceiver
+ }
+ }
+
/**
* Send the package to the package installer and then register a broadcast pending intent that
* will wake up {@link InstallResultReceiver}