mirror of
https://github.com/sudoxnym/fdroiddata.git
synced 2026-04-19 22:11:32 +00:00
234 lines
9.4 KiB
Diff
234 lines
9.4 KiB
Diff
diff --git a/app/build.gradle b/app/build.gradle
|
|
index d33ceeff..6949eb25 100644
|
|
--- a/app/build.gradle
|
|
+++ b/app/build.gradle
|
|
@@ -82,7 +82,6 @@ dependencies {
|
|
implementation library.core
|
|
implementation library.activity
|
|
implementation library.fragment
|
|
- implementation library.playcore
|
|
|
|
// UI
|
|
implementation library.appcompat
|
|
diff --git a/app/src/main/kotlin/com/brackeys/ui/feature/main/activities/MainActivity.kt b/app/src/main/kotlin/com/brackeys/ui/feature/main/activities/MainActivity.kt
|
|
index 99372d43..f8059c0c 100644
|
|
--- a/app/src/main/kotlin/com/brackeys/ui/feature/main/activities/MainActivity.kt
|
|
+++ b/app/src/main/kotlin/com/brackeys/ui/feature/main/activities/MainActivity.kt
|
|
@@ -33,16 +33,11 @@ import com.brackeys.ui.feature.main.viewmodel.MainViewModel
|
|
import com.brackeys.ui.utils.extensions.fragment
|
|
import com.brackeys.ui.utils.extensions.multiplyDraggingEdgeSizeBy
|
|
import com.google.android.material.snackbar.Snackbar
|
|
-import com.google.android.play.core.install.model.ActivityResult
|
|
import dagger.hilt.android.AndroidEntryPoint
|
|
|
|
@AndroidEntryPoint
|
|
class MainActivity : BaseActivity() {
|
|
|
|
- companion object {
|
|
- private const val REQUEST_CODE_UPDATE = 10
|
|
- }
|
|
-
|
|
private val viewModel: MainViewModel by viewModels()
|
|
|
|
private lateinit var binding: ActivityMainBinding
|
|
@@ -61,21 +56,10 @@ class MainActivity : BaseActivity() {
|
|
.fragment<ExplorerFragment>(R.id.fragment_explorer)
|
|
|
|
binding.drawerLayout?.multiplyDraggingEdgeSizeBy(2)
|
|
-
|
|
- viewModel.checkForUpdates()
|
|
}
|
|
|
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
super.onActivityResult(requestCode, resultCode, data)
|
|
- if (requestCode == REQUEST_CODE_UPDATE) {
|
|
- when (resultCode) {
|
|
- Activity.RESULT_OK -> { /* approved */ }
|
|
- Activity.RESULT_CANCELED -> { /* rejected */ }
|
|
- ActivityResult.RESULT_IN_APP_UPDATE_FAILED -> {
|
|
- showToast(R.string.message_in_app_update_failed)
|
|
- }
|
|
- }
|
|
- }
|
|
}
|
|
|
|
override fun onBackPressed() {
|
|
@@ -95,22 +79,6 @@ class MainActivity : BaseActivity() {
|
|
}
|
|
|
|
private fun observeViewModel() {
|
|
- viewModel.updateEvent.observe(this) {
|
|
- val appUpdateManager = it.first
|
|
- val appUpdateInfo = it.second
|
|
- val appUpdateType = it.third
|
|
- appUpdateManager.startUpdateFlowForResult(
|
|
- appUpdateInfo,
|
|
- appUpdateType,
|
|
- this,
|
|
- REQUEST_CODE_UPDATE
|
|
- )
|
|
- }
|
|
- viewModel.installEvent.observe(this) {
|
|
- Snackbar.make(binding.root, R.string.message_in_app_update_ready, Snackbar.LENGTH_INDEFINITE)
|
|
- .setAction(R.string.action_restart) { viewModel.completeUpdate() }
|
|
- .show()
|
|
- }
|
|
viewModel.fullscreenEvent.observe(this) { enabled ->
|
|
if (enabled) {
|
|
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
|
|
@@ -127,4 +95,4 @@ class MainActivity : BaseActivity() {
|
|
|
|
viewModel.observeSettings()
|
|
}
|
|
-}
|
|
\ No newline at end of file
|
|
+}
|
|
diff --git a/app/src/main/kotlin/com/brackeys/ui/feature/main/viewmodel/MainViewModel.kt b/app/src/main/kotlin/com/brackeys/ui/feature/main/viewmodel/MainViewModel.kt
|
|
index 7615dafc..41ca7922 100644
|
|
--- a/app/src/main/kotlin/com/brackeys/ui/feature/main/viewmodel/MainViewModel.kt
|
|
+++ b/app/src/main/kotlin/com/brackeys/ui/feature/main/viewmodel/MainViewModel.kt
|
|
@@ -24,27 +24,17 @@ import com.brackeys.ui.domain.providers.rx.SchedulersProvider
|
|
import com.brackeys.ui.feature.base.viewmodel.BaseViewModel
|
|
import com.brackeys.ui.filesystem.base.model.FileModel
|
|
import com.brackeys.ui.utils.event.SingleLiveEvent
|
|
-import com.google.android.play.core.appupdate.AppUpdateInfo
|
|
-import com.google.android.play.core.appupdate.AppUpdateManager
|
|
-import com.google.android.play.core.install.InstallStateUpdatedListener
|
|
-import com.google.android.play.core.install.model.AppUpdateType
|
|
-import com.google.android.play.core.install.model.InstallStatus
|
|
-import com.google.android.play.core.install.model.UpdateAvailability
|
|
-import com.google.android.play.core.ktx.installStatus
|
|
import io.reactivex.rxkotlin.subscribeBy
|
|
|
|
class MainViewModel @ViewModelInject constructor(
|
|
private val schedulersProvider: SchedulersProvider,
|
|
private val settingsManager: SettingsManager,
|
|
- private val appUpdateManager: AppUpdateManager
|
|
) : BaseViewModel() {
|
|
|
|
companion object {
|
|
private const val TAG = "MainViewModel"
|
|
}
|
|
|
|
- val updateEvent: SingleLiveEvent<Triple<AppUpdateManager, AppUpdateInfo, Int>> = SingleLiveEvent()
|
|
- val installEvent: SingleLiveEvent<Unit> = SingleLiveEvent()
|
|
val fullscreenEvent: SingleLiveEvent<Boolean> = SingleLiveEvent()
|
|
val confirmExitEvent: SingleLiveEvent<Boolean> = SingleLiveEvent()
|
|
|
|
@@ -56,37 +46,6 @@ class MainViewModel @ViewModelInject constructor(
|
|
val openAsEvent: SingleLiveEvent<FileModel> = SingleLiveEvent()
|
|
val propertiesEvent: SingleLiveEvent<FileModel> = SingleLiveEvent()
|
|
|
|
- private val installStateUpdatedListener = InstallStateUpdatedListener { state ->
|
|
- if (state.installStatus == InstallStatus.DOWNLOADED) {
|
|
- installEvent.call()
|
|
- }
|
|
- }
|
|
-
|
|
- fun checkForUpdates() {
|
|
- // TODO: 2020/8/5 Google Play is not available in Chinese mainland
|
|
- appUpdateManager.registerListener(installStateUpdatedListener)
|
|
- appUpdateManager.appUpdateInfo
|
|
- .addOnSuccessListener { appUpdateInfo ->
|
|
- if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) {
|
|
- if (appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {
|
|
- updateEvent.value = Triple(appUpdateManager, appUpdateInfo, AppUpdateType.FLEXIBLE)
|
|
- } else if (appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
|
|
- updateEvent.value = Triple(appUpdateManager, appUpdateInfo, AppUpdateType.IMMEDIATE)
|
|
- }
|
|
- } else {
|
|
- appUpdateManager.unregisterListener(installStateUpdatedListener)
|
|
- }
|
|
- }
|
|
- .addOnFailureListener {
|
|
- Log.e(TAG, it.message, it)
|
|
- }
|
|
- }
|
|
-
|
|
- fun completeUpdate() {
|
|
- appUpdateManager.unregisterListener(installStateUpdatedListener)
|
|
- appUpdateManager.completeUpdate()
|
|
- }
|
|
-
|
|
fun observeSettings() {
|
|
settingsManager.getFullscreenMode()
|
|
.asObservable()
|
|
@@ -100,4 +59,4 @@ class MainViewModel @ViewModelInject constructor(
|
|
.subscribeBy { confirmExitEvent.value = it }
|
|
.disposeOnViewModelDestroy()
|
|
}
|
|
-}
|
|
\ No newline at end of file
|
|
+}
|
|
diff --git a/app/src/main/kotlin/com/brackeys/ui/internal/di/main/MainModule.kt b/app/src/main/kotlin/com/brackeys/ui/internal/di/main/MainModule.kt
|
|
deleted file mode 100644
|
|
index c4590a23..00000000
|
|
--- a/app/src/main/kotlin/com/brackeys/ui/internal/di/main/MainModule.kt
|
|
+++ /dev/null
|
|
@@ -1,38 +0,0 @@
|
|
-/*
|
|
- * Copyright 2020 Brackeys IDE contributors.
|
|
- *
|
|
- * 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.
|
|
- */
|
|
-
|
|
-package com.brackeys.ui.internal.di.main
|
|
-
|
|
-import android.content.Context
|
|
-import com.google.android.play.core.appupdate.AppUpdateManager
|
|
-import com.google.android.play.core.appupdate.AppUpdateManagerFactory
|
|
-import dagger.Module
|
|
-import dagger.Provides
|
|
-import dagger.hilt.InstallIn
|
|
-import dagger.hilt.android.components.ActivityRetainedComponent
|
|
-import dagger.hilt.android.qualifiers.ApplicationContext
|
|
-import dagger.hilt.android.scopes.ActivityRetainedScoped
|
|
-
|
|
-@Module
|
|
-@InstallIn(ActivityRetainedComponent::class)
|
|
-object MainModule {
|
|
-
|
|
- @Provides
|
|
- @ActivityRetainedScoped
|
|
- fun provideAppUpdateManager(@ApplicationContext context: Context): AppUpdateManager {
|
|
- return AppUpdateManagerFactory.create(context)
|
|
- }
|
|
-}
|
|
\ No newline at end of file
|
|
diff --git a/dependencies.gradle b/dependencies.gradle
|
|
index 2d37c510..f19538d3 100644
|
|
--- a/dependencies.gradle
|
|
+++ b/dependencies.gradle
|
|
@@ -36,7 +36,6 @@ ext {
|
|
core_version = '1.5.0-alpha05'
|
|
activity_version = '1.2.0-rc01'
|
|
fragment_version = '1.3.0-rc01'
|
|
- playcore_version = '1.8.1'
|
|
|
|
// UI
|
|
appcompat_version = '1.3.0-alpha02'
|
|
@@ -96,7 +95,6 @@ ext {
|
|
core: "androidx.core:core-ktx:$core_version",
|
|
activity: "androidx.activity:activity-ktx:$activity_version",
|
|
fragment: "androidx.fragment:fragment-ktx:$fragment_version",
|
|
- playcore: "com.google.android.play:core-ktx:$playcore_version",
|
|
|
|
// UI
|
|
appcompat: "androidx.appcompat:appcompat:$appcompat_version",
|
|
@@ -153,4 +151,4 @@ ext {
|
|
test_runner: "androidx.test:runner:$test_runner_version",
|
|
espresso_core: "androidx.test.espresso:espresso-core:$espresso_core_version"
|
|
]
|
|
-}
|
|
\ No newline at end of file
|
|
+}
|