chore: clean
This commit is contained in:
parent
31a67c8edb
commit
f9f9767ecc
106 changed files with 855 additions and 584 deletions
|
@ -1,6 +1,5 @@
|
|||
package ani.dantotsu.media.manga
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
|
|
@ -22,8 +22,8 @@ import ani.dantotsu.currActivity
|
|||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.databinding.CustomDialogLayoutBinding
|
||||
import ani.dantotsu.databinding.DialogLayoutBinding
|
||||
import ani.dantotsu.databinding.ItemMediaSourceBinding
|
||||
import ani.dantotsu.databinding.ItemChipBinding
|
||||
import ani.dantotsu.databinding.ItemMediaSourceBinding
|
||||
import ani.dantotsu.isOnline
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.media.Media
|
||||
|
@ -75,7 +75,8 @@ class MangaReadAdapter(
|
|||
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val bind = ItemMediaSourceBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
val bind =
|
||||
ItemMediaSourceBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
return ViewHolder(bind)
|
||||
}
|
||||
|
||||
|
@ -99,11 +100,11 @@ class MangaReadAdapter(
|
|||
}
|
||||
val offline = !isOnline(binding.root.context) || PrefManager.getVal(PrefName.OfflineMode)
|
||||
//for removing saved progress
|
||||
binding.sourceTitle.setOnLongClickListener{
|
||||
binding.sourceTitle.setOnLongClickListener {
|
||||
fragment.requireContext().customAlertDialog().apply {
|
||||
setTitle(" Delete Progress for all chapters of ${media.nameRomaji}")
|
||||
setMessage("This will delete all the locally stored progress for chapters")
|
||||
setPosButton(R.string.ok){
|
||||
setPosButton(R.string.ok) {
|
||||
clearCustomValsForMedia("${media.id}", "_Chapter")
|
||||
clearCustomValsForMedia("${media.id}", "_Vol")
|
||||
snackString("Deleted the progress of Chapters for ${media.nameRomaji}")
|
||||
|
@ -286,7 +287,7 @@ class MangaReadAdapter(
|
|||
fragment.requireContext().customAlertDialog().apply {
|
||||
setTitle(" Delete Progress for all chapters of ${media.nameRomaji}")
|
||||
setMessage("This will delete all the locally stored progress for chapters")
|
||||
setPosButton(R.string.ok){
|
||||
setPosButton(R.string.ok) {
|
||||
// Usage
|
||||
clearCustomValsForMedia("${media.id}", "_Chapter")
|
||||
clearCustomValsForMedia("${media.id}", "_Vol")
|
||||
|
@ -297,7 +298,7 @@ class MangaReadAdapter(
|
|||
show()
|
||||
}
|
||||
}
|
||||
resetProgressDef.text = getString(currContext()!!,R.string.clear_stored_chapter)
|
||||
resetProgressDef.text = getString(currContext()!!, R.string.clear_stored_chapter)
|
||||
|
||||
// Scanlator
|
||||
mangaScanlatorContainer.isVisible = options.count() > 1
|
||||
|
@ -331,12 +332,17 @@ class MangaReadAdapter(
|
|||
val checkBox = CheckBox(currContext()).apply {
|
||||
text = option
|
||||
setOnCheckedChangeListener { _, _ ->
|
||||
tickAllButton.setImageResource(getToggleImageResource(checkboxContainer))
|
||||
tickAllButton.setImageResource(
|
||||
getToggleImageResource(
|
||||
checkboxContainer
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (media.selected!!.scanlators != null) {
|
||||
checkBox.isChecked = media.selected!!.scanlators?.contains(option) != true
|
||||
checkBox.isChecked =
|
||||
media.selected!!.scanlators?.contains(option) != true
|
||||
scanlatorSelectionListener?.onScanlatorsSelected()
|
||||
} else {
|
||||
checkBox.isChecked = true
|
||||
|
@ -488,10 +494,12 @@ class MangaReadAdapter(
|
|||
}
|
||||
}
|
||||
val formattedChapters = filteredChapters.map {
|
||||
MediaNameAdapter.findChapterNumber(it.value.number)?.toInt()?.toString() to it.key
|
||||
MediaNameAdapter.findChapterNumber(it.value.number)?.toInt()
|
||||
?.toString() to it.key
|
||||
}
|
||||
if (formattedChapters.any { it.first == continueNumber }) {
|
||||
var continueEp = media.manga.chapters!![formattedChapters.first { it.first == continueNumber }.second]
|
||||
var continueEp =
|
||||
media.manga.chapters!![formattedChapters.first { it.first == continueNumber }.second]
|
||||
binding.sourceContinue.visibility = View.VISIBLE
|
||||
handleProgress(
|
||||
binding.itemMediaProgressCont,
|
||||
|
@ -501,9 +509,11 @@ class MangaReadAdapter(
|
|||
continueEp!!.number
|
||||
)
|
||||
if ((binding.itemMediaProgress.layoutParams as LinearLayout.LayoutParams).weight > 0.8f) {
|
||||
val numberPlusOne = formattedChapters.indexOfFirst { it.first?.toIntOrNull() == continueNumber.toInt() + 1 }
|
||||
val numberPlusOne =
|
||||
formattedChapters.indexOfFirst { it.first?.toIntOrNull() == continueNumber.toInt() + 1 }
|
||||
if (numberPlusOne != -1) {
|
||||
continueEp = media.manga.chapters!![formattedChapters[numberPlusOne].second]
|
||||
continueEp =
|
||||
media.manga.chapters!![formattedChapters[numberPlusOne].second]
|
||||
}
|
||||
}
|
||||
binding.itemMediaImage.loadImage(media.banner ?: media.cover)
|
||||
|
@ -530,7 +540,8 @@ class MangaReadAdapter(
|
|||
binding.sourceProgressBar.visibility = View.GONE
|
||||
|
||||
val sourceFound = filteredChapters.isNotEmpty()
|
||||
val isDownloadedSource = mangaReadSources[media.selected!!.sourceIndex] is OfflineMangaParser
|
||||
val isDownloadedSource =
|
||||
mangaReadSources[media.selected!!.sourceIndex] is OfflineMangaParser
|
||||
|
||||
if (isDownloadedSource) {
|
||||
binding.sourceNotFound.text = if (sourceFound) {
|
||||
|
@ -539,7 +550,8 @@ class MangaReadAdapter(
|
|||
currActivity()!!.getString(R.string.download_not_found)
|
||||
}
|
||||
} else {
|
||||
binding.sourceNotFound.text = currActivity()!!.getString(R.string.source_not_found)
|
||||
binding.sourceNotFound.text =
|
||||
currActivity()!!.getString(R.string.source_not_found)
|
||||
}
|
||||
|
||||
binding.sourceNotFound.isGone = sourceFound
|
||||
|
|
|
@ -261,13 +261,14 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener {
|
|||
val chapters = loadedChapters[media.selected!!.sourceIndex]
|
||||
if (chapters != null) {
|
||||
headerAdapter.options = getScanlators(chapters)
|
||||
val filteredChapters = if (model.mangaReadSources?.get(media.selected!!.sourceIndex) is OfflineMangaParser) {
|
||||
chapters
|
||||
} else {
|
||||
chapters.filterNot { (_, chapter) ->
|
||||
chapter.scanlator in headerAdapter.hiddenScanlators
|
||||
val filteredChapters =
|
||||
if (model.mangaReadSources?.get(media.selected!!.sourceIndex) is OfflineMangaParser) {
|
||||
chapters
|
||||
} else {
|
||||
chapters.filterNot { (_, chapter) ->
|
||||
chapter.scanlator in headerAdapter.hiddenScanlators
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
media.manga?.chapters = filteredChapters.toMutableMap()
|
||||
|
||||
|
@ -397,17 +398,18 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener {
|
|||
selectedSetting = allSettings[which]
|
||||
itemSelected = true
|
||||
|
||||
val fragment = MangaSourcePreferencesFragment().getInstance(selectedSetting.id) {
|
||||
changeUIVisibility(true)
|
||||
loadChapters(media.selected!!.sourceIndex, true)
|
||||
}
|
||||
val fragment =
|
||||
MangaSourcePreferencesFragment().getInstance(selectedSetting.id) {
|
||||
changeUIVisibility(true)
|
||||
loadChapters(media.selected!!.sourceIndex, true)
|
||||
}
|
||||
parentFragmentManager.beginTransaction()
|
||||
.setCustomAnimations(R.anim.slide_up, R.anim.slide_down)
|
||||
.replace(R.id.fragmentExtensionsContainer, fragment)
|
||||
.addToBackStack(null)
|
||||
.commit()
|
||||
}
|
||||
onDismiss{
|
||||
onDismiss {
|
||||
if (!itemSelected) {
|
||||
changeUIVisibility(true)
|
||||
}
|
||||
|
@ -590,7 +592,9 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener {
|
|||
|
||||
// Find latest chapter for subscription
|
||||
selected.latest =
|
||||
media.manga?.chapters?.values?.maxOfOrNull { MediaNameAdapter.findChapterNumber(it.number) ?: 0f } ?: 0f
|
||||
media.manga?.chapters?.values?.maxOfOrNull {
|
||||
MediaNameAdapter.findChapterNumber(it.number) ?: 0f
|
||||
} ?: 0f
|
||||
selected.latest =
|
||||
media.userProgress?.toFloat()?.takeIf { selected.latest < it } ?: selected.latest
|
||||
|
||||
|
|
|
@ -78,7 +78,8 @@ class ChapterLoaderDialog : BottomSheetDialogFragment() {
|
|||
_binding = BottomSheetSelectorBinding.inflate(inflater, container, false)
|
||||
val window = dialog?.window
|
||||
window?.statusBarColor = Color.TRANSPARENT
|
||||
window?.navigationBarColor = requireContext().getThemeColor(com.google.android.material.R.attr.colorSurface)
|
||||
window?.navigationBarColor =
|
||||
requireContext().getThemeColor(com.google.android.material.R.attr.colorSurface)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package ani.dantotsu.media.manga.mangareader
|
|||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.res.Configuration
|
||||
|
@ -58,8 +57,6 @@ import ani.dantotsu.media.Media
|
|||
import ani.dantotsu.media.MediaDetailsViewModel
|
||||
import ani.dantotsu.media.MediaNameAdapter
|
||||
import ani.dantotsu.media.MediaSingleton
|
||||
import ani.dantotsu.media.anime.ExoplayerView
|
||||
import ani.dantotsu.media.anime.ExoplayerView.Companion
|
||||
import ani.dantotsu.media.manga.MangaCache
|
||||
import ani.dantotsu.media.manga.MangaChapter
|
||||
import ani.dantotsu.others.ImageViewDialog
|
||||
|
@ -196,8 +193,9 @@ class MangaReaderActivity : AppCompatActivity() {
|
|||
finish()
|
||||
return@addCallback
|
||||
}
|
||||
val chapter = (MediaNameAdapter.findChapterNumber(media.manga!!.selectedChapter!!.number)
|
||||
?.minus(1L) ?: 0).toString()
|
||||
val chapter =
|
||||
(MediaNameAdapter.findChapterNumber(media.manga!!.selectedChapter!!.number)
|
||||
?.minus(1L) ?: 0).toString()
|
||||
if (chapter == "0.0" && PrefManager.getVal(PrefName.ChapterZeroReader)
|
||||
// Not asking individually or incognito
|
||||
&& !showProgressDialog && !PrefManager.getVal<Boolean>(PrefName.Incognito)
|
||||
|
|
|
@ -55,6 +55,7 @@ class Swipy @JvmOverloads constructor(
|
|||
else
|
||||
VerticalPosition.Top
|
||||
}
|
||||
|
||||
!it.canScrollVertically(1) -> VerticalPosition.Bottom
|
||||
!it.canScrollVertically(-1) -> VerticalPosition.Top
|
||||
else -> VerticalPosition.None
|
||||
|
@ -67,6 +68,7 @@ class Swipy @JvmOverloads constructor(
|
|||
else
|
||||
HorizontalPosition.Left
|
||||
}
|
||||
|
||||
!it.canScrollHorizontally(1) -> HorizontalPosition.Right
|
||||
!it.canScrollHorizontally(-1) -> HorizontalPosition.Left
|
||||
else -> HorizontalPosition.None
|
||||
|
@ -97,12 +99,14 @@ class Swipy @JvmOverloads constructor(
|
|||
initialDown = if (vertical) ev.getY(0) else ev.getX(0)
|
||||
isBeingDragged = false
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
val pointerIndex = ev.findPointerIndex(activePointerId)
|
||||
if (pointerIndex >= 0) {
|
||||
startDragging(if (vertical) ev.getY(pointerIndex) else ev.getX(pointerIndex))
|
||||
}
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_POINTER_UP -> onSecondaryPointerUp(ev)
|
||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
||||
isBeingDragged = false
|
||||
|
@ -122,6 +126,7 @@ class Swipy @JvmOverloads constructor(
|
|||
activePointerId = ev.getPointerId(0)
|
||||
isBeingDragged = false
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
pointerIndex = ev.findPointerIndex(activePointerId)
|
||||
if (pointerIndex >= 0) {
|
||||
|
@ -130,28 +135,36 @@ class Swipy @JvmOverloads constructor(
|
|||
if (isBeingDragged) handleDrag(pos)
|
||||
}
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_POINTER_DOWN -> {
|
||||
pointerIndex = ev.actionIndex
|
||||
if (pointerIndex >= 0) activePointerId = ev.getPointerId(pointerIndex)
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_POINTER_UP -> onSecondaryPointerUp(ev)
|
||||
MotionEvent.ACTION_UP -> {
|
||||
resetSwipes()
|
||||
pointerIndex = ev.findPointerIndex(activePointerId)
|
||||
if (pointerIndex >= 0) finishSpinner(if (vertical) ev.getY(pointerIndex) else ev.getX(pointerIndex))
|
||||
if (pointerIndex >= 0) finishSpinner(
|
||||
if (vertical) ev.getY(pointerIndex) else ev.getX(
|
||||
pointerIndex
|
||||
)
|
||||
)
|
||||
activePointerId = INVALID_POINTER
|
||||
return false
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_CANCEL -> return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun startDragging(pos: Float) {
|
||||
val posDiff = if ((vertical && verticalPos == VerticalPosition.Top) || (!vertical && horizontalPos == HorizontalPosition.Left))
|
||||
pos - initialDown
|
||||
else
|
||||
initialDown - pos
|
||||
val posDiff =
|
||||
if ((vertical && verticalPos == VerticalPosition.Top) || (!vertical && horizontalPos == HorizontalPosition.Left))
|
||||
pos - initialDown
|
||||
else
|
||||
initialDown - pos
|
||||
if (posDiff > touchSlop && !isBeingDragged) {
|
||||
initialMotion = initialDown + touchSlop
|
||||
isBeingDragged = true
|
||||
|
@ -185,7 +198,7 @@ class Swipy @JvmOverloads constructor(
|
|||
leftBeingSwiped.invoke(0f)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun finishSpinner(overscrollDistance: Float) {
|
||||
if (vertical) {
|
||||
val totalDragDistance = Resources.getSystem().displayMetrics.heightPixels / dragDivider
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue