Finally fixed the intent from notifications! (I hope)

Also do a manual reload when a pin is enabled.
captchafix
Florens Douwes 11 years ago
parent c21d2b76cc
commit 5d4da74365
  1. 4
      Chan/AndroidManifest.xml
  2. 9
      Chan/src/org/floens/chan/core/model/Pin.java
  3. 28
      Chan/src/org/floens/chan/core/watch/WatchNotifier.java
  4. 3
      Chan/src/org/floens/chan/ui/adapter/PinnedAdapter.java

@ -101,8 +101,8 @@
</activity>
<activity
android:name="org.floens.chan.ui.activity.ImageViewActivity"
android:launchMode="singleTop"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleTop"
android:theme="@style/Theme.ImageList" >
</activity>
<activity android:name="org.floens.chan.ui.activity.ImagePickActivity" >
@ -116,4 +116,4 @@
</service>
</application>
</manifest>
</manifest>

@ -1,5 +1,6 @@
package org.floens.chan.core.model;
import org.floens.chan.ChanApplication;
import org.floens.chan.core.watch.PinWatcher;
import com.j256.ormlite.field.DatabaseField;
@ -84,4 +85,12 @@ public class Pin {
pinWatcher = null;
}
}
public void toggleWatch() {
watching = !watching;
ChanApplication.getPinnedManager().onPinsChanged();
if (watching) {
updateWatch();
}
}
}

@ -19,19 +19,18 @@ import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
public class WatchNotifier {
private static final String TAG = "WatchNotifier";
private final int NOTIFICATION_ID = 1;
private final WatchService pinnedService;
private final Context context;
private final NotificationManager nm;
public WatchNotifier(WatchService pinnedService) {
this.pinnedService = pinnedService;
nm = (NotificationManager) pinnedService.getSystemService(Context.NOTIFICATION_SERVICE);
public WatchNotifier(Context context) {
this.context = context;
nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
}
public void destroy() {
@ -143,15 +142,14 @@ public class WatchNotifier {
@SuppressWarnings("deprecation")
private void showNotification(String tickerText, String title, String content, String contentInfo,
List<CharSequence> lines, boolean makeSound) {
Intent resultIntent = new Intent(pinnedService, BoardActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(pinnedService);
stackBuilder.addParentStack(BoardActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
Intent intent = new Intent(context, BoardActivity.class);
intent.addCategory("android.intent.category.LAUNCHER");
intent.setAction("android.intent.action.MAIN");
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(pinnedService);
builder.setContentIntent(resultPendingIntent);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setContentIntent(pendingIntent);
builder.setTicker(tickerText);
builder.setContentTitle(title);
@ -159,13 +157,13 @@ public class WatchNotifier {
builder.setContentInfo(contentInfo);
builder.setSmallIcon(R.drawable.ic_stat_notify);
Intent pauseWatching = new Intent(pinnedService, WatchService.class);
Intent pauseWatching = new Intent(context, WatchService.class);
pauseWatching.putExtra("pause_pins", true);
PendingIntent pauseWatchingPending = PendingIntent.getService(pinnedService, 0, pauseWatching,
PendingIntent pauseWatchingPending = PendingIntent.getService(context, 0, pauseWatching,
PendingIntent.FLAG_UPDATE_CURRENT);
builder.addAction(R.drawable.ic_action_pause, pinnedService.getString(R.string.watch_pause_pins),
builder.addAction(R.drawable.ic_action_pause, context.getString(R.string.watch_pause_pins),
pauseWatchingPending);
if (makeSound) {

@ -64,8 +64,7 @@ public class PinnedAdapter extends ArrayAdapter<Pin> {
itemCount.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
item.watching = !item.watching;
ChanApplication.getPinnedManager().onPinsChanged();
item.toggleWatch();
}
});

Loading…
Cancel
Save