Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import com.yogeshpaliyal.deepr.R
import com.yogeshpaliyal.deepr.Tags
import compose.icons.TablerIcons
import compose.icons.tablericons.DotsVertical
import compose.icons.tablericons.ExternalLink
import compose.icons.tablericons.Edit
import compose.icons.tablericons.Note
import compose.icons.tablericons.Refresh
Expand All @@ -76,6 +77,10 @@ sealed class MenuItem(
item: GetLinksAndTags,
) : MenuItem(item)

class OpenWith(
item: GetLinksAndTags,
) : MenuItem(item)

class Shortcut(
item: GetLinksAndTags,
) : MenuItem(item)
Expand Down Expand Up @@ -371,6 +376,22 @@ fun DeeprItem(
)
},
)
}
DropdownMenuItem(
text = { Text(stringResource(R.string.open_with)) },
onClick = {
onItemClick(MenuItem.OpenWith(account))
expanded = false
},
leadingIcon = {
Icon(
TablerIcons.ExternalLink,
contentDescription = stringResource(R.string.open_with),
)
},
)


DropdownMenuItem(
text = { Text(stringResource(R.string.edit)) },
onClick = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import com.yogeshpaliyal.deepr.util.QRScanner
import com.yogeshpaliyal.deepr.util.isValidDeeplink
import com.yogeshpaliyal.deepr.util.normalizeLink
import com.yogeshpaliyal.deepr.util.openDeeplink
import com.yogeshpaliyal.deepr.util.openDeeplinkWithChooser
import com.yogeshpaliyal.deepr.viewmodel.AccountViewModel
import compose.icons.TablerIcons
import compose.icons.tablericons.ArrowLeft
Expand Down Expand Up @@ -477,6 +478,11 @@ fun Content(
openDeeplink(context, it.item.link)
}

is MenuItem.OpenWith -> {
viewModel.incrementOpenedCount(it.item.id)
openDeeplinkWithChooser(context, it.item.link)
}

is MenuItem.Delete -> showDeleteConfirmDialog = it.item
is MenuItem.Edit -> editDeepr(it.item)
is MenuItem.FavouriteClick -> viewModel.toggleFavourite(it.item.id)
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/java/com/yogeshpaliyal/deepr/util/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,29 @@ fun openDeeplink(
}
}

fun openDeeplinkWithChooser(
context: Context,
link: String,
): Boolean {
if (!isValidDeeplink(link)) return false
val normalizedLink = normalizeLink(link)
return try {
val intent = Intent(Intent.ACTION_VIEW, normalizedLink.toUri())
val chooserIntent = Intent.createChooser(intent, null)
context.startActivity(chooserIntent)
true
} catch (e: Exception) {
e.printStackTrace()
Toast
.makeText(
context,
context.getString(R.string.invalid_deeplink_toast, normalizedLink),
Toast.LENGTH_SHORT,
).show()
false
}
}

fun getShortcutAppIcon(
context: Context,
link: String,
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

<!-- Menu and Dialog Items -->
<string name="more_options">Weitere Optionen</string>
<string name="open_with">Öffnen mit</string>
<string name="copy_link">Link kopieren</string>
<string name="link_copied">Link kopiert</string>
<string name="delete">Löschen</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

<!-- Menu and Dialog Items -->
<string name="more_options">Más opciones</string>
<string name="open_with">Abrir con</string>
<string name="copy_link">Copiar enlace</string>
<string name="link_copied">Enlace copiado</string>
<string name="delete">Eliminar</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

<!-- Menu and Dialog Items -->
<string name="more_options">Plus d\'options</string>
<string name="open_with">Ouvrir avec</string>
<string name="copy_link">Copier le lien</string>
<string name="link_copied">Lien copié</string>
<string name="delete">Supprimer</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

<!-- Menu and Dialog Items -->
<string name="more_options">अधिक विकल्प</string>
<string name="open_with">इसके साथ खोलें</string>
<string name="copy_link">लिंक कॉपी करें</string>
<string name="link_copied">लिंक कॉपी किया गया</string>
<string name="delete">हटाएं</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ur/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

<!-- Menu and Dialog Items -->
<string name="more_options">مزید اختیارات</string>
<string name="open_with">اس کے ساتھ کھولیں</string>
<string name="copy_link">لنک کاپی کریں</string>
<string name="link_copied">لنک کاپی ہو گیا</string>
<string name="delete">حذف کریں</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

<!-- Menu and Dialog Items -->
<string name="more_options">More options</string>
<string name="open_with">Open with</string>
<string name="copy_link">Copy link</string>
<string name="link_copied">Link copied</string>
<string name="delete">Delete</string>
Expand Down
Loading