Skip to content

Commit

Permalink
Implement EmailFeedbackButton
Browse files Browse the repository at this point in the history
  • Loading branch information
bingzheung committed Feb 22, 2025
1 parent 60a377c commit 78742d7
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 19 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ android {
}
}

val composeVersion = "1.7.6"
val composeVersion = "1.7.8"
dependencies {
implementation("androidx.activity:activity-compose:1.10.0")
implementation("androidx.activity:activity-ktx:1.10.0")
Expand All @@ -62,7 +62,7 @@ dependencies {
implementation("androidx.core:core-ktx:1.15.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7")
implementation("androidx.lifecycle:lifecycle-service:2.8.7")
implementation("androidx.navigation:navigation-compose:2.8.5")
implementation("androidx.navigation:navigation-compose:2.8.7")
implementation("com.louiscad.splitties:splitties-systemservices:3.0.0")
implementation("com.louiscad.splitties:splitties-views:3.0.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package org.jyutping.jyutping.mainapp.about

import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.util.Log
import android.widget.Toast
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.selection.SelectionContainer
Expand All @@ -17,6 +25,8 @@ import androidx.compose.material.icons.outlined.AlternateEmail
import androidx.compose.material.icons.outlined.CenterFocusStrong
import androidx.compose.material.icons.outlined.CheckCircle
import androidx.compose.material.icons.outlined.Code
import androidx.compose.material.icons.outlined.Edit
import androidx.compose.material.icons.outlined.Email
import androidx.compose.material.icons.outlined.Group
import androidx.compose.material.icons.outlined.Info
import androidx.compose.material.icons.outlined.Link
Expand All @@ -28,11 +38,14 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import org.jyutping.jyutping.BuildConfig
import org.jyutping.jyutping.R
import org.jyutping.jyutping.presets.PresetConstant
import org.jyutping.jyutping.ui.common.AppLinkLabel
import org.jyutping.jyutping.ui.common.WebLinkLabel
import org.jyutping.jyutping.utilities.AppMaster
Expand Down Expand Up @@ -95,9 +108,8 @@ fun AboutScreen() {
WebLinkLabel(icon = Icons.Outlined.CheckCircle, text = stringResource(id = R.string.about_label_google_forms), uri = AppMaster.GoogleFormsAddress)
HorizontalDivider()
WebLinkLabel(icon = Icons.Outlined.CheckCircle, text = stringResource(id = R.string.about_label_tencent_survey), uri = AppMaster.TencentSurveyAddress)

// TODO: Implement mailto
// OpenAppLabel(icon = Icons.Outlined.Mail, text = stringResource(id = R.string.about_label_email), uri = AppMaster.EmailAddress)
HorizontalDivider()
EmailFeedbackButton()
}
}
}
Expand Down Expand Up @@ -133,3 +145,59 @@ private fun VersionLabel() {
}
}
}

