Fix #74
This commit is contained in:
@@ -7,6 +7,7 @@ import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatDialogFragment
|
||||
import androidx.fragment.app.Fragment
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
/**
|
||||
@@ -38,6 +39,11 @@ abstract class AlertDialogFragment<Arg : Parcelable, Ret : Parcelable> :
|
||||
super.onDismiss(dialog)
|
||||
targetFragment?.onActivityResult(targetRequestCode, Activity.RESULT_CANCELED, null)
|
||||
}
|
||||
|
||||
fun show(target: Fragment, requestCode: Int = 0, tag: String = javaClass.simpleName) {
|
||||
setTargetFragment(target, requestCode)
|
||||
show(target.fragmentManager ?: return, tag)
|
||||
}
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
|
||||
@@ -132,7 +132,7 @@ class ClientsFragment : Fragment(), MainScope by MainScope.Supervisor() {
|
||||
R.id.nickname -> {
|
||||
val client = binding.client ?: return false
|
||||
NicknameDialogFragment().withArg(NicknameArg(client.mac, client.nickname))
|
||||
.show(fragmentManager ?: return false, "NicknameDialogFragment")
|
||||
.show(this@ClientsFragment)
|
||||
true
|
||||
}
|
||||
R.id.block, R.id.unblock -> {
|
||||
@@ -151,9 +151,10 @@ class ClientsFragment : Fragment(), MainScope by MainScope.Supervisor() {
|
||||
R.id.stats -> {
|
||||
binding.client?.let { client ->
|
||||
launch(start = CoroutineStart.UNDISPATCHED) {
|
||||
StatsDialogFragment().withArg(StatsArg(client.title.value ?: return@launch,
|
||||
AppDatabase.instance.trafficRecordDao.queryStats(client.mac)))
|
||||
.show(fragmentManager ?: return@launch, "StatsDialogFragment")
|
||||
StatsDialogFragment().withArg(StatsArg(
|
||||
client.title.value ?: return@launch,
|
||||
AppDatabase.instance.trafficRecordDao.queryStats(client.mac)
|
||||
)).show(this@ClientsFragment)
|
||||
}
|
||||
}
|
||||
true
|
||||
|
||||
@@ -90,10 +90,7 @@ class RepeaterManager(private val parent: TetheringFragment) : Manager(), Servic
|
||||
}
|
||||
|
||||
fun wps() {
|
||||
if (binder?.active == true) WpsDialogFragment().run {
|
||||
setTargetFragment(parent, TetheringFragment.REPEATER_WPS)
|
||||
show(parent.fragmentManager ?: return, "WpsDialogFragment")
|
||||
}
|
||||
if (binder?.active == true) WpsDialogFragment().show(parent, TetheringFragment.REPEATER_WPS)
|
||||
}
|
||||
|
||||
fun editConfigurations() {
|
||||
@@ -104,7 +101,7 @@ class RepeaterManager(private val parent: TetheringFragment) : Manager(), Servic
|
||||
WifiP2pDialogFragment().withArg(WifiP2pDialogFragment.Arg(WifiConfiguration().apply {
|
||||
SSID = group.networkName
|
||||
preSharedKey = config.psk
|
||||
})).show(parent.fragmentManager ?: return, "WifiP2pDialogFragment")
|
||||
})).show(parent, TetheringFragment.REPEATER_EDIT_CONFIGURATION)
|
||||
return
|
||||
} catch (e: RuntimeException) {
|
||||
Timber.w(e)
|
||||
|
||||
Reference in New Issue
Block a user