From e0df092a701c9bed2b28aa5b28cada848ab3c9a7 Mon Sep 17 00:00:00 2001 From: aayush262 Date: Thu, 4 Apr 2024 22:59:58 +0530 Subject: [PATCH] fix: some tweaks in settings --- .../ani/dantotsu/settings/SettingsActivity.kt | 66 ++++++++++++------- .../layout/activity_settings_extensions.xml | 63 +++++++----------- app/src/main/res/layout/item_repository.xml | 9 ++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 76 insertions(+), 63 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt b/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt index 766c6a97ef..faa4d70f5c 100644 --- a/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt +++ b/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt @@ -599,19 +599,29 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene val view = ItemRepositoryBinding.inflate( LayoutInflater.from(animeRepoInventory.context), animeRepoInventory, true ) - view.repositoryItem.text = item + view.repositoryItem.text = item.replace("https://raw.githubusercontent.com/", "") view.repositoryItem.setOnClickListener { - snackString(getString(R.string.long_click_delete)) + AlertDialog.Builder(this@SettingsActivity, R.style.MyPopup) + .setTitle("Delete Anime Repository") + .setMessage(item) + .setPositiveButton(getString(R.string.ok)) { dialog, _ -> + val anime = PrefManager.getVal>(PrefName.AnimeExtensionRepos).minus(item) + PrefManager.setVal(PrefName.AnimeExtensionRepos, anime) + it.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) + setExtensionOutput() + CoroutineScope(Dispatchers.IO).launch { + animeExtensionManager.findAvailableExtensions() + } + dialog.dismiss() + } + .setNegativeButton(getString(R.string.cancel)) { dialog, _ -> + dialog.dismiss() + } + .create() + .show() } view.repositoryItem.setOnLongClickListener { - val anime = PrefManager.getVal>(PrefName.AnimeExtensionRepos) - .minus(item) - PrefManager.setVal(PrefName.AnimeExtensionRepos, anime) - it.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) - setExtensionOutput() - CoroutineScope(Dispatchers.IO).launch { - animeExtensionManager.findAvailableExtensions() - } + copyToClipboard(item, true) true } } @@ -621,19 +631,29 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene val view = ItemRepositoryBinding.inflate( LayoutInflater.from(mangaRepoInventory.context), mangaRepoInventory, true ) - view.repositoryItem.text = item + view.repositoryItem.text = item.replace("https://raw.githubusercontent.com/", "") view.repositoryItem.setOnClickListener { - snackString(getString(R.string.long_click_delete)) + AlertDialog.Builder(this@SettingsActivity, R.style.MyPopup) + .setTitle("Delete Manga Repository") + .setMessage(item) + .setPositiveButton(getString(R.string.ok)) { dialog, _ -> + val manga = PrefManager.getVal>(PrefName.MangaExtensionRepos).minus(item) + PrefManager.setVal(PrefName.MangaExtensionRepos, manga) + it.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) + setExtensionOutput() + CoroutineScope(Dispatchers.IO).launch { + mangaExtensionManager.findAvailableExtensions() + } + dialog.dismiss() + } + .setNegativeButton(getString(R.string.cancel)) { dialog, _ -> + dialog.dismiss() + } + .create() + .show() } view.repositoryItem.setOnLongClickListener { - val anime = PrefManager.getVal>(PrefName.MangaExtensionRepos) - .minus(item) - PrefManager.setVal(PrefName.MangaExtensionRepos, anime) - it.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) - setExtensionOutput() - CoroutineScope(Dispatchers.IO).launch { - mangaExtensionManager.findAvailableExtensions() - } + copyToClipboard(item, true) true } } @@ -684,7 +704,8 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene hint = getString(R.string.anime_add_repository) } val alertDialog = AlertDialog.Builder(this@SettingsActivity, R.style.MyPopup) - .setTitle(R.string.anime_add_repository) + .setTitle(R.string.add_repository) + .setMessage("Add additional repo for anime extensions") .setView(dialogView) .setPositiveButton(getString(R.string.ok)) { dialog, _ -> processUserInput(editText.text.toString(), MediaType.ANIME) @@ -712,8 +733,9 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene hint = getString(R.string.manga_add_repository) } val alertDialog = AlertDialog.Builder(this@SettingsActivity, R.style.MyPopup) - .setTitle(R.string.manga_add_repository) + .setTitle(R.string.add_repository) .setView(dialogView) + .setMessage("Add additional repo for manga extensions") .setPositiveButton(getString(R.string.ok)) { dialog, _ -> processUserInput(editText.text.toString(), MediaType.MANGA) dialog.dismiss() diff --git a/app/src/main/res/layout/activity_settings_extensions.xml b/app/src/main/res/layout/activity_settings_extensions.xml index f0309591cc..6929b3f1d2 100644 --- a/app/src/main/res/layout/activity_settings_extensions.xml +++ b/app/src/main/res/layout/activity_settings_extensions.xml @@ -50,16 +50,6 @@ app:iconSize="24dp" app:iconTint="?attr/colorPrimary" /> - - - -