Counters close to button + add full date for messages (default: disabled)

This commit is contained in:
Thomas 2023-12-18 12:14:18 +01:00
parent 4ebe2a2719
commit 082ecce9be
5 changed files with 128 additions and 57 deletions

View File

@ -579,6 +579,20 @@ public class Helper {
return df.format(date); 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 * Convert a date in String -> format yyyy-MM-dd HH:mm:ss
* *

View File

@ -451,6 +451,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
boolean displayReactions = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_REACTIONS) + MainActivity.currentUserID + MainActivity.currentInstance, true); 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 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 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 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 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); boolean warnNoMedia = sharedpreferences.getBoolean(context.getString(R.string.SET_MANDATORY_ALT_TEXT_FOR_BOOSTS), true);
@ -1309,28 +1310,33 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
holder.binding.editTime.setVisibility(View.GONE); holder.binding.editTime.setVisibility(View.GONE);
holder.binding.visibilitySmall.setImageResource(ressource); holder.binding.visibilitySmall.setImageResource(ressource);
if (displayCounters && canBeFederated) { if (displayCounters && canBeFederated) {
if (statusToDeal.replies_count > 0 && !(context instanceof ContextActivity)) {
holder.binding.replyCount.setVisibility(View.VISIBLE);
holder.binding.replyCount.setText(String.valueOf(statusToDeal.replies_count)); 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));
} else { } else {
holder.binding.time.setText(Helper.dateDiff(context, status.created_at)); holder.binding.replyCount.setVisibility(View.GONE);
} }
if (statusToDeal.edited_at != null) { if(statusToDeal.reblogs_count > 0 && !(context instanceof ContextActivity)) {
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_baseline_mode_edit_message_24); holder.binding.boostCount.setText(String.valueOf(statusToDeal.reblogs_count));
img.setBounds(0, 0, (int) (Helper.convertDpToPixel(16, context) * scale + 0.5f), (int) (Helper.convertDpToPixel(16, context) * scale + 0.5f)); holder.binding.boostCount.setVisibility(View.VISIBLE);
holder.binding.time.setCompoundDrawables(null, null, img, null);
} else { } else {
holder.binding.time.setCompoundDrawables(null, null, null, null); holder.binding.boostCount.setVisibility(View.GONE);
} }
Helper.absoluteDateTimeReveal(context, holder.binding.time, statusToDeal.created_at, statusToDeal.edited_at); if(statusToDeal.favourites_count > 0 && !(context instanceof ContextActivity)) {
holder.binding.visibility.setImageResource(ressource); holder.binding.favoriteCount.setText(String.valueOf(statusToDeal.favourites_count));
holder.binding.time.setVisibility(View.VISIBLE); holder.binding.favoriteCount.setVisibility(View.VISIBLE);
} else { } else {
holder.binding.favoriteCount.setVisibility(View.GONE);
}
} else {
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.replyCount.setVisibility(View.GONE);
}
}
holder.binding.statusInfo.setVisibility(View.GONE); holder.binding.statusInfo.setVisibility(View.GONE);
holder.binding.dateShort.setVisibility(View.VISIBLE); holder.binding.dateShort.setVisibility(View.VISIBLE);
holder.binding.visibilitySmall.setVisibility(View.VISIBLE); holder.binding.visibilitySmall.setVisibility(View.VISIBLE);
@ -1341,15 +1347,22 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
} else { } else {
holder.binding.dateShort.setCompoundDrawables(null, null, null, null); holder.binding.dateShort.setCompoundDrawables(null, null, null, null);
} }
if(relativeDate) {
if (originalDateForBoost || status.reblog == null) { if (originalDateForBoost || status.reblog == null) {
holder.binding.dateShort.setText(Helper.dateDiff(context, statusToDeal.created_at)); holder.binding.dateShort.setText(Helper.dateDiff(context, statusToDeal.created_at));
} else { } else {
holder.binding.dateShort.setText(Helper.dateDiff(context, status.created_at)); holder.binding.dateShort.setText(Helper.dateDiff(context, status.created_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); holder.binding.time.setVisibility(View.GONE);
Helper.absoluteDateTimeReveal(context, holder.binding.dateShort, statusToDeal.created_at, statusToDeal.edited_at); Helper.absoluteDateTimeReveal(context, holder.binding.dateShort, statusToDeal.created_at, statusToDeal.edited_at);
} }
}
//---- SPOILER TEXT ----- //---- SPOILER TEXT -----
if (statusToDeal.spoiler_text != null && !statusToDeal.spoiler_text.trim().isEmpty()) { if (statusToDeal.spoiler_text != null && !statusToDeal.spoiler_text.trim().isEmpty()) {
@ -2408,11 +2421,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
}); });
popup.show(); 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 -> { holder.binding.actionButtonReply.setOnLongClickListener(v -> {
CrossActionHelper.doCrossAction(context, CrossActionHelper.TypeOfCrossAction.REPLY_ACTION, null, statusToDeal); CrossActionHelper.doCrossAction(context, CrossActionHelper.TypeOfCrossAction.REPLY_ACTION, null, statusToDeal);
return true; return true;

View File

@ -657,6 +657,7 @@
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/reply_count" android:id="@+id/reply_count"
android:layout_marginStart="10dp"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
@ -668,22 +669,44 @@
tools:visibility="visible" /> tools:visibility="visible" />
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/action_button_boost_container"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/action_button_quote"
app:layout_constraintStart_toEndOf="@+id/action_button_reply_container"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0">
<com.varunest.sparkbutton.SparkButton <com.varunest.sparkbutton.SparkButton
android:id="@+id/action_button_boost" android:id="@+id/action_button_boost"
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:layout_gravity="center"
android:contentDescription="@string/reblog_add" android:contentDescription="@string/reblog_add"
app:activeImage="@drawable/ic_round_repeat_active_24" app:activeImage="@drawable/ic_round_repeat_active_24"
app:iconSize="28dp" app:iconSize="28dp"
app:inactiveImage="@drawable/ic_round_repeat_24" app:inactiveImage="@drawable/ic_round_repeat_24"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/action_button_quote"
app:layout_constraintStart_toEndOf="@+id/action_button_reply_container"
app:layout_constraintTop_toTopOf="parent"
app:primaryColor="@color/boost_icon" app:primaryColor="@color/boost_icon"
app:secondaryColor="@color/boost_icon" /> app:secondaryColor="@color/boost_icon" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/boost_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:textColor="?colorControlNormal"
android:textSize="12sp"
android:visibility="gone"
tools:ignore="HardcodedText"
tools:visibility="visible" />
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/action_button_quote" android:id="@+id/action_button_quote"
android:layout_width="28dp" android:layout_width="28dp"
@ -697,11 +720,21 @@
android:src="@drawable/ic_baseline_format_quote_24" android:src="@drawable/ic_baseline_format_quote_24"
android:visibility="gone" android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/action_button_favorite" app:layout_constraintEnd_toStartOf="@+id/action_button_favorite_container"
app:layout_constraintStart_toEndOf="@+id/action_button_boost" app:layout_constraintStart_toEndOf="@+id/action_button_boost_container"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" /> tools:visibility="visible" />
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/action_button_favorite_container"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/action_button_bookmark"
app:layout_constraintStart_toEndOf="@+id/action_button_quote"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0">
<com.varunest.sparkbutton.SparkButton <com.varunest.sparkbutton.SparkButton
android:id="@+id/action_button_favorite" android:id="@+id/action_button_favorite"
android:layout_width="48dp" android:layout_width="48dp"
@ -712,13 +745,20 @@
app:activeImage="@drawable/ic_round_star_24" app:activeImage="@drawable/ic_round_star_24"
app:animationSpeed="1.5" app:animationSpeed="1.5"
app:inactiveImage="@drawable/ic_round_star_border_24" app:inactiveImage="@drawable/ic_round_star_border_24"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/action_button_bookmark"
app:layout_constraintStart_toEndOf="@+id/action_button_quote"
app:layout_constraintTop_toTopOf="parent"
app:primaryColor="@color/marked_icon" app:primaryColor="@color/marked_icon"
app:secondaryColor="@color/marked_icon" app:secondaryColor="@color/marked_icon"
sparkbutton:iconSize="28dp" /> sparkbutton:iconSize="28dp" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/favorite_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:textColor="?colorControlNormal"
android:textSize="12sp"
android:visibility="gone"
tools:ignore="HardcodedText"
tools:visibility="visible" />
</androidx.appcompat.widget.LinearLayoutCompat>
<com.varunest.sparkbutton.SparkButton <com.varunest.sparkbutton.SparkButton
android:id="@+id/action_button_bookmark" android:id="@+id/action_button_bookmark"
@ -732,7 +772,7 @@
app:inactiveImage="@drawable/ic_round_bookmark_border_24" app:inactiveImage="@drawable/ic_round_bookmark_border_24"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/action_button_translate" app:layout_constraintEnd_toStartOf="@+id/action_button_translate"
app:layout_constraintStart_toEndOf="@+id/action_button_favorite" app:layout_constraintStart_toEndOf="@+id/action_button_favorite_container"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:primaryColor="@color/marked_icon" app:primaryColor="@color/marked_icon"
app:secondaryColor="@color/marked_icon" app:secondaryColor="@color/marked_icon"

View File

@ -1168,6 +1168,7 @@
<string name="SET_NOTIF_VALIDATION_FAV" translatable="false">SET_NOTIF_VALIDATION_FAV</string> <string name="SET_NOTIF_VALIDATION_FAV" translatable="false">SET_NOTIF_VALIDATION_FAV</string>
<string name="SET_DISPLAY_COUNTER_FAV_BOOST" translatable="false">SET_DISPLAY_COUNTER_FAV_BOOST</string> <string name="SET_DISPLAY_COUNTER_FAV_BOOST" translatable="false">SET_DISPLAY_COUNTER_FAV_BOOST</string>
<string name="SET_DISPLAY_RELATIVE_DATE" translatable="false">SET_DISPLAY_RELATIVE_DATE</string>
<string name="SET_REMOVE_LEFT_MARGIN" translatable="false">SET_REMOVE_LEFT_MARGIN</string> <string name="SET_REMOVE_LEFT_MARGIN" translatable="false">SET_REMOVE_LEFT_MARGIN</string>
<string name="SET_PROFILE_REMOTELY" translatable="false">SET_PROFILE_REMOTELY</string> <string name="SET_PROFILE_REMOTELY" translatable="false">SET_PROFILE_REMOTELY</string>
@ -1729,6 +1730,7 @@
<string name="set_timelines_in_a_list_title">Timelines in a list</string> <string name="set_timelines_in_a_list_title">Timelines in a list</string>
<string name="set_timelines_in_a_list">When enabled, all pinned timelines will be displayed in a drop-down menu</string> <string name="set_timelines_in_a_list">When enabled, all pinned timelines will be displayed in a drop-down menu</string>
<string name="set_display_counter">Display counters for messages</string> <string name="set_display_counter">Display counters for messages</string>
<string name="set_display_relative_date">Display relative date for messages</string>
<string name="set_use_cache">Use cache</string> <string name="set_use_cache">Use cache</string>
<string name="set_use_cache_indication">Timelines will be cached so the application will be faster.</string> <string name="set_use_cache_indication">Timelines will be cached so the application will be faster.</string>
<string name="load_media_type_title">Load thumbnails for media</string> <string name="load_media_type_title">Load thumbnails for media</string>

View File

@ -198,6 +198,12 @@
app:key="@string/SET_DISPLAY_COUNTER_FAV_BOOST" app:key="@string/SET_DISPLAY_COUNTER_FAV_BOOST"
app:singleLineTitle="false" app:singleLineTitle="false"
app:title="@string/set_display_counter" /> app:title="@string/set_display_counter" />
<SwitchPreferenceCompat
android:defaultValue="true"
app:iconSpaceReserved="false"
app:key="@string/SET_DISPLAY_RELATIVE_DATE"
app:singleLineTitle="false"
app:title="@string/set_display_relative_date" />
<SeekBarPreference <SeekBarPreference
android:defaultValue="0" android:defaultValue="0"
android:max="20" android:max="20"