diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java index d9c3dd790..17e012aa1 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java @@ -107,6 +107,7 @@ import static fr.gouv.etalab.mastodon.helper.Helper.CHANGE_THEME_INTENT; import static fr.gouv.etalab.mastodon.helper.Helper.CHANGE_USER_INTENT; import static fr.gouv.etalab.mastodon.helper.Helper.HOME_TIMELINE_INTENT; import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION; +import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_TARGETED_ACCOUNT; import static fr.gouv.etalab.mastodon.helper.Helper.NOTIFICATION_INTENT; import static fr.gouv.etalab.mastodon.helper.Helper.PREF_KEY_ID; import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor; @@ -1030,6 +1031,13 @@ public abstract class BaseMainActivity extends BaseActivity if( tabLayout.getTabAt(1) != null) //noinspection ConstantConditions tabLayout.getTabAt(1).select(); + if( extras.getString(INTENT_TARGETED_ACCOUNT) != null ){ + Intent intentShow = new Intent(BaseMainActivity.this, ShowAccountActivity.class); + Bundle b = new Bundle(); + b.putString("accountId", extras.getString(INTENT_TARGETED_ACCOUNT)); + intentShow.putExtras(b); + startActivity(intentShow); + } }else if( extras.getInt(INTENT_ACTION) == HOME_TIMELINE_INTENT){ changeUser(BaseMainActivity.this, userIdIntent, true); //Connects the account which is related to the notification }else if( extras.getInt(INTENT_ACTION) == CHANGE_THEME_INTENT){ diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java index b7d6ba8c6..e2b6e390c 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java @@ -278,7 +278,7 @@ public class Helper { public static final int SECONDES_BETWEEN_TRANSLATE = 30; //Intent public static final String INTENT_ACTION = "intent_action"; - + public static final String INTENT_TARGETED_ACCOUNT = "intent_targeted_account"; //Receiver public static final String RECEIVE_DATA = "receive_data"; public static final String RECEIVE_FEDERATED_DATA = "receive_federated_data"; diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java b/app/src/main/java/fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java index 1dc705e79..69b949e77 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java @@ -51,6 +51,7 @@ import fr.gouv.etalab.mastodon.sqlite.AccountDAO; import fr.gouv.etalab.mastodon.sqlite.Sqlite; import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION; +import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_TARGETED_ACCOUNT; import static fr.gouv.etalab.mastodon.helper.Helper.NOTIFICATION_INTENT; import static fr.gouv.etalab.mastodon.helper.Helper.PREF_INSTANCE; import static fr.gouv.etalab.mastodon.helper.Helper.PREF_KEY_ID; @@ -161,6 +162,7 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications String notificationUrl = null; String title = null; final String message; + String targeted_account = null; for(Notification notification: notifications){ switch (notification.getType()){ case "mention": @@ -209,6 +211,7 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications title = String.format("%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getContext().getString(R.string.notif_follow)); else title = String.format("@%s %s", notification.getAccount().getAcct(),getContext().getString(R.string.notif_follow)); + targeted_account = notification.getAccount().getId(); } } break; @@ -228,6 +231,8 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK ); intent.putExtra(INTENT_ACTION, NOTIFICATION_INTENT); intent.putExtra(PREF_KEY_ID, account.getId()); + if( targeted_account != null ) + intent.putExtra(INTENT_TARGETED_ACCOUNT, targeted_account); intent.putExtra(PREF_INSTANCE, account.getInstance()); long notif_id = Long.parseLong(account.getId()); final int notificationId = ((notif_id + 1) > 2147483647) ? (int) (2147483647 - notif_id - 1) : (int) (notif_id + 1); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/services/LiveNotificationService.java b/app/src/main/java/fr/gouv/etalab/mastodon/services/LiveNotificationService.java index 45e91c030..432abbe03 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/services/LiveNotificationService.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/services/LiveNotificationService.java @@ -66,6 +66,7 @@ import fr.gouv.etalab.mastodon.sqlite.AccountDAO; import fr.gouv.etalab.mastodon.sqlite.Sqlite; import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION; +import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_TARGETED_ACCOUNT; import static fr.gouv.etalab.mastodon.helper.Helper.NOTIFICATION_INTENT; import static fr.gouv.etalab.mastodon.helper.Helper.PREF_KEY_ID; import static fr.gouv.etalab.mastodon.helper.Helper.notify_user; @@ -274,7 +275,7 @@ public class LiveNotificationService extends Service { boolean canNotify = Helper.canNotify(getApplicationContext()); boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); - + String targeted_account = null; if((userId == null || !userId.equals(account.getId()) || activityPaused) && liveNotifications && canNotify && notify) { boolean notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true); boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true); @@ -314,6 +315,7 @@ public class LiveNotificationService extends Service { title = String.format("%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getString(R.string.notif_follow)); else title = String.format("@%s %s", notification.getAccount().getAcct(),getString(R.string.notif_follow)); + targeted_account = notification.getAccount().getId(); } break; default: @@ -323,6 +325,8 @@ public class LiveNotificationService extends Service { intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK ); intent.putExtra(INTENT_ACTION, NOTIFICATION_INTENT); intent.putExtra(PREF_KEY_ID, account.getId()); + if( targeted_account != null ) + intent.putExtra(INTENT_TARGETED_ACCOUNT, targeted_account); long notif_id = Long.parseLong(account.getId()); final int notificationId = ((notif_id + 1) > 2147483647) ? (int) (2147483647 - notif_id - 1) : (int) (notif_id + 1); if( notification.getAccount().getAvatar() != null ) {