Better notification text for watching.

Add debug logs for the pinwatcher.
captchafix
Florens Douwes 11 years ago
parent fa0855a7cc
commit 99a9dccc53
  1. 7
      Clover/app/src/main/java/org/floens/chan/core/watch/PinWatcher.java
  2. 14
      Clover/app/src/main/java/org/floens/chan/core/watch/WatchNotifier.java
  3. 4
      Clover/app/src/main/java/org/floens/chan/utils/Logger.java

@ -17,8 +17,6 @@
*/ */
package org.floens.chan.core.watch; package org.floens.chan.core.watch;
import android.util.Log;
import com.android.volley.VolleyError; import com.android.volley.VolleyError;
import org.floens.chan.core.loader.Loader; import org.floens.chan.core.loader.Loader;
@ -137,7 +135,10 @@ public class PinWatcher implements Loader.LoaderListener {
wereNewQuotes = true; wereNewQuotes = true;
} }
Log.d(TAG, "QuoteLastCount: " + pin.quoteLastCount + ", quoteNewCount: " + pin.quoteNewCount + ", wereNewQuotes: " + wereNewQuotes); if (Logger.debugEnabled()) {
Logger.d(TAG, String.format("postlast=%d postnew=%d quotelast=%d quotenew=%d werenewquotes=%b",
pin.watchLastCount, pin.watchNewCount, pin.quoteLastCount, pin.quoteNewCount, wereNewQuotes));
}
WatchService.onPinWatcherResult(); WatchService.onPinWatcherResult();
} }

@ -125,23 +125,19 @@ public class WatchNotifier {
} }
if (show) { if (show) {
// "33 new posts, 3 quoting you"
String title = newPostsCount + " new post" + (newPostsCount != 1 ? "s" : ""); String title = newPostsCount + " new post" + (newPostsCount != 1 ? "s" : "");
if (newQuotesCount > 0) { if (newQuotesCount > 0) {
title += ", " + newQuotesCount + " quoting you"; title += ", " + newQuotesCount + " quoting you";
} }
// "234 new posts in DPT" String tickerText = title + " in ";
// "234 new posts in 5 threads"
String descriptor;
if (pins.size() == 1) { if (pins.size() == 1) {
descriptor = pins.get(0).loadable.title; tickerText += pins.get(0).loadable.title;
} else { } else {
descriptor = pins.size() + " thread" + (pins.size() != 1 ? "s" : ""); tickerText += pins.size() + " thread" + (pins.size() != 1 ? "s" : "");
} }
String content = newPostsCount + " new post" + (newPostsCount != 1 ? "s" : "") + " in " + descriptor;
Collections.sort(posts, new PostAgeComparer()); Collections.sort(posts, new PostAgeComparer());
List<CharSequence> lines = new ArrayList<CharSequence>(); List<CharSequence> lines = new ArrayList<CharSequence>();
@ -160,7 +156,7 @@ public class WatchNotifier {
} }
} }
showNotification(content, title, content, Integer.toString(newPostsCount), lines, makeSound); showNotification(tickerText, title, tickerText, Integer.toString(newPostsCount), lines, makeSound);
} }
} }

@ -25,6 +25,10 @@ public class Logger {
private static final String TAG = "Clover"; private static final String TAG = "Clover";
private static final String TAG_SPACER = " | "; private static final String TAG_SPACER = " | ";
public static boolean debugEnabled() {
return ChanBuild.DEVELOPER_MODE;
}
public static void v(String tag, String message) { public static void v(String tag, String message) {
Log.v(TAG + TAG_SPACER + tag, message); Log.v(TAG + TAG_SPACER + tag, message);
} }

Loading…
Cancel
Save