mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-28 11:58:23 +01:00
Add a boolean variable isSendingMessage to avoid sending multiple messages before the first message is sent in ViewPrivateMessageActivity. When the message is being sent, the send button will have a secondary text color. Use wrap_content for comment content in item_comment.
This commit is contained in:
parent
7d1aa07b9d
commit
d06f66975e
@ -92,6 +92,9 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
private String mUserAvatar;
|
private String mUserAvatar;
|
||||||
private ArrayList<ProvideUserAvatarCallback> mProvideUserAvatarCallbacks;
|
private ArrayList<ProvideUserAvatarCallback> mProvideUserAvatarCallbacks;
|
||||||
private LoadUserDataAsyncTask mLoadUserDataAsyncTask;
|
private LoadUserDataAsyncTask mLoadUserDataAsyncTask;
|
||||||
|
private boolean isSendingMessage = false;
|
||||||
|
private int mSecondaryTextColor;
|
||||||
|
private int mSendMessageIconColor;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -114,9 +117,6 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
privateMessage = intent.getParcelableExtra(EXTRA_PRIVATE_MESSAGE);
|
privateMessage = intent.getParcelableExtra(EXTRA_PRIVATE_MESSAGE);
|
||||||
|
|
||||||
if (privateMessage != null) {
|
|
||||||
mToolbar.setTitle(privateMessage.getSubject());
|
|
||||||
}
|
|
||||||
setSupportActionBar(mToolbar);
|
setSupportActionBar(mToolbar);
|
||||||
setToolbarGoToTop(mToolbar);
|
setToolbarGoToTop(mToolbar);
|
||||||
|
|
||||||
@ -151,6 +151,23 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void bindView() {
|
private void bindView() {
|
||||||
|
if (privateMessage != null) {
|
||||||
|
if (privateMessage.getAuthor().equals(mAccountName)) {
|
||||||
|
mToolbar.setTitle(privateMessage.getDestination());
|
||||||
|
mToolbar.setOnClickListener(view -> {
|
||||||
|
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getDestination());
|
||||||
|
startActivity(intent);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
mToolbar.setTitle(privateMessage.getAuthor());
|
||||||
|
mToolbar.setOnClickListener(view -> {
|
||||||
|
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getAuthor());
|
||||||
|
startActivity(intent);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
mAdapter = new PrivateMessagesDetailRecyclerViewAdapter(this, mSharedPreferences,
|
mAdapter = new PrivateMessagesDetailRecyclerViewAdapter(this, mSharedPreferences,
|
||||||
getResources().getConfiguration().locale, privateMessage, mAccountName, mCustomThemeWrapper);
|
getResources().getConfiguration().locale, privateMessage, mAccountName, mCustomThemeWrapper);
|
||||||
mLinearLayoutManager = new LinearLayoutManager(this);
|
mLinearLayoutManager = new LinearLayoutManager(this);
|
||||||
@ -159,63 +176,72 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
mRecyclerView.setAdapter(mAdapter);
|
mRecyclerView.setAdapter(mAdapter);
|
||||||
goToBottom();
|
goToBottom();
|
||||||
mSendImageView.setOnClickListener(view -> {
|
mSendImageView.setOnClickListener(view -> {
|
||||||
if (!mEditText.getText().toString().equals("")) {
|
if (!isSendingMessage) {
|
||||||
//Send Message
|
if (!mEditText.getText().toString().equals("")) {
|
||||||
if (privateMessage != null) {
|
//Send Message
|
||||||
Message replyTo;
|
if (privateMessage != null) {
|
||||||
ArrayList<Message> replies = privateMessage.getReplies();
|
Message replyTo;
|
||||||
if (replies != null && !replies.isEmpty()) {
|
ArrayList<Message> replies = privateMessage.getReplies();
|
||||||
replyTo = replies.get(replies.size() - 1);
|
|
||||||
} else {
|
|
||||||
replyTo = privateMessage;
|
|
||||||
}
|
|
||||||
if (replyTo != null) {
|
|
||||||
ReplyMessage.replyMessage(mEditText.getText().toString(), replyTo.getFullname(),
|
|
||||||
getResources().getConfiguration().locale, mOauthRetrofit, mAccessToken,
|
|
||||||
new ReplyMessage.ReplyMessageListener() {
|
|
||||||
@Override
|
|
||||||
public void replyMessageSuccess(Message message) {
|
|
||||||
if (mAdapter != null) {
|
|
||||||
mAdapter.addReply(message);
|
|
||||||
}
|
|
||||||
goToBottom();
|
|
||||||
mEditText.setText("");
|
|
||||||
EventBus.getDefault().post(new RepliedToPrivateMessageEvent(message, getIntent().getIntExtra(EXTRA_MESSAGE_POSITION, -1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void replyMessageFailed(String errorMessage) {
|
|
||||||
if (errorMessage != null && !errorMessage.equals("")) {
|
|
||||||
Snackbar.make(mCoordinatorLayout, errorMessage, Snackbar.LENGTH_LONG).show();
|
|
||||||
} else {
|
|
||||||
Snackbar.make(mCoordinatorLayout, R.string.reply_message_failed, Snackbar.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
StringBuilder fullnames = new StringBuilder();
|
|
||||||
if (privateMessage.isNew()) {
|
|
||||||
fullnames.append(privateMessage.getFullname()).append(",");
|
|
||||||
}
|
|
||||||
if (replies != null && !replies.isEmpty()) {
|
if (replies != null && !replies.isEmpty()) {
|
||||||
for (Message m : replies) {
|
replyTo = replies.get(replies.size() - 1);
|
||||||
if (m.isNew()) {
|
} else {
|
||||||
fullnames.append(m).append(",");
|
replyTo = privateMessage;
|
||||||
|
}
|
||||||
|
if (replyTo != null) {
|
||||||
|
isSendingMessage = true;
|
||||||
|
mSendImageView.setColorFilter(mSecondaryTextColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
ReplyMessage.replyMessage(mEditText.getText().toString(), replyTo.getFullname(),
|
||||||
|
getResources().getConfiguration().locale, mOauthRetrofit, mAccessToken,
|
||||||
|
new ReplyMessage.ReplyMessageListener() {
|
||||||
|
@Override
|
||||||
|
public void replyMessageSuccess(Message message) {
|
||||||
|
if (mAdapter != null) {
|
||||||
|
mAdapter.addReply(message);
|
||||||
|
}
|
||||||
|
goToBottom();
|
||||||
|
mEditText.setText("");
|
||||||
|
mSendImageView.setColorFilter(mSendMessageIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
isSendingMessage = false;
|
||||||
|
EventBus.getDefault().post(new RepliedToPrivateMessageEvent(message, getIntent().getIntExtra(EXTRA_MESSAGE_POSITION, -1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void replyMessageFailed(String errorMessage) {
|
||||||
|
if (errorMessage != null && !errorMessage.equals("")) {
|
||||||
|
Snackbar.make(mCoordinatorLayout, errorMessage, Snackbar.LENGTH_LONG).show();
|
||||||
|
} else {
|
||||||
|
Snackbar.make(mCoordinatorLayout, R.string.reply_message_failed, Snackbar.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
mSendImageView.setColorFilter(mSendMessageIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
isSendingMessage = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
StringBuilder fullnames = new StringBuilder();
|
||||||
|
if (privateMessage.isNew()) {
|
||||||
|
fullnames.append(privateMessage.getFullname()).append(",");
|
||||||
|
}
|
||||||
|
if (replies != null && !replies.isEmpty()) {
|
||||||
|
for (Message m : replies) {
|
||||||
|
if (m.isNew()) {
|
||||||
|
fullnames.append(m).append(",");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (fullnames.length() > 0) {
|
||||||
if (fullnames.length() > 0) {
|
fullnames.deleteCharAt(fullnames.length() - 1);
|
||||||
fullnames.deleteCharAt(fullnames.length() - 1);
|
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, fullnames.toString(),
|
||||||
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, fullnames.toString(),
|
new ReadMessage.ReadMessageListener() {
|
||||||
new ReadMessage.ReadMessageListener() {
|
@Override
|
||||||
@Override
|
public void readSuccess() {}
|
||||||
public void readSuccess() {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFailed() {}
|
public void readFailed() {}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isSendingMessage = false;
|
||||||
|
Snackbar.make(mCoordinatorLayout, R.string.error_getting_message, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Snackbar.make(mCoordinatorLayout, R.string.error_getting_message, Snackbar.LENGTH_LONG).show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,9 +311,11 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
applyAppBarLayoutAndToolbarTheme(mAppBarLayout, mToolbar);
|
applyAppBarLayoutAndToolbarTheme(mAppBarLayout, mToolbar);
|
||||||
mDivider.setBackgroundColor(mCustomThemeWrapper.getDividerColor());
|
mDivider.setBackgroundColor(mCustomThemeWrapper.getDividerColor());
|
||||||
mEditText.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
mEditText.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||||
mEditText.setHintTextColor(mCustomThemeWrapper.getSecondaryTextColor());
|
mSecondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor();
|
||||||
|
mEditText.setHintTextColor(mSecondaryTextColor);
|
||||||
mEditTextLinearLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
mEditTextLinearLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||||
mSendImageView.setColorFilter(mCustomThemeWrapper.getSendMessageIconColor(), android.graphics.PorterDuff.Mode.SRC_IN);
|
mSendMessageIconColor = mCustomThemeWrapper.getSendMessageIconColor();
|
||||||
|
mSendImageView.setColorFilter(mSendMessageIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,6 +20,7 @@ public class Message implements Parcelable {
|
|||||||
private String fullname;
|
private String fullname;
|
||||||
private String subject;
|
private String subject;
|
||||||
private String author;
|
private String author;
|
||||||
|
private String destination;
|
||||||
private String parentFullName;
|
private String parentFullName;
|
||||||
private String title;
|
private String title;
|
||||||
private String body;
|
private String body;
|
||||||
@ -34,9 +35,9 @@ public class Message implements Parcelable {
|
|||||||
private ArrayList<Message> replies;
|
private ArrayList<Message> replies;
|
||||||
|
|
||||||
Message(String kind, String subredditName, String subredditNamePrefixed, String id, String fullname,
|
Message(String kind, String subredditName, String subredditNamePrefixed, String id, String fullname,
|
||||||
String subject, String author, String parentFullName, String title, String body, String context,
|
String subject, String author, String destination, String parentFullName, String title, String body,
|
||||||
String distinguished, String formattedTime, boolean wasComment, boolean isNew, int score,
|
String context, String distinguished, String formattedTime, boolean wasComment, boolean isNew,
|
||||||
int nComments, long timeUTC) {
|
int score, int nComments, long timeUTC) {
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
this.subredditName = subredditName;
|
this.subredditName = subredditName;
|
||||||
this.subredditNamePrefixed = subredditNamePrefixed;
|
this.subredditNamePrefixed = subredditNamePrefixed;
|
||||||
@ -44,6 +45,7 @@ public class Message implements Parcelable {
|
|||||||
this.fullname = fullname;
|
this.fullname = fullname;
|
||||||
this.subject = subject;
|
this.subject = subject;
|
||||||
this.author = author;
|
this.author = author;
|
||||||
|
this.destination = destination;
|
||||||
this.parentFullName = parentFullName;
|
this.parentFullName = parentFullName;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.body = body;
|
this.body = body;
|
||||||
@ -66,6 +68,7 @@ public class Message implements Parcelable {
|
|||||||
fullname = in.readString();
|
fullname = in.readString();
|
||||||
subject = in.readString();
|
subject = in.readString();
|
||||||
author = in.readString();
|
author = in.readString();
|
||||||
|
destination = in.readString();
|
||||||
parentFullName = in.readString();
|
parentFullName = in.readString();
|
||||||
title = in.readString();
|
title = in.readString();
|
||||||
body = in.readString();
|
body = in.readString();
|
||||||
@ -120,6 +123,10 @@ public class Message implements Parcelable {
|
|||||||
return author;
|
return author;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDestination() {
|
||||||
|
return destination;
|
||||||
|
}
|
||||||
|
|
||||||
public String getParentFullName() {
|
public String getParentFullName() {
|
||||||
return parentFullName;
|
return parentFullName;
|
||||||
}
|
}
|
||||||
@ -197,6 +204,7 @@ public class Message implements Parcelable {
|
|||||||
parcel.writeString(fullname);
|
parcel.writeString(fullname);
|
||||||
parcel.writeString(subject);
|
parcel.writeString(subject);
|
||||||
parcel.writeString(author);
|
parcel.writeString(author);
|
||||||
|
parcel.writeString(destination);
|
||||||
parcel.writeString(parentFullName);
|
parcel.writeString(parentFullName);
|
||||||
parcel.writeString(title);
|
parcel.writeString(title);
|
||||||
parcel.writeString(body);
|
parcel.writeString(body);
|
||||||
|
@ -60,6 +60,7 @@ public class ParseMessage {
|
|||||||
String fullname = rawMessageJSON.getString(JSONUtils.NAME_KEY);
|
String fullname = rawMessageJSON.getString(JSONUtils.NAME_KEY);
|
||||||
String subject = rawMessageJSON.getString(JSONUtils.SUBJECT_KEY);
|
String subject = rawMessageJSON.getString(JSONUtils.SUBJECT_KEY);
|
||||||
String author = rawMessageJSON.getString(JSONUtils.AUTHOR_KEY);
|
String author = rawMessageJSON.getString(JSONUtils.AUTHOR_KEY);
|
||||||
|
String destination = rawMessageJSON.getString(JSONUtils.DEST_KEY);
|
||||||
String parentFullname = rawMessageJSON.getString(JSONUtils.PARENT_ID_KEY);
|
String parentFullname = rawMessageJSON.getString(JSONUtils.PARENT_ID_KEY);
|
||||||
String title = rawMessageJSON.has(JSONUtils.LINK_TITLE_KEY) ? rawMessageJSON.getString(JSONUtils.LINK_TITLE_KEY) : null;
|
String title = rawMessageJSON.has(JSONUtils.LINK_TITLE_KEY) ? rawMessageJSON.getString(JSONUtils.LINK_TITLE_KEY) : null;
|
||||||
String body = Utils.modifyMarkdown(rawMessageJSON.getString(JSONUtils.BODY_KEY));
|
String body = Utils.modifyMarkdown(rawMessageJSON.getString(JSONUtils.BODY_KEY));
|
||||||
@ -84,7 +85,7 @@ public class ParseMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Message message = new Message(kind, subredditName, subredditNamePrefixed, id, fullname, subject,
|
Message message = new Message(kind, subredditName, subredditNamePrefixed, id, fullname, subject,
|
||||||
author, parentFullname, title, body, context, distinguished, formattedTime,
|
author, destination, parentFullname, title, body, context, distinguished, formattedTime,
|
||||||
wasComment, isNew, score, nComments, timeUTC);
|
wasComment, isNew, score, nComments, timeUTC);
|
||||||
if (replies != null) {
|
if (replies != null) {
|
||||||
message.setReplies(replies);
|
message.setReplies(replies);
|
||||||
|
@ -121,4 +121,5 @@ public class JSONUtils {
|
|||||||
public static final String S_KEY = "s";
|
public static final String S_KEY = "s";
|
||||||
public static final String X_KEY = "x";
|
public static final String X_KEY = "x";
|
||||||
public static final String Y_KEY = "y";
|
public static final String Y_KEY = "y";
|
||||||
|
public static final String DEST_KEY = "dest";
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@
|
|||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/comment_markdown_view_item_post_comment"
|
android:id="@+id/comment_markdown_view_item_post_comment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
|
@ -357,7 +357,7 @@
|
|||||||
<string name="settings_start_autoplay_visible_area_offset_landscape_title">Autoplay Videos Visible Area Offset (Landscape)</string>
|
<string name="settings_start_autoplay_visible_area_offset_landscape_title">Autoplay Videos Visible Area Offset (Landscape)</string>
|
||||||
<string name="settings_start_autoplay_visible_area_offset_landscape_summary">Start autoplaying videos when %1$d%% of them are visible</string>
|
<string name="settings_start_autoplay_visible_area_offset_landscape_summary">Start autoplaying videos when %1$d%% of them are visible</string>
|
||||||
<string name="settings_immersive_interface_title">Immersive Interface</string>
|
<string name="settings_immersive_interface_title">Immersive Interface</string>
|
||||||
<string name="settings_immersive_interface_summary">Does Not Apply to All Pages</string>
|
<string name="settings_immersive_interface_summary">Does Not Apply to All Pages\nMay Not Work On Android 11</string>
|
||||||
<string name="settings_immersive_interface_ignore_nav_bar_title">Ignore Navigation Bar in Immersive Interface</string>
|
<string name="settings_immersive_interface_ignore_nav_bar_title">Ignore Navigation Bar in Immersive Interface</string>
|
||||||
<string name="settings_immersive_interface_ignore_nav_bar_summary">Prevent the Bottom Navigation Bar Having Extra Padding</string>
|
<string name="settings_immersive_interface_ignore_nav_bar_summary">Prevent the Bottom Navigation Bar Having Extra Padding</string>
|
||||||
<string name="settings_customize_tabs_in_main_page_title">Customize Tabs in Main Page</string>
|
<string name="settings_customize_tabs_in_main_page_title">Customize Tabs in Main Page</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user