diff --git a/Chan/res/drawable-hdpi/ic_action_pause.png b/Chan/res/drawable-hdpi/ic_action_pause.png
new file mode 100644
index 00000000..535ad58b
Binary files /dev/null and b/Chan/res/drawable-hdpi/ic_action_pause.png differ
diff --git a/Chan/res/drawable-mdpi/ic_action_pause.png b/Chan/res/drawable-mdpi/ic_action_pause.png
new file mode 100644
index 00000000..ffa11337
Binary files /dev/null and b/Chan/res/drawable-mdpi/ic_action_pause.png differ
diff --git a/Chan/res/drawable-xhdpi/ic_action_pause.png b/Chan/res/drawable-xhdpi/ic_action_pause.png
new file mode 100644
index 00000000..b02cf909
Binary files /dev/null and b/Chan/res/drawable-xhdpi/ic_action_pause.png differ
diff --git a/Chan/res/drawable-xxhdpi/ic_action_pause.png b/Chan/res/drawable-xxhdpi/ic_action_pause.png
new file mode 100644
index 00000000..293f7127
Binary files /dev/null and b/Chan/res/drawable-xxhdpi/ic_action_pause.png differ
diff --git a/Chan/res/values/strings.xml b/Chan/res/values/strings.xml
index ff6ebe6e..cbcb097e 100644
--- a/Chan/res/values/strings.xml
+++ b/Chan/res/values/strings.xml
@@ -103,6 +103,8 @@
Open link?
+ Stop watching
+
Off
Watching pinned threads
To watch pins for new posts, turn the thread watcher on.
diff --git a/Chan/src/org/floens/chan/core/watch/WatchNotifier.java b/Chan/src/org/floens/chan/core/watch/WatchNotifier.java
index d9b50972..7f9366cf 100644
--- a/Chan/src/org/floens/chan/core/watch/WatchNotifier.java
+++ b/Chan/src/org/floens/chan/core/watch/WatchNotifier.java
@@ -47,6 +47,17 @@ public class WatchNotifier {
}
}
+ public void onPausePinsClicked() {
+ nm.cancel(NOTIFICATION_ID);
+
+ List watchingPins = ChanApplication.getPinnedManager().getWatchingPins();
+ for (Pin pin : watchingPins) {
+ pin.watching = false;
+ }
+
+ ChanApplication.getPinnedManager().onPinsChanged();
+ }
+
private void prepareNotification() {
List watchingPins = ChanApplication.getPinnedManager().getWatchingPins();
@@ -128,6 +139,15 @@ public class WatchNotifier {
builder.setContentInfo(contentInfo);
builder.setSmallIcon(R.drawable.ic_stat_notify);
+ Intent pauseWatching = new Intent(pinnedService, WatchService.class);
+ pauseWatching.putExtra("pause_pins", true);
+
+ PendingIntent pauseWatchingPending = PendingIntent.getService(pinnedService, 0, pauseWatching,
+ PendingIntent.FLAG_UPDATE_CURRENT);
+
+ builder.addAction(R.drawable.ic_action_pause, pinnedService.getString(R.string.watch_pause_pins),
+ pauseWatchingPending);
+
if (makeSound) {
builder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
}
@@ -137,7 +157,7 @@ public class WatchNotifier {
style.addLine(line);
}
style.setBigContentTitle(title);
- style.setSummaryText(content);
+ // style.setSummaryText(content);
builder.setStyle(style);
diff --git a/Chan/src/org/floens/chan/service/WatchService.java b/Chan/src/org/floens/chan/service/WatchService.java
index d9e148f0..7084f326 100644
--- a/Chan/src/org/floens/chan/service/WatchService.java
+++ b/Chan/src/org/floens/chan/service/WatchService.java
@@ -14,7 +14,6 @@ import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
-import android.widget.Toast;
public class WatchService extends Service {
private static final String TAG = "WatchService";
@@ -116,13 +115,11 @@ public class WatchService extends Service {
public void onDestroy() {
super.onDestroy();
-
instance = null;
running = false;
if (loadThread != null) {
loadThread.interrupt();
- Toast.makeText(getApplicationContext(), "Pinned thread interrupted", Toast.LENGTH_SHORT).show();
}
Logger.i(TAG, "WatchService destroyed");
@@ -130,6 +127,14 @@ public class WatchService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
+ Logger.test("Startcommand " + startId);
+
+ if (intent.getExtras() != null && intent.getExtras().getBoolean("pause_pins", false)) {
+ if (watchNotifier != null) {
+ watchNotifier.onPausePinsClicked();
+ }
+ }
+
return START_STICKY;
}
@@ -171,7 +176,6 @@ public class WatchService extends Service {
});
loadThread.start();
- Toast.makeText(getApplicationContext(), "Pinned thread started", Toast.LENGTH_SHORT).show();
}
}
@@ -188,6 +192,7 @@ public class WatchService extends Service {
/**
* Returns the sleep time the user specified for background iteration
+ *
* @return the sleep time in ms, or -1 if background reloading is disabled
*/
private long getBackgroundTimeout() {
diff --git a/Chan/src/org/floens/chan/ui/adapter/PinnedAdapter.java b/Chan/src/org/floens/chan/ui/adapter/PinnedAdapter.java
index f6bf2417..9069a82d 100644
--- a/Chan/src/org/floens/chan/ui/adapter/PinnedAdapter.java
+++ b/Chan/src/org/floens/chan/ui/adapter/PinnedAdapter.java
@@ -51,7 +51,7 @@ public class PinnedAdapter extends ArrayAdapter {
TextView itemCount = (TextView) view.findViewById(R.id.drawer_item_count);
if (item.isError()) {
- itemCount.setText("404");
+ itemCount.setText("Err");
} else {
int count = item.getPinWatcher() == null ? 0 : item.getPinWatcher().getNewPostsCount();
String total = Integer.toString(count);
@@ -69,12 +69,12 @@ public class PinnedAdapter extends ArrayAdapter {
}
});
- if (item.isError()) {
+ if (!item.watching) {
+ frameLayout.setBackgroundResource(R.drawable.pin_icon_gray);
+ } else if (item.isError()) {
frameLayout.setBackgroundResource(R.drawable.pin_icon_red);
- } else if (item.watching) {
- frameLayout.setBackgroundResource(R.drawable.pin_icon_blue);
} else {
- frameLayout.setBackgroundResource(R.drawable.pin_icon_gray);
+ frameLayout.setBackgroundResource(R.drawable.pin_icon_blue);
}
} else {
frameLayout.setVisibility(View.GONE);