mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-01-31 08:54:57 +01:00
Add option to hide status numbers
This commit is contained in:
parent
fd237ee188
commit
1d19161b2e
@ -289,6 +289,8 @@ public interface SharedPreferenceConstants {
|
||||
String KEY_YANDEX_KEY = "yandex_key";
|
||||
@ExportablePreference(BOOLEAN)
|
||||
String KEY_AUTO_HIDE_TABS = "auto_hide_tabs";
|
||||
@ExportablePreference(BOOLEAN)
|
||||
String KEY_HIDE_CARD_NUMBERS = "hide_card_numbers";
|
||||
|
||||
// Internal preferences
|
||||
|
||||
|
@ -2,9 +2,9 @@ package org.mariotaku.twidere.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.util.SparseBooleanArray
|
||||
import androidx.core.text.BidiFormatter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import android.util.SparseBooleanArray
|
||||
import com.bumptech.glide.RequestManager
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.twidere.R
|
||||
@ -13,8 +13,8 @@ import org.mariotaku.twidere.adapter.iface.IStatusesAdapter
|
||||
import org.mariotaku.twidere.adapter.iface.IUserListsAdapter
|
||||
import org.mariotaku.twidere.adapter.iface.IUsersAdapter
|
||||
import org.mariotaku.twidere.constant.*
|
||||
import org.mariotaku.twidere.model.*
|
||||
import org.mariotaku.twidere.extension.model.activityStatus
|
||||
import org.mariotaku.twidere.model.*
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper
|
||||
import org.mariotaku.twidere.util.TwidereLinkify
|
||||
import org.mariotaku.twidere.util.UserColorNameManager
|
||||
@ -63,6 +63,8 @@ class DummyItemAdapter(
|
||||
|
||||
var showCardActions: Boolean = false
|
||||
|
||||
var showCardNumbers: Boolean = false
|
||||
|
||||
private var showingActionCardPosition = RecyclerView.NO_POSITION
|
||||
private val showingFullTextStates = SparseBooleanArray()
|
||||
|
||||
@ -98,6 +100,11 @@ class DummyItemAdapter(
|
||||
|
||||
override fun findStatusById(accountKey: UserKey, statusId: String) = null
|
||||
|
||||
override fun isCardNumbersShown(position: Int): Boolean {
|
||||
if (position == RecyclerView.NO_POSITION) return showCardNumbers
|
||||
return showCardNumbers || showingActionCardPosition == position
|
||||
}
|
||||
|
||||
override fun isCardActionsShown(position: Int): Boolean {
|
||||
if (position == RecyclerView.NO_POSITION) return showCardActions
|
||||
return showCardActions || showingActionCardPosition == position
|
||||
@ -181,6 +188,7 @@ class DummyItemAdapter(
|
||||
mediaPreviewEnabled = preferences[mediaPreviewKey]
|
||||
sensitiveContentEnabled = preferences[displaySensitiveContentsKey]
|
||||
showCardActions = !preferences[hideCardActionsKey]
|
||||
showCardNumbers = !preferences[hideCardNumbersKey]
|
||||
linkHighlightingStyle = preferences[linkHighlightOptionKey]
|
||||
lightFont = preferences[lightFontKey]
|
||||
useStarsForLikes = preferences[iWantMyStarsBackKey]
|
||||
|
@ -79,6 +79,7 @@ abstract class ParcelableStatusesAdapter(
|
||||
final override val mediaPreviewEnabled: Boolean = Utils.isMediaPreviewEnabled(context, preferences)
|
||||
final override val sensitiveContentEnabled: Boolean = preferences.getBoolean(KEY_DISPLAY_SENSITIVE_CONTENTS, false)
|
||||
private val showCardActions: Boolean = !preferences[hideCardActionsKey]
|
||||
private val showCardNumbers: Boolean = !preferences[hideCardNumbersKey]
|
||||
|
||||
private val gapLoadingIds: MutableSet<ObjectId> = HashSet()
|
||||
|
||||
@ -261,6 +262,11 @@ abstract class ParcelableStatusesAdapter(
|
||||
}, def, raw)!!
|
||||
}
|
||||
|
||||
override fun isCardNumbersShown(position: Int): Boolean {
|
||||
if (position == RecyclerView.NO_POSITION) return showCardNumbers
|
||||
return showCardNumbers || showingActionCardId == getItemId(position)
|
||||
}
|
||||
|
||||
override fun isCardActionsShown(position: Int): Boolean {
|
||||
if (position == RecyclerView.NO_POSITION) return showCardActions
|
||||
return showCardActions || showingActionCardId == getItemId(position)
|
||||
|
@ -71,6 +71,7 @@ class StatusDetailsAdapter(
|
||||
private val inflater: LayoutInflater
|
||||
private val cardBackgroundColor: Int
|
||||
private val showCardActions = !preferences[hideCardActionsKey]
|
||||
private val showCardNumbers = !preferences[hideCardNumbersKey]
|
||||
private var recyclerView: RecyclerView? = null
|
||||
private var detailMediaExpanded: Boolean = false
|
||||
|
||||
@ -173,6 +174,11 @@ class StatusDetailsAdapter(
|
||||
return getTypeCount(ITEM_IDX_CONVERSATION) + getTypeCount(ITEM_IDX_STATUS) + getTypeCount(ITEM_IDX_REPLY)
|
||||
}
|
||||
|
||||
override fun isCardNumbersShown(position: Int): Boolean {
|
||||
if (position == RecyclerView.NO_POSITION) return showCardNumbers
|
||||
return showCardNumbers || showingActionCardPosition == position
|
||||
}
|
||||
|
||||
override fun isCardActionsShown(position: Int): Boolean {
|
||||
if (position == RecyclerView.NO_POSITION) return showCardActions
|
||||
return showCardActions || showingActionCardPosition == position
|
||||
|
@ -33,6 +33,8 @@ interface IStatusesAdapter<in Data> : IContentAdapter, IGapSupportedAdapter {
|
||||
|
||||
val statusClickListener: IStatusViewHolder.StatusClickListener?
|
||||
|
||||
fun isCardNumbersShown(position: Int): Boolean
|
||||
|
||||
fun isCardActionsShown(position: Int): Boolean
|
||||
|
||||
fun showCardActions(position: Int)
|
||||
|
@ -89,6 +89,8 @@ val translationDestinationKey = KNullableStringKey(KEY_TRANSLATION_DESTINATION,
|
||||
val tabPositionKey = KStringKey(KEY_TAB_POSITION, SharedPreferenceConstants.DEFAULT_TAB_POSITION)
|
||||
val yandexKeyKey = KStringKey(SharedPreferenceConstants.KEY_YANDEX_KEY, TwidereConstants.YANDEX_KEY)
|
||||
val autoHideTabs = KBooleanKey(SharedPreferenceConstants.KEY_AUTO_HIDE_TABS, true)
|
||||
val hideCardNumbersKey = KBooleanKey(KEY_HIDE_CARD_NUMBERS, false)
|
||||
|
||||
|
||||
object cacheSizeLimitKey : KSimpleKey<Int>(KEY_CACHE_SIZE_LIMIT, 300) {
|
||||
override fun read(preferences: SharedPreferences) = preferences.getInt(key, def).coerceIn(100,
|
||||
|
@ -75,6 +75,7 @@ abstract class AbsStatusDialogFragment : BaseDialogFragment() {
|
||||
|
||||
adapter = DummyItemAdapter(context!!, requestManager = requestManager)
|
||||
adapter.showCardActions = false
|
||||
adapter.showCardNumbers = false
|
||||
adapter.showAccountsColor = true
|
||||
|
||||
val dialog = builder.create()
|
||||
|
@ -1,10 +1,5 @@
|
||||
package org.mariotaku.twidere.view.holder
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.widget.TextViewCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||
import android.text.SpannableString
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.Spanned
|
||||
@ -14,6 +9,11 @@ import android.view.View.OnClickListener
|
||||
import android.view.View.OnLongClickListener
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.widget.TextViewCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||
import com.bumptech.glide.RequestManager
|
||||
import kotlinx.android.synthetic.main.list_item_status.view.*
|
||||
import org.mariotaku.ktextension.*
|
||||
@ -378,7 +378,7 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
|
||||
}
|
||||
textView.hideIfEmpty()
|
||||
|
||||
if (replyCount > 0) {
|
||||
if (replyCount > 0 && isCardNumbersShown) {
|
||||
replyCountView.spannable = UnitConvertUtils.calculateProperCount(replyCount)
|
||||
} else {
|
||||
replyCountView.spannable = null
|
||||
@ -406,7 +406,7 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
|
||||
status.my_retweet_id)
|
||||
}
|
||||
|
||||
if (retweetCount > 0) {
|
||||
if (retweetCount > 0 && isCardNumbersShown) {
|
||||
retweetCountView.spannable = UnitConvertUtils.calculateProperCount(retweetCount)
|
||||
} else {
|
||||
retweetCountView.spannable = null
|
||||
@ -420,7 +420,7 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
|
||||
favoriteIcon.isActivated = creatingFavorite || status.is_favorite
|
||||
}
|
||||
|
||||
if (favoriteCount > 0) {
|
||||
if (favoriteCount > 0 && isCardNumbersShown) {
|
||||
favoriteCountView.spannable = UnitConvertUtils.calculateProperCount(favoriteCount)
|
||||
} else {
|
||||
favoriteCountView.spannable = null
|
||||
@ -576,6 +576,9 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
|
||||
}
|
||||
}
|
||||
|
||||
private val isCardNumbersShown: Boolean
|
||||
get() = adapter.isCardNumbersShown(layoutPosition)
|
||||
|
||||
private val isCardActionsShown: Boolean
|
||||
get() = adapter.isCardActionsShown(layoutPosition)
|
||||
|
||||
|
@ -52,6 +52,7 @@ import org.mariotaku.twidere.adapter.BaseRecyclerViewAdapter
|
||||
import org.mariotaku.twidere.adapter.StatusDetailsAdapter
|
||||
import org.mariotaku.twidere.annotation.ProfileImageSize
|
||||
import org.mariotaku.twidere.constant.displaySensitiveContentsKey
|
||||
import org.mariotaku.twidere.constant.hideCardNumbersKey
|
||||
import org.mariotaku.twidere.constant.newDocumentApiKey
|
||||
import org.mariotaku.twidere.extension.loadProfileImage
|
||||
import org.mariotaku.twidere.extension.model.*
|
||||
@ -543,7 +544,7 @@ class DetailStatusViewHolder(
|
||||
(holder as ProfileImageViewHolder).displayUser(getUser(position)!!)
|
||||
}
|
||||
ITEM_VIEW_TYPE_COUNT -> {
|
||||
(holder as CountViewHolder).displayCount(getCount(position)!!)
|
||||
(holder as CountViewHolder).displayCount(getCount(position)!!, preferences[hideCardNumbersKey])
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -702,7 +703,7 @@ class DetailStatusViewHolder(
|
||||
adapter.notifyItemClick(layoutPosition)
|
||||
}
|
||||
|
||||
fun displayCount(count: LabeledCount) {
|
||||
fun displayCount(count: LabeledCount, hideNumbers: Boolean) {
|
||||
val label: String
|
||||
when (count.type) {
|
||||
KEY_REPLY_COUNT -> {
|
||||
@ -718,7 +719,9 @@ class DetailStatusViewHolder(
|
||||
throw UnsupportedOperationException("Unsupported type " + count.type)
|
||||
}
|
||||
}
|
||||
itemView.count.text = Utils.getLocalizedNumber(Locale.getDefault(), count.count)
|
||||
if (!hideNumbers) {
|
||||
itemView.count.text = Utils.getLocalizedNumber(Locale.getDefault(), count.count)
|
||||
}
|
||||
itemView.label.text = label
|
||||
}
|
||||
}
|
||||
|
@ -445,6 +445,7 @@
|
||||
<string name="hidden_settings_warning_title">WARNING: These settings may harm!</string>
|
||||
|
||||
<string name="hide_card_actions">Hide card actions</string>
|
||||
<string name="hide_card_numbers">Hide card numbers</string>
|
||||
<string name="hide_quotes">Hide quotes</string>
|
||||
<string name="hide_replies">Hide replies</string>
|
||||
<string name="hide_retweets">Hide retweets</string>
|
||||
|
@ -101,8 +101,18 @@
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="i_want_my_stars_back"
|
||||
android:key="hide_card_numbers"
|
||||
android:order="34"
|
||||
android:title="@string/hide_card_numbers">
|
||||
<extra
|
||||
android:name="should_recreate"
|
||||
android:value="true"/>
|
||||
</SwitchPreferenceCompat>
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="i_want_my_stars_back"
|
||||
android:order="35"
|
||||
android:summary="@string/i_want_my_stars_back_summary"
|
||||
android:title="@string/i_want_my_stars_back">
|
||||
<extra
|
||||
@ -113,7 +123,7 @@
|
||||
<org.mariotaku.twidere.preference.FavoriteConfirmSwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="favorite_confirmation"
|
||||
android:order="35"
|
||||
android:order="36"
|
||||
android:summary="@string/preference_summary_favorite_confirmation"
|
||||
android:title="@string/preference_title_favorite_confirmation"/>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user