Auto-complete interface names
This commit is contained in:
@@ -11,7 +11,9 @@ import android.support.customtabs.CustomTabsIntent
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v4.content.LocalBroadcastManager
|
||||
import android.support.v7.preference.Preference
|
||||
import be.mygod.vpnhotspot.preference.AlwaysAutoCompleteEditTextPreferenceDialogFragmentCompat
|
||||
import com.takisoft.fix.support.v7.preference.PreferenceFragmentCompatDividers
|
||||
import java.net.NetworkInterface
|
||||
|
||||
class SettingsFragment : PreferenceFragmentCompatDividers(), ServiceConnection {
|
||||
private lateinit var service: Preference
|
||||
@@ -51,6 +53,16 @@ class SettingsFragment : PreferenceFragmentCompatDividers(), ServiceConnection {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDisplayPreferenceDialog(preference: Preference) = when (preference.key) {
|
||||
HotspotService.KEY_UPSTREAM -> displayPreferenceDialog(
|
||||
AlwaysAutoCompleteEditTextPreferenceDialogFragmentCompat(), HotspotService.KEY_UPSTREAM,
|
||||
Bundle().put(AlwaysAutoCompleteEditTextPreferenceDialogFragmentCompat.KEY_SUGGESTIONS,
|
||||
NetworkInterface.getNetworkInterfaces().asSequence()
|
||||
.filter { it.isUp && !it.isLoopback && it.interfaceAddresses.isNotEmpty() }
|
||||
.map { it.name }.toList().toTypedArray()))
|
||||
else -> super.onDisplayPreferenceDialog(preference)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
val activity = activity!!
|
||||
|
||||
Reference in New Issue
Block a user