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);
}
/**
* 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
*

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 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<RecyclerView.ViewHolder>
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<RecyclerView.ViewHolder>
});
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;

View file

@ -657,6 +657,7 @@
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/reply_count"
android:layout_marginStart="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
@ -668,21 +669,43 @@
tools:visibility="visible" />
</androidx.appcompat.widget.LinearLayoutCompat>
<com.varunest.sparkbutton.SparkButton
android:id="@+id/action_button_boost"
android:layout_width="48dp"
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/action_button_boost_container"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:adjustViewBounds="true"
android:contentDescription="@string/reblog_add"
app:activeImage="@drawable/ic_round_repeat_active_24"
app:iconSize="28dp"
app:inactiveImage="@drawable/ic_round_repeat_24"
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:primaryColor="@color/boost_icon"
app:secondaryColor="@color/boost_icon" />
app:layout_constraintVertical_bias="0.0">
<com.varunest.sparkbutton.SparkButton
android:id="@+id/action_button_boost"
android:layout_width="48dp"
android:layout_height="48dp"
android:adjustViewBounds="true"
android:layout_gravity="center"
android:contentDescription="@string/reblog_add"
app:activeImage="@drawable/ic_round_repeat_active_24"
app:iconSize="28dp"
app:inactiveImage="@drawable/ic_round_repeat_24"
app:primaryColor="@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
android:id="@+id/action_button_quote"
@ -697,28 +720,45 @@
android:src="@drawable/ic_baseline_format_quote_24"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/action_button_favorite"
app:layout_constraintStart_toEndOf="@+id/action_button_boost"
app:layout_constraintEnd_toStartOf="@+id/action_button_favorite_container"
app:layout_constraintStart_toEndOf="@+id/action_button_boost_container"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />
<com.varunest.sparkbutton.SparkButton
android:id="@+id/action_button_favorite"
android:layout_width="48dp"
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/action_button_favorite_container"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="@string/favourite_add"
app:activeImage="@drawable/ic_round_star_24"
app:animationSpeed="1.5"
app:inactiveImage="@drawable/ic_round_star_border_24"
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:primaryColor="@color/marked_icon"
app:secondaryColor="@color/marked_icon"
sparkbutton:iconSize="28dp" />
app:layout_constraintVertical_bias="0.0">
<com.varunest.sparkbutton.SparkButton
android:id="@+id/action_button_favorite"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="@string/favourite_add"
app:activeImage="@drawable/ic_round_star_24"
app:animationSpeed="1.5"
app:inactiveImage="@drawable/ic_round_star_border_24"
app:primaryColor="@color/marked_icon"
app:secondaryColor="@color/marked_icon"
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
android:id="@+id/action_button_bookmark"
@ -732,7 +772,7 @@
app:inactiveImage="@drawable/ic_round_bookmark_border_24"
app:layout_constraintBottom_toBottomOf="parent"
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:primaryColor="@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_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_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">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_relative_date">Display relative date for messages</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="load_media_type_title">Load thumbnails for media</string>

View file

@ -198,6 +198,12 @@
app:key="@string/SET_DISPLAY_COUNTER_FAV_BOOST"
app:singleLineTitle="false"
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
android:defaultValue="0"
android:max="20"