Language name in extension setting (#111)
* Full language name in ext settings * added more lang name * changed alter dialog view * sort language by names * 3x grid for 360DP mobiles * Default novel settings * Oled for LN * Lang full name * Notification icon changed to dantotsu * Remember 'sort' value
This commit is contained in:
parent
ef30869b62
commit
4286232d17
21 changed files with 1487 additions and 649 deletions
|
@ -78,7 +78,7 @@ class SearchActivity : AppCompatActivity() {
|
|||
mediaAdaptor = MediaAdaptor(style, model.searchResults.results, this, matchParent = true)
|
||||
val headerAdaptor = SearchAdapter(this)
|
||||
|
||||
val gridSize = (screenWidth / 124f).toInt()
|
||||
val gridSize = (screenWidth / 120f).toInt()
|
||||
val gridLayoutManager = GridLayoutManager(this, gridSize)
|
||||
gridLayoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
||||
override fun getSpanSize(position: Int): Int {
|
||||
|
|
|
@ -395,7 +395,7 @@ class AnimeWatchAdapter(
|
|||
val adapter = ArrayAdapter(
|
||||
fragment.requireContext(),
|
||||
R.layout.item_dropdown,
|
||||
parser.extension.sources.map { LanguageMapper.mapLanguageCodeToName(it.lang) }
|
||||
parser.extension.sources.sortedBy { it.lang }.map { LanguageMapper.mapLanguageCodeToName(it.lang) }
|
||||
)
|
||||
val items = adapter.count
|
||||
if (items > 1) binding?.animeSourceLanguageContainer?.visibility = View.VISIBLE else binding?.animeSourceLanguageContainer?.visibility = View.GONE
|
||||
|
|
|
@ -23,6 +23,7 @@ import ani.dantotsu.databinding.FragmentAnimeWatchBinding
|
|||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.media.MediaDetailsActivity
|
||||
import ani.dantotsu.media.MediaDetailsViewModel
|
||||
import ani.dantotsu.others.LanguageMapper
|
||||
import ani.dantotsu.parsers.AnimeParser
|
||||
import ani.dantotsu.parsers.AnimeSources
|
||||
import ani.dantotsu.parsers.HAnimeSources
|
||||
|
@ -314,19 +315,19 @@ class AnimeWatchFragment : Fragment() {
|
|||
if (show) View.GONE else View.VISIBLE
|
||||
}
|
||||
}
|
||||
var itemSelected = false
|
||||
val allSettings = pkg.sources.filterIsInstance<ConfigurableAnimeSource>()
|
||||
if (allSettings.isNotEmpty()) {
|
||||
var selectedSetting = allSettings[0]
|
||||
if (allSettings.size > 1) {
|
||||
val names = allSettings.map { it.lang }.toTypedArray()
|
||||
val names = allSettings.sortedBy { it.lang }.map { LanguageMapper.mapLanguageCodeToName(it.lang) }.toTypedArray()
|
||||
var selectedIndex = 0
|
||||
val dialog = AlertDialog.Builder(requireContext())
|
||||
val dialog = AlertDialog.Builder(requireContext() , R.style.MyPopup)
|
||||
.setTitle("Select a Source")
|
||||
.setSingleChoiceItems(names, selectedIndex) { _, which ->
|
||||
.setSingleChoiceItems(names, selectedIndex) { dialog, which ->
|
||||
selectedIndex = which
|
||||
}
|
||||
.setPositiveButton("OK") { dialog, _ ->
|
||||
selectedSetting = allSettings[selectedIndex]
|
||||
itemSelected = true
|
||||
dialog.dismiss()
|
||||
|
||||
// Move the fragment transaction here
|
||||
|
@ -343,10 +344,10 @@ class AnimeWatchFragment : Fragment() {
|
|||
.commit()
|
||||
}
|
||||
}
|
||||
.setNegativeButton("Cancel") { dialog, _ ->
|
||||
dialog.cancel()
|
||||
changeUIVisibility(true)
|
||||
return@setNegativeButton
|
||||
.setOnDismissListener {
|
||||
if (!itemSelected) {
|
||||
changeUIVisibility(true)
|
||||
}
|
||||
}
|
||||
.show()
|
||||
dialog.window?.setDimAmount(0.8f)
|
||||
|
|
|
@ -425,7 +425,7 @@ class MangaReadAdapter(
|
|||
val adapter = ArrayAdapter(
|
||||
fragment.requireContext(),
|
||||
R.layout.item_dropdown,
|
||||
parser.extension.sources.map { LanguageMapper.mapLanguageCodeToName(it.lang) }
|
||||
parser.extension.sources.sortedBy { it.lang }.map { LanguageMapper.mapLanguageCodeToName(it.lang) }
|
||||
)
|
||||
val items = adapter.count
|
||||
if (items > 1) binding?.animeSourceLanguageContainer?.visibility = View.VISIBLE else binding?.animeSourceLanguageContainer?.visibility = View.GONE
|
||||
|
|
|
@ -37,6 +37,7 @@ import ani.dantotsu.media.Media
|
|||
import ani.dantotsu.media.MediaDetailsActivity
|
||||
import ani.dantotsu.media.MediaDetailsViewModel
|
||||
import ani.dantotsu.media.manga.mangareader.ChapterLoaderDialog
|
||||
import ani.dantotsu.others.LanguageMapper
|
||||
import ani.dantotsu.parsers.DynamicMangaParser
|
||||
import ani.dantotsu.parsers.HMangaSources
|
||||
import ani.dantotsu.parsers.MangaParser
|
||||
|
@ -357,19 +358,19 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener {
|
|||
if (show) View.GONE else View.VISIBLE
|
||||
}
|
||||
}
|
||||
var itemSelected = false
|
||||
val allSettings = pkg.sources.filterIsInstance<ConfigurableSource>()
|
||||
if (allSettings.isNotEmpty()) {
|
||||
var selectedSetting = allSettings[0]
|
||||
if (allSettings.size > 1) {
|
||||
val names = allSettings.map { it.lang }.toTypedArray()
|
||||
val names = allSettings.sortedBy { it.lang }.map { LanguageMapper.mapLanguageCodeToName(it.lang) }.toTypedArray()
|
||||
var selectedIndex = 0
|
||||
val dialog = AlertDialog.Builder(requireContext())
|
||||
val dialog = AlertDialog.Builder(requireContext(), R.style.MyPopup)
|
||||
.setTitle("Select a Source")
|
||||
.setSingleChoiceItems(names, selectedIndex) { _, which ->
|
||||
.setSingleChoiceItems(names, selectedIndex) { dialog, which ->
|
||||
selectedIndex = which
|
||||
}
|
||||
.setPositiveButton("OK") { dialog, _ ->
|
||||
selectedSetting = allSettings[selectedIndex]
|
||||
itemSelected = true
|
||||
dialog.dismiss()
|
||||
|
||||
// Move the fragment transaction here
|
||||
|
@ -384,10 +385,10 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener {
|
|||
.addToBackStack(null)
|
||||
.commit()
|
||||
}
|
||||
.setNegativeButton("Cancel") { dialog, _ ->
|
||||
dialog.cancel()
|
||||
changeUIVisibility(true)
|
||||
return@setNegativeButton
|
||||
.setOnDismissListener {
|
||||
if (!itemSelected) {
|
||||
changeUIVisibility(true)
|
||||
}
|
||||
}
|
||||
.show()
|
||||
dialog.window?.setDimAmount(0.8f)
|
||||
|
|
|
@ -36,7 +36,7 @@ import ani.dantotsu.saveData
|
|||
import ani.dantotsu.setSafeOnClickListener
|
||||
import ani.dantotsu.settings.CurrentNovelReaderSettings
|
||||
import ani.dantotsu.settings.CurrentReaderSettings
|
||||
import ani.dantotsu.settings.NovelReaderSettings
|
||||
import ani.dantotsu.settings.ReaderSettings
|
||||
import ani.dantotsu.settings.UserInterfaceSettings
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
|
@ -62,7 +62,7 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener {
|
|||
private lateinit var binding: ActivityNovelReaderBinding
|
||||
private val scope = lifecycleScope
|
||||
|
||||
lateinit var settings: NovelReaderSettings
|
||||
lateinit var settings: ReaderSettings
|
||||
private lateinit var uiSettings: UserInterfaceSettings
|
||||
|
||||
private var notchHeight: Int? = null
|
||||
|
@ -159,9 +159,8 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener {
|
|||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityNovelReaderBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
settings = loadData("novel_reader_settings", this)
|
||||
?: NovelReaderSettings().apply { saveData("novel_reader_settings", this) }
|
||||
settings = loadData("reader_settings", this)
|
||||
?: ReaderSettings().apply { saveData("reader_settings", this) }
|
||||
uiSettings = loadData("ui_settings", this)
|
||||
?: UserInterfaceSettings().also { saveData("ui_settings", it) }
|
||||
|
||||
|
@ -271,7 +270,7 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener {
|
|||
binding.bookReader.getAppearance {
|
||||
currentTheme = it
|
||||
themes.add(0, it)
|
||||
settings.default = loadData("${sanitizedBookId}_current_settings") ?: settings.default
|
||||
settings.defaultLN = loadData("${sanitizedBookId}_current_settings") ?: settings.defaultLN
|
||||
applySettings()
|
||||
}
|
||||
|
||||
|
@ -323,7 +322,7 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener {
|
|||
return when (event.keyCode) {
|
||||
KeyEvent.KEYCODE_VOLUME_UP, KeyEvent.KEYCODE_DPAD_UP, KeyEvent.KEYCODE_PAGE_UP -> {
|
||||
if (event.keyCode == KeyEvent.KEYCODE_VOLUME_UP)
|
||||
if (!settings.default.volumeButtons)
|
||||
if (!settings.defaultLN.volumeButtons)
|
||||
return false
|
||||
if (event.action == KeyEvent.ACTION_DOWN) {
|
||||
onVolumeUp?.invoke()
|
||||
|
@ -333,7 +332,7 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener {
|
|||
|
||||
KeyEvent.KEYCODE_VOLUME_DOWN, KeyEvent.KEYCODE_DPAD_DOWN, KeyEvent.KEYCODE_PAGE_DOWN -> {
|
||||
if (event.keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
|
||||
if (!settings.default.volumeButtons)
|
||||
if (!settings.defaultLN.volumeButtons)
|
||||
return false
|
||||
if (event.action == KeyEvent.ACTION_DOWN) {
|
||||
onVolumeDown?.invoke()
|
||||
|
@ -349,13 +348,18 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener {
|
|||
|
||||
|
||||
fun applySettings() {
|
||||
saveData("${sanitizedBookId}_current_settings", settings.default)
|
||||
saveData("${sanitizedBookId}_current_settings", settings.defaultLN)
|
||||
hideBars()
|
||||
|
||||
if(settings.defaultLN.useOledTheme) {
|
||||
themes.forEach { theme ->
|
||||
theme.darkBg = Color.parseColor("#000000")
|
||||
}
|
||||
}
|
||||
currentTheme =
|
||||
themes.first { it.name.equals(settings.default.currentThemeName, ignoreCase = true) }
|
||||
themes.first { it.name.equals(settings.defaultLN.currentThemeName, ignoreCase = true) }
|
||||
|
||||
when (settings.default.layout) {
|
||||
when (settings.defaultLN.layout) {
|
||||
CurrentNovelReaderSettings.Layouts.PAGED -> {
|
||||
currentTheme?.flow = ReaderFlow.PAGINATED
|
||||
}
|
||||
|
@ -366,22 +370,22 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener {
|
|||
}
|
||||
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER
|
||||
when (settings.default.dualPageMode) {
|
||||
when (settings.defaultLN.dualPageMode) {
|
||||
CurrentReaderSettings.DualPageModes.No -> currentTheme?.maxColumnCount = 1
|
||||
CurrentReaderSettings.DualPageModes.Automatic -> currentTheme?.maxColumnCount = 2
|
||||
CurrentReaderSettings.DualPageModes.Force -> requestedOrientation =
|
||||
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||
}
|
||||
|
||||
currentTheme?.lineHeight = settings.default.lineHeight
|
||||
currentTheme?.gap = settings.default.margin
|
||||
currentTheme?.maxInlineSize = settings.default.maxInlineSize
|
||||
currentTheme?.maxBlockSize = settings.default.maxBlockSize
|
||||
currentTheme?.useDark = settings.default.useDarkTheme
|
||||
currentTheme?.lineHeight = settings.defaultLN.lineHeight
|
||||
currentTheme?.gap = settings.defaultLN.margin
|
||||
currentTheme?.maxInlineSize = settings.defaultLN.maxInlineSize
|
||||
currentTheme?.maxBlockSize = settings.defaultLN.maxBlockSize
|
||||
currentTheme?.useDark = settings.defaultLN.useDarkTheme
|
||||
|
||||
currentTheme?.let { binding.bookReader.setAppearance(it) }
|
||||
|
||||
if (settings.default.keepScreenOn) window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
if (settings.defaultLN.keepScreenOn) window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
else window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,7 @@ class NovelReaderSettingsDialogFragment : BottomSheetDialogFragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val activity = requireActivity() as NovelReaderActivity
|
||||
val settings = activity.settings.default
|
||||
|
||||
val settings = activity.settings.defaultLN
|
||||
val themeLabels = activity.themes.map { it.name }
|
||||
binding.themeSelect.adapter =
|
||||
NoPaddingArrayAdapter(activity, R.layout.item_dropdown, themeLabels)
|
||||
|
@ -49,7 +48,11 @@ class NovelReaderSettingsDialogFragment : BottomSheetDialogFragment() {
|
|||
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {}
|
||||
}
|
||||
|
||||
binding.useOledTheme.isChecked = settings.useOledTheme
|
||||
binding.useOledTheme.setOnCheckedChangeListener { _, isChecked ->
|
||||
settings.useOledTheme = isChecked
|
||||
activity.applySettings()
|
||||
}
|
||||
val layoutList = listOf(
|
||||
binding.paged,
|
||||
binding.continuous
|
||||
|
@ -173,6 +176,20 @@ class NovelReaderSettingsDialogFragment : BottomSheetDialogFragment() {
|
|||
binding.maxBlockSize.setText(value.toString())
|
||||
activity.applySettings()
|
||||
}
|
||||
|
||||
}
|
||||
binding.incrementMaxBlockSize.setOnClickListener {
|
||||
val value = binding.maxBlockSize.text.toString().toIntOrNull() ?: 720
|
||||
settings.maxBlockSize = value + 10
|
||||
binding.maxBlockSize.setText(settings.maxBlockSize.toString())
|
||||
activity.applySettings()
|
||||
}
|
||||
|
||||
binding.decrementMaxBlockSize.setOnClickListener {
|
||||
val value = binding.maxBlockSize.text.toString().toIntOrNull() ?: 720
|
||||
settings.maxBlockSize = value - 10
|
||||
binding.maxBlockSize.setText(settings.maxBlockSize.toString())
|
||||
activity.applySettings()
|
||||
}
|
||||
|
||||
binding.useDarkTheme.isChecked = settings.useDarkTheme
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ani.dantotsu.media.user
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
|
@ -14,9 +15,11 @@ import androidx.lifecycle.MutableLiveData
|
|||
import androidx.lifecycle.lifecycleScope
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.Refresh
|
||||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.databinding.ActivityListBinding
|
||||
import ani.dantotsu.loadData
|
||||
import ani.dantotsu.others.LangSet
|
||||
import ani.dantotsu.saveData
|
||||
import ani.dantotsu.settings.UserInterfaceSettings
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
|
@ -144,7 +147,8 @@ class ListActivity : AppCompatActivity() {
|
|||
R.id.release -> "release"
|
||||
else -> null
|
||||
}
|
||||
|
||||
currContext()?.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)?.edit()
|
||||
?.putString("sort_order", sort)?.apply()
|
||||
binding.listProgressBar.visibility = View.VISIBLE
|
||||
binding.listViewPager.adapter = null
|
||||
scope.launch {
|
||||
|
|
|
@ -46,7 +46,7 @@ class ListFragment : Fragment() {
|
|||
binding.listRecyclerView.layoutManager =
|
||||
GridLayoutManager(
|
||||
requireContext(),
|
||||
if (grid!!) (screenWidth / 124f).toInt() else 1
|
||||
if (grid!!) (screenWidth / 120f).toInt() else 1
|
||||
)
|
||||
binding.listRecyclerView.adapter = adapter
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue