mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-27 13:33:00 +00:00
swiperefreshlayout test
This commit is contained in:
parent
cb988af82d
commit
1ba1d7f570
4 changed files with 150 additions and 129 deletions
|
@ -66,12 +66,14 @@ dependencies {
|
||||||
implementation 'androidx.lifecycle:lifecycle-livedata-core-ktx:2.2.0'
|
implementation 'androidx.lifecycle:lifecycle-livedata-core-ktx:2.2.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
|
||||||
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
|
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
|
||||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
|
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
|
||||||
implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'
|
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
|
||||||
implementation 'androidx.preference:preference-ktx:1.1.1'
|
implementation 'androidx.preference:preference-ktx:1.1.1'
|
||||||
|
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||||
implementation 'com.google.android.material:material:1.1.0'
|
implementation 'com.google.android.material:material:1.1.0'
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
|
implementation 'com.crowdin.platform:mobile-sdk:1.1.4'
|
||||||
implementation 'com.github.100rabhkr:GetJSON:1.0'
|
implementation 'com.github.100rabhkr:GetJSON:1.0'
|
||||||
implementation 'com.github.topjohnwu.libsu:core:2.5.1'
|
implementation 'com.github.topjohnwu.libsu:core:2.5.1'
|
||||||
implementation 'com.mindorks.android:prdownloader:0.6.0'
|
implementation 'com.mindorks.android:prdownloader:0.6.0'
|
||||||
|
|
|
@ -34,27 +34,60 @@ class HomeViewModel(application: Application): AndroidViewModel(application) {
|
||||||
|
|
||||||
val vancedInstallButtonTxt: MutableLiveData<String> = MutableLiveData()
|
val vancedInstallButtonTxt: MutableLiveData<String> = MutableLiveData()
|
||||||
val vancedInstallButtonIcon: MutableLiveData<Drawable> = MutableLiveData()
|
val vancedInstallButtonIcon: MutableLiveData<Drawable> = MutableLiveData()
|
||||||
|
val microgInstalled: MutableLiveData<Boolean> = MutableLiveData()
|
||||||
val microgInstalled: Boolean = isPackageInstalled("com.mgoogle.android.gms", application.packageManager)
|
val vancedInstalled: MutableLiveData<Boolean> = MutableLiveData()
|
||||||
val vancedInstalled: Boolean = isPackageInstalled(vancedPkgName, application.packageManager)
|
|
||||||
|
|
||||||
val vancedInstalledVersion: MutableLiveData<String> = MutableLiveData()
|
val vancedInstalledVersion: MutableLiveData<String> = MutableLiveData()
|
||||||
val microgInstalledVersion: MutableLiveData<String> = MutableLiveData()
|
val microgInstalledVersion: MutableLiveData<String> = MutableLiveData()
|
||||||
|
|
||||||
val vancedVersion: MutableLiveData<String> = MutableLiveData()
|
val vancedVersion: MutableLiveData<String> = MutableLiveData()
|
||||||
val microgVersion: MutableLiveData<String> = MutableLiveData()
|
val microgVersion: MutableLiveData<String> = MutableLiveData()
|
||||||
|
val microgInstallButtonTxt: MutableLiveData<String> = MutableLiveData()
|
||||||
|
val microgInstallButtonIcon: MutableLiveData<Drawable> = MutableLiveData()
|
||||||
|
|
||||||
private val vancedInstalledVersionCode = getPkgVerCode(vancedInstalled, vancedPkgName)
|
private val vancedInstalledVersionCode: MutableLiveData<Int> = MutableLiveData()
|
||||||
private val microgInstalledVersionCode = getPkgVerCode(microgInstalled, "com.mgoogle.android.gms")
|
private val microgInstalledVersionCode: MutableLiveData<Int> = MutableLiveData()
|
||||||
|
|
||||||
private val vancedVersionCode = displayJsonInt("vanced.json", "versionCode", application)
|
private val vancedVersionCode: MutableLiveData<Int> = MutableLiveData()
|
||||||
private val microgVersionCode = displayJsonInt("microg.json", "versionCode", application)
|
private val microgVersionCode: MutableLiveData<Int> = MutableLiveData()
|
||||||
|
|
||||||
val microgInstallButtonTxt = compareInt(microgInstalledVersionCode, microgVersionCode, application)
|
|
||||||
val microgInstallButtonIcon = compareIntDrawable(microgInstalledVersionCode, microgVersionCode, application)
|
|
||||||
|
|
||||||
val nonrootModeSelected: Boolean = variant == "nonroot"
|
val nonrootModeSelected: Boolean = variant == "nonroot"
|
||||||
|
|
||||||
|
val fetching: MutableLiveData<Boolean> = MutableLiveData()
|
||||||
|
|
||||||
|
fun fetchData() {
|
||||||
|
fetching.value = true
|
||||||
|
vancedVersion.value = displayJsonString("vanced.json", "version", getApplication())
|
||||||
|
microgVersion.value = displayJsonString("microg.json", "version", getApplication())
|
||||||
|
vancedInstalledVersion.value = getPkgInfo(vancedInstalled.value!!, vancedPkgName, getApplication())
|
||||||
|
microgInstalledVersion.value = getPkgInfo(microgInstalled.value!!, "com.mgoogle.android.gms", getApplication())
|
||||||
|
microgInstalled.value = isPackageInstalled("com.mgoogle.android.gms", pm)
|
||||||
|
vancedVersionCode.value = displayJsonInt("vanced.json", "versionCode", getApplication())
|
||||||
|
microgVersionCode.value = displayJsonInt("microg.json", "versionCode", getApplication())
|
||||||
|
vancedInstalledVersionCode.value = getPkgVerCode(vancedInstalled.value!!, vancedPkgName)
|
||||||
|
vancedInstalledVersionCode.value = getPkgVerCode(microgInstalled.value!!, "com.mgoogle.android.gms")
|
||||||
|
vancedInstalled.value = isPackageInstalled(vancedPkgName, pm)
|
||||||
|
microgInstallButtonTxt.value = compareInt(microgInstalledVersionCode.value!!, microgVersionCode.value!!, getApplication())
|
||||||
|
microgInstallButtonIcon.value = compareIntDrawable(microgInstalledVersionCode.value!!, microgVersionCode.value!!, getApplication())
|
||||||
|
vancedInstallButtonIcon.value =
|
||||||
|
if (variant == "nonroot") {
|
||||||
|
if (microgInstalled.value!!)
|
||||||
|
compareIntDrawable(vancedVersionCode.value!!, vancedInstalledVersionCode.value!!, getApplication())
|
||||||
|
else
|
||||||
|
null
|
||||||
|
} else
|
||||||
|
compareIntDrawable(vancedVersionCode.value!!, vancedInstalledVersionCode.value!!, getApplication())
|
||||||
|
|
||||||
|
vancedInstallButtonTxt.value =
|
||||||
|
if (variant == "nonroot") {
|
||||||
|
if (microgInstalled.value!!) {
|
||||||
|
compareInt(vancedVersionCode.value!!, vancedInstalledVersionCode.value!!, getApplication())
|
||||||
|
} else {
|
||||||
|
getApplication<Application>().getString(R.string.no_microg)
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
compareInt(vancedVersionCode.value!!, vancedInstalledVersionCode.value!!, getApplication())
|
||||||
|
fetching.value = false
|
||||||
|
}
|
||||||
|
|
||||||
fun openMicrogSettings() {
|
fun openMicrogSettings() {
|
||||||
try {
|
try {
|
||||||
val intent = Intent()
|
val intent = Intent()
|
||||||
|
@ -132,29 +165,7 @@ class HomeViewModel(application: Application): AndroidViewModel(application) {
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
vancedVersion.value = displayJsonString("vanced.json", "version", application)
|
fetchData()
|
||||||
microgVersion.value = displayJsonString("microg.json", "version", application)
|
|
||||||
vancedInstalledVersion.value = getPkgInfo(vancedInstalled, vancedPkgName, application)
|
|
||||||
microgInstalledVersion.value = getPkgInfo(microgInstalled, "com.mgoogle.android.gms", application)
|
|
||||||
vancedInstallButtonIcon.value =
|
|
||||||
if (variant == "nonroot") {
|
|
||||||
if (microgInstalled)
|
|
||||||
compareIntDrawable(vancedVersionCode, vancedInstalledVersionCode, application)
|
|
||||||
else
|
|
||||||
null
|
|
||||||
} else
|
|
||||||
compareIntDrawable(vancedVersionCode, vancedInstalledVersionCode, application)
|
|
||||||
|
|
||||||
vancedInstallButtonTxt.value =
|
|
||||||
if (variant == "nonroot") {
|
|
||||||
if (microgInstalled) {
|
|
||||||
compareInt(vancedVersionCode, vancedInstalledVersionCode, application)
|
|
||||||
} else {
|
|
||||||
application.getString(R.string.no_microg)
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
compareInt(vancedVersionCode, vancedInstalledVersionCode, application)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,13 +1,13 @@
|
||||||
package com.vanced.manager.utils
|
package com.vanced.manager.utils
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import com.vanced.manager.R
|
import com.vanced.manager.R
|
||||||
import com.vanced.manager.ui.MainActivity
|
|
||||||
|
|
||||||
object ThemeHelper {
|
object ThemeHelper {
|
||||||
|
|
||||||
fun setFinalTheme(activity: MainActivity) {
|
fun setFinalTheme(activity: Activity) {
|
||||||
val currentAccent = PreferenceManager.getDefaultSharedPreferences(activity).getString("accent_color", "Blue")
|
val currentAccent = PreferenceManager.getDefaultSharedPreferences(activity).getString("accent_color", "Blue")
|
||||||
when (PreferenceManager.getDefaultSharedPreferences(activity)
|
when (PreferenceManager.getDefaultSharedPreferences(activity)
|
||||||
.getString("theme_mode", "Follow System")) {
|
.getString("theme_mode", "Follow System")) {
|
||||||
|
|
|
@ -12,6 +12,12 @@
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
bind:refreshing="@{viewModel.fetching}"
|
||||||
|
bind:onRefreshListener="@{()-> viewModel.fetchData()}">
|
||||||
|
|
||||||
<com.vanced.manager.ui.core.SlidingNestedScrollView
|
<com.vanced.manager.ui.core.SlidingNestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -128,4 +134,6 @@
|
||||||
|
|
||||||
</com.vanced.manager.ui.core.SlidingNestedScrollView>
|
</com.vanced.manager.ui.core.SlidingNestedScrollView>
|
||||||
|
|
||||||
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
Loading…
Reference in a new issue