3492: Correctly shorten name in drawer and notifications (#3495)

* #3492: Correctly shorten name in drawer and notifications

* Trigger linter again

* 3492: Use a flat ContraintLayout for everything
This commit is contained in:
UlrichKu 2023-04-08 16:55:32 +02:00 committed by GitHub
parent 5f00e3fd35
commit 040268e2d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 133 additions and 121 deletions

View file

@ -27,6 +27,7 @@ import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils
import android.util.Log import android.util.Log
import android.view.KeyEvent import android.view.KeyEvent
import android.view.Menu import android.view.Menu
@ -463,6 +464,9 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
closeDrawerOnProfileListClick = true closeDrawerOnProfileListClick = true
} }
header.currentProfileName.maxLines = 1
header.currentProfileName.ellipsize = TextUtils.TruncateAt.END
header.accountHeaderBackground.setColorFilter(getColor(R.color.headerBackgroundFilter)) header.accountHeaderBackground.setColorFilter(getColor(R.color.headerBackgroundFilter))
header.accountHeaderBackground.setBackgroundColor(MaterialColors.getColor(header, R.attr.colorBackgroundAccent)) header.accountHeaderBackground.setBackgroundColor(MaterialColors.getColor(header, R.attr.colorBackgroundAccent))
val animateAvatars = preferences.getBoolean("animateGifAvatars", false) val animateAvatars = preferences.getBoolean("animateGifAvatars", false)

View file

