Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lemkinator committed Mar 1, 2023
1 parent 0b02745 commit 162b8d7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 31 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ android {
applicationId "de.lemke.studiportal"
minSdk 26
targetSdk 33
versionCode 12
versionName "1.2.2"
versionCode 13
versionName "1.2.3"

kapt {
arguments {
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 11,
"versionName": "1.2.1",
"versionCode": 13,
"versionName": "1.2.3",
"outputFile": "app-release.apk"
}
],
Expand Down
55 changes: 28 additions & 27 deletions app/src/main/java/de/lemke/studiportal/ui/ExamActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ExamActivity : AppCompatActivity(R.layout.activity_main) {
binding = ActivityExamBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.toolbarLayout.setNavigationButtonTooltip(getString(R.string.sesl_navigate_up))
binding.toolbarLayout.setNavigationButtonOnClickListener { lifecycleScope.launch { opportunityToShowInAppReview() } }
binding.toolbarLayout.setNavigationButtonOnClickListener { opportunityToShowInAppReview() }
val examNumber = intent.getStringExtra("examNumber")
val semester = intent.getStringExtra("semester")
boldText = intent.getStringExtra("boldText") ?: ""
Expand All @@ -75,36 +75,37 @@ class ExamActivity : AppCompatActivity(R.layout.activity_main) {
}
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
lifecycleScope.launch {
try {
opportunityToShowInAppReview()
} catch (e: Exception) {
Log.e("InAppReview", "Error: ${e.message}")
}
}
opportunityToShowInAppReview()
}
})
}

private suspend fun opportunityToShowInAppReview() {
val lastInAppReviewRequest = getUserSettings().lastInAppReviewRequest
val daysSinceLastRequest = TimeUnit.MILLISECONDS.toDays(System.currentTimeMillis() - lastInAppReviewRequest)
if (daysSinceLastRequest < 7) {
finish()
return
}
updateUserSettings { it.copy(lastInAppReviewRequest = System.currentTimeMillis()) }
val manager = ReviewManagerFactory.create(this)
//val manager = FakeReviewManager(context);
val request = manager.requestReviewFlow()
request.addOnCompleteListener { task ->
if (task.isSuccessful) {
val reviewInfo = task.result
val flow = manager.launchReviewFlow(this, reviewInfo)
flow.addOnCompleteListener {}
} else {
// There was some problem, log or handle the error code.
Log.e("InAppReview", "Review task failed: ${task.exception?.message}")
private fun opportunityToShowInAppReview() {
lifecycleScope.launch {
try {
val lastInAppReviewRequest = getUserSettings().lastInAppReviewRequest
val daysSinceLastRequest = TimeUnit.MILLISECONDS.toDays(System.currentTimeMillis() - lastInAppReviewRequest)
if (daysSinceLastRequest < 7) {
finish()
return@launch
}
updateUserSettings { it.copy(lastInAppReviewRequest = System.currentTimeMillis()) }
val manager = ReviewManagerFactory.create(this@ExamActivity)
//val manager = FakeReviewManager(context);
val request = manager.requestReviewFlow()
request.addOnCompleteListener { task ->
if (task.isSuccessful) {
val reviewInfo = task.result
val flow = manager.launchReviewFlow(this@ExamActivity, reviewInfo)
flow.addOnCompleteListener {}
} else {
// There was some problem, log or handle the error code.
Log.e("InAppReview", "Review task failed: ${task.exception?.message}")
}
}
} catch (e: Exception) {
Log.e("InAppReview", "Error: ${e.message}")
finish()
}
}
}
Expand Down

0 comments on commit 162b8d7

Please sign in to comment.