Mercurial > dwindows
diff android/DWindows.kt @ 2722:cacde852e2db
Android: Add dialog dismiss and color change handlers to the color chooser.
dw_color_choose() now blocks and waits for the user to pick a color....
previously it opened the dialog and returned the original color.
Probably need to add a GradientBar for the brightness... maybe some
buttons to apply or cancel, but for now the Android < button closes it.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 09 Dec 2021 11:52:59 +0000 |
parents | 9ce1649b0fbd |
children | bf585f375286 |
line wrap: on
line diff
--- a/android/DWindows.kt Thu Dec 09 04:52:01 2021 +0000 +++ b/android/DWindows.kt Thu Dec 09 11:52:59 2021 +0000 @@ -66,6 +66,10 @@ import kotlin.math.* import android.content.ContentUris import androidx.appcompat.widget.AppCompatSeekBar +import android.content.DialogInterface + + + // Color Wheel section @@ -1685,6 +1689,9 @@ private var fileURI: Uri? = null private var fileLock = ReentrantLock() private var fileCond = fileLock.newCondition() + private var colorLock = ReentrantLock() + private var colorCond = colorLock.newCondition() + private var colorChosen: Int = 0 // Lists of data for our Windows private var windowTitles = mutableListOf<String?>() private var windowMenuBars = mutableListOf<DWMenu?>() @@ -5247,19 +5254,29 @@ // This can't be called from the main thread if(Looper.getMainLooper() != Looper.myLooper()) { + colorLock.lock() waitOnUiThread { val dialog = Dialog(this) val colorWheel = ColorWheel(this, null, 0) dialog.setContentView(colorWheel) colorWheel.rgb = Color.rgb(red, green, blue) + colorChosen = colorWheel.rgb + colorWheel.colorChangeListener = { rgb: Int -> colorChosen = rgb } dialog.window?.setLayout( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ) + dialog.setOnDismissListener { + colorLock.lock() + colorCond.signal() + colorLock.unlock() + } dialog.show() - retval = colorWheel.rgb } + colorCond.await() + retval = colorChosen + colorLock.unlock() } return retval }