Fix Direct messages

This commit is contained in:
Thomas 2023-09-09 16:10:33 +02:00
parent 57860793ff
commit 392efd2c0c
19 changed files with 102 additions and 128 deletions

View File

@ -1219,7 +1219,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
} }
if (!isFinishing()) { if (!isFinishing()) {
headerMainBinding.accountName.setText( headerMainBinding.accountName.setText(
currentAccount.mastodon_account.getSpanDisplayName(BaseMainActivity.this, currentAccount.mastodon_account.getSpanDisplayNameEmoji(BaseMainActivity.this,
new WeakReference<>(headerMainBinding.accountName)), new WeakReference<>(headerMainBinding.accountName)),
TextView.BufferType.SPANNABLE); TextView.BufferType.SPANNABLE);
} }

View File

@ -53,7 +53,6 @@ public class DirectMessageActivity extends BaseActivity implements FragmentMasto
public static boolean displayCW; public static boolean displayCW;
FragmentMastodonDirectMessage currentFragment; FragmentMastodonDirectMessage currentFragment;
private Status firstMessage;
private String remote_instance; private String remote_instance;
@Override @Override
@ -149,7 +148,6 @@ public class DirectMessageActivity extends BaseActivity implements FragmentMasto
@Override @Override
public void get(Status status) { public void get(Status status) {
firstMessage = status;
invalidateOptionsMenu(); invalidateOptionsMenu();
} }
} }

View File

@ -456,7 +456,7 @@ public class ProfileActivity extends BaseActivity {
} }
binding.accountDn.setText( binding.accountDn.setText(
account.getSpanDisplayName(ProfileActivity.this, account.getSpanDisplayNameEmoji(ProfileActivity.this,
new WeakReference<>(binding.accountDn)), new WeakReference<>(binding.accountDn)),
TextView.BufferType.SPANNABLE); TextView.BufferType.SPANNABLE);

View File

@ -310,7 +310,7 @@ public class AdminAccountActivity extends BaseActivity {
binding.accountDn.setText( binding.accountDn.setText(
adminAccount.account.getSpanDisplayName(AdminAccountActivity.this, adminAccount.account.getSpanDisplayNameEmoji(AdminAccountActivity.this,
new WeakReference<>(binding.accountDn)), new WeakReference<>(binding.accountDn)),
TextView.BufferType.SPANNABLE); TextView.BufferType.SPANNABLE);
binding.accountUn.setText(String.format("@%s", adminAccount.account.acct)); binding.accountUn.setText(String.format("@%s", adminAccount.account.acct));

View File

@ -328,7 +328,7 @@ public class AdminReportActivity extends BaseBarActivity {
} }
binding.accountDn.setText( binding.accountDn.setText(
account.getSpanDisplayName(AdminReportActivity.this, account.getSpanDisplayNameEmoji(AdminReportActivity.this,
new WeakReference<>(binding.accountDn)), new WeakReference<>(binding.accountDn)),
TextView.BufferType.SPANNABLE); TextView.BufferType.SPANNABLE);
binding.accountUn.setText(String.format("@%s", account.acct)); binding.accountUn.setText(String.format("@%s", account.acct));

View File

