watcher: enable clicking notification to go to thread

feature/sentry
Floens 6 years ago
parent 0a8cc47512
commit 316dafb0ba
  1. 6
      Clover/app/src/main/java/org/floens/chan/ui/activity/StartActivity.java
  2. 4
      Clover/app/src/main/java/org/floens/chan/ui/controller/DrawerController.java
  3. 6
      Clover/app/src/main/java/org/floens/chan/ui/notification/ThreadWatchNotifications.java

@ -308,16 +308,16 @@ public class StartActivity extends AppCompatActivity implements NfcAdapter.Creat
protected void onNewIntent(Intent intent) { protected void onNewIntent(Intent intent) {
super.onNewIntent(intent); super.onNewIntent(intent);
// Handle WatchNotifier clicks // Handle notification clicks
if (intent.getExtras() != null) { if (intent.getExtras() != null) {
int pinId = intent.getExtras().getInt("pin_id", -2); int pinId = intent.getExtras().getInt("pin_id", -2);
if (pinId != -2 && mainNavigationController.getTop() instanceof BrowseController) { if (pinId != -2) {
if (pinId == -1) { if (pinId == -1) {
drawerController.onMenuClicked(); drawerController.onMenuClicked();
} else { } else {
Pin pin = watchManager.findPinById(pinId); Pin pin = watchManager.findPinById(pinId);
if (pin != null) { if (pin != null) {
browseController.showThread(pin.loadable, false); drawerController.openPin(pin);
} }
} }
} }

@ -142,6 +142,10 @@ public class DrawerController extends Controller implements DrawerAdapter.Callba
// TODO: probably twice because of some force redraw, fix that. // TODO: probably twice because of some force redraw, fix that.
drawerLayout.post(() -> drawerLayout.post(() -> drawerLayout.closeDrawer(drawer))); drawerLayout.post(() -> drawerLayout.post(() -> drawerLayout.closeDrawer(drawer)));
openPin(pin);
}
public void openPin(Pin pin) {
ThreadController threadController = getTopThreadController(); ThreadController threadController = getTopThreadController();
if (threadController != null) { if (threadController != null) {
threadController.openPin(pin); threadController.openPin(pin);

@ -119,7 +119,7 @@ public class ThreadWatchNotifications extends NotificationHelper {
addPostsToMessagingStyle(messagingStyle, posts); addPostsToMessagingStyle(messagingStyle, posts);
builder.setStyle(messagingStyle); builder.setStyle(messagingStyle);
setNotificationIntent(builder); setNotificationIntent(builder, pinWatcher.getPinId());
return builder; return builder;
} }
@ -151,7 +151,7 @@ public class ThreadWatchNotifications extends NotificationHelper {
} }
} }
private void setNotificationIntent(NotificationCompat.Builder builder) { private void setNotificationIntent(NotificationCompat.Builder builder, int pinId) {
Intent intent = new Intent(applicationContext, BoardActivity.class); Intent intent = new Intent(applicationContext, BoardActivity.class);
intent.setAction(Intent.ACTION_MAIN); intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.addCategory(Intent.CATEGORY_LAUNCHER);
@ -160,6 +160,8 @@ public class ThreadWatchNotifications extends NotificationHelper {
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
intent.putExtra("pin_id", pinId);
PendingIntent pendingIntent = PendingIntent.getActivity( PendingIntent pendingIntent = PendingIntent.getActivity(
applicationContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); applicationContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

Loading…
Cancel
Save