@Composable
private fun EmailFeedbackButton() {
val context = LocalContext.current
Row(
modifier = Modifier
.fillMaxWidth()
.background(color = colorScheme.background)
.clickable {
val appVersion: String = BuildConfig.VERSION_NAME // 0.1.0
val appBuildNumber: Int = BuildConfig.VERSION_CODE // 23
val androidVersion: String = Build.VERSION.RELEASE // 15
val sdkVersion: Int = Build.VERSION.SDK_INT // 35
val deviceModel: String = Build.MODEL // Pixel 9 Pro XL
val manufacturer: String = Build.MANUFACTURER // Google
val information: String = """
App Version: $appVersion ($appBuildNumber)
Android Version: $androidVersion (API ${sdkVersion})
Device: $manufacturer $deviceModel
""".trimIndent()
val intent = Intent(Intent.ACTION_SENDTO).apply {
data = Uri.parse("mailto:")
putExtra(Intent.EXTRA_EMAIL, arrayOf(AppMaster.EmailAddress))
putExtra(Intent.EXTRA_SUBJECT, "Jyutping Feedback")
putExtra(Intent.EXTRA_TEXT, "\n\n${information}")
}
try {
context.startActivity(intent)
} catch (e: ActivityNotFoundException) {
val logTag: String = PresetConstant.keyboardPackageName + ".about"
e.message?.let { Log.i(logTag, it) }
Toast.makeText(context, "Email Unavailable", Toast.LENGTH_LONG).show()
}
}
.padding(8.dp),
horizontalArrangement = Arrangement.spacedBy(16.dp),
verticalAlignment = Alignment.CenterVertically
) {
Icon(
imageVector = Icons.Outlined.Email,
contentDescription = null,
tint = colorScheme.onBackground
)
Text(
text = stringResource(id = R.string.about_label_email),
color = colorScheme.onBackground
)
Spacer(modifier = Modifier.weight(1.0f))
Icon(
imageVector = Icons.Outlined.Edit,
contentDescription = null,
modifier = Modifier.size(18.dp).alpha(0.75f),
tint = colorScheme.onBackground
)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jyutping.jyutping.utilities

@Suppress("ConstPropertyName")
object AppMaster {
const val websiteAddress: String = "https://jyutping.app"
const val sourceCodeAddress: String = "https://github.com/yuetyam/jyutping-android"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-b+yue+Hant+CN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<string name="cantonese_label_confusion">簡化字常見混亂</string>
<string name="cantonese_screen_title_confusion">簡化字常見混亂</string>
<string name="about_label_version">版本</string>
<string name="about_label_website">網棧</string>
<string name="about_label_website">官網</string>
<string name="about_label_source_code">源碼</string>
<string name="about_label_privacy_policy">私隱政策</string>
<string name="about_label_faq">常問問題(FAQ)</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-b+yue+Hant+HK/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<string name="cantonese_label_confusion">簡化字常見混亂</string>
<string name="cantonese_screen_title_confusion">簡化字常見混亂</string>
<string name="about_label_version">版本</string>
<string name="about_label_website">網棧</string>
<string name="about_label_website">官網</string>
<string name="about_label_source_code">源碼</string>
<string name="about_label_privacy_policy">私隱政策</string>
<string name="about_label_faq">常問問題(FAQ)</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-b+yue+Hant+MO/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<string name="cantonese_label_confusion">簡化字常見混亂</string>
<string name="cantonese_screen_title_confusion">簡化字常見混亂</string>
<string name="about_label_version">版本</string>
<string name="about_label_website">網棧</string>
<string name="about_label_website">官網</string>
<string name="about_label_source_code">源碼</string>
<string name="about_label_privacy_policy">私隱政策</string>
<string name="about_label_faq">常問問題(FAQ)</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-b+yue+Hant/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<string name="cantonese_label_confusion">簡化字常見混亂</string>
<string name="cantonese_screen_title_confusion">簡化字常見混亂</string>
<string name="about_label_version">版本</string>
<string name="about_label_website">網棧</string>
<string name="about_label_website">官網</string>
<string name="about_label_source_code">源碼</string>
<string name="about_label_privacy_policy">私隱政策</string>
<string name="about_label_faq">常問問題(FAQ)</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-b+yue/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<string name="cantonese_label_confusion">簡化字常見混亂</string>
<string name="cantonese_screen_title_confusion">簡化字常見混亂</string>
<string name="about_label_version">版本</string>
<string name="about_label_website">網棧</string>
<string name="about_label_website">官網</string>
<string name="about_label_source_code">源碼</string>
<string name="about_label_privacy_policy">私隱政策</string>
<string name="about_label_faq">常問問題(FAQ)</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-b+zh+Hans+CN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<string name="cantonese_label_confusion">簡化字常見混亂</string>
<string name="cantonese_screen_title_confusion">簡化字常見混亂</string>
<string name="about_label_version">版本</string>
<string name="about_label_website">網棧</string>
<string name="about_label_website">官網</string>
<string name="about_label_source_code">源碼</string>
<string name="about_label_privacy_policy">私隱政策</string>
<string name="about_label_faq">常問問題(FAQ)</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-b+zh+Hans/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<string name="cantonese_label_confusion">簡化字常見混亂</string>
<string name="cantonese_screen_title_confusion">簡化字常見混亂</string>
<string name="about_label_version">版本</string>
<string name="about_label_website">網棧</string>
<string name="about_label_website">官網</string>
<string name="about_label_source_code">源碼</string>
<string name="about_label_privacy_policy">私隱政策</string>
<string name="about_label_faq">常問問題(FAQ)</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-b+zh+Hant+CN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<string name="cantonese_label_confusion">簡化字常見混亂</string>
<string name="cantonese_screen_title_confusion">簡化字常見混亂</string>
<string name="about_label_version">版本</string>
<string name="about_label_website">網棧</string>
<string name="about_label_website">官網</string>
<string name="about_label_source_code">源碼</string>
<string name="about_label_privacy_policy">私隱政策</string>
<string name="about_label_faq">常問問題(FAQ)</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-b+zh+Hant+HK/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<string name="cantonese_label_confusion">簡化字常見混亂</string>
<string name="cantonese_screen_title_confusion">簡化字常見混亂</string>
<string name="about_label_version">版本</string>
<string name="about_label_website">網棧</string>
<string name="about_label_website">官網</string>
<string name="about_label_source_code">源碼</string>
<string name="about_label_privacy_policy">私隱政策</string>
<string name="about_label_faq">常問問題(FAQ)</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-b+zh+Hant+MO/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<string name="cantonese_label_confusion">簡化字常見混亂</string>
<string name="cantonese_screen_title_confusion">簡化字常見混亂</string>
<string name="about_label_version">版本</string>
<string name="about_label_website">網棧</string>
<string name="about_label_website">官網</string>
<string name="about_label_source_code">源碼</string>
<string name="about_label_privacy_policy">私隱政策</string>
<string name="about_label_faq">常問問題(FAQ)</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-b+zh+Hant+TW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<string name="cantonese_label_confusion">簡化字常見混亂</string>
<string name="cantonese_screen_title_confusion">簡化字常見混亂</string>
<string name="about_label_version">版本</string>
<string name="about_label_website">網棧</string>
<string name="about_label_website">官網</string>
<string name="about_label_source_code">源碼</string>
<string name="about_label_privacy_policy">私隱政策</string>
<string name="about_label_faq">常問問題(FAQ)</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-b+zh+Hant/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<string name="cantonese_label_confusion">簡化字常見混亂</string>
<string name="cantonese_screen_title_confusion">簡化字常見混亂</string>
<string name="about_label_version">版本</string>
<string name="about_label_website">網棧</string>
<string name="about_label_website">官網</string>
<string name="about_label_source_code">源碼</string>
<string name="about_label_privacy_policy">私隱政策</string>
<string name="about_label_faq">常問問題(FAQ)</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-b+zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<string name="cantonese_label_confusion">簡化字常見混亂</string>
<string name="cantonese_screen_title_confusion">簡化字常見混亂</string>
<string name="about_label_version">版本</string>
<string name="about_label_website">網棧</string>
<string name="about_label_website">官網</string>
<string name="about_label_source_code">源碼</string>
<string name="about_label_privacy_policy">私隱政策</string>
<string name="about_label_faq">常問問題(FAQ)</string>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("com.android.application") version "8.8.0" apply false
id("com.android.application") version "8.8.1" apply false
id("org.jetbrains.kotlin.android") version "2.0.21" apply false
id("org.jetbrains.kotlin.plugin.compose") version "2.0.21" apply false
id("org.jetbrains.kotlin.plugin.serialization") version "2.0.21" apply false
Expand Down

0 comments on commit 78742d7

Please sign in to comment.