@ -89,14 +89,15 @@ public class Account implements Serializable {
public Role role; public Role role;
public transient RelationShip relationShip; public transient RelationShip relationShip;
public synchronized Spannable getSpanDisplayName(Context context, WeakReference<View> viewWeakReference) { public synchronized Spannable getSpanDisplayName(Context context, WeakReference<View> viewWeakReference) {
if (display_name == null || display_name.isEmpty()) { if (display_name == null || display_name.isEmpty()) {
display_name = username; display_name = username;
} }
return SpannableHelper.convert(context, display_name, null, this, null, viewWeakReference); return SpannableHelper.convert(context, display_name, null, this, null, viewWeakReference, null, true, false);
} }
public synchronized Spannable getSpanDisplayName(Activity activity, WeakReference<View> viewWeakReference) { public synchronized Spannable getSpanDisplayNameEmoji(Activity activity, WeakReference<View> viewWeakReference) {
if (display_name == null || display_name.isEmpty()) { if (display_name == null || display_name.isEmpty()) {
display_name = username; display_name = username;
} }
@ -104,11 +105,11 @@ public class Account implements Serializable {
} }
public synchronized Spannable getSpanDisplayNameTitle(Context context, WeakReference<View> viewWeakReference, String title) { public synchronized Spannable getSpanDisplayNameTitle(Context context, WeakReference<View> viewWeakReference, String title) {
return SpannableHelper.convert(context, title, null, this, null, viewWeakReference); return SpannableHelper.convert(context, title, null, this, null, viewWeakReference, null, true, false);
} }
public synchronized Spannable getSpanNote(Context context, WeakReference<View> viewWeakReference) { public synchronized Spannable getSpanNote(Context context, WeakReference<View> viewWeakReference) {
return SpannableHelper.convert(context, note, null, this, null, viewWeakReference); return SpannableHelper.convert(context, note, null, this, null, viewWeakReference, null, true, false);
} }
@Override @Override

View File

@ -56,7 +56,7 @@ public class Announcement {
public synchronized Spannable getSpanContent(Context context, WeakReference<View> viewWeakReference) { public synchronized Spannable getSpanContent(Context context, WeakReference<View> viewWeakReference) {
return SpannableHelper.convert(context, content, null, null, this, viewWeakReference); return SpannableHelper.convert(context, content, null, null, this, viewWeakReference, null, true, false);
} }
} }

View File

@ -47,7 +47,7 @@ public class Field implements Serializable {
if (verified_at != null && value != null) { if (verified_at != null && value != null) {
value_span = new ForegroundColorSpan(ContextCompat.getColor(context, R.color.verified_text)); value_span = new ForegroundColorSpan(ContextCompat.getColor(context, R.color.verified_text));
} }
Spannable spannable = SpannableHelper.convert(context, value, null, account, null, viewWeakReference); Spannable spannable = SpannableHelper.convert(context, value, null, account, null, viewWeakReference, null, true, false);
if (value_span != null && spannable != null) { if (value_span != null && spannable != null) {
spannable.setSpan(value_span, 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spannable.setSpan(value_span, 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
} }
@ -57,7 +57,7 @@ public class Field implements Serializable {
public synchronized Spannable getLabelSpan(Context context, Account account, WeakReference<View> viewWeakReference) { public synchronized Spannable getLabelSpan(Context context, Account account, WeakReference<View> viewWeakReference) {
Spannable spannable = SpannableHelper.convert(context, name, null, account, null, viewWeakReference); Spannable spannable = SpannableHelper.convert(context, name, null, account, null, viewWeakReference, null, true, false);
if (name_span != null && spannable != null) { if (name_span != null && spannable != null) {
spannable.setSpan(name_span, 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spannable.setSpan(name_span, 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
} }

View File

@ -133,6 +133,8 @@ public class Status implements Serializable, Cloneable {
public transient boolean setCursorToEnd = false; public transient boolean setCursorToEnd = false;
public transient int cursorPosition = 0; public transient int cursorPosition = 0;
public transient boolean submitted = false; public transient boolean submitted = false;
public transient boolean underlined = false;
public boolean spoilerChecked = false; public boolean spoilerChecked = false;
public Filter filteredByApp; public Filter filteredByApp;
public transient Spannable contentSpan; public transient Spannable contentSpan;
@ -152,21 +154,21 @@ public class Status implements Serializable, Cloneable {
public synchronized Spannable getSpanContent(Context context, WeakReference<View> viewWeakReference, Callback callback) { public synchronized Spannable getSpanContent(Context context, WeakReference<View> viewWeakReference, Callback callback) {
if (contentSpan == null) { if (contentSpan == null) {
contentSpan = SpannableHelper.convert(context, content, this, null, null, viewWeakReference, callback, true); contentSpan = SpannableHelper.convert(context, content, this, null, null, viewWeakReference, callback, true, true);
} }
return contentSpan; return contentSpan;
} }
public synchronized Spannable getSpanSpoiler(Context context, WeakReference<View> viewWeakReference, Callback callback) { public synchronized Spannable getSpanSpoiler(Context context, WeakReference<View> viewWeakReference, Callback callback) {
if (contentSpoilerSpan == null) { if (contentSpoilerSpan == null) {
contentSpoilerSpan = SpannableHelper.convert(context, spoiler_text, this, null, null, viewWeakReference, callback, false); contentSpoilerSpan = SpannableHelper.convert(context, spoiler_text, this, null, null, viewWeakReference, callback, true, false);
} }
return contentSpoilerSpan; return contentSpoilerSpan;
} }
public synchronized Spannable getSpanTranslate(Context context, WeakReference<View> viewWeakReference, Callback callback) { public synchronized Spannable getSpanTranslate(Context context, WeakReference<View> viewWeakReference, Callback callback) {
if (contentTranslateSpan == null) { if (contentTranslateSpan == null) {
contentTranslateSpan = SpannableHelper.convert(context, translationContent, this, null, null, viewWeakReference, callback, true); contentTranslateSpan = SpannableHelper.convert(context, translationContent, this, null, null, viewWeakReference, callback, true, true);
} }
return contentTranslateSpan; return contentTranslateSpan;
} }

View File

@ -2044,6 +2044,31 @@ public class Helper {
} }
} }
public static boolean isNumeric(String str) {
try {
Double.parseDouble(str);
return true;
} catch (NumberFormatException e) {
return false;
}
}
public static OkHttpClient myOkHttpClient(Context context) {
return new OkHttpClient.Builder()
.addInterceptor(chain -> {
Request originalRequest = chain.request();
Request requestWithUserAgent = originalRequest.newBuilder()
.header("User-Agent", context.getString(R.string.app_name) + "/" + BuildConfig.VERSION_NAME + "/" + BuildConfig.VERSION_CODE)
.build();
return chain.proceed(requestWithUserAgent);
})
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(context))
.build();
}
//Enum that described actions to replace inside a toot content //Enum that described actions to replace inside a toot content
public enum PatternType { public enum PatternType {
MENTION, MENTION,
@ -2074,29 +2099,4 @@ public class Helper {
public interface OnFileCopied { public interface OnFileCopied {
void onFileCopied(File file); void onFileCopied(File file);
} }
public static boolean isNumeric(String str) {
try {
Double.parseDouble(str);
return true;
} catch (NumberFormatException e) {
return false;
}
}
public static OkHttpClient myOkHttpClient(Context context) {
return new OkHttpClient.Builder()
.addInterceptor(chain -> {
Request originalRequest = chain.request();
Request requestWithUserAgent = originalRequest.newBuilder()
.header("User-Agent", context.getString(R.string.app_name) + "/" + BuildConfig.VERSION_NAME + "/" + BuildConfig.VERSION_CODE)
.build();
return chain.proceed(requestWithUserAgent);
})
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(context))
.build();
}
} }

View File

@ -62,9 +62,8 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class NotificationsHelper { public class NotificationsHelper {
public static HashMap<String, List<String>> pushed_notifications = new HashMap<>();
private static final HashMap<String, ReentrantLock> lockMap = new HashMap<>(); private static final HashMap<String, ReentrantLock> lockMap = new HashMap<>();
public static HashMap<String, List<String>> pushed_notifications = new HashMap<>();
private static ReentrantLock getLock(String slug) { private static ReentrantLock getLock(String slug) {
synchronized (lockMap) { synchronized (lockMap) {

View File

@ -43,7 +43,6 @@ import android.view.View;
import android.webkit.URLUtil; import android.webkit.URLUtil;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
@ -106,33 +105,6 @@ public class SpannableHelper {
public static final String CLICKABLE_SPAN = "CLICKABLE_SPAN"; public static final String CLICKABLE_SPAN = "CLICKABLE_SPAN";
private static int linkColor; private static int linkColor;
public static Spannable convert(Context context, String text,
Status status, Account account, Announcement announcement, WeakReference<View> viewWeakReference) {
return convert(context, text, status, account, announcement, viewWeakReference, null, true, false);
}
public static Spannable convert(Context context, String text,
Status status, Account account, Announcement announcement,
WeakReference<View> viewWeakReference, Status.Callback callback, boolean convertMarkdown) {
return convert(context, text, status, account, announcement, viewWeakReference, callback, true, convertMarkdown);
}
public static boolean isRTL(String s) {
for (int i = 0; i < s.length(); i++) {
byte d = Character.getDirectionality(s.charAt(i));
if (d == Character.DIRECTIONALITY_RIGHT_TO_LEFT ||
d == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC ||
d == Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING ||
d == Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE
) {
return true;
}
}
return false;
}
public static Spannable convert(Context context, String text, public static Spannable convert(Context context, String text,
Status status, Account account, Announcement announcement, Status status, Account account, Announcement announcement,
WeakReference<View> viewWeakReference, Status.Callback callback, boolean convertHtml, boolean convertMarkdown) { WeakReference<View> viewWeakReference, Status.Callback callback, boolean convertHtml, boolean convertMarkdown) {
@ -160,6 +132,10 @@ public class SpannableHelper {
if (linkColor == 0) { if (linkColor == 0) {
linkColor = -1; linkColor = -1;
} }
if (status != null && status.underlined) {
linkColor = -1;
}
List<Mention> mentions = new ArrayList<>(); List<Mention> mentions = new ArrayList<>();
if (status != null && status.mentions != null) { if (status != null && status.mentions != null) {
mentions.addAll(status.mentions); mentions.addAll(status.mentions);
@ -333,7 +309,7 @@ public class SpannableHelper {
@Override @Override
public void updateDrawState(@NonNull TextPaint ds) { public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds); super.updateDrawState(ds);
ds.setUnderlineText(false); ds.setUnderlineText(status != null && status.underlined);
if (linkColor != -1) { if (linkColor != -1) {
ds.setColor(linkColor); ds.setColor(linkColor);
} }
@ -341,10 +317,10 @@ public class SpannableHelper {
}, start, end, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); }, start, end, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
} else { } else {
makeLinks(context, content, url, start, end); makeLinks(context, status, content, url, start, end);
} }
replaceQuoteSpans(context, content); replaceQuoteSpans(context, content);
emails(context, content); emails(context, content, status);
} }
Pattern imgPattern = Pattern.compile("<img [^>]*src=\"([^\"]+)\"[^>]*>"); Pattern imgPattern = Pattern.compile("<img [^>]*src=\"([^\"]+)\"[^>]*>");
@ -390,25 +366,8 @@ public class SpannableHelper {
return trimSpannable(new SpannableStringBuilder(content)); return trimSpannable(new SpannableStringBuilder(content));
} }
public interface Prism4jTheme {
@ColorInt private static void makeLinks(Context context, Status status, SpannableStringBuilder content, String url, int start, int end) {
int background();
@ColorInt
int textColor();
void apply(
@NonNull String language,
@NonNull Prism4j.Syntax syntax,
@NonNull SpannableStringBuilder builder,
int start,
int end
);
}
private static void makeLinks(Context context, SpannableStringBuilder content, String url, int start, int end) {
String newUrl = url; String newUrl = url;
boolean validUrl = URLUtil.isValidUrl(url) && url.length() == (end - start); boolean validUrl = URLUtil.isValidUrl(url) && url.length() == (end - start);
if (validUrl) { if (validUrl) {
@ -640,7 +599,7 @@ public class SpannableHelper {
@Override @Override
public void updateDrawState(@NonNull TextPaint ds) { public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds); super.updateDrawState(ds);
ds.setUnderlineText(false); ds.setUnderlineText(status != null && status.underlined);
if (linkColor != -1) { if (linkColor != -1) {
ds.setColor(linkColor); ds.setColor(linkColor);
} }
@ -756,7 +715,7 @@ public class SpannableHelper {
} }
} }
private static void emails(Context context, Spannable content) { private static void emails(Context context, Spannable content, Status status) {
// --- For all patterns defined in Helper class --- // --- For all patterns defined in Helper class ---
Pattern pattern = Helper.emailPattern; Pattern pattern = Helper.emailPattern;
Matcher matcher = pattern.matcher(content); Matcher matcher = pattern.matcher(content);
@ -785,7 +744,7 @@ public class SpannableHelper {
@Override @Override
public void updateDrawState(@NonNull TextPaint ds) { public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds); super.updateDrawState(ds);
ds.setUnderlineText(false); ds.setUnderlineText(status != null && status.underlined);
if (linkColor != -1) { if (linkColor != -1) {
ds.setColor(linkColor); ds.setColor(linkColor);
} }

View File

@ -159,14 +159,13 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
private final String editMessageId; private final String editMessageId;
public ManageDrafts manageDrafts; public ManageDrafts manageDrafts;
public promptDraftListener promptDraftListener; public promptDraftListener promptDraftListener;
public MediaDescriptionCallBack mediaDescriptionCallBack;
private int statusCount; private int statusCount;
private Context context; private Context context;
private AlertDialog alertDialogEmoji; private AlertDialog alertDialogEmoji;
private List<Emoji> emojisList = new ArrayList<>(); private List<Emoji> emojisList = new ArrayList<>();
private boolean unlisted_changed = false; private boolean unlisted_changed = false;
private RecyclerView mRecyclerView; private RecyclerView mRecyclerView;
public MediaDescriptionCallBack mediaDescriptionCallBack;
public ComposeAdapter(List<Status> statusList, int statusCount, BaseAccount account, Account mentionedAccount, String visibility, String editMessageId) { public ComposeAdapter(List<Status> statusList, int statusCount, BaseAccount account, Account mentionedAccount, String visibility, String editMessageId) {
@ -1251,10 +1250,6 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
} }
} }
public interface MediaDescriptionCallBack {
void click(ComposeViewHolder holder, Attachment attachment, int messagePosition, int mediaPosition);
}
/** /**
* Manage state of media and poll button * Manage state of media and poll button
* *
@ -2052,7 +2047,6 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
alertPollDiaslog.show(); alertPollDiaslog.show();
} }
/** /**
* Display the emoji picker in the current message * Display the emoji picker in the current message
* *
@ -2086,6 +2080,11 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
alertDialogEmoji = builder.show(); alertDialogEmoji = builder.show();
} }
public interface MediaDescriptionCallBack {
void click(ComposeViewHolder holder, Attachment attachment, int messagePosition, int mediaPosition);
}
public interface promptDraftListener { public interface promptDraftListener {
void promptDraft(); void promptDraft();
} }

View File

@ -234,6 +234,7 @@ public class StatusDirectMessageAdapter extends RecyclerView.Adapter<RecyclerVie
StatusChatViewHolder holder = (StatusChatViewHolder) viewHolder; StatusChatViewHolder holder = (StatusChatViewHolder) viewHolder;
Status status = statusList.get(position); Status status = statusList.get(position);
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
status.underlined = true;
holder.binding.messageContent.setText( holder.binding.messageContent.setText(
status.getSpanContent(context, status.getSpanContent(context,
new WeakReference<>(holder.binding.messageContent), new WeakReference<>(holder.binding.messageContent),
@ -279,17 +280,19 @@ public class StatusDirectMessageAdapter extends RecyclerView.Adapter<RecyclerVie
holder.binding.mainContainer.setBackgroundResource(R.drawable.bubble_right_tail); holder.binding.mainContainer.setBackgroundResource(R.drawable.bubble_right_tail);
layoutParams.setMargins((int) Helper.convertDpToPixel(50, context), (int) Helper.convertDpToPixel(12, context), 0, 0); layoutParams.setMargins((int) Helper.convertDpToPixel(50, context), (int) Helper.convertDpToPixel(12, context), 0, 0);
holder.binding.date.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary)); holder.binding.date.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnPrimary));
holder.binding.messageContent.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary)); holder.binding.messageContent.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnPrimary));
holder.binding.userName.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary)); holder.binding.userName.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnPrimary));
Helper.changeDrawableColor(context, holder.binding.visibility, ThemeHelper.getAttColor(context, R.attr.colorOnSecondary)); holder.binding.messageContent.setLinkTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnPrimary));
Helper.changeDrawableColor(context, holder.binding.visibility, ThemeHelper.getAttColor(context, R.attr.colorOnPrimary));
} else { } else {
holder.binding.mainContainer.setBackgroundResource(R.drawable.bubble_left_tail); holder.binding.mainContainer.setBackgroundResource(R.drawable.bubble_left_tail);
layoutParams.setMargins(0, (int) Helper.convertDpToPixel(12, context), (int) Helper.convertDpToPixel(50, context), 0); layoutParams.setMargins(0, (int) Helper.convertDpToPixel(12, context), (int) Helper.convertDpToPixel(50, context), 0);
holder.binding.date.setTextColor(ContextCompat.getColor(context, R.color.black)); holder.binding.date.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
holder.binding.messageContent.setTextColor(ContextCompat.getColor(context, R.color.black)); holder.binding.messageContent.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
holder.binding.userName.setTextColor(ContextCompat.getColor(context, R.color.black)); holder.binding.userName.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
Helper.changeDrawableColor(context, holder.binding.visibility, R.color.black); holder.binding.messageContent.setLinkTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
Helper.changeDrawableColor(context, holder.binding.visibility, ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
} }
holder.binding.mainContainer.setLayoutParams(layoutParams); holder.binding.mainContainer.setLayoutParams(layoutParams);
@ -333,9 +336,13 @@ public class StatusDirectMessageAdapter extends RecyclerView.Adapter<RecyclerVie
final float scale = sharedpreferences.getFloat(context.getString(R.string.SET_FONT_SCALE), 1.1f); final float scale = sharedpreferences.getFloat(context.getString(R.string.SET_FONT_SCALE), 1.1f);
if (status.poll != null && status.poll.options != null) { if (status.poll != null && status.poll.options != null) {
if (status.account.id.equals(MainActivity.currentUserID)) {
holder.binding.poll.pollInfo.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnPrimary));
holder.binding.poll.refresh.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnPrimary));
} else {
holder.binding.poll.pollInfo.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary)); holder.binding.poll.pollInfo.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
holder.binding.poll.refresh.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary)); holder.binding.poll.refresh.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
}
StatusesVM statusesVM = new ViewModelProvider((ViewModelStoreOwner) context).get(StatusesVM.class); StatusesVM statusesVM = new ViewModelProvider((ViewModelStoreOwner) context).get(StatusesVM.class);
if (status.poll.voted || status.poll.expired) { if (status.poll.voted || status.poll.expired) {
holder.binding.poll.submitVote.setVisibility(View.GONE); holder.binding.poll.submitVote.setVisibility(View.GONE);
@ -362,8 +369,13 @@ public class StatusDirectMessageAdapter extends RecyclerView.Adapter<RecyclerVie
pollItem.getSpanTitle(context, status, pollItem.getSpanTitle(context, status,
new WeakReference<>(pollItemBinding.pollItemText)), new WeakReference<>(pollItemBinding.pollItemText)),
TextView.BufferType.SPANNABLE); TextView.BufferType.SPANNABLE);
if (status.account.id.equals(MainActivity.currentUserID)) {
pollItemBinding.pollItemPercent.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnPrimary));
pollItemBinding.pollItemText.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnPrimary));
} else {
pollItemBinding.pollItemPercent.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary)); pollItemBinding.pollItemPercent.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
pollItemBinding.pollItemText.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary)); pollItemBinding.pollItemText.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
}
pollItemBinding.pollItemValue.setProgress((int) value); pollItemBinding.pollItemValue.setProgress((int) value);
if (pollItem.votes_count == greaterValue) { if (pollItem.votes_count == greaterValue) {
pollItemBinding.pollItemPercent.setTypeface(null, Typeface.BOLD); pollItemBinding.pollItemPercent.setTypeface(null, Typeface.BOLD);
@ -395,8 +407,13 @@ public class StatusDirectMessageAdapter extends RecyclerView.Adapter<RecyclerVie
new WeakReference<>(cb)), new WeakReference<>(cb)),
TextView.BufferType.SPANNABLE); TextView.BufferType.SPANNABLE);
holder.binding.poll.multipleChoice.addView(cb); holder.binding.poll.multipleChoice.addView(cb);
if (status.account.id.equals(MainActivity.currentUserID)) {
cb.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnPrimary));
} else {
cb.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary)); cb.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
} }
}
holder.binding.poll.multipleChoice.setVisibility(View.VISIBLE); holder.binding.poll.multipleChoice.setVisibility(View.VISIBLE);
holder.binding.poll.singleChoiceRadioGroup.setVisibility(View.GONE); holder.binding.poll.singleChoiceRadioGroup.setVisibility(View.GONE);
} else { } else {
@ -408,7 +425,12 @@ public class StatusDirectMessageAdapter extends RecyclerView.Adapter<RecyclerVie
pollOption.getSpanTitle(context, status, pollOption.getSpanTitle(context, status,
new WeakReference<>(rb)), new WeakReference<>(rb)),
TextView.BufferType.SPANNABLE); TextView.BufferType.SPANNABLE);
if (status.account.id.equals(MainActivity.currentUserID)) {
rb.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnPrimary));
} else {
rb.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary)); rb.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorOnSecondary));
}
holder.binding.poll.singleChoiceRadioGroup.addView(rb); holder.binding.poll.singleChoiceRadioGroup.addView(rb);
} }
holder.binding.poll.singleChoiceRadioGroup.setVisibility(View.VISIBLE); holder.binding.poll.singleChoiceRadioGroup.setVisibility(View.VISIBLE);

View File

@ -19,7 +19,6 @@ import static app.fedilab.android.BaseMainActivity.currentInstance;
import static app.fedilab.android.BaseMainActivity.currentUserID; import static app.fedilab.android.BaseMainActivity.currentUserID;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;

View File

@ -6,13 +6,13 @@
android:pivotY="100%" android:pivotY="100%"
android:toDegrees="0"> android:toDegrees="0">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="@color/chat_other_background" /> <solid android:color="?attr/colorSecondary" />
</shape> </shape>
</rotate> </rotate>
</item> </item>
<item android:left="5dp"> <item android:left="5dp">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="@color/chat_other_background" /> <solid android:color="?attr/colorSecondary" />
<corners android:radius="5dp" /> <corners android:radius="5dp" />
</shape> </shape>
</item> </item>

View File

@ -6,13 +6,13 @@
android:pivotY="100%" android:pivotY="100%"
android:toDegrees="0"> android:toDegrees="0">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="?attr/colorSecondary" /> <solid android:color="?attr/colorPrimary" />
</shape> </shape>
</rotate> </rotate>
</item> </item>
<item android:right="6dp"> <item android:right="6dp">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="?attr/colorSecondary" /> <solid android:color="?attr/colorPrimary" />
<corners android:radius="5dp" /> <corners android:radius="5dp" />
</shape> </shape>
</item> </item>

View File

@ -7,7 +7,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/fab_margin" android:layout_marginHorizontal="@dimen/fab_margin"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:background="@drawable/bubble_right_tail"
android:padding="12dp"> android:padding="12dp">
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
@ -25,7 +24,6 @@
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:textColor="?attr/colorOnPrimary"
app:layout_constraintEnd_toStartOf="@+id/visibility" app:layout_constraintEnd_toStartOf="@+id/visibility"
app:layout_constraintStart_toEndOf="@+id/user_pp" app:layout_constraintStart_toEndOf="@+id/user_pp"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
@ -42,7 +40,6 @@
app:layout_constraintBottom_toTopOf="@+id/date" app:layout_constraintBottom_toTopOf="@+id/date"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:tint="?attr/colorOnPrimary"
tools:src="@drawable/ic_baseline_public_24" tools:src="@drawable/ic_baseline_public_24"
tools:visibility="visible" /> tools:visibility="visible" />
@ -53,7 +50,6 @@
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:gravity="end" android:gravity="end"
android:textColor="?attr/colorOnPrimary"
app:layout_constraintBottom_toTopOf="@+id/message_content" app:layout_constraintBottom_toTopOf="@+id/message_content"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/user_pp" app:layout_constraintStart_toEndOf="@+id/user_pp"
@ -66,7 +62,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
android:textColor="?attr/colorOnPrimary"
app:layout_constraintTop_toBottomOf="@+id/date" app:layout_constraintTop_toBottomOf="@+id/date"
tools:text="@tools:sample/lorem/random" /> tools:text="@tools:sample/lorem/random" />