mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 19:32:16 +00:00
Fix: Parsing clipboard's content for repo URI (closes #244)
This commit is contained in:
parent
93dec1ed7a
commit
1750020e20
@ -66,13 +66,14 @@ data class Repository(
|
|||||||
|
|
||||||
fun newRepository(
|
fun newRepository(
|
||||||
address: String = "",
|
address: String = "",
|
||||||
|
fallbackName: String = "",
|
||||||
fingerprint: String = "",
|
fingerprint: String = "",
|
||||||
authentication: String = "",
|
authentication: String = "",
|
||||||
): Repository {
|
): Repository {
|
||||||
val name = try {
|
val name = try {
|
||||||
URL(address).let { "${it.host}${it.path}" }
|
URL(address).let { "${it.host}${it.path}" }
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
address
|
fallbackName
|
||||||
}
|
}
|
||||||
return Repository(
|
return Repository(
|
||||||
address = address,
|
address = address,
|
||||||
|
@ -151,7 +151,7 @@ class EditRepositorySheetX() : FullscreenBottomSheetDialogFragment(), RepoManage
|
|||||||
|
|
||||||
override fun updateSheet() {
|
override fun updateSheet() {
|
||||||
val repository = viewModel.repo.value
|
val repository = viewModel.repo.value
|
||||||
if (repository == null) {
|
if (repository == null || repository.address == "") {
|
||||||
val clipboardManager =
|
val clipboardManager =
|
||||||
requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
val text = clipboardManager.primaryClip
|
val text = clipboardManager.primaryClip
|
||||||
|
@ -63,7 +63,7 @@ class RepositoriesViewModelX(val repositoryDao: RepositoryDao) : ViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun addNewRepository(): Long = withContext(Dispatchers.IO) {
|
private suspend fun addNewRepository(): Long = withContext(Dispatchers.IO) {
|
||||||
repositoryDao.insert(newRepository(address = "new repository"))
|
repositoryDao.insert(newRepository(fallbackName = "new repository"))
|
||||||
repositoryDao.latestAddedId()
|
repositoryDao.latestAddedId()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user