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 ArrayList<ProvideUserAvatarCallback> mProvideUserAvatarCallbacks;
|
||||
private LoadUserDataAsyncTask mLoadUserDataAsyncTask;
|
||||
private boolean isSendingMessage = false;
|
||||
private int mSecondaryTextColor;
|
||||
private int mSendMessageIconColor;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -114,9 +117,6 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
Intent intent = getIntent();
|
||||
privateMessage = intent.getParcelableExtra(EXTRA_PRIVATE_MESSAGE);
|
||||
|
||||
if (privateMessage != null) {
|
||||
mToolbar.setTitle(privateMessage.getSubject());
|
||||
}
|
||||
setSupportActionBar(mToolbar);
|
||||
setToolbarGoToTop(mToolbar);
|
||||
|
||||
@ -151,6 +151,23 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
}
|
||||
|
||||
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,
|
||||
getResources().getConfiguration().locale, privateMessage, mAccountName, mCustomThemeWrapper);
|
||||
mLinearLayoutManager = new LinearLayoutManager(this);
|
||||
@ -159,6 +176,7 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
goToBottom();
|
||||
mSendImageView.setOnClickListener(view -> {
|
||||
if (!isSendingMessage) {
|
||||
if (!mEditText.getText().toString().equals("")) {
|
||||
//Send Message
|
||||
if (privateMessage != null) {
|
||||
@ -170,6 +188,8 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
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() {
|
||||
@ -180,6 +200,8 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
}
|
||||
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)));
|
||||
}
|
||||
|
||||
@ -190,6 +212,8 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
} 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();
|
||||
@ -215,10 +239,12 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
});
|
||||
}
|
||||
} else {
|
||||
isSendingMessage = false;
|
||||
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);
|
||||
mDivider.setBackgroundColor(mCustomThemeWrapper.getDividerColor());
|
||||
mEditText.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||
mEditText.setHintTextColor(mCustomThemeWrapper.getSecondaryTextColor());
|
||||
mSecondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor();
|
||||
mEditText.setHintTextColor(mSecondaryTextColor);
|
||||
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
|
||||
|
@ -20,6 +20,7 @@ public class Message implements Parcelable {
|
||||
private String fullname;
|
||||
private String subject;
|
||||
private String author;
|
||||
private String destination;
|
||||
private String parentFullName;
|
||||
private String title;
|
||||
private String body;
|
||||
@ -34,9 +35,9 @@ public class Message implements Parcelable {
|
||||
private ArrayList<Message> replies;
|
||||
|
||||
Message(String kind, String subredditName, String subredditNamePrefixed, String id, String fullname,
|
||||
String subject, String author, String parentFullName, String title, String body, String context,
|
||||
String distinguished, String formattedTime, boolean wasComment, boolean isNew, int score,
|
||||
int nComments, long timeUTC) {
|
||||
String subject, String author, String destination, String parentFullName, String title, String body,
|
||||
String context, String distinguished, String formattedTime, boolean wasComment, boolean isNew,
|
||||
int score, int nComments, long timeUTC) {
|
||||
this.kind = kind;
|
||||
this.subredditName = subredditName;
|
||||
this.subredditNamePrefixed = subredditNamePrefixed;
|
||||
@ -44,6 +45,7 @@ public class Message implements Parcelable {
|
||||
this.fullname = fullname;
|
||||
this.subject = subject;
|
||||
this.author = author;
|
||||
this.destination = destination;
|
||||
this.parentFullName = parentFullName;
|
||||
this.title = title;
|
||||
this.body = body;
|
||||
@ -66,6 +68,7 @@ public class Message implements Parcelable {
|
||||
fullname = in.readString();
|
||||
subject = in.readString();
|
||||
author = in.readString();
|
||||
destination = in.readString();
|
||||
parentFullName = in.readString();
|
||||
title = in.readString();
|
||||
body = in.readString();
|
||||
@ -120,6 +123,10 @@ public class Message implements Parcelable {
|
||||
return author;
|
||||
}
|
||||
|
||||
public String getDestination() {
|
||||
return destination;
|
||||
}
|
||||
|
||||
public String getParentFullName() {
|
||||
return parentFullName;
|
||||
}
|
||||
@ -197,6 +204,7 @@ public class Message implements Parcelable {
|
||||
parcel.writeString(fullname);
|
||||
parcel.writeString(subject);
|
||||
parcel.writeString(author);
|
||||
parcel.writeString(destination);
|
||||
parcel.writeString(parentFullName);
|
||||
parcel.writeString(title);
|
||||
parcel.writeString(body);
|
||||
|
@ -60,6 +60,7 @@ public class ParseMessage {
|
||||
String fullname = rawMessageJSON.getString(JSONUtils.NAME_KEY);
|
||||
String subject = rawMessageJSON.getString(JSONUtils.SUBJECT_KEY);
|
||||
String author = rawMessageJSON.getString(JSONUtils.AUTHOR_KEY);
|
||||
String destination = rawMessageJSON.getString(JSONUtils.DEST_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 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,
|
||||
author, parentFullname, title, body, context, distinguished, formattedTime,
|
||||
author, destination, parentFullname, title, body, context, distinguished, formattedTime,
|
||||
wasComment, isNew, score, nComments, timeUTC);
|
||||
if (replies != null) {
|
||||
message.setReplies(replies);
|
||||
|
@ -121,4 +121,5 @@ public class JSONUtils {
|
||||
public static final String S_KEY = "s";
|
||||
public static final String X_KEY = "x";
|
||||
public static final String Y_KEY = "y";
|
||||
public static final String DEST_KEY = "dest";
|
||||
}
|
||||
|
@ -106,7 +106,7 @@
|
||||
|
||||
<TextView
|
||||
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_marginTop="8dp"
|
||||
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_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_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_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>
|
||||
|
Loading…
Reference in New Issue
Block a user