mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-29 04:50:15 +02:00
fix(ui/settings_gear): simple Snapchat support
Signed-off-by: rhunk <101876869+rhunk@users.noreply.github.com>
This commit is contained in:
parent
b37d6635ff
commit
bb00569cf0
@ -50,6 +50,7 @@ class MenuViewInjector : Feature("MenuViewInjector") {
|
|||||||
val actionMenu = context.resources.getIdentifier("action_menu", "id")
|
val actionMenu = context.resources.getIdentifier("action_menu", "id")
|
||||||
val componentsHolder = context.resources.getIdentifier("components_holder", "id")
|
val componentsHolder = context.resources.getIdentifier("components_holder", "id")
|
||||||
val feedNewChat = context.resources.getIdentifier("feed_new_chat", "id")
|
val feedNewChat = context.resources.getIdentifier("feed_new_chat", "id")
|
||||||
|
val hovaNavMapIcon = context.resources.getIdentifier("hova_header_search_icon", "id")
|
||||||
val contextMenuButtonIconView = context.resources.getIdentifier("context_menu_button_icon_view", "id")
|
val contextMenuButtonIconView = context.resources.getIdentifier("context_menu_button_icon_view", "id")
|
||||||
val chatActionMenu = context.resources.getIdentifier("chat_action_menu", "id")
|
val chatActionMenu = context.resources.getIdentifier("chat_action_menu", "id")
|
||||||
|
|
||||||
@ -87,7 +88,7 @@ class MenuViewInjector : Feature("MenuViewInjector") {
|
|||||||
menuMap[OperaViewerIcons::class]!!.inject(viewGroup, childView, originalAddView)
|
menuMap[OperaViewerIcons::class]!!.inject(viewGroup, childView, originalAddView)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.parent.id == componentsHolder && childView.id == feedNewChat) {
|
if (event.parent.id == componentsHolder && (childView.id == feedNewChat || childView.id == hovaNavMapIcon)) {
|
||||||
menuMap[SettingsGearInjector::class]!!.inject(viewGroup, childView, originalAddView)
|
menuMap[SettingsGearInjector::class]!!.inject(viewGroup, childView, originalAddView)
|
||||||
return@subscribe
|
return@subscribe
|
||||||
}
|
}
|
||||||
|
@ -18,21 +18,22 @@ import me.rhunk.snapenhance.core.util.ktx.getStyledAttributes
|
|||||||
class SettingsGearInjector : AbstractMenu() {
|
class SettingsGearInjector : AbstractMenu() {
|
||||||
override fun inject(parent: ViewGroup, view: View, viewConsumer: (View) -> Unit) {
|
override fun inject(parent: ViewGroup, view: View, viewConsumer: (View) -> Unit) {
|
||||||
if (context.config.userInterface.hideSettingsGear.get()) return
|
if (context.config.userInterface.hideSettingsGear.get()) return
|
||||||
val firstView = (view as ViewGroup).getChildAt(0)
|
val hovaNavMapIcon = parent.findViewById<View>(context.resources.getId("hova_nav_map_icon"))
|
||||||
|
val firstView = hovaNavMapIcon ?: (view as ViewGroup).getChildAt(0)
|
||||||
|
|
||||||
val ngsHovaHeaderSearchIconBackgroundMarginLeft = context.resources.getDimens("ngs_hova_header_search_icon_background_margin_left")
|
val ngsHovaHeaderSearchIconBackgroundMarginLeft = context.resources.getDimens("ngs_hova_header_search_icon_background_margin_left")
|
||||||
|
|
||||||
view.clipChildren = false
|
(view as ViewGroup).clipChildren = false
|
||||||
view.addView(FrameLayout(parent.context).apply {
|
view.addView(FrameLayout(parent.context).apply {
|
||||||
visibility = View.GONE
|
visibility = View.GONE
|
||||||
post {
|
post {
|
||||||
layoutParams = FrameLayout.LayoutParams(firstView.layoutParams.width, firstView.layoutParams.height).apply {
|
layoutParams = FrameLayout.LayoutParams(firstView.layoutParams.width, firstView.layoutParams.height).apply {
|
||||||
y = 0f
|
y = 0f
|
||||||
x = if (parent.findViewById<View>(context.resources.getId("hova_nav_map_icon")) != null) {
|
// TODO: find a better way to calculate the x position with the correct padding when Simple Snapchat is active
|
||||||
parent.resources.displayMetrics.widthPixels - firstView.layoutParams.width - ngsHovaHeaderSearchIconBackgroundMarginLeft * 2 - (firstView.layoutParams.width).toFloat() * 2f
|
x = -(ngsHovaHeaderSearchIconBackgroundMarginLeft + firstView.layoutParams.width).toFloat() +
|
||||||
} else {
|
(hovaNavMapIcon.takeIf { it != null }?.let {
|
||||||
-(ngsHovaHeaderSearchIconBackgroundMarginLeft + firstView.layoutParams.width).toFloat()
|
7 * context.resources.displayMetrics.density
|
||||||
}
|
} ?: 0f)
|
||||||
}
|
}
|
||||||
visibility = View.VISIBLE
|
visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
@ -66,6 +67,7 @@ class SettingsGearInjector : AbstractMenu() {
|
|||||||
gravity = android.view.Gravity.CENTER
|
gravity = android.view.Gravity.CENTER
|
||||||
}
|
}
|
||||||
setImageDrawable(context.resources.getDrawable("svg_settings_32x32", context.theme))
|
setImageDrawable(context.resources.getDrawable("svg_settings_32x32", context.theme))
|
||||||
|
// TODO: find a better way to tint the icon when Simple Snapchat is active
|
||||||
context.resources.getStyledAttributes("headerButtonOpaqueIconTint", context.theme).use {
|
context.resources.getStyledAttributes("headerButtonOpaqueIconTint", context.theme).use {
|
||||||
imageTintList = it.getColorStateList(0)
|
imageTintList = it.getColorStateList(0)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user