From 43c5fce526473bf8d1563c8833ec5a354b8adf37 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Fri, 14 May 2021 10:09:12 +1000 Subject: [PATCH] Make chips look better --- .../securesms/loki/activities/JoinPublicChatActivity.kt | 8 +++++--- .../main/res/layout-sw400dp/fragment_enter_chat_url.xml | 6 ++++++ app/src/main/res/layout/default_group_chip.xml | 8 +++++--- app/src/main/res/layout/fragment_enter_chat_url.xml | 6 ++++++ app/src/main/res/values-notnight-v21/colors.xml | 1 + app/src/main/res/values/colors.xml | 1 + 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/JoinPublicChatActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/JoinPublicChatActivity.kt index f0490d379d..e7c018bc48 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/JoinPublicChatActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/JoinPublicChatActivity.kt @@ -10,6 +10,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.view.inputmethod.InputMethodManager +import android.widget.GridLayout import android.widget.Toast import androidx.activity.viewModels import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory @@ -184,8 +185,9 @@ class EnterChatURLFragment : Fragment() { private fun populateDefaultGroups(groups: List) { defaultRoomsGridLayout.removeAllViews() + defaultRoomsGridLayout.useDefaultMargins = false 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 bitmap = BitmapFactory.decodeByteArray(bytes,0,bytes.size) RoundedBitmapDrawableFactory.create(resources,bitmap).apply { @@ -197,10 +199,10 @@ class EnterChatURLFragment : Fragment() { chip.setOnClickListener { (requireActivity() as JoinPublicChatActivity).joinPublicChatIfPossible(defaultGroup.joinURL) } + defaultRoomsGridLayout.addView(chip) } - if (groups.size and 1 != 0) { - // add a filler weight 1 view + if ((groups.size and 1) != 0) { // This checks that the number of rooms is even layoutInflater.inflate(R.layout.grid_layout_filler, defaultRoomsGridLayout) } } diff --git a/app/src/main/res/layout-sw400dp/fragment_enter_chat_url.xml b/app/src/main/res/layout-sw400dp/fragment_enter_chat_url.xml index a4b088aac1..db470a8785 100644 --- a/app/src/main/res/layout-sw400dp/fragment_enter_chat_url.xml +++ b/app/src/main/res/layout-sw400dp/fragment_enter_chat_url.xml @@ -33,8 +33,12 @@ >>>>>> 133bcac17 (Make chips look better) android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> @@ -42,12 +46,14 @@ android:layout_marginVertical="16dp" android:textSize="18sp" android:textStyle="bold" + android:paddingHorizontal="24dp" android:text="@string/activity_join_public_chat_join_rooms" android:layout_width="match_parent" android:layout_height="wrap_content"/> diff --git a/app/src/main/res/layout/default_group_chip.xml b/app/src/main/res/layout/default_group_chip.xml index 844898e885..e0a410ca6b 100644 --- a/app/src/main/res/layout/default_group_chip.xml +++ b/app/src/main/res/layout/default_group_chip.xml @@ -4,11 +4,13 @@ xmlns:tools="http://schemas.android.com/tools" android:theme="@style/Theme.MaterialComponents.DayNight" style="?attr/chipStyle" - app:chipStartPadding="6dp" + app:chipStartPadding="4dp" + app:chipBackgroundColor="@color/open_group_chip_color" android:layout_columnWeight="1" - android:layout_marginHorizontal="2dp" tools:text="Main Group" android:ellipsize="end" tools:layout_width="wrap_content" + app:chipMinTouchTargetSize="0dp" + android:layout_margin="4dp" android:layout_width="0dp" - android:layout_height="52dp" /> \ No newline at end of file + android:layout_height="wrap_content" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_enter_chat_url.xml b/app/src/main/res/layout/fragment_enter_chat_url.xml index 7affed157e..27dd369d71 100644 --- a/app/src/main/res/layout/fragment_enter_chat_url.xml +++ b/app/src/main/res/layout/fragment_enter_chat_url.xml @@ -33,8 +33,12 @@ >>>>>> 133bcac17 (Make chips look better) android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> @@ -42,12 +46,14 @@ android:layout_marginVertical="16dp" android:textSize="18sp" android:textStyle="bold" + android:paddingHorizontal="24dp" android:text="@string/activity_join_public_chat_join_rooms" android:layout_width="match_parent" android:layout_height="wrap_content"/> diff --git a/app/src/main/res/values-notnight-v21/colors.xml b/app/src/main/res/values-notnight-v21/colors.xml index 4d90ff3f87..36e4a1858d 100644 --- a/app/src/main/res/values-notnight-v21/colors.xml +++ b/app/src/main/res/values-notnight-v21/colors.xml @@ -22,6 +22,7 @@ #F5F5F5 #FCFCFC #F5F5F5 + #0D000000 #ffffff diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index ecbcd77ec7..8771cdae4e 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -31,6 +31,7 @@ #1B1B1B #212121 #FFCE3A + #0DFFFFFF #5ff8b0