From 54b97759e266e3ad58530c43d35cad44f757064a Mon Sep 17 00:00:00 2001 From: rhunk <101876869+rhunk@users.noreply.github.com> Date: Sat, 7 Oct 2023 11:32:24 +0200 Subject: [PATCH] feat: better ff group menu buttons --- .../ui/menu/impl/FriendFeedInfoMenu.kt | 14 ++++---------- .../snapenhance/ui/menu/impl/MenuViewInjector.kt | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/ui/menu/impl/FriendFeedInfoMenu.kt b/core/src/main/kotlin/me/rhunk/snapenhance/ui/menu/impl/FriendFeedInfoMenu.kt index 1a41be75..c7c8f3d0 100644 --- a/core/src/main/kotlin/me/rhunk/snapenhance/ui/menu/impl/FriendFeedInfoMenu.kt +++ b/core/src/main/kotlin/me/rhunk/snapenhance/ui/menu/impl/FriendFeedInfoMenu.kt @@ -1,7 +1,5 @@ package me.rhunk.snapenhance.ui.menu.impl -import android.annotation.SuppressLint -import android.content.Context import android.content.DialogInterface import android.content.res.Resources import android.graphics.BitmapFactory @@ -102,7 +100,7 @@ class FriendFeedInfoMenu : AbstractMenu() { } } - private fun showPreview(userId: String?, conversationId: String, androidCtx: Context?) { + private fun showPreview(userId: String?, conversationId: String) { //query message val messageLogger = context.feature(MessageLogger::class) val messages: List = context.database.getMessagesFromConversationId( @@ -213,16 +211,13 @@ class FriendFeedInfoMenu : AbstractMenu() { val switch = Switch(context.androidContext) switch.text = context.translation[text] switch.isChecked = isChecked() - switch.applyTheme() + switch.applyTheme(hasRadius = true) switch.setOnCheckedChangeListener { _: CompoundButton?, checked: Boolean -> toggle(checked) } viewConsumer(switch) } - @SuppressLint("SetTextI18n", "UseSwitchCompatOrMaterialCode", "DefaultLocale", "InflateParams", - "DiscouragedApi", "ClickableViewAccessibility" - ) fun inject(viewModel: View, viewConsumer: ((View) -> Unit)) { val modContext = context @@ -233,12 +228,11 @@ class FriendFeedInfoMenu : AbstractMenu() { val previewButton = Button(viewModel.context).apply { text = modContext.translation["friend_menu_option.preview"] - applyTheme(viewModel.width) + applyTheme(viewModel.width, hasRadius = true) setOnClickListener { showPreview( targetUser, - conversationId, - context + conversationId ) } } diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/ui/menu/impl/MenuViewInjector.kt b/core/src/main/kotlin/me/rhunk/snapenhance/ui/menu/impl/MenuViewInjector.kt index d43b1076..181adf37 100644 --- a/core/src/main/kotlin/me/rhunk/snapenhance/ui/menu/impl/MenuViewInjector.kt +++ b/core/src/main/kotlin/me/rhunk/snapenhance/ui/menu/impl/MenuViewInjector.kt @@ -88,11 +88,22 @@ class MenuViewInjector : Feature("MenuViewInjector", loadParams = FeatureLoadPar val viewList = mutableListOf() context.runOnUiThread { friendFeedInfoMenu.inject(injectedLayout) { view -> - view.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { - setMargins(0, 3, 0, 3) + view.layoutParams = LinearLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT + ).apply { + setMargins(0, 5, 0, 5) } viewList.add(view) } + + viewList.add(View(injectedLayout.context).apply { + layoutParams = LinearLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + 30 + ) + }) + viewList.reversed().forEach { injectedLayout.addView(it, 0) } }