android-usb-script icon indicating copy to clipboard operation
android-usb-script copied to clipboard

Adding a selection dialog

Open C-512L opened this issue 1 year ago • 3 comments

I am writting a Multi-ISO boot script and one thing I found missing is the ability to call from lua to open a selection dialog with options passed by lua. The code i conceptualize in lua could look something like this:

...
-- a, b and c would be an integer representing the selected option in the array or nil
local a,b,c = select {
  message = "Please select an option",
    -- maybe throw an error if it is empty?
  select_opts = { 
     [1] = "A Text",
     [2] = "B Text",
     [3] = "C Text".
  },
  multiple = true -- false by default
}
...
-- Possible code used later on
luausb.create({
  type = "storage"
  file = boot_entries[a].path
})

I have dived into the Java/Kotlin side of the code a little so If I have spare time, I might even try to make a PR implementing it.

C-512L avatar Aug 23 '24 12:08 C-512L

That looks like a reasonable addition to me, if you're interested in implementing this feel free to submit a PR. Otherwise, I could implement it myself.

Netdex avatar Aug 24 '24 00:08 Netdex

That looks like a reasonable addition to me, if you're interested in implementing this feel free to submit a PR. Otherwise, I could implement it myself.

I see the project uses both Kotlin and Java in a lot of places. Are there any contributing guidelines for the project on whether certain functionality should be written on Java or Kotlin?

C-512L avatar Aug 24 '24 11:08 C-512L

The Kotlin is a fairly recent addition, in general I have been writing new code in Kotlin and slowly rewriting the Java into Kotlin. The exception is classes which are directly exposed to the lua interface using CoerceJavaToLua, because LuaJ doesn't support Kotlin. These classes are contained under org.netdex.androidusbscript.lua and have a special Proguard rule to avoid scrambling names.

Netdex avatar Aug 24 '24 12:08 Netdex