From 6c0543039ef5c0653ba6c3c9de0c8fa0cb4099de Mon Sep 17 00:00:00 2001 From: tareksander <57038324+tareksander@users.noreply.github.com> Date: Fri, 7 Jan 2022 13:58:37 +0100 Subject: [PATCH] Changed: Removed experimental RecyclerView support, added options to make links in TextViews clickable and text selectable. --- Protocol.md | 4 +- README.md | 13 ++ TODO | 6 +- .../java/com/termux/gui/ConnectionHandler.kt | 4 +- .../main/java/com/termux/gui/GUIActivity.kt | 125 +----------------- app/src/main/java/com/termux/gui/Util.kt | 20 +-- .../java/com/termux/gui/protocol/v0/Create.kt | 45 ++++--- .../gui/protocol/v0/GUIRecyclerViewAdapter.kt | 104 --------------- .../termux/gui/protocol/v0/HandleBuffer.kt | 8 +- .../com/termux/gui/protocol/v0/HandleView.kt | 92 ++++++------- .../gui/protocol/v0/LifecycleListener.kt | 20 +-- .../java/com/termux/gui/protocol/v0/V0.kt | 38 ++---- 12 files changed, 130 insertions(+), 349 deletions(-) delete mode 100644 app/src/main/java/com/termux/gui/protocol/v0/GUIRecyclerViewAdapter.kt diff --git a/Protocol.md b/Protocol.md index 727a810..73805de 100644 --- a/Protocol.md +++ b/Protocol.md @@ -175,6 +175,8 @@ Due to Android limitations, methods that return a value fail when the Activity i - parent: The View id of the parent in the Layout hierarchy. if not specified, this will replace the root of the hierarchy and delete all existing views. - aid: The id of the Activity in which to create the View. - text: For Button, TextView and EditText, this is the initial Text. + - selectableText: For TextViews, this specifies whether the text can be selected. Default is false. + - clickableLinks: For TextViews, this specifies whether links can be clicked or not. Default is false. - vertical: For LinearLayout, this specifies if the Layout is vertical or horizontal. If not specified, vertical is assumed. - snapping: NestedScrollView and HorizontalScrollView snap to the nearest item if this is set to true. Default is false. - fillviewport: Makes the child of a HorizontalScrollView or a NestedScrollView automatically expand to the ScrollView size. Default is false. @@ -450,7 +452,7 @@ The additional values are: - action: one of "up", "down", "pointer_up", "pointer_down", "cancel", "move", corresponding to [MotionEvent values](https://developer.android.com/reference/android/view/MotionEvent#constants_1) for ACTION_DOWN etc. - index: for "pointer_up" and "pointer_down" this is the index of the pointer removed/added. - time: The time of the event in milliseconds since boot excluding sleep. Use this when checking for gestures or other time-sensitive things. -- pointers: An array of pointer data objects, each containing: +- pointers: An array of arrays of pointer data objects. The first dimension is for grouping multiple move events together. The second dimension is for the pointer positions in each event. The elements in the array are: - x, y: The coordinates of the pointer inside the View (not in the window). For ImageView, these are the coordinates of the pixel in the displayed image or buffer, so you don't need to convert the position yourself. - id: The pointer id. This stays consistent for each pointer in the frame between "up" and "down" events diff --git a/README.md b/README.md index 85f173e..28c3d0c 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,19 @@ Releases on f-droid will be provided as soon as possible. When there is a releas Protocol.md describes the Protocol used and the available functions you can use. If you want to use overlay windows or be able to open windows from the background, go into the app settings for Termux:GUI, open the advanced section and enable "Display over other apps". +### Comparison with native apps + +| Native app | With Termux:GUI | +|-----------------------------------------------------------|-----------------------------------------------------------------------------| +| Has to be installed | Program can be run in Termux | +| Full access to the Android API | Access to the Android API through Termux:GUI and Termux:API | +| Limited to C, C++, Kotlin and Java for native development | Any programming language can be used, prebuilt library for python available | +| | Lower performance caused by IPC | +| Accessing files in Termux only possible via SAF | Direct access to files in Termux | +| Has to be started with `am` from Termux | Can be started like any other program in Termux | +| | Can receive command line arguments and output back to the Terminal | + + ## Language Bindings - [Python](https://github.com/tareksander/termux-gui-python-bindings) diff --git a/TODO b/TODO index 9c2c461..8c74446 100644 --- a/TODO +++ b/TODO @@ -29,6 +29,9 @@ Roadmap: [x] timezone [x] locale [x] TabLayout + [x] add the ability to make text selectable in a TextView and hyperlinks clickable + [x] https://stackoverflow.com/questions/6025818/select-copy-text-in-a-textview + [x] https://stackoverflow.com/questions/2734270/how-to-make-links-in-a-textview-clickable [ ] update the f-droid metadata [x] write a changelog [ ] more screenshots @@ -51,6 +54,7 @@ Roadmap: [ ] Rework the widgets [ ] option to set an executable as a onClick handler in widgets, that then gets started sa a Termux task. That should work even when no program is connected to listen to widget events. [ ] add everything to the python library + [ ] add the ability to intercept touch events in layouts [ ] add a small helper script to termux-gui-packages, that can be used as a daemon for small stateful widgets. [ ] registers itself to start at boot with Termux:Boot, so the widget state can be restored at startup [ ] watches with inotify on ~/.image-shortcuts @@ -88,7 +92,7 @@ Roadmap: the methods should improve performance [ ] You should also be able to replace the arguments with arrays, in case you want that argument to have a different value for each view, like the text for TextViews [ ] think about creating a batch api to group multiple messages together into one runnable for the ui thread - [ ] + [ ] add the binary protocol type using protobuf diff --git a/app/src/main/java/com/termux/gui/ConnectionHandler.kt b/app/src/main/java/com/termux/gui/ConnectionHandler.kt index f28e0b2..bba879d 100644 --- a/app/src/main/java/com/termux/gui/ConnectionHandler.kt +++ b/app/src/main/java/com/termux/gui/ConnectionHandler.kt @@ -44,7 +44,7 @@ class ConnectionHandler(private val request: GUIService.ConnectionRequest, val s override fun run() { - println("Socket address: " + request.mainSocket) + //println("Socket address: " + request.mainSocket) val main = LocalSocket(LocalSocket.SOCKET_STREAM) val event = LocalSocket(LocalSocket.SOCKET_STREAM) @@ -92,7 +92,7 @@ class ConnectionHandler(private val request: GUIService.ConnectionRequest, val s } } eventWorker!!.start() - println("listening") + //println("listening") when (pversion) { 0 -> V0(app).handleConnection(ptype, main, eventQueue) } diff --git a/app/src/main/java/com/termux/gui/GUIActivity.kt b/app/src/main/java/com/termux/gui/GUIActivity.kt index c1425ff..a16f37a 100644 --- a/app/src/main/java/com/termux/gui/GUIActivity.kt +++ b/app/src/main/java/com/termux/gui/GUIActivity.kt @@ -1,22 +1,11 @@ package com.termux.gui -import android.content.Context -import android.content.pm.ActivityInfo import android.content.res.Configuration import android.graphics.drawable.ColorDrawable -import android.hardware.HardwareBuffer import android.os.Build import android.os.Bundle -import android.os.Parcelable -import android.util.SparseArray -import android.view.View -import android.view.ViewGroup -import android.widget.* import androidx.appcompat.app.AppCompatActivity -import androidx.appcompat.widget.SwitchCompat -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.google.gson.JsonElement -import com.termux.gui.protocol.v0.GUIRecyclerViewAdapter import java.io.Serializable import java.util.* import java.util.concurrent.LinkedBlockingQueue @@ -25,17 +14,11 @@ import kotlin.collections.HashMap open class GUIActivity : AppCompatActivity() { - // a Tree to store the view hierarchy. The existence of Views isn't stored by android itself - private data class Node(val parent: Node?, val id: Int, val claz: Class, val children: LinkedList = LinkedList()) : Serializable - companion object { - private const val THEME_KEY = "tgui_heme" - private const val IDS_KEY = "gui_used_ids" - private const val VIEWS_KEY = "gui_views" + private const val THEME_KEY = "gui_theme" private const val DATA_KEY = "gui_data" - private const val RECYCLERVIEWS_KEY = "rec_data" } val usedIds: TreeSet = TreeSet() init { @@ -56,8 +39,6 @@ open class GUIActivity : AppCompatActivity() { data class GUITheme(val statusBarColor: Int, val colorPrimary: Int, var windowBackground: Int, val textColor: Int, val colorAccent: Int) : Serializable var eventQueue : LinkedBlockingQueue? = null - val recyclerviews = HashMap() - @Suppress("UNCHECKED_CAST") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -72,38 +53,10 @@ open class GUIActivity : AppCompatActivity() { setContentView(R.layout.activity_gui) if (savedInstanceState != null) { theme = savedInstanceState.getSerializable(THEME_KEY) as? GUITheme? - /* - val ids = savedInstanceState.getSerializable(IDS_KEY) as? TreeSet<*> - if (ids != null) { - usedIds.clear() - val l = ids.filterIsInstance(Int::class.java) - for (id in l) { - usedIds.add(id) - } - } - */ val d = savedInstanceState.getSerializable(DATA_KEY) as? ActivityData if (d != null) { data = d } - // Disabled the view saving and restoring for now, because it's unstable - /* - val tree = savedInstanceState.getSerializable(VIEWS_KEY) as? Node - if (tree != null) { - findViewById(R.id.root).addView(buildHierarchyFromTree(tree)) - } - val recs = savedInstanceState.getSerializable(RECYCLERVIEWS_KEY) as? HashMap, Pair, LinkedList>>>> - if (recs != null) { - for (r in recs) { - val rec = GUIRecyclerViewAdapter(this) - for (i in 0 until r.value.first.size) { - r.value.first[i].v = buildHierarchyFromTree(r.value.second.first[i]) - r.value.first[i].v.restoreHierarchyState(r.value.second.second[i]) - } - rec.importViewList(r.value.first) - } - } - */ } } @@ -137,32 +90,6 @@ open class GUIActivity : AppCompatActivity() { super.onConfigurationChanged(newConfig) eventQueue?.offer(ConnectionHandler.Event("config", configToJson(newConfig))) } - - - private fun buildHierarchyFromTree(tree: Node): View { - val v = tree.claz.getConstructor(Context::class.java).newInstance(this) - v.id = tree.id - if (v is ViewGroup) { - for (n in tree.children) { - v.addView(buildHierarchyFromTree(n)) - } - } - - if (v is Button || v is CheckBox || v is SwitchCompat || v is ToggleButton) { - eventQueue?.let { Util.setClickListener(v, data.toString(), true, it) } - } - if (v is RadioGroup) { - eventQueue?.let { Util.setCheckedListener(v, data.toString(), it) } - } - if (v is Spinner) { - eventQueue?.let { Util.setSpinnerListener(v, data.toString(), it) } - } - if (v is SwipeRefreshLayout) { - eventQueue?.let { Util.setRefreshListener(v, data.toString(), it) } - } - - return v - } @Suppress("DEPRECATION") override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) { @@ -192,60 +119,12 @@ open class GUIActivity : AppCompatActivity() { override fun onSaveInstanceState(outState: Bundle) { super.onSaveInstanceState(outState) outState.putSerializable(THEME_KEY, theme) - /* - outState.putSerializable(IDS_KEY, usedIds) - val root = findViewById(R.id.root).getChildAt(0) - if (root != null) { - val tree = createViewTree(root, null) - outState.putSerializable(VIEWS_KEY, tree) - } - val recs = HashMap, Pair, LinkedList>>>>() - for (r in recyclerviews) { - val l = r.value.exportViewList() - val n = LinkedList() - val pl = LinkedList>() - for (v in l) { - val p = SparseArray() - val view = v.v - n.add(createViewTree(view, null)) - view.saveHierarchyState(p) - pl.add(p) - } - recs[r.key] = Pair(l, Pair(n, pl)) - } - outState.putSerializable(RECYCLERVIEWS_KEY, recs) - */ outState.putSerializable(DATA_KEY, data) } - private fun createViewTree(start: View, parent: Node?) : Node { - val children = LinkedList() - if (start !is ViewGroup) { - return Node(parent, start.id, start::class.java, children) - } - val tree = Node(parent, start.id, start::class.java, children) - for (i in 0 until start.childCount) { - val c = start.getChildAt(i) - if (Class.forName("androidx.swiperefreshlayout.widget.CircleImageView").isInstance(c)) { - continue - } - children.add(createViewTree(c, tree)) - } - return tree - } @Suppress("UNCHECKED_CAST") - fun findViewReimplemented(id: Int, recid: Int?, recindex: Int?) : T? { - if (recid != null && recindex != null) { - val rec = recyclerviews[recid] - if (rec != null) { - val el = rec.getViewByIndex(recindex) - if (el != null) { - return el.v.findViewById(id) as? T - } - } - return null - } + fun findViewReimplemented(id: Int) : T? { return findViewById(id) } diff --git a/app/src/main/java/com/termux/gui/Util.kt b/app/src/main/java/com/termux/gui/Util.kt index fba929d..83dfb3b 100644 --- a/app/src/main/java/com/termux/gui/Util.kt +++ b/app/src/main/java/com/termux/gui/Util.kt @@ -13,10 +13,8 @@ import android.view.MotionEvent import android.view.View import android.view.ViewGroup import android.widget.* -import androidx.recyclerview.widget.RecyclerView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.google.android.material.tabs.TabLayout -import com.termux.gui.protocol.v0.GUIRecyclerViewAdapter import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking @@ -109,11 +107,11 @@ class Util { if (t != null) { v.setBackgroundColor(t.windowBackground) } - val fl = a.findViewReimplemented(R.id.root, recid, recindex) as? FrameLayout + val fl = a.findViewReimplemented(R.id.root) as? FrameLayout fl?.removeAllViews() fl?.addView(v) } else { - val g = a.findViewReimplemented(parent, recid, recindex) + val g = a.findViewReimplemented(parent) if (g is LinearLayout) { val p = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1F) if (g.orientation == LinearLayout.VERTICAL) { @@ -322,19 +320,11 @@ class Util { } - fun removeViewRecursive(v: View?, usedIds: MutableSet, recyclerviews: HashMap) { + fun removeViewRecursive(v: View?, usedIds: MutableSet) { if (v != null) { if (v is ViewGroup) { - if (v is RecyclerView) { - val rv = recyclerviews[v.id] - if (rv != null) { - usedIds.removeAll(rv.exportViewList().map { it.id }.toSet()) - recyclerviews.remove(v.id) - } - } else { - while (v.childCount > 0) { - removeViewRecursive(v.getChildAt(0), usedIds, recyclerviews) - } + while (v.childCount > 0) { + removeViewRecursive(v.getChildAt(0), usedIds) } } val p = v.parent diff --git a/app/src/main/java/com/termux/gui/protocol/v0/Create.kt b/app/src/main/java/com/termux/gui/protocol/v0/Create.kt index 6baecf1..ff30f5d 100644 --- a/app/src/main/java/com/termux/gui/protocol/v0/Create.kt +++ b/app/src/main/java/com/termux/gui/protocol/v0/Create.kt @@ -6,6 +6,7 @@ import android.content.ClipboardManager import android.content.Context import android.content.Intent import android.net.Uri +import android.text.method.LinkMovementMethod import android.view.KeyEvent import android.view.inputmethod.EditorInfo import android.view.inputmethod.InputConnection @@ -47,6 +48,10 @@ class Create { v.id = id v.text = m.params?.get("text")?.asString v.freezesText = true + v.setTextIsSelectable(m.params?.get("selectableText")?.asBoolean ?: false) + if (m.params?.get("clickableLinks")?.asBoolean == true) { + v.movementMethod = LinkMovementMethod.getInstance() + } Util.setViewActivity(it, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) @@ -312,7 +317,11 @@ class Create { v.id = id v.text = m.params?.get("text")?.asString v.freezesText = true - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + v.setTextIsSelectable(m.params?.get("selectableText")?.asBoolean ?: false) + if (m.params?.get("clickableLinks")?.asBoolean == true) { + v.movementMethod = LinkMovementMethod.getInstance() + } + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return @@ -326,7 +335,7 @@ class Create { v.setBackgroundResource(android.R.color.transparent) } v.setText(m.params?.get("text")?.asString, TextView.BufferType.EDITABLE) - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return @@ -341,7 +350,7 @@ class Create { } else { LinearLayout.HORIZONTAL } - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return @@ -354,7 +363,7 @@ class Create { v.text = m.params?.get("text")?.asString v.freezesText = true Util.setClickListener(v, aid, true, eventQueue) - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return @@ -364,7 +373,7 @@ class Create { val id = Util.generateViewIDRaw(rand, o.usedIds) Util.runOnUIThreadBlocking { v.id = id - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return @@ -374,7 +383,7 @@ class Create { val id = Util.generateViewIDRaw(rand, o.usedIds) Util.runOnUIThreadBlocking { v.id = id - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return @@ -384,7 +393,7 @@ class Create { val id = Util.generateViewIDRaw(rand, o.usedIds) Util.runOnUIThreadBlocking { v.id = id - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return @@ -398,7 +407,7 @@ class Create { v.isChecked = m.params?.get("checked")?.asBoolean ?: false v.freezesText = true Util.setClickListener(v, aid, true, eventQueue) - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return @@ -414,7 +423,7 @@ class Create { if (m.params?.get("nobar")?.asBoolean == true) { v.scrollBarSize = 0 } - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return @@ -430,7 +439,7 @@ class Create { if (m.params?.get("nobar")?.asBoolean == true) { v.scrollBarSize = 0 } - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return @@ -441,7 +450,7 @@ class Create { Util.runOnUIThreadBlocking { v.id = id Util.setCheckedListener(v, aid, eventQueue) - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return @@ -454,7 +463,7 @@ class Create { v.text = m.params?.get("text")?.asString v.freezesText = true v.isChecked = m.params?.get("checked")?.asBoolean ?: false - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return @@ -465,7 +474,7 @@ class Create { Util.runOnUIThreadBlocking { v.id = id Util.setSpinnerListener(v, aid, eventQueue) - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return @@ -479,7 +488,7 @@ class Create { v.freezesText = true v.isChecked = m.params?.get("checked")?.asBoolean ?: false Util.setClickListener(v, aid, true, eventQueue) - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return @@ -494,7 +503,7 @@ class Create { v.freezesText = true v.isChecked = m.params?.get("checked")?.asBoolean ?: false Util.setClickListener(v, aid, true, eventQueue) - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return @@ -505,7 +514,7 @@ class Create { val v = ProgressBar(app, null, android.R.attr.progressBarStyleHorizontal) id = Util.generateViewIDRaw(rand, o.usedIds) v.id = id - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return @@ -517,7 +526,7 @@ class Create { id = Util.generateViewIDRaw(rand, o.usedIds) v.id = id Util.setRefreshListener(v, aid, eventQueue) - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return @@ -529,7 +538,7 @@ class Create { id = Util.generateViewIDRaw(rand, o.usedIds) v.id = id Util.setTabSelectedListener(v, aid, eventQueue) - V0.setViewOverlay(o, v, parent, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + V0.setViewOverlay(o, v, parent) } Util.sendMessage(out, ConnectionHandler.gson.toJson(id)) return diff --git a/app/src/main/java/com/termux/gui/protocol/v0/GUIRecyclerViewAdapter.kt b/app/src/main/java/com/termux/gui/protocol/v0/GUIRecyclerViewAdapter.kt deleted file mode 100644 index 754fea7..0000000 --- a/app/src/main/java/com/termux/gui/protocol/v0/GUIRecyclerViewAdapter.kt +++ /dev/null @@ -1,104 +0,0 @@ -package com.termux.gui.protocol.v0 - -import android.annotation.SuppressLint -import android.view.View -import android.view.ViewGroup -import android.widget.FrameLayout -import androidx.recyclerview.widget.RecyclerView -import androidx.recyclerview.widget.SortedList -import com.termux.gui.GUIActivity -import java.io.Serializable -import java.util.* -import kotlin.collections.HashMap - -class GUIRecyclerViewAdapter(private val a: GUIActivity) : RecyclerView.Adapter() { - class GUIViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) - class ViewData(val index: Int, val id: Int, @Transient var v: View) : Serializable - - - - - private val views = SortedList(ViewData::class.java, object: SortedList.Callback() { - override fun compare(o1: ViewData?, o2: ViewData?): Int { - if (o1 == null || o2 == null) { - return 0 - } - return o1.index - o2.index - } - override fun onInserted(position: Int, count: Int) { - notifyItemRangeInserted(position, count) - } - override fun onRemoved(position: Int, count: Int) { - notifyItemRangeRemoved(position, count) - } - override fun onMoved(fromPosition: Int, toPosition: Int) { - notifyItemMoved(fromPosition, toPosition) - } - override fun onChanged(position: Int, count: Int) { - notifyItemRangeChanged(position, count) - } - override fun areContentsTheSame(oldItem: ViewData?, newItem: ViewData?): Boolean { - return areItemsTheSame(oldItem, newItem) - } - override fun areItemsTheSame(item1: ViewData?, item2: ViewData?): Boolean { - if (item1 == null || item2 == null) { - return false - } - return item1.index == item2.index - } - }) - - @SuppressLint("NotifyDataSetChanged") - fun clearViews() { - views.clear() - notifyDataSetChanged() - } - - - fun getViewByIndex(index: Int) : ViewData? { - return try { - views.get(index) - } catch (e: ArrayIndexOutOfBoundsException) { - null - } - } - - fun setViewByIndex(index: Int, v: View) { - val vd = views.get(index) - if (vd != null) { - vd.v = v - notifyItemChanged(index) - } else { - val newvd = ViewData(index, v.id, v) - views.add(newvd) - notifyItemChanged(newvd.index) - } - } - - - fun exportViewList(): LinkedList { - val l = LinkedList() - return l - } - - fun importViewList(l: LinkedList) { - clearViews() - val sorted = l.sortedBy { it.index } - views.addAll(sorted) - } - - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GUIViewHolder { - return GUIViewHolder(FrameLayout(a)) - } - - override fun onBindViewHolder(holder: GUIViewHolder, position: Int) { - val f = holder.itemView as FrameLayout - f.removeAllViews() - f.addView(views[position].v) - } - - override fun getItemCount(): Int { - return views.size() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/termux/gui/protocol/v0/HandleBuffer.kt b/app/src/main/java/com/termux/gui/protocol/v0/HandleBuffer.kt index 2a07e13..7c5c134 100644 --- a/app/src/main/java/com/termux/gui/protocol/v0/HandleBuffer.kt +++ b/app/src/main/java/com/termux/gui/protocol/v0/HandleBuffer.kt @@ -135,12 +135,12 @@ class HandleBuffer { if (buffer != null && id != null) { if (a != null) { V0.runOnUIThreadActivityStarted(a) { - it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.setImageBitmap(buffer.btm) + it.findViewReimplemented(id)?.setImageBitmap(buffer.btm) } } if (o != null) { Util.runOnUIThreadBlocking { - o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.setImageBitmap(buffer.btm) + o.root.findViewReimplemented(id)?.setImageBitmap(buffer.btm) } } } @@ -154,12 +154,12 @@ class HandleBuffer { if (id != null) { if (a != null) { V0.runOnUIThreadActivityStarted(a) { - it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.invalidate() + it.findViewReimplemented(id)?.invalidate() } } if (o != null) { Util.runOnUIThreadBlocking { - o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.invalidate() + o.root.findViewReimplemented(id)?.invalidate() } } } diff --git a/app/src/main/java/com/termux/gui/protocol/v0/HandleView.kt b/app/src/main/java/com/termux/gui/protocol/v0/HandleView.kt index b23c3f4..d92ae96 100644 --- a/app/src/main/java/com/termux/gui/protocol/v0/HandleView.kt +++ b/app/src/main/java/com/termux/gui/protocol/v0/HandleView.kt @@ -43,12 +43,12 @@ class HandleView { val o = overlays[aid] if (a != null && id != null) { V0.runOnUIThreadActivityStarted(a) { - it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.isCursorVisible = show + it.findViewReimplemented(id)?.isCursorVisible = show } } if (o != null && id != null) { Util.runOnUIThreadBlocking { - o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.isCursorVisible = show + o.root.findViewReimplemented(id)?.isCursorVisible = show } } return true @@ -61,12 +61,12 @@ class HandleView { if (a != null && id != null) { V0.runOnUIThreadActivityStarted(a) { - Util.removeViewRecursive(it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt), it.usedIds, it.recyclerviews) + Util.removeViewRecursive(it.findViewReimplemented(id), it.usedIds) } } if (o != null && id != null) { Util.runOnUIThreadBlocking { - Util.removeViewRecursive(o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt), o.usedIds, o.recyclerviews) + Util.removeViewRecursive(o.root.findViewReimplemented(id), o.usedIds) } } return true @@ -78,20 +78,20 @@ class HandleView { val o = overlays[aid] if (a != null && id != null) { V0.runOnUIThreadActivityStarted(a) { - val v = it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = it.findViewReimplemented(id) if (v != null) { while (v.childCount > 0) { - Util.removeViewRecursive(v.getChildAt(0), it.usedIds, it.recyclerviews) + Util.removeViewRecursive(v.getChildAt(0), it.usedIds) } } } } if (o != null && id != null) { Util.runOnUIThreadBlocking { - val v = o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = o.root.findViewReimplemented(id) if (v != null) { while (v.childCount > 0) { - Util.removeViewRecursive(v.getChildAt(0), o.usedIds, o.recyclerviews) + Util.removeViewRecursive(v.getChildAt(0), o.usedIds) } } } @@ -108,13 +108,13 @@ class HandleView { if (id != null && size != null && size > 0) { if (a != null) { V0.runOnUIThreadActivityStarted(a) { - val tv = it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val tv = it.findViewReimplemented(id) tv?.setTextSize(TypedValue.COMPLEX_UNIT_SP, size.toFloat()) } } if (o != null) { Util.runOnUIThreadBlocking { - o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.setTextSize(TypedValue.COMPLEX_UNIT_SP, size.toFloat()) + o.root.findViewReimplemented(id)?.setTextSize(TypedValue.COMPLEX_UNIT_SP, size.toFloat()) } } } @@ -132,14 +132,14 @@ class HandleView { V0.runOnUIThreadActivityStarted(a) { val bin = Base64.decode(img, Base64.DEFAULT) val bitmap = BitmapFactory.decodeByteArray(bin, 0, bin.size) - it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.setImageBitmap(bitmap) + it.findViewReimplemented(id)?.setImageBitmap(bitmap) } } if (o != null) { val bin = Base64.decode(img, Base64.DEFAULT) val bitmap = BitmapFactory.decodeByteArray(bin, 0, bin.size) Util.runOnUIThreadBlocking { - o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.setImageBitmap(bitmap) + o.root.findViewReimplemented(id)?.setImageBitmap(bitmap) } } } @@ -156,7 +156,7 @@ class HandleView { if (a != null) { V0.runOnUIThreadActivityStarted(a) { val mar = Util.toPX(it, margin) - val v = it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = it.findViewReimplemented(id) val p = v?.layoutParams as? ViewGroup.MarginLayoutParams when (m.params?.get("dir")?.asString) { "top" -> p?.topMargin = mar @@ -171,7 +171,7 @@ class HandleView { if (o != null) { Util.runOnUIThreadBlocking { val mar = Util.toPX(app, margin) - val v = o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = o.root.findViewReimplemented(id) val p = v?.layoutParams as? ViewGroup.MarginLayoutParams when (m.params?.get("dir")?.asString) { "top" -> p?.topMargin = mar @@ -196,7 +196,7 @@ class HandleView { if (id != null && weight != null) { if (a != null) { V0.runOnUIThreadActivityStarted(a) { - val v = it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = it.findViewReimplemented(id) val p = v?.layoutParams as? LinearLayout.LayoutParams if (p != null) { p.weight = weight.toFloat() @@ -206,7 +206,7 @@ class HandleView { } if (o != null) { Util.runOnUIThreadBlocking { - val v = o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = o.root.findViewReimplemented(id) val p = v?.layoutParams as? LinearLayout.LayoutParams if (p != null) { p.weight = weight.toFloat() @@ -234,7 +234,7 @@ class HandleView { if (id != null) { if (a != null) { V0.runOnUIThreadActivityStarted(a) { - val v = it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = it.findViewReimplemented(id) if (v != null) { Util.sendMessage(out, ConnectionHandler.gson.toJson(arrayOf(v.width, v.height))) } else { @@ -244,7 +244,7 @@ class HandleView { } if (o != null) { Util.runOnUIThreadBlocking { - val v = o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = o.root.findViewReimplemented(id) if (v != null) { Util.sendMessage(out, ConnectionHandler.gson.toJson(arrayOf(v.width, v.height))) } else { @@ -266,13 +266,13 @@ class HandleView { if (id != null) { if (a != null) { V0.runOnUIThreadActivityStarted(a) { - val tv = it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val tv = it.findViewReimplemented(id) tv?.text = text } } if (o != null) { Util.runOnUIThreadBlocking { - o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.text = text + o.root.findViewReimplemented(id)?.text = text } } } @@ -289,12 +289,12 @@ class HandleView { if (id != null && color != null) { if (a != null) { V0.runOnUIThreadActivityStarted(a) { - it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.backgroundTintList = ColorStateList.valueOf(color) + it.findViewReimplemented(id)?.backgroundTintList = ColorStateList.valueOf(color) } } if (o != null) { Util.runOnUIThreadBlocking { - o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.backgroundTintList = ColorStateList.valueOf(color) + o.root.findViewReimplemented(id)?.backgroundTintList = ColorStateList.valueOf(color) } } } @@ -311,12 +311,12 @@ class HandleView { if (id != null && color != null) { if (a != null) { V0.runOnUIThreadActivityStarted(a) { - it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.setTextColor(color) + it.findViewReimplemented(id)?.setTextColor(color) } } if (o != null) { Util.runOnUIThreadBlocking { - o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.setTextColor(color) + o.root.findViewReimplemented(id)?.setTextColor(color) } } } @@ -333,12 +333,12 @@ class HandleView { if (id != null && progress != null) { if (a != null) { V0.runOnUIThreadActivityStarted(a) { - it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.progress = progress + it.findViewReimplemented(id)?.progress = progress } } if (o != null) { Util.runOnUIThreadBlocking { - o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.progress = progress + o.root.findViewReimplemented(id)?.progress = progress } } } @@ -355,12 +355,12 @@ class HandleView { if (id != null && refresh != null) { if (a != null) { V0.runOnUIThreadActivityStarted(a) { - it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.isRefreshing = refresh + it.findViewReimplemented(id)?.isRefreshing = refresh } } if (o != null) { Util.runOnUIThreadBlocking { - o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.isRefreshing = refresh + o.root.findViewReimplemented(id)?.isRefreshing = refresh } } } @@ -377,12 +377,12 @@ class HandleView { if (id != null) { if (a != null) { V0.runOnUIThreadActivityStartedBlocking(a) { - text = it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.text?.toString() + text = it.findViewReimplemented(id)?.text?.toString() } } if (o != null) { Util.runOnUIThreadBlocking { - text = o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.text?.toString() + text = o.root.findViewReimplemented(id)?.text?.toString() } } } @@ -401,12 +401,12 @@ class HandleView { if (id != null) { if (a != null) { V0.runOnUIThreadActivityStarted(a) { - it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.isChecked = m.params?.get("checked")?.asBoolean ?: false + it.findViewReimplemented(id)?.isChecked = m.params?.get("checked")?.asBoolean ?: false } } if (o != null) { Util.runOnUIThreadBlocking { - o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.isChecked = m.params?.get("checked")?.asBoolean ?: false + o.root.findViewReimplemented(id)?.isChecked = m.params?.get("checked")?.asBoolean ?: false } } } @@ -422,7 +422,7 @@ class HandleView { if (id != null) { if (a != null) { V0.runOnUIThreadActivityStarted(a) { - val v = it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = it.findViewReimplemented(id) if (v != null) { v.requestFocus() if (m.params?.get("forcesoft")?.asBoolean == true) { @@ -434,7 +434,7 @@ class HandleView { } if (o != null) { Util.runOnUIThreadBlocking { - val v = o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = o.root.findViewReimplemented(id) if (v != null) { v.requestFocus() if (m.params?.get("forcesoft")?.asBoolean == true) { @@ -460,7 +460,7 @@ class HandleView { if (id != null && x != null && y != null) { if (a != null) { V0.runOnUIThreadActivityStarted(a) { - val v = it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = it.findViewReimplemented(id) if (v is NestedScrollView || v is HorizontalScrollView) { if (soft == true && v is NestedScrollView) { v.smoothScrollTo(x, y) @@ -472,7 +472,7 @@ class HandleView { } if (o != null) { Util.runOnUIThreadBlocking { - val v = o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = o.root.findViewReimplemented(id) if (v is NestedScrollView || v is HorizontalScrollView) { if (soft == true && v is NestedScrollView) { v.smoothScrollTo(x, y) @@ -495,7 +495,7 @@ class HandleView { if (id != null) { if (a != null) { V0.runOnUIThreadActivityStarted(a) { - val v = it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = it.findViewReimplemented(id) if (v is NestedScrollView || v is HorizontalScrollView) { Util.sendMessage(out, ConnectionHandler.gson.toJson(arrayOf(v.scrollX, v.scrollY))) } else { @@ -505,7 +505,7 @@ class HandleView { } if (o != null) { Util.runOnUIThreadBlocking { - val v = o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = o.root.findViewReimplemented(id) if (v is NestedScrollView || v is HorizontalScrollView) { Util.sendMessage(out, ConnectionHandler.gson.toJson(arrayOf(v.scrollX, v.scrollY))) } else { @@ -539,11 +539,11 @@ class HandleView { if (id != null) { if (a != null) { V0.runOnUIThreadActivityStartedBlocking(a) { - val v = it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = it.findViewReimplemented(id) if (v is Spinner) v.adapter = ArrayAdapter(it, R.layout.spinner_text, options) if (v is TabLayout) { - v.removeAllTabs(); + v.removeAllTabs() for (tab in options) { val t = v.newTab() t.text = tab @@ -554,11 +554,11 @@ class HandleView { } if (o != null) { Util.runOnUIThreadBlocking { - val v = o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = o.root.findViewReimplemented(id) if (v is Spinner) v.adapter = ArrayAdapter(app, R.layout.spinner_text, options) if (v is TabLayout) { - v.removeAllTabs(); + v.removeAllTabs() for (tab in options) { val t = TabLayout.Tab() t.text = tab @@ -581,7 +581,7 @@ class HandleView { if (id != null && vis != null && vis >= 0 && vis <= 2) { if (a != null) { V0.runOnUIThreadActivityStarted(a) { - it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.visibility = when (vis) { + it.findViewReimplemented(id)?.visibility = when (vis) { 0 -> View.GONE 1 -> View.INVISIBLE 2 -> View.VISIBLE @@ -591,7 +591,7 @@ class HandleView { } if (o != null) { Util.runOnUIThreadBlocking { - o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.visibility = when (vis) { + o.root.findViewReimplemented(id)?.visibility = when (vis) { 0 -> View.GONE 1 -> View.INVISIBLE 2 -> View.VISIBLE @@ -645,7 +645,7 @@ class HandleView { val p = el.asJsonPrimitive if (a != null) { V0.runOnUIThreadActivityStarted(a) { - val v = it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = it.findViewReimplemented(id) val pa = v?.layoutParams if (pa != null) { set(pa, p) @@ -655,7 +655,7 @@ class HandleView { } if (o != null) { Util.runOnUIThreadBlocking { - val v = o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt) + val v = o.root.findViewReimplemented(id) val pa = v?.layoutParams if (pa != null) { set(pa, p) diff --git a/app/src/main/java/com/termux/gui/protocol/v0/LifecycleListener.kt b/app/src/main/java/com/termux/gui/protocol/v0/LifecycleListener.kt index eb18505..8bf1398 100644 --- a/app/src/main/java/com/termux/gui/protocol/v0/LifecycleListener.kt +++ b/app/src/main/java/com/termux/gui/protocol/v0/LifecycleListener.kt @@ -13,14 +13,14 @@ import java.util.concurrent.LinkedBlockingQueue class LifecycleListener(private val eventQueue: LinkedBlockingQueue, private val activities: MutableMap, private val tasks: LinkedList, private val am: ActivityManager) : Application.ActivityLifecycleCallbacks { override fun onActivityCreated(a: Activity, savedInstanceState: Bundle?) { - println("create") + //println("create") if (a is GUIActivity) { val f = activities[a.intent?.dataString] if (f != null) { if (tasks.find { Util.getTaskInfo(tasks, it)?.let { it1 -> Util.getTaskId(it1) } == a.taskId } == null) { for (t in am.appTasks) { if (Util.getTaskInfo(tasks, t)?.let { it1 -> Util.getTaskId(it1) } == a.taskId) { - println("task added") + //println("task added") tasks.add(t) break } @@ -36,13 +36,13 @@ class LifecycleListener(private val eventQueue: LinkedBlockingQueue Unit> = LinkedBlockingQueue<(activity: GUIActivity) -> Unit>(100)) data class Overlay(val context: Context) { val usedIds: TreeSet = TreeSet() - val recyclerviews = HashMap() var theme: GUIActivity.GUITheme? = null var sendTouch = false val root = OverlayView(context) @@ -66,17 +64,7 @@ class V0(val app: Context) { } @Suppress("UNCHECKED_CAST") - fun findViewReimplemented(id: Int, recid: Int?, recindex: Int?) : T? { - if (recid != null && recindex != null) { - val rec = recyclerviews[recid] - if (rec != null) { - val el = rec.getViewByIndex(recindex) - if (el != null) { - return el.v.findViewById(id) as? T - } - } - return null - } + fun findViewReimplemented(id: Int) : T? { return findViewById(id) } } @@ -191,60 +179,60 @@ class V0(val app: Context) { if (m.method == "sendTouchEvent") { if (a != null) { runOnUIThreadActivityStarted(a) { - it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.let { Util.setTouchListener(it, aid, send, eventQueue) } + it.findViewReimplemented(id)?.let { Util.setTouchListener(it, aid, send, eventQueue) } } } if (o != null) { runOnUIThreadBlocking { - o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.let { Util.setTouchListener(it, aid, send, eventQueue) } + o.root.findViewReimplemented(id)?.let { Util.setTouchListener(it, aid, send, eventQueue) } } } } if (m.method == "sendFocusChangeEvent") { if (a != null) { runOnUIThreadActivityStarted(a) { - it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.let { Util.setFocusChangeListener(it, aid, send, eventQueue) } + it.findViewReimplemented(id)?.let { Util.setFocusChangeListener(it, aid, send, eventQueue) } } } if (o != null) { runOnUIThreadBlocking { - o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.let { Util.setFocusChangeListener(it, aid, send, eventQueue) } + o.root.findViewReimplemented(id)?.let { Util.setFocusChangeListener(it, aid, send, eventQueue) } } } } if (m.method == "sendLongClickEvent") { if (a != null) { runOnUIThreadActivityStarted(a) { - it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.let { Util.setLongClickListener(it, aid, send, eventQueue) } + it.findViewReimplemented(id)?.let { Util.setLongClickListener(it, aid, send, eventQueue) } } } if (o != null) { runOnUIThreadBlocking { - o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.let { Util.setLongClickListener(it, aid, send, eventQueue) } + o.root.findViewReimplemented(id)?.let { Util.setLongClickListener(it, aid, send, eventQueue) } } } } if (m.method == "sendClickEvent") { if (a != null) { runOnUIThreadActivityStarted(a) { - it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.let { Util.setClickListener(it, aid, send, eventQueue) } + it.findViewReimplemented(id)?.let { Util.setClickListener(it, aid, send, eventQueue) } } } if (o != null) { runOnUIThreadBlocking { - o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.let { Util.setClickListener(it, aid, send, eventQueue) } + o.root.findViewReimplemented(id)?.let { Util.setClickListener(it, aid, send, eventQueue) } } } } if (m.method == "sendTextEvent") { if (a != null) { runOnUIThreadActivityStarted(a) { - it.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.let {Util.setTextWatcher(it, aid, send, eventQueue)} + it.findViewReimplemented(id)?.let {Util.setTextWatcher(it, aid, send, eventQueue)} } } if (o != null) { runOnUIThreadBlocking { - o.root.findViewReimplemented(id, m.params?.get("recyclerview")?.asInt, m.params?.get("recyclerindex")?.asInt)?.let {Util.setTextWatcher(it, aid, send, eventQueue)} + o.root.findViewReimplemented(id)?.let {Util.setTextWatcher(it, aid, send, eventQueue)} } } } @@ -452,7 +440,7 @@ class V0(val app: Context) { } } companion object { - fun setViewOverlay(o: Overlay, v: View, parent: Int?, recid: Int?, recindex: Int?) { + fun setViewOverlay(o: Overlay, v: View, parent: Int?) { val t = o.theme if (v is TextView) { if (t != null) { @@ -473,7 +461,7 @@ class V0(val app: Context) { println("adding view") fl.addView(v) } else { - val g = o.root.findViewReimplemented(parent, recid, recindex) + val g = o.root.findViewReimplemented(parent) if (g is LinearLayout) { val p = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1F) if (g.orientation == LinearLayout.VERTICAL) {