-
Notifications
You must be signed in to change notification settings - Fork 26
Feature/in app rating integration #676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR integrates in-app rating functionality by adding a dedicated helper for managing review flow and integrating it into the main activity.
- Introduces InAppReviewHelper to encapsulate review flow logic and counters.
- Updates MainActivity to initialize review helpers, request review info, and trigger the review prompt after a delay.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
app/src/main/java/net/opendasharchive/openarchive/util/InAppReviewHelper.kt | Implements in-app review logic and utility functions. |
app/src/main/java/net/opendasharchive/openarchive/features/main/MainActivity.kt | Integrates in-app review flow, triggering the prompt after a delay once eligibility conditions are met. |
import com.google.android.play.core.review.ReviewManager | ||
import com.google.android.play.core.review.ReviewManagerFactory | ||
import com.google.android.play.core.review.model.ReviewErrorCode | ||
import com.google.android.play.core.review.testing.FakeReviewManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the unused import 'FakeReviewManager' to reduce clutter in the production code.
import com.google.android.play.core.review.testing.FakeReviewManager |
Copilot uses AI. Check for mistakes.
@@ -16,6 +17,7 @@ import android.view.inputmethod.EditorInfo | |||
import android.view.inputmethod.InputMethodManager | |||
import android.widget.LinearLayout | |||
import android.widget.PopupWindow | |||
import android.widget.Toast |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the unused import 'android.widget.Toast' to clean up the code.
import android.widget.Toast |
Copilot uses AI. Check for mistakes.
@@ -78,6 +86,9 @@ import net.opendasharchive.openarchive.util.extensions.show | |||
import org.koin.android.ext.android.inject | |||
import org.koin.androidx.viewmodel.ext.android.viewModel | |||
import java.text.NumberFormat | |||
import androidx.core.content.edit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the unused import 'androidx.core.content.edit' as it is not required.
import androidx.core.content.edit |
Copilot uses AI. Check for mistakes.
if (shouldPromptReview) { | ||
lifecycleScope.launch(Dispatchers.Main) { | ||
// Wait a small delay so we don’t interrupt initial load (e.g. 2 seconds). | ||
delay(2_000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider extracting the delay duration (2 seconds) into a named constant for better maintainability and clarity.
delay(2_000) | |
delay(REVIEW_PROMPT_DELAY_MS) |
Copilot uses AI. Check for mistakes.
@@ -1,5 +1,6 @@ | |||
package net.opendasharchive.openarchive.features.main | |||
|
|||
import android.app.Activity |
Check warning
Code scanning / detekt
Detects imports in non default order Warning
@@ -1,5 +1,6 @@ | |||
package net.opendasharchive.openarchive.features.main | |||
|
|||
import android.app.Activity |
Check warning
Code scanning / detekt
Detects unused imports Warning
@@ -16,6 +17,7 @@ | |||
import android.view.inputmethod.InputMethodManager | |||
import android.widget.LinearLayout | |||
import android.widget.PopupWindow | |||
import android.widget.Toast |
Check warning
Code scanning / detekt
Detects unused imports Warning
@@ -27,6 +29,12 @@ | |||
import androidx.recyclerview.widget.LinearLayoutManager | |||
import androidx.viewpager2.widget.ViewPager2 | |||
import com.google.android.material.snackbar.Snackbar | |||
import com.google.android.play.core.review.ReviewException |
Check warning
Code scanning / detekt
Detects unused imports Warning
@@ -27,6 +29,12 @@ | |||
import androidx.recyclerview.widget.LinearLayoutManager | |||
import androidx.viewpager2.widget.ViewPager2 | |||
import com.google.android.material.snackbar.Snackbar | |||
import com.google.android.play.core.review.ReviewException | |||
import com.google.android.play.core.review.ReviewInfo |
Check warning
Code scanning / detekt
Detects unused imports Warning
import com.google.android.play.core.review.ReviewManager | ||
import com.google.android.play.core.review.ReviewManagerFactory | ||
import com.google.android.play.core.review.model.ReviewErrorCode | ||
import com.google.android.play.core.review.testing.FakeReviewManager |
Check warning
Code scanning / detekt
Detects unused imports Warning
@@ -78,6 +86,9 @@ | |||
import org.koin.android.ext.android.inject | |||
import org.koin.androidx.viewmodel.ext.android.viewModel | |||
import java.text.NumberFormat | |||
import androidx.core.content.edit |
Check warning
Code scanning / detekt
Detects unused imports Warning
if (shouldPromptReview) { | ||
lifecycleScope.launch(Dispatchers.Main) { | ||
// Wait a small delay so we don’t interrupt initial load (e.g. 2 seconds). | ||
delay(2_000) |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
|
||
|
Check warning
Code scanning / detekt
Reports consecutive blank lines Warning
.addOnCompleteListener { task -> | ||
if (task.isSuccessful) { | ||
reviewInfo = task.result | ||
AppLogger.d("InAppReview", "ReviewInfo obtained successfully.") |
Check warning
Code scanning / detekt
Multiple occurrences of the same string literal within a single file detected. Prefer extracting the string literal into a property or constant. Warning
The app tracks how many times it has been opened. If it’s been opened at least 5 times, and it’s been over 30 days since the last review prompt, it becomes eligible. In MainActivity, once the main screen is visible, it waits 2 seconds before showing the prompt.