clear notification for app once it has been successfully installed
This logic is pretty basic for now, it'll have to be expanded a lot to support the different UX between priv and non-priv installs. For example, priv updates will be able to happen entirely in the background. Those will then require leaving a notification to tell the user that the app was updated so nothing can transparently install updates without the user knowing. When the user is an active part of each install, like the non-priv experience requires, then keeping the "app installed" notification feels like just extra noise.
This commit is contained in:
parent
e75143530f
commit
78c0416c84
@ -7,6 +7,7 @@ import android.app.Service;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.IBinder;
|
||||
@ -25,6 +26,7 @@ import org.fdroid.fdroid.net.DownloaderService;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -106,6 +108,24 @@ public class InstallManagerService extends Service {
|
||||
Utils.debugLog(TAG, "creating Service");
|
||||
localBroadcastManager = LocalBroadcastManager.getInstance(this);
|
||||
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
|
||||
BroadcastReceiver br = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String packageName = intent.getData().getSchemeSpecificPart();
|
||||
for (Map.Entry<String, Apk> entry : ACTIVE_APKS.entrySet()) {
|
||||
if (TextUtils.equals(packageName, entry.getValue().packageName)) {
|
||||
String urlString = entry.getKey();
|
||||
cancelNotification(urlString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
|
||||
intentFilter.addDataScheme("package");
|
||||
registerReceiver(br, intentFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user