remove default anime/manga sources
This commit is contained in:
parent
73be639397
commit
1e6041f99e
6 changed files with 16 additions and 183 deletions
|
@ -4,6 +4,7 @@ import android.animation.ObjectAnimator
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.SharedPreferences
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
@ -41,6 +42,8 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
|
@ -268,18 +271,8 @@ class AnimeFragment : Fragment() {
|
||||||
model.loaded = true
|
model.loaded = true
|
||||||
model.loadTrending(1)
|
model.loadTrending(1)
|
||||||
model.loadUpdated()
|
model.loadUpdated()
|
||||||
}
|
model.loadPopular("ANIME", sort = Anilist.sortBy[1], onList = Injekt.get<SharedPreferences>()
|
||||||
withContext(Dispatchers.Main) {
|
.getBoolean("popular_list", false))
|
||||||
if (isAdded) { // Check if the fragment is still attached
|
|
||||||
model.loadPopular(
|
|
||||||
"ANIME",
|
|
||||||
sort = Anilist.sortBy[1],
|
|
||||||
onList = requireContext().getSharedPreferences(
|
|
||||||
"Dantotsu",
|
|
||||||
Context.MODE_PRIVATE
|
|
||||||
)
|
|
||||||
.getBoolean("popular_list", false)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
live.postValue(false)
|
live.postValue(false)
|
||||||
_binding?.animeRefresh?.isRefreshing = false
|
_binding?.animeRefresh?.isRefreshing = false
|
||||||
|
@ -288,8 +281,6 @@ class AnimeFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
if (!model.loaded) Refresh.activity[this.hashCode()]!!.postValue(true)
|
if (!model.loaded) Refresh.activity[this.hashCode()]!!.postValue(true)
|
||||||
if (animePageAdapter.trendingViewPager != null) {
|
if (animePageAdapter.trendingViewPager != null) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package ani.dantotsu.home
|
||||||
import android.animation.ObjectAnimator
|
import android.animation.ObjectAnimator
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
@ -38,6 +39,8 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
|
@ -242,19 +245,8 @@ class MangaFragment : Fragment() {
|
||||||
model.loaded = true
|
model.loaded = true
|
||||||
model.loadTrending()
|
model.loadTrending()
|
||||||
model.loadTrendingNovel()
|
model.loadTrendingNovel()
|
||||||
}
|
model.loadPopular("MANGA", sort = Anilist.sortBy[1], onList = Injekt.get<SharedPreferences>()
|
||||||
withContext(Dispatchers.Main) {
|
.getBoolean("popular_list", false) )
|
||||||
if (isAdded) {
|
|
||||||
val sharedPrefs = requireContext().getSharedPreferences(
|
|
||||||
"Dantotsu",
|
|
||||||
Context.MODE_PRIVATE
|
|
||||||
)
|
|
||||||
val isPopularList = sharedPrefs.getBoolean("popular_list", false)
|
|
||||||
model.loadPopular(
|
|
||||||
"MANGA",
|
|
||||||
sort = Anilist.sortBy[1],
|
|
||||||
onList = isPopularList
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
live.postValue(false)
|
live.postValue(false)
|
||||||
_binding?.mangaRefresh?.isRefreshing = false
|
_binding?.mangaRefresh?.isRefreshing = false
|
||||||
|
@ -262,7 +254,6 @@ class MangaFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
if (!model.loaded) Refresh.activity[this.hashCode()]!!.postValue(true)
|
if (!model.loaded) Refresh.activity[this.hashCode()]!!.postValue(true)
|
||||||
|
|
|
@ -47,12 +47,8 @@ class MediaDetailsViewModel : ViewModel() {
|
||||||
|
|
||||||
|
|
||||||
fun loadSelected(media: Media, isDownload: Boolean = false): Selected {
|
fun loadSelected(media: Media, isDownload: Boolean = false): Selected {
|
||||||
val sharedPreferences = Injekt.get<SharedPreferences>()
|
|
||||||
val data = loadData<Selected>("${media.id}-select") ?: Selected().let {
|
val data = loadData<Selected>("${media.id}-select") ?: Selected().let {
|
||||||
it.sourceIndex = if (media.isAdult) 0 else when (media.anime != null) {
|
it.sourceIndex = 0
|
||||||
true -> sharedPreferences.getInt("settings_def_anime_source_s_r", 0)
|
|
||||||
else -> sharedPreferences.getInt(("settings_def_manga_source_s_r"), 0)
|
|
||||||
}
|
|
||||||
it.preferDub = loadData("settings_prefer_dub") ?: false
|
it.preferDub = loadData("settings_prefer_dub") ?: false
|
||||||
saveSelected(media.id, it)
|
saveSelected(media.id, it)
|
||||||
it
|
it
|
||||||
|
|
|
@ -190,30 +190,6 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
||||||
.show(this, tag)
|
.show(this, tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
val animeSource = getSharedPreferences(
|
|
||||||
"Dantotsu",
|
|
||||||
Context.MODE_PRIVATE
|
|
||||||
).getInt("settings_def_anime_source_s_r", 0)
|
|
||||||
if (AnimeSources.names.isNotEmpty() && animeSource in 0 until AnimeSources.names.size) {
|
|
||||||
binding.animeSource.setText(AnimeSources.names[animeSource], false)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.animeSource.setAdapter(
|
|
||||||
ArrayAdapter(
|
|
||||||
this,
|
|
||||||
R.layout.item_dropdown,
|
|
||||||
AnimeSources.names
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
binding.animeSource.setOnItemClickListener { _, _, i, _ ->
|
|
||||||
//saveData("settings_def_anime_source_s", i)
|
|
||||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
|
||||||
.putInt("settings_def_anime_source_s_r", i).apply()
|
|
||||||
binding.animeSource.clearFocus()
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.settingsPinnedAnimeSources.setOnClickListener {
|
binding.settingsPinnedAnimeSources.setOnClickListener {
|
||||||
val animeSourcesWithoutDownloadsSource =
|
val animeSourcesWithoutDownloadsSource =
|
||||||
AnimeSources.list.filter { it.name != "Downloaded" }
|
AnimeSources.list.filter { it.name != "Downloaded" }
|
||||||
|
@ -238,20 +214,10 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.setPositiveButton("OK") { dialog, _ ->
|
.setPositiveButton("OK") { dialog, _ ->
|
||||||
val oldDefaultSourceIndex = getSharedPreferences(
|
|
||||||
"Dantotsu",
|
|
||||||
Context.MODE_PRIVATE
|
|
||||||
).getInt("settings_def_anime_source_s_r", 0)
|
|
||||||
val oldName =
|
|
||||||
if (oldDefaultSourceIndex >= AnimeSources.names.size) "" else AnimeSources.names[oldDefaultSourceIndex]
|
|
||||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
||||||
.putStringSet("pinned_anime_sources", pinnedSources).apply()
|
.putStringSet("pinned_anime_sources", pinnedSources).apply()
|
||||||
AnimeSources.pinnedAnimeSources = pinnedSources
|
AnimeSources.pinnedAnimeSources = pinnedSources
|
||||||
AnimeSources.performReorderAnimeSources()
|
AnimeSources.performReorderAnimeSources()
|
||||||
val newDefaultSourceIndex =
|
|
||||||
if (oldName == "") 0 else AnimeSources.names.indexOf(oldName)
|
|
||||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
|
||||||
.putInt("settings_def_anime_source_s_r", newDefaultSourceIndex).apply()
|
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
.create()
|
.create()
|
||||||
|
@ -445,32 +411,6 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
||||||
saveData("settings_prefer_dub", isChecked)
|
saveData("settings_prefer_dub", isChecked)
|
||||||
}
|
}
|
||||||
|
|
||||||
//val mangaSource = loadData<Int>("settings_def_manga_source_s")?.let { if (it >= MangaSources.names.size) 0 else it } ?: 0
|
|
||||||
val mangaSource = getSharedPreferences(
|
|
||||||
"Dantotsu",
|
|
||||||
Context.MODE_PRIVATE
|
|
||||||
).getInt("settings_def_manga_source_s_r", 0)
|
|
||||||
if (MangaSources.names.isNotEmpty() && mangaSource in 0 until MangaSources.names.size) {
|
|
||||||
binding.mangaSource.setText(MangaSources.names[mangaSource], false)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up the dropdown adapter.
|
|
||||||
binding.mangaSource.setAdapter(
|
|
||||||
ArrayAdapter(
|
|
||||||
this,
|
|
||||||
R.layout.item_dropdown,
|
|
||||||
MangaSources.names
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
// Set up the item click listener for the dropdown.
|
|
||||||
binding.mangaSource.setOnItemClickListener { _, _, i, _ ->
|
|
||||||
//saveData("settings_def_manga_source_s", i)
|
|
||||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
|
||||||
.putInt("settings_def_manga_source_s_r", i).apply()
|
|
||||||
binding.mangaSource.clearFocus()
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.settingsPinnedMangaSources.setOnClickListener {
|
binding.settingsPinnedMangaSources.setOnClickListener {
|
||||||
val mangaSourcesWithoutDownloadsSource =
|
val mangaSourcesWithoutDownloadsSource =
|
||||||
MangaSources.list.filter { it.name != "Downloaded" }
|
MangaSources.list.filter { it.name != "Downloaded" }
|
||||||
|
@ -495,20 +435,10 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.setPositiveButton("OK") { dialog, _ ->
|
.setPositiveButton("OK") { dialog, _ ->
|
||||||
val oldDefaultSourceIndex = getSharedPreferences(
|
|
||||||
"Dantotsu",
|
|
||||||
Context.MODE_PRIVATE
|
|
||||||
).getInt("settings_def_manga_source_s_r", 0)
|
|
||||||
val oldName =
|
|
||||||
if (oldDefaultSourceIndex >= MangaSources.names.size) "" else MangaSources.names[oldDefaultSourceIndex]
|
|
||||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
||||||
.putStringSet("pinned_manga_sources", pinnedSources).apply()
|
.putStringSet("pinned_manga_sources", pinnedSources).apply()
|
||||||
MangaSources.pinnedMangaSources = pinnedSources
|
MangaSources.pinnedMangaSources = pinnedSources
|
||||||
MangaSources.performReorderMangaSources()
|
MangaSources.performReorderMangaSources()
|
||||||
val newDefaultSourceIndex =
|
|
||||||
if (oldName == "") 0 else MangaSources.names.indexOf(oldName)
|
|
||||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
|
||||||
.putInt("settings_def_manga_source_s_r", newDefaultSourceIndex).apply()
|
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
.create()
|
.create()
|
||||||
|
|
|
@ -27,15 +27,8 @@ class SubscriptionHelper {
|
||||||
isAdult: Boolean,
|
isAdult: Boolean,
|
||||||
isAnime: Boolean
|
isAnime: Boolean
|
||||||
): Selected {
|
): Selected {
|
||||||
val sharedPreferences = context.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)
|
|
||||||
val data = loadData<Selected>("${mediaId}-select", context) ?: Selected().let {
|
val data = loadData<Selected>("${mediaId}-select", context) ?: Selected().let {
|
||||||
it.sourceIndex =
|
it.sourceIndex = 0
|
||||||
if (isAdult) 0
|
|
||||||
else if (isAnime) {
|
|
||||||
sharedPreferences.getInt("settings_def_anime_source_s_r", 0)
|
|
||||||
} else {
|
|
||||||
sharedPreferences.getInt("settings_def_manga_source_s_r", 0)
|
|
||||||
}
|
|
||||||
it.preferDub = loadData("settings_prefer_dub", context) ?: false
|
it.preferDub = loadData("settings_prefer_dub", context) ?: false
|
||||||
it
|
it
|
||||||
}
|
}
|
||||||
|
|
|
@ -1134,40 +1134,6 @@
|
||||||
app:drawableEndCompat="@drawable/ic_round_arrow_drop_down_24"
|
app:drawableEndCompat="@drawable/ic_round_arrow_drop_down_24"
|
||||||
tools:ignore="TextContrastCheck" />
|
tools:ignore="TextContrastCheck" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:alpha="0.58"
|
|
||||||
android:fontFamily="@font/poppins_bold"
|
|
||||||
android:text="@string/default_source" />
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
|
||||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
app:boxCornerRadiusBottomEnd="8dp"
|
|
||||||
app:boxCornerRadiusBottomStart="8dp"
|
|
||||||
app:boxCornerRadiusTopEnd="8dp"
|
|
||||||
app:boxCornerRadiusTopStart="8dp"
|
|
||||||
app:hintAnimationEnabled="true"
|
|
||||||
app:startIconDrawable="@drawable/ic_round_source_24">
|
|
||||||
|
|
||||||
<AutoCompleteTextView
|
|
||||||
android:id="@+id/animeSource"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:fontFamily="@font/poppins_bold"
|
|
||||||
android:freezesText="false"
|
|
||||||
android:inputType="none"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:text="@string/watch"
|
|
||||||
android:textAllCaps="true"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
android:textSize="14sp"
|
|
||||||
tools:ignore="LabelFor,TextContrastCheck,DuplicateSpeakableTextCheck" />
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
|
@ -1374,40 +1340,6 @@
|
||||||
app:drawableEndCompat="@drawable/ic_round_arrow_drop_down_24"
|
app:drawableEndCompat="@drawable/ic_round_arrow_drop_down_24"
|
||||||
tools:ignore="TextContrastCheck" />
|
tools:ignore="TextContrastCheck" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:alpha="0.58"
|
|
||||||
android:fontFamily="@font/poppins_bold"
|
|
||||||
android:text="@string/default_source" />
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
|
||||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
app:boxCornerRadiusBottomEnd="8dp"
|
|
||||||
app:boxCornerRadiusBottomStart="8dp"
|
|
||||||
app:boxCornerRadiusTopEnd="8dp"
|
|
||||||
app:boxCornerRadiusTopStart="8dp"
|
|
||||||
app:hintAnimationEnabled="true"
|
|
||||||
app:startIconDrawable="@drawable/ic_round_source_24">
|
|
||||||
|
|
||||||
<AutoCompleteTextView
|
|
||||||
android:id="@+id/mangaSource"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:fontFamily="@font/poppins_bold"
|
|
||||||
android:freezesText="false"
|
|
||||||
android:inputType="none"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:text="@string/read"
|
|
||||||
android:textAllCaps="true"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
android:textSize="14sp"
|
|
||||||
tools:ignore="LabelFor,TextContrastCheck,DuplicateSpeakableTextCheck" />
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue