Skip to content

Commit

Permalink
feat: Add website link in about section (#184)
Browse files Browse the repository at this point in the history
Signed-off-by: starry-shivam <[email protected]>
  • Loading branch information
starry-shivam authored Jun 6, 2024
1 parent 6f0bbf1 commit 5fc2cbc
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 22 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/com/starry/myne/helpers/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ object Constants {
const val DEV_TELEGRAM_URL = "https://t.me/starryboi"
const val PROJECT_CONTRIBUTORS = "https://github.com/Pool-Of-Tears/Myne/graphs/contributors"
const val GITHUB_REPO = "https://github.com/Pool-Of-Tears/Myne"
const val WEBSITE = "https://pooloftears.in"
const val PRIVACY_POLICY =
"https://github.com/Pool-Of-Tears/Myne/blob/main/legal/PRIVACY-POLICY.md"
const val GITHUB_ISSUE = "https://github.com/Pool-Of-Tears/Myne/issues/new/choose"
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/com/starry/myne/helpers/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@

package com.starry.myne.helpers

import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import com.starry.myne.R
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
Expand Down Expand Up @@ -48,6 +53,23 @@ object Utils {
}
}

/**
* Opens a web link in the default browser.
*
* @param context The context to use.
* @param url The URL to open.
*/
fun openWebLink(context: Context, url: String) {
val uri: Uri = Uri.parse(url)
val intent = Intent(Intent.ACTION_VIEW, uri)
try {
context.startActivity(intent)
} catch (exc: ActivityNotFoundException) {
exc.printStackTrace()
context.getString(R.string.error).toToast(context)
}
}

/**
* Check if the device is running on MIUI.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@

package com.starry.myne.ui.screens.settings.composables

import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.net.Uri
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
Expand All @@ -40,6 +37,7 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.Notes
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.material.icons.filled.PrivacyTip
import androidx.compose.material.icons.filled.Web
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
Expand Down Expand Up @@ -72,11 +70,11 @@ import coil.request.ImageRequest
import com.starry.myne.BuildConfig
import com.starry.myne.R
import com.starry.myne.helpers.Constants
import com.starry.myne.helpers.Utils
import com.starry.myne.ui.common.CustomTopAppBar
import com.starry.myne.ui.theme.figeronaFont


@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AboutScreen(navController: NavController) {
val context = LocalContext.current
Expand Down Expand Up @@ -121,7 +119,7 @@ fun AboutScreen(navController: NavController) {
SettingItem(ImageVector.vectorResource(id = R.drawable.ic_osi_logo),
mainText = stringResource(id = R.string.project_contributors),
subText = stringResource(id = R.string.project_contributors_desc),
onClick = { openWebLink(context, Constants.PROJECT_CONTRIBUTORS) }
onClick = { Utils.openWebLink(context, Constants.PROJECT_CONTRIBUTORS) }
)
}

Expand All @@ -144,27 +142,32 @@ fun AboutScreen(navController: NavController) {
SettingItem(icon = Icons.AutoMirrored.Filled.Notes,
mainText = stringResource(id = R.string.link_readme),
subText = stringResource(id = R.string.link_readme_desc),
onClick = { openWebLink(context, Constants.GITHUB_REPO) }
onClick = { Utils.openWebLink(context, Constants.GITHUB_REPO) }
)
SettingItem(icon = Icons.Filled.Web,
mainText = stringResource(id = R.string.link_website),
subText = stringResource(id = R.string.link_website_desc),
onClick = { Utils.openWebLink(context, Constants.WEBSITE) }
)
SettingItem(icon = Icons.Filled.PrivacyTip,
mainText = stringResource(id = R.string.link_privacy_policy),
subText = stringResource(id = R.string.link_privacy_policy_desc),
onClick = { openWebLink(context, Constants.PRIVACY_POLICY) }
onClick = { Utils.openWebLink(context, Constants.PRIVACY_POLICY) }
)
SettingItem(icon = ImageVector.vectorResource(id = R.drawable.ic_github_logo),
mainText = stringResource(id = R.string.link_gh_issue),
subText = stringResource(id = R.string.link_gh_issue_desc),
onClick = { openWebLink(context, Constants.GITHUB_ISSUE) }
onClick = { Utils.openWebLink(context, Constants.GITHUB_ISSUE) }
)
SettingItem(ImageVector.vectorResource(id = R.drawable.ic_telegram_logo),
mainText = stringResource(id = R.string.link_telegram),
subText = stringResource(id = R.string.link_telegram_desc),
onClick = { openWebLink(context, Constants.TELEGRAM_GROUP) }
onClick = { Utils.openWebLink(context, Constants.TELEGRAM_GROUP) }
)
SettingItem(icon = Icons.Filled.Favorite,
mainText = stringResource(id = R.string.link_support),
subText = stringResource(id = R.string.link_support_desc),
onClick = { openWebLink(context, Constants.SUPPORT) }
onClick = { Utils.openWebLink(context, Constants.SUPPORT) }
)
}

Expand Down Expand Up @@ -353,31 +356,21 @@ private fun DeveloperCard(context: Context) {
text = "Github",
icon = ImageVector.vectorResource(id = R.drawable.ic_github_logo)
) {
openWebLink(context, Constants.DEV_GITHUB_URL)
Utils.openWebLink(context, Constants.DEV_GITHUB_URL)
}

LinkButton(
text = "Telegram",
icon = ImageVector.vectorResource(id = R.drawable.ic_telegram_logo)
) {
openWebLink(context, Constants.DEV_TELEGRAM_URL)
Utils.openWebLink(context, Constants.DEV_TELEGRAM_URL)
}
}
}
}
}
}

private fun openWebLink(context: Context, url: String) {
val uri: Uri = Uri.parse(url)
val intent = Intent(Intent.ACTION_VIEW, uri)
try {
context.startActivity(intent)
} catch (exc: ActivityNotFoundException) {
exc.printStackTrace()
}
}

@ExperimentalMaterial3Api
@Composable
@Preview(showBackground = true)
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@
<string name="useful_links">روابط مفيدة</string>
<string name="link_readme">README</string>
<string name="link_readme_desc">تفقد README للتطبيق على Github.</string>
<string name="link_website">الموقع الإلكتروني</string>
<string name="link_website_desc">قم بزيارة موقعنا الإلكتروني لمزيد من المعلومات.</string>
<string name="link_privacy_policy">سياسة الخصوصية</string>
<string name="link_privacy_policy_desc">اقرأ سياسة الخصوصية الأخيرة لدينا.</string>
<string name="link_gh_issue">مشاكل Github</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
<string name="useful_links">Užitečné odkazy</string>
<string name="link_readme">README</string>
<string name="link_readme_desc">Zkontrolujte README aplikace na Githubu.</string>
<string name="link_website">Webová stránka</string>
<string name="link_website_desc">Navštivte naše webové stránky pro více informací.</string>
<string name="link_privacy_policy">Zásady ochrany osobních údajů</string>
<string name="link_privacy_policy_desc">Přečtěte si naše nejnovější zásady ochrany osobních údajů.</string>
<string name="link_gh_issue">Problémy na Githubu</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@
<string name="useful_links">Nützliche Links</string>
<string name="link_readme">README</string>
<string name="link_readme_desc">Schauen Sie sich das README der App auf Github an.</string>
<string name="link_website">Webseite</string>
<string name="link_website_desc">Besuchen Sie unsere Webseite für weitere Informationen.</string>
<string name="link_privacy_policy">Datenschutzrichtlinie</string>
<string name="link_privacy_policy_desc">Lesen Sie unsere neueste Datenschutzrichtlinie.</string>
<string name="link_gh_issue">Github-Probleme</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@
<string name="useful_links">Nützliche Links</string>
<string name="link_readme">README</string>
<string name="link_readme_desc">Schauen Sie sich das README der App auf Github an.</string>
<string name="link_website">Sitio web</string>
<string name="link_website_desc">Visite nuestro sitio web para más información.</string>
<string name="link_privacy_policy">Datenschutzrichtlinie</string>
<string name="link_privacy_policy_desc">Lesen Sie unsere neueste Datenschutzrichtlinie.</string>
<string name="link_gh_issue">Github-Probleme</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@
<string name="useful_links">Link Utili</string>
<string name="link_readme">README</string>
<string name="link_readme_desc">Consulta il README dell\'app su Github.</string>
<string name="link_website">Sito web</string>
<string name="link_website_desc">Visita il nostro sito web per maggiori informazioni.</string>
<string name="link_privacy_policy">Informativa sulla Privacy</string>
<string name="link_privacy_policy_desc">Leggi la nostra ultima informativa sulla privacy.</string>
<string name="link_gh_issue">Problemi Github</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@
<string name="useful_links">Link Utili</string>
<string name="link_readme">README</string>
<string name="link_readme_desc">Consulta il README dell\'app su Github.</string>
<string name="link_website">Site</string>
<string name="link_website_desc">Visite nosso site para mais informações.</string>
<string name="link_privacy_policy">Informativa sulla Privacy</string>
<string name="link_privacy_policy_desc">Leggi la nostra última informativa sulla privacy.</string>
<string name="link_gh_issue">Problemi Github</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ro/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@
<string name="useful_links">Link-uri Utile</string>
<string name="link_readme">README</string>
<string name="link_readme_desc">Consultă README-ul aplicației pe Github.</string>
<string name="link_website">Site web</string>
<string name="link_website_desc">Vizitați site-ul nostru pentru mai multe informații.</string>
<string name="link_privacy_policy">Politica de Confidențialitate</string>
<string name="link_privacy_policy_desc">Citește ultima noastră politică de confidențialitate.</string>
<string name="link_gh_issue">Probleme Github</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@
<string name="useful_links">Полезные Ссылки</string>
<string name="link_readme">README</string>
<string name="link_readme_desc">Информация о проекте на Github.</string>
<string name="link_website">Веб-сайт</string>
<string name="link_website_desc">Посетите наш веб-сайт для получения дополнительной информации.</string>
<string name="link_privacy_policy">Политика Конфиденциальности</string>
<string name="link_privacy_policy_desc">Прочтите нашу последнюю политику конфиденциальности.</string>
<string name="link_gh_issue">Темы на Github</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@
<string name="useful_links">有用链接</string>
<string name="link_readme">自述文件</string>
<string name="link_readme_desc">在Github上查看应用的自述文件。</string>
<string name="link_website">网站</string>
<string name="link_website_desc">访问我们的网站以获取更多信息。</string>
<string name="link_privacy_policy">隐私政策</string>
<string name="link_privacy_policy_desc">阅读我们的最新隐私政策。</string>
<string name="link_gh_issue">Github问题</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@
<string name="useful_links">Useful Links</string>
<string name="link_readme">README</string>
<string name="link_readme_desc">Checkout app\'s README on Github.</string>
<string name="link_website">Website</string>
<string name="link_website_desc">Visit our website for more information.</string>
<string name="link_privacy_policy">Privacy Policy</string>
<string name="link_privacy_policy_desc">Read our latest privacy policy.</string>
<string name="link_gh_issue">Github Issues</string>
Expand Down

0 comments on commit 5fc2cbc

Please sign in to comment.