Rating model implementation for third-party stores - #680
Conversation
|
Thanks so much for this, @ashb155! We'll try to review it soon :) |
angrezichatterbox
left a comment
There was a problem hiding this comment.
Hey @ashb155
Thanks for the PR.
Instead of the inbuild review flow fail leading to a toast could the user be instead be redirected to the playstore page. This would be better for the user experience.
|
will work on this @angrezichatterbox! |
|
Let us know when this is ready for further review, @ashb155 :) |
|
should be good to go @andrewtavis! i guess tests are passing now |
|
Great to hear, @ashb155! Let us know how this is looking, @angrezichatterbox :) |
angrezichatterbox
left a comment
There was a problem hiding this comment.
Thanks for the quick changes @ashb155. I have a small nitpick suggestion to add on once thats done this PR would be good to go.
| @@ -63,7 +88,14 @@ object RatingHelper { | |||
| .launchReviewFlow(activity, reviewInfo) | |||
| .addOnCompleteListener { } | |||
| } else { | |||
| Toast.makeText(context, "Failed to launch review flow", Toast.LENGTH_SHORT).show() | |||
| val url = "https://play.google.com/store/apps/details?id=${context.packageName}" | |||
| val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) | |||
| try { | |||
| context.startActivity(intent) | |||
| } catch (e: ActivityNotFoundException) { | |||
| Toast.makeText(context, "No browser found to open Play Store page", Toast.LENGTH_SHORT).show() | |||
| Log.e("RatingHelper", "Unable to open Play Store link", e) | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -73,14 +105,43 @@ object RatingHelper { | |||
| val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) | |||
| try { | |||
| context.startActivity(intent) | |||
| } catch (e: PackageManager.NameNotFoundException) { | |||
| } catch (e: ActivityNotFoundException) { | |||
| Toast.makeText(context, "No browser found to open F-Droid page", Toast.LENGTH_SHORT).show() | |||
| Log.e("RatingHelper", "Unable to open F-Droid link", e) | |||
| } | |||
| } | |||
|
|
|||
| INSTALLER_AMAZON -> { | |||
| val url = "https://www.amazon.com/gp/mas/dl/android?p=${context.packageName}" | |||
| val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) | |||
| try { | |||
| context.startActivity(intent) | |||
| } catch (e: ActivityNotFoundException) { | |||
| Toast.makeText(context, "No browser found to open Amazon page", Toast.LENGTH_SHORT).show() | |||
| Log.e("RatingHelper", "Unable to open Amazon link", e) | |||
| } | |||
| } | |||
|
|
|||
| INSTALLER_SAMSUNG -> { | |||
| val url = "https://galaxystore.samsung.com/detail/${context.packageName}" | |||
| val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) | |||
| try { | |||
| context.startActivity(intent) | |||
| } catch (e: ActivityNotFoundException) { | |||
| Toast.makeText(context, "No browser found to open Galaxy Store page", Toast.LENGTH_SHORT).show() | |||
| Log.e("RatingHelper", "Unable to open Galaxy Store link", e) | |||
| } | |||
| } | |||
|
|
|||
| else -> { | |||
| Toast.makeText(context, "Unknown installation source", Toast.LENGTH_SHORT).show() | |||
| val url = "https://play.google.com/store/apps/details?id=${context.packageName}" | |||
| val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) | |||
| try { | |||
| context.startActivity(intent) | |||
| } catch (e: ActivityNotFoundException) { | |||
| Toast.makeText(context, "No browser found to open Play Store page", Toast.LENGTH_SHORT).show() | |||
| Log.e("RatingHelper", "Unable to open Play Store link", e) | |||
| } | |||
| } | |||
| } | |||
There was a problem hiding this comment.
Make this into a function and make the condtions exceution the function with the store being passed as they all do similae things.
Define all the urls at the place where all the constants are defined
Contributor checklist
./gradlew lintKotlin detekt testcommand as directed in the testing section of the contributing guideDescription
This PR expands the "Rate Us" functionality on the About Page by dynamically detecting the installation source (added
PackageManager.getInstallSourceInfomethod for Android 11+ along with existinggetInstallerPackageName()) and rendering a contextual subtitle and intent link (Google Play, F-Droid, Amazon, and Galaxy Store).Previously, the rating item only showed a generic "Rate Scribe" and lacked support for alternative app stores like Amazon and Samsung. Now, it accurately reflects where the user downloaded the app and routes them there directly.
The external store URLs are constructed dynamically using the app's package name (e.g., https://f-droid.org/packages/${context.packageName}, https://www.amazon.com/gp/mas/dl/android?p=${context.packageName}) as dummy links, which can be modified later as required.
For other third party stores, we default to Google Play Store, which again, can be modified as required.
Related issue