Merge branch 'v2.4' into q-beta
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
apply plugin: 'com.github.ben-manes.versions'
|
apply plugin: 'com.github.ben-manes.versions'
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlinVersion = '1.3.30'
|
ext.kotlinVersion = '1.3.31'
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
@@ -12,7 +12,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.4.0-rc03'
|
classpath 'com.android.tools.build:gradle:3.4.0'
|
||||||
classpath 'com.github.ben-manes:gradle-versions-plugin:0.21.0'
|
classpath 'com.github.ben-manes:gradle-versions-plugin:0.21.0'
|
||||||
classpath 'com.google.gms:google-services:4.2.0'
|
classpath 'com.google.gms:google-services:4.2.0'
|
||||||
classpath 'io.fabric.tools:gradle:1.28.1'
|
classpath 'io.fabric.tools:gradle:1.28.1'
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
18
gradlew
vendored
18
gradlew
vendored
@@ -1,5 +1,21 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2015 the original author or authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
##
|
||||||
## Gradle start up script for UN*X
|
## Gradle start up script for UN*X
|
||||||
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
|
|||||||
APP_BASE_NAME=`basename "$0"`
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD="maximum"
|
||||||
|
|||||||
18
gradlew.bat
vendored
18
gradlew.bat
vendored
@@ -1,3 +1,19 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
|
|||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m"
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ android {
|
|||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
resConfigs "ru", "zh-rCN"
|
resConfigs "ru", "zh-rCN"
|
||||||
versionCode 200
|
versionCode 201
|
||||||
versionName "2.4.0"
|
versionName "2.4.1"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
javaCompileOptions {
|
javaCompileOptions {
|
||||||
annotationProcessorOptions {
|
annotationProcessorOptions {
|
||||||
@@ -68,28 +68,28 @@ def aux = [
|
|||||||
'com.google.firebase:firebase-core:16.0.8',
|
'com.google.firebase:firebase-core:16.0.8',
|
||||||
]
|
]
|
||||||
def lifecycleVersion = '2.0.0'
|
def lifecycleVersion = '2.0.0'
|
||||||
def roomVersion = '2.1.0-alpha06'
|
def roomVersion = '2.1.0-alpha07'
|
||||||
dependencies {
|
dependencies {
|
||||||
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycleVersion"
|
|
||||||
kapt "androidx.room:room-compiler:$roomVersion"
|
kapt "androidx.room:room-compiler:$roomVersion"
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
implementation 'androidx.browser:browser:1.0.0'
|
implementation 'androidx.browser:browser:1.0.0'
|
||||||
implementation 'androidx.core:core-ktx:1.0.1'
|
implementation 'androidx.core:core-ktx:1.0.1'
|
||||||
implementation 'androidx.emoji:emoji:1.0.0'
|
implementation 'androidx.emoji:emoji:1.0.0'
|
||||||
|
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
|
||||||
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion"
|
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion"
|
||||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion"
|
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion"
|
||||||
implementation 'androidx.preference:preference:1.1.0-alpha04'
|
implementation 'androidx.preference:preference:1.1.0-alpha04'
|
||||||
implementation "androidx.room:room-ktx:$roomVersion"
|
implementation "androidx.room:room-ktx:$roomVersion"
|
||||||
implementation 'com.android.billingclient:billing:1.2.2'
|
implementation 'com.android.billingclient:billing:1.2.2'
|
||||||
implementation 'com.github.luongvo:BadgeView:1.1.5'
|
implementation 'com.github.luongvo:BadgeView:1.1.5'
|
||||||
implementation 'com.github.topjohnwu.libsu:core:2.4.0'
|
implementation 'com.github.topjohnwu.libsu:core:2.5.0'
|
||||||
implementation 'com.google.android.material:material:1.0.0'
|
implementation 'com.google.android.material:material:1.0.0'
|
||||||
implementation 'com.jakewharton.timber:timber:4.7.1'
|
implementation 'com.jakewharton.timber:timber:4.7.1'
|
||||||
implementation 'com.linkedin.dexmaker:dexmaker:2.25.0'
|
implementation 'com.linkedin.dexmaker:dexmaker:2.25.0'
|
||||||
implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.0.0'
|
implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.0.0'
|
||||||
implementation 'net.glxn.qrgen:android:2.0'
|
implementation 'net.glxn.qrgen:android:2.0'
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.0'
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.1'
|
||||||
for (dep in aux) {
|
for (dep in aux) {
|
||||||
freedomImplementation dep
|
freedomImplementation dep
|
||||||
googleImplementation dep
|
googleImplementation dep
|
||||||
|
|||||||
@@ -88,19 +88,15 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailed(reason: Int) {
|
override fun onFailed(reason: Int) {
|
||||||
val message = getString(R.string.tethering_temp_hotspot_failure,
|
SmartSnackbar.make(getString(R.string.tethering_temp_hotspot_failure, when (reason) {
|
||||||
when (reason) {
|
ERROR_NO_CHANNEL -> getString(R.string.tethering_temp_hotspot_failure_no_channel)
|
||||||
WifiManager.LocalOnlyHotspotCallback.ERROR_NO_CHANNEL ->
|
ERROR_GENERIC -> getString(R.string.tethering_temp_hotspot_failure_generic)
|
||||||
getString(R.string.tethering_temp_hotspot_failure_no_channel)
|
ERROR_INCOMPATIBLE_MODE -> getString(R.string.tethering_temp_hotspot_failure_incompatible_mode)
|
||||||
WifiManager.LocalOnlyHotspotCallback.ERROR_GENERIC ->
|
ERROR_TETHERING_DISALLOWED -> {
|
||||||
getString(R.string.tethering_temp_hotspot_failure_generic)
|
getString(R.string.tethering_temp_hotspot_failure_tethering_disallowed)
|
||||||
WifiManager.LocalOnlyHotspotCallback.ERROR_INCOMPATIBLE_MODE ->
|
}
|
||||||
getString(R.string.tethering_temp_hotspot_failure_incompatible_mode)
|
else -> getString(R.string.failure_reason_unknown, reason)
|
||||||
WifiManager.LocalOnlyHotspotCallback.ERROR_TETHERING_DISALLOWED ->
|
})).show()
|
||||||
getString(R.string.tethering_temp_hotspot_failure_tethering_disallowed)
|
|
||||||
else -> getString(R.string.failure_reason_unknown, reason)
|
|
||||||
})
|
|
||||||
SmartSnackbar.make(message).show()
|
|
||||||
startFailure()
|
startFailure()
|
||||||
}
|
}
|
||||||
}, null)
|
}, null)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class TetheringService : IpNeighbourMonitoringService() {
|
|||||||
RoutingManager(caller, downstream, TetherType.ofInterface(downstream).isWifi) {
|
RoutingManager(caller, downstream, TetherType.ofInterface(downstream).isWifi) {
|
||||||
override fun Routing.configure() {
|
override fun Routing.configure() {
|
||||||
forward()
|
forward()
|
||||||
masquerade(RoutingManager.masqueradeMode)
|
masquerade(masqueradeMode)
|
||||||
if (app.pref.getBoolean("service.disableIpv6", true)) disableIpv6()
|
if (app.pref.getBoolean("service.disableIpv6", true)) disableIpv6()
|
||||||
commit()
|
commit()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,8 @@ import androidx.annotation.RequiresApi
|
|||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.view.updatePaddingRelative
|
import androidx.core.view.updatePaddingRelative
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.DefaultLifecycleObserver
|
||||||
import androidx.lifecycle.LifecycleObserver
|
import androidx.lifecycle.LifecycleOwner
|
||||||
import androidx.lifecycle.OnLifecycleEvent
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import be.mygod.vpnhotspot.App.Companion.app
|
import be.mygod.vpnhotspot.App.Companion.app
|
||||||
import be.mygod.vpnhotspot.DebugHelper
|
import be.mygod.vpnhotspot.DebugHelper
|
||||||
@@ -105,8 +104,7 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(),
|
|||||||
fun updateErrorMessage(errored: List<String>) {
|
fun updateErrorMessage(errored: List<String>) {
|
||||||
data.text = errored.filter { TetherType.ofInterface(it) == tetherType }.joinToString("\n") {
|
data.text = errored.filter { TetherType.ofInterface(it) == tetherType }.joinToString("\n") {
|
||||||
"$it: " + try {
|
"$it: " + try {
|
||||||
val error = TetheringManager.getLastTetherError(it)
|
when (val error = TetheringManager.getLastTetherError(it)) {
|
||||||
when (error) {
|
|
||||||
TetheringManager.TETHER_ERROR_NO_ERROR -> "TETHER_ERROR_NO_ERROR"
|
TetheringManager.TETHER_ERROR_NO_ERROR -> "TETHER_ERROR_NO_ERROR"
|
||||||
TetheringManager.TETHER_ERROR_UNKNOWN_IFACE -> "TETHER_ERROR_UNKNOWN_IFACE"
|
TetheringManager.TETHER_ERROR_UNKNOWN_IFACE -> "TETHER_ERROR_UNKNOWN_IFACE"
|
||||||
TetheringManager.TETHER_ERROR_SERVICE_UNAVAIL -> "TETHER_ERROR_SERVICE_UNAVAIL"
|
TetheringManager.TETHER_ERROR_SERVICE_UNAVAIL -> "TETHER_ERROR_SERVICE_UNAVAIL"
|
||||||
@@ -148,15 +146,14 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(),
|
|||||||
override fun stop() = TetheringManager.stop(TetheringManager.TETHERING_USB)
|
override fun stop() = TetheringManager.stop(TetheringManager.TETHERING_USB)
|
||||||
}
|
}
|
||||||
@RequiresApi(24)
|
@RequiresApi(24)
|
||||||
class Bluetooth(parent: TetheringFragment) : TetherManager(parent), LifecycleObserver {
|
class Bluetooth(parent: TetheringFragment) : TetherManager(parent), DefaultLifecycleObserver {
|
||||||
private val tethering = BluetoothTethering(parent.requireContext()) { onTetheringStarted() }
|
private val tethering = BluetoothTethering(parent.requireContext()) { onTetheringStarted() }
|
||||||
|
|
||||||
init {
|
init {
|
||||||
parent.lifecycle.addObserver(this)
|
parent.lifecycle.addObserver(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
override fun onDestroy(owner: LifecycleOwner) = tethering.close()
|
||||||
fun onDestroy() = tethering.close()
|
|
||||||
|
|
||||||
override val title get() = parent.getString(R.string.tethering_manage_bluetooth)
|
override val title get() = parent.getString(R.string.tethering_manage_bluetooth)
|
||||||
override val tetherType get() = TetherType.BLUETOOTH
|
override val tetherType get() = TetherType.BLUETOOTH
|
||||||
|
|||||||
@@ -10,9 +10,8 @@ import androidx.annotation.RequiresApi
|
|||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import androidx.core.os.BuildCompat
|
import androidx.core.os.BuildCompat
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.DefaultLifecycleObserver
|
||||||
import androidx.lifecycle.LifecycleObserver
|
import androidx.lifecycle.LifecycleOwner
|
||||||
import androidx.lifecycle.OnLifecycleEvent
|
|
||||||
import be.mygod.vpnhotspot.App.Companion.app
|
import be.mygod.vpnhotspot.App.Companion.app
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,7 +69,7 @@ class WifiDoubleLock(lockType: Int) : AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ActivityListener(private val activity: ComponentActivity) :
|
class ActivityListener(private val activity: ComponentActivity) :
|
||||||
LifecycleObserver, SharedPreferences.OnSharedPreferenceChangeListener {
|
DefaultLifecycleObserver, SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
private var keepScreenOn: Boolean = false
|
private var keepScreenOn: Boolean = false
|
||||||
set(value) {
|
set(value) {
|
||||||
if (field == value) return
|
if (field == value) return
|
||||||
@@ -89,8 +88,7 @@ class WifiDoubleLock(lockType: Int) : AutoCloseable {
|
|||||||
if (key == KEY) keepScreenOn = mode.keepScreenOn
|
if (key == KEY) keepScreenOn = mode.keepScreenOn
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
override fun onDestroy(owner: LifecycleOwner) = app.pref.unregisterOnSharedPreferenceChangeListener(this)
|
||||||
fun shutdown() = app.pref.unregisterOnSharedPreferenceChangeListener(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val wifi = app.wifi.createWifiLock(lockType, "vpnhotspot:wifi").apply { acquire() }
|
private val wifi = app.wifi.createWifiLock(lockType, "vpnhotspot:wifi").apply { acquire() }
|
||||||
|
|||||||
@@ -5,17 +5,15 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.ServiceConnection
|
import android.content.ServiceConnection
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.DefaultLifecycleObserver
|
||||||
import androidx.lifecycle.LifecycleObserver
|
|
||||||
import androidx.lifecycle.LifecycleOwner
|
import androidx.lifecycle.LifecycleOwner
|
||||||
import androidx.lifecycle.OnLifecycleEvent
|
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* owner also needs to be Context/Fragment.
|
* owner also needs to be Context/Fragment.
|
||||||
*/
|
*/
|
||||||
class ServiceForegroundConnector(private val owner: LifecycleOwner, private val connection: ServiceConnection,
|
class ServiceForegroundConnector(private val owner: LifecycleOwner, private val connection: ServiceConnection,
|
||||||
private val clazz: KClass<out Service>) : LifecycleObserver {
|
private val clazz: KClass<out Service>) : DefaultLifecycleObserver {
|
||||||
init {
|
init {
|
||||||
owner.lifecycle.addObserver(this)
|
owner.lifecycle.addObserver(this)
|
||||||
}
|
}
|
||||||
@@ -26,12 +24,10 @@ class ServiceForegroundConnector(private val owner: LifecycleOwner, private val
|
|||||||
else -> throw UnsupportedOperationException("Unsupported owner")
|
else -> throw UnsupportedOperationException("Unsupported owner")
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnLifecycleEvent(Lifecycle.Event.ON_START)
|
override fun onStart(owner: LifecycleOwner) {
|
||||||
fun onStart() {
|
|
||||||
val context = context
|
val context = context
|
||||||
context.bindService(Intent(context, clazz.java), connection, Context.BIND_AUTO_CREATE)
|
context.bindService(Intent(context, clazz.java), connection, Context.BIND_AUTO_CREATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
|
override fun onStop(owner: LifecycleOwner) = context.stopAndUnbind(connection)
|
||||||
fun onStop() = context.stopAndUnbind(connection)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,9 +59,8 @@ object SpanFormatter {
|
|||||||
|
|
||||||
val argTerm = m.group(1)!!
|
val argTerm = m.group(1)!!
|
||||||
val modTerm = m.group(2)
|
val modTerm = m.group(2)
|
||||||
val typeTerm = m.group(3)
|
|
||||||
|
|
||||||
val cookedArg = when (typeTerm) {
|
val cookedArg = when (val typeTerm = m.group(3)) {
|
||||||
"%" -> "%"
|
"%" -> "%"
|
||||||
"n" -> "\n"
|
"n" -> "\n"
|
||||||
else -> {
|
else -> {
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import android.os.Looper
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.lifecycle.DefaultLifecycleObserver
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.LifecycleObserver
|
import androidx.lifecycle.LifecycleOwner
|
||||||
import androidx.lifecycle.OnLifecycleEvent
|
|
||||||
import be.mygod.vpnhotspot.App.Companion.app
|
import be.mygod.vpnhotspot.App.Companion.app
|
||||||
import be.mygod.vpnhotspot.util.readableMessage
|
import be.mygod.vpnhotspot.util.readableMessage
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
@@ -32,17 +32,15 @@ sealed class SmartSnackbar {
|
|||||||
}.readableMessage)
|
}.readableMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
class Register(lifecycle: Lifecycle, private val view: View) : LifecycleObserver {
|
class Register(lifecycle: Lifecycle, private val view: View) : DefaultLifecycleObserver {
|
||||||
init {
|
init {
|
||||||
lifecycle.addObserver(this)
|
lifecycle.addObserver(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
override fun onResume(owner: LifecycleOwner) {
|
||||||
fun onResume() {
|
|
||||||
holder = view
|
holder = view
|
||||||
}
|
}
|
||||||
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
override fun onPause(owner: LifecycleOwner) {
|
||||||
fun onPause() {
|
|
||||||
if (holder === view) holder = null
|
if (holder === view) holder = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user