Skip to content

Commit

Permalink
fixed upload image button padding (#142)
Browse files Browse the repository at this point in the history
* no extra media in offline mode

* incognito display in media

* fixed upload image button padding
  • Loading branch information
aayush2622 authored Jan 19, 2024
1 parent 87a9df4 commit 4cee512
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 37 deletions.
17 changes: 15 additions & 2 deletions app/src/main/java/ani/dantotsu/media/MediaDetailsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
76 changes: 42 additions & 34 deletions app/src/main/java/ani/dantotsu/media/MediaInfoFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<ViewGroup.MarginLayoutParams> { bottomMargin += 128f.px + navBarHeight }
Expand Down Expand Up @@ -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)
Expand All @@ -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
)
}
}
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -304,7 +312,7 @@ class MediaInfoFragment : Fragment() {
}
}

if (media.genres.isNotEmpty()) {
if (media.genres.isNotEmpty() && !offline) {
val bind = ActivityGenreBinding.inflate(
LayoutInflater.from(context),
parent,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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),
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -54,7 +57,9 @@ class ImageSearchActivity : AppCompatActivity() {
ThemeManager(this).applyTheme()
binding = ActivityImageSearchBinding.inflate(layoutInflater)
setContentView(binding.root)

binding.uploadImage.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = navBarHeight
}
binding.uploadImage.setOnClickListener {
viewModel.clearResults()
imageSelectionLauncher.launch("image/*")
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
<color name="filler">#29FF6B08</color>
<color name="chip">#b3aead</color>
<color name="grey_nav">#F9222222</color>
<color name="incognito">#6347D4</color>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<color name="button_icon">#A9FFFFFF</color>
<color name="nav_status">#80FFFFFF</color>
<color name="fav">#ad5edd</color>
<color name="incognito">#291B65 </color>
<color name="filler">#54FF8400</color>
<color name="warning">#FF0000</color>
<color name="grey_20">#444444</color>
Expand Down

0 comments on commit 4cee512

Please sign in to comment.