Skip to content

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

Merged
merged 5 commits into from
Jun 3, 2025
Merged

Conversation

Elelan
Copy link

@Elelan Elelan commented Jun 3, 2025

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.

@Elelan Elelan requested review from Copilot and prathieshna June 3, 2025 19:39
Copy link

@Copilot Copilot AI left a 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
Copy link
Preview

Copilot AI Jun 3, 2025

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.

Suggested change
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
Copy link
Preview

Copilot AI Jun 3, 2025

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.

Suggested change
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
Copy link
Preview

Copilot AI Jun 3, 2025

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.

Suggested change
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)
Copy link
Preview

Copilot AI Jun 3, 2025

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.

Suggested change
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

Imports must be ordered in lexicographic order without any empty lines in-between with "java", "javax", "kotlin" and aliases in the end
@@ -1,5 +1,6 @@
package net.opendasharchive.openarchive.features.main

import android.app.Activity

Check warning

Code scanning / detekt

Detects unused imports Warning

Unused import
@@ -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

Unused import
@@ -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

Unused import
@@ -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

Unused import
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

Unused import
@@ -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

Unused import
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

This expression contains a magic number. Consider defining it to a well named constant.
Comment on lines +755 to +756


Check warning

Code scanning / detekt

Reports consecutive blank lines Warning

Needless blank line(s)
.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

Multiple occurrences of the same string literal within a single file detected. Prefer extracting the string literal into a property or constant.
@Elelan Elelan merged commit 5217689 into next Jun 3, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant