fix: some tweaks in settings

This commit is contained in:
aayush262 2024-04-04 22:59:58 +05:30
parent da56aecd5e
commit e0df092a70
4 changed files with 76 additions and 63 deletions

View file

@ -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<Set<String>>(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<Set<String>>(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<Set<String>>(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<Set<String>>(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()

View file

@ -50,16 +50,6 @@
app:iconSize="24dp"
app:iconTint="?attr/colorPrimary" />
<TextView
android:id="@+id/animeRepoHeading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:fontFamily="@font/poppins_bold"
android:text="@string/anime_repo_listing"
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
@ -67,16 +57,6 @@
android:layout_marginEnd="-16dp"
android:background="?android:attr/listDivider" />
<LinearLayout
android:id="@+id/animeRepoInventory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:paddingStart="36dp"
android:visibility="gone"
tools:ignore="RtlSymmetry"
android:orientation="vertical" />
<Button
android:id="@+id/animeAddRepository"
android:layout_width="match_parent"
@ -100,34 +80,24 @@
app:iconSize="24dp"
app:iconTint="?attr/colorPrimary" />
<TextView
android:id="@+id/mangaRepoHeading"
<LinearLayout
android:id="@+id/animeRepoInventory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:fontFamily="@font/poppins_bold"
android:text="@string/manga_repo_listing"
android:textSize="14sp"
android:layout_marginTop="8dp"
android:orientation="vertical"
android:paddingStart="36dp"
android:visibility="gone"
tools:ignore="RtlSymmetry" />
<View
android:id="@+id/mangaRepoDivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="-16dp"
android:layout_marginEnd="-16dp"
android:background="?android:attr/listDivider" />
<LinearLayout
android:id="@+id/mangaRepoInventory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:paddingStart="36dp"
android:visibility="gone"
tools:ignore="RtlSymmetry"
android:orientation="vertical" />
<Button
android:id="@+id/mangaAddRepository"
android:layout_width="match_parent"
@ -151,6 +121,23 @@
app:iconSize="24dp"
app:iconTint="?attr/colorPrimary" />
<LinearLayout
android:id="@+id/mangaRepoInventory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="vertical"
android:paddingStart="36dp"
android:visibility="gone"
tools:ignore="RtlSymmetry" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="-16dp"
android:layout_marginEnd="-16dp"
android:background="?android:attr/listDivider" />
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/settingsForceLegacyInstall"
android:layout_width="match_parent"
@ -209,8 +196,8 @@
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="-16dp"
android:layout_marginEnd="-16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="-16dp"
android:layout_marginBottom="16dp"
android:background="?android:attr/listDivider" />
</ani.dantotsu.others.Xpandable>

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:layout_marginBottom="16dp"
android:orientation="vertical">
@ -12,7 +12,10 @@
android:layout_height="wrap_content"
android:fontFamily="@font/poppins_semi_bold"
android:textSize="12sp"
android:ellipsize="end"
android:textAlignment="viewStart"
android:textColor="?attr/colorOnBackground" />
android:textColor="?attr/colorOnBackground"
android:singleLine="true"
tools:text="xyz repo"/>
</LinearLayout>

View file

@ -868,6 +868,7 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
<string name="anime_add_repository">Add Anime Repo</string>
<string name="manga_repo_listing">Manga Extension Repos</string>
<string name="manga_add_repository">Add Manga Repo</string>
<string name="add_repository">Add Repo</string>
<string name="long_click_delete">Long click to delete</string>
<string name="trending_movies">Trending Movies</string>