diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4d994c18..28f2c331 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -108,9 +108,6 @@ - @@ -130,7 +127,8 @@ + android:theme="@style/Theme.Dantotsu.NeverCutout" + android:windowSoftInputMode="adjustPan|stateHidden"/> { diff --git a/app/src/main/java/ani/dantotsu/media/MediaDetailsActivity.kt b/app/src/main/java/ani/dantotsu/media/MediaDetailsActivity.kt index 732eff38..05ed9bc9 100644 --- a/app/src/main/java/ani/dantotsu/media/MediaDetailsActivity.kt +++ b/app/src/main/java/ani/dantotsu/media/MediaDetailsActivity.kt @@ -36,6 +36,7 @@ import ani.dantotsu.databinding.ActivityMediaBinding import ani.dantotsu.initActivity import ani.dantotsu.loadImage import ani.dantotsu.media.anime.AnimeWatchFragment +import ani.dantotsu.media.comments.CommentsFragment import ani.dantotsu.media.manga.MangaReadFragment import ani.dantotsu.media.novel.NovelReadFragment import ani.dantotsu.navBarHeight @@ -318,13 +319,14 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi tabLayout.menu.clear() if (media.anime != null) { viewPager.adapter = - ViewPagerAdapter(supportFragmentManager, lifecycle, SupportedMedia.ANIME) + ViewPagerAdapter(supportFragmentManager, lifecycle, SupportedMedia.ANIME, media) tabLayout.inflateMenu(R.menu.anime_menu_detail) } else if (media.manga != null) { viewPager.adapter = ViewPagerAdapter( supportFragmentManager, lifecycle, - if (media.format == "NOVEL") SupportedMedia.NOVEL else SupportedMedia.MANGA + if (media.format == "NOVEL") SupportedMedia.NOVEL else SupportedMedia.MANGA, + media ) if (media.format == "NOVEL") { tabLayout.inflateMenu(R.menu.novel_menu_detail) @@ -378,6 +380,10 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi R.id.watch, R.id.read -> { selected = 1 } + + R.id.comment -> { + selected = 2 + } } } @@ -385,10 +391,12 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi if (anime) when (selected) { 0 -> return R.id.info 1 -> return R.id.watch + 2 -> return R.id.comment } else when (selected) { 0 -> return R.id.info 1 -> return R.id.read + 2 -> return R.id.comment } return R.id.info } @@ -408,19 +416,28 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi private class ViewPagerAdapter( fragmentManager: FragmentManager, lifecycle: Lifecycle, - private val media: SupportedMedia + private val mediaType: SupportedMedia, + private val media: Media ) : FragmentStateAdapter(fragmentManager, lifecycle) { - override fun getItemCount(): Int = 2 + override fun getItemCount(): Int = 3 override fun createFragment(position: Int): Fragment = when (position) { 0 -> MediaInfoFragment() - 1 -> when (media) { + 1 -> when (mediaType) { SupportedMedia.ANIME -> AnimeWatchFragment() SupportedMedia.MANGA -> MangaReadFragment() SupportedMedia.NOVEL -> NovelReadFragment() } + 2 -> { + val fragment = CommentsFragment() + val bundle = Bundle() + bundle.putInt("mediaId", media.id) + bundle.putString("mediaName", media.mainName()) + fragment.arguments = bundle + fragment + } else -> MediaInfoFragment() } diff --git a/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchAdapter.kt b/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchAdapter.kt index b17826ca..c9f0f920 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchAdapter.kt @@ -19,7 +19,6 @@ import ani.dantotsu.connections.comments.CommentsAPI import ani.dantotsu.databinding.DialogLayoutBinding import ani.dantotsu.databinding.ItemAnimeWatchBinding import ani.dantotsu.databinding.ItemChipBinding -import ani.dantotsu.media.comments.CommentsActivity import ani.dantotsu.media.Media import ani.dantotsu.media.MediaDetailsActivity import ani.dantotsu.media.SourceSearchDialogFragment @@ -60,17 +59,6 @@ class AnimeWatchAdapter( override fun onBindViewHolder(holder: ViewHolder, position: Int) { val binding = holder.binding _binding = binding - //CommentsAPI - binding.animeComments.visibility = if (CommentsAPI.userId == null) View.GONE else View.VISIBLE - binding.animeComments.setOnClickListener { - startActivity( - fragment.requireContext(), - Intent(fragment.requireContext(), CommentsActivity::class.java) - .putExtra("mediaId", media.id) - .putExtra("mediaName", media.mainName()), - null - ) - } binding.faqbutton.setOnClickListener { startActivity( diff --git a/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt b/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt index 9b23040c..645458cb 100644 --- a/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt +++ b/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt @@ -12,8 +12,6 @@ import ani.dantotsu.currActivity import ani.dantotsu.databinding.ItemCommentsBinding import ani.dantotsu.loadImage import ani.dantotsu.openLinkInBrowser -import ani.dantotsu.settings.saving.PrefManager -import ani.dantotsu.settings.saving.PrefName import ani.dantotsu.snackString import com.xwray.groupie.GroupieAdapter import com.xwray.groupie.Section @@ -33,7 +31,7 @@ import kotlin.math.sqrt class CommentItem(val comment: Comment, private val markwon: Markwon, val parentSection: Section, - private val commentsActivity: CommentsActivity, + private val commentsFragment: CommentsFragment, private val backgroundColor: Int, val commentDepth: Int ) : BindableItem() { @@ -62,6 +60,12 @@ class CommentItem(val comment: Comment, viewBinding.commentDelete.visibility = if (isUserComment || CommentsAPI.isAdmin || CommentsAPI.isMod) View.VISIBLE else View.GONE viewBinding.commentBanUser.visibility = if ((CommentsAPI.isAdmin || CommentsAPI.isMod) && !isUserComment) View.VISIBLE else View.GONE viewBinding.commentEdit.visibility = if (isUserComment) View.VISIBLE else View.GONE + if (comment.tag == null) { + viewBinding.commentUserTagLayout.visibility = View.GONE + } else { + viewBinding.commentUserTagLayout.visibility = View.VISIBLE + viewBinding.commentUserTag.text = comment.tag.toString() + } replying(isReplying) //sets default text editing(isEditing) if ((comment.replyCount ?: 0) > 0) { @@ -83,7 +87,7 @@ class CommentItem(val comment: Comment, } else { viewBinding.commentTotalReplies.text = "Hide Replies" repliesSection.clear() - commentsActivity.viewReplyCallback(this) + commentsFragment.viewReplyCallback(this) repliesVisible = true } } @@ -98,12 +102,12 @@ class CommentItem(val comment: Comment, viewBinding.commentEdit.setOnClickListener { editing(!isEditing) - commentsActivity.editCallback(this) + commentsFragment.editCallback(this) } viewBinding.commentReply.setOnClickListener { replying(!isReplying) - commentsActivity.replyTo(this, comment.username) - commentsActivity.replyCallback(this) + commentsFragment.replyTo(this, comment.username) + commentsFragment.replyCallback(this) } viewBinding.modBadge.visibility = if (comment.isMod == true) View.VISIBLE else View.GONE viewBinding.adminBadge.visibility = if (comment.isAdmin == true) View.VISIBLE else View.GONE @@ -134,7 +138,7 @@ class CommentItem(val comment: Comment, dialogBuilder("Report Comment", "Only report comments that violate the rules. Are you sure you want to report this comment?") { val scope = CoroutineScope(Dispatchers.Main + SupervisorJob()) scope.launch { - val success = CommentsAPI.reportComment(comment.commentId, comment.username, commentsActivity.mediaName) + val success = CommentsAPI.reportComment(comment.commentId, comment.username, commentsFragment.mediaName) if (success) { snackString("Comment Reported") } @@ -347,7 +351,7 @@ class CommentItem(val comment: Comment, * @param callback the callback to call when the user clicks yes */ private fun dialogBuilder(title: String, message: String, callback: () -> Unit) { - val alertDialog = android.app.AlertDialog.Builder(commentsActivity, R.style.MyPopup) + val alertDialog = android.app.AlertDialog.Builder(commentsFragment.activity, R.style.MyPopup) .setTitle(title) .setMessage(message) .setPositiveButton("Yes") { dialog, _ -> diff --git a/app/src/main/java/ani/dantotsu/media/comments/CommentsActivity.kt b/app/src/main/java/ani/dantotsu/media/comments/CommentsFragment.kt similarity index 69% rename from app/src/main/java/ani/dantotsu/media/comments/CommentsActivity.kt rename to app/src/main/java/ani/dantotsu/media/comments/CommentsFragment.kt index b7fb698a..23d81d99 100644 --- a/app/src/main/java/ani/dantotsu/media/comments/CommentsActivity.kt +++ b/app/src/main/java/ani/dantotsu/media/comments/CommentsFragment.kt @@ -1,14 +1,23 @@ package ani.dantotsu.media.comments -import android.graphics.drawable.ColorDrawable +import android.animation.ValueAnimator import android.annotation.SuppressLint +import android.app.AlertDialog +import android.content.Context.INPUT_METHOD_SERVICE +import android.graphics.drawable.ColorDrawable import android.graphics.drawable.Drawable import android.os.Bundle import android.text.TextWatcher +import android.view.LayoutInflater import android.view.View +import android.view.ViewGroup import android.view.inputmethod.InputMethodManager +import android.widget.EditText import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.PopupMenu +import androidx.core.animation.doOnEnd +import androidx.core.content.res.ResourcesCompat +import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.LinearLayoutManager import ani.dantotsu.R @@ -16,13 +25,11 @@ import ani.dantotsu.connections.anilist.Anilist import ani.dantotsu.connections.comments.Comment import ani.dantotsu.connections.comments.CommentResponse import ani.dantotsu.connections.comments.CommentsAPI -import ani.dantotsu.databinding.ActivityCommentsBinding -import ani.dantotsu.initActivity +import ani.dantotsu.databinding.FragmentCommentsBinding import ani.dantotsu.loadImage import ani.dantotsu.settings.saving.PrefManager import ani.dantotsu.settings.saving.PrefName import ani.dantotsu.snackString -import ani.dantotsu.themes.ThemeManager import com.bumptech.glide.Glide import com.bumptech.glide.RequestBuilder import com.bumptech.glide.RequestManager @@ -51,30 +58,39 @@ import java.text.SimpleDateFormat import java.util.Locale import java.util.TimeZone -class CommentsActivity : AppCompatActivity() { - lateinit var binding: ActivityCommentsBinding +class CommentsFragment : Fragment() { + lateinit var binding: FragmentCommentsBinding + lateinit var activity: AppCompatActivity private var interactionState = InteractionState.NONE private var commentWithInteraction: CommentItem? = null private val section = Section() private val adapter = GroupieAdapter() + private var tag: Int? = null + private var filterTag: Int? = null private var mediaId: Int = -1 var mediaName: String = "" private var backgroundColor: Int = 0 var pagesLoaded = 1 var totalPages = 1 - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - ThemeManager(this).applyTheme() - binding = ActivityCommentsBinding.inflate(layoutInflater) - setContentView(binding.root) - initActivity(this) + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + binding = FragmentCommentsBinding.inflate(inflater, container, false) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + activity = requireActivity() as AppCompatActivity //get the media id from the intent - val mediaId = intent.getIntExtra("mediaId", -1) - mediaName = intent.getStringExtra("mediaName")?:"unknown" + val mediaId = arguments?.getInt("mediaId") ?: -1 + mediaName = arguments?.getString("mediaName") ?: "unknown" if (mediaId == -1) { snackString("Invalid Media ID") - finish() + return } this.mediaId = mediaId backgroundColor = (binding.root.background as? ColorDrawable)?.color ?: 0 @@ -82,7 +98,6 @@ class CommentsActivity : AppCompatActivity() { val markwon = buildMarkwon() binding.commentUserAvatar.loadImage(Anilist.avatar) - binding.commentTitle.text = getText(R.string.comments) val markwonEditor = MarkwonEditor.create(markwon) binding.commentInput.addTextChangedListener( MarkwonEditorTextWatcher.withProcess( @@ -99,7 +114,7 @@ class CommentsActivity : AppCompatActivity() { } binding.commentsList.adapter = adapter - binding.commentsList.layoutManager = LinearLayoutManager(this) + binding.commentsList.layoutManager = LinearLayoutManager(activity) lifecycleScope.launch { loadAndDisplayComments() @@ -117,7 +132,7 @@ class CommentsActivity : AppCompatActivity() { section.update(groups) } - val popup = PopupMenu(this, view) + val popup = PopupMenu(activity, view) popup.setOnMenuItemClickListener { item -> val sortOrder = when (item.itemId) { R.id.comment_sort_newest -> "newest" @@ -136,6 +151,36 @@ class CommentsActivity : AppCompatActivity() { popup.show() } + binding.commentFilter.setOnClickListener { + val alertDialog = android.app.AlertDialog.Builder(activity, R.style.MyPopup) + .setTitle("Enter a chapter/episode number tag") + .setView(R.layout.dialog_edittext) + .setPositiveButton("OK") { dialog, _ -> + val editText = + (dialog as AlertDialog).findViewById(R.id.dialogEditText) + val text = editText?.text.toString() + filterTag = text.toIntOrNull() + lifecycleScope.launch { + loadAndDisplayComments() + } + + dialog.dismiss() + } + .setNeutralButton("Clear") { dialog, _ -> + filterTag = null + lifecycleScope.launch { + loadAndDisplayComments() + } + dialog.dismiss() + } + .setNegativeButton("Cancel") { dialog, _ -> + filterTag = null + dialog.dismiss() + } + val dialog = alertDialog.show() + dialog?.window?.setDimAmount(0.8f) + } + var isFetching = false //if we have scrolled to the bottom of the list, load more comments binding.commentsList.addOnScrollListener(object : @@ -170,7 +215,7 @@ class CommentsActivity : AppCompatActivity() { private suspend fun fetchComments(): CommentResponse? { return withContext(Dispatchers.IO) { - CommentsAPI.getCommentsForId(mediaId, pagesLoaded + 1) + CommentsAPI.getCommentsForId(mediaId, pagesLoaded + 1, filterTag) } } @@ -182,7 +227,7 @@ class CommentsActivity : AppCompatActivity() { comment, buildMarkwon(), section, - this@CommentsActivity, + this@CommentsFragment, backgroundColor, 0 ) @@ -206,6 +251,79 @@ class CommentsActivity : AppCompatActivity() { } } }) + + binding.commentInput.setOnFocusChangeListener { _, hasFocus -> + if (hasFocus) { + val targetWidth = binding.commentInputLayout.width - + binding.commentLabel.width - + binding.commentSend.width - + binding.commentUserAvatar.width - 12 + 16 + val anim = ValueAnimator.ofInt(binding.commentInput.width, targetWidth) + anim.addUpdateListener { valueAnimator -> + val layoutParams = binding.commentInput.layoutParams + layoutParams.width = valueAnimator.animatedValue as Int + binding.commentInput.layoutParams = layoutParams + } + anim.duration = 300 + + anim.start() + anim.doOnEnd { + binding.commentLabel.visibility = View.VISIBLE + binding.commentSend.visibility = View.VISIBLE + binding.commentLabel.animate().translationX(0f).setDuration(300).start() + binding.commentSend.animate().translationX(0f).setDuration(300).start() + + } + } + + binding.commentLabel.setOnClickListener { + //alert dialog to enter a number, with a cancel and ok button + val alertDialog = android.app.AlertDialog.Builder(activity, R.style.MyPopup) + .setTitle("Enter a chapter/episode number tag") + .setView(R.layout.dialog_edittext) + .setPositiveButton("OK") { dialog, _ -> + val editText = + (dialog as AlertDialog).findViewById(R.id.dialogEditText) + val text = editText?.text.toString() + tag = text.toIntOrNull() + if (tag == null) { + binding.commentLabel.background = ResourcesCompat.getDrawable( + resources, + R.drawable.ic_label_off_24, + null + ) + } else { + binding.commentLabel.background = ResourcesCompat.getDrawable( + resources, + R.drawable.ic_label_24, + null + ) + } + dialog.dismiss() + } + .setNeutralButton("Clear") { dialog, _ -> + tag = null + binding.commentLabel.background = ResourcesCompat.getDrawable( + resources, + R.drawable.ic_label_off_24, + null + ) + dialog.dismiss() + } + .setNegativeButton("Cancel") { dialog, _ -> + tag = null + binding.commentLabel.background = ResourcesCompat.getDrawable( + resources, + R.drawable.ic_label_off_24, + null + ) + dialog.dismiss() + } + val dialog = alertDialog.show() + dialog?.window?.setDimAmount(0.8f) + } + } + binding.commentSend.setOnClickListener { if (CommentsAPI.isBanned) { snackString("You are banned from commenting :(") @@ -220,6 +338,19 @@ class CommentsActivity : AppCompatActivity() { } } + @SuppressLint("NotifyDataSetChanged") + override fun onStart() { + super.onStart() + adapter.notifyDataSetChanged() + } + + @SuppressLint("NotifyDataSetChanged") + override fun onResume() { + super.onResume() + tag = null + adapter.notifyDataSetChanged() + } + enum class InteractionState { NONE, EDIT, REPLY } @@ -229,7 +360,6 @@ class CommentsActivity : AppCompatActivity() { * Called when the activity is created * Or when the user refreshes the comments */ - private suspend fun loadAndDisplayComments() { binding.commentsProgressBar.visibility = View.VISIBLE binding.commentsList.visibility = View.GONE @@ -237,7 +367,7 @@ class CommentsActivity : AppCompatActivity() { section.clear() val comments = withContext(Dispatchers.IO) { - CommentsAPI.getCommentsForId(mediaId) + CommentsAPI.getCommentsForId(mediaId, tag = filterTag) } val sortedComments = sortComments(comments?.comments) @@ -248,7 +378,7 @@ class CommentsActivity : AppCompatActivity() { it, buildMarkwon(), section, - this@CommentsActivity, + this@CommentsFragment, backgroundColor, 0 ) @@ -264,8 +394,7 @@ class CommentsActivity : AppCompatActivity() { private fun sortComments(comments: List?): List { if (comments == null) return emptyList() - val sortOrder = PrefManager.getVal(PrefName.CommentSortOrder, "newest") - return when (sortOrder) { + return when (PrefManager.getVal(PrefName.CommentSortOrder, "newest")) { "newest" -> comments.sortedByDescending { CommentItem.timestampToMillis(it.timestamp) } "oldest" -> comments.sortedBy { CommentItem.timestampToMillis(it.timestamp) } "highest_rated" -> comments.sortedByDescending { it.upvotes - it.downvotes } @@ -285,7 +414,7 @@ class CommentsActivity : AppCompatActivity() { InteractionState.EDIT -> { binding.commentReplyToContainer.visibility = View.GONE binding.commentInput.setText("") - val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager + val imm = activity.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager imm.hideSoftInputFromWindow(binding.commentInput.windowToken, 0) commentWithInteraction?.editing(false) InteractionState.EDIT @@ -293,7 +422,7 @@ class CommentsActivity : AppCompatActivity() { InteractionState.REPLY -> { binding.commentInput.setText("") - val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager + val imm = activity.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager imm.hideSoftInputFromWindow(binding.commentInput.windowToken, 0) commentWithInteraction?.replying(false) InteractionState.REPLY @@ -316,7 +445,7 @@ class CommentsActivity : AppCompatActivity() { binding.commentInput.setText(comment.comment.content) binding.commentInput.requestFocus() binding.commentInput.setSelection(binding.commentInput.text.length) - val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager + val imm = activity.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager imm.showSoftInput(binding.commentInput, InputMethodManager.SHOW_IMPLICIT) interactionState = InteractionState.EDIT } @@ -332,11 +461,12 @@ class CommentsActivity : AppCompatActivity() { binding.commentReplyToContainer.visibility = View.VISIBLE binding.commentInput.requestFocus() binding.commentInput.setSelection(binding.commentInput.text.length) - val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager + val imm = activity.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager imm.showSoftInput(binding.commentInput, InputMethodManager.SHOW_IMPLICIT) interactionState = InteractionState.REPLY } + @SuppressLint("SetTextI18n") fun replyTo(comment: CommentItem, username: String) { if (comment.isReplying) { @@ -363,14 +493,16 @@ class CommentsActivity : AppCompatActivity() { } replies?.comments?.forEach { - val depth = if (comment.commentDepth + 1 > comment.MAX_DEPTH) comment.commentDepth else comment.commentDepth + 1 - val section = if (comment.commentDepth + 1 > comment.MAX_DEPTH) comment.parentSection else comment.repliesSection + val depth = + if (comment.commentDepth + 1 > comment.MAX_DEPTH) comment.commentDepth else comment.commentDepth + 1 + val section = + if (comment.commentDepth + 1 > comment.MAX_DEPTH) comment.parentSection else comment.repliesSection if (depth >= comment.MAX_DEPTH) comment.registerSubComment(it.commentId) val newCommentItem = CommentItem( it, buildMarkwon(), section, - this@CommentsActivity, + this@CommentsFragment, backgroundColor, depth ) @@ -386,7 +518,7 @@ class CommentsActivity : AppCompatActivity() { * Called when the user tries to comment for the first time */ private fun showCommentRulesDialog() { - val alertDialog = android.app.AlertDialog.Builder(this, R.style.MyPopup) + val alertDialog = android.app.AlertDialog.Builder(activity, R.style.MyPopup) .setTitle("Commenting Rules") .setMessage( "I WILL BAN YOU WITHOUT HESITATION\n" + @@ -426,6 +558,12 @@ class CommentsActivity : AppCompatActivity() { handleEditComment(commentText) } else { handleNewComment(commentText) + tag = null + binding.commentLabel.background = ResourcesCompat.getDrawable( + resources, + R.drawable.ic_label_off_24, + null + ) } } } @@ -469,22 +607,27 @@ class CommentsActivity : AppCompatActivity() { CommentsAPI.comment( mediaId, if (interactionState == InteractionState.REPLY) commentWithInteraction?.comment?.commentId else null, - commentText + commentText, + tag ) } success?.let { if (interactionState == InteractionState.REPLY) { if (commentWithInteraction == null) return@let - val section = if (commentWithInteraction!!.commentDepth + 1 > commentWithInteraction!!.MAX_DEPTH) commentWithInteraction?.parentSection else commentWithInteraction?.repliesSection - val depth = if (commentWithInteraction!!.commentDepth + 1 > commentWithInteraction!!.MAX_DEPTH) commentWithInteraction!!.commentDepth else commentWithInteraction!!.commentDepth + 1 - if (depth >= commentWithInteraction!!.MAX_DEPTH) commentWithInteraction!!.registerSubComment(it.commentId) + val section = + if (commentWithInteraction!!.commentDepth + 1 > commentWithInteraction!!.MAX_DEPTH) commentWithInteraction?.parentSection else commentWithInteraction?.repliesSection + val depth = + if (commentWithInteraction!!.commentDepth + 1 > commentWithInteraction!!.MAX_DEPTH) commentWithInteraction!!.commentDepth else commentWithInteraction!!.commentDepth + 1 + if (depth >= commentWithInteraction!!.MAX_DEPTH) commentWithInteraction!!.registerSubComment( + it.commentId + ) section?.add( if (commentWithInteraction!!.commentDepth + 1 > commentWithInteraction!!.MAX_DEPTH) 0 else section.itemCount, CommentItem( it, buildMarkwon(), section, - this@CommentsActivity, + this@CommentsFragment, backgroundColor, depth ) @@ -492,7 +635,14 @@ class CommentsActivity : AppCompatActivity() { } else { section.add( 0, - CommentItem(it, buildMarkwon(), section, this@CommentsActivity, backgroundColor, 0) + CommentItem( + it, + buildMarkwon(), + section, + this@CommentsFragment, + backgroundColor, + 0 + ) ) } } @@ -503,11 +653,11 @@ class CommentsActivity : AppCompatActivity() { * @return the markwon instance */ private fun buildMarkwon(): Markwon { - val markwon = Markwon.builder(this) + val markwon = Markwon.builder(activity) .usePlugin(SoftBreakAddsNewLinePlugin.create()) .usePlugin(StrikethroughPlugin.create()) - .usePlugin(TablePlugin.create(this)) - .usePlugin(TaskListPlugin.create(this)) + .usePlugin(TablePlugin.create(activity)) + .usePlugin(TaskListPlugin.create(activity)) .usePlugin(HtmlPlugin.create { plugin -> plugin.addHandler( TagHandlerNoOp.create("h1", "h2", "h3", "h4", "h5", "h6", "hr", "pre") @@ -516,7 +666,7 @@ class CommentsActivity : AppCompatActivity() { .usePlugin(GlideImagesPlugin.create(object : GlideImagesPlugin.GlideStore { private val requestManager: RequestManager = - Glide.with(this@CommentsActivity).apply { + Glide.with(this@CommentsFragment).apply { addDefaultRequestListener(object : RequestListener { override fun onResourceReady( resource: Any, diff --git a/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt b/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt index 2342fede..33230325 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt @@ -24,7 +24,6 @@ import ani.dantotsu.media.Media import ani.dantotsu.media.MediaDetailsActivity import ani.dantotsu.media.SourceSearchDialogFragment import ani.dantotsu.media.anime.handleProgress -import ani.dantotsu.media.comments.CommentsActivity import ani.dantotsu.others.LanguageMapper import ani.dantotsu.others.webview.CookieCatcher import ani.dantotsu.parsers.DynamicMangaParser @@ -67,17 +66,6 @@ class MangaReadAdapter( _binding = binding binding.sourceTitle.setText(R.string.chaps) - binding.animeComments.visibility = if (CommentsAPI.userId == null) View.GONE else View.VISIBLE - binding.animeComments.setOnClickListener { - startActivity( - fragment.requireContext(), - Intent(fragment.requireContext(), CommentsActivity::class.java) - .putExtra("mediaId", media.id) - .putExtra("mediaName", media.mainName()), - null - ) - } - //Fuck u launch binding.faqbutton.setOnClickListener { val intent = Intent(fragment.requireContext(), FAQActivity::class.java) diff --git a/app/src/main/res/drawable/ic_label_24.xml b/app/src/main/res/drawable/ic_label_24.xml new file mode 100644 index 00000000..ad3f2592 --- /dev/null +++ b/app/src/main/res/drawable/ic_label_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_label_off_24.xml b/app/src/main/res/drawable/ic_label_off_24.xml new file mode 100644 index 00000000..d4dbdd00 --- /dev/null +++ b/app/src/main/res/drawable/ic_label_off_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_round_comment_24.xml b/app/src/main/res/drawable/ic_round_comment_24.xml index da93094d..b39f06fa 100644 --- a/app/src/main/res/drawable/ic_round_comment_24.xml +++ b/app/src/main/res/drawable/ic_round_comment_24.xml @@ -1,10 +1,10 @@ - - + android:height="24dp" + android:tint="?attr/colorControlNormal" + android:viewportWidth="960" + android:viewportHeight="960"> + diff --git a/app/src/main/res/drawable/ic_round_send_24.xml b/app/src/main/res/drawable/ic_round_send_24.xml index 320ac7a3..a951e7f0 100644 --- a/app/src/main/res/drawable/ic_round_send_24.xml +++ b/app/src/main/res/drawable/ic_round_send_24.xml @@ -1,11 +1,10 @@ - + android:viewportWidth="960" + android:viewportHeight="960"> + android:fillColor="#FFF" + android:pathData="M792,517 L176,777q-20,8 -38,-3.5T120,740v-520q0,-22 18,-33.5t38,-3.5l616,260q25,11 25,37t-25,37ZM200,680l474,-200 -474,-200v140l240,60 -240,60v140ZM200,680v-400,400Z" /> diff --git a/app/src/main/res/layout/activity_comments.xml b/app/src/main/res/layout/activity_comments.xml deleted file mode 100644 index 395c82f6..00000000 --- a/app/src/main/res/layout/activity_comments.xml +++ /dev/null @@ -1,168 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/activity_media.xml b/app/src/main/res/layout/activity_media.xml index 47ac2dca..4986a0e1 100644 --- a/app/src/main/res/layout/activity_media.xml +++ b/app/src/main/res/layout/activity_media.xml @@ -234,7 +234,7 @@ android:id="@+id/mediaViewPager" android:layout_width="match_parent" android:layout_height="match_parent" - android:nestedScrollingEnabled="false" + android:nestedScrollingEnabled="true" tools:ignore="SpeakableTextPresentCheck" /> @@ -248,7 +248,7 @@ android:translationZ="1dp" app:itemActiveIndicatorStyle="@style/BottomNavBar" app:itemIconTint="@color/tab_layout_icon" - app:itemRippleColor="?attr/colorPrimary" + app:itemRippleColor="#00000000" app:itemTextAppearanceActive="@style/NavBarText" app:itemTextAppearanceInactive="@style/NavBarText" app:itemTextColor="@color/tab_layout_icon" diff --git a/app/src/main/res/layout/dialog_edittext.xml b/app/src/main/res/layout/dialog_edittext.xml new file mode 100644 index 00000000..86970870 --- /dev/null +++ b/app/src/main/res/layout/dialog_edittext.xml @@ -0,0 +1,17 @@ + + + + + + diff --git a/app/src/main/res/layout/fragment_comments.xml b/app/src/main/res/layout/fragment_comments.xml new file mode 100644 index 00000000..e1cbfd04 --- /dev/null +++ b/app/src/main/res/layout/fragment_comments.xml @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/item_anime_watch.xml b/app/src/main/res/layout/item_anime_watch.xml index f41cd0a9..b0c06814 100644 --- a/app/src/main/res/layout/item_anime_watch.xml +++ b/app/src/main/res/layout/item_anime_watch.xml @@ -19,22 +19,6 @@ android:orientation="vertical" android:padding="32dp"> -