mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-12 05:07:46 +02:00
fix(core/ui): hide download icon for opera viewer with toolbar
This commit is contained in:
@ -16,6 +16,7 @@ import android.os.SystemClock
|
||||
import android.view.Gravity
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Switch
|
||||
import android.widget.TextView
|
||||
import me.rhunk.snapenhance.core.util.ktx.getDimens
|
||||
@ -69,6 +70,14 @@ fun View.triggerCloseTouchEvent() {
|
||||
}
|
||||
}
|
||||
|
||||
fun ViewGroup.children(): List<View> {
|
||||
val children = mutableListOf<View>()
|
||||
for (i in 0 until childCount) {
|
||||
children.add(getChildAt(i))
|
||||
}
|
||||
return children
|
||||
}
|
||||
|
||||
fun View.iterateParent(predicate: (View) -> Boolean) {
|
||||
var parent = this.parent as? View ?: return
|
||||
while (true) {
|
||||
|
@ -7,6 +7,7 @@ import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import me.rhunk.snapenhance.core.features.impl.downloader.MediaDownloader
|
||||
import me.rhunk.snapenhance.core.ui.children
|
||||
import me.rhunk.snapenhance.core.ui.menu.AbstractMenu
|
||||
import me.rhunk.snapenhance.core.util.ktx.getDimens
|
||||
import me.rhunk.snapenhance.core.util.ktx.getDrawable
|
||||
@ -34,6 +35,19 @@ class OperaDownloadIconMenu : AbstractMenu() {
|
||||
setOnClickListener {
|
||||
this@OperaDownloadIconMenu.context.feature(MediaDownloader::class).downloadLastOperaMediaAsync()
|
||||
}
|
||||
addOnAttachStateChangeListener(object: View.OnAttachStateChangeListener {
|
||||
override fun onViewAttachedToWindow(v: View) {
|
||||
v.visibility = View.VISIBLE
|
||||
(parent.parent as? ViewGroup)?.children()?.forEach { child ->
|
||||
if (child !is ViewGroup) return@forEach
|
||||
child.children().forEach {
|
||||
if (it::class.java.name.endsWith("PreviewToolbar")) v.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewDetachedFromWindow(v: View) {}
|
||||
})
|
||||
}, 0)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user