Skip to content

Commit

Permalink
fix: some tweaks in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
aayush2622 committed Apr 4, 2024
1 parent da56aec commit e0df092
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 63 deletions.
66 changes: 44 additions & 22 deletions app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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)

This comment has been minimized.

Copy link
@rebelonion

rebelonion Apr 4, 2024

Owner

copyToClipboard should toast for older versions

true
}
}
Expand Down Expand Up @@ -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")

This comment was marked as off-topic.

Copy link
@AbandonedCart

AbandonedCart Apr 4, 2024

Contributor

Really struggling with the whole string resources thing, huh?

.setView(dialogView)
.setPositiveButton(getString(R.string.ok)) { dialog, _ ->
processUserInput(editText.text.toString(), MediaType.ANIME)
Expand Down Expand Up @@ -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()
Expand Down
63 changes: 25 additions & 38 deletions app/src/main/res/layout/activity_settings_extensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,33 +50,13 @@
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"
android:layout_marginStart="-16dp"
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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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>
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/res/layout/item_repository.xml
Original file line number Diff line number Diff line change
@@ -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">

Expand All @@ -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>
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 @@ -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>
Expand Down

0 comments on commit e0df092

Please sign in to comment.