Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
aba08e6aa9 | |||
124b6dfd79 | |||
1dbaa8bfdc | |||
25ac171298 | |||
387ff1cba7 | |||
eef3464d0b | |||
61297a01c7 | |||
762d4b1393 | |||
2e86b67eec |
@ -27,8 +27,8 @@ android {
|
||||
testApplicationId "io.github.tests.wulkanowy"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 34
|
||||
versionCode 134
|
||||
versionName "2.2.2"
|
||||
versionCode 136
|
||||
versionName "2.2.4"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
resValue "string", "app_name", "Wulkanowy"
|
||||
@ -162,7 +162,7 @@ play {
|
||||
track = 'production'
|
||||
releaseStatus = ReleaseStatus.IN_PROGRESS
|
||||
userFraction = 0.01d
|
||||
updatePriority = 3
|
||||
updatePriority = 0
|
||||
enabled.set(false)
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ ext {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'io.github.wulkanowy:sdk:2.2.2'
|
||||
implementation 'io.github.wulkanowy:sdk:2.2.4'
|
||||
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
|
||||
|
||||
@ -253,10 +253,10 @@ dependencies {
|
||||
playImplementation 'com.google.firebase:firebase-messaging:'
|
||||
playImplementation 'com.google.firebase:firebase-crashlytics:'
|
||||
playImplementation 'com.google.firebase:firebase-config-ktx'
|
||||
playImplementation 'com.google.android.play:core:1.10.3'
|
||||
playImplementation 'com.google.android.play:core-ktx:1.8.1'
|
||||
playImplementation 'com.google.android.gms:play-services-ads:22.4.0'
|
||||
playImplementation "com.google.android.play:integrity:1.2.0"
|
||||
playImplementation 'com.google.android.play:app-update-ktx:2.1.0'
|
||||
playImplementation 'com.google.android.play:review-ktx:2.0.1'
|
||||
|
||||
hmsImplementation 'com.huawei.hms:hianalytics:6.12.0.300'
|
||||
hmsImplementation 'com.huawei.agconnect:agconnect-crash:1.9.1.301'
|
||||
|
@ -0,0 +1,13 @@
|
||||
package io.github.wulkanowy.utils
|
||||
|
||||
import android.view.View
|
||||
import javax.inject.Inject
|
||||
|
||||
class InAppUpdateHelper @Inject constructor() {
|
||||
|
||||
lateinit var messageContainer: View
|
||||
|
||||
fun checkAndInstallUpdates() {}
|
||||
|
||||
fun onResume() {}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package io.github.wulkanowy.utils
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
import javax.inject.Inject
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
class UpdateHelper @Inject constructor() {
|
||||
|
||||
lateinit var messageContainer: View
|
||||
|
||||
fun checkAndInstallUpdates(activity: Activity) {}
|
||||
|
||||
fun onActivityResult(requestCode: Int, resultCode: Int) {}
|
||||
|
||||
fun onResume(activity: Activity) {}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package io.github.wulkanowy.utils
|
||||
|
||||
import android.view.View
|
||||
import javax.inject.Inject
|
||||
|
||||
class InAppUpdateHelper @Inject constructor() {
|
||||
|
||||
lateinit var messageContainer: View
|
||||
|
||||
fun checkAndInstallUpdates() {}
|
||||
|
||||
fun onResume() {}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package io.github.wulkanowy.utils
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
import javax.inject.Inject
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
class UpdateHelper @Inject constructor() {
|
||||
|
||||
lateinit var messageContainer: View
|
||||
|
||||
fun checkAndInstallUpdates(activity: Activity) {}
|
||||
|
||||
fun onActivityResult(requestCode: Int, resultCode: Int) {}
|
||||
|
||||
fun onResume(activity: Activity) {}
|
||||
}
|
@ -194,12 +194,6 @@ class PreferencesRepository @Inject constructor(
|
||||
)
|
||||
)
|
||||
|
||||
val showTimetableTimers: Boolean
|
||||
get() = getBoolean(
|
||||
R.string.pref_key_timetable_show_timers,
|
||||
R.bool.pref_default_timetable_show_timers
|
||||
)
|
||||
|
||||
val showTimetableGaps: TimetableGapsMode
|
||||
get() = TimetableGapsMode.getByValue(
|
||||
getString(
|
||||
|
@ -23,7 +23,7 @@ import io.github.wulkanowy.ui.modules.login.symbol.LoginSymbolFragment
|
||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||
import io.github.wulkanowy.ui.modules.notifications.NotificationsFragment
|
||||
import io.github.wulkanowy.utils.AppInfo
|
||||
import io.github.wulkanowy.utils.UpdateHelper
|
||||
import io.github.wulkanowy.utils.InAppUpdateHelper
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
@ -33,7 +33,7 @@ class LoginActivity : BaseActivity<LoginPresenter, ActivityLoginBinding>(), Logi
|
||||
override lateinit var presenter: LoginPresenter
|
||||
|
||||
@Inject
|
||||
lateinit var updateHelper: UpdateHelper
|
||||
lateinit var inAppUpdateHelper: InAppUpdateHelper
|
||||
|
||||
@Inject
|
||||
lateinit var appInfo: AppInfo
|
||||
@ -47,10 +47,10 @@ class LoginActivity : BaseActivity<LoginPresenter, ActivityLoginBinding>(), Logi
|
||||
setContentView(ActivityLoginBinding.inflate(layoutInflater).apply { binding = this }.root)
|
||||
setSupportActionBar(binding.loginToolbar)
|
||||
messageContainer = binding.loginContainer
|
||||
updateHelper.messageContainer = binding.loginContainer
|
||||
inAppUpdateHelper.messageContainer = binding.loginContainer
|
||||
|
||||
presenter.onAttachView(this)
|
||||
updateHelper.checkAndInstallUpdates(this)
|
||||
inAppUpdateHelper.checkAndInstallUpdates()
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
openFragment(LoginFormFragment.newInstance(), clearBackStack = true)
|
||||
@ -117,14 +117,6 @@ class LoginActivity : BaseActivity<LoginPresenter, ActivityLoginBinding>(), Logi
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
updateHelper.onResume(this)
|
||||
}
|
||||
|
||||
//https://developer.android.com/guide/playcore/in-app-updates#status_callback
|
||||
@Deprecated("Deprecated in Java")
|
||||
@Suppress("DEPRECATION")
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
updateHelper.onActivityResult(requestCode, resultCode)
|
||||
inAppUpdateHelper.onResume()
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
||||
lateinit var analytics: AnalyticsHelper
|
||||
|
||||
@Inject
|
||||
lateinit var updateHelper: UpdateHelper
|
||||
lateinit var inAppUpdateHelper: InAppUpdateHelper
|
||||
|
||||
@Inject
|
||||
lateinit var inAppReviewHelper: InAppReviewHelper
|
||||
@ -100,7 +100,7 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
||||
this.savedInstanceState = savedInstanceState
|
||||
messageContainer = binding.mainMessageContainer
|
||||
messageAnchor = binding.mainMessageContainer
|
||||
updateHelper.messageContainer = binding.mainFragmentContainer
|
||||
inAppUpdateHelper.messageContainer = binding.mainFragmentContainer
|
||||
onBackCallback = onBackPressedDispatcher.addCallback(this, enabled = false) {
|
||||
presenter.onBackPressed()
|
||||
}
|
||||
@ -109,19 +109,12 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
||||
?.takeIf { savedInstanceState == null }
|
||||
|
||||
presenter.onAttachView(this, destination)
|
||||
updateHelper.checkAndInstallUpdates(this)
|
||||
inAppUpdateHelper.checkAndInstallUpdates()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
updateHelper.onResume(this)
|
||||
}
|
||||
|
||||
//https://developer.android.com/guide/playcore/in-app-updates#status_callback
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
updateHelper.onActivityResult(requestCode, resultCode)
|
||||
inAppUpdateHelper.onResume()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
|
@ -325,7 +325,7 @@ class TimetableAdapter @Inject constructor() :
|
||||
|
||||
override fun getChangePayload(oldItem: TimetableItem, newItem: TimetableItem): Any? {
|
||||
return if (oldItem is TimetableItem.Normal && newItem is TimetableItem.Normal) {
|
||||
if (oldItem.lesson == newItem.lesson && oldItem.timeLeft != newItem.timeLeft) {
|
||||
if (oldItem.lesson == newItem.lesson && oldItem.showGroupsInPlan == newItem.showGroupsInPlan && oldItem.timeLeft != newItem.timeLeft) {
|
||||
"time_left"
|
||||
} else super.getChangePayload(oldItem, newItem)
|
||||
} else super.getChangePayload(oldItem, newItem)
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.github.wulkanowy.ui.modules.timetable
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import io.github.wulkanowy.data.dataOrNull
|
||||
import io.github.wulkanowy.data.db.entities.Semester
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
@ -236,11 +238,13 @@ class TimetablePresenter @Inject constructor(
|
||||
private fun updateData(lessons: List<Timetable>) {
|
||||
tickTimer?.cancel()
|
||||
|
||||
if (!prefRepository.showTimetableTimers) {
|
||||
if (currentDate != now()) {
|
||||
view?.updateData(createItems(lessons))
|
||||
} else {
|
||||
tickTimer = timer(period = 2_000) {
|
||||
view?.updateData(createItems(lessons))
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
view?.updateData(createItems(lessons))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
Wersja 2.2.2
|
||||
Wersja 2.2.4
|
||||
|
||||
— dodaliśmy możliwość łatwego wejścia w sobotę i niedziele w planie lekcji przy użyciu strzałek
|
||||
— ułatwiliśmy przełączenie dnia na weekend w planie lekcji przy użyciu strzałek
|
||||
— poprawiliśmy wsparcie dla statystyk ocen z systemem punktowym
|
||||
— poprawiliśmy sortowanie nauczycieli w widoku Szkoła i nauczyciele
|
||||
|
||||
|
@ -713,7 +713,6 @@
|
||||
<string name="pref_view_present">Zobrazit přítomnost</string>
|
||||
<string name="pref_view_app_theme">Motiv</string>
|
||||
<string name="pref_view_expand_grade">Rozvíjení známek</string>
|
||||
<string name="pref_view_timetable_show_timers">Označit aktuální lekci</string>
|
||||
<string name="pref_view_timetable_show_groups">Zobrazit skupiny vedle předmětů</string>
|
||||
<string name="pref_view_timetable_show_gaps">Zobrazit prázdné dlaždice, kde není žádná lekce</string>
|
||||
<string name="pref_view_grade_statistics_list">Zobrazit seznam grafů v známkách třídy</string>
|
||||
|
@ -623,7 +623,6 @@
|
||||
<string name="pref_view_present">Show presence</string>
|
||||
<string name="pref_view_app_theme">Theme</string>
|
||||
<string name="pref_view_expand_grade">Grades expanding</string>
|
||||
<string name="pref_view_timetable_show_timers">Mark current lesson</string>
|
||||
<string name="pref_view_timetable_show_groups">Show groups next to subjects</string>
|
||||
<string name="pref_view_timetable_show_gaps">Show empty tiles where there\'s no lesson</string>
|
||||
<string name="pref_view_grade_statistics_list">Show chart list in class grades</string>
|
||||
|
@ -623,7 +623,6 @@
|
||||
<string name="pref_view_present">Anwesendheit zeigen</string>
|
||||
<string name="pref_view_app_theme">Thema</string>
|
||||
<string name="pref_view_expand_grade">Steigende Sorten</string>
|
||||
<string name="pref_view_timetable_show_timers">Aktuelle Lektion markieren</string>
|
||||
<string name="pref_view_timetable_show_groups">Gruppen neben Schulfächen anzeigen</string>
|
||||
<string name="pref_view_timetable_show_gaps">Show empty tiles where there\'s no lesson</string>
|
||||
<string name="pref_view_grade_statistics_list">Liste der Diagramme in Klassenbewertungen anzeigen</string>
|
||||
|
@ -623,7 +623,6 @@
|
||||
<string name="pref_view_present">Show presence</string>
|
||||
<string name="pref_view_app_theme">Theme</string>
|
||||
<string name="pref_view_expand_grade">Grades expanding</string>
|
||||
<string name="pref_view_timetable_show_timers">Mark current lesson</string>
|
||||
<string name="pref_view_timetable_show_groups">Show groups next to subjects</string>
|
||||
<string name="pref_view_timetable_show_gaps">Show empty tiles where there\'s no lesson</string>
|
||||
<string name="pref_view_grade_statistics_list">Show chart list in class grades</string>
|
||||
|
@ -623,7 +623,6 @@
|
||||
<string name="pref_view_present">Show presence</string>
|
||||
<string name="pref_view_app_theme">Theme</string>
|
||||
<string name="pref_view_expand_grade">Grades expanding</string>
|
||||
<string name="pref_view_timetable_show_timers">Mark current lesson</string>
|
||||
<string name="pref_view_timetable_show_groups">Show groups next to subjects</string>
|
||||
<string name="pref_view_timetable_show_gaps">Show empty tiles where there\'s no lesson</string>
|
||||
<string name="pref_view_grade_statistics_list">Show chart list in class grades</string>
|
||||
|
@ -713,7 +713,6 @@
|
||||
<string name="pref_view_present">Pokazuj obecność</string>
|
||||
<string name="pref_view_app_theme">Motyw</string>
|
||||
<string name="pref_view_expand_grade">Rozwijanie ocen</string>
|
||||
<string name="pref_view_timetable_show_timers">Oznaczaj bieżącą lekcję</string>
|
||||
<string name="pref_view_timetable_show_groups">Pokazuj grupę obok przedmiotu</string>
|
||||
<string name="pref_view_timetable_show_gaps">Pokazuj puste kafelki gdzie nie ma lekcji</string>
|
||||
<string name="pref_view_grade_statistics_list">Pokazuj listę wykresów w ocenach klasy</string>
|
||||
|
@ -713,7 +713,6 @@
|
||||
<string name="pref_view_present">Показывать присутствия</string>
|
||||
<string name="pref_view_app_theme">Тема</string>
|
||||
<string name="pref_view_expand_grade">Разворачивание оценок</string>
|
||||
<string name="pref_view_timetable_show_timers">Отметить текущий урок</string>
|
||||
<string name="pref_view_timetable_show_groups">Показать группы рядом с темами</string>
|
||||
<string name="pref_view_timetable_show_gaps">Show empty tiles where there\'s no lesson</string>
|
||||
<string name="pref_view_grade_statistics_list">Показывать диаграммы в оценках класса</string>
|
||||
|
@ -713,7 +713,6 @@
|
||||
<string name="pref_view_present">Zobraziť prítomnosť</string>
|
||||
<string name="pref_view_app_theme">Motív</string>
|
||||
<string name="pref_view_expand_grade">Rozvijanie známok</string>
|
||||
<string name="pref_view_timetable_show_timers">Označiť aktuálne lekciu</string>
|
||||
<string name="pref_view_timetable_show_groups">Zobraziť skupiny vedľa predmetov</string>
|
||||
<string name="pref_view_timetable_show_gaps">Zobraziť prázdne dlaždice, kde nie je žiadne lekcie</string>
|
||||
<string name="pref_view_grade_statistics_list">Zobraziť zoznam grafov v známkach triedy</string>
|
||||
|
@ -713,7 +713,6 @@
|
||||
<string name="pref_view_present">Показувати присутність</string>
|
||||
<string name="pref_view_app_theme">Тема</string>
|
||||
<string name="pref_view_expand_grade">Розгортання оцінок</string>
|
||||
<string name="pref_view_timetable_show_timers">Позначити поточний урок</string>
|
||||
<string name="pref_view_timetable_show_groups">Показувати групи поруч з темами</string>
|
||||
<string name="pref_view_timetable_show_gaps">Показувати порожні плитки там, де немає уроків</string>
|
||||
<string name="pref_view_grade_statistics_list">Показувати діаграми в оцінках класу</string>
|
||||
|
@ -22,7 +22,6 @@
|
||||
<bool name="pref_default_timetable_show_groups">false</bool>
|
||||
<string name="pref_default_timetable_show_whole_class">no</string>
|
||||
<string name="pref_default_grade_sorting_mode">alphabetic</string>
|
||||
<bool name="pref_default_timetable_show_timers">false</bool>
|
||||
<string name="pref_default_timetable_show_gaps">between</string>
|
||||
<bool name="pref_default_subjects_without_grades">false</bool>
|
||||
<bool name="pref_default_optional_arithmetic_average">false</bool>
|
||||
|
@ -27,7 +27,6 @@
|
||||
<string name="pref_key_grade_sorting_mode">grade_sorting_mode</string>
|
||||
<string name="pref_key_timetable_show_whole_class">show_whole_class_plan</string>
|
||||
<string name="pref_key_timetable_show_groups">show_groups_in_plan</string>
|
||||
<string name="pref_key_timetable_show_timers">timetable_show_timers</string>
|
||||
<string name="pref_key_timetable_show_gaps">timetable_show_gaps</string>
|
||||
<string name="pref_key_subjects_without_grades">subjects_without_grades</string>
|
||||
<string name="pref_key_optional_arithmetic_average">optional_arithmetic_average</string>
|
||||
|
@ -701,7 +701,6 @@
|
||||
<string name="pref_view_present">Show presence</string>
|
||||
<string name="pref_view_app_theme">Theme</string>
|
||||
<string name="pref_view_expand_grade">Grades expanding</string>
|
||||
<string name="pref_view_timetable_show_timers">Mark current lesson</string>
|
||||
<string name="pref_view_timetable_show_groups">Show groups next to subjects</string>
|
||||
<string name="pref_view_timetable_show_gaps">Show empty tiles where there\'s no lesson</string>
|
||||
<string name="pref_view_grade_statistics_list">Show chart list in class grades</string>
|
||||
|
@ -90,11 +90,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
app:iconSpaceReserved="false"
|
||||
app:title="@string/pref_timetable_appearance_view">
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="@bool/pref_default_timetable_show_timers"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="@string/pref_key_timetable_show_timers"
|
||||
app:title="@string/pref_view_timetable_show_timers" />
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="@bool/pref_default_timetable_show_groups"
|
||||
app:iconSpaceReserved="false"
|
||||
|
@ -3,12 +3,15 @@ package io.github.wulkanowy.utils
|
||||
import android.app.Activity
|
||||
import android.app.Activity.RESULT_OK
|
||||
import android.content.Context
|
||||
import android.content.IntentSender
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.ActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.google.android.play.core.appupdate.AppUpdateInfo
|
||||
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
|
||||
import com.google.android.play.core.appupdate.AppUpdateOptions
|
||||
import com.google.android.play.core.install.InstallStateUpdatedListener
|
||||
import com.google.android.play.core.install.model.AppUpdateType.FLEXIBLE
|
||||
import com.google.android.play.core.install.model.AppUpdateType.IMMEDIATE
|
||||
@ -20,15 +23,16 @@ import com.google.android.play.core.ktx.isFlexibleUpdateAllowed
|
||||
import com.google.android.play.core.ktx.isImmediateUpdateAllowed
|
||||
import com.google.android.play.core.ktx.updatePriority
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import dagger.hilt.android.scopes.ActivityScoped
|
||||
import io.github.wulkanowy.R
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class UpdateHelper @Inject constructor(
|
||||
@ActivityScoped
|
||||
class InAppUpdateHelper @Inject constructor(
|
||||
@ApplicationContext private val context: Context,
|
||||
private val analyticsHelper: AnalyticsHelper,
|
||||
activity: Activity
|
||||
) {
|
||||
|
||||
lateinit var messageContainer: View
|
||||
@ -39,6 +43,7 @@ class UpdateHelper @Inject constructor(
|
||||
when (state.installStatus()) {
|
||||
PENDING -> Toast.makeText(context, R.string.update_download_started, Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
|
||||
DOWNLOADED -> popupSnackBarForCompleteUpdate()
|
||||
else -> Timber.d("Update state: ${state.installStatus()}")
|
||||
}
|
||||
@ -70,45 +75,55 @@ class UpdateHelper @Inject constructor(
|
||||
return updateAvailability() == UPDATE_AVAILABLE && isFlexibleUpdateAllowed && isUpdatePriorityAllowUpdate
|
||||
}
|
||||
|
||||
fun checkAndInstallUpdates(activity: Activity) {
|
||||
private val activityResultLauncher = (activity as AppCompatActivity).registerForActivityResult(
|
||||
ActivityResultContracts.StartIntentSenderForResult(),
|
||||
::onActivityResult
|
||||
)
|
||||
|
||||
fun checkAndInstallUpdates() {
|
||||
Timber.d("Checking for updates...")
|
||||
appUpdateManager.appUpdateInfo.addOnSuccessListener { appUpdateInfo ->
|
||||
when {
|
||||
appUpdateInfo.isImmediateUpdateAvailable -> {
|
||||
startUpdate(activity, appUpdateInfo, IMMEDIATE)
|
||||
startUpdate(appUpdateInfo, IMMEDIATE)
|
||||
}
|
||||
|
||||
appUpdateInfo.isFlexibleUpdateAvailable -> {
|
||||
appUpdateManager.registerListener(flexibleUpdateListener)
|
||||
startUpdate(activity, appUpdateInfo, FLEXIBLE)
|
||||
startUpdate(appUpdateInfo, FLEXIBLE)
|
||||
}
|
||||
|
||||
else -> Timber.d("No update available")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun startUpdate(activity: Activity, appUpdateInfo: AppUpdateInfo, updateType: Int) {
|
||||
private fun startUpdate(appUpdateInfo: AppUpdateInfo, updateType: Int) {
|
||||
Timber.d("Start update ($updateType): $appUpdateInfo")
|
||||
|
||||
try {
|
||||
appUpdateManager.startUpdateFlowForResult(
|
||||
appUpdateInfo, updateType, activity, IN_APP_UPDATE_REQUEST_CODE
|
||||
appUpdateInfo,
|
||||
activityResultLauncher,
|
||||
AppUpdateOptions.defaultOptions(updateType)
|
||||
)
|
||||
} catch (e: IntentSender.SendIntentException) {
|
||||
Timber.i("Update failed! Duplicated PendingIntent")
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "Update failed!")
|
||||
}
|
||||
}
|
||||
|
||||
fun onActivityResult(requestCode: Int, resultCode: Int) {
|
||||
if (requestCode == IN_APP_UPDATE_REQUEST_CODE) {
|
||||
if (resultCode != RESULT_OK) {
|
||||
Timber.i("Update failed! Result code: $resultCode")
|
||||
Toast.makeText(context, R.string.update_failed, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
private fun onActivityResult(activityResult: ActivityResult) {
|
||||
val resultCode = activityResult.resultCode
|
||||
|
||||
analyticsHelper.logEvent("inapp_update", "code" to resultCode)
|
||||
if (resultCode != RESULT_OK) {
|
||||
Timber.i("Update failed! Result code: $resultCode")
|
||||
Toast.makeText(context, R.string.update_failed, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
analyticsHelper.logEvent("inapp_update", "code" to resultCode)
|
||||
}
|
||||
|
||||
fun onResume(activity: Activity) {
|
||||
fun onResume() {
|
||||
appUpdateManager.appUpdateInfo.addOnSuccessListener { info ->
|
||||
Timber.d("InAppUpdate.onResume() listener: $info")
|
||||
|
||||
@ -116,7 +131,6 @@ class UpdateHelper @Inject constructor(
|
||||
DOWNLOADED == info.installStatus() -> popupSnackBarForCompleteUpdate()
|
||||
DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS == info.updateAvailability() -> {
|
||||
startUpdate(
|
||||
activity = activity,
|
||||
appUpdateInfo = info,
|
||||
updateType = if (info.isImmediateUpdateAvailable) IMMEDIATE else FLEXIBLE
|
||||
)
|
||||
@ -139,9 +153,4 @@ class UpdateHelper @Inject constructor(
|
||||
show()
|
||||
}
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
||||
private const val IN_APP_UPDATE_REQUEST_CODE = 1721
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user