Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
machiav3lli committed Jul 21, 2024
1 parent d032dec commit b25d721
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 58 deletions.
34 changes: 13 additions & 21 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ android {
buildConfigField("int", "MAJOR", "8")
buildConfigField("int", "MINOR", "3")

testApplicationId = "${applicationId}.tests"
testApplicationId = "$applicationId.tests"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

javaCompileOptions {
Expand All @@ -50,7 +50,6 @@ android {
}
}
}

}

applicationVariants.all { variant ->
Expand All @@ -65,9 +64,8 @@ android {
named("release") {
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
"proguard-rules.pro",
)
//versionNameSuffix = "-alpha01"
isMinifyEnabled = true
}
named("debug") {
Expand All @@ -79,13 +77,12 @@ android {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
"proguard-rules.pro",
)
}
}
buildFeatures {
buildConfig = true
dataBinding = true
compose = true
}
compileOptions {
Expand Down Expand Up @@ -113,7 +110,6 @@ android {

dependencies {
implementation(libs.kotlin.stdlib)
//implementation(kotlin("reflect", vKotlin))
implementation(libs.ksp)

// Libs
Expand Down Expand Up @@ -150,10 +146,7 @@ dependencies {
implementation(libs.compose.material3)
implementation(libs.compose.animation)
implementation(libs.compose.navigation)
//implementation("androidx.compose.ui:ui-tooling:$vCompose")
//implementation("androidx.compose.runtime:runtime-livedata:$vCompose")
implementation(libs.coil.compose)
//implementation("com.google.accompanist:accompanist-systemuicontroller:$vAccompanist")
implementation(libs.accompanist.permissions)

// Testing
Expand All @@ -169,21 +162,20 @@ dependencies {
debugImplementation(libs.compose.ui.test.manifest)
}

//TODO: how to do this with ksp?
//kapt {
// correctErrorTypes = true
//}

// using a task as a preBuild dependency instead of a function that takes some time insures that it runs
task("detectAndroidLocals") {
val langsList: MutableSet<String> = HashSet()

// in /res are (almost) all languages that have a translated string is saved. this is safer and saves some time
fileTree("src/main/res").visit {
if (this.file.path.endsWith("strings.xml")
&& this.file.canonicalFile.readText().contains("<string")
if (this.file.path.endsWith("strings.xml") &&
this.file.canonicalFile
.readText()
.contains("<string")
) {
var languageCode = this.file.parentFile.name.replace("values-", "")
var languageCode =
this.file.parentFile.name
.replace("values-", "")
languageCode = if (languageCode == "values") "en" else languageCode
langsList.add(languageCode)
}
Expand All @@ -194,7 +186,7 @@ task("detectAndroidLocals") {
tasks.preBuild.dependsOn("detectAndroidLocals")

tasks.withType<Test> {
useJUnit() // we still use junit4
//useTestNG()
//useJUnitPlatform()
useJUnit() // we still use junit4
// useTestNG()
// useJUnitPlatform()
}
8 changes: 7 additions & 1 deletion src/main/java/com/machiav3lli/backup/dbs/entity/Backup.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ data class Backup @OptIn(ExperimentalSerializationApi::class) constructor(
var persistent: Boolean = false,
) {
constructor(
base: com.machiav3lli.backup.dbs.entity.PackageInfo,
base: PackageInfo,
backupDate: LocalDateTime,
hasApk: Boolean,
hasAppData: Boolean,
Expand All @@ -83,6 +83,7 @@ data class Backup @OptIn(ExperimentalSerializationApi::class) constructor(
permissions: List<String>,
size: Long,
persistent: Boolean = false,
note: String = "",
) : this(
backupVersionCode = BuildConfig.MAJOR * 1000 + BuildConfig.MINOR,
packageName = base.packageName,
Expand All @@ -107,6 +108,7 @@ data class Backup @OptIn(ExperimentalSerializationApi::class) constructor(
permissions = permissions.sorted(),
size = size,
persistent = persistent,
note = note,
)

val isCompressed: Boolean
Expand Down Expand Up @@ -147,6 +149,8 @@ data class Backup @OptIn(ExperimentalSerializationApi::class) constructor(
", cipherType='" + cipherType + '\'' +
", iv='" + iv + '\'' +
", permissions='" + permissions + '\'' +
", persistent=" + persistent +
", note='" + note + '\'' +
'}'

override fun equals(other: Any?): Boolean = when {
Expand Down Expand Up @@ -178,6 +182,7 @@ data class Backup @OptIn(ExperimentalSerializationApi::class) constructor(
|| isEncrypted != other.isEncrypted
|| permissions != other.permissions
|| persistent != other.persistent
|| note != other.note
|| file?.path != other.file?.path
|| dir?.path != other.dir?.path
-> false
Expand Down Expand Up @@ -209,6 +214,7 @@ data class Backup @OptIn(ExperimentalSerializationApi::class) constructor(
result = 31 * result + isEncrypted.hashCode()
result = 31 * result + permissions.hashCode()
result = 31 * result + persistent.hashCode()
result = 31 * result + note.hashCode()
result = 31 * result + file?.path.hashCode()
result = 31 * result + dir?.path.hashCode()
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ fun TerminalText(
fontFamily = FontFamily.Monospace,
fontSize = fontSize,
lineHeight = lineHeightSp,
softWrap = wrap,
color = color,
modifier = Modifier
.fillMaxWidth()
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/machiav3lli/backup/sheets/AppSheet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,12 @@ fun AppSheet(
) {
Text(
text = pkg.packageLabel,
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.titleMedium
)
Text(
text = pkg.packageName,
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.labelMedium,
Expand Down
26 changes: 5 additions & 21 deletions src/main/java/com/machiav3lli/backup/ui/compose/item/BackupItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fun BackupItem(
onRestore: (Backup) -> Unit = { },
onDelete: (Backup) -> Unit = { },
onNote: (Backup) -> Unit = { },
rewriteBackup: (Backup, Backup) -> Unit = { backup, changedBackup -> },
rewriteBackup: (Backup, Backup) -> Unit = { _, _ -> },
) {
ListItem(
modifier = Modifier
Expand All @@ -56,12 +56,12 @@ fun BackupItem(
),
headlineContent = {
Row(modifier = Modifier.fillMaxWidth()) {
Row(modifier = Modifier.weight(1f)) {
Row(
modifier = Modifier.weight(1f),
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = item.versionName ?: "",
modifier = Modifier
.align(Alignment.CenterVertically),
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 2,
style = MaterialTheme.typography.titleMedium
Expand All @@ -70,9 +70,6 @@ fun BackupItem(
Text(
text = " ${item.cpuArch}",
color = Color.Red,
modifier = Modifier
.align(Alignment.CenterVertically),
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.labelMedium,
Expand Down Expand Up @@ -105,7 +102,6 @@ fun BackupItem(
Text(
text = item.backupDate.format(BACKUP_DATE_TIME_SHOW_FORMATTER),
modifier = Modifier.align(Alignment.Top),
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.labelMedium,
Expand All @@ -114,7 +110,6 @@ fun BackupItem(
Text(
text = " ${item.tag}",
modifier = Modifier.align(Alignment.Top),
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 3,
style = MaterialTheme.typography.labelMedium,
Expand All @@ -123,7 +118,6 @@ fun BackupItem(
Row {
Text(
text = if (item.backupVersionCode == 0) "old" else "${item.backupVersionCode / 1000}.${item.backupVersionCode % 1000}",
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.labelMedium,
Expand All @@ -142,7 +136,6 @@ fun BackupItem(
onClick = {},
onLongClick = { showTooltip.value = true }
),
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 2,
style = MaterialTheme.typography.labelMedium,
Expand All @@ -160,7 +153,6 @@ fun BackupItem(
Text(
text = compressionText + fileSizeText,
modifier = Modifier.align(Alignment.Top),
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.labelMedium,
Expand All @@ -174,7 +166,6 @@ fun BackupItem(
Text(
text = "${item.profileId}",
color = Color.Red,
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.labelMedium,
Expand Down Expand Up @@ -271,7 +262,6 @@ fun RestoreBackupItem(
text = item.versionName ?: "",
modifier = Modifier
.align(Alignment.CenterVertically),
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.titleMedium
Expand All @@ -281,7 +271,6 @@ fun RestoreBackupItem(
modifier = Modifier
.align(Alignment.CenterVertically)
.weight(1f),
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.labelMedium,
Expand All @@ -300,15 +289,13 @@ fun RestoreBackupItem(
) {
Text(
text = item.backupDate.format(BACKUP_DATE_TIME_SHOW_FORMATTER),
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.labelMedium,
)
if (item.tag.isNotEmpty())
Text(
text = " - ${item.tag}",
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.labelMedium,
Expand All @@ -317,7 +304,6 @@ fun RestoreBackupItem(
Row {
Text(
text = if (item.backupVersionCode == 0) "old" else "${item.backupVersionCode / 1000}.${item.backupVersionCode % 1000}",
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.labelMedium,
Expand All @@ -335,7 +321,6 @@ fun RestoreBackupItem(
onClick = {},
onLongClick = { showTooltip.value = true }
),
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.labelMedium,
Expand All @@ -349,7 +334,6 @@ fun RestoreBackupItem(
else ""
Text(
text = compressionText + fileSizeText,
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.labelMedium,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ fun BatchPackageItem(
modifier = Modifier
.align(Alignment.CenterVertically)
.weight(1f),
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.titleMedium
Expand All @@ -122,7 +121,6 @@ fun BatchPackageItem(
modifier = Modifier
.align(Alignment.CenterVertically)
.weight(1f),
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.labelMedium,
Expand Down Expand Up @@ -187,7 +185,6 @@ fun RestorePackageItem(
modifier = Modifier
.align(Alignment.CenterVertically)
.weight(1f),
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.titleMedium
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ fun ExportedScheduleItem(
modifier = Modifier
.align(Alignment.CenterVertically)
.weight(1f),
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.titleMedium
Expand Down Expand Up @@ -80,7 +79,6 @@ fun ExportedScheduleItem(
modifier = Modifier
.align(Alignment.CenterVertically)
.weight(1f),
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.labelMedium,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ fun LogItem(
Column(modifier = Modifier.weight(1f, true)) {
Text(
text = item.logDate.getFormattedDate(true) ?: "",
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.titleMedium
Expand All @@ -72,7 +71,6 @@ fun LogItem(
if (item.sdkCodename.isNotEmpty())
Text(
text = "abi${item.sdkCodename} ",
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.labelMedium,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,6 @@ fun MainPackageItem(
modifier = Modifier
.align(Alignment.CenterVertically)
.weight(1f),
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.titleMedium
Expand All @@ -824,7 +823,6 @@ fun MainPackageItem(
modifier = Modifier
.align(Alignment.CenterVertically)
.weight(1f),
softWrap = true,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.labelMedium,
Expand Down
Loading

0 comments on commit b25d721

Please sign in to comment.