Skip to content

Commit 16bc1a9

Browse files
committed
refactor(AboutFragment): convert librariesTitle MaterialTextView and forum related MaterialTextViews to ComposeView
1 parent b017487 commit 16bc1a9

File tree

2 files changed

+72
-27
lines changed

2 files changed

+72
-27
lines changed

legacy/ui/legacy/src/main/java/com/fsck/k9/ui/settings/AboutFragment.kt

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ import androidx.compose.foundation.layout.fillMaxWidth
1616
import androidx.compose.foundation.layout.padding
1717
import androidx.compose.foundation.layout.size
1818
import androidx.compose.foundation.layout.wrapContentHeight
19-
import androidx.compose.foundation.layout.wrapContentWidth
2019
import androidx.compose.runtime.remember
2120
import androidx.compose.ui.Modifier
2221
import androidx.compose.ui.platform.ComposeView
2322
import androidx.compose.ui.platform.LocalContext
2423
import androidx.compose.ui.res.painterResource
25-
import androidx.compose.ui.text.style.TextAlign
2624
import androidx.compose.ui.unit.dp
2725
import androidx.fragment.app.Fragment
2826
import androidx.navigation.fragment.findNavController
@@ -73,21 +71,27 @@ class AboutFragment : Fragment() {
7371

7472
setVersionText(view)
7573

76-
setAuthorsText(view)
74+
setAuthorsLabel(view)
7775

7876
setAuthorOne(view)
7977

8078
setAuthorTwo(view)
8179

82-
setLicenseText(view)
80+
setLicenseLabel(view)
8381

84-
setLicense(view)
82+
setLicenseText(view)
8583

8684
setAboutProjectTitle(view)
8785

86+
setWebsiteLabel(view)
87+
8888
setWebsiteText(view)
8989

90-
setWebsite(view)
90+
setForumLabel(view)
91+
92+
setForumText(view)
93+
94+
setLibrariesTitle(view)
9195

9296
val versionLayout = view.findViewById<View>(R.id.versionLayout)
9397
versionLayout.setOnClickListener { displayChangeLog() }
@@ -213,7 +217,7 @@ class AboutFragment : Fragment() {
213217
themeProvider.WithTheme {
214218
val context = LocalContext.current
215219
TextTitleSmall(
216-
text = context.getString(R.string.about_title,appNameProvider.appName),
220+
text = context.getString(R.string.about_title, appNameProvider.appName),
217221
modifier = Modifier
218222
.fillMaxWidth()
219223
.padding(
@@ -222,7 +226,7 @@ class AboutFragment : Fragment() {
222226
top = 16.dp,
223227
bottom = 8.dp,
224228
),
225-
color = MainTheme.colors.secondary
229+
color = MainTheme.colors.secondary,
226230
)
227231
}
228232
}
@@ -259,7 +263,7 @@ class AboutFragment : Fragment() {
259263
}
260264
}
261265

262-
private fun setAuthorsText(view: View) {
266+
private fun setAuthorsLabel(view: View) {
263267
val authorsLabel = view.findViewById<ComposeView>(R.id.authorsLabel)
264268
authorsLabel.setContent {
265269
val context = LocalContext.current
@@ -307,7 +311,7 @@ class AboutFragment : Fragment() {
307311
}
308312
}
309313

310-
private fun setLicenseText(view: View) {
314+
private fun setLicenseLabel(view: View) {
311315
val licenseLabel = view.findViewById<ComposeView>(R.id.licenseLabel)
312316
licenseLabel.setContent {
313317
val context = LocalContext.current
@@ -323,7 +327,7 @@ class AboutFragment : Fragment() {
323327
}
324328
}
325329

326-
private fun setLicense(view: View) {
330+
private fun setLicenseText(view: View) {
327331
val license = view.findViewById<ComposeView>(R.id.license)
328332
license.setContent {
329333
val context = LocalContext.current
@@ -356,7 +360,7 @@ class AboutFragment : Fragment() {
356360
}
357361
}
358362

359-
private fun setWebsiteText(view: View) {
363+
private fun setWebsiteLabel(view: View) {
360364
val websiteLabel = view.findViewById<ComposeView>(R.id.websiteLabel)
361365
websiteLabel.setContent {
362366
val context = LocalContext.current
@@ -372,7 +376,7 @@ class AboutFragment : Fragment() {
372376
}
373377
}
374378

375-
private fun setWebsite(view: View) {
379+
private fun setWebsiteText(view: View) {
376380
val website = view.findViewById<ComposeView>(R.id.website)
377381
website.setContent {
378382
val context = LocalContext.current
@@ -388,6 +392,55 @@ class AboutFragment : Fragment() {
388392
}
389393
}
390394

395+
private fun setForumLabel(view: View) {
396+
val forumLabel = view.findViewById<ComposeView>(R.id.user_forum_label)
397+
forumLabel.setContent {
398+
val context = LocalContext.current
399+
themeProvider.WithTheme {
400+
TextTitleMedium(
401+
text = context.getString(R.string.user_forum_title),
402+
modifier = Modifier
403+
.fillMaxWidth()
404+
.wrapContentHeight(),
405+
color = MainTheme.colors.secondary,
406+
)
407+
}
408+
}
409+
}
410+
411+
private fun setForumText(view: View) {
412+
val forum = view.findViewById<ComposeView>(R.id.user_forum)
413+
forum.setContent {
414+
val context = LocalContext.current
415+
themeProvider.WithTheme {
416+
TextBodyMedium(
417+
text = context.getString(R.string.user_forum_url),
418+
modifier = Modifier
419+
.fillMaxWidth()
420+
.wrapContentHeight(),
421+
color = MainTheme.colors.secondary,
422+
)
423+
}
424+
}
425+
}
426+
427+
private fun setLibrariesTitle(view: View) {
428+
val librariesTitle = view.findViewById<ComposeView>(R.id.librariesTitle)
429+
librariesTitle.setContent {
430+
val context = LocalContext.current
431+
themeProvider.WithTheme {
432+
TextTitleSmall(
433+
text = context.getString(R.string.about_libraries),
434+
modifier = Modifier
435+
.fillMaxWidth()
436+
.wrapContentHeight()
437+
.padding(top = 16.dp, bottom = 8.dp, start = 16.dp, end = 16.dp),
438+
color = MainTheme.colors.secondary,
439+
)
440+
}
441+
}
442+
}
443+
391444
private fun displayChangeLog() {
392445
findNavController().navigate(R.id.action_aboutScreen_to_changelogScreen)
393446
}

legacy/ui/legacy/src/main/res/layout/fragment_about.xml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -300,32 +300,24 @@
300300
android:paddingEnd="0dp"
301301
>
302302

303-
<com.google.android.material.textview.MaterialTextView
303+
<androidx.compose.ui.platform.ComposeView
304+
android:id="@+id/user_forum_label"
304305
android:layout_width="match_parent"
305306
android:layout_height="wrap_content"
306-
android:text="@string/user_forum_title"
307-
android:textAppearance="?attr/textAppearanceTitleMedium"
308307
/>
309308

310-
<com.google.android.material.textview.MaterialTextView
309+
<androidx.compose.ui.platform.ComposeView
310+
android:id="@+id/user_forum"
311311
android:layout_width="match_parent"
312312
android:layout_height="wrap_content"
313-
android:text="@string/user_forum_url"
314-
android:textAppearance="?attr/textAppearanceBodyMedium"
315313
/>
316314
</LinearLayout>
317315
</LinearLayout>
318316

319-
<com.google.android.material.textview.MaterialTextView
317+
<androidx.compose.ui.platform.ComposeView
318+
android:id="@+id/librariesTitle"
320319
android:layout_width="match_parent"
321320
android:layout_height="wrap_content"
322-
android:gravity="center_vertical"
323-
android:paddingHorizontal="16dp"
324-
android:paddingTop="16dp"
325-
android:paddingBottom="8dp"
326-
android:text="@string/about_libraries"
327-
android:textAppearance="?attr/textAppearanceTitleSmall"
328-
android:textColor="?attr/colorSecondary"
329321
/>
330322

331323
<androidx.recyclerview.widget.RecyclerView

0 commit comments

Comments
 (0)