Skip to content

Commit 6eb6746

Browse files
Add link name option (#48)
* feat: add dialog for name field * feat: added name in database * feat: add name in edit deeplink
1 parent 5749f47 commit 6eb6746

File tree

16 files changed

+901
-703
lines changed

16 files changed

+901
-703
lines changed

app/src/main/java/com/yogeshpaliyal/deepr/MainActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ import androidx.navigation3.ui.NavDisplay
1818
import androidx.navigation3.ui.rememberSceneSetupNavEntryDecorator
1919
import com.yogeshpaliyal.deepr.ui.screens.AboutUs
2020
import com.yogeshpaliyal.deepr.ui.screens.AboutUsScreen
21-
import com.yogeshpaliyal.deepr.ui.screens.Home
22-
import com.yogeshpaliyal.deepr.ui.screens.HomeScreen
2321
import com.yogeshpaliyal.deepr.ui.screens.Settings
2422
import com.yogeshpaliyal.deepr.ui.screens.SettingsScreen
23+
import com.yogeshpaliyal.deepr.ui.screens.home.Home
24+
import com.yogeshpaliyal.deepr.ui.screens.home.HomeScreen
2525
import com.yogeshpaliyal.deepr.ui.theme.DeeprTheme
2626

2727
class MainActivity : ComponentActivity() {

app/src/main/java/com/yogeshpaliyal/deepr/backup/ExportRepositoryImpl.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ class ExportRepositoryImpl(
8383
) {
8484
outputStream.bufferedWriter().use { writer ->
8585
// Write Header
86-
writer.write("${Constants.Header.LINK},${Constants.Header.CREATED_AT},${Constants.Header.OPENED_COUNT}\n")
86+
writer.write(
87+
"${Constants.Header.LINK},${Constants.Header.CREATED_AT},${Constants.Header.OPENED_COUNT},${Constants.Header.NAME}\n",
88+
)
8789
// Write Data
8890
data.forEach { item ->
89-
val row = "${item.link},${item.createdAt},${item.openedCount}\n"
91+
val row = "${item.link},${item.createdAt},${item.openedCount},${item.name}\n"
9092
writer.write(row)
9193
}
9294
}

app/src/main/java/com/yogeshpaliyal/deepr/backup/ImportRepositoryImpl.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ class ImportRepositoryImpl(
3939
if (row.size >= 3) {
4040
val link = row[0]
4141
val openedCount = row[2].toLongOrNull() ?: 0L
42+
val name = row[3].toString()
4243
val existing = deeprQueries.getDeeprByLink(link).executeAsOneOrNull()
4344
if (link.isNotBlank() && existing == null) {
4445
updatedCount++
4546
deeprQueries.transaction {
4647
deeprQueries.insertDeepr(
4748
link = link,
4849
openedCount = openedCount,
50+
name = name,
4951
)
5052
}
5153
} else {

app/src/main/java/com/yogeshpaliyal/deepr/ui/components/EditDeeplinkDialog.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.Column
44
import androidx.compose.foundation.layout.Spacer
55
import androidx.compose.foundation.layout.fillMaxWidth
66
import androidx.compose.foundation.layout.height
7-
import androidx.compose.foundation.layout.padding
87
import androidx.compose.material3.AlertDialog
98
import androidx.compose.material3.Button
109
import androidx.compose.material3.MaterialTheme
@@ -25,9 +24,10 @@ import com.yogeshpaliyal.deepr.util.isValidDeeplink
2524
fun EditDeeplinkDialog(
2625
deepr: Deepr,
2726
onDismiss: () -> Unit,
28-
onSave: (String) -> Unit,
27+
onSave: (link: String, name: String) -> Unit,
2928
) {
3029
var link by remember { mutableStateOf(deepr.link) }
30+
var name by remember { mutableStateOf(deepr.name) }
3131
var isError by remember { mutableStateOf(false) }
3232

3333
AlertDialog(
@@ -55,19 +55,21 @@ fun EditDeeplinkDialog(
5555
)
5656

5757
Spacer(modifier = Modifier.height(8.dp))
58-
59-
Text(
60-
text = "Edit your deeplink URL",
61-
style = MaterialTheme.typography.bodySmall,
62-
modifier = Modifier.padding(horizontal = 4.dp),
58+
TextField(
59+
value = name,
60+
onValueChange = {
61+
name = it
62+
},
63+
label = { Text("Name") },
64+
modifier = Modifier.fillMaxWidth(),
6365
)
6466
}
6567
},
6668
confirmButton = {
6769
Button(
6870
onClick = {
6971
if (isValidDeeplink(link)) {
70-
onSave(link)
72+
onSave(link, name)
7173
} else {
7274
isError = true
7375
}

0 commit comments

Comments
 (0)