reformat
This commit is contained in:
parent
1df528c0dc
commit
afa960c808
171 changed files with 3458 additions and 1915 deletions
|
@ -13,8 +13,6 @@ import ani.dantotsu.loadImage
|
|||
import ani.dantotsu.media.MediaDetailsViewModel
|
||||
import ani.dantotsu.others.getSerialized
|
||||
import ani.dantotsu.parsers.ShowResponse
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.others.LangSet
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
@ -25,13 +23,14 @@ class BookDialog : BottomSheetDialogFragment() {
|
|||
|
||||
private val viewModel by activityViewModels<MediaDetailsViewModel>()
|
||||
|
||||
private lateinit var novelName:String
|
||||
private lateinit var novelName: String
|
||||
private lateinit var novel: ShowResponse
|
||||
private var source:Int = 0
|
||||
private var source: Int = 0
|
||||
|
||||
interface Callback {
|
||||
fun onDownloadTriggered(link: String)
|
||||
}
|
||||
|
||||
private var callback: Callback? = null
|
||||
fun setCallback(callback: Callback) {
|
||||
this.callback = callback
|
||||
|
@ -46,7 +45,11 @@ class BookDialog : BottomSheetDialogFragment() {
|
|||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = BottomSheetBookBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
@ -55,7 +58,7 @@ class BookDialog : BottomSheetDialogFragment() {
|
|||
binding.bookRecyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||
|
||||
viewModel.book.observe(viewLifecycleOwner) {
|
||||
if(it!=null){
|
||||
if (it != null) {
|
||||
binding.itemBookTitle.text = it.name
|
||||
binding.itemBookDesc.text = it.description
|
||||
binding.itemBookImage.loadImage(it.img)
|
||||
|
@ -73,7 +76,7 @@ class BookDialog : BottomSheetDialogFragment() {
|
|||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(novelName:String, novel:ShowResponse, source: Int) : BookDialog{
|
||||
fun newInstance(novelName: String, novel: ShowResponse, source: Int): BookDialog {
|
||||
val bundle = Bundle().apply {
|
||||
putString("novelName", novelName)
|
||||
putInt("source", source)
|
||||
|
|
|
@ -22,12 +22,14 @@ class NovelReadAdapter(
|
|||
var progress: View? = null
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NovelReadAdapter.ViewHolder {
|
||||
val binding = ItemNovelHeaderBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
val binding =
|
||||
ItemNovelHeaderBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
progress = binding.progress.root
|
||||
return ViewHolder(binding)
|
||||
}
|
||||
|
||||
private val imm = fragment.requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
private val imm = fragment.requireContext()
|
||||
.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val binding = holder.binding
|
||||
|
@ -35,7 +37,8 @@ class NovelReadAdapter(
|
|||
|
||||
fun search(): Boolean {
|
||||
val query = binding.searchBarText.text.toString()
|
||||
val source = media.selected!!.sourceIndex.let { if (it >= novelReadSources.names.size) 0 else it }
|
||||
val source =
|
||||
media.selected!!.sourceIndex.let { if (it >= novelReadSources.names.size) 0 else it }
|
||||
fragment.source = source
|
||||
|
||||
binding.searchBarText.clearFocus()
|
||||
|
@ -44,11 +47,18 @@ class NovelReadAdapter(
|
|||
return true
|
||||
}
|
||||
|
||||
val source = media.selected!!.sourceIndex.let { if (it >= novelReadSources.names.size) 0 else it }
|
||||
val source =
|
||||
media.selected!!.sourceIndex.let { if (it >= novelReadSources.names.size) 0 else it }
|
||||
if (novelReadSources.names.isNotEmpty() && source in 0 until novelReadSources.names.size) {
|
||||
binding.animeSource.setText(novelReadSources.names[source], false)
|
||||
}
|
||||
binding.animeSource.setAdapter(ArrayAdapter(fragment.requireContext(), R.layout.item_dropdown, novelReadSources.names))
|
||||
binding.animeSource.setAdapter(
|
||||
ArrayAdapter(
|
||||
fragment.requireContext(),
|
||||
R.layout.item_dropdown,
|
||||
novelReadSources.names
|
||||
)
|
||||
)
|
||||
binding.animeSource.setOnItemClickListener { _, _, i, _ ->
|
||||
fragment.onSourceChange(i)
|
||||
search()
|
||||
|
@ -58,7 +68,7 @@ class NovelReadAdapter(
|
|||
binding.searchBarText.setOnEditorActionListener { _, actionId, _ ->
|
||||
return@setOnEditorActionListener when (actionId) {
|
||||
IME_ACTION_SEARCH -> search()
|
||||
else -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
binding.searchBar.setEndIconOnClickListener { search() }
|
||||
|
@ -66,5 +76,6 @@ class NovelReadAdapter(
|
|||
|
||||
override fun getItemCount(): Int = 1
|
||||
|
||||
inner class ViewHolder(val binding: ItemNovelHeaderBinding) : RecyclerView.ViewHolder(binding.root)
|
||||
inner class ViewHolder(val binding: ItemNovelHeaderBinding) :
|
||||
RecyclerView.ViewHolder(binding.root)
|
||||
}
|
|
@ -61,7 +61,8 @@ class NovelReadFragment : Fragment(),
|
|||
private var continueEp: Boolean = false
|
||||
var loaded = false
|
||||
|
||||
val uiSettings = loadData("ui_settings", toast = false) ?: UserInterfaceSettings().apply { saveData("ui_settings", this) }
|
||||
val uiSettings = loadData("ui_settings", toast = false)
|
||||
?: UserInterfaceSettings().apply { saveData("ui_settings", this) }
|
||||
|
||||
override fun downloadTrigger(novelDownloadPackage: NovelDownloadPackage) {
|
||||
Log.e("downloadTrigger", novelDownloadPackage.link)
|
||||
|
@ -90,10 +91,24 @@ class NovelReadFragment : Fragment(),
|
|||
|
||||
override fun downloadedCheckWithStart(novel: ShowResponse): Boolean {
|
||||
val downloadsManager = Injekt.get<DownloadsManager>()
|
||||
if(downloadsManager.queryDownload(Download(media.nameMAL ?: media.nameRomaji, novel.name, Download.Type.NOVEL))) {
|
||||
val file = File(context?.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), "${DownloadsManager.novelLocation}/${media.nameMAL ?: media.nameRomaji}/${novel.name}/0.epub")
|
||||
if (downloadsManager.queryDownload(
|
||||
Download(
|
||||
media.nameMAL ?: media.nameRomaji,
|
||||
novel.name,
|
||||
Download.Type.NOVEL
|
||||
)
|
||||
)
|
||||
) {
|
||||
val file = File(
|
||||
context?.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
|
||||
"${DownloadsManager.novelLocation}/${media.nameMAL ?: media.nameRomaji}/${novel.name}/0.epub"
|
||||
)
|
||||
if (!file.exists()) return false
|
||||
val fileUri = FileProvider.getUriForFile(requireContext(), "${requireContext().packageName}.provider", file)
|
||||
val fileUri = FileProvider.getUriForFile(
|
||||
requireContext(),
|
||||
"${requireContext().packageName}.provider",
|
||||
file
|
||||
)
|
||||
val intent = Intent(context, NovelReaderActivity::class.java).apply {
|
||||
action = Intent.ACTION_VIEW
|
||||
setDataAndType(fileUri, "application/epub+zip")
|
||||
|
@ -108,12 +123,24 @@ class NovelReadFragment : Fragment(),
|
|||
|
||||
override fun downloadedCheck(novel: ShowResponse): Boolean {
|
||||
val downloadsManager = Injekt.get<DownloadsManager>()
|
||||
return downloadsManager.queryDownload(Download(media.nameMAL ?: media.nameRomaji, novel.name, Download.Type.NOVEL))
|
||||
return downloadsManager.queryDownload(
|
||||
Download(
|
||||
media.nameMAL ?: media.nameRomaji,
|
||||
novel.name,
|
||||
Download.Type.NOVEL
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun deleteDownload(novel: ShowResponse) {
|
||||
val downloadsManager = Injekt.get<DownloadsManager>()
|
||||
downloadsManager.removeDownload(Download(media.nameMAL ?: media.nameRomaji, novel.name, Download.Type.NOVEL))
|
||||
downloadsManager.removeDownload(
|
||||
Download(
|
||||
media.nameMAL ?: media.nameRomaji,
|
||||
novel.name,
|
||||
Download.Type.NOVEL
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private val downloadStatusReceiver = object : BroadcastReceiver() {
|
||||
|
@ -126,18 +153,21 @@ class NovelReadFragment : Fragment(),
|
|||
novelResponseAdapter.startDownload(it)
|
||||
}
|
||||
}
|
||||
|
||||
ACTION_DOWNLOAD_FINISHED -> {
|
||||
val link = intent.getStringExtra(EXTRA_NOVEL_LINK)
|
||||
link?.let {
|
||||
novelResponseAdapter.stopDownload(it)
|
||||
}
|
||||
}
|
||||
|
||||
ACTION_DOWNLOAD_FAILED -> {
|
||||
val link = intent.getStringExtra(EXTRA_NOVEL_LINK)
|
||||
link?.let {
|
||||
novelResponseAdapter.purgeDownload(it)
|
||||
}
|
||||
}
|
||||
|
||||
ACTION_DOWNLOAD_PROGRESS -> {
|
||||
val link = intent.getStringExtra(EXTRA_NOVEL_LINK)
|
||||
val progress = intent.getIntExtra("progress", 0)
|
||||
|
@ -159,7 +189,12 @@ class NovelReadFragment : Fragment(),
|
|||
addAction(ACTION_DOWNLOAD_PROGRESS)
|
||||
}
|
||||
|
||||
ContextCompat.registerReceiver(requireContext(), downloadStatusReceiver, intentFilter ,ContextCompat.RECEIVER_EXPORTED)
|
||||
ContextCompat.registerReceiver(
|
||||
requireContext(),
|
||||
downloadStatusReceiver,
|
||||
intentFilter,
|
||||
ContextCompat.RECEIVER_EXPORTED
|
||||
)
|
||||
|
||||
binding.animeSourceRecycler.updatePadding(bottom = binding.animeSourceRecycler.paddingBottom + navBarHeight)
|
||||
|
||||
|
@ -179,8 +214,13 @@ class NovelReadFragment : Fragment(),
|
|||
val sel = media.selected
|
||||
searchQuery = sel?.server ?: media.name ?: media.nameRomaji
|
||||
headerAdapter = NovelReadAdapter(media, this, model.novelSources)
|
||||
novelResponseAdapter = NovelResponseAdapter(this, this, this) // probably a better way to do this but it works
|
||||
binding.animeSourceRecycler.adapter = ConcatAdapter(headerAdapter, novelResponseAdapter)
|
||||
novelResponseAdapter = NovelResponseAdapter(
|
||||
this,
|
||||
this,
|
||||
this
|
||||
) // probably a better way to do this but it works
|
||||
binding.animeSourceRecycler.adapter =
|
||||
ConcatAdapter(headerAdapter, novelResponseAdapter)
|
||||
loaded = true
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
search(searchQuery, sel?.sourceIndex ?: 0, auto = sel?.server == null)
|
||||
|
@ -206,7 +246,7 @@ class NovelReadFragment : Fragment(),
|
|||
searchQuery = query
|
||||
headerAdapter.progress?.visibility = View.VISIBLE
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
if (auto || query=="") model.autoSearchNovels(media)
|
||||
if (auto || query == "") model.autoSearchNovels(media)
|
||||
else model.searchNovels(query, source)
|
||||
}
|
||||
searching = true
|
||||
|
|
|
@ -13,11 +13,22 @@ import ani.dantotsu.parsers.Book
|
|||
import ani.dantotsu.setSafeOnClickListener
|
||||
import ani.dantotsu.tryWith
|
||||
|
||||
class UrlAdapter(private val urls: List<FileUrl>, val book: Book, val novel: String, val callback: BookDialog.Callback?) :
|
||||
class UrlAdapter(
|
||||
private val urls: List<FileUrl>,
|
||||
val book: Book,
|
||||
val novel: String,
|
||||
val callback: BookDialog.Callback?
|
||||
) :
|
||||
RecyclerView.Adapter<UrlAdapter.UrlViewHolder>() {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): UrlViewHolder {
|
||||
return UrlViewHolder(ItemUrlBinding.inflate(LayoutInflater.from(parent.context), parent, false))
|
||||
return UrlViewHolder(
|
||||
ItemUrlBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
|
|
|
@ -27,6 +27,7 @@ import ani.dantotsu.databinding.ActivityNovelReaderBinding
|
|||
import ani.dantotsu.hideSystemBars
|
||||
import ani.dantotsu.loadData
|
||||
import ani.dantotsu.others.ImageViewDialog
|
||||
import ani.dantotsu.others.LangSet
|
||||
import ani.dantotsu.saveData
|
||||
import ani.dantotsu.setSafeOnClickListener
|
||||
import ani.dantotsu.settings.CurrentNovelReaderSettings
|
||||
|
@ -35,7 +36,6 @@ import ani.dantotsu.settings.NovelReaderSettings
|
|||
import ani.dantotsu.settings.UserInterfaceSettings
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.others.LangSet
|
||||
import ani.dantotsu.tryWith
|
||||
import com.google.android.material.slider.Slider
|
||||
import com.vipulog.ebookreader.Book
|
||||
|
@ -161,7 +161,8 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener {
|
|||
|
||||
binding.novelReaderBack.setOnClickListener { finish() }
|
||||
binding.novelReaderSettings.setSafeOnClickListener {
|
||||
NovelReaderSettingsDialogFragment.newInstance().show(supportFragmentManager, NovelReaderSettingsDialogFragment.TAG)
|
||||
NovelReaderSettingsDialogFragment.newInstance()
|
||||
.show(supportFragmentManager, NovelReaderSettingsDialogFragment.TAG)
|
||||
}
|
||||
|
||||
val gestureDetector = GestureDetectorCompat(this, object : GesturesListener() {
|
||||
|
@ -233,14 +234,21 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener {
|
|||
binding.novelReaderSource.text = book.author?.joinToString(", ")
|
||||
|
||||
val tocLabels = book.toc.map { it.label ?: "" }
|
||||
binding.novelReaderChapterSelect.adapter = NoPaddingArrayAdapter(this, R.layout.item_dropdown, tocLabels)
|
||||
binding.novelReaderChapterSelect.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||
binding.bookReader.goto(book.toc[position].href)
|
||||
}
|
||||
binding.novelReaderChapterSelect.adapter =
|
||||
NoPaddingArrayAdapter(this, R.layout.item_dropdown, tocLabels)
|
||||
binding.novelReaderChapterSelect.onItemSelectedListener =
|
||||
object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(
|
||||
parent: AdapterView<*>?,
|
||||
view: View?,
|
||||
position: Int,
|
||||
id: Long
|
||||
) {
|
||||
binding.bookReader.goto(book.toc[position].href)
|
||||
}
|
||||
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {}
|
||||
}
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {}
|
||||
}
|
||||
|
||||
binding.bookReader.getAppearance {
|
||||
currentTheme = it
|
||||
|
@ -295,7 +303,7 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener {
|
|||
private var onVolumeDown: (() -> Unit)? = null
|
||||
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
||||
return when (event.keyCode) {
|
||||
KeyEvent.KEYCODE_VOLUME_UP, KeyEvent.KEYCODE_DPAD_UP, KeyEvent.KEYCODE_PAGE_UP -> {
|
||||
KeyEvent.KEYCODE_VOLUME_UP, KeyEvent.KEYCODE_DPAD_UP, KeyEvent.KEYCODE_PAGE_UP -> {
|
||||
if (event.keyCode == KeyEvent.KEYCODE_VOLUME_UP)
|
||||
if (!settings.default.volumeButtons)
|
||||
return false
|
||||
|
@ -315,7 +323,7 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener {
|
|||
} else false
|
||||
}
|
||||
|
||||
else -> {
|
||||
else -> {
|
||||
super.dispatchKeyEvent(event)
|
||||
}
|
||||
}
|
||||
|
@ -326,10 +334,11 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener {
|
|||
saveData("${sanitizedBookId}_current_settings", settings.default)
|
||||
hideBars()
|
||||
|
||||
currentTheme = themes.first { it.name.equals(settings.default.currentThemeName, ignoreCase = true) }
|
||||
currentTheme =
|
||||
themes.first { it.name.equals(settings.default.currentThemeName, ignoreCase = true) }
|
||||
|
||||
when (settings.default.layout) {
|
||||
CurrentNovelReaderSettings.Layouts.PAGED -> {
|
||||
CurrentNovelReaderSettings.Layouts.PAGED -> {
|
||||
currentTheme?.flow = ReaderFlow.PAGINATED
|
||||
}
|
||||
|
||||
|
@ -340,9 +349,10 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener {
|
|||
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER
|
||||
when (settings.default.dualPageMode) {
|
||||
CurrentReaderSettings.DualPageModes.No -> currentTheme?.maxColumnCount = 1
|
||||
CurrentReaderSettings.DualPageModes.No -> currentTheme?.maxColumnCount = 1
|
||||
CurrentReaderSettings.DualPageModes.Automatic -> currentTheme?.maxColumnCount = 2
|
||||
CurrentReaderSettings.DualPageModes.Force -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||
CurrentReaderSettings.DualPageModes.Force -> requestedOrientation =
|
||||
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||
}
|
||||
|
||||
currentTheme?.lineHeight = settings.default.lineHeight
|
||||
|
@ -393,7 +403,8 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener {
|
|||
isContVisible = false
|
||||
if (!isAnimating) {
|
||||
isAnimating = true
|
||||
ObjectAnimator.ofFloat(binding.novelReaderCont, "alpha", 1f, 0f).setDuration(controllerDuration).start()
|
||||
ObjectAnimator.ofFloat(binding.novelReaderCont, "alpha", 1f, 0f)
|
||||
.setDuration(controllerDuration).start()
|
||||
ObjectAnimator.ofFloat(binding.novelReaderBottomCont, "translationY", 0f, 128f)
|
||||
.apply { interpolator = overshoot;duration = controllerDuration;start() }
|
||||
ObjectAnimator.ofFloat(binding.novelReaderTopLayout, "translationY", 0f, -128f)
|
||||
|
@ -403,7 +414,8 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener {
|
|||
} else {
|
||||
isContVisible = true
|
||||
binding.novelReaderCont.visibility = View.VISIBLE
|
||||
ObjectAnimator.ofFloat(binding.novelReaderCont, "alpha", 0f, 1f).setDuration(controllerDuration).start()
|
||||
ObjectAnimator.ofFloat(binding.novelReaderCont, "alpha", 0f, 1f)
|
||||
.setDuration(controllerDuration).start()
|
||||
ObjectAnimator.ofFloat(binding.novelReaderTopLayout, "translationY", -128f, 0f)
|
||||
.apply { interpolator = overshoot;duration = controllerDuration;start() }
|
||||
ObjectAnimator.ofFloat(binding.novelReaderBottomCont, "translationY", 128f, 0f)
|
||||
|
@ -418,7 +430,10 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener {
|
|||
val displayCutout = window.decorView.rootWindowInsets.displayCutout
|
||||
if (displayCutout != null) {
|
||||
if (displayCutout.boundingRects.size > 0) {
|
||||
notchHeight = min(displayCutout.boundingRects[0].width(), displayCutout.boundingRects[0].height())
|
||||
notchHeight = min(
|
||||
displayCutout.boundingRects[0].width(),
|
||||
displayCutout.boundingRects[0].height()
|
||||
)
|
||||
applyNotchMargin()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,11 @@ class NovelReaderSettingsDialogFragment : BottomSheetDialogFragment() {
|
|||
private val binding get() = _binding!!
|
||||
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = BottomSheetCurrentNovelReaderSettingsBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
@ -29,10 +33,16 @@ class NovelReaderSettingsDialogFragment : BottomSheetDialogFragment() {
|
|||
val settings = activity.settings.default
|
||||
|
||||
val themeLabels = activity.themes.map { it.name }
|
||||
binding.themeSelect.adapter = NoPaddingArrayAdapter(activity, R.layout.item_dropdown, themeLabels)
|
||||
binding.themeSelect.adapter =
|
||||
NoPaddingArrayAdapter(activity, R.layout.item_dropdown, themeLabels)
|
||||
binding.themeSelect.setSelection(themeLabels.indexOfFirst { it == settings.currentThemeName })
|
||||
binding.themeSelect.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||
override fun onItemSelected(
|
||||
parent: AdapterView<*>?,
|
||||
view: View?,
|
||||
position: Int,
|
||||
id: Long
|
||||
) {
|
||||
settings.currentThemeName = themeLabels[position]
|
||||
activity.applySettings()
|
||||
}
|
||||
|
@ -54,7 +64,8 @@ class NovelReaderSettingsDialogFragment : BottomSheetDialogFragment() {
|
|||
selected.alpha = 0.33f
|
||||
selected = imageButton
|
||||
selected.alpha = 1f
|
||||
settings.layout = CurrentNovelReaderSettings.Layouts[index]?:CurrentNovelReaderSettings.Layouts.PAGED
|
||||
settings.layout = CurrentNovelReaderSettings.Layouts[index]
|
||||
?: CurrentNovelReaderSettings.Layouts.PAGED
|
||||
binding.layoutText.text = settings.layout.string
|
||||
activity.applySettings()
|
||||
}
|
||||
|
@ -75,7 +86,8 @@ class NovelReaderSettingsDialogFragment : BottomSheetDialogFragment() {
|
|||
selectedDual.alpha = 0.33f
|
||||
selectedDual = imageButton
|
||||
selectedDual.alpha = 1f
|
||||
settings.dualPageMode = CurrentReaderSettings.DualPageModes[index] ?: CurrentReaderSettings.DualPageModes.Automatic
|
||||
settings.dualPageMode = CurrentReaderSettings.DualPageModes[index]
|
||||
?: CurrentReaderSettings.DualPageModes.Automatic
|
||||
binding.dualPageText.text = settings.dualPageMode.toString()
|
||||
activity.applySettings()
|
||||
}
|
||||
|
@ -164,19 +176,19 @@ class NovelReaderSettingsDialogFragment : BottomSheetDialogFragment() {
|
|||
}
|
||||
|
||||
binding.useDarkTheme.isChecked = settings.useDarkTheme
|
||||
binding.useDarkTheme.setOnCheckedChangeListener { _,isChecked ->
|
||||
binding.useDarkTheme.setOnCheckedChangeListener { _, isChecked ->
|
||||
settings.useDarkTheme = isChecked
|
||||
activity.applySettings()
|
||||
}
|
||||
|
||||
binding.keepScreenOn.isChecked = settings.keepScreenOn
|
||||
binding.keepScreenOn.setOnCheckedChangeListener { _,isChecked ->
|
||||
binding.keepScreenOn.setOnCheckedChangeListener { _, isChecked ->
|
||||
settings.keepScreenOn = isChecked
|
||||
activity.applySettings()
|
||||
}
|
||||
|
||||
binding.volumeButton.isChecked = settings.volumeButtons
|
||||
binding.volumeButton.setOnCheckedChangeListener { _,isChecked ->
|
||||
binding.volumeButton.setOnCheckedChangeListener { _, isChecked ->
|
||||
settings.volumeButtons = isChecked
|
||||
activity.applySettings()
|
||||
}
|
||||
|
@ -189,7 +201,7 @@ class NovelReaderSettingsDialogFragment : BottomSheetDialogFragment() {
|
|||
}
|
||||
|
||||
|
||||
companion object{
|
||||
companion object {
|
||||
fun newInstance() = NovelReaderSettingsDialogFragment()
|
||||
const val TAG = "NovelReaderSettingsDialogFragment"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue