Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@ import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Bundle
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
Expand All @@ -19,7 +28,10 @@ import com.google.android.material.textview.MaterialTextView
import net.thunderbird.core.common.provider.AppNameProvider
import net.thunderbird.core.logging.legacy.Log
import org.koin.android.ext.android.inject
import app.k9mail.core.ui.legacy.designsystem.R as DesignSystemR
import app.k9mail.core.ui.legacy.theme2.common.R as Theme2CommonR

@Suppress("TooManyFunctions")
class AboutFragment : Fragment() {
private val appNameProvider: AppNameProvider by inject()

Expand All @@ -30,6 +42,20 @@ class AboutFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

setAppLogo(view)

setVersionImage(view)

setAuthorsImage(view)

setSourceCodeImage(view)

setLicenceImage(view)

setLinkImage(view)

setForumImage(view)

val titleTextView = view.findViewById<MaterialTextView>(R.id.about_title)
titleTextView.text = getString(R.string.about_title, appNameProvider.appName)

Expand Down Expand Up @@ -74,6 +100,86 @@ class AboutFragment : Fragment() {
}
}

private fun setForumImage(view: View) {
val forumImage = view.findViewById<ComposeView>(R.id.forum_image)
forumImage.setContent {
Image(
painter = painterResource(id = DesignSystemR.drawable.ic_forum),
modifier = Modifier.size(size = 32.dp),
contentDescription = null,
)
}
}

private fun setLinkImage(view: View) {
val linkImage = view.findViewById<ComposeView>(R.id.link_image)
linkImage.setContent {
Image(
painter = painterResource(id = DesignSystemR.drawable.ic_link),
modifier = Modifier.size(size = 32.dp),
contentDescription = null,
)
}
}

private fun setLicenceImage(view: View) {
val licenceImage = view.findViewById<ComposeView>(R.id.licence_image)
licenceImage.setContent {
Image(
painter = painterResource(id = DesignSystemR.drawable.ic_description),
modifier = Modifier.size(size = 32.dp),
contentDescription = null,
)
}
}

private fun setSourceCodeImage(view: View) {
val sourceCodeImage = view.findViewById<ComposeView>(R.id.source_code_image)
sourceCodeImage.setContent {
Image(
painter = painterResource(id = DesignSystemR.drawable.ic_code),
modifier = Modifier.size(size = 32.dp),
contentDescription = null,
)
}
}

private fun setAuthorsImage(view: View) {
val authorsImage = view.findViewById<ComposeView>(R.id.authors_image)
authorsImage.setContent {
Image(
painter = painterResource(id = DesignSystemR.drawable.ic_group),
modifier = Modifier.size(size = 32.dp),
contentDescription = null,
)
}
}

private fun setVersionImage(view: View) {
val versionImage = view.findViewById<ComposeView>(R.id.version_image)
versionImage.setContent {
Image(
painter = painterResource(id = DesignSystemR.drawable.ic_info),
modifier = Modifier.size(size = 32.dp),
contentDescription = null,
)
}
}

private fun setAppLogo(view: View) {
val appLogo = view.findViewById<ComposeView>(R.id.app_logo)
appLogo.setContent {
val context = LocalContext.current
val typedValue = remember { TypedValue() }
context.theme.resolveAttribute(Theme2CommonR.attr.appLogo, typedValue, true)
Image(
painter = painterResource(id = typedValue.resourceId),
modifier = Modifier.size(size = 128.dp),
contentDescription = null,
)
}
}

private fun displayChangeLog() {
findNavController().navigate(R.id.action_aboutScreen_to_changelogScreen)
}
Expand Down
23 changes: 15 additions & 8 deletions legacy/ui/legacy/src/main/res/layout/fragment_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
android:orientation="vertical"
>

<ImageView
<androidx.compose.ui.platform.ComposeView
android:id="@+id/app_logo"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
Expand Down Expand Up @@ -50,9 +51,10 @@
android:paddingBottom="8dp"
>

<ImageView
<androidx.compose.ui.platform.ComposeView
android:id="@+id/version_image"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_height="18dp"
android:layout_gravity="center"
android:contentDescription="@null"
app:srcCompat="@drawable/ic_info"
Expand Down Expand Up @@ -97,7 +99,8 @@
android:paddingBottom="8dp"
>

<ImageView
<androidx.compose.ui.platform.ComposeView
android:id="@+id/authors_image"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
Expand Down Expand Up @@ -150,7 +153,8 @@
android:paddingBottom="8dp"
>

<ImageView
<androidx.compose.ui.platform.ComposeView
android:id="@+id/source_code_image"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
Expand Down Expand Up @@ -196,7 +200,8 @@
android:paddingBottom="8dp"
>

<ImageView
<androidx.compose.ui.platform.ComposeView
android:id="@+id/licence_image"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
Expand Down Expand Up @@ -253,7 +258,8 @@
android:paddingBottom="8dp"
>

<ImageView
<androidx.compose.ui.platform.ComposeView
android:id="@+id/link_image"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
Expand Down Expand Up @@ -299,7 +305,8 @@
android:paddingBottom="8dp"
>

<ImageView
<androidx.compose.ui.platform.ComposeView
android:id="@+id/forum_image"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
Expand Down
Loading