improved the About screen and added version number
This commit is contained in:
+2
-2
@@ -4,10 +4,10 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2024-10-20T07:27:51.115175643Z">
|
<DropdownSelection timestamp="2024-11-29T17:18:42.354545820Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="LocalEmulator" identifier="path=/home/thinker/.android/avd/Motorola_Moto_e22_API_31.avd" />
|
<DeviceId pluginId="LocalEmulator" identifier="path=/home/thinker/.config/.android/avd/Medium_Phone_API_35.avd" />
|
||||||
</handle>
|
</handle>
|
||||||
</Target>
|
</Target>
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.odweta.solon
|
|||||||
|
|
||||||
import androidx.activity.compose.BackHandler
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
@@ -9,6 +10,7 @@ import androidx.compose.foundation.layout.Box
|
|||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
@@ -25,6 +27,7 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalUriHandler
|
import androidx.compose.ui.platform.LocalUriHandler
|
||||||
import com.odweta.solon.ui.theme.PastelYellow
|
import com.odweta.solon.ui.theme.PastelYellow
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
@@ -33,7 +36,6 @@ import androidx.compose.ui.text.style.TextAlign
|
|||||||
import androidx.compose.ui.text.style.TextDecoration
|
import androidx.compose.ui.text.style.TextDecoration
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import java.time.format.TextStyle
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AboutScreen(modifier: Modifier = Modifier) {
|
fun AboutScreen(modifier: Modifier = Modifier) {
|
||||||
@@ -51,6 +53,7 @@ fun AboutScreen(modifier: Modifier = Modifier) {
|
|||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
.padding(start = 5.dp)
|
||||||
) {
|
) {
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
@@ -106,30 +109,71 @@ fun AboutScreen(modifier: Modifier = Modifier) {
|
|||||||
.padding(10.dp)
|
.padding(10.dp)
|
||||||
)
|
)
|
||||||
|
|
||||||
Row(
|
HorizontalLine()
|
||||||
modifier = Modifier
|
|
||||||
.padding(10.dp)
|
|
||||||
) {
|
|
||||||
val uriHandler = LocalUriHandler.current
|
|
||||||
|
|
||||||
Text(
|
AboutTableRow(
|
||||||
text = "Vývoj: ",
|
"Vývoj",
|
||||||
textAlign = TextAlign.Start,
|
"@Odweta",
|
||||||
color = Color.White,
|
"https://www.gitlab.com/Odweta/solon"
|
||||||
fontSize = 30.sp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
AboutTableRow(
|
||||||
|
"Verze aplikace",
|
||||||
|
Util.getAppVersion(LocalContext.current)?.versionName ?: "N/A"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun HorizontalLine(modifier: Modifier = Modifier) {
|
||||||
|
Spacer(modifier = Modifier.height(20.dp))
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier
|
||||||
|
.height(2.dp)
|
||||||
|
.background(color = PastelYellow)
|
||||||
|
.fillMaxWidth(fraction = 0.8f)
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(20.dp))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun AboutTableRow(key: String, value: String, href: String = "") {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(10.dp)
|
||||||
|
.background(color = Color.Black, shape = RoundedCornerShape(roundedCornerDimen))
|
||||||
|
.fillMaxWidth()
|
||||||
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = "@Odweta",
|
text = key,
|
||||||
|
textAlign = TextAlign.Start,
|
||||||
|
color = Color.White,
|
||||||
|
fontSize = 20.sp
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
|
||||||
|
if (href != "") {
|
||||||
|
val uriHandler = LocalUriHandler.current
|
||||||
|
Text(
|
||||||
|
text = value,
|
||||||
color = PastelYellow,
|
color = PastelYellow,
|
||||||
fontSize = 30.sp,
|
fontSize = 20.sp,
|
||||||
textAlign = TextAlign.End,
|
textAlign = TextAlign.End,
|
||||||
textDecoration = TextDecoration.Underline,
|
textDecoration = TextDecoration.Underline,
|
||||||
modifier = Modifier.clickable {
|
modifier = Modifier.clickable {
|
||||||
uriHandler.openUri("https://www.gitlab.com/Odweta/solon")
|
uriHandler.openUri(href)
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
Text(
|
||||||
|
text = value,
|
||||||
|
color = Color.White,
|
||||||
|
fontSize = 20.sp,
|
||||||
|
textAlign = TextAlign.End
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -7,12 +7,14 @@ import android.animation.ArgbEvaluator
|
|||||||
import android.animation.ValueAnimator
|
import android.animation.ValueAnimator
|
||||||
import android.app.ActivityManager
|
import android.app.ActivityManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.graphics.drawable.GradientDrawable
|
import android.graphics.drawable.GradientDrawable
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
import android.net.NetworkCapabilities
|
import android.net.NetworkCapabilities
|
||||||
|
import android.os.Build
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
@@ -20,6 +22,7 @@ import android.view.animation.AnimationUtils
|
|||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.content.pm.PackageInfoCompat
|
||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
import com.odweta.solon.ui.theme.PastelGreenTransparent
|
import com.odweta.solon.ui.theme.PastelGreenTransparent
|
||||||
import com.odweta.solon.ui.theme.PastelOrangeTransparent
|
import com.odweta.solon.ui.theme.PastelOrangeTransparent
|
||||||
@@ -220,5 +223,30 @@ class Util {
|
|||||||
|
|
||||||
return d
|
return d
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
data class AppVersion(
|
||||||
|
val versionName: String,
|
||||||
|
val versionNumber: Long,
|
||||||
|
)
|
||||||
|
|
||||||
|
fun getAppVersion(
|
||||||
|
context: Context,
|
||||||
|
): AppVersion? {
|
||||||
|
return try {
|
||||||
|
val packageManager = context.packageManager
|
||||||
|
val packageName = context.packageName
|
||||||
|
val packageInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
packageManager.getPackageInfo(packageName, PackageManager.PackageInfoFlags.of(0))
|
||||||
|
} else {
|
||||||
|
packageManager.getPackageInfo(packageName, 0)
|
||||||
|
}
|
||||||
|
AppVersion(
|
||||||
|
versionName = packageInfo.versionName,
|
||||||
|
versionNumber = PackageInfoCompat.getLongVersionCode(packageInfo),
|
||||||
|
)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user