mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-06 18:57:26 +01:00
Mark as read for replies
This commit is contained in:
parent
f7185445e1
commit
0178569f14
@ -231,7 +231,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
private boolean mFetchUserInfoSuccess = false;
|
||||
private boolean mFetchSubscriptionsSuccess = false;
|
||||
private boolean mDrawerOnAccountSwitch = false;
|
||||
private String mMessageFullname;
|
||||
private int mMessageFullname;
|
||||
private String mNewAccountName;
|
||||
private boolean hideFab;
|
||||
|
||||
@ -348,11 +348,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
|
||||
mFetchSubscriptionsSuccess = savedInstanceState.getBoolean(FETCH_SUBSCRIPTIONS_STATE);
|
||||
mDrawerOnAccountSwitch = savedInstanceState.getBoolean(DRAWER_ON_ACCOUNT_SWITCH_STATE);
|
||||
mMessageFullname = savedInstanceState.getString(MESSAGE_FULLNAME_STATE);
|
||||
mMessageFullname = savedInstanceState.getInt(MESSAGE_FULLNAME_STATE);
|
||||
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
|
||||
inboxCount = savedInstanceState.getInt(INBOX_COUNT_STATE);
|
||||
} else {
|
||||
mMessageFullname = getIntent().getStringExtra(EXTRA_MESSSAGE_FULLNAME);
|
||||
mMessageFullname = getIntent().getIntExtra(EXTRA_MESSSAGE_FULLNAME, 0);
|
||||
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
|
||||
}
|
||||
|
||||
@ -1029,11 +1029,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
loadUserData();
|
||||
|
||||
if (mAccessToken != null) {
|
||||
if (mMessageFullname != null) {
|
||||
if (mMessageFullname != 0) {
|
||||
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
|
||||
@Override
|
||||
public void readSuccess() {
|
||||
mMessageFullname = null;
|
||||
mMessageFullname = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1190,7 +1190,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess);
|
||||
outState.putBoolean(FETCH_SUBSCRIPTIONS_STATE, mFetchSubscriptionsSuccess);
|
||||
outState.putBoolean(DRAWER_ON_ACCOUNT_SWITCH_STATE, mDrawerOnAccountSwitch);
|
||||
outState.putString(MESSAGE_FULLNAME_STATE, mMessageFullname);
|
||||
outState.putInt(MESSAGE_FULLNAME_STATE, mMessageFullname);
|
||||
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
|
||||
outState.putInt(INBOX_COUNT_STATE, inboxCount);
|
||||
}
|
||||
|
@ -229,13 +229,15 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
}
|
||||
if (fullnames.length() > 0) {
|
||||
fullnames.deleteCharAt(fullnames.length() - 1);
|
||||
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, fullnames.toString(),
|
||||
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, 0,
|
||||
new ReadMessage.ReadMessageListener() {
|
||||
@Override
|
||||
public void readSuccess() {}
|
||||
public void readSuccess() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFailed() {}
|
||||
public void readFailed() {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
private boolean hideFab;
|
||||
private boolean showBottomAppBar;
|
||||
private boolean lockBottomAppBar;
|
||||
private String mMessageFullname;
|
||||
private int mMessageFullname;
|
||||
private String mNewAccountName;
|
||||
private RequestManager glide;
|
||||
private int expandedTabTextColor;
|
||||
@ -352,12 +352,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
mMessageFullname = getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME);
|
||||
mMessageFullname = getIntent().getIntExtra(EXTRA_MESSAGE_FULLNAME, 0);
|
||||
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
|
||||
} else {
|
||||
mFetchSubredditInfoSuccess = savedInstanceState.getBoolean(FETCH_SUBREDDIT_INFO_STATE);
|
||||
mNCurrentOnlineSubscribers = savedInstanceState.getInt(CURRENT_ONLINE_SUBSCRIBERS_STATE);
|
||||
mMessageFullname = savedInstanceState.getString(MESSAGE_FULLNAME_STATE);
|
||||
mMessageFullname = savedInstanceState.getInt(MESSAGE_FULLNAME_STATE);
|
||||
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
|
||||
|
||||
if (mFetchSubredditInfoSuccess) {
|
||||
@ -872,11 +872,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
}
|
||||
|
||||
private void bindView() {
|
||||
if (mMessageFullname != null) {
|
||||
if (mMessageFullname != 0) {
|
||||
ReadMessage.readMessage(mRetrofit.getRetrofit(), mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
|
||||
@Override
|
||||
public void readSuccess() {
|
||||
mMessageFullname = null;
|
||||
mMessageFullname = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1234,7 +1234,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(FETCH_SUBREDDIT_INFO_STATE, mFetchSubredditInfoSuccess);
|
||||
outState.putInt(CURRENT_ONLINE_SUBSCRIBERS_STATE, mNCurrentOnlineSubscribers);
|
||||
outState.putString(MESSAGE_FULLNAME_STATE, mMessageFullname);
|
||||
outState.putInt(MESSAGE_FULLNAME_STATE, mMessageFullname);
|
||||
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
private boolean hideFab;
|
||||
private boolean showBottomAppBar;
|
||||
private boolean lockBottomAppBar;
|
||||
private String mMessageFullname;
|
||||
private int mMessageId;
|
||||
private String mNewAccountName;
|
||||
|
||||
private UserData mUserData;
|
||||
@ -282,11 +282,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
mMessageFullname = getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME);
|
||||
mMessageId = getIntent().getIntExtra(EXTRA_MESSAGE_FULLNAME, 0);
|
||||
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
|
||||
} else {
|
||||
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
|
||||
mMessageFullname = savedInstanceState.getString(MESSAGE_FULLNAME_STATE);
|
||||
mMessageId = savedInstanceState.getInt(MESSAGE_FULLNAME_STATE);
|
||||
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
|
||||
}
|
||||
|
||||
@ -706,11 +706,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
|
||||
fixViewPager2Sensitivity(viewPager2);
|
||||
|
||||
if (mMessageFullname != null) {
|
||||
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
|
||||
if (mMessageId != 0) {
|
||||
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageId, new ReadMessage.ReadMessageListener() {
|
||||
@Override
|
||||
public void readSuccess() {
|
||||
mMessageFullname = null;
|
||||
mMessageId = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1268,7 +1268,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess);
|
||||
outState.putString(MESSAGE_FULLNAME_STATE, mMessageFullname);
|
||||
outState.putInt(MESSAGE_FULLNAME_STATE, mMessageId);
|
||||
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,8 @@ import androidx.paging.PagedListAdapter;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.toldi.infinityforlemmy.NetworkState;
|
||||
@ -27,12 +29,14 @@ import eu.toldi.infinityforlemmy.activities.ViewPostDetailActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewPrivateMessagesActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.events.ChangeInboxCountEvent;
|
||||
import eu.toldi.infinityforlemmy.markdown.RedditHeadingPlugin;
|
||||
import eu.toldi.infinityforlemmy.markdown.SpoilerAwareMovementMethod;
|
||||
import eu.toldi.infinityforlemmy.markdown.SpoilerParserPlugin;
|
||||
import eu.toldi.infinityforlemmy.markdown.SuperscriptPlugin;
|
||||
import eu.toldi.infinityforlemmy.message.CommentInteraction;
|
||||
import eu.toldi.infinityforlemmy.message.FetchMessage;
|
||||
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||
import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.MarkwonConfiguration;
|
||||
@ -61,7 +65,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<CommentInteract
|
||||
}
|
||||
};
|
||||
private BaseActivity mActivity;
|
||||
private Retrofit mOauthRetrofit;
|
||||
private Retrofit retrofit;
|
||||
private Markwon mMarkwon;
|
||||
private String mAccessToken;
|
||||
private int mMessageType;
|
||||
@ -83,7 +87,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<CommentInteract
|
||||
RetryLoadingMoreCallback retryLoadingMoreCallback) {
|
||||
super(DIFF_CALLBACK);
|
||||
mActivity = activity;
|
||||
mOauthRetrofit = oauthRetrofit;
|
||||
retrofit = oauthRetrofit;
|
||||
mRetryLoadingMoreCallback = retryLoadingMoreCallback;
|
||||
|
||||
mColorAccent = customThemeWrapper.getColorAccent();
|
||||
@ -190,7 +194,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<CommentInteract
|
||||
holder.itemView.setBackgroundColor(mMessageBackgroundColor);
|
||||
|
||||
|
||||
/*ReadMessage.readMessage(mOauthRetrofit, mAccessToken, message.getId(),
|
||||
ReadMessage.readMessage(retrofit, mAccessToken, message.getId(),
|
||||
new ReadMessage.ReadMessageListener() {
|
||||
@Override
|
||||
public void readSuccess() {
|
||||
@ -203,7 +207,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<CommentInteract
|
||||
message.markAsUnRead();
|
||||
holder.itemView.setBackgroundColor(mUnreadMessageBackgroundColor);
|
||||
}
|
||||
});*/
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -13,6 +13,8 @@ import eu.toldi.infinityforlemmy.dto.EditCommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.EditPostDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.FollowCommunityDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.PostVoteDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReadCommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReadMessageDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReadPostDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.SaveCommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.SavePostDTO;
|
||||
@ -51,6 +53,14 @@ public interface LemmyAPI {
|
||||
@GET("api/v3/user/unread_count")
|
||||
Call<MessageCount> userUnreadCount(@NonNull @Query("auth") String access_token);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/user/mention/mark_as_read")
|
||||
Call<String> userMentionMarkAsRead(@Body ReadMessageDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/comment/mark_as_read")
|
||||
Call<String> commentMarkAsRead(@Body ReadCommentDTO params);
|
||||
|
||||
@GET("api/v3/community")
|
||||
Call<String> communityInfo(@Query("name") String name, @Query("auth") String access_token);
|
||||
|
||||
|
@ -0,0 +1,26 @@
|
||||
package eu.toldi.infinityforlemmy.dto;
|
||||
|
||||
public class ReadCommentDTO {
|
||||
|
||||
private int comment_reply_id;
|
||||
private boolean read;
|
||||
private String auth;
|
||||
|
||||
public ReadCommentDTO(int comment_reply_id, boolean read, String auth) {
|
||||
this.comment_reply_id = comment_reply_id;
|
||||
this.read = read;
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
public int getComment_reply_id() {
|
||||
return comment_reply_id;
|
||||
}
|
||||
|
||||
public boolean isRead() {
|
||||
return read;
|
||||
}
|
||||
|
||||
public String getAuth() {
|
||||
return auth;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package eu.toldi.infinityforlemmy.dto;
|
||||
|
||||
public class ReadMessageDTO {
|
||||
|
||||
private int person_mention_id;
|
||||
private boolean read;
|
||||
private String auth;
|
||||
|
||||
public ReadMessageDTO(int person_mention_id, boolean read, String auth) {
|
||||
this.person_mention_id = person_mention_id;
|
||||
this.read = read;
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
public int getPerson_mention_id() {
|
||||
return person_mention_id;
|
||||
}
|
||||
|
||||
public boolean isRead() {
|
||||
return read;
|
||||
}
|
||||
|
||||
public String getAuth() {
|
||||
return auth;
|
||||
}
|
||||
}
|
@ -213,7 +213,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
@State
|
||||
boolean isFetchingComments = false;
|
||||
@State
|
||||
String mMessageFullname;
|
||||
int mMessageFullname;
|
||||
@State
|
||||
SortType.Type sortType;
|
||||
@State
|
||||
@ -553,7 +553,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
if (mSingleCommentId != 0) {
|
||||
isSingleCommentThreadMode = true;
|
||||
}
|
||||
mMessageFullname = getArguments().getString(EXTRA_MESSAGE_FULLNAME);
|
||||
mMessageFullname = getArguments().getInt(EXTRA_MESSAGE_FULLNAME);
|
||||
|
||||
if (!mRespectSubredditRecommendedSortType || isSingleCommentThreadMode) {
|
||||
sortType = loadSortType();
|
||||
@ -575,11 +575,11 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
}
|
||||
|
||||
private void bindView() {
|
||||
if (mAccessToken != null && mMessageFullname != null) {
|
||||
if (mAccessToken != null && mMessageFullname != 0) {
|
||||
ReadMessage.readMessage(mRetrofit.getRetrofit(), mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
|
||||
@Override
|
||||
public void readSuccess() {
|
||||
mMessageFullname = null;
|
||||
mMessageFullname = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,22 +2,17 @@ package eu.toldi.infinityforlemmy.message;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.dto.ReadCommentDTO;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class ReadMessage {
|
||||
public static void readMessage(Retrofit oauthRetrofit, String accessToken, String commaSeparatedFullnames,
|
||||
public static void readMessage(Retrofit oauthRetrofit, String accessToken, int messageId,
|
||||
ReadMessageListener readMessageListener) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(APIUtils.ID_KEY, commaSeparatedFullnames);
|
||||
oauthRetrofit.create(RedditAPI.class).readMessage(APIUtils.getOAuthHeader(accessToken), params)
|
||||
oauthRetrofit.create(LemmyAPI.class).commentMarkAsRead(new ReadCommentDTO(messageId, true, accessToken))
|
||||
.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
|
Loading…
Reference in New Issue
Block a user