Moving Bitmessage context into a foreground service (work in progress)

This commit is contained in:
2015-10-21 16:43:13 +02:00
parent f19996f79c
commit 9b1bf6bdb3
6 changed files with 81 additions and 29 deletions

View File

@ -10,7 +10,7 @@ import android.content.Context;
public abstract class AbstractNotification {
protected final Context ctx;
protected final NotificationManager manager;
public Notification notification;
protected Notification notification;
public AbstractNotification(Context ctx) {

View File

@ -1,6 +1,7 @@
package ch.dissem.apps.abit.notification;
import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
@ -19,6 +20,8 @@ import ch.dissem.bitmessage.utils.Property;
* Shows the network status (as long as the client is connected as a full node)
*/
public class NetworkNotification extends AbstractNotification {
public static final int ONGOING_NOTIFICATION_ID = 2;
private final BitmessageContext bmc;
private NotificationCompat.Builder builder;
@ -31,6 +34,11 @@ public class NetworkNotification extends AbstractNotification {
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
}
public Notification getNotification() {
update();
return notification;
}
@SuppressLint("StringFormatMatches")
private boolean update() {
boolean running = bmc.isRunning();
@ -82,6 +90,6 @@ public class NetworkNotification extends AbstractNotification {
@Override
protected int getNotificationId() {
return 2;
return ONGOING_NOTIFICATION_ID;
}
}