You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-android/src/org/thoughtcrime/securesms/loki/DeviceLinkingDialog.kt

33 lines
1.2 KiB
Kotlin

package org.thoughtcrime.securesms.loki
import android.content.Context
import android.graphics.Color
import android.graphics.PorterDuff
import android.support.v7.app.AlertDialog
import android.util.AttributeSet
import android.widget.LinearLayout
import kotlinx.android.synthetic.main.view_device_linking.view.*
import kotlinx.android.synthetic.main.view_qr_code.view.cancelButton
import network.loki.messenger.R
object DeviceLinkingDialog {
fun show(context: Context) {
val view = DeviceLinkingView(context)
val dialog = AlertDialog.Builder(context).setView(view).show()
view.onCancel = { dialog.dismiss() }
}
}
class DeviceLinkingView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : LinearLayout(context, attrs, defStyleAttr) {
var onCancel: (() -> Unit)? = null
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
constructor(context: Context) : this(context, null)
init {
inflate(context, R.layout.view_device_linking, this)
spinner.indeterminateDrawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN)
cancelButton.setOnClickListener { onCancel?.invoke() }
}
}