diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index ac762d49..a9b477ba 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -22,7 +22,6 @@ import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_SOFTWARE; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN; -import static app.fedilab.android.mastodon.helper.Helper.TAG; import static app.fedilab.android.mastodon.helper.Helper.displayReleaseNotesIfNeeded; import static app.fedilab.android.mastodon.helper.ThemeHelper.fetchAccentColor; import static app.fedilab.android.mastodon.ui.drawer.StatusAdapter.sendAction; diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/ComposeActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/ComposeActivity.java index d70268aa..03d33238 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/ComposeActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/ComposeActivity.java @@ -17,7 +17,6 @@ package app.fedilab.android.mastodon.activities; import static app.fedilab.android.BaseMainActivity.currentInstance; import static app.fedilab.android.BaseMainActivity.emojis; -import static app.fedilab.android.mastodon.helper.Helper.TAG; import android.Manifest; import android.annotation.SuppressLint; @@ -35,7 +34,6 @@ import android.os.Looper; import android.text.Editable; import android.text.InputFilter; import android.text.TextWatcher; -import android.util.Log; import android.util.TypedValue; import android.view.Menu; import android.view.MenuItem; diff --git a/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Status.java b/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Status.java index c6ef8d87..94a7d08f 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Status.java +++ b/app/src/main/java/app/fedilab/android/mastodon/client/entities/api/Status.java @@ -112,6 +112,7 @@ public class Status implements Serializable, Cloneable { @SerializedName("reactions") public List reactions; + public String attachedNotification = null; public transient boolean isFetchMore = false; public transient boolean isFetching = false; diff --git a/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/StatusCache.java b/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/StatusCache.java index 67b1ac04..15ffd8d5 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/StatusCache.java +++ b/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/StatusCache.java @@ -14,6 +14,8 @@ package app.fedilab.android.mastodon.client.entities.app; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ +import static app.fedilab.android.mastodon.helper.Helper.TAG; + import android.content.ContentValues; import android.content.Context; import android.database.Cursor; @@ -289,7 +291,6 @@ public class StatusCache { if (statusCache.type != null) { query += " AND " + Sqlite.COL_TYPE + " = '" + statusCache.type.getValue() + "'"; } - Cursor mCount = db.rawQuery(query, null); mCount.moveToFirst(); int count = mCount.getInt(0); @@ -352,7 +353,11 @@ public class StatusCache { values.put(Sqlite.COL_STATUS, mastodonStatusToStringStorage(statusCache.status)); } if (statusCache.notification != null) { - values.put(Sqlite.COL_STATUS, mastodonNotificationToStringStorage(statusCache.notification)); + Notification currentNotification = getCachedNotification(statusCache); + if(currentNotification != null && currentNotification.status != null) { + currentNotification.status = statusCache.notification.status; + values.put(Sqlite.COL_STATUS, mastodonNotificationToStringStorage(currentNotification)); + } } if (statusCache.conversation != null) { values.put(Sqlite.COL_STATUS, mastodonConversationToStringStorage(statusCache.conversation)); @@ -594,6 +599,15 @@ public class StatusCache { } } + public Notification getCachedNotification(StatusCache statusCache) throws DBException { + if (db == null) { + throw new DBException("db is null. Wrong initialization."); + } + Cursor c = db.query(Sqlite.TABLE_STATUS_CACHE, null, Sqlite.COL_STATUS_ID + " = ? AND " + Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =?", + new String[]{statusCache.status_id, statusCache.user_id, statusCache.instance}, null, null, null, "1"); + c.moveToFirst(); + return convertCursorToNotification(c); + } /** * Get paginated conversations from db diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/PushNotifications.java b/app/src/main/java/app/fedilab/android/mastodon/helper/PushNotifications.java index c996e4ff..fc95a0ba 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/PushNotifications.java +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/PushNotifications.java @@ -15,7 +15,6 @@ package app.fedilab.android.mastodon.helper; * see . */ -import static app.fedilab.android.mastodon.helper.Helper.TAG; import android.content.Context; import android.content.SharedPreferences; diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/NotificationAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/NotificationAdapter.java index 76f5d172..d10155f1 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/NotificationAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/NotificationAdapter.java @@ -379,6 +379,7 @@ public class NotificationAdapter extends RecyclerView.Adapter StatusCache statusCache = new StatusCache(); statusCache.instance = BaseMainActivity.currentInstance; statusCache.user_id = BaseMainActivity.currentUserID; - statusCache.status = statusToDeal; - statusCache.status_id = statusToDeal.id; + if(statusToDeal.attachedNotification != null) { + statusCache.notification = new Notification(); + statusCache.notification.status = statusToDeal; + statusCache.status_id = statusToDeal.attachedNotification; + statusCache.type = Timeline.TimeLineEnum.NOTIFICATION; + } else { + statusCache.status_id = statusToDeal.id; + statusCache.status = statusToDeal; + } + try { new StatusCache(context).updateIfExists(statusCache); } catch (DBException e) { diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusScheduledAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusScheduledAdapter.java index 98ba8a1f..f263f80a 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusScheduledAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusScheduledAdapter.java @@ -17,7 +17,6 @@ package app.fedilab.android.mastodon.ui.drawer; import static androidx.core.text.HtmlCompat.FROM_HTML_MODE_LEGACY; -import static app.fedilab.android.mastodon.helper.Helper.TAG; import android.content.Context; import android.content.Intent; diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java index 156d85b0..9f0fa760 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java @@ -17,7 +17,6 @@ package app.fedilab.android.mastodon.ui.fragment.timeline; import static app.fedilab.android.BaseMainActivity.currentInstance; import static app.fedilab.android.BaseMainActivity.networkAvailable; -import static app.fedilab.android.mastodon.helper.Helper.TAG; import android.content.BroadcastReceiver; import android.content.Context; diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/NotificationsVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/NotificationsVM.java index f04ed2a5..08e3c900 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/NotificationsVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/NotificationsVM.java @@ -14,7 +14,6 @@ package app.fedilab.android.mastodon.viewmodel.mastodon; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ -import static app.fedilab.android.mastodon.helper.Helper.TAG; import android.app.Application; import android.os.Handler; diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/ManageInstancesActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/ManageInstancesActivity.java index 290b68b6..0c4e37f6 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/ManageInstancesActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/ManageInstancesActivity.java @@ -15,7 +15,6 @@ package app.fedilab.android.peertube.activities; * see . */ import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE_PEERTUBE_BROWSING; -import static app.fedilab.android.mastodon.helper.Helper.TAG; import static app.fedilab.android.mastodon.helper.Helper.addFragment; import static app.fedilab.android.peertube.helper.Helper.recreatePeertubeActivity;