Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions app/schemas/co.adityarajput.fileflow.data.FileFlowDatabase/3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"formatVersion": 1,
"database": {
"version": 3,
"identityHash": "6517669d413b15b9fd2c38215b1fe3be",
"entities": [
{
"tableName": "rules",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`action` TEXT NOT NULL, `enabled` INTEGER NOT NULL, `executions` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
"fields": [
{
"fieldPath": "action",
"columnName": "action",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "enabled",
"columnName": "enabled",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "executions",
"columnName": "executions",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
}
},
{
"tableName": "executions",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`fileName` TEXT NOT NULL, `verb` TEXT NOT NULL DEFAULT 'MOVE', `timestamp` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
"fields": [
{
"fieldPath": "fileName",
"columnName": "fileName",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "verb",
"columnName": "verb",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "'MOVE'"
},
{
"fieldPath": "timestamp",
"columnName": "timestamp",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
}
}
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '6517669d413b15b9fd2c38215b1fe3be')"
]
}
}
11 changes: 5 additions & 6 deletions app/src/main/java/co/adityarajput/fileflow/data/AppContainer.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package co.adityarajput.fileflow.data

import android.content.Context
import co.adityarajput.fileflow.R
import co.adityarajput.fileflow.data.models.Action
import co.adityarajput.fileflow.data.models.Execution
import co.adityarajput.fileflow.data.models.Rule
Expand Down Expand Up @@ -56,27 +55,27 @@ class AppContainer(private val context: Context) {
repository.upsert(
Execution(
"TubularData-20251201_113745.zip",
R.string.move,
Verb.MOVE,
System.currentTimeMillis() - 86400000L * 66,
),
Execution(
"TubularData-20260101_141634.zip",
R.string.move,
Verb.MOVE,
System.currentTimeMillis() - 86400000L * 35,
),
Execution(
"TubularData-20260201_160604.zip",
R.string.move,
Verb.MOVE,
System.currentTimeMillis() - 86400000L * 4,
),
Execution(
"AntennaPodBackup-2026-02-02.db",
R.string.copy,
Verb.COPY,
System.currentTimeMillis() - 86400000L * 3,
),
Execution(
"AntennaPodBackup-2026-02-05.db",
R.string.copy,
Verb.COPY,
System.currentTimeMillis() - 60_000L * 5,
),
)
Expand Down
13 changes: 12 additions & 1 deletion app/src/main/java/co/adityarajput/fileflow/data/Converters.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package co.adityarajput.fileflow.data
import androidx.room.TypeConverter
import co.adityarajput.fileflow.data.models.Action
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.jsonObject

class Converters {
@TypeConverter
Expand All @@ -12,6 +13,16 @@ class Converters {
fun toAction(value: String) = try {
Json.decodeFromString<Action>(value)
} catch (_: Exception) {
Action.entries[0]
try {
Json.decodeFromString<Action>(
Json.encodeToString(
Json.parseToJsonElement(value)
.jsonObject.toMap()
.filterKeys { it != "title" },
),
)
} catch (_: Exception) {
Action.entries[0]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@ package co.adityarajput.fileflow.data

import android.content.Context
import androidx.room.*
import androidx.room.migration.AutoMigrationSpec
import co.adityarajput.fileflow.data.models.Execution
import co.adityarajput.fileflow.data.models.Rule

@Database([Rule::class, Execution::class], version = 2, autoMigrations = [AutoMigration(1, 2)])
@Database(
[Rule::class, Execution::class],
version = 3,
autoMigrations = [
AutoMigration(1, 2),
AutoMigration(2, 3, FileFlowDatabase.DeleteEColumnAV::class),
],
)
@TypeConverters(Converters::class)
abstract class FileFlowDatabase : RoomDatabase() {
abstract fun ruleDao(): RuleDao
abstract fun executionDao(): ExecutionDao

@DeleteColumn("executions", "actionVerb")
class DeleteEColumnAV : AutoMigrationSpec

companion object {
@Volatile
private var instance: FileFlowDatabase? = null
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/co/adityarajput/fileflow/data/Verb.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package co.adityarajput.fileflow.data

import co.adityarajput.fileflow.R

enum class Verb(val resource: Int) {
MOVE(R.string.move),
COPY(R.string.copy),
DELETE_STALE(R.string.delete_stale),
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.withStyle
import co.adityarajput.fileflow.R
import co.adityarajput.fileflow.data.Verb
import co.adityarajput.fileflow.utils.FileSuperlative
import co.adityarajput.fileflow.utils.getGetDirectoryFromUri
import co.adityarajput.fileflow.utils.toShortHumanReadableTime
Expand All @@ -19,7 +20,7 @@ sealed class Action {
abstract val srcFileNamePattern: String
abstract val scanSubdirectories: Boolean

abstract val verb: Int
abstract val verb: Verb
abstract val phrase: Int

@Composable
Expand All @@ -45,7 +46,7 @@ sealed class Action {
val superlative: FileSuperlative = FileSuperlative.LATEST,
val preserveStructure: Boolean = scanSubdirectories,
) : Action() {
override val verb get() = if (keepOriginal) R.string.copy else R.string.move
override val verb get() = if (keepOriginal) Verb.COPY else Verb.MOVE

override val phrase = R.string.move_phrase

Expand Down Expand Up @@ -73,7 +74,7 @@ sealed class Action {
val retentionDays: Int = 30,
override val scanSubdirectories: Boolean = false,
) : Action() {
override val verb get() = R.string.delete_stale
override val verb get() = Verb.DELETE_STALE

override val phrase = R.string.delete_stale_phrase

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package co.adityarajput.fileflow.data.models

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import co.adityarajput.fileflow.data.Verb

@Entity(tableName = "executions")
data class Execution(
val fileName: String,

val actionVerb: Int,
@ColumnInfo(defaultValue = "MOVE")
val verb: Verb,

val timestamp: Long = System.currentTimeMillis(),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ fun FolderPickerBottomSheet(viewModel: UpsertRuleViewModel) {
)
HorizontalDivider()
LazyColumn(
Modifier.padding(dimensionResource(R.dimen.padding_medium)),
Modifier
.weight(1f)
.padding(dimensionResource(R.dimen.padding_medium)),
verticalArrangement = Arrangement.spacedBy(dimensionResource(R.dimen.padding_medium)),
) {
if (currentDir.parentFile?.canRead() ?: false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fun ImproperRulesetDialog(
rulesToBeMigrated.forEach {
Tile(
it.action.srcFileNamePattern,
stringResource(it.action.verb),
stringResource(it.action.verb.resource),
if (!it.enabled) stringResource(R.string.disabled)
else pluralStringResource(
R.plurals.execution,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fun ExecutionsScreen(
items(state.value.executions!!, { it.id }) {
Tile(
it.fileName,
stringResource(it.actionVerb),
stringResource(it.verb.resource),
stringResource(
R.string.ago,
(System.currentTimeMillis() - it.timestamp).toShortHumanReadableTime(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fun RulesScreen(
items(state.value.rules!!, { it.id }) {
Tile(
it.action.srcFileNamePattern,
stringResource(it.action.verb),
stringResource(it.action.verb.resource),
if (!it.enabled) stringResource(R.string.disabled)
else pluralStringResource(
R.plurals.execution,
Expand Down
4 changes: 3 additions & 1 deletion metadata/en-US/changelogs/4.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Rules can now target protected folders (like "Download") if special "all files" access is granted.

The new "DELETE_STALE" action helps get rid of unused/untouched files. Note: "Staleness" is calculated based on when the file was last modified, not when it was last accessed.
The new "DELETE_STALE" action helps get rid of unused/untouched files.

IMPORTANT: "Staleness" is calculated based on when the file was last modified, not when it was last accessed.

Finally, rules can now recursively scan (and re-create) subfolders.
Loading