diff --git a/build.gradle b/build.gradle index c87366a2..66beb88d 100644 --- a/build.gradle +++ b/build.gradle @@ -12,8 +12,8 @@ buildscript { } } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0-rc02' - classpath 'com.github.ben-manes:gradle-versions-plugin:0.21.0' + classpath 'com.android.tools.build:gradle:3.5.0-rc03' + classpath 'com.github.ben-manes:gradle-versions-plugin:0.22.0' classpath 'com.google.gms:google-services:4.3.0' classpath 'io.fabric.tools:gradle:1.31.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" diff --git a/mobile/build.gradle b/mobile/build.gradle index f04593e7..96e6d07e 100644 --- a/mobile/build.gradle +++ b/mobile/build.gradle @@ -8,12 +8,21 @@ if (!getGradle().getStartParameter().getTaskRequests().toString().contains("Fdro apply plugin: 'io.fabric' } +def javaVersion = JavaVersion.VERSION_1_8 +def aux = [ + 'com.crashlytics.sdk.android:crashlytics:2.10.1', + 'com.google.firebase:firebase-core:17.0.1', +] +def lifecycleVersion = '2.2.0-alpha03' +def roomVersion = '2.1.0' + android { compileSdkVersion 29 compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility javaVersion + targetCompatibility javaVersion } + kotlinOptions.jvmTarget = javaVersion defaultConfig { applicationId "be.mygod.vpnhotspot" minSdkVersion 21 @@ -63,17 +72,11 @@ androidExtensions { experimental = true } -def aux = [ - 'com.crashlytics.sdk.android:crashlytics:2.10.1', - 'com.google.firebase:firebase-core:17.0.1', -] -def lifecycleVersion = '2.2.0-alpha02' -def roomVersion = '2.1.0' dependencies { kapt "androidx.room:room-compiler:$roomVersion" implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.browser:browser:1.0.0' - implementation 'androidx.core:core-ktx:1.1.0-rc02' + implementation 'androidx.core:core-ktx:1.1.0-rc03' implementation 'androidx.emoji:emoji:1.0.0' implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion" @@ -82,7 +85,8 @@ dependencies { implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion" implementation 'androidx.preference:preference:1.1.0-rc01' implementation "androidx.room:room-ktx:$roomVersion" - implementation 'com.android.billingclient:billing:2.0.2' + implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0' + implementation 'com.android.billingclient:billing:2.0.3' implementation 'com.github.topjohnwu.libsu:core:2.5.0' implementation 'com.google.android.material:material:1.1.0-alpha09' implementation 'com.jakewharton.timber:timber:4.7.1' @@ -90,7 +94,7 @@ dependencies { implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.0.0' implementation 'net.glxn.qrgen:android:2.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0-RC' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0-RC2' for (dep in aux) { freedomImplementation dep googleImplementation dep diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/MainActivity.kt b/mobile/src/main/java/be/mygod/vpnhotspot/MainActivity.kt index 7a23b692..9c3b09c4 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/MainActivity.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/MainActivity.kt @@ -7,7 +7,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat import androidx.databinding.DataBindingUtil import androidx.fragment.app.Fragment -import androidx.lifecycle.ViewModelProviders +import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.get import androidx.lifecycle.observe import be.mygod.vpnhotspot.client.ClientViewModel @@ -23,6 +23,7 @@ import java.net.Inet4Address class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemSelectedListener { private lateinit var binding: ActivityMainBinding + val provider by lazy { ViewModelProvider(this) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -30,7 +31,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS binding.lifecycleOwner = this binding.navigation.setOnNavigationItemSelectedListener(this) if (savedInstanceState == null) displayFragment(TetheringFragment()) - val model = ViewModelProviders.of(this).get() + val model = provider.get() if (RepeaterService.supported) ServiceForegroundConnector(this, model, RepeaterService::class) model.clients.observe(this) { clients -> val count = clients.count { diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/client/ClientsFragment.kt b/mobile/src/main/java/be/mygod/vpnhotspot/client/ClientsFragment.kt index 067d0074..cc10300d 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/client/ClientsFragment.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/client/ClientsFragment.kt @@ -17,7 +17,6 @@ import androidx.appcompat.widget.PopupMenu import androidx.databinding.BaseObservable import androidx.databinding.DataBindingUtil import androidx.fragment.app.Fragment -import androidx.lifecycle.ViewModelProviders import androidx.lifecycle.get import androidx.lifecycle.lifecycleScope import androidx.lifecycle.observe @@ -28,6 +27,7 @@ import androidx.recyclerview.widget.RecyclerView import be.mygod.vpnhotspot.AlertDialogFragment import be.mygod.vpnhotspot.App.Companion.app import be.mygod.vpnhotspot.Empty +import be.mygod.vpnhotspot.MainActivity import be.mygod.vpnhotspot.R import be.mygod.vpnhotspot.databinding.FragmentClientsBinding import be.mygod.vpnhotspot.databinding.ListitemClientBinding @@ -224,7 +224,7 @@ class ClientsFragment : Fragment() { binding.swipeRefresher.setOnRefreshListener { IpNeighbourMonitor.instance?.flush() } - ViewModelProviders.of(requireActivity()).get().clients.observe(this) { + (activity as MainActivity).provider.get().clients.observe(this) { adapter.submitList(it.toMutableList()) } return binding.root diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/manage/RepeaterManager.kt b/mobile/src/main/java/be/mygod/vpnhotspot/manage/RepeaterManager.kt index 8fcc5dbb..cf7381bc 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/manage/RepeaterManager.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/manage/RepeaterManager.kt @@ -21,7 +21,7 @@ import androidx.core.content.ContextCompat import androidx.databinding.BaseObservable import androidx.databinding.Bindable import androidx.lifecycle.ViewModel -import androidx.lifecycle.ViewModelProviders +import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.get import androidx.recyclerview.widget.RecyclerView import be.mygod.vpnhotspot.* @@ -136,7 +136,7 @@ class RepeaterManager(private val parent: TetheringFragment) : Manager(), Servic internal var binder: RepeaterService.Binder? = null private var p2pInterface: String? = null @Suppress("DEPRECATION") - private val holder = ViewModelProviders.of(parent).get() + private val holder = ViewModelProvider(parent).get() override fun bindTo(viewHolder: RecyclerView.ViewHolder) { (viewHolder as ViewHolder).binding.data = data