Better notifications:

Fix the intent
Launch the thread the notification is about, or when it shows multiple threads, show the pinned drawer.
captchafix
Florens Douwes 11 years ago
parent 7727e16395
commit 11b6b42911
  1. 10
      Clover/app/src/main/java/org/floens/chan/core/manager/PinnedManager.java
  2. 2
      Clover/app/src/main/java/org/floens/chan/core/model/Pin.java
  3. 15
      Clover/app/src/main/java/org/floens/chan/core/watch/WatchNotifier.java
  4. 15
      Clover/app/src/main/java/org/floens/chan/ui/activity/BoardActivity.java

@ -60,6 +60,16 @@ public class PinnedManager {
return null;
}
public Pin findPinById(int id) {
for (Pin pin : pins) {
if (pin.id == id) {
return pin;
}
}
return null;
}
public List<Pin> getPins() {
return pins;
}

@ -27,7 +27,7 @@ import org.floens.chan.core.watch.PinWatcher;
public class Pin {
// Database stuff
@DatabaseField(generatedId = true)
private int id;
public int id;
@DatabaseField(canBeNull = false, foreign = true)
public Loadable loadable = new Loadable("", -1);

@ -154,17 +154,24 @@ public class WatchNotifier {
}
}
showNotification(tickerText, title, tickerText, Integer.toString(newPostsCount), lines, makeSound);
Pin targetPin = null;
if (pins.size() == 1) {
targetPin = pins.get(0);
}
showNotification(tickerText, title, tickerText, Integer.toString(newPostsCount), lines, makeSound, targetPin);
}
}
@SuppressWarnings("deprecation")
private void showNotification(String tickerText, String title, String content, String contentInfo,
List<CharSequence> lines, boolean makeSound) {
List<CharSequence> lines, boolean makeSound, Pin targetPin) {
Intent intent = new Intent(context, BoardActivity.class);
intent.addCategory("android.intent.category.LAUNCHER");
intent.setAction("android.intent.action.MAIN");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("pin_id", targetPin == null ? -1 : targetPin.id);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);

@ -103,6 +103,21 @@ public class BoardActivity extends BaseActivity implements ActionBar.OnNavigatio
}
}
}
Bundle extras = startIntent.getExtras();
if (extras != null) {
int pinId = extras.getInt("pin_id", -2);
if (pinId != -2) {
if (pinId == -1) {
pinDrawer.openDrawer(pinDrawerView);
} else {
Pin pin = ChanApplication.getPinnedManager().findPinById(pinId);
if (pin != null) {
startLoadingThread(pin.loadable);
}
}
}
}
}
@Override

Loading…
Cancel
Save