forked from github/wulkanowy-mirror
Add in app review (#1435)
This commit is contained in:

committed by
GitHub

parent
04c727a0c8
commit
765f8a2d1f
@ -45,6 +45,7 @@ import io.github.wulkanowy.ui.modules.schoolannouncement.SchoolAnnouncementFragm
|
||||
import io.github.wulkanowy.ui.modules.timetable.TimetableFragment
|
||||
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||
import io.github.wulkanowy.utils.AppInfo
|
||||
import io.github.wulkanowy.utils.InAppReviewHelper
|
||||
import io.github.wulkanowy.utils.UpdateHelper
|
||||
import io.github.wulkanowy.utils.createNameInitialsDrawable
|
||||
import io.github.wulkanowy.utils.dpToPx
|
||||
@ -68,6 +69,9 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
||||
@Inject
|
||||
lateinit var updateHelper: UpdateHelper
|
||||
|
||||
@Inject
|
||||
lateinit var inAppReviewHelper: InAppReviewHelper
|
||||
|
||||
@Inject
|
||||
lateinit var appInfo: AppInfo
|
||||
|
||||
@ -362,6 +366,10 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
||||
}
|
||||
}
|
||||
|
||||
override fun showInAppReview() {
|
||||
inAppReviewHelper.showInAppReview(this)
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
navController.onSaveInstanceState(outState)
|
||||
|
@ -14,6 +14,7 @@ import io.github.wulkanowy.utils.AnalyticsHelper
|
||||
import io.github.wulkanowy.utils.flowWithResource
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import timber.log.Timber
|
||||
import java.time.LocalDate
|
||||
import javax.inject.Inject
|
||||
|
||||
class MainPresenter @Inject constructor(
|
||||
@ -106,11 +107,27 @@ class MainPresenter @Inject constructor(
|
||||
} else {
|
||||
notifyMenuViewChanged()
|
||||
switchMenuView(index)
|
||||
checkInAppReview()
|
||||
true
|
||||
}
|
||||
} == true
|
||||
}
|
||||
|
||||
private fun checkInAppReview() {
|
||||
prefRepository.inAppReviewCount++
|
||||
|
||||
if (prefRepository.inAppReviewDate == null) {
|
||||
prefRepository.inAppReviewDate = LocalDate.now()
|
||||
}
|
||||
|
||||
if (!prefRepository.isAppReviewDone && prefRepository.inAppReviewCount >= 50 &&
|
||||
LocalDate.now().minusDays(14).isAfter(prefRepository.inAppReviewDate)
|
||||
) {
|
||||
view?.showInAppReview()
|
||||
prefRepository.isAppReviewDone = true
|
||||
}
|
||||
}
|
||||
|
||||
private fun showCurrentStudentAvatar() {
|
||||
val currentStudent =
|
||||
studentsWitSemesters?.singleOrNull { it.student.isCurrent }?.student ?: return
|
||||
|
@ -40,6 +40,8 @@ interface MainView : BaseView {
|
||||
|
||||
fun showStudentAvatar(student: Student)
|
||||
|
||||
fun showInAppReview()
|
||||
|
||||
interface MainChildView {
|
||||
|
||||
fun onFragmentReselected()
|
||||
|
Reference in New Issue
Block a user