Deprecate reset credentials
Due to persistent groups no longer useful in Android Q, this feature will be removed. Users on older releases can remove remembered groups from Wi-Fi Direct settings manually.
This commit is contained in:
@@ -95,18 +95,6 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
|
||||
fun shutdown() {
|
||||
if (active) removeGroup()
|
||||
}
|
||||
|
||||
fun resetCredentials() {
|
||||
val channel = channel
|
||||
if (channel == null) SmartSnackbar.make(R.string.repeater_failure_disconnected).show()
|
||||
else p2pManager.deletePersistentGroup(channel, (group ?: return).netId,
|
||||
object : WifiP2pManager.ActionListener {
|
||||
override fun onSuccess() = SmartSnackbar.make(R.string.repeater_reset_credentials_success)
|
||||
.shortToast().show()
|
||||
override fun onFailure(reason: Int) = SmartSnackbar.make(
|
||||
formatReason(R.string.repeater_reset_credentials_failure, reason)).show()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private val p2pManager get() = RepeaterService.p2pManager!!
|
||||
|
||||
@@ -168,18 +168,15 @@ class RepeaterManager(private val parent: TetheringFragment) : Manager(), Servic
|
||||
}
|
||||
}
|
||||
|
||||
fun onEditResult(which: Int, data: Intent?) {
|
||||
when (which) {
|
||||
DialogInterface.BUTTON_POSITIVE -> try {
|
||||
val master = holder.config ?: return
|
||||
val config = AlertDialogFragment.getRet<WifiP2pDialogFragment.Arg>(data!!).configuration
|
||||
master.update(config.SSID, config.preSharedKey)
|
||||
binder!!.group = null
|
||||
} catch (e: Exception) {
|
||||
Timber.w(e)
|
||||
SmartSnackbar.make(e).show()
|
||||
}
|
||||
DialogInterface.BUTTON_NEUTRAL -> binder!!.resetCredentials()
|
||||
fun onEditResult(data: Intent?) {
|
||||
val master = holder.config ?: return
|
||||
try {
|
||||
val config = AlertDialogFragment.getRet<WifiP2pDialogFragment.Arg>(data!!).configuration
|
||||
master.update(config.SSID, config.preSharedKey)
|
||||
binder!!.group = null
|
||||
} catch (e: Exception) {
|
||||
Timber.w(e)
|
||||
SmartSnackbar.make(e).show()
|
||||
}
|
||||
holder.config = null
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ class TetheringFragment : Fragment(), ServiceConnection, MenuItem.OnMenuItemClic
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) = when (requestCode) {
|
||||
REPEATER_WPS -> adapter.repeaterManager.onWpsResult(resultCode, data)
|
||||
REPEATER_EDIT_CONFIGURATION -> adapter.repeaterManager.onEditResult(resultCode, data)
|
||||
REPEATER_EDIT_CONFIGURATION -> adapter.repeaterManager.onEditResult(data)
|
||||
else -> super.onActivityResult(requestCode, resultCode, data)
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,6 @@ class WifiP2pDialogFragment : AlertDialogFragment<WifiP2pDialogFragment.Arg, Wif
|
||||
mPassword = mView.password
|
||||
setPositiveButton(context.getString(R.string.wifi_save), listener)
|
||||
setNegativeButton(context.getString(R.string.wifi_cancel), null)
|
||||
setNeutralButton(context.getString(R.string.repeater_reset_credentials), listener)
|
||||
mSsid.text = arg.configuration.SSID
|
||||
mSsid.addTextChangedListener(this@WifiP2pDialogFragment)
|
||||
mPassword.setText(arg.configuration.preSharedKey)
|
||||
|
||||
@@ -14,9 +14,6 @@
|
||||
<string name="repeater_wps_failure">打开 WPS 失败(原因:%s)</string>
|
||||
<string name="repeater_configure">设置 WLAN 中继</string>
|
||||
<string name="repeater_configure_failure">未能找到有效的档案。请尝试先打开中继。</string>
|
||||
<string name="repeater_reset_credentials">重置</string>
|
||||
<string name="repeater_reset_credentials_success">凭据已重置。</string>
|
||||
<string name="repeater_reset_credentials_failure">重置凭据失败(原因:%s)</string>
|
||||
<string name="repeater_clean_pog_failure">删除多余 P2P 群组失败(原因:%s)</string>
|
||||
|
||||
<string name="repeater_p2p_unavailable">Wi\u2011Fi 直连不可用,请打开 Wi\u2011Fi</string>
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
<string name="repeater_wps_failure">Failed to start WPS (reason: %s)</string>
|
||||
<string name="repeater_configure">Configure Wi\u2011Fi repeater</string>
|
||||
<string name="repeater_configure_failure">Valid config not found. Please start repeater first.</string>
|
||||
<string name="repeater_reset_credentials">Reset</string>
|
||||
<string name="repeater_reset_credentials_success">Credentials reset.</string>
|
||||
<string name="repeater_reset_credentials_failure">Failed to reset credentials (reason: %s)</string>
|
||||
<string name="repeater_clean_pog_failure">Failed to remove redundant P2P group (reason: %s)</string>
|
||||
|
||||
<string name="repeater_p2p_unavailable">Wi\u2011Fi direct unavailable, please enable Wi\u2011Fi</string>
|
||||
|
||||
Reference in New Issue
Block a user