diff --git a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingTagViewHolder.kt b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingTagViewHolder.kt index 36a65f4fe..318683ba1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingTagViewHolder.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/trending/TrendingTagViewHolder.kt @@ -41,7 +41,7 @@ class TrendingTagViewHolder( binding.totalAccounts.text = formatNumber(totalAccounts, 1000) binding.currentUsage.text = numberFormat.format(tagViewData.usage.last()) - binding.currentAccounts.text = numberFormat.format(tagViewData.usage.last()) + binding.currentAccounts.text = numberFormat.format(tagViewData.accounts.last()) itemView.setOnClickListener { onViewTag(tagViewData.name) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/NumberUtils.kt b/app/src/main/java/com/keylesspalace/tusky/util/NumberUtils.kt index 83bc1ab57..541687582 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/NumberUtils.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/NumberUtils.kt @@ -8,7 +8,6 @@ import kotlin.math.abs import kotlin.math.ln import kotlin.math.pow -private val numberFormatter: NumberFormat = NumberFormat.getInstance() private val ln_1k = ln(1000.0) /** @@ -19,6 +18,7 @@ private val ln_1k = ln(1000.0) * a suffix appropriate to the scaling is appended. */ fun formatNumber(num: Long, min: Int = 100000): String { + val numberFormatter: NumberFormat = NumberFormat.getInstance() val absNum = abs(num) if (absNum < min) return numberFormatter.format(num) diff --git a/app/src/main/java/com/keylesspalace/tusky/view/GraphView.kt b/app/src/main/java/com/keylesspalace/tusky/view/GraphView.kt index 0d70f011a..dab8716fb 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/GraphView.kt +++ b/app/src/main/java/com/keylesspalace/tusky/view/GraphView.kt @@ -21,6 +21,7 @@ import android.graphics.Paint import android.graphics.Path import android.graphics.PathMeasure import android.graphics.Rect +import android.text.TextUtils import android.util.AttributeSet import android.view.View import androidx.annotation.ColorInt @@ -29,6 +30,7 @@ import androidx.core.content.res.use import com.google.android.material.R as materialR import com.google.android.material.color.MaterialColors import com.keylesspalace.tusky.R +import java.util.Locale import kotlin.math.max class GraphView @JvmOverloads constructor( @@ -68,63 +70,40 @@ class GraphView @JvmOverloads constructor( private var primaryLinePath: Path = Path() private var secondaryLinePath: Path = Path() + private var isRtlLayout: Boolean = false + var maxTrendingValue: Long = 300 var primaryLineData: List = if (isInEditMode) { - listOf( - 30, - 60, - 70, - 80, - 130, - 190, - 80 - ) + listOf(30, 60, 70, 80, 130, 190, 80) } else { - listOf( - 1, - 1, - 1, - 1, - 1, - 1, - 1 - ) + listOf(1, 1, 1, 1, 1, 1, 1) } set(value) { field = value.map { max(1, it) } + if (isRtlLayout) { + field = field.reversed() + } primaryLinePath.reset() invalidate() } var secondaryLineData: List = if (isInEditMode) { - listOf( - 10, - 20, - 40, - 60, - 100, - 132, - 20 - ) + listOf(10, 20, 40, 60, 100, 132, 20) } else { - listOf( - 1, - 1, - 1, - 1, - 1, - 1, - 1 - ) + listOf(1, 1, 1, 1, 1, 1, 1) } set(value) { field = value.map { max(1, it) } + if (isRtlLayout) { + field = field.reversed() + } secondaryLinePath.reset() invalidate() } init { initFromXML(attrs) + isRtlLayout = TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == LAYOUT_DIRECTION_RTL } private fun initFromXML(attr: AttributeSet?) { @@ -291,7 +270,7 @@ class GraphView @JvmOverloads constructor( linePath = secondaryLinePath, linePaint = secondaryLinePaint, circlePaint = secondaryCirclePaint, - lineThickness = lineWidth + lineThickness = lineWidth, ) drawLine( canvas = canvas, @@ -317,8 +296,11 @@ class GraphView @JvmOverloads constructor( ) val pm = PathMeasure(linePath, false) + + val dotPosition = if (isRtlLayout) 0f else pm.length + val coord = floatArrayOf(0f, 0f) - pm.getPosTan(pm.length * 1f, coord, null) + pm.getPosTan(dotPosition, coord, null) drawCircle(coord[0], coord[1], lineThickness * 2f, circlePaint) } diff --git a/app/src/main/res/color/color_background_transparent_60.xml b/app/src/main/res/color/color_background_transparent_60.xml index 0a09f2aa3..d62f447b5 100644 --- a/app/src/main/res/color/color_background_transparent_60.xml +++ b/app/src/main/res/color/color_background_transparent_60.xml @@ -1,4 +1,4 @@ - - \ No newline at end of file + + diff --git a/app/src/main/res/layout-land/item_trending_cell.xml b/app/src/main/res/layout-land/item_trending_cell.xml index 4d5b0302e..5e1dbef4f 100644 --- a/app/src/main/res/layout-land/item_trending_cell.xml +++ b/app/src/main/res/layout-land/item_trending_cell.xml @@ -39,12 +39,13 @@ android:textAlignment="textEnd" android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textColor="?attr/colorPrimary" - android:textSize="8sp" + android:textSize="12sp" android:textStyle="normal" app:layout_constrainedWidth="true" app:layout_constraintBottom_toTopOf="@id/current_accounts" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/graph" + tools:ignore="RtlSymmetry" tools:text="12 345" /> + diff --git a/app/src/main/res/layout/item_filtered_notifications_info.xml b/app/src/main/res/layout/item_filtered_notifications_info.xml index fea3dccd7..54cdfded7 100644 --- a/app/src/main/res/layout/item_filtered_notifications_info.xml +++ b/app/src/main/res/layout/item_filtered_notifications_info.xml @@ -12,6 +12,7 @@ android:id="@+id/notification_policy_summary_title" android:layout_width="0dp" android:layout_height="wrap_content" + android:layout_marginEnd="8dp" android:text="@string/filtered_notifications" android:textColor="?android:textColorSecondary" android:textStyle="normal|bold" @@ -23,6 +24,7 @@ android:id="@+id/notification_policy_summary_description" android:layout_width="0dp" android:layout_height="wrap_content" + android:layout_marginEnd="8dp" android:textColor="?android:textColorSecondary" app:layout_constraintEnd_toStartOf="@id/notification_policy_summary_badge" app:layout_constraintStart_toStartOf="parent" diff --git a/app/src/main/res/layout/item_status.xml b/app/src/main/res/layout/item_status.xml index 45a2eb757..14bf4e0bd 100644 --- a/app/src/main/res/layout/item_status.xml +++ b/app/src/main/res/layout/item_status.xml @@ -12,21 +12,22 @@ + tools:ignore="RtlSymmetry" + tools:text="13" /> + app:layout_constraintBottom_toBottomOf="@+id/total_usage" + app:layout_constraintStart_toEndOf="@+id/total_usage" + app:layout_constraintTop_toTopOf="@+id/total_usage" /> + app:layout_constraintBottom_toBottomOf="@+id/total_accounts" + app:layout_constraintStart_toEndOf="@id/total_accounts" + app:layout_constraintTop_toTopOf="@+id/total_accounts" /> + diff --git a/app/src/main/res/layout/item_trending_date.xml b/app/src/main/res/layout/item_trending_date.xml index 09481c72b..c189fb2b3 100644 --- a/app/src/main/res/layout/item_trending_date.xml +++ b/app/src/main/res/layout/item_trending_date.xml @@ -12,6 +12,5 @@ android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:textAppearance="?android:attr/textAppearanceListItem" - android:textAlignment="textEnd" android:textColor="?android:textColorTertiary" tools:text="@string/date_range" />