This commit is contained in:
Mygod
2018-06-10 21:35:27 +08:00
parent d68932f72b
commit 3fbca0abef
4 changed files with 11 additions and 8 deletions

View File

@@ -7,6 +7,8 @@ import android.content.ComponentName
import android.content.Intent
import android.content.ServiceConnection
import android.content.pm.PackageManager
import android.location.LocationManager
import android.os.Build
import android.os.IBinder
import android.provider.Settings
import android.support.v7.widget.RecyclerView
@@ -46,8 +48,10 @@ class LocalOnlyHotspotManager(private val parent: TetheringFragment) : Manager()
* https://android.googlesource.com/platform/frameworks/opt/net/wifi/+/53e0284/service/java/com/android/server/wifi/WifiServiceImpl.java#1204
* https://android.googlesource.com/platform/frameworks/opt/net/wifi/+/53e0284/service/java/com/android/server/wifi/WifiSettingsStore.java#228
*/
if (Settings.Secure.getInt(view.context.contentResolver, Settings.Secure.LOCATION_MODE,
Settings.Secure.LOCATION_MODE_OFF) == Settings.Secure.LOCATION_MODE_OFF) {
if (if (Build.VERSION.SDK_INT < 28) @Suppress("DEPRECATION") {
Settings.Secure.getInt(view.context.contentResolver, Settings.Secure.LOCATION_MODE,
Settings.Secure.LOCATION_MODE_OFF) == Settings.Secure.LOCATION_MODE_OFF
} else !context.getSystemService(LocationManager::class.java).isLocationEnabled) {
Toast.makeText(view.context, R.string.tethering_temp_hotspot_location, Toast.LENGTH_LONG).show()
try {
view.context.startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS))

View File

@@ -142,13 +142,11 @@ class RepeaterManager(private val parent: TetheringFragment) : Manager(), Servic
(viewHolder as ViewHolder).binding.data = data
}
fun update() = data.notifyChange()
override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
binder = service as RepeaterService.Binder
service.statusChanged[this] = data::onStatusChanged
service.groupChanged[this] = data::onGroupChanged
update()
data.notifyChange()
}
override fun onServiceDisconnected(name: ComponentName?) {

View File

@@ -127,7 +127,8 @@ object TetheringManager {
}
fun getTetheredIfaces(extras: Bundle) = extras.getStringArrayList(
if (Build.VERSION.SDK_INT >= 26) EXTRA_ACTIVE_TETHER else EXTRA_ACTIVE_TETHER_LEGACY)
if (Build.VERSION.SDK_INT >= 26) EXTRA_ACTIVE_TETHER else EXTRA_ACTIVE_TETHER_LEGACY)!!
fun getLocalOnlyTetheredIfaces(extras: Bundle) =
if (Build.VERSION.SDK_INT >= 26) extras.getStringArrayList(EXTRA_ACTIVE_LOCAL_ONLY) else emptyList<String>()
if (Build.VERSION.SDK_INT >= 26) extras.getStringArrayList(EXTRA_ACTIVE_LOCAL_ONLY)!!
else emptyList<String>()
}

View File

@@ -37,7 +37,7 @@ open class AlwaysAutoCompleteEditTextPreferenceDialogFragmentCompat : Preference
override fun needInputMethod(): Boolean = true
protected fun onAddEditTextToDialogView(dialogView: View, editText: EditText) {
protected open fun onAddEditTextToDialogView(dialogView: View, editText: EditText) {
val oldEditText = dialogView.findViewById<View>(android.R.id.edit)
if (oldEditText != null) {
val container = oldEditText.parent as? ViewGroup?