Skip to content

Commit

Permalink
chore: merge branch dev into main
Browse files Browse the repository at this point in the history
  • Loading branch information
aliernfrog authored Apr 21, 2024
2 parents 10cab80 + 4eec10e commit 74f16cc
Show file tree
Hide file tree
Showing 24 changed files with 313 additions and 209 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ android {
applicationId = "com.aliernfrog.pftool"
minSdk = 23
targetSdk = 34
versionCode = 17100
versionName = "1.7.1"
versionCode = 17200
versionName = "1.7.2"
vectorDrawables { useSupportLibrary = true }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class MainActivity : AppCompatActivity() {
PFToolTheme(
darkTheme = useDarkTheme,
dynamicColors = mainViewModel.prefs.materialYou,
pitchBlack = mainViewModel.prefs.pitchBlack,
content = content
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.aliernfrog.pftool.ui.component.form

import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.KeyboardArrowUp
Expand All @@ -28,7 +27,6 @@ fun ButtonRow(
arrowRotation: Float = if (expanded == true) 0f else 180f,
trailingComponent: @Composable (() -> Unit)? = null,
shape: Shape = RectangleShape,
contentPadding: PaddingValues = PaddingValues(0.dp),
containerColor: Color = Color.Transparent,
contentColor: Color =
if (containerColor == Color.Transparent) MaterialTheme.colorScheme.onSurface
Expand All @@ -42,7 +40,6 @@ fun ButtonRow(
description = description,
painter = painter,
shape = shape,
contentPadding = contentPadding,
containerColor = containerColor,
contentColor = contentColor,
onClick = onClick
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.aliernfrog.pftool.ui.component.form

import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
Expand All @@ -14,7 +13,9 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@Composable
fun FormHeader(
Expand All @@ -32,28 +33,30 @@ fun FormHeader(
Icon(
painter = painter,
contentDescription = null,
modifier = Modifier.size(30.dp).padding(1.dp),
modifier = Modifier.padding(end = 18.dp),
tint = contentColor
)
}
Column(
modifier = Modifier
.padding(vertical = 4.dp, horizontal = 8.dp)
verticalArrangement = Arrangement.spacedBy(2.dp)
) {
Text(
text = title,
color = contentColor,
style = MaterialTheme.typography.titleMedium,
modifier = Modifier.fillMaxWidth()
style = MaterialTheme.typography.titleLarge.copy(
fontWeight = FontWeight.Normal,
fontSize = 19.sp
),
modifier = Modifier.animateContentSize()
)
description?.let {
Text(
text = description,
color = contentColor,
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier
.fillMaxWidth()
.animateContentSize()
style = MaterialTheme.typography.bodyMedium.copy(
color = MaterialTheme.colorScheme.onSurface.copy(0.6f)
),
modifier = Modifier.animateContentSize()
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.aliernfrog.pftool.ui.component.form

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
Expand All @@ -26,7 +25,6 @@ fun FormRow(
description: String? = null,
painter: Painter? = null,
shape: Shape = RectangleShape,
contentPadding: PaddingValues = PaddingValues(0.dp),
containerColor: Color = Color.Transparent,
contentColor: Color = if (containerColor == Color.Transparent)
MaterialTheme.colorScheme.onSurface else contentColorFor(containerColor),
Expand All @@ -35,16 +33,15 @@ fun FormRow(
) {
Row(
modifier = modifier
.fillMaxWidth()
.heightIn(56.dp)
.fillMaxWidth()
.clip(shape)
.background(containerColor)
.clickableWithColor(
color = contentColor,
onClick = onClick
)
.padding(horizontal = 8.dp, vertical = 4.dp)
.padding(contentPadding),
.padding(end = 9.dp),
verticalAlignment = Alignment.CenterVertically
) {
FormHeader(
Expand All @@ -55,6 +52,10 @@ fun FormRow(
modifier = Modifier
.fillMaxWidth()
.weight(1f)
.padding(
vertical = 8.dp,
horizontal = 18.dp
)
)
content()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fun SwitchRow(
modifier: Modifier = Modifier,
description: String? = null,
painter: Painter? = null,
enabled: Boolean = true,
shape: Shape = RectangleShape,
containerColor: Color = Color.Transparent,
contentColor: Color = MaterialTheme.colorScheme.onSurface,
Expand All @@ -30,14 +31,17 @@ fun SwitchRow(
painter = painter,
shape = shape,
containerColor = containerColor,
contentColor = contentColor,
contentColor = contentColor.let {
if (enabled) it else it.copy(alpha = 0.7f)
},
onClick = {
onCheckedChange(!checked)
if (enabled) onCheckedChange(!checked)
}
) {
Switch(
checked = checked,
onCheckedChange = onCheckedChange,
enabled = enabled,
modifier = Modifier.padding(horizontal = 8.dp)
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.aliernfrog.pftool.ui.component
package com.aliernfrog.pftool.ui.component.maps

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
Expand All @@ -13,6 +11,10 @@ import androidx.compose.material.icons.outlined.PinDrop
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
Expand All @@ -21,12 +23,13 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.ColorPainter
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import com.aliernfrog.pftool.impl.MapFile
import com.aliernfrog.pftool.ui.component.form.FormHeader
import com.aliernfrog.pftool.ui.theme.AppComponentShape
import com.aliernfrog.pftool.util.extension.combinedClickableWithColor

Expand All @@ -41,6 +44,9 @@ fun MapButton(
onLongClick: () -> Unit = {},
onClick: () -> Unit
) {
val density = LocalDensity.current
var headerHeight by remember { mutableStateOf(0.dp) }

val isRTL = LocalLayoutDirection.current == LayoutDirection.Rtl
fun invertIfRTL(list: List<Color>): List<Color> {
return if (isRTL) list.reversed() else list
Expand All @@ -49,7 +55,6 @@ fun MapButton(
Box(
modifier = modifier
.fillMaxWidth()
.height(IntrinsicSize.Max)
.padding(8.dp)
.clip(AppComponentShape)
.background(containerColor)
Expand All @@ -62,7 +67,7 @@ fun MapButton(
if (showMapThumbnail) AsyncImage(
model = map.thumbnailModel,
contentDescription = null,
modifier = Modifier.fillMaxWidth(),
modifier = Modifier.height(headerHeight).fillMaxWidth(),
placeholder = ColorPainter(containerColor),
error = ColorPainter(containerColor),
fallback = ColorPainter(containerColor),
Expand All @@ -77,12 +82,17 @@ fun MapButton(
)
))
) {
FormHeader(
MapHeader(
title = map.name,
description = map.details,
painter = rememberVectorPainter(Icons.Outlined.PinDrop),
modifier = Modifier
.fillMaxSize()
.onSizeChanged {
density.run {
headerHeight = it.height.toDp()
}
}
.fillMaxWidth()
.padding(horizontal = 8.dp, vertical = 4.dp)
.weight(1f)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.aliernfrog.pftool.ui.component.maps

import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.unit.dp

@Composable
fun MapHeader(
title: String,
modifier: Modifier = Modifier,
description: String? = null,
painter: Painter? = null,
contentColor: Color = MaterialTheme.colorScheme.onSurface
) {
Row(
modifier = modifier,
verticalAlignment = Alignment.CenterVertically
) {
painter?.let {
Icon(
painter = painter,
contentDescription = null,
modifier = Modifier.size(30.dp).padding(1.dp),
tint = contentColor
)
}
Column(
modifier = Modifier
.padding(vertical = 4.dp, horizontal = 8.dp)
) {
Text(
text = title,
color = contentColor,
style = MaterialTheme.typography.titleMedium,
modifier = Modifier.fillMaxWidth()
)
description?.let {
Text(
text = description,
color = contentColor,
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier
.fillMaxWidth()
.animateContentSize()
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.aliernfrog.pftool.ui.component
package com.aliernfrog.pftool.ui.component.maps

import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.background
Expand All @@ -23,7 +23,7 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import com.aliernfrog.pftool.impl.MapFile
import com.aliernfrog.pftool.ui.component.form.FormHeader
import com.aliernfrog.pftool.ui.component.FadeVisibility
import com.aliernfrog.pftool.ui.theme.AppComponentShape
import com.aliernfrog.pftool.util.extension.clickableWithColor

Expand Down Expand Up @@ -66,7 +66,7 @@ fun PickMapButton(
.padding(horizontal = 8.dp),
verticalAlignment = Alignment.CenterVertically
) {
FormHeader(
MapHeader(
title = chosenMap?.name ?: "",
description = chosenMap?.details,
painter = rememberVectorPainter(Icons.Rounded.LocationOn),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import com.aliernfrog.pftool.impl.MapFile
import com.aliernfrog.pftool.ui.component.AppScaffold
import com.aliernfrog.pftool.ui.component.AppTopBar
import com.aliernfrog.pftool.ui.component.ErrorWithIcon
import com.aliernfrog.pftool.ui.component.MapButton
import com.aliernfrog.pftool.ui.component.maps.MapButton
import com.aliernfrog.pftool.ui.component.SegmentedButtons
import com.aliernfrog.pftool.ui.component.SettingsButton
import com.aliernfrog.pftool.ui.component.form.DividerRow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import com.aliernfrog.pftool.ui.component.AppScaffold
import com.aliernfrog.pftool.ui.component.AppTopBar
import com.aliernfrog.pftool.ui.component.ButtonIcon
import com.aliernfrog.pftool.ui.component.FadeVisibility
import com.aliernfrog.pftool.ui.component.PickMapButton
import com.aliernfrog.pftool.ui.component.maps.PickMapButton
import com.aliernfrog.pftool.ui.component.SettingsButton
import com.aliernfrog.pftool.ui.component.VerticalSegmentedButtons
import com.aliernfrog.pftool.ui.component.form.ButtonRow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.LifecycleEventEffect
import com.aliernfrog.pftool.R
import com.aliernfrog.pftool.data.PermissionData
import com.aliernfrog.pftool.documentsUIPackageName
import com.aliernfrog.pftool.enum.StorageAccessType
import com.aliernfrog.pftool.ui.component.AppScaffold
import com.aliernfrog.pftool.ui.component.AppTopBar
Expand Down Expand Up @@ -102,7 +103,7 @@ fun PermissionsScreen(
permissionsViewModel.showFilesDowngradeDialog = false
Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
data = Uri.parse("package:com.google.android.documentsui")
data = Uri.parse("package:$documentsUIPackageName")
context.startActivity(this)
}
}
Expand Down
Loading

0 comments on commit 74f16cc

Please sign in to comment.