@ -137,7 +137,9 @@ internal class StatusNotificationViewHolder(
} }
private fun showNotificationContent(show: Boolean) { private fun showNotificationContent(show: Boolean) {
binding.statusNameBar.visibility = if (show) View.VISIBLE else View.GONE binding.statusDisplayName.visibility = if (show) View.VISIBLE else View.GONE
binding.statusUsername.visibility = if (show) View.VISIBLE else View.GONE
binding.statusMetaInfo.visibility = if (show) View.VISIBLE else View.GONE
binding.notificationContentWarningDescription.visibility = binding.notificationContentWarningDescription.visibility =
if (show) View.VISIBLE else View.GONE if (show) View.VISIBLE else View.GONE
binding.notificationContentWarningButton.visibility = binding.notificationContentWarningButton.visibility =

View file

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?><!--This applies only to favourite and rebnotificationsEnabledions.--> <?xml version="1.0" encoding="utf-8"?><!--This applies only to favourite and rebnotificationsEnabledions.-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/notification_container" android:id="@+id/notification_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="14dp" android:paddingLeft="14dp"
android:paddingRight="14dp"> android:paddingRight="14dp">
@ -12,7 +12,6 @@
android:id="@+id/notification_top_text" android:id="@+id/notification_top_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginBottom="6dp" android:layout_marginBottom="6dp"
android:drawablePadding="10dp" android:drawablePadding="10dp"
@ -22,130 +21,20 @@
android:paddingStart="28dp" android:paddingStart="28dp"
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorSecondary"
android:textSize="?attr/status_text_medium" android:textSize="?attr/status_text_medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Someone favourited your status" /> tools:text="Someone favourited your status" />
<RelativeLayout
android:id="@+id/status_name_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/notification_top_text"
android:layout_toEndOf="@+id/notification_status_avatar"
android:paddingBottom="4dp">
<TextView
android:id="@+id/status_display_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:ellipsize="end"
android:maxLines="1"
android:paddingStart="0dp"
android:paddingEnd="@dimen/status_display_name_padding_end"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_medium"
android:textStyle="normal|bold"
tools:text="Ente" />
<TextView
android:id="@+id/status_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toStartOf="@+id/status_meta_info"
android:layout_toEndOf="@id/status_display_name"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_medium"
tools:text="\@Entenhausen" />
<TextView
android:id="@+id/status_meta_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginStart="4dp"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_medium"
tools:text="13:37" />
</RelativeLayout>
<com.keylesspalace.tusky.view.ClickableSpanTextView
android:id="@+id/notification_content_warning_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/status_name_bar"
android:layout_toEndOf="@id/notification_status_avatar"
android:hyphenationFrequency="full"
android:lineSpacingMultiplier="1.1"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_medium"
tools:text="Example CW text" />
<Button
android:id="@+id/notification_content_warning_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/notification_content_warning_description"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_toEndOf="@id/notification_status_avatar"
android:minWidth="150dp"
android:minHeight="0dp"
android:paddingLeft="16dp"
android:paddingTop="4dp"
android:paddingRight="16dp"
android:paddingBottom="4dp"
android:textAllCaps="true"
tools:text="@string/post_content_warning_show_more"
style="@style/TuskyButton.Outlined"
android:textSize="?attr/status_text_medium" />
<com.keylesspalace.tusky.view.ClickableSpanTextView
android:id="@+id/notification_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/notification_content_warning_button"
android:layout_toEndOf="@+id/notification_status_avatar"
android:hyphenationFrequency="full"
android:lineSpacingMultiplier="1.1"
android:paddingBottom="10dp"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_medium"
tools:text="Example status here" />
<Button
android:id="@+id/button_toggle_notification_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/notification_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_toEndOf="@id/notification_status_avatar"
android:minWidth="150dp"
android:minHeight="0dp"
android:paddingLeft="16dp"
android:paddingTop="4dp"
android:paddingRight="16dp"
android:paddingBottom="4dp"
android:textAllCaps="true"
tools:text="@string/post_content_show_less"
style="@style/TuskyButton.Outlined"
android:textSize="?attr/status_text_medium"
android:visibility="gone" />
<ImageView <ImageView
android:id="@+id/notification_status_avatar" android:id="@+id/notification_status_avatar"
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_below="@id/notification_top_text"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_marginEnd="14dp"
android:layout_marginRight="14dp"
android:layout_marginBottom="14dp" android:layout_marginBottom="14dp"
android:contentDescription="@string/action_view_profile" android:contentDescription="@string/action_view_profile"
android:scaleType="centerCrop" android:scaleType="centerCrop"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/notification_top_text"
tools:ignore="RtlHardcoded,RtlSymmetry" tools:ignore="RtlHardcoded,RtlSymmetry"
tools:src="@drawable/avatar_default" /> tools:src="@drawable/avatar_default" />
@ -153,7 +42,124 @@
android:id="@+id/notification_notification_avatar" android:id="@+id/notification_notification_avatar"
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_alignEnd="@id/notification_status_avatar" app:layout_constraintBottom_toBottomOf="@id/notification_status_avatar"
android:layout_alignBottom="@+id/notification_status_avatar" /> app:layout_constraintEnd_toEndOf="@id/notification_status_avatar" />
</RelativeLayout> <TextView
android:id="@+id/status_display_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="14dp"
android:ellipsize="end"
android:maxLines="1"
android:paddingStart="0dp"
android:paddingEnd="@dimen/status_display_name_padding_end"
android:paddingBottom="4dp"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_medium"
android:textStyle="normal|bold"
app:layout_constrainedWidth="true"
app:layout_constraintEnd_toStartOf="@id/status_meta_info"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@id/notification_notification_avatar"
app:layout_constraintTop_toBottomOf="@id/notification_top_text"
tools:text="Ente MM" />
<TextView
android:id="@+id/status_username"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:paddingBottom="4dp"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_medium"
app:layout_constraintEnd_toStartOf="@id/status_meta_info"
app:layout_constraintStart_toEndOf="@id/status_display_name"
app:layout_constraintTop_toBottomOf="@id/notification_top_text"
tools:text="\@Entenhausen" />
<TextView
android:id="@+id/status_meta_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:paddingBottom="4dp"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/notification_top_text"
tools:text="13:37" />
<com.keylesspalace.tusky.view.ClickableSpanTextView
android:id="@+id/notification_content_warning_description"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="14dp"
android:hyphenationFrequency="full"
android:lineSpacingMultiplier="1.1"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/notification_status_avatar"
app:layout_constraintTop_toBottomOf="@id/status_display_name"
tools:text="Example CW text" />
<Button
android:id="@+id/notification_content_warning_button"
style="@style/TuskyButton.Outlined"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="14dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:minWidth="150dp"
android:minHeight="0dp"
android:paddingLeft="16dp"
android:paddingTop="4dp"
android:paddingRight="16dp"
android:paddingBottom="4dp"
android:textAllCaps="true"
android:textSize="?attr/status_text_medium"
app:layout_constraintStart_toEndOf="@id/notification_status_avatar"
app:layout_constraintTop_toBottomOf="@id/notification_content_warning_description"
tools:text="@string/post_content_warning_show_more" />
<com.keylesspalace.tusky.view.ClickableSpanTextView
android:id="@+id/notification_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="14dp"
android:hyphenationFrequency="full"
android:lineSpacingMultiplier="1.1"
android:paddingBottom="10dp"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/notification_status_avatar"
app:layout_constraintTop_toBottomOf="@id/notification_content_warning_button"
tools:text="Example status here" />
<Button
android:id="@+id/button_toggle_notification_content"
style="@style/TuskyButton.Outlined"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="14dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:minWidth="150dp"
android:minHeight="0dp"
android:paddingLeft="16dp"
android:paddingTop="4dp"
android:paddingRight="16dp"
android:paddingBottom="4dp"
android:textAllCaps="true"
android:textSize="?attr/status_text_medium"
android:visibility="gone"
app:layout_constraintStart_toEndOf="@id/notification_status_avatar"
app:layout_constraintTop_toBottomOf="@id/notification_content"
tools:text="@string/post_content_show_less" />
</androidx.constraintlayout.widget.ConstraintLayout>