Fixed problems with FlattrClickWorker on Gingerbread

This commit is contained in:
daniel oeh 2014-03-05 17:41:56 +01:00
parent 3e091afa6e
commit 6c56883f11

View File

@ -3,8 +3,10 @@ package de.danoeh.antennapod.asynctask;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.os.AsyncTask; import android.os.AsyncTask;
@ -13,6 +15,7 @@ import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
import de.danoeh.antennapod.AppConfig; import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.storage.DBReader; import de.danoeh.antennapod.storage.DBReader;
import de.danoeh.antennapod.storage.DBWriter; import de.danoeh.antennapod.storage.DBWriter;
import de.danoeh.antennapod.util.flattr.FlattrThing; import de.danoeh.antennapod.util.flattr.FlattrThing;
@ -136,12 +139,14 @@ public class FlattrClickWorker extends AsyncTask<Void, String, Void> {
notificationManager.cancel(NOTIFICATION_ID); notificationManager.cancel(NOTIFICATION_ID);
if (run_mode == FLATTR_NOTIFICATION || flattr_failed.size() > 0) { if (run_mode == FLATTR_NOTIFICATION || flattr_failed.size() > 0) {
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);
if (android.os.Build.VERSION.SDK_INT >= 16) { if (android.os.Build.VERSION.SDK_INT >= 16) {
notificationBuilder = new Notification.BigTextStyle( notificationBuilder = new Notification.BigTextStyle(
new Notification.Builder(context) new Notification.Builder(context)
.setOngoing(false) .setOngoing(false)
.setContentTitle(notificationTitle) .setContentTitle(notificationTitle)
.setContentText(notificationText) .setContentText(notificationText)
.setContentIntent(contentIntent)
.setSubText(notificationSubText) .setSubText(notificationSubText)
.setSmallIcon(R.drawable.stat_notify_sync)) .setSmallIcon(R.drawable.stat_notify_sync))
.bigText(notificationText + "\n" + notificationBigText); .bigText(notificationText + "\n" + notificationBigText);
@ -150,6 +155,7 @@ public class FlattrClickWorker extends AsyncTask<Void, String, Void> {
notificationCompatBuilder = new NotificationCompat.Builder(context) // need new notificationBuilder and cancel/renotify to get rid of progress bar notificationCompatBuilder = new NotificationCompat.Builder(context) // need new notificationBuilder and cancel/renotify to get rid of progress bar
.setContentTitle(notificationTitle) .setContentTitle(notificationTitle)
.setContentText(notificationText) .setContentText(notificationText)
.setContentIntent(contentIntent)
.setSubText(notificationBigText) .setSubText(notificationBigText)
.setTicker(notificationTitle) .setTicker(notificationTitle)
.setSmallIcon(R.drawable.stat_notify_sync) .setSmallIcon(R.drawable.stat_notify_sync)
@ -274,11 +280,13 @@ public class FlattrClickWorker extends AsyncTask<Void, String, Void> {
@Override @Override
protected void onProgressUpdate(String... names) { protected void onProgressUpdate(String... names) {
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);
if (android.os.Build.VERSION.SDK_INT >= 16) { if (android.os.Build.VERSION.SDK_INT >= 16) {
notificationBuilder.setBigContentTitle(names[0]); notificationBuilder.setBigContentTitle(names[0]);
notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build()); notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());
} else { } else {
notificationCompatBuilder.setContentText(names[0]); notificationCompatBuilder.setContentText(names[0]);
notificationCompatBuilder.setContentIntent(contentIntent);
notificationManager.notify(NOTIFICATION_ID, notificationCompatBuilder.build()); notificationManager.notify(NOTIFICATION_ID, notificationCompatBuilder.build());
} }
} }