fix quick reply
This commit is contained in:
parent
4edaa45986
commit
87d29e835a
|
@ -1999,6 +1999,10 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
|
|||
holder.spark_button_reblog.playAnimation();
|
||||
}
|
||||
|
||||
if( status.isShortReply()) {
|
||||
manageQuickReplyOpen(status, holder);
|
||||
}
|
||||
|
||||
Helper.changeDrawableColor(context, R.drawable.ic_photo, R.color.cyanea_accent_reference);
|
||||
Helper.changeDrawableColor(context, R.drawable.ic_more_toot_content, R.color.cyanea_accent_reference);
|
||||
|
||||
|
@ -2254,7 +2258,10 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
|
|||
holder.status_reply.setOnClickListener(v -> {
|
||||
|
||||
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED || (quick_reply && type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS)) {
|
||||
|
||||
toot_content = null;
|
||||
toot_cw_content = null;
|
||||
tootReply = null;
|
||||
currentToId = -1;
|
||||
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
|
||||
holder.quick_reply_switch_to_full.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -2275,119 +2282,7 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
|
|||
|
||||
boolean shown = status.isShortReply();
|
||||
if (!shown) {
|
||||
for (Status s : statuses) {
|
||||
if (s.isShortReply() && !s.getId().equals(status.getId())) {
|
||||
s.setShortReply(false);
|
||||
notifyStatusChanged(s);
|
||||
}
|
||||
}
|
||||
status.setShortReply(true);
|
||||
statusForQuickReply = status;
|
||||
holder.quick_reply_container.setVisibility(View.VISIBLE);
|
||||
InputMethodManager inputMethodManager =
|
||||
(InputMethodManager) context.getSystemService(INPUT_METHOD_SERVICE);
|
||||
inputMethodManager.toggleSoftInputFromWindow(
|
||||
holder.quick_reply_text.getApplicationWindowToken(),
|
||||
InputMethodManager.SHOW_FORCED, 0);
|
||||
holder.quick_reply_text.requestFocus();
|
||||
EditText content_cw = new EditText(context);
|
||||
content_cw.setText(status.getReblog() != null ? status.getReblog().getSpoiler_text() : status.getSpoiler_text());
|
||||
if (status.getQuickReplyContent() == null) {
|
||||
TootActivity.manageMentions(context, social, userId,
|
||||
holder.quick_reply_text, content_cw, holder.toot_space_left, status.getReblog() != null ? status.getReblog() : status);
|
||||
} else {
|
||||
holder.quick_reply_text.setText(status.getQuickReplyContent());
|
||||
}
|
||||
TextWatcher textWatcher = TootActivity.initializeTextWatcher(context, social, status, holder.quick_reply_text, content_cw, holder.toot_space_left, null, null, BaseStatusListAdapter.this, BaseStatusListAdapter.this, BaseStatusListAdapter.this);
|
||||
|
||||
toot_content = holder.quick_reply_text;
|
||||
int newInputType = toot_content.getInputType() & (toot_content.getInputType() ^ InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
|
||||
toot_content.setInputType(newInputType);
|
||||
toot_cw_content = content_cw;
|
||||
toot_space_left = holder.toot_space_left;
|
||||
in_reply_to_status = status.getReblog() != null ? status.getReblog().getId() : status.getId();
|
||||
tootReply = status;
|
||||
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
||||
String defaultVisibility = account.isLocked() ? "private" : "public";
|
||||
String settingsVisibility = sharedpreferences.getString(Helper.SET_TOOT_VISIBILITY + "@" + account.getAcct() + "@" + account.getInstance(), defaultVisibility);
|
||||
int initialTootVisibility = 0;
|
||||
int ownerTootVisibility = 0;
|
||||
switch (status.getReblog() != null ? status.getReblog().getVisibility() : status.getVisibility()) {
|
||||
case "public":
|
||||
initialTootVisibility = 4;
|
||||
break;
|
||||
case "unlisted":
|
||||
initialTootVisibility = 3;
|
||||
break;
|
||||
case "private":
|
||||
status.setQuickReplyPrivacy("private");
|
||||
initialTootVisibility = 2;
|
||||
break;
|
||||
case "direct":
|
||||
status.setQuickReplyPrivacy("direct");
|
||||
initialTootVisibility = 1;
|
||||
break;
|
||||
}
|
||||
if (settingsVisibility != null) {
|
||||
switch (settingsVisibility) {
|
||||
case "public":
|
||||
ownerTootVisibility = 4;
|
||||
break;
|
||||
case "unlisted":
|
||||
ownerTootVisibility = 3;
|
||||
break;
|
||||
case "private":
|
||||
status.setQuickReplyPrivacy("private");
|
||||
ownerTootVisibility = 2;
|
||||
break;
|
||||
case "direct":
|
||||
status.setQuickReplyPrivacy("direct");
|
||||
ownerTootVisibility = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int tootVisibility = Math.min(ownerTootVisibility, initialTootVisibility);
|
||||
|
||||
switch (tootVisibility) {
|
||||
case 4:
|
||||
status.setQuickReplyPrivacy("public");
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_public_toot);
|
||||
break;
|
||||
case 3:
|
||||
status.setQuickReplyPrivacy("unlisted");
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_open_toot);
|
||||
break;
|
||||
case 2:
|
||||
status.setQuickReplyPrivacy("private");
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_outline_toot);
|
||||
break;
|
||||
case 1:
|
||||
status.setQuickReplyPrivacy("direct");
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_mail_outline_toot);
|
||||
break;
|
||||
}
|
||||
if (status.getQuickReplyPrivacy() != null) {
|
||||
switch (status.getQuickReplyPrivacy()) {
|
||||
case "public":
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_public_toot);
|
||||
break;
|
||||
case "unlisted":
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_open_toot);
|
||||
break;
|
||||
case "private":
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_outline_toot);
|
||||
break;
|
||||
case "direct":
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_mail_outline_toot);
|
||||
break;
|
||||
}
|
||||
}
|
||||
holder.quick_reply_text.addTextChangedListener(textWatcher);
|
||||
|
||||
manageQuickReplyOpen(status, holder);
|
||||
|
||||
} else {
|
||||
status.setShortReply(false);
|
||||
|
@ -3015,6 +2910,126 @@ public abstract class BaseStatusListAdapter extends RecyclerView.Adapter<Recycle
|
|||
|
||||
}
|
||||
|
||||
private void manageQuickReplyOpen(Status status, ViewHolder holder){
|
||||
for (Status s : statuses) {
|
||||
if (s.isShortReply() && !s.getId().equals(status.getId())) {
|
||||
s.setShortReply(false);
|
||||
notifyStatusChanged(s);
|
||||
}
|
||||
}
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
status.setShortReply(true);
|
||||
statusForQuickReply = status;
|
||||
holder.quick_reply_container.setVisibility(View.VISIBLE);
|
||||
InputMethodManager inputMethodManager =
|
||||
(InputMethodManager) context.getSystemService(INPUT_METHOD_SERVICE);
|
||||
if (inputMethodManager != null) {
|
||||
inputMethodManager.toggleSoftInputFromWindow(
|
||||
holder.quick_reply_text.getApplicationWindowToken(),
|
||||
InputMethodManager.SHOW_FORCED, 0);
|
||||
}
|
||||
holder.quick_reply_text.requestFocus();
|
||||
EditText content_cw = new EditText(context);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
content_cw.setText(status.getReblog() != null ? status.getReblog().getSpoiler_text() : status.getSpoiler_text());
|
||||
if (status.getQuickReplyContent() == null) {
|
||||
TootActivity.manageMentions(context, social, userId,
|
||||
holder.quick_reply_text, content_cw, holder.toot_space_left, status.getReblog() != null ? status.getReblog() : status);
|
||||
} else {
|
||||
holder.quick_reply_text.setText(status.getQuickReplyContent());
|
||||
}
|
||||
TextWatcher textWatcher = TootActivity.initializeTextWatcher(context, social, status, holder.quick_reply_text, content_cw, holder.toot_space_left, null, null, BaseStatusListAdapter.this, BaseStatusListAdapter.this, BaseStatusListAdapter.this);
|
||||
|
||||
toot_content = holder.quick_reply_text;
|
||||
int newInputType = toot_content.getInputType() & (toot_content.getInputType() ^ InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
|
||||
toot_content.setInputType(newInputType);
|
||||
toot_cw_content = content_cw;
|
||||
toot_space_left = holder.toot_space_left;
|
||||
in_reply_to_status = status.getReblog() != null ? status.getReblog().getId() : status.getId();
|
||||
tootReply = status;
|
||||
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
||||
String defaultVisibility = account.isLocked() ? "private" : "public";
|
||||
String settingsVisibility = sharedpreferences.getString(Helper.SET_TOOT_VISIBILITY + "@" + account.getAcct() + "@" + account.getInstance(), defaultVisibility);
|
||||
int initialTootVisibility = 0;
|
||||
int ownerTootVisibility = 0;
|
||||
switch (status.getReblog() != null ? status.getReblog().getVisibility() : status.getVisibility()) {
|
||||
case "public":
|
||||
initialTootVisibility = 4;
|
||||
break;
|
||||
case "unlisted":
|
||||
initialTootVisibility = 3;
|
||||
break;
|
||||
case "private":
|
||||
status.setQuickReplyPrivacy("private");
|
||||
initialTootVisibility = 2;
|
||||
break;
|
||||
case "direct":
|
||||
status.setQuickReplyPrivacy("direct");
|
||||
initialTootVisibility = 1;
|
||||
break;
|
||||
}
|
||||
if (settingsVisibility != null) {
|
||||
switch (settingsVisibility) {
|
||||
case "public":
|
||||
ownerTootVisibility = 4;
|
||||
break;
|
||||
case "unlisted":
|
||||
ownerTootVisibility = 3;
|
||||
break;
|
||||
case "private":
|
||||
status.setQuickReplyPrivacy("private");
|
||||
ownerTootVisibility = 2;
|
||||
break;
|
||||
case "direct":
|
||||
status.setQuickReplyPrivacy("direct");
|
||||
ownerTootVisibility = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int tootVisibility = Math.min(ownerTootVisibility, initialTootVisibility);
|
||||
|
||||
switch (tootVisibility) {
|
||||
case 4:
|
||||
status.setQuickReplyPrivacy("public");
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_public_toot);
|
||||
break;
|
||||
case 3:
|
||||
status.setQuickReplyPrivacy("unlisted");
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_open_toot);
|
||||
break;
|
||||
case 2:
|
||||
status.setQuickReplyPrivacy("private");
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_outline_toot);
|
||||
break;
|
||||
case 1:
|
||||
status.setQuickReplyPrivacy("direct");
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_mail_outline_toot);
|
||||
break;
|
||||
}
|
||||
if (status.getQuickReplyPrivacy() != null) {
|
||||
switch (status.getQuickReplyPrivacy()) {
|
||||
case "public":
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_public_toot);
|
||||
break;
|
||||
case "unlisted":
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_open_toot);
|
||||
break;
|
||||
case "private":
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_outline_toot);
|
||||
break;
|
||||
case "direct":
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_mail_outline_toot);
|
||||
break;
|
||||
}
|
||||
}
|
||||
holder.quick_reply_text.addTextChangedListener(textWatcher);
|
||||
|
||||
}
|
||||
|
||||
protected abstract void statusAddReactionClick(Status status, ViewHolder viewHolder);
|
||||
|
||||
protected abstract void notificationCharts(Status status);
|
||||
|
|
Loading…
Reference in New Issue