-
Notifications
You must be signed in to change notification settings - Fork 1
[LLM] feat: Implement 'About' Section via Bottom Tab & License Collection #157
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| package com.anysoftkeyboard.janus.app.ui | ||
|
|
||
| import android.content.Context | ||
| import android.content.Intent | ||
| import android.net.Uri | ||
| import androidx.compose.foundation.BorderStroke | ||
| import androidx.compose.foundation.clickable | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.Spacer | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.size | ||
| import androidx.compose.foundation.rememberScrollState | ||
| import androidx.compose.foundation.verticalScroll | ||
| import androidx.compose.material.icons.Icons | ||
| import androidx.compose.material.icons.automirrored.filled.ArrowForward | ||
| import androidx.compose.material3.ButtonDefaults | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.material3.OutlinedButton | ||
| import androidx.compose.material3.Scaffold | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.platform.LocalContext | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.text.style.TextAlign | ||
| import androidx.compose.ui.unit.dp | ||
| import com.anysoftkeyboard.janus.app.BuildConfig | ||
| import com.anysoftkeyboard.janus.app.R | ||
| import com.google.android.gms.oss.licenses.OssLicensesMenuActivity | ||
|
|
||
| /** | ||
| * About screen displaying application information, explanation of the unique translation mechanism | ||
| * (The Colophon), links to GitHub repository and issue tracker, and the open-source licenses | ||
| * attribution page. | ||
| */ | ||
| @Composable | ||
| fun AboutScreen(modifier: Modifier = Modifier) { | ||
| val context = LocalContext.current | ||
| val scrollState = rememberScrollState() | ||
|
|
||
| Scaffold(modifier = modifier) { paddingValues -> | ||
| Column( | ||
| modifier = | ||
| Modifier.fillMaxSize() | ||
| .verticalScroll(scrollState) | ||
| .padding(paddingValues) | ||
| .padding(horizontal = 24.dp, vertical = 24.dp), | ||
| horizontalAlignment = Alignment.CenterHorizontally, | ||
| ) { | ||
| // 1. Header | ||
| Icon( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Maintenance] The Icon component uses a tint on a mipmap resource (ic_launcher_foreground). This matches the monochromatic design goal but is fragile for bitmaps. Consider using a dedicated vector or setting tint to Color.Unspecified. |
||
| painter = painterResource(R.mipmap.ic_launcher_foreground), | ||
| contentDescription = null, | ||
| modifier = Modifier.size(96.dp), | ||
| tint = MaterialTheme.colorScheme.primary, | ||
| ) | ||
| Spacer(modifier = Modifier.height(12.dp)) | ||
| Text( | ||
| text = stringResource(R.string.about_title), | ||
| style = MaterialTheme.typography.headlineMedium, | ||
| color = MaterialTheme.colorScheme.onSurface, | ||
| ) | ||
| Spacer(modifier = Modifier.height(4.dp)) | ||
| Text( | ||
| text = stringResource(R.string.about_version, BuildConfig.VERSION_NAME), | ||
| style = MaterialTheme.typography.labelLarge, | ||
| color = MaterialTheme.colorScheme.secondary, | ||
| ) | ||
| Spacer(modifier = Modifier.height(28.dp)) | ||
|
|
||
| // 2. Abstract | ||
| Text( | ||
| text = stringResource(R.string.about_abstract), | ||
| style = MaterialTheme.typography.bodyLarge, | ||
| color = MaterialTheme.colorScheme.onSurface, | ||
| textAlign = TextAlign.Center, | ||
| ) | ||
| Spacer(modifier = Modifier.height(28.dp)) | ||
|
|
||
| // 3. Methodology | ||
| Text( | ||
| text = stringResource(R.string.about_methodology_title), | ||
| style = MaterialTheme.typography.titleMedium, | ||
| color = MaterialTheme.colorScheme.primary, | ||
| modifier = Modifier.align(Alignment.Start), | ||
| ) | ||
| Spacer(modifier = Modifier.height(8.dp)) | ||
| Text( | ||
| text = stringResource(R.string.about_methodology_text), | ||
| style = MaterialTheme.typography.bodyMedium, | ||
| color = MaterialTheme.colorScheme.onSurface, | ||
| modifier = Modifier.align(Alignment.Start), | ||
| ) | ||
| Spacer(modifier = Modifier.height(28.dp)) | ||
|
|
||
| // 4. References | ||
| ReferenceLinkRow( | ||
| label = stringResource(R.string.about_link_source_code), | ||
| url = "https://github.com/AnySoftKeyboard/janus", | ||
| context = context, | ||
| ) | ||
| Spacer(modifier = Modifier.height(4.dp)) | ||
| ReferenceLinkRow( | ||
| label = stringResource(R.string.about_link_issue_tracker), | ||
| url = "https://github.com/AnySoftKeyboard/janus/issues", | ||
| context = context, | ||
| ) | ||
| Spacer(modifier = Modifier.height(28.dp)) | ||
|
|
||
| // 5. Attributions | ||
| OutlinedButton( | ||
| onClick = { context.startActivity(Intent(context, OssLicensesMenuActivity::class.java)) }, | ||
| colors = | ||
| ButtonDefaults.outlinedButtonColors( | ||
| contentColor = MaterialTheme.colorScheme.secondary | ||
| ), | ||
| border = BorderStroke(1.dp, MaterialTheme.colorScheme.secondary), | ||
| modifier = Modifier.fillMaxWidth(), | ||
| ) { | ||
| Text( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Risk] The startActivity call for OssLicensesMenuActivity is not protected. Any failure to resolve the class or launch the intent will result in a crash. This should be wrapped in a try-catch block to handle ActivityNotFoundException. |
||
| text = stringResource(R.string.about_button_licenses), | ||
| style = MaterialTheme.typography.labelLarge, | ||
| ) | ||
| } | ||
| Spacer(modifier = Modifier.height(16.dp)) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun ReferenceLinkRow( | ||
| label: String, | ||
| url: String, | ||
| context: Context, | ||
| modifier: Modifier = Modifier, | ||
| ) { | ||
| Row( | ||
| modifier = | ||
| modifier | ||
| .fillMaxWidth() | ||
| .clickable { | ||
| val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) | ||
| context.startActivity(intent) | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Risk] Launching an external browser using ACTION_VIEW can throw an ActivityNotFoundException on devices without a browser. This call must be protected to ensure system stability. |
||
| .padding(vertical = 12.dp), | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| ) { | ||
| Text( | ||
| text = label, | ||
| style = MaterialTheme.typography.bodyLarge, | ||
| color = MaterialTheme.colorScheme.primary, | ||
| modifier = Modifier.weight(1f), | ||
| ) | ||
| Icon( | ||
| imageVector = Icons.AutoMirrored.Filled.ArrowForward, | ||
| contentDescription = null, | ||
| tint = MaterialTheme.colorScheme.secondary, | ||
| modifier = Modifier.size(20.dp), | ||
| ) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,4 +121,16 @@ | |
| <!-- Detection Failed --> | ||
| <string name="error_detection_failed_title">لغة غير معروفة</string> | ||
| <string name="error_detection_failed_message">تعذر اكتشاف لغة النص المُدخل.</string> | ||
|
|
||
| <!-- About screen --> | ||
| <string name="tab_about">حول</string> | ||
| <string name="about_title">Janus Glossa</string> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Observation] The version string in Arabic (إصدار %1$s) omits the 'v' prefix used in other locales. Consider if strict consistency across languages is required. |
||
| <string name="about_version">إصدار %1$s</string> | ||
| <string name="about_abstract">Janus Glossa هي أداة مفتوحة المصدر مصممة لترجمة المفاهيم داخل سياقها، باستخدام المعرفة الجماعية لـ ويكيبيديا.</string> | ||
| <string name="about_methodology_title">كيف يعمل</string> | ||
| <string name="about_methodology_text">على عكس القواميس القياسية، يقوم Janus Glossa بمحاذاة المفاهيم. فهو يبحث عن إدخال الموسوعة لمصطلحك، ثم يتبع الرابط بين اللغات إلى اللغة المستهدفة لتقديم ترجمة دقيقة ومناسبة للسياق.</string> | ||
| <string name="about_link_source_code">كود المصدر</string> | ||
| <string name="about_link_issue_tracker">متتبع المشكلات</string> | ||
| <string name="about_button_licenses">تراخيص البرمجيات مفتوحة المصدر</string> | ||
| <string name="content_description_about">حول Janus Glossa</string> | ||
| </resources> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,4 +136,16 @@ | |
| <!-- Detection Failed --> | ||
| <string name="error_detection_failed_title">Language Unknown</string> | ||
| <string name="error_detection_failed_message">Could not detect the language of the input text.</string> | ||
|
|
||
| <!-- About screen --> | ||
| <string name="tab_about">About</string> | ||
| <string name="about_title">Janus Glossa</string> | ||
| <string name="about_version">v%1$s</string> | ||
| <string name="about_abstract">Janus Glossa is an open-source tool designed to translate concepts within their context, utilizing the crowd-sourced knowledge of Wikipedia.</string> | ||
| <string name="about_methodology_title">How it works</string> | ||
| <string name="about_methodology_text">Unlike standard dictionaries, Janus Glossa aligns concepts. It finds the encyclopedia entry for your term, then follows the inter-language link to the target language to provide a precise, context-aware translation.</string> | ||
| <string name="about_link_source_code">Source Code</string> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Observation] The string content_description_about is defined but remains unused. It should be applied to the app icon in the AboutScreen header or the tab icon to improve accessibility. |
||
| <string name="about_link_issue_tracker">Issue Tracker</string> | ||
| <string name="about_button_licenses">Open Source Licenses</string> | ||
| <string name="content_description_about">About Janus Glossa</string> | ||
| </resources> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| package com.anysoftkeyboard.janus.app | ||
|
|
||
| import android.content.Intent | ||
| import androidx.compose.material.icons.filled.Info | ||
| import androidx.test.core.app.ActivityScenario | ||
| import androidx.test.core.app.ApplicationProvider | ||
| import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
|
@@ -17,6 +18,7 @@ import dagger.hilt.android.testing.HiltTestApplication | |
| import dagger.hilt.android.testing.UninstallModules | ||
| import kotlinx.coroutines.flow.MutableStateFlow | ||
| import kotlinx.coroutines.test.runTest | ||
| import org.junit.Assert.assertEquals | ||
| import org.junit.Before | ||
| import org.junit.Rule | ||
| import org.junit.Test | ||
|
|
@@ -65,6 +67,14 @@ class MainActivityTest { | |
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun testTabScreenAbout_isCorrectlyConfigured() { | ||
| val aboutTab = TabScreen.About | ||
| assertEquals("about", aboutTab.route) | ||
| assertEquals(R.string.tab_about, aboutTab.titleRes) | ||
| assertEquals(androidx.compose.material.icons.Icons.Default.Info, aboutTab.icon) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Maintenance] The test uses a full package name inline: androidx.compose.material.icons.Icons.Default.Info. Per guidelines, use imports instead. |
||
| } | ||
|
|
||
| @Test | ||
| fun startMainActivity_withoutProcessText_doesNotSearch() = runTest { | ||
| val intent = Intent(ApplicationProvider.getApplicationContext(), MainActivity::class.java) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Observation] The AboutScreen uses a nested Scaffold. Ensure that it doesn't cause conflicting inset handling with the Scaffold in JanusApp. It appears safe here as the inner Scaffold has no bars.