diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java b/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java index 940f587d9..b2069db7c 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java @@ -579,6 +579,20 @@ public class Helper { return df.format(date); } + /** + * Convert a date in String + * + * @param date Date + * @return String + */ + public static String mediumDateToString(Date date) { + if (date == null) { + date = new Date(); + } + DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.getDefault()); + return df.format(date); + } + /** * Convert a date in String -> format yyyy-MM-dd HH:mm:ss * diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java index a554defab..b907fd48a 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java @@ -451,6 +451,7 @@ public class StatusAdapter extends RecyclerView.Adapter boolean displayReactions = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_REACTIONS) + MainActivity.currentUserID + MainActivity.currentInstance, true); boolean compactButtons = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_COMPACT_ACTION_BUTTON), false); boolean originalDateForBoost = sharedpreferences.getBoolean(context.getString(R.string.SET_BOOST_ORIGINAL_DATE), true); + boolean relativeDate = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_RELATIVE_DATE), true); boolean hideSingleMediaWithCard = sharedpreferences.getBoolean(context.getString(R.string.SET_HIDE_SINGLE_MEDIA_WITH_CARD), false); boolean autofetch = sharedpreferences.getBoolean(context.getString(R.string.SET_AUTO_FETCH_MISSING_MESSAGES), false); boolean warnNoMedia = sharedpreferences.getBoolean(context.getString(R.string.SET_MANDATORY_ALT_TEXT_FOR_BOOSTS), true); @@ -1309,46 +1310,58 @@ public class StatusAdapter extends RecyclerView.Adapter holder.binding.editTime.setVisibility(View.GONE); holder.binding.visibilitySmall.setImageResource(ressource); if (displayCounters && canBeFederated) { - holder.binding.replyCount.setText(String.valueOf(statusToDeal.replies_count)); - holder.binding.statusInfo.setVisibility(View.VISIBLE); - holder.binding.dateShort.setVisibility(View.GONE); - holder.binding.visibilitySmall.setVisibility(View.GONE); - holder.binding.reblogsCount.setText(String.valueOf(statusToDeal.reblogs_count)); - holder.binding.favoritesCount.setText(String.valueOf(statusToDeal.favourites_count)); - if (originalDateForBoost || status.reblog == null) { - holder.binding.time.setText(Helper.dateDiff(context, statusToDeal.created_at)); + if (statusToDeal.replies_count > 0 && !(context instanceof ContextActivity)) { + holder.binding.replyCount.setVisibility(View.VISIBLE); + holder.binding.replyCount.setText(String.valueOf(statusToDeal.replies_count)); } else { - holder.binding.time.setText(Helper.dateDiff(context, status.created_at)); + holder.binding.replyCount.setVisibility(View.GONE); } - if (statusToDeal.edited_at != null) { - Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_baseline_mode_edit_message_24); - img.setBounds(0, 0, (int) (Helper.convertDpToPixel(16, context) * scale + 0.5f), (int) (Helper.convertDpToPixel(16, context) * scale + 0.5f)); - holder.binding.time.setCompoundDrawables(null, null, img, null); + if(statusToDeal.reblogs_count > 0 && !(context instanceof ContextActivity)) { + holder.binding.boostCount.setText(String.valueOf(statusToDeal.reblogs_count)); + holder.binding.boostCount.setVisibility(View.VISIBLE); } else { - holder.binding.time.setCompoundDrawables(null, null, null, null); + holder.binding.boostCount.setVisibility(View.GONE); + } + if(statusToDeal.favourites_count > 0 && !(context instanceof ContextActivity)) { + holder.binding.favoriteCount.setText(String.valueOf(statusToDeal.favourites_count)); + holder.binding.favoriteCount.setVisibility(View.VISIBLE); + } else { + holder.binding.favoriteCount.setVisibility(View.GONE); } - Helper.absoluteDateTimeReveal(context, holder.binding.time, statusToDeal.created_at, statusToDeal.edited_at); - holder.binding.visibility.setImageResource(ressource); - holder.binding.time.setVisibility(View.VISIBLE); } else { - holder.binding.statusInfo.setVisibility(View.GONE); - holder.binding.dateShort.setVisibility(View.VISIBLE); - holder.binding.visibilitySmall.setVisibility(View.VISIBLE); - if (statusToDeal.edited_at != null) { - Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_baseline_mode_edit_message_24); - img.setBounds(0, 0, (int) (Helper.convertDpToPixel(16, context) * scale + 0.5f), (int) (Helper.convertDpToPixel(16, context) * scale + 0.5f)); - holder.binding.dateShort.setCompoundDrawables(null, null, img, null); + holder.binding.boostCount.setVisibility(View.GONE); + holder.binding.favoriteCount.setVisibility(View.GONE); + if (statusToDeal.replies_count > 0 && !(context instanceof ContextActivity)) { + holder.binding.replyCount.setVisibility(View.VISIBLE); } else { - holder.binding.dateShort.setCompoundDrawables(null, null, null, null); + holder.binding.replyCount.setVisibility(View.GONE); } + } + holder.binding.statusInfo.setVisibility(View.GONE); + holder.binding.dateShort.setVisibility(View.VISIBLE); + holder.binding.visibilitySmall.setVisibility(View.VISIBLE); + if (statusToDeal.edited_at != null) { + Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_baseline_mode_edit_message_24); + img.setBounds(0, 0, (int) (Helper.convertDpToPixel(16, context) * scale + 0.5f), (int) (Helper.convertDpToPixel(16, context) * scale + 0.5f)); + holder.binding.dateShort.setCompoundDrawables(null, null, img, null); + } else { + holder.binding.dateShort.setCompoundDrawables(null, null, null, null); + } + if(relativeDate) { if (originalDateForBoost || status.reblog == null) { holder.binding.dateShort.setText(Helper.dateDiff(context, statusToDeal.created_at)); } else { holder.binding.dateShort.setText(Helper.dateDiff(context, status.created_at)); } - holder.binding.time.setVisibility(View.GONE); - Helper.absoluteDateTimeReveal(context, holder.binding.dateShort, statusToDeal.created_at, statusToDeal.edited_at); + } else { + if (originalDateForBoost || status.reblog == null) { + holder.binding.dateShort.setText(Helper.mediumDateToString(statusToDeal.created_at)); + } else { + holder.binding.dateShort.setText(Helper.mediumDateToString(status.created_at)); + } } + holder.binding.time.setVisibility(View.GONE); + Helper.absoluteDateTimeReveal(context, holder.binding.dateShort, statusToDeal.created_at, statusToDeal.edited_at); } //---- SPOILER TEXT ----- @@ -2408,11 +2421,7 @@ public class StatusAdapter extends RecyclerView.Adapter }); popup.show(); }); - if (statusToDeal.replies_count > 0 && !(context instanceof ContextActivity)) { - holder.binding.replyCount.setVisibility(View.VISIBLE); - } else { - holder.binding.replyCount.setVisibility(View.GONE); - } + holder.binding.actionButtonReply.setOnLongClickListener(v -> { CrossActionHelper.doCrossAction(context, CrossActionHelper.TypeOfCrossAction.REPLY_ACTION, null, statusToDeal); return true; diff --git a/app/src/main/res/layouts/mastodon/layout/drawer_status.xml b/app/src/main/res/layouts/mastodon/layout/drawer_status.xml index 1f27d35fc..d331c73d4 100644 --- a/app/src/main/res/layouts/mastodon/layout/drawer_status.xml +++ b/app/src/main/res/layouts/mastodon/layout/drawer_status.xml @@ -657,32 +657,53 @@ - + app:layout_constraintVertical_bias="0.0"> + + + + + + - + app:layout_constraintVertical_bias="0.0"> + + + SET_NOTIF_VALIDATION_FAV SET_DISPLAY_COUNTER_FAV_BOOST + SET_DISPLAY_RELATIVE_DATE SET_REMOVE_LEFT_MARGIN SET_PROFILE_REMOTELY @@ -1729,6 +1730,7 @@ Timelines in a list When enabled, all pinned timelines will be displayed in a drop-down menu Display counters for messages + Display relative date for messages Use cache Timelines will be cached so the application will be faster. Load thumbnails for media diff --git a/app/src/main/res/xml/pref_timelines.xml b/app/src/main/res/xml/pref_timelines.xml index 3335f68d0..4143933b4 100644 --- a/app/src/main/res/xml/pref_timelines.xml +++ b/app/src/main/res/xml/pref_timelines.xml @@ -198,6 +198,12 @@ app:key="@string/SET_DISPLAY_COUNTER_FAV_BOOST" app:singleLineTitle="false" app:title="@string/set_display_counter" /> +