commit 54b97759e266e3ad58530c43d35cad44f757064a
parent bc67308df831fe3007131107ba7a4cc38f592bac
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date: Sat, 7 Oct 2023 11:32:24 +0200
feat: better ff group menu buttons
Diffstat:
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
@@ -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<ConversationMessage> = 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
@@ -88,11 +88,22 @@ class MenuViewInjector : Feature("MenuViewInjector", loadParams = FeatureLoadPar
val viewList = mutableListOf<View>()
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) }
}