Make chips look better

This commit is contained in:
Niels Andriesse 2021-05-14 10:09:12 +10:00
parent 61c210837e
commit 133bcac17c
6 changed files with 16 additions and 7 deletions

View File

@ -10,6 +10,7 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import android.widget.GridLayout
import android.widget.Toast import android.widget.Toast
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory
import androidx.core.view.isVisible import androidx.core.view.isVisible
@ -193,8 +194,9 @@ class EnterChatURLFragment : Fragment() {
private fun populateDefaultGroups(groups: List<DefaultGroup>) { private fun populateDefaultGroups(groups: List<DefaultGroup>) {
defaultRoomsGridLayout.removeAllViews() defaultRoomsGridLayout.removeAllViews()
defaultRoomsGridLayout.useDefaultMargins = false
groups.forEach { defaultGroup -> groups.forEach { defaultGroup ->
val chip = layoutInflater.inflate(R.layout.default_group_chip,defaultRoomsGridLayout, false) as Chip val chip = layoutInflater.inflate(R.layout.default_group_chip, defaultRoomsGridLayout, false) as Chip
val drawable = defaultGroup.image?.let { bytes -> val drawable = defaultGroup.image?.let { bytes ->
val bitmap = BitmapFactory.decodeByteArray(bytes,0, bytes.size) val bitmap = BitmapFactory.decodeByteArray(bytes,0, bytes.size)
RoundedBitmapDrawableFactory.create(resources,bitmap).apply { RoundedBitmapDrawableFactory.create(resources,bitmap).apply {
@ -206,9 +208,10 @@ class EnterChatURLFragment : Fragment() {
chip.setOnClickListener { chip.setOnClickListener {
(requireActivity() as JoinPublicChatActivity).joinPublicChatIfPossible(defaultGroup.joinURL) (requireActivity() as JoinPublicChatActivity).joinPublicChatIfPossible(defaultGroup.joinURL)
} }
defaultRoomsGridLayout.addView(chip) defaultRoomsGridLayout.addView(chip)
} }
if (groups.size and 1 != 0) { if ((groups.size and 1) != 0) { // This checks that the number of rooms is even
layoutInflater.inflate(R.layout.grid_layout_filler, defaultRoomsGridLayout) layoutInflater.inflate(R.layout.grid_layout_filler, defaultRoomsGridLayout)
} }
} }

View File

@ -33,7 +33,6 @@
<LinearLayout <LinearLayout
android:visibility="gone" android:visibility="gone"
android:paddingHorizontal="24dp"
android:id="@+id/defaultRoomsContainer" android:id="@+id/defaultRoomsContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -43,6 +42,7 @@
android:layout_marginVertical="16dp" android:layout_marginVertical="16dp"
android:textSize="18sp" android:textSize="18sp"
android:textStyle="bold" android:textStyle="bold"
android:paddingHorizontal="24dp"
android:text="@string/activity_join_public_chat_join_rooms" android:text="@string/activity_join_public_chat_join_rooms"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
@ -50,6 +50,7 @@
<GridLayout <GridLayout
android:id="@+id/defaultRoomsGridLayout" android:id="@+id/defaultRoomsGridLayout"
android:columnCount="2" android:columnCount="2"
android:paddingHorizontal="16dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>

View File

@ -5,11 +5,13 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:theme="@style/Theme.MaterialComponents.DayNight" android:theme="@style/Theme.MaterialComponents.DayNight"
style="?attr/chipStyle" style="?attr/chipStyle"
app:chipStartPadding="6dp" app:chipStartPadding="4dp"
app:chipBackgroundColor="@color/open_group_chip_color"
android:layout_columnWeight="1" android:layout_columnWeight="1"
android:layout_marginHorizontal="2dp"
tools:text="Main Group" tools:text="Main Group"
android:ellipsize="end" android:ellipsize="end"
tools:layout_width="wrap_content" tools:layout_width="wrap_content"
app:chipMinTouchTargetSize="0dp"
android:layout_margin="4dp"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="52dp" /> android:layout_height="wrap_content" />

View File

@ -33,7 +33,6 @@
<LinearLayout <LinearLayout
android:visibility="gone" android:visibility="gone"
android:paddingHorizontal="24dp"
android:id="@+id/defaultRoomsContainer" android:id="@+id/defaultRoomsContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -43,6 +42,7 @@
android:layout_marginVertical="16dp" android:layout_marginVertical="16dp"
android:textSize="18sp" android:textSize="18sp"
android:textStyle="bold" android:textStyle="bold"
android:paddingHorizontal="24dp"
android:text="@string/activity_join_public_chat_join_rooms" android:text="@string/activity_join_public_chat_join_rooms"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
@ -50,6 +50,7 @@
<GridLayout <GridLayout
android:id="@+id/defaultRoomsGridLayout" android:id="@+id/defaultRoomsGridLayout"
android:columnCount="2" android:columnCount="2"
android:paddingHorizontal="16dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>

View File

@ -22,6 +22,7 @@
<color name="new_conversation_button_collapsed_background">#F5F5F5</color> <color name="new_conversation_button_collapsed_background">#F5F5F5</color>
<color name="pn_option_background">#FCFCFC</color> <color name="pn_option_background">#FCFCFC</color>
<color name="fake_chat_bubble_background">#F5F5F5</color> <color name="fake_chat_bubble_background">#F5F5F5</color>
<color name="open_group_chip_color">#0D000000</color>
<color name="default_background_start">#ffffff</color> <color name="default_background_start">#ffffff</color>

View File

@ -31,6 +31,7 @@
<color name="pn_option_background">#1B1B1B</color> <color name="pn_option_background">#1B1B1B</color>
<color name="pn_option_border">#212121</color> <color name="pn_option_border">#212121</color>
<color name="paths_building">#FFCE3A</color> <color name="paths_building">#FFCE3A</color>
<color name="open_group_chip_color">#0DFFFFFF</color>
<array name="profile_picture_placeholder_colors"> <array name="profile_picture_placeholder_colors">
<item>#5ff8b0</item> <item>#5ff8b0</item>