From d04ced94ea968a641c4298948d184f2cc047726f Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Sun, 10 Mar 2024 00:02:40 -0600 Subject: [PATCH 1/7] fix: comment pagination --- .../media/comments/CommentsFragment.kt | 89 +++++++++---- app/src/main/res/layout/fragment_comments.xml | 117 +++++++++--------- 2 files changed, 122 insertions(+), 84 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/media/comments/CommentsFragment.kt b/app/src/main/java/ani/dantotsu/media/comments/CommentsFragment.kt index 646b1744..a8a6a1e9 100644 --- a/app/src/main/java/ani/dantotsu/media/comments/CommentsFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/comments/CommentsFragment.kt @@ -5,13 +5,12 @@ 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.MotionEvent import android.view.View import android.view.ViewGroup -import android.view.WindowManager import android.view.inputmethod.InputMethodManager import android.widget.EditText import androidx.appcompat.app.AppCompatActivity @@ -27,36 +26,15 @@ 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.copyToClipboard import ani.dantotsu.databinding.FragmentCommentsBinding import ani.dantotsu.loadImage -import ani.dantotsu.media.MediaDetailsActivity import ani.dantotsu.settings.saving.PrefManager import ani.dantotsu.settings.saving.PrefName import ani.dantotsu.snackString -import com.bumptech.glide.Glide -import com.bumptech.glide.RequestBuilder -import com.bumptech.glide.RequestManager -import com.bumptech.glide.load.DataSource -import com.bumptech.glide.load.engine.GlideException -import com.bumptech.glide.load.resource.gif.GifDrawable -import com.bumptech.glide.request.RequestListener -import com.bumptech.glide.request.target.Target import com.xwray.groupie.GroupieAdapter import com.xwray.groupie.Section -import io.noties.markwon.AbstractMarkwonPlugin -import io.noties.markwon.Markwon -import io.noties.markwon.MarkwonConfiguration -import io.noties.markwon.SoftBreakAddsNewLinePlugin import io.noties.markwon.editor.MarkwonEditor import io.noties.markwon.editor.MarkwonEditorTextWatcher -import io.noties.markwon.ext.strikethrough.StrikethroughPlugin -import io.noties.markwon.ext.tables.TablePlugin -import io.noties.markwon.ext.tasklist.TaskListPlugin -import io.noties.markwon.html.HtmlPlugin -import io.noties.markwon.html.TagHandlerNoOp -import io.noties.markwon.image.AsyncDrawable -import io.noties.markwon.image.glide.GlideImagesPlugin import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext @@ -64,6 +42,7 @@ import java.text.SimpleDateFormat import java.util.Locale import java.util.TimeZone +@SuppressLint("ClickableViewAccessibility") class CommentsFragment : Fragment() { lateinit var binding: FragmentCommentsBinding lateinit var activity: AppCompatActivity @@ -193,8 +172,68 @@ class CommentsFragment : Fragment() { } var isFetching = false + binding.commentsList.setOnTouchListener( + object : View.OnTouchListener { + override fun onTouch(v: View?, event: MotionEvent?): Boolean { + if (event?.action == MotionEvent.ACTION_UP) { + if (pagesLoaded < totalPages) { + if (!binding.commentsList.canScrollVertically(1) && !isFetching && + (binding.commentsList.layoutManager as LinearLayoutManager).findLastVisibleItemPosition() == (binding.commentsList.adapter!!.itemCount - 1) + ) { + binding.commentBottomRefresh.visibility = View.VISIBLE + loadMoreComments() + lifecycleScope.launch { + kotlinx.coroutines.delay(1000) + withContext(Dispatchers.Main) { + binding.commentBottomRefresh.visibility = View.GONE + } + } + } + } else { + snackString("No more comments") + } + } + return false + } + + 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: Comment) { + withContext(Dispatchers.Main) { + section.add( + CommentItem( + comment, + buildMarkwon(activity), + section, + this@CommentsFragment, + backgroundColor, + 0 + ) + ) + } + } + }) + //if we have scrolled to the bottom of the list, load more comments - binding.commentsList.addOnScrollListener(object : + /*binding.commentsList.addOnScrollListener(object : androidx.recyclerview.widget.RecyclerView.OnScrollListener() { override fun onScrolled( recyclerView: androidx.recyclerview.widget.RecyclerView, @@ -245,7 +284,7 @@ class CommentsFragment : Fragment() { ) } } - }) + })*/ binding.commentInput.addTextChangedListener(object : TextWatcher { diff --git a/app/src/main/res/layout/fragment_comments.xml b/app/src/main/res/layout/fragment_comments.xml index 2c31e8c5..b7dcbbea 100644 --- a/app/src/main/res/layout/fragment_comments.xml +++ b/app/src/main/res/layout/fragment_comments.xml @@ -21,65 +21,64 @@ android:layout_height="match_parent" android:orientation="vertical"> - + android:layout_height="wrap_content" + android:gravity="end" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> - + + + + + + + + + + android:nestedScrollingEnabled="true" + android:visibility="gone" + tools:listitem="@layout/item_comments" + tools:visibility="visible" /> - - - - - - - - - - - - - - - + + @@ -133,8 +132,8 @@ android:id="@+id/commentInputLayout" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="horizontal" android:background="?android:colorBackground" + android:orientation="horizontal" android:paddingTop="8dp" android:paddingBottom="8dp"> @@ -172,18 +171,18 @@ android:layout_width="24dp" android:layout_height="24dp" android:layout_gravity="center" - android:background="@drawable/ic_label_off_24" android:layout_marginEnd="8dp" + android:background="@drawable/ic_label_off_24" android:visibility="gone" - tools:visibility="visible" - tools:ignore="ContentDescription" /> + tools:ignore="ContentDescription" + tools:visibility="visible" /> Date: Sun, 10 Mar 2024 03:20:05 -0500 Subject: [PATCH 2/7] fix: activity pagination --- .../ani/dantotsu/profile/ProfileActivity.kt | 49 ++++++++++++++++++- .../ani/dantotsu/profile/StatsFragment.kt | 5 +- .../dantotsu/profile/activity/FeedFragment.kt | 9 ++-- app/src/main/res/layout/activity_profile.xml | 38 ++++++++------ app/src/main/res/layout/fragment_profile.xml | 21 +++++--- .../main/res/layout/fragment_statistics.xml | 5 +- 6 files changed, 97 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt b/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt index a7f8216d..ac3c64a9 100644 --- a/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt +++ b/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt @@ -1,8 +1,10 @@ package ani.dantotsu.profile +import android.animation.ObjectAnimator import android.annotation.SuppressLint import android.content.Intent import android.os.Bundle +import android.util.TypedValue import android.view.View import android.view.ViewGroup import android.widget.PopupMenu @@ -29,13 +31,15 @@ import ani.dantotsu.snackString import ani.dantotsu.statusBarHeight import ani.dantotsu.themes.ThemeManager import ani.dantotsu.toast +import com.google.android.material.appbar.AppBarLayout import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import nl.joery.animatedbottombar.AnimatedBottomBar +import kotlin.math.abs -class ProfileActivity : AppCompatActivity() { +class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListener { lateinit var binding: ActivityProfileBinding private var selected: Int = 1 private lateinit var navBar: AnimatedBottomBar @@ -47,6 +51,7 @@ class ProfileActivity : AppCompatActivity() { initActivity(this) binding = ActivityProfileBinding.inflate(layoutInflater) setContentView(binding.root) + screenWidth = resources.displayMetrics.widthPixels.toFloat() navBar = binding.profileNavBar navBar.updateLayoutParams { bottomMargin = navBarHeight } val feedTab = navBar.createTab(R.drawable.ic_round_filter_24, "Feed") @@ -57,6 +62,7 @@ class ProfileActivity : AppCompatActivity() { navBar.addTab(statsTab) navBar.visibility = View.GONE binding.profileViewPager.isUserInputEnabled = false + lifecycleScope.launch(Dispatchers.IO) { val userid = intent.getIntExtra("userId", 0) val respond = Anilist.query.getUserProfile(userid) @@ -72,6 +78,7 @@ class ProfileActivity : AppCompatActivity() { } binding.profileViewPager.adapter = ViewPagerAdapter(supportFragmentManager, lifecycle, user) + binding.profileViewPager.setOffscreenPageLimit(3) binding.profileViewPager.setCurrentItem(selected, false) navBar.visibility = View.VISIBLE navBar.selectTabAt(selected) @@ -163,10 +170,50 @@ class ProfileActivity : AppCompatActivity() { ) } + mMaxScrollSize = binding.profileAppBar.totalScrollRange + binding.profileAppBar.addOnOffsetChangedListener(this@ProfileActivity) } } } + //Collapsing UI Stuff + private var isCollapsed = false + private val percent = 45 + private var mMaxScrollSize = 0 + private var screenWidth: Float = 0f + + override fun onOffsetChanged(appBar: AppBarLayout, i: Int) { + if (mMaxScrollSize == 0) mMaxScrollSize = appBar.totalScrollRange + val percentage = abs(i) * 100 / mMaxScrollSize + + binding.profileUserAvatarContainer.visibility = + if (binding.profileUserAvatarContainer.scaleX == 0f) View.GONE else View.VISIBLE + val duration = (200 * (PrefManager.getVal(PrefName.AnimationSpeed) as Float)).toLong() + val typedValue = TypedValue() + this@ProfileActivity.theme.resolveAttribute( + com.google.android.material.R.attr.colorSecondary, + typedValue, + true + ) + val color = typedValue.data + if (percentage >= percent && !isCollapsed) { + isCollapsed = true + ObjectAnimator.ofFloat(binding.profileUserDataContainer, "translationX", screenWidth) + .setDuration(duration).start() + ObjectAnimator.ofFloat(binding.profileUserAvatarContainer, "translationX", screenWidth) + .setDuration(duration).start() + binding.profileBannerImage.pause() + } + if (percentage <= percent && isCollapsed) { + isCollapsed = false + ObjectAnimator.ofFloat(binding.profileUserDataContainer, "translationX", 0f) + .setDuration(duration).start() + ObjectAnimator.ofFloat(binding.profileUserAvatarContainer, "translationX", 0f).setDuration(duration) + .start() + if (PrefManager.getVal(PrefName.BannerAnimations)) binding.profileBannerImage.resume() + } + } + override fun onResume() { if (this::navBar.isInitialized) { navBar.selectTabAt(selected) diff --git a/app/src/main/java/ani/dantotsu/profile/StatsFragment.kt b/app/src/main/java/ani/dantotsu/profile/StatsFragment.kt index bb245f47..3b878846 100644 --- a/app/src/main/java/ani/dantotsu/profile/StatsFragment.kt +++ b/app/src/main/java/ani/dantotsu/profile/StatsFragment.kt @@ -5,6 +5,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ArrayAdapter +import androidx.core.view.updateLayoutParams import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.LinearLayoutManager @@ -16,6 +17,7 @@ import ani.dantotsu.profile.ChartBuilder.Companion.ChartPacket import ani.dantotsu.profile.ChartBuilder.Companion.ChartType import ani.dantotsu.profile.ChartBuilder.Companion.MediaType import ani.dantotsu.profile.ChartBuilder.Companion.StatType +import ani.dantotsu.statusBarHeight import com.github.aachartmodel.aainfographics.aachartcreator.AAChartType import com.xwray.groupie.GroupieAdapter import kotlinx.coroutines.Dispatchers @@ -49,10 +51,11 @@ class StatsFragment : binding.statisticList.adapter = adapter binding.statisticList.setHasFixedSize(true) - binding.statisticList.isNestedScrollingEnabled = false + binding.statisticList.isNestedScrollingEnabled = true binding.statisticList.layoutManager = LinearLayoutManager(requireContext()) binding.statisticProgressBar.visibility = View.VISIBLE binding.compare.visibility = if (user.id == Anilist.userid) View.GONE else View.VISIBLE + binding.filterContainer.updateLayoutParams { topMargin = statusBarHeight } binding.sourceType.setAdapter( ArrayAdapter( diff --git a/app/src/main/java/ani/dantotsu/profile/activity/FeedFragment.kt b/app/src/main/java/ani/dantotsu/profile/activity/FeedFragment.kt index f6751d53..720514c9 100644 --- a/app/src/main/java/ani/dantotsu/profile/activity/FeedFragment.kt +++ b/app/src/main/java/ani/dantotsu/profile/activity/FeedFragment.kt @@ -58,14 +58,11 @@ class FeedFragment : Fragment() { adapter.update(activityList.map { ActivityItem(it) { _, _ -> } }) } binding.listProgressBar.visibility = ViewGroup.GONE - val scrollView = if (activity is ProfileActivity) { - (activity as ProfileActivity).binding.profileScrollView - } else { - binding.listRecyclerView - } + val scrollView = binding.listRecyclerView + binding.listRecyclerView.setOnTouchListener { _, event -> if (event?.action == MotionEvent.ACTION_UP) { - if (adapter.itemCount % AnilistQueries.ITEMS_PER_PAGE != 0) { + if (adapter.itemCount % AnilistQueries.ITEMS_PER_PAGE != 0 && !global) { snackString("No more activities") } else if (!scrollView.canScrollVertically(1) && !binding.feedRefresh.isVisible && binding.listRecyclerView.adapter!!.itemCount != 0 && diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml index 409e6860..5cfbe177 100644 --- a/app/src/main/res/layout/activity_profile.xml +++ b/app/src/main/res/layout/activity_profile.xml @@ -19,17 +19,18 @@ android:layout_height="wrap_content" /> - + android:translationZ="5dp"> - + android:layout_height="wrap_content" + android:fitsSystemWindows="false" + app:contentScrim="?android:colorBackground" + app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"> - + - + - + + + + - + @@ -344,9 +349,9 @@ android:layout_marginTop="8dp" android:layout_marginEnd="32dp" android:fontFamily="@font/poppins_bold" - android:text="@string/about_me" android:padding="8dp" - android:textSize="18sp"/> + android:text="@string/about_me" + android:textSize="18sp" /> @@ -464,8 +470,8 @@ android:layout_marginTop="8dp" android:layout_marginEnd="32dp" android:fontFamily="@font/poppins_bold" - android:text="@string/fav_character" android:padding="8dp" + android:text="@string/fav_character" android:textSize="18sp" /> - \ No newline at end of file + + diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml index 19aaff14..9f202f6d 100644 --- a/app/src/main/res/layout/fragment_statistics.xml +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -14,7 +14,9 @@ android:layout_height="wrap_content" android:baselineAligned="false" android:orientation="vertical" - android:padding="16dp"> + android:paddingBottom="16dp" + android:paddingStart="16dp" + android:paddingEnd="16dp"> From af1a481bdbdc0d454abfb4eca76f47397dd36b37 Mon Sep 17 00:00:00 2001 From: TwistedUmbrellaX <1173913+AbandonedCart@users.noreply.github.com> Date: Sun, 10 Mar 2024 04:21:14 -0400 Subject: [PATCH 3/7] Cleaning up navigation (#234) * fix: align bottom to top with RTL * fix: clean up the overlapping decor * feat: match theme color with navbar * fix: measure view on return to view --- app/src/main/java/ani/dantotsu/Functions.kt | 61 +++++++++++-------- .../main/java/ani/dantotsu/MainActivity.kt | 24 ++------ .../dantotsu/media/manga/MangaReadFragment.kt | 1 + .../manga/mangareader/MangaReaderActivity.kt | 18 ++++-- .../settings/DevelopersDialogFragment.kt | 6 ++ app/src/main/res/values/themes.xml | 1 + 6 files changed, 61 insertions(+), 50 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/Functions.kt b/app/src/main/java/ani/dantotsu/Functions.kt index cdc8ffdd..d52c9465 100644 --- a/app/src/main/java/ani/dantotsu/Functions.kt +++ b/app/src/main/java/ani/dantotsu/Functions.kt @@ -135,7 +135,7 @@ fun logger(e: Any?, print: Boolean = true) { } -fun initActivity(a: Activity) { +fun initActivityTheme(a: Activity) { val window = a.window WindowCompat.setDecorFitsSystemWindows(window, false) val darkMode = PrefManager.getVal(PrefName.DarkMode) @@ -156,7 +156,7 @@ fun initActivity(a: Activity) { navBarHeight = this.getInsets(WindowInsetsCompat.Type.systemBars()).bottom } } - a.hideStatusBar() + WindowInsetsControllerCompat(window, window.decorView).hide(WindowInsetsCompat.Type.statusBars()) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && statusBarHeight == 0 && a.resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { window.decorView.rootWindowInsets?.displayCutout?.apply { if (boundingRects.size > 0) { @@ -176,40 +176,47 @@ fun initActivity(a: Activity) { } } -@Suppress("DEPRECATION") fun Activity.hideSystemBars() { - window.decorView.systemUiVisibility = ( - View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY - or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - or View.SYSTEM_UI_FLAG_FULLSCREEN - or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - ) + WindowInsetsControllerCompat(window, window.decorView).let { controller -> + controller.systemBarsBehavior = + WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE + controller.hide(WindowInsetsCompat.Type.systemBars()) + } } -@Suppress("DEPRECATION") -fun Activity.hideStatusBar() { - window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN) +fun Activity.setNavigationTheme() { + val a = TypedValue() + theme.resolveAttribute(android.R.attr.colorBackground, a, true) + if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && a.isColorType) + || (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT)) { + window.navigationBarColor = a.data + } } open class BottomSheetDialogFragment : BottomSheetDialogFragment() { override fun onStart() { super.onStart() - val window = dialog?.window - val decorView: View = window?.decorView ?: return - decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN - if (this.resources.configuration.orientation != Configuration.ORIENTATION_PORTRAIT) { - val behavior = BottomSheetBehavior.from(requireView().parent as View) - behavior.state = BottomSheetBehavior.STATE_EXPANDED + dialog?.window?.let { window -> + WindowCompat.setDecorFitsSystemWindows(window, false) + val immersiveMode: Boolean = PrefManager.getVal(PrefName.ImmersiveMode) + if (immersiveMode) { + WindowInsetsControllerCompat( + window, window.decorView + ).hide(WindowInsetsCompat.Type.statusBars()) + } + if (this.resources.configuration.orientation != Configuration.ORIENTATION_PORTRAIT) { + val behavior = BottomSheetBehavior.from(requireView().parent as View) + behavior.state = BottomSheetBehavior.STATE_EXPANDED + } + val typedValue = TypedValue() + val theme = requireContext().theme + theme.resolveAttribute( + com.google.android.material.R.attr.colorSurface, + typedValue, + true + ) + window.navigationBarColor = typedValue.data } - val typedValue = TypedValue() - val theme = requireContext().theme - theme.resolveAttribute( - com.google.android.material.R.attr.colorSurface, - typedValue, - true - ) - window.navigationBarColor = typedValue.data } override fun show(manager: FragmentManager, tag: String?) { diff --git a/app/src/main/java/ani/dantotsu/MainActivity.kt b/app/src/main/java/ani/dantotsu/MainActivity.kt index ba47d2fb..3b2d7323 100644 --- a/app/src/main/java/ani/dantotsu/MainActivity.kt +++ b/app/src/main/java/ani/dantotsu/MainActivity.kt @@ -146,24 +146,14 @@ class MainActivity : AppCompatActivity() { finish() } doubleBackToExitPressedOnce = true - WindowInsetsControllerCompat(window, window.decorView) - .show(WindowInsetsCompat.Type.navigationBars()) snackString(this@MainActivity.getString(R.string.back_to_exit)).apply { this?.addCallback(object : BaseTransientBottomBar.BaseCallback() { override fun onDismissed(transientBottomBar: Snackbar?, event: Int) { super.onDismissed(transientBottomBar, event) - WindowInsetsControllerCompat(window, window.decorView).let { controller -> - controller.systemBarsBehavior = - WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE - controller.hide(WindowInsetsCompat.Type.navigationBars()) - } + doubleBackToExitPressedOnce = false } }) } - Handler(Looper.getMainLooper()).postDelayed( - { doubleBackToExitPressedOnce = false }, - 2000 - ) } val preferences: SourcePreferences = Injekt.get() @@ -219,7 +209,7 @@ class MainActivity : AppCompatActivity() { binding.root.doOnAttach { - initActivity(this) + initActivityTheme(this) selectedOption = if (fragment != null) { when (fragment) { AnimeFragment::class.java.name -> 0 @@ -369,13 +359,11 @@ class MainActivity : AppCompatActivity() { override fun onResume() { super.onResume() - - WindowCompat.setDecorFitsSystemWindows(window, false) - - WindowInsetsControllerCompat(window, window.decorView).let { controller -> - controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE - controller.hide(WindowInsetsCompat.Type.navigationBars()) + initActivityTheme(this) + binding.includedNavbar.navbarContainer.updateLayoutParams { + bottomMargin = navBarHeight } + window.navigationBarColor = getColor(android.R.color.transparent) } //ViewPager diff --git a/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt b/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt index 2d570043..6b979319 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt @@ -601,6 +601,7 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { super.onResume() binding.mediaInfoProgressBar.visibility = progress binding.animeSourceRecycler.layoutManager?.onRestoreInstanceState(state) + requireActivity().setNavigationTheme() } override fun onPause() { diff --git a/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt b/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt index a6ce9bd3..3665eb3e 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt @@ -285,7 +285,7 @@ class MangaReaderActivity : AppCompatActivity() { binding.mangaReaderNextChapter.performClick() } binding.mangaReaderNextChapter.setOnClickListener { - if (defaultSettings.direction == RIGHT_TO_LEFT) { + if (defaultSettings.direction == RIGHT_TO_LEFT || defaultSettings.direction == BOTTOM_TO_TOP) { if (currentChapterIndex > 0) change(currentChapterIndex - 1) else snackString(getString(R.string.first_chapter)) } else { @@ -298,7 +298,7 @@ class MangaReaderActivity : AppCompatActivity() { binding.mangaReaderPreviousChapter.performClick() } binding.mangaReaderPreviousChapter.setOnClickListener { - if (defaultSettings.direction == RIGHT_TO_LEFT) { + if (defaultSettings.direction == RIGHT_TO_LEFT || defaultSettings.direction == BOTTOM_TO_TOP) { if (chaptersArr.size > currentChapterIndex + 1) progress { change(currentChapterIndex + 1) } else snackString(getString(R.string.next_chapter_not_found)) } else { @@ -315,7 +315,7 @@ class MangaReaderActivity : AppCompatActivity() { PrefManager.setCustomVal("${media.id}_current_chp", chap.number) currentChapterIndex = chaptersArr.indexOf(chap.number) binding.mangaReaderChapterSelect.setSelection(currentChapterIndex) - if (defaultSettings.direction == RIGHT_TO_LEFT) { + if (defaultSettings.direction == RIGHT_TO_LEFT || defaultSettings.direction == BOTTOM_TO_TOP) { binding.mangaReaderNextChap.text = chaptersTitleArr.getOrNull(currentChapterIndex - 1) ?: "" binding.mangaReaderPrevChap.text = @@ -439,6 +439,10 @@ class MangaReaderActivity : AppCompatActivity() { if ((defaultSettings.direction == TOP_TO_BOTTOM || defaultSettings.direction == BOTTOM_TO_TOP)) { binding.mangaReaderSwipy.vertical = true if (defaultSettings.direction == TOP_TO_BOTTOM) { + binding.mangaReaderNextChap.text = + chaptersTitleArr.getOrNull(currentChapterIndex + 1) ?: "" + binding.mangaReaderPrevChap.text = + chaptersTitleArr.getOrNull(currentChapterIndex - 1) ?: "" binding.BottomSwipeText.text = chaptersTitleArr.getOrNull(currentChapterIndex + 1) ?: getString(R.string.no_chapter) binding.TopSwipeText.text = chaptersTitleArr.getOrNull(currentChapterIndex - 1) @@ -450,6 +454,10 @@ class MangaReaderActivity : AppCompatActivity() { binding.mangaReaderNextChapter.performClick() } } else { + binding.mangaReaderNextChap.text = + chaptersTitleArr.getOrNull(currentChapterIndex - 1) ?: "" + binding.mangaReaderPrevChap.text = + chaptersTitleArr.getOrNull(currentChapterIndex + 1) ?: "" binding.BottomSwipeText.text = chaptersTitleArr.getOrNull(currentChapterIndex - 1) ?: getString(R.string.no_chapter) binding.TopSwipeText.text = chaptersTitleArr.getOrNull(currentChapterIndex + 1) @@ -729,7 +737,7 @@ class MangaReaderActivity : AppCompatActivity() { val screenWidth = Resources.getSystem().displayMetrics.widthPixels //if in the 1st 1/5th of the screen width, left and lower than 1/5th of the screen height, left if (screenWidth / 5 in x + 1.. screenWidth - screenWidth / 5 && y > screenWidth / 5) { - pressLocation = if (defaultSettings.direction == RIGHT_TO_LEFT) { + pressLocation = if (defaultSettings.direction == RIGHT_TO_LEFT || defaultSettings.direction == BOTTOM_TO_TOP) { pressPos.LEFT } else { pressPos.RIGHT diff --git a/app/src/main/java/ani/dantotsu/settings/DevelopersDialogFragment.kt b/app/src/main/java/ani/dantotsu/settings/DevelopersDialogFragment.kt index b7a12ad1..564c0aaa 100644 --- a/app/src/main/java/ani/dantotsu/settings/DevelopersDialogFragment.kt +++ b/app/src/main/java/ani/dantotsu/settings/DevelopersDialogFragment.kt @@ -25,6 +25,12 @@ class DevelopersDialogFragment : BottomSheetDialogFragment() { "Contributor", "https://github.com/aayush2622" ), + Developer( + "AbandonedCart", + "https://avatars.githubusercontent.com/u/1173913?v=4", + "Contributor", + "https://github.com/AbandonedCart" + ), Developer( "Sadwhy", "https://avatars.githubusercontent.com/u/99601717?v=4", diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index e1d6f959..87eb6f03 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,6 +1,7 @@