From 4cee5125723a4d75fcc91faddec485a8955ad96c Mon Sep 17 00:00:00 2001 From: aayush262 <99584765+aayush2622@users.noreply.github.com> Date: Fri, 19 Jan 2024 13:38:30 +0530 Subject: [PATCH] fixed upload image button padding (#142) * no extra media in offline mode * incognito display in media * fixed upload image button padding --- .../dantotsu/media/MediaDetailsActivity.kt | 17 ++++- .../ani/dantotsu/media/MediaInfoFragment.kt | 76 ++++++++++--------- .../others/imagesearch/ImageSearchActivity.kt | 7 +- app/src/main/res/values-night/colors.xml | 1 + app/src/main/res/values/colors.xml | 1 + 5 files changed, 65 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/media/MediaDetailsActivity.kt b/app/src/main/java/ani/dantotsu/media/MediaDetailsActivity.kt index 4f1e4c0c8f..4ef01b8ad8 100644 --- a/app/src/main/java/ani/dantotsu/media/MediaDetailsActivity.kt +++ b/app/src/main/java/ani/dantotsu/media/MediaDetailsActivity.kt @@ -2,6 +2,7 @@ package ani.dantotsu.media import android.animation.ObjectAnimator import android.annotation.SuppressLint +import android.content.Context import android.content.Intent import android.os.Bundle import android.text.SpannableStringBuilder @@ -16,6 +17,7 @@ import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.content.res.AppCompatResources import androidx.core.content.ContextCompat +import androidx.core.graphics.drawable.DrawableCompat import androidx.core.text.bold import androidx.core.text.color import androidx.core.view.updateLayoutParams @@ -158,12 +160,23 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi } }) banner.setOnTouchListener { _, motionEvent -> gestureDetector.onTouchEvent(motionEvent);true } - binding.mediaTitle.text = media.userPreferredName + if (this.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE) + .getBoolean("incognito", false)) { + binding.mediaTitle.text = " ${media.userPreferredName}" + binding.mediaTitleCollapse.text = " ${media.userPreferredName}" + val drawable = ContextCompat.getDrawable(this, R.drawable.ic_incognito_24) + val color = ContextCompat.getColor(this, R.color.incognito) + DrawableCompat.setTint(drawable!!, color) + binding.mediaTitle.setCompoundDrawablesRelativeWithIntrinsicBounds(drawable, null, null, null) + binding.mediaTitleCollapse.setCompoundDrawablesRelativeWithIntrinsicBounds(drawable, null, null, null) + }else { + binding.mediaTitle.text = media.userPreferredName + binding.mediaTitleCollapse.text = media.userPreferredName + } binding.mediaTitle.setOnLongClickListener { copyToClipboard(media.userPreferredName) true } - binding.mediaTitleCollapse.text = media.userPreferredName binding.mediaTitleCollapse.setOnLongClickListener { copyToClipboard(media.userPreferredName) true diff --git a/app/src/main/java/ani/dantotsu/media/MediaInfoFragment.kt b/app/src/main/java/ani/dantotsu/media/MediaInfoFragment.kt index a7b78f8e5a..b7e850a5e6 100644 --- a/app/src/main/java/ani/dantotsu/media/MediaInfoFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/MediaInfoFragment.kt @@ -2,6 +2,7 @@ package ani.dantotsu.media import android.animation.ObjectAnimator import android.annotation.SuppressLint +import android.content.Context import android.content.Intent import android.os.Build import android.os.Bundle @@ -59,6 +60,7 @@ class MediaInfoFragment : Fragment() { @SuppressLint("SetJavaScriptEnabled") override fun onViewCreated(view: View, savedInstanceState: Bundle?) { val model: MediaDetailsViewModel by activityViewModels() + val offline = requireContext().getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getBoolean("offlineMode", false) binding.mediaInfoProgressBar.visibility = if (!loaded) View.VISIBLE else View.GONE binding.mediaInfoContainer.visibility = if (loaded) View.VISIBLE else View.GONE binding.mediaInfoContainer.updateLayoutParams { bottomMargin += 128f.px + navBarHeight } @@ -101,29 +103,33 @@ class MediaInfoFragment : Fragment() { if (media.anime.mainStudio != null) { binding.mediaInfoStudioContainer.visibility = View.VISIBLE binding.mediaInfoStudio.text = media.anime.mainStudio!!.name - binding.mediaInfoStudioContainer.setOnClickListener { - ContextCompat.startActivity( - requireActivity(), - Intent(activity, StudioActivity::class.java).putExtra( - "studio", - media.anime.mainStudio!! as Serializable - ), - null - ) + if (!offline) { + binding.mediaInfoStudioContainer.setOnClickListener { + ContextCompat.startActivity( + requireActivity(), + Intent(activity, StudioActivity::class.java).putExtra( + "studio", + media.anime.mainStudio!! as Serializable + ), + null + ) + } } } if (media.anime.author != null) { binding.mediaInfoAuthorContainer.visibility = View.VISIBLE binding.mediaInfoAuthor.text = media.anime.author!!.name - binding.mediaInfoAuthorContainer.setOnClickListener { - ContextCompat.startActivity( - requireActivity(), - Intent(activity, AuthorActivity::class.java).putExtra( - "author", - media.anime.author!! as Serializable - ), - null - ) + if (!offline) { + binding.mediaInfoAuthorContainer.setOnClickListener { + ContextCompat.startActivity( + requireActivity(), + Intent(activity, AuthorActivity::class.java).putExtra( + "author", + media.anime.author!! as Serializable + ), + null + ) + } } } binding.mediaInfoTotalTitle.setText(R.string.total_eps) @@ -137,15 +143,17 @@ class MediaInfoFragment : Fragment() { if (media.manga.author != null) { binding.mediaInfoAuthorContainer.visibility = View.VISIBLE binding.mediaInfoAuthor.text = media.manga.author!!.name - binding.mediaInfoAuthorContainer.setOnClickListener { - ContextCompat.startActivity( - requireActivity(), - Intent(activity, AuthorActivity::class.java).putExtra( - "author", - media.manga.author!! as Serializable - ), - null - ) + if (!offline) { + binding.mediaInfoAuthorContainer.setOnClickListener { + ContextCompat.startActivity( + requireActivity(), + Intent(activity, AuthorActivity::class.java).putExtra( + "author", + media.manga.author!! as Serializable + ), + null + ) + } } } } @@ -189,7 +197,7 @@ class MediaInfoFragment : Fragment() { parent.addView(bind.root) } - if (media.trailer != null) { + if (media.trailer != null && !offline) { @Suppress("DEPRECATION") class MyChrome : WebChromeClient() { private var mCustomView: View? = null @@ -243,7 +251,7 @@ class MediaInfoFragment : Fragment() { parent.addView(bind.root) } - if (media.anime != null && (media.anime.op.isNotEmpty() || media.anime.ed.isNotEmpty())) { + if (media.anime != null && (media.anime.op.isNotEmpty() || media.anime.ed.isNotEmpty()) && !offline) { val markWon = Markwon.builder(requireContext()) .usePlugin(SoftBreakAddsNewLinePlugin.create()).build() @@ -304,7 +312,7 @@ class MediaInfoFragment : Fragment() { } } - if (media.genres.isNotEmpty()) { + if (media.genres.isNotEmpty() && !offline) { val bind = ActivityGenreBinding.inflate( LayoutInflater.from(context), parent, @@ -335,7 +343,7 @@ class MediaInfoFragment : Fragment() { parent.addView(bind.root) } - if (media.tags.isNotEmpty()) { + if (media.tags.isNotEmpty() && !offline) { val bind = ItemTitleChipgroupBinding.inflate( LayoutInflater.from(context), parent, @@ -376,7 +384,7 @@ class MediaInfoFragment : Fragment() { parent.addView(bind.root) } - if (!media.characters.isNullOrEmpty()) { + if (!media.characters.isNullOrEmpty() && !offline) { val bind = ItemTitleRecyclerBinding.inflate( LayoutInflater.from(context), parent, @@ -393,7 +401,7 @@ class MediaInfoFragment : Fragment() { parent.addView(bind.root) } - if (!media.relations.isNullOrEmpty()) { + if (!media.relations.isNullOrEmpty() && !offline) { if (media.sequel != null || media.prequel != null) { val bind = ItemQuelsBinding.inflate( LayoutInflater.from(context), @@ -456,7 +464,7 @@ class MediaInfoFragment : Fragment() { parent.addView(bindi.root) } - if (!media.recommendations.isNullOrEmpty()) { + if (!media.recommendations.isNullOrEmpty() && !offline ) { val bind = ItemTitleRecyclerBinding.inflate( LayoutInflater.from(context), parent, diff --git a/app/src/main/java/ani/dantotsu/others/imagesearch/ImageSearchActivity.kt b/app/src/main/java/ani/dantotsu/others/imagesearch/ImageSearchActivity.kt index 75be146552..282c17fc40 100644 --- a/app/src/main/java/ani/dantotsu/others/imagesearch/ImageSearchActivity.kt +++ b/app/src/main/java/ani/dantotsu/others/imagesearch/ImageSearchActivity.kt @@ -4,9 +4,11 @@ import android.content.Intent import android.net.Uri import android.os.Bundle import android.view.View +import android.view.ViewGroup import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.updateLayoutParams import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -16,6 +18,7 @@ import ani.dantotsu.connections.anilist.Anilist import ani.dantotsu.databinding.ActivityImageSearchBinding import ani.dantotsu.initActivity import ani.dantotsu.media.MediaDetailsActivity +import ani.dantotsu.navBarHeight import ani.dantotsu.others.LangSet import ani.dantotsu.themes.ThemeManager import ani.dantotsu.toast @@ -54,7 +57,9 @@ class ImageSearchActivity : AppCompatActivity() { ThemeManager(this).applyTheme() binding = ActivityImageSearchBinding.inflate(layoutInflater) setContentView(binding.root) - + binding.uploadImage.updateLayoutParams { + bottomMargin = navBarHeight + } binding.uploadImage.setOnClickListener { viewModel.clearResults() imageSelectionLauncher.launch("image/*") diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index ac9e38071b..c565ebf10c 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -12,4 +12,5 @@ #29FF6B08 #b3aead #F9222222 + #6347D4 \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 8b384ed847..6bf3faa962 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -16,6 +16,7 @@ #A9FFFFFF #80FFFFFF #ad5edd + #291B65 #54FF8400 #FF0000 #444444