after downloading is complete, update notification to "Tap to install"

f9a30d2e1c9d95302e8f4dd0e733d019f70bed66 broke the "Tap to install" aspect.
This commit is contained in:
Hans-Christoph Steiner 2016-05-23 22:32:03 +02:00
parent f08f8cb53d
commit 5f623e0c4a

View File

@ -240,7 +240,7 @@ public class InstallManagerService extends Service {
if (AppDetails.isAppVisible(apk.packageName)) { if (AppDetails.isAppVisible(apk.packageName)) {
cancelNotification(urlString); cancelNotification(urlString);
} else { } else {
notifyDownloadComplete(urlString, builder, apk); notifyDownloadComplete(urlString, apk);
} }
unregisterDownloaderReceivers(urlString); unregisterDownloaderReceivers(urlString);
} }
@ -312,9 +312,14 @@ public class InstallManagerService extends Service {
/** /**
* Post a notification about a completed download. {@code packageName} must be a valid * Post a notification about a completed download. {@code packageName} must be a valid
* and currently in the app index database. * and currently in the app index database. This must create a new {@code Builder}
* instance otherwise the progress/cancel stuff does not go away.
*
* @see <a href=https://code.google.com/p/android/issues/detail?id=47809> Issue 47809:
* Removing the progress bar from a notification should cause the notification's content
* text to return to normal size</a>
*/ */
private void notifyDownloadComplete(String urlString, NotificationCompat.Builder builder, Apk apk) { private void notifyDownloadComplete(String urlString, Apk apk) {
String title; String title;
try { try {
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
@ -325,12 +330,16 @@ public class InstallManagerService extends Service {
} }
int downloadUrlId = urlString.hashCode(); int downloadUrlId = urlString.hashCode();
builder.setAutoCancel(true) notificationManager.cancel(downloadUrlId);
Notification notification = new NotificationCompat.Builder(this)
.setAutoCancel(true)
.setOngoing(false) .setOngoing(false)
.setContentTitle(title) .setContentTitle(title)
.setContentIntent(getAppDetailsIntent(downloadUrlId, apk))
.setSmallIcon(android.R.drawable.stat_sys_download_done) .setSmallIcon(android.R.drawable.stat_sys_download_done)
.setContentText(getString(R.string.tap_to_install)); .setContentText(getString(R.string.tap_to_install))
notificationManager.notify(downloadUrlId, builder.build()); .build();
notificationManager.notify(downloadUrlId, notification);
} }
/** /**