Skip to content
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

Add share app and rate app functionalities with custom message and app link #134

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.canopas.yourspace.ui.flow.settings

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import androidx.compose.foundation.Image
Expand Down Expand Up @@ -186,6 +187,18 @@ private fun OtherSettingsContent(viewModel: SettingsViewModel) {
}
)

SettingsItem(
label = stringResource(id = R.string.setting_share_app),
icon = R.drawable.ic_setting_share_icon,
onClick = { shareApp(context) }
)

SettingsItem(
label = stringResource(id = R.string.setting_rate_app),
icon = R.drawable.ic_setting_rate_icon,
onClick = { rateApp(context) }
)

SettingsItem(
label = stringResource(id = R.string.setting_btn_sign_out),
icon = R.drawable.ic_setting_sign_out_icon,
Expand All @@ -202,6 +215,29 @@ private fun openUrl(context: Activity, url: String) {
context.startActivity(intent)
}

fun shareApp(context: Context) {
val appUrl = "https://play.google.com/store/apps/details?id=${context.packageName}"
val shareMessage = context.getString(R.string.app_share_message, appUrl)

val shareIntent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, shareMessage)
type = "text/plain"
}
context.startActivity(
Intent.createChooser(
shareIntent,
context.getString(R.string.setting_share_app)
)
)
}

fun rateApp(context: Context) {
val appUrl = "https://play.google.com/store/apps/details?id=${context.packageName}"
val rateIntent = Intent(Intent.ACTION_VIEW, Uri.parse(appUrl))
context.startActivity(rateIntent)
}

@Composable
private fun SpaceSettingsContent(
spaces: List<ApiSpace>,
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/ic_setting_rate_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,17.27L18.18,21L16.54,13.97L22,9.24L14.81,8.63L12,2L9.19,8.63L2,9.24L7.46,13.97L5.82,21L12,17.27Z"
android:strokeWidth="1"
android:strokeColor="#000000"
android:strokeLineJoin="round" />
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_setting_share_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M18,16.08C17.24,16.08 16.56,16.38 16.05,16.88L8.91,12.7C8.96,12.47 9,12.24 9,12C9,11.76 8.96,11.53 8.91,11.3L15.95,7.12C16.46,7.62 17.24,7.92 18,7.92C19.66,7.92 21,6.58 21,4.92C21,3.26 19.66,1.92 18,1.92C16.34,1.92 15,3.26 15,4.92C15,5.16 15.04,5.39 15.09,5.62L8.05,9.8C7.54,9.3 6.76,9 6,9C4.34,9 3,10.34 3,12C3,13.66 4.34,15 6,15C6.76,15 7.54,14.7 8.05,14.2L15.09,18.38C15.04,18.61 15,18.84 15,19.08C15,20.74 16.34,22.08 18,22.08C19.66,22.08 21,20.74 21,19.08C21,17.42 19.66,16.08 18,16.08Z"
android:strokeWidth="0.8"
android:strokeColor="#000000"/>
</vector>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@
<string name="setting_privacy">Privacy Policy</string>
<string name="setting_about_us">About Us</string>
<string name="setting_app_version">App version: %s</string>
<string name="setting_share_app">Share app</string>
<string name="setting_rate_app">Rate us</string>
<string name="app_share_message">Check out GroupTrack - the best app to stay connected with your loved ones! Download now: %1$s</string>

<string name="edit_profile_title">Edit profile</string>
<string name="edit_profile_toolbar_save_text">Save</string>
Expand Down
Loading