package jp.juggler.subwaytooter.dialog import android.annotation.SuppressLint import android.app.AlertDialog import android.app.Dialog import android.view.Gravity import android.view.View import android.view.WindowManager import android.widget.Button import android.widget.EditText import jp.juggler.subwaytooter.* import jp.juggler.subwaytooter.api.entity.TootVisibility import jp.juggler.subwaytooter.pref.PrefS import jp.juggler.subwaytooter.pref.put import jp.juggler.util.ui.dismissSafe import java.lang.ref.WeakReference class DlgQuickTootMenu( internal val activity: ActMain, internal val callback: Callback, ) : View.OnClickListener { companion object { val etTextIds = intArrayOf( R.id.etText0, R.id.etText1, R.id.etText2, R.id.etText3, R.id.etText4, R.id.etText5 ) val btnTextIds = intArrayOf( R.id.btnText0, R.id.btnText1, R.id.btnText2, R.id.btnText3, R.id.btnText4, R.id.btnText5 ) val visibilityList = arrayOf( TootVisibility.AccountSetting, TootVisibility.WebSetting, TootVisibility.Public, TootVisibility.UnlistedHome, TootVisibility.PrivateFollowers, TootVisibility.DirectSpecified ) } interface Callback { fun onMacro(text: String) var visibility: TootVisibility } private var refDialog: WeakReference? = null fun toggle() { val dialog = refDialog?.get() if (dialog != null && dialog.isShowing) { dialog.dismissSafe() } else { show() } } private val etText = arrayOfNulls(6) private lateinit var btnVisibility: Button @SuppressLint("InflateParams") fun show() { val view = activity.layoutInflater.inflate(R.layout.dlg_quick_toot_menu, null, false) view.findViewById