Long usernames no longer cover up likes in chat (#1130)

* Switching the LinearLayout containing the username and likes with a
table whose columns can stretch such that the username will word wrap,
but the moderator or likes text will not word wrap or spill out.

* - Fixing line endings (had it set to CRLF)
- Removing a grivity=right since the table is now taking care of it

* nevermind, that was just autoformatting :/

* Switching from wordwrap to elipses

* Moving back to word wrap and shortened Mod tag

* missed committing this

* Not fully resolving LayoutParams for consistency
This commit is contained in:
bacowan 2019-05-15 09:58:54 -03:00 committed by Phillip Thelen
parent 38952f1078
commit 2f2fbce0ba
3 changed files with 55 additions and 49 deletions

View file

@ -32,56 +32,57 @@
style="@style/CardContent.Compact"
android:background="@drawable/layout_rounded_bg"
android:padding="@dimen/spacing_medium">
<LinearLayout
android:layout_width="fill_parent"
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1.0"
android:baselineAligned="false"
android:gravity="center_vertical">
<com.habitrpg.android.habitica.ui.views.social.UsernameLabel
android:id="@+id/user_label"
style="@style/ChatMessageUserTextViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
tools:text="Username"
android:focusable="true" />
<TextView
android:id="@+id/mod_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textSize="12sp"
android:textColor="@color/white"
style="@style/Pill.Purple"
tools:text="Moderator"
android:layout_marginLeft="@dimen/spacing_small"/>
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1" />
<LinearLayout
android:id="@+id/like_background_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_weight="1"
android:background="@drawable/layout_rounded_bg">
<TextView
android:id="@+id/tvLikes"
android:gravity="center_vertical"
android:shrinkColumns="0"
android:stretchColumns="2">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.habitrpg.android.habitica.ui.views.social.UsernameLabel
android:id="@+id/user_label"
style="@style/ChatMessageUserTextViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_gravity="center_vertical"
android:clickable="true"
android:gravity="center_vertical"
tools:text="Username"
android:focusable="true" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/mod_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textSize="12sp"
android:textColor="@color/white"
style="@style/Pill.Purple"
tools:text="Moderator"
android:layout_marginLeft="@dimen/spacing_small"/>
<View
android:layout_width="0dp"
android:layout_height="1dp"/>
<LinearLayout
android:id="@+id/like_background_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:background="@drawable/layout_rounded_bg">
<TextView
android:id="@+id/tvLikes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:clickable="true"
android:gravity="center_vertical"
android:focusable="true" />
</LinearLayout>
</TableRow>
</TableLayout>
<TextView
android:id="@+id/subline_textview"
android:layout_width="wrap_content"

View file

@ -807,7 +807,7 @@
<string name="daily_tip_7">Try pinning items from the Market to your Rewards to help motivate you to earn them!</string>
<string name="daily_tip_8">You can change your task\'s difficulty to reward yourself more for hard tasks!</string>
<string name="daily_tip_9">If you\'re having a tough time, try breaking your tasks down into smaller parts.</string>
<string name="moderator">Moderator</string>
<string name="moderator">Mod</string>
<string name="staff">Staff</string>
<string name="expand_notes">Read More</string>
<string name="collapse_notes">Show Less</string>

View file

@ -39,11 +39,12 @@ class UsernameLabel(context: Context?, attrs: AttributeSet?) : LinearLayout(cont
}
init {
val params = LayoutParams(
val textViewParams = LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT)
params.gravity = Gravity.CENTER_VERTICAL
addView(textView, params)
textViewParams.gravity = Gravity.CENTER_VERTICAL
textViewParams.weight = 1.0f
addView(textView, textViewParams)
val padding = context?.resources?.getDimension(R.dimen.spacing_small)?.toInt() ?: 0
textView.setPadding(0, 0, padding, 0)
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f)
@ -52,6 +53,10 @@ class UsernameLabel(context: Context?, attrs: AttributeSet?) : LinearLayout(cont
} else {
textView.setTextAppearance(context, R.style.Body1)
}
addView(tierIconView, params)
val iconViewParams = LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT)
iconViewParams.gravity = Gravity.CENTER_VERTICAL
addView(tierIconView, iconViewParams)
}
}