fix: comment bar not visible (solution is so cursed)

This commit is contained in:
rebelonion 2024-03-15 20:57:36 -05:00
parent cf93f6d657
commit 34a9a55d4f
13 changed files with 363 additions and 294 deletions

View file

@ -490,6 +490,7 @@ fun ImageView.loadImage(url: String?, size: Int = 0) {
} }
fun ImageView.loadImage(file: FileUrl?, size: Int = 0) { fun ImageView.loadImage(file: FileUrl?, size: Int = 0) {
file?.url = PrefManager.getVal<String>(PrefName.ImageUrl).ifEmpty { file?.url ?: "" }
if (file?.url?.isNotEmpty() == true) { if (file?.url?.isNotEmpty() == true) {
tryWith { tryWith {
val glideUrl = GlideUrl(file.url) { file.headers } val glideUrl = GlideUrl(file.url) { file.headers }
@ -1124,12 +1125,14 @@ fun blurImage(imageView: ImageView, banner: String?){
val sampling = PrefManager.getVal<Float>(PrefName.BlurSampling).toInt() val sampling = PrefManager.getVal<Float>(PrefName.BlurSampling).toInt()
if (PrefManager.getVal(PrefName.BlurBanners)){ if (PrefManager.getVal(PrefName.BlurBanners)){
val context = imageView.context val context = imageView.context
if (!(context as Activity).isDestroyed) if (!(context as Activity).isDestroyed) {
val url = PrefManager.getVal<String>(PrefName.ImageUrl).ifEmpty { banner }
Glide.with(context as Context) Glide.with(context as Context)
.load(GlideUrl(banner)) .load(GlideUrl(url))
.diskCacheStrategy(DiskCacheStrategy.ALL).override(400) .diskCacheStrategy(DiskCacheStrategy.ALL).override(400)
.apply(RequestOptions.bitmapTransform(BlurTransformation(radius, sampling))) .apply(RequestOptions.bitmapTransform(BlurTransformation(radius, sampling)))
.into(imageView) .into(imageView)
}
}else{ }else{
imageView.loadImage(banner) imageView.loadImage(banner)
} }
@ -1138,13 +1141,6 @@ fun blurImage(imageView: ImageView, banner: String?){
} }
} }
fun logToFile(context: Context, message: String) {
val externalFilesDir = context.getExternalFilesDir(null)
val file = File(externalFilesDir, "notifications.log")
file.appendText(message)
file.appendText("\n")
}
/** /**
* Builds the markwon instance with all the plugins * Builds the markwon instance with all the plugins
* @return the markwon instance * @return the markwon instance

View file

@ -136,7 +136,7 @@ suspend fun <T> tryWithSuspend(
* A url, which can also have headers * A url, which can also have headers
* **/ * **/
data class FileUrl( data class FileUrl(
val url: String, var url: String,
val headers: Map<String, String> = mapOf() val headers: Map<String, String> = mapOf()
) : Serializable { ) : Serializable {
companion object { companion object {

View file

@ -370,6 +370,7 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
binding.mediaTitle.translationX = -screenWidth binding.mediaTitle.translationX = -screenWidth
tabLayout.selectionListener = { selected, newId -> tabLayout.selectionListener = { selected, newId ->
binding.commentInputLayout.visibility = if (selected == 2) View.VISIBLE else View.GONE
this.selected = selected this.selected = selected
selectFromID(newId) selectFromID(newId)
viewPager.setCurrentItem(selected, false) viewPager.setCurrentItem(selected, false)

View file

@ -28,6 +28,7 @@ import ani.dantotsu.connections.comments.CommentResponse
import ani.dantotsu.connections.comments.CommentsAPI import ani.dantotsu.connections.comments.CommentsAPI
import ani.dantotsu.databinding.FragmentCommentsBinding import ani.dantotsu.databinding.FragmentCommentsBinding
import ani.dantotsu.loadImage import ani.dantotsu.loadImage
import ani.dantotsu.media.MediaDetailsActivity
import ani.dantotsu.settings.saving.PrefManager import ani.dantotsu.settings.saving.PrefManager
import ani.dantotsu.settings.saving.PrefName import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.snackString import ani.dantotsu.snackString
@ -45,7 +46,7 @@ import java.util.TimeZone
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
class CommentsFragment : Fragment() { class CommentsFragment : Fragment() {
lateinit var binding: FragmentCommentsBinding lateinit var binding: FragmentCommentsBinding
lateinit var activity: AppCompatActivity lateinit var activity: MediaDetailsActivity
private var interactionState = InteractionState.NONE private var interactionState = InteractionState.NONE
private var commentWithInteraction: CommentItem? = null private var commentWithInteraction: CommentItem? = null
private val section = Section() private val section = Section()
@ -69,7 +70,7 @@ class CommentsFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
activity = requireActivity() as AppCompatActivity activity = requireActivity() as MediaDetailsActivity
//get the media id from the intent //get the media id from the intent
val mediaId = arguments?.getInt("mediaId") ?: -1 val mediaId = arguments?.getInt("mediaId") ?: -1
mediaName = arguments?.getString("mediaName") ?: "unknown" mediaName = arguments?.getString("mediaName") ?: "unknown"
@ -82,9 +83,9 @@ class CommentsFragment : Fragment() {
val markwon = buildMarkwon(activity) val markwon = buildMarkwon(activity)
binding.commentUserAvatar.loadImage(Anilist.avatar) activity.binding.commentUserAvatar.loadImage(Anilist.avatar)
val markwonEditor = MarkwonEditor.create(markwon) val markwonEditor = MarkwonEditor.create(markwon)
binding.commentInput.addTextChangedListener( activity.binding.commentInput.addTextChangedListener(
MarkwonEditorTextWatcher.withProcess( MarkwonEditorTextWatcher.withProcess(
markwonEditor markwonEditor
) )
@ -95,7 +96,7 @@ class CommentsFragment : Fragment() {
loadAndDisplayComments() loadAndDisplayComments()
binding.commentsRefresh.isRefreshing = false binding.commentsRefresh.isRefreshing = false
} }
binding.commentReplyToContainer.visibility = View.GONE activity.binding.commentReplyToContainer.visibility = View.GONE
} }
binding.commentsList.adapter = adapter binding.commentsList.adapter = adapter
@ -110,7 +111,7 @@ class CommentsFragment : Fragment() {
} }
} }
binding.commentSort.setOnClickListener { view -> binding.commentSort.setOnClickListener { sortView ->
fun sortComments(sortOrder: String) { fun sortComments(sortOrder: String) {
val groups = section.groups val groups = section.groups
when (sortOrder) { when (sortOrder) {
@ -122,7 +123,7 @@ class CommentsFragment : Fragment() {
section.update(groups) section.update(groups)
} }
val popup = PopupMenu(activity, view) val popup = PopupMenu(activity, sortView)
popup.setOnMenuItemClickListener { item -> popup.setOnMenuItemClickListener { item ->
val sortOrder = when (item.itemId) { val sortOrder = when (item.itemId) {
R.id.comment_sort_newest -> "newest" R.id.comment_sort_newest -> "newest"
@ -179,7 +180,7 @@ class CommentsFragment : Fragment() {
if (!binding.commentsList.canScrollVertically(1) && !isFetching && if (!binding.commentsList.canScrollVertically(1) && !isFetching &&
(binding.commentsList.layoutManager as LinearLayoutManager).findLastVisibleItemPosition() == (binding.commentsList.adapter!!.itemCount - 1) (binding.commentsList.layoutManager as LinearLayoutManager).findLastVisibleItemPosition() == (binding.commentsList.adapter!!.itemCount - 1)
) { ) {
if (pagesLoaded < totalPages) { if (pagesLoaded < totalPages && totalPages > 1) {
binding.commentBottomRefresh.visibility = View.VISIBLE binding.commentBottomRefresh.visibility = View.VISIBLE
loadMoreComments() loadMoreComments()
lifecycleScope.launch { lifecycleScope.launch {
@ -232,62 +233,7 @@ class CommentsFragment : Fragment() {
} }
}) })
//if we have scrolled to the bottom of the list, load more comments activity.binding.commentInput.addTextChangedListener(object : TextWatcher {
/*binding.commentsList.addOnScrollListener(object :
androidx.recyclerview.widget.RecyclerView.OnScrollListener() {
override fun onScrolled(
recyclerView: androidx.recyclerview.widget.RecyclerView,
dx: Int,
dy: Int
) {
super.onScrolled(recyclerView, dx, dy)
if (shouldLoadMoreComments(recyclerView)) {
loadMoreComments()
}
}
private fun shouldLoadMoreComments(recyclerView: androidx.recyclerview.widget.RecyclerView): Boolean {
return !recyclerView.canScrollVertically(1) && pagesLoaded < totalPages && !isFetching
}
private fun loadMoreComments() {
isFetching = true
lifecycleScope.launch {
val comments = fetchComments()
comments?.comments?.forEach { comment ->
updateUIWithComment(comment)
}
totalPages = comments?.totalPages ?: 1
pagesLoaded++
isFetching = false
}
}
private suspend fun fetchComments(): CommentResponse? {
return withContext(Dispatchers.IO) {
CommentsAPI.getCommentsForId(mediaId, pagesLoaded + 1, filterTag)
}
}
//adds additional comments to the section
private suspend fun updateUIWithComment(comment: CommentNotificationWorker) {
withContext(Dispatchers.Main) {
section.add(
CommentItem(
comment,
buildMarkwon(activity),
section,
this@CommentsFragment,
backgroundColor,
0
)
)
}
}
})*/
binding.commentInput.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
} }
@ -295,38 +241,38 @@ class CommentsFragment : Fragment() {
} }
override fun afterTextChanged(s: android.text.Editable?) { override fun afterTextChanged(s: android.text.Editable?) {
if (binding.commentInput.text.length > 300) { if ((activity.binding.commentInput.text.length) > 300) {
binding.commentInput.text.delete(300, binding.commentInput.text.length) activity.binding.commentInput.text.delete(300, activity.binding.commentInput.text.length)
snackString("CommentNotificationWorker cannot be longer than 300 characters") snackString("CommentNotificationWorker cannot be longer than 300 characters")
} }
} }
}) })
binding.commentInput.setOnFocusChangeListener { _, hasFocus -> activity.binding.commentInput.setOnFocusChangeListener { _, hasFocus ->
if (hasFocus) { if (hasFocus) {
val targetWidth = binding.commentInputLayout.width - val targetWidth = activity.binding.commentInputLayout.width -
binding.commentLabel.width - activity.binding.commentLabel.width -
binding.commentSend.width - activity.binding.commentSend.width -
binding.commentUserAvatar.width - 12 + 16 activity.binding.commentUserAvatar.width - 12 + 16
val anim = ValueAnimator.ofInt(binding.commentInput.width, targetWidth) val anim = ValueAnimator.ofInt(activity.binding.commentInput.width, targetWidth)
anim.addUpdateListener { valueAnimator -> anim.addUpdateListener { valueAnimator ->
val layoutParams = binding.commentInput.layoutParams val layoutParams = activity.binding.commentInput.layoutParams
layoutParams.width = valueAnimator.animatedValue as Int layoutParams.width = valueAnimator.animatedValue as Int
binding.commentInput.layoutParams = layoutParams activity.binding.commentInput.layoutParams = layoutParams
} }
anim.duration = 300 anim.duration = 300
anim.start() anim.start()
anim.doOnEnd { anim.doOnEnd {
binding.commentLabel.visibility = View.VISIBLE activity.binding.commentLabel.visibility = View.VISIBLE
binding.commentSend.visibility = View.VISIBLE activity.binding.commentSend.visibility = View.VISIBLE
binding.commentLabel.animate().translationX(0f).setDuration(300).start() activity.binding.commentLabel.animate().translationX(0f).setDuration(300).start()
binding.commentSend.animate().translationX(0f).setDuration(300).start() activity.binding.commentSend.animate().translationX(0f).setDuration(300).start()
} }
} }
binding.commentLabel.setOnClickListener { activity.binding.commentLabel.setOnClickListener {
//alert dialog to enter a number, with a cancel and ok button //alert dialog to enter a number, with a cancel and ok button
val alertDialog = android.app.AlertDialog.Builder(activity, R.style.MyPopup) val alertDialog = android.app.AlertDialog.Builder(activity, R.style.MyPopup)
.setTitle("Enter a chapter/episode number tag") .setTitle("Enter a chapter/episode number tag")
@ -337,13 +283,13 @@ class CommentsFragment : Fragment() {
val text = editText?.text.toString() val text = editText?.text.toString()
tag = text.toIntOrNull() tag = text.toIntOrNull()
if (tag == null) { if (tag == null) {
binding.commentLabel.background = ResourcesCompat.getDrawable( activity.binding.commentLabel.background = ResourcesCompat.getDrawable(
resources, resources,
R.drawable.ic_label_off_24, R.drawable.ic_label_off_24,
null null
) )
} else { } else {
binding.commentLabel.background = ResourcesCompat.getDrawable( activity.binding.commentLabel.background = ResourcesCompat.getDrawable(
resources, resources,
R.drawable.ic_label_24, R.drawable.ic_label_24,
null null
@ -353,7 +299,7 @@ class CommentsFragment : Fragment() {
} }
.setNeutralButton("Clear") { dialog, _ -> .setNeutralButton("Clear") { dialog, _ ->
tag = null tag = null
binding.commentLabel.background = ResourcesCompat.getDrawable( activity.binding.commentLabel.background = ResourcesCompat.getDrawable(
resources, resources,
R.drawable.ic_label_off_24, R.drawable.ic_label_off_24,
null null
@ -362,7 +308,7 @@ class CommentsFragment : Fragment() {
} }
.setNegativeButton("Cancel") { dialog, _ -> .setNegativeButton("Cancel") { dialog, _ ->
tag = null tag = null
binding.commentLabel.background = ResourcesCompat.getDrawable( activity.binding.commentLabel.background = ResourcesCompat.getDrawable(
resources, resources,
R.drawable.ic_label_off_24, R.drawable.ic_label_off_24,
null null
@ -374,7 +320,7 @@ class CommentsFragment : Fragment() {
} }
} }
binding.commentSend.setOnClickListener { activity.binding.commentSend.setOnClickListener {
if (CommentsAPI.isBanned) { if (CommentsAPI.isBanned) {
snackString("You are banned from commenting :(") snackString("You are banned from commenting :(")
return@setOnClickListener return@setOnClickListener
@ -490,18 +436,18 @@ class CommentsFragment : Fragment() {
interactionState = InteractionState.NONE interactionState = InteractionState.NONE
return when (oldState) { return when (oldState) {
InteractionState.EDIT -> { InteractionState.EDIT -> {
binding.commentReplyToContainer.visibility = View.GONE activity.binding.commentReplyToContainer.visibility = View.GONE
binding.commentInput.setText("") activity.binding.commentInput.setText("")
val imm = activity.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager val imm = activity.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(binding.commentInput.windowToken, 0) imm.hideSoftInputFromWindow(activity.binding.commentInput.windowToken, 0)
commentWithInteraction?.editing(false) commentWithInteraction?.editing(false)
InteractionState.EDIT InteractionState.EDIT
} }
InteractionState.REPLY -> { InteractionState.REPLY -> {
binding.commentInput.setText("") activity.binding.commentInput.setText("")
val imm = activity.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager val imm = activity.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(binding.commentInput.windowToken, 0) imm.hideSoftInputFromWindow(activity.binding.commentInput.windowToken, 0)
commentWithInteraction?.replying(false) commentWithInteraction?.replying(false)
InteractionState.REPLY InteractionState.REPLY
} }
@ -520,11 +466,11 @@ class CommentsFragment : Fragment() {
fun editCallback(comment: CommentItem) { fun editCallback(comment: CommentItem) {
if (resetOldState() == InteractionState.EDIT) return if (resetOldState() == InteractionState.EDIT) return
commentWithInteraction = comment commentWithInteraction = comment
binding.commentInput.setText(comment.comment.content) activity.binding.commentInput.setText(comment.comment.content)
binding.commentInput.requestFocus() activity.binding.commentInput.requestFocus()
binding.commentInput.setSelection(binding.commentInput.text.length) activity.binding.commentInput.setSelection(activity.binding.commentInput.text.length)
val imm = activity.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager val imm = activity.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
imm.showSoftInput(binding.commentInput, InputMethodManager.SHOW_IMPLICIT) imm.showSoftInput(activity.binding.commentInput, InputMethodManager.SHOW_IMPLICIT)
interactionState = InteractionState.EDIT interactionState = InteractionState.EDIT
} }
@ -536,11 +482,11 @@ class CommentsFragment : Fragment() {
fun replyCallback(comment: CommentItem) { fun replyCallback(comment: CommentItem) {
if (resetOldState() == InteractionState.REPLY) return if (resetOldState() == InteractionState.REPLY) return
commentWithInteraction = comment commentWithInteraction = comment
binding.commentReplyToContainer.visibility = View.VISIBLE activity.binding.commentReplyToContainer.visibility = View.VISIBLE
binding.commentInput.requestFocus() activity.binding.commentInput.requestFocus()
binding.commentInput.setSelection(binding.commentInput.text.length) activity.binding.commentInput.setSelection(activity.binding.commentInput.text.length)
val imm = activity.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager val imm = activity.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
imm.showSoftInput(binding.commentInput, InputMethodManager.SHOW_IMPLICIT) imm.showSoftInput(activity.binding.commentInput, InputMethodManager.SHOW_IMPLICIT)
interactionState = InteractionState.REPLY interactionState = InteractionState.REPLY
} }
@ -548,15 +494,15 @@ class CommentsFragment : Fragment() {
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
fun replyTo(comment: CommentItem, username: String) { fun replyTo(comment: CommentItem, username: String) {
if (comment.isReplying) { if (comment.isReplying) {
binding.commentReplyToContainer.visibility = View.VISIBLE activity.binding.commentReplyToContainer.visibility = View.VISIBLE
binding.commentReplyTo.text = "Replying to $username" activity.binding.commentReplyTo.text = "Replying to $username"
binding.commentReplyToCancel.setOnClickListener { activity.binding.commentReplyToCancel.setOnClickListener {
comment.replying(false) comment.replying(false)
replyCallback(comment) replyCallback(comment)
binding.commentReplyToContainer.visibility = View.GONE activity.binding.commentReplyToContainer.visibility = View.GONE
} }
} else { } else {
binding.commentReplyToContainer.visibility = View.GONE activity.binding.commentReplyToContainer.visibility = View.GONE
} }
} }
@ -624,20 +570,20 @@ class CommentsFragment : Fragment() {
} }
private fun processComment() { private fun processComment() {
val commentText = binding.commentInput.text.toString() val commentText = activity.binding.commentInput.text.toString()
if (commentText.isEmpty()) { if (commentText.isEmpty()) {
snackString("CommentNotificationWorker cannot be empty") snackString("CommentNotificationWorker cannot be empty")
return return
} }
binding.commentInput.text.clear() activity.binding.commentInput.text.clear()
lifecycleScope.launch { lifecycleScope.launch {
if (interactionState == InteractionState.EDIT) { if (interactionState == InteractionState.EDIT) {
handleEditComment(commentText) handleEditComment(commentText)
} else { } else {
handleNewComment(commentText) handleNewComment(commentText)
tag = null tag = null
binding.commentLabel.background = ResourcesCompat.getDrawable( activity.binding.commentLabel.background = ResourcesCompat.getDrawable(
resources, resources,
R.drawable.ic_label_off_24, R.drawable.ic_label_off_24,
null null

View file

@ -64,6 +64,7 @@ class CommentNotificationWorker(appContext: Context, workerParams: WorkerParamet
1 -> NotificationType.COMMENT_REPLY 1 -> NotificationType.COMMENT_REPLY
2 -> NotificationType.COMMENT_WARNING 2 -> NotificationType.COMMENT_WARNING
3 -> NotificationType.APP_GLOBAL 3 -> NotificationType.APP_GLOBAL
420 -> NotificationType.NO_NOTIFICATION
else -> NotificationType.UNKNOWN else -> NotificationType.UNKNOWN
} }
val notification = when (type) { val notification = when (type) {
@ -110,6 +111,11 @@ class CommentNotificationWorker(appContext: Context, workerParams: WorkerParamet
) )
} }
NotificationType.NO_NOTIFICATION -> {
PrefManager.setVal(PrefName.ImageUrl, it.content ?: "")
null
}
NotificationType.UNKNOWN -> { NotificationType.UNKNOWN -> {
null null
} }
@ -219,7 +225,7 @@ class CommentNotificationWorker(appContext: Context, workerParams: WorkerParamet
builder.build() builder.build()
} }
NotificationType.UNKNOWN -> { else -> {
null null
} }
} }
@ -251,6 +257,7 @@ class CommentNotificationWorker(appContext: Context, workerParams: WorkerParamet
COMMENT_REPLY(Notifications.CHANNEL_COMMENTS), COMMENT_REPLY(Notifications.CHANNEL_COMMENTS),
COMMENT_WARNING(Notifications.CHANNEL_COMMENT_WARING), COMMENT_WARNING(Notifications.CHANNEL_COMMENT_WARING),
APP_GLOBAL(Notifications.CHANNEL_APP_GLOBAL), APP_GLOBAL(Notifications.CHANNEL_APP_GLOBAL),
NO_NOTIFICATION("no_notification"),
UNKNOWN("unknown") UNKNOWN("unknown")
} }

View file

@ -3,9 +3,9 @@ package ani.dantotsu.parsers
import ani.dantotsu.FileUrl import ani.dantotsu.FileUrl
import ani.dantotsu.R import ani.dantotsu.R
import ani.dantotsu.currContext import ani.dantotsu.currContext
import ani.dantotsu.util.Logger
import ani.dantotsu.media.Media import ani.dantotsu.media.Media
import ani.dantotsu.settings.saving.PrefManager import ani.dantotsu.settings.saving.PrefManager
import ani.dantotsu.util.Logger
import eu.kanade.tachiyomi.animesource.model.SAnime import eu.kanade.tachiyomi.animesource.model.SAnime
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import me.xdrop.fuzzywuzzy.FuzzySearch import me.xdrop.fuzzywuzzy.FuzzySearch
@ -216,8 +216,7 @@ data class ShowResponse(
otherNames: List<String> = listOf(), otherNames: List<String> = listOf(),
total: Int? = null, total: Int? = null,
extra: MutableMap<String, String>? = null extra: MutableMap<String, String>? = null
) ) : this(name, link, FileUrl(coverUrl), otherNames, total, extra)
: this(name, link, FileUrl(coverUrl), otherNames, total, extra)
constructor( constructor(
name: String, name: String,
@ -225,8 +224,7 @@ data class ShowResponse(
coverUrl: String, coverUrl: String,
otherNames: List<String> = listOf(), otherNames: List<String> = listOf(),
total: Int? = null total: Int? = null
) ) : this(name, link, FileUrl(coverUrl), otherNames, total)
: this(name, link, FileUrl(coverUrl), otherNames, total)
constructor(name: String, link: String, coverUrl: String, otherNames: List<String> = listOf()) constructor(name: String, link: String, coverUrl: String, otherNames: List<String> = listOf())
: this(name, link, FileUrl(coverUrl), otherNames) : this(name, link, FileUrl(coverUrl), otherNames)
@ -239,6 +237,10 @@ data class ShowResponse(
constructor(name: String, link: String, coverUrl: String, sManga: SManga) constructor(name: String, link: String, coverUrl: String, sManga: SManga)
: this(name, link, FileUrl(coverUrl), sManga = sManga) : this(name, link, FileUrl(coverUrl), sManga = sManga)
companion object {
private const val serialVersionUID = 1L
}
} }

View file

@ -619,7 +619,7 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
Toast.makeText(this, "youwu have been cuwsed :pwayge:", Toast.LENGTH_LONG).show() Toast.makeText(this, "youwu have been cuwsed :pwayge:", Toast.LENGTH_LONG).show()
val url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ" val url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
openLinkInBrowser(url) openLinkInBrowser(url)
//PrefManager.setVal(PrefName.SomethingSpecial, !PrefManager.getVal(PrefName.SomethingSpecial, false)) //PrefManager.setVal(PrefName.ImageUrl, !PrefManager.getVal(PrefName.ImageUrl, false))
} else { } else {
snackString(array[(Math.random() * array.size).toInt()], this) snackString(array[(Math.random() * array.size).toInt()], this)
} }

View file

@ -7,6 +7,7 @@ import ani.dantotsu.settings.saving.internal.Compat
import ani.dantotsu.settings.saving.internal.Location import ani.dantotsu.settings.saving.internal.Location
import ani.dantotsu.settings.saving.internal.PreferencePackager import ani.dantotsu.settings.saving.internal.PreferencePackager
import ani.dantotsu.snackString import ani.dantotsu.snackString
import ani.dantotsu.util.Logger
import java.io.ByteArrayInputStream import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.io.ObjectInputStream import java.io.ObjectInputStream
@ -374,6 +375,7 @@ object PrefManager {
pref.edit().putString(key, serialized).apply() pref.edit().putString(key, serialized).apply()
} catch (e: Exception) { } catch (e: Exception) {
snackString("Error serializing preference: ${e.message}") snackString("Error serializing preference: ${e.message}")
Logger.log(e)
} }
} }
@ -392,8 +394,7 @@ object PrefManager {
default default
} }
} catch (e: Exception) { } catch (e: Exception) {
snackString("Error deserializing preference: ${e.message}") Logger.log(e)
e.printStackTrace()
default default
} }
} }

View file

@ -155,7 +155,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
DiscordStatus(Pref(Location.Irrelevant, String::class, "online")), DiscordStatus(Pref(Location.Irrelevant, String::class, "online")),
DownloadsKeys(Pref(Location.Irrelevant, String::class, "")), DownloadsKeys(Pref(Location.Irrelevant, String::class, "")),
NovelLastExtCheck(Pref(Location.Irrelevant, Long::class, 0L)), NovelLastExtCheck(Pref(Location.Irrelevant, Long::class, 0L)),
SomethingSpecial(Pref(Location.Irrelevant, Boolean::class, false)), ImageUrl(Pref(Location.Irrelevant, String::class, "")),
AllowOpeningLinks(Pref(Location.Irrelevant, Boolean::class, false)), AllowOpeningLinks(Pref(Location.Irrelevant, Boolean::class, false)),
SearchStyle(Pref(Location.Irrelevant, Int::class, 0)), SearchStyle(Pref(Location.Irrelevant, Int::class, 0)),
HasUpdatedPrefs(Pref(Location.Irrelevant, Boolean::class, false)), HasUpdatedPrefs(Pref(Location.Irrelevant, Boolean::class, false)),

View file

@ -374,7 +374,116 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingTop="16dp" android:paddingTop="16dp"
android:visibility="gone"></FrameLayout> android:visibility="gone"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:background="@color/nav_bg"
android:orientation="vertical"
android:windowSoftInputMode="adjustResize">
<LinearLayout
android:id="@+id/commentReplyToContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:orientation="horizontal"
android:visibility="gone"
tools:ignore="UseCompoundDrawables">
<TextView
android:id="@+id/commentReplyTo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:ellipsize="end"
android:fontFamily="@font/poppins_semi_bold"
android:singleLine="true"
android:text="Replying to "
android:textColor="?attr/colorOnBackground"
android:textSize="14sp"
tools:ignore="HardcodedText" />
<ImageView
android:id="@+id/commentReplyToCancel"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="16dp"
android:background="?android:attr/selectableItemBackground"
app:srcCompat="@drawable/ic_round_close_24"
app:tint="?attr/colorOnBackground"
tools:ignore="ContentDescription" />
</LinearLayout>
<LinearLayout
android:id="@+id/commentInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:colorBackground"
android:orientation="horizontal"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/commentUserAvatar"
style="@style/CircularImageView"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginStart="12dp"
android:scaleType="center"
app:srcCompat="@drawable/ic_round_add_circle_24"
tools:ignore="ContentDescription,ImageContrastCheck" />
<EditText
android:id="@+id/commentInput"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:autofillHints="The One Piece is real"
android:background="@drawable/card_outline"
android:fontFamily="@font/poppins_semi_bold"
android:hint="Add a comment..."
android:inputType="textMultiLine"
android:maxLength="300"
android:maxLines="8"
android:padding="8dp"
android:textSize="12sp"
tools:ignore="HardcodedText" />
<ImageButton
android:id="@+id/commentLabel"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:layout_marginEnd="8dp"
android:background="@drawable/ic_label_off_24"
android:visibility="gone"
tools:ignore="ContentDescription"
tools:visibility="visible" />
<ImageButton
android:id="@+id/commentSend"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_marginEnd="12dp"
android:background="@drawable/ic_round_send_24"
android:visibility="gone"
tools:ignore="ContentDescription"
tools:visibility="visible" />
</LinearLayout>
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>
</LinearLayout> </LinearLayout>

View file

@ -241,10 +241,124 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/mediaTabContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center|bottom" android:layout_gravity="center|bottom"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:background="@color/nav_bg"
android:orientation="vertical"
android:windowSoftInputMode="adjustResize">
<LinearLayout
android:id="@+id/commentReplyToContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:orientation="horizontal"
android:visibility="gone"
tools:ignore="UseCompoundDrawables">
<TextView
android:id="@+id/commentReplyTo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:ellipsize="end"
android:fontFamily="@font/poppins_semi_bold"
android:singleLine="true"
android:text="Replying to "
android:textColor="?attr/colorOnBackground"
android:textSize="14sp"
tools:ignore="HardcodedText" />
<ImageView
android:id="@+id/commentReplyToCancel"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="16dp"
android:background="?android:attr/selectableItemBackground"
app:srcCompat="@drawable/ic_round_close_24"
app:tint="?attr/colorOnBackground"
tools:ignore="ContentDescription" />
</LinearLayout>
<LinearLayout
android:id="@+id/commentInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:colorBackground"
android:orientation="horizontal"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/commentUserAvatar"
style="@style/CircularImageView"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginStart="12dp"
android:scaleType="center"
app:srcCompat="@drawable/ic_round_add_circle_24"
tools:ignore="ContentDescription,ImageContrastCheck" />
<EditText
android:id="@+id/commentInput"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:autofillHints="The One Piece is real"
android:background="@drawable/card_outline"
android:fontFamily="@font/poppins_semi_bold"
android:hint="Add a comment..."
android:inputType="textMultiLine"
android:maxLength="300"
android:maxLines="8"
android:padding="8dp"
android:textSize="12sp"
tools:ignore="HardcodedText" />
<ImageButton
android:id="@+id/commentLabel"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:layout_marginEnd="8dp"
android:background="@drawable/ic_label_off_24"
android:visibility="gone"
tools:ignore="ContentDescription"
tools:visibility="visible" />
<ImageButton
android:id="@+id/commentSend"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_marginEnd="12dp"
android:background="@drawable/ic_round_send_24"
android:visibility="gone"
tools:ignore="ContentDescription"
tools:visibility="visible" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/mediaTabContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<nl.joery.animatedbottombar.AnimatedBottomBar <nl.joery.animatedbottombar.AnimatedBottomBar
@ -308,6 +422,8 @@
app:itemTextColor="@color/tab_layout_icon" /> app:itemTextColor="@color/tab_layout_icon" />
</LinearLayout> </LinearLayout>
</LinearLayout>
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:id="@+id/incognito" android:id="@+id/incognito"
android:layout_width="32dp" android:layout_width="32dp"

View file

@ -82,112 +82,4 @@
</LinearLayout> </LinearLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:background="@color/nav_bg"
android:orientation="vertical"
android:windowSoftInputMode="adjustResize">
<LinearLayout
android:id="@+id/commentReplyToContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:orientation="horizontal"
android:visibility="gone"
tools:ignore="UseCompoundDrawables">
<TextView
android:id="@+id/commentReplyTo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:ellipsize="end"
android:fontFamily="@font/poppins_semi_bold"
android:singleLine="true"
android:text="Replying to "
android:textColor="?attr/colorOnBackground"
android:textSize="14sp"
tools:ignore="HardcodedText" />
<ImageView
android:id="@+id/commentReplyToCancel"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="16dp"
android:background="?android:attr/selectableItemBackground"
app:srcCompat="@drawable/ic_round_close_24"
app:tint="?attr/colorOnBackground"
tools:ignore="ContentDescription" />
</LinearLayout>
<LinearLayout
android:id="@+id/commentInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:colorBackground"
android:orientation="horizontal"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/commentUserAvatar"
style="@style/CircularImageView"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginStart="12dp"
android:scaleType="center"
app:srcCompat="@drawable/ic_round_add_circle_24"
tools:ignore="ContentDescription,ImageContrastCheck" />
<EditText
android:id="@+id/commentInput"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:autofillHints="The One Piece is real"
android:background="@drawable/card_outline"
android:fontFamily="@font/poppins_semi_bold"
android:hint="Add a comment..."
android:inputType="textMultiLine"
android:maxLength="300"
android:maxLines="8"
android:padding="8dp"
android:textSize="12sp"
tools:ignore="HardcodedText" />
<ImageButton
android:id="@+id/commentLabel"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:layout_marginEnd="8dp"
android:background="@drawable/ic_label_off_24"
android:visibility="gone"
tools:ignore="ContentDescription"
tools:visibility="visible" />
<ImageButton
android:id="@+id/commentSend"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_marginEnd="12dp"
android:background="@drawable/ic_round_send_24"
android:visibility="gone"
tools:ignore="ContentDescription"
tools:visibility="visible" />
</LinearLayout>
</LinearLayout>
</FrameLayout> </FrameLayout>

View file

@ -675,7 +675,6 @@
<string name="no_fav_manga">User has no favorite Manga</string> <string name="no_fav_manga">User has no favorite Manga</string>
<string name="fav_character">Favourite Characters</string> <string name="fav_character">Favourite Characters</string>
<string name="fav_staff">Favorite Staff</string> <string name="fav_staff">Favorite Staff</string>
<string name="stats">Stats</string> <string name="stats">Stats</string>
<string name="days_watched">Days watched</string> <string name="days_watched">Days watched</string>
<string name="total_anime">Total Anime</string> <string name="total_anime">Total Anime</string>