chore: cleanup pt 3
This commit is contained in:
parent
ea48809d07
commit
0a0da65f7c
26 changed files with 99 additions and 243 deletions
|
@ -67,9 +67,12 @@ import android.widget.FrameLayout
|
|||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.AttrRes
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.ContextCompat.getSystemService
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.core.math.MathUtils.clamp
|
||||
|
@ -339,14 +342,7 @@ open class BottomSheetDialogFragment : BottomSheetDialogFragment() {
|
|||
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
|
||||
window.navigationBarColor = requireContext().getThemeColor(com.google.android.material.R.attr.colorSurface)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1383,7 +1379,11 @@ fun blurImage(imageView: ImageView, banner: String?) {
|
|||
imageView.setImageResource(R.drawable.linear_gradient_bg)
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.getThemeColor(@AttrRes attribute: Int): Int {
|
||||
val typedValue = TypedValue()
|
||||
theme.resolveAttribute(attribute, typedValue, true)
|
||||
return typedValue.data
|
||||
}
|
||||
/**
|
||||
* Builds the markwon instance with all the plugins
|
||||
* @return the markwon instance
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.net.Uri
|
|||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -37,6 +36,7 @@ import ani.dantotsu.download.DownloadedType
|
|||
import ani.dantotsu.download.DownloadsManager
|
||||
import ani.dantotsu.download.DownloadsManager.Companion.compareName
|
||||
import ani.dantotsu.download.findValidName
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.initActivity
|
||||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.media.MediaDetailsActivity
|
||||
|
@ -91,9 +91,7 @@ class OfflineAnimeFragment : Fragment(), OfflineAnimeSearchListener {
|
|||
textInputLayout.boxBackgroundColor = semiTransparentColor
|
||||
val materialCardView = view.findViewById<MaterialCardView>(R.id.offlineMangaAvatarContainer)
|
||||
materialCardView.setCardBackgroundColor(semiTransparentColor)
|
||||
val typedValue = TypedValue()
|
||||
requireContext().theme?.resolveAttribute(android.R.attr.windowBackground, typedValue, true)
|
||||
val color = typedValue.data
|
||||
val color = requireContext().getThemeColor(android.R.attr.windowBackground)
|
||||
|
||||
val animeUserAvatar = view.findViewById<ShapeableImageView>(R.id.offlineMangaUserAvatar)
|
||||
animeUserAvatar.setSafeOnClickListener {
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.net.Uri
|
|||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -35,6 +34,7 @@ import ani.dantotsu.download.DownloadsManager
|
|||
import ani.dantotsu.download.DownloadsManager.Companion.compareName
|
||||
import ani.dantotsu.download.DownloadsManager.Companion.getSubDirectory
|
||||
import ani.dantotsu.download.findValidName
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.initActivity
|
||||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.media.MediaDetailsActivity
|
||||
|
@ -85,9 +85,7 @@ class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener {
|
|||
textInputLayout.boxBackgroundColor = semiTransparentColor
|
||||
val materialCardView = view.findViewById<MaterialCardView>(R.id.offlineMangaAvatarContainer)
|
||||
materialCardView.setCardBackgroundColor(semiTransparentColor)
|
||||
val typedValue = TypedValue()
|
||||
requireContext().theme?.resolveAttribute(android.R.attr.windowBackground, typedValue, true)
|
||||
val color = typedValue.data
|
||||
val color = requireContext().getThemeColor(android.R.attr.windowBackground)
|
||||
|
||||
val animeUserAvatar = view.findViewById<ShapeableImageView>(R.id.offlineMangaUserAvatar)
|
||||
animeUserAvatar.setSafeOnClickListener {
|
||||
|
|
|
@ -3,7 +3,6 @@ package ani.dantotsu.home
|
|||
import android.content.Intent
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.util.TypedValue
|
||||
import android.view.HapticFeedbackConstants
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
|
@ -24,6 +23,7 @@ import ani.dantotsu.connections.anilist.Anilist
|
|||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.databinding.ItemAnimePageBinding
|
||||
import ani.dantotsu.databinding.LayoutTrendingBinding
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.media.CalendarActivity
|
||||
import ani.dantotsu.media.GenreActivity
|
||||
|
@ -67,10 +67,7 @@ class AnimePageAdapter : RecyclerView.Adapter<AnimePageAdapter.AnimePageViewHold
|
|||
val materialCardView =
|
||||
holder.itemView.findViewById<MaterialCardView>(R.id.userAvatarContainer)
|
||||
materialCardView.setCardBackgroundColor(semiTransparentColor)
|
||||
val typedValue = TypedValue()
|
||||
currContext()?.theme?.resolveAttribute(android.R.attr.windowBackground, typedValue, true)
|
||||
val color = typedValue.data
|
||||
|
||||
val color = binding.root.context.getThemeColor(android.R.attr.windowBackground)
|
||||
textInputLayout.boxBackgroundColor = (color and 0x00FFFFFF) or 0x28000000
|
||||
materialCardView.setCardBackgroundColor((color and 0x00FFFFFF) or 0x28000000)
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package ani.dantotsu.home
|
|||
import android.content.Intent
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.util.TypedValue
|
||||
import android.view.HapticFeedbackConstants
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
|
@ -21,9 +20,9 @@ import androidx.viewpager2.widget.ViewPager2
|
|||
import ani.dantotsu.MediaPageTransformer
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.connections.anilist.Anilist
|
||||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.databinding.ItemMangaPageBinding
|
||||
import ani.dantotsu.databinding.LayoutTrendingBinding
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.media.GenreActivity
|
||||
import ani.dantotsu.media.MediaAdaptor
|
||||
|
@ -66,10 +65,7 @@ class MangaPageAdapter : RecyclerView.Adapter<MangaPageAdapter.MangaPageViewHold
|
|||
val materialCardView =
|
||||
holder.itemView.findViewById<MaterialCardView>(R.id.userAvatarContainer)
|
||||
materialCardView.setCardBackgroundColor(semiTransparentColor)
|
||||
val typedValue = TypedValue()
|
||||
currContext()?.theme?.resolveAttribute(android.R.attr.windowBackground, typedValue, true)
|
||||
val color = typedValue.data
|
||||
|
||||
val color = binding.root.context.getThemeColor(android.R.attr.windowBackground)
|
||||
textInputLayout.boxBackgroundColor = (color and 0x00FFFFFF) or 0x28000000
|
||||
materialCardView.setCardBackgroundColor((color and 0x00FFFFFF) or 0x28000000)
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ import android.graphics.Color
|
|||
import android.graphics.Paint
|
||||
import android.graphics.Path
|
||||
import android.util.AttributeSet
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import ani.dantotsu.getThemeColor
|
||||
|
||||
class CircleView(context: Context, attrs: AttributeSet?) : View(context, attrs) {
|
||||
private var parts: Int = 3
|
||||
|
@ -30,12 +30,11 @@ class CircleView(context: Context, attrs: AttributeSet?) : View(context, attrs)
|
|||
|
||||
val totalGapAngle = gapAngle * (parts)
|
||||
val totalAngle = 360f - totalGapAngle
|
||||
val typedValue = TypedValue()
|
||||
context.theme.resolveAttribute(com.google.android.material.R.attr.colorPrimary, typedValue, true)
|
||||
val primaryColor = typedValue.data
|
||||
val typedValue1 = TypedValue()
|
||||
context.theme.resolveAttribute(com.google.android.material.R.attr.colorOnPrimary, typedValue1, true)
|
||||
val secondColor = typedValue1.data
|
||||
|
||||
|
||||
val primaryColor = context.getThemeColor(com.google.android.material.R.attr.colorPrimary)
|
||||
val secondColor = context.getThemeColor(com.google.android.material.R.attr.colorOnPrimary)
|
||||
|
||||
fun setColor(int: Int) {
|
||||
paint.color = if (int < booleanList.size && booleanList[int]) {
|
||||
Color.GRAY
|
||||
|
@ -46,7 +45,6 @@ class CircleView(context: Context, attrs: AttributeSet?) : View(context, attrs)
|
|||
}
|
||||
|
||||
if (parts == 1) {
|
||||
// Draw a single arc covering the entire circle
|
||||
path.addArc(
|
||||
centerX - radius,
|
||||
centerY - radius,
|
||||
|
|
|
@ -7,16 +7,11 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.util.AttributeSet
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.core.content.ContextCompat
|
||||
|
@ -27,6 +22,7 @@ import ani.dantotsu.buildMarkwon
|
|||
import ani.dantotsu.connections.anilist.Anilist
|
||||
import ani.dantotsu.connections.anilist.api.Activity
|
||||
import ani.dantotsu.databinding.FragmentStatusBinding
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.home.status.listener.StoriesCallback
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.media.MediaDetailsActivity
|
||||
|
@ -70,12 +66,9 @@ constructor(
|
|||
val inflater: LayoutInflater = LayoutInflater.from(context)
|
||||
binding = FragmentStatusBinding.inflate(inflater, this, false)
|
||||
addView(binding.root)
|
||||
val typedValue = TypedValue()
|
||||
val typedValue1 = TypedValue()
|
||||
context.theme.resolveAttribute(com.google.android.material.R.attr.colorPrimary, typedValue, true)
|
||||
context.theme.resolveAttribute(com.google.android.material.R.attr.colorOnPrimary, typedValue1, true)
|
||||
primaryColor = typedValue.data
|
||||
onPrimaryColor = typedValue1.data
|
||||
|
||||
primaryColor = context.getThemeColor(com.google.android.material.R.attr.colorPrimary)
|
||||
onPrimaryColor = context.getThemeColor(com.google.android.material.R.attr.colorOnPrimary)
|
||||
|
||||
if (context is StoriesCallback)
|
||||
storiesListener = context as StoriesCallback
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ani.dantotsu.home.status
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ani.dantotsu.media
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
|
@ -14,6 +13,7 @@ import androidx.lifecycle.lifecycleScope
|
|||
import ani.dantotsu.R
|
||||
import ani.dantotsu.Refresh
|
||||
import ani.dantotsu.databinding.ActivityListBinding
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.hideSystemBarsExtendView
|
||||
import ani.dantotsu.media.user.ListViewPagerAdapter
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
|
@ -39,15 +39,10 @@ class CalendarActivity : AppCompatActivity() {
|
|||
binding = ActivityListBinding.inflate(layoutInflater)
|
||||
|
||||
|
||||
val typedValue = TypedValue()
|
||||
theme.resolveAttribute(com.google.android.material.R.attr.colorSurface, typedValue, true)
|
||||
val primaryColor = typedValue.data
|
||||
val typedValue3 = TypedValue()
|
||||
theme.resolveAttribute(com.google.android.material.R.attr.colorPrimary, typedValue3, true)
|
||||
val primaryTextColor = typedValue3.data
|
||||
val typedValue4 = TypedValue()
|
||||
theme.resolveAttribute(com.google.android.material.R.attr.colorOutline, typedValue4, true)
|
||||
val secondaryTextColor = typedValue4.data
|
||||
|
||||
val primaryColor = getThemeColor(com.google.android.material.R.attr.colorSurface)
|
||||
val primaryTextColor = getThemeColor(com.google.android.material.R.attr.colorPrimary)
|
||||
val secondaryTextColor = getThemeColor(com.google.android.material.R.attr.colorOutline)
|
||||
|
||||
window.statusBarColor = primaryColor
|
||||
window.navigationBarColor = primaryColor
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.content.Intent
|
|||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.util.TypedValue
|
||||
import android.view.GestureDetector
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
|
@ -38,6 +37,7 @@ import ani.dantotsu.blurImage
|
|||
import ani.dantotsu.connections.anilist.Anilist
|
||||
import ani.dantotsu.copyToClipboard
|
||||
import ani.dantotsu.databinding.ActivityMediaBinding
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.initActivity
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.media.anime.AnimeWatchFragment
|
||||
|
@ -250,22 +250,12 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
|
|||
@SuppressLint("ResourceType")
|
||||
fun total() {
|
||||
val text = SpannableStringBuilder().apply {
|
||||
val mediaTypedValue = TypedValue()
|
||||
this@MediaDetailsActivity.theme.resolveAttribute(
|
||||
com.google.android.material.R.attr.colorOnBackground,
|
||||
mediaTypedValue,
|
||||
true
|
||||
)
|
||||
val white = mediaTypedValue.data
|
||||
|
||||
val white = this@MediaDetailsActivity.getThemeColor(com.google.android.material.R.attr.colorOnBackground)
|
||||
if (media.userStatus != null) {
|
||||
append(if (media.anime != null) getString(R.string.watched_num) else getString(R.string.read_num))
|
||||
val typedValue = TypedValue()
|
||||
theme.resolveAttribute(
|
||||
com.google.android.material.R.attr.colorSecondary,
|
||||
typedValue,
|
||||
true
|
||||
)
|
||||
bold { color(typedValue.data) { append("${media.userProgress}") } }
|
||||
val colorSecondary = getThemeColor(com.google.android.material.R.attr.colorSecondary)
|
||||
bold { color(colorSecondary) { append("${media.userProgress}") } }
|
||||
append(
|
||||
if (media.anime != null) getString(R.string.episodes_out_of) else getString(
|
||||
R.string.chapters_out_of
|
||||
|
|
|
@ -577,14 +577,14 @@ class MediaInfoFragment : Fragment() {
|
|||
if (Anilist.token != null && media.userStatus != null) {
|
||||
users.add(0,
|
||||
User(
|
||||
Anilist.userid!!,
|
||||
Anilist.username!!,
|
||||
Anilist.avatar,
|
||||
Anilist.bg,
|
||||
id = Anilist.userid!!,
|
||||
name = getString(R.string.your_progress),
|
||||
pfp = Anilist.avatar,
|
||||
banner = "",
|
||||
status = media.userStatus,
|
||||
score = media.userScore.toFloat(),
|
||||
progress = media.userProgress,
|
||||
totalEpisodes = if (type == "ANIME") media.anime?.totalEpisodes else media.manga?.totalChapters,
|
||||
totalEpisodes = media.anime?.totalEpisodes ?: media.manga?.totalChapters,
|
||||
nextAiringEpisode = media.anime?.nextAiringEpisode
|
||||
)
|
||||
)
|
||||
|
|
|
@ -10,7 +10,6 @@ import android.content.Intent
|
|||
import android.graphics.Color
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -34,6 +33,7 @@ import ani.dantotsu.databinding.ItemStreamBinding
|
|||
import ani.dantotsu.databinding.ItemUrlBinding
|
||||
import ani.dantotsu.download.DownloadedType
|
||||
import ani.dantotsu.download.video.Helper
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.hideSystemBars
|
||||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.media.MediaDetailsViewModel
|
||||
|
@ -95,10 +95,7 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
|
|||
_binding = BottomSheetSelectorBinding.inflate(inflater, container, false)
|
||||
val window = dialog?.window
|
||||
window?.statusBarColor = Color.TRANSPARENT
|
||||
val typedValue = TypedValue()
|
||||
val theme = requireContext().theme
|
||||
theme.resolveAttribute(com.google.android.material.R.attr.colorSurface, typedValue, true)
|
||||
window?.navigationBarColor = typedValue.data
|
||||
window?.navigationBarColor = requireContext().getThemeColor(com.google.android.material.R.attr.colorSurface)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ani.dantotsu.media.manga
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -145,8 +144,6 @@ class MangaChapterAdapter(
|
|||
inner class ChapterListViewHolder(val binding: ItemChapterListBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
private val activeCoroutines = mutableSetOf<String>()
|
||||
private val typedValue1 = TypedValue()
|
||||
private val typedValue2 = TypedValue()
|
||||
fun bind(chapterNumber: String, progress: String?) {
|
||||
if (progress != null) {
|
||||
binding.itemChapterTitle.visibility = View.VISIBLE
|
||||
|
@ -201,17 +198,6 @@ class MangaChapterAdapter(
|
|||
}
|
||||
|
||||
init {
|
||||
val theme = currContext()?.theme
|
||||
theme?.resolveAttribute(
|
||||
com.google.android.material.R.attr.colorError,
|
||||
typedValue1,
|
||||
true
|
||||
)
|
||||
theme?.resolveAttribute(
|
||||
com.google.android.material.R.attr.colorPrimary,
|
||||
typedValue2,
|
||||
true
|
||||
)
|
||||
itemView.setOnClickListener {
|
||||
if (0 <= bindingAdapterPosition && bindingAdapterPosition < arr.size)
|
||||
fragment.onMangaChapterClick(arr[bindingAdapterPosition].number)
|
||||
|
|
|
@ -3,7 +3,6 @@ package ani.dantotsu.media.manga.mangareader
|
|||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -14,6 +13,7 @@ import ani.dantotsu.BottomSheetDialogFragment
|
|||
import ani.dantotsu.R
|
||||
import ani.dantotsu.currActivity
|
||||
import ani.dantotsu.databinding.BottomSheetSelectorBinding
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.media.MediaDetailsViewModel
|
||||
import ani.dantotsu.media.MediaSingleton
|
||||
import ani.dantotsu.media.manga.MangaChapter
|
||||
|
@ -78,10 +78,7 @@ class ChapterLoaderDialog : BottomSheetDialogFragment() {
|
|||
_binding = BottomSheetSelectorBinding.inflate(inflater, container, false)
|
||||
val window = dialog?.window
|
||||
window?.statusBarColor = Color.TRANSPARENT
|
||||
val typedValue = TypedValue()
|
||||
val theme = requireContext().theme
|
||||
theme.resolveAttribute(com.google.android.material.R.attr.colorSurface, typedValue, true)
|
||||
window?.navigationBarColor = typedValue.data
|
||||
window?.navigationBarColor = requireContext().getThemeColor(com.google.android.material.R.attr.colorSurface)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ani.dantotsu.media.novel
|
||||
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
|
@ -8,6 +7,7 @@ import androidx.core.view.isVisible
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.databinding.ItemNovelResponseBinding
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.parsers.ShowResponse
|
||||
import ani.dantotsu.setAnimation
|
||||
|
@ -40,14 +40,7 @@ class NovelResponseAdapter(
|
|||
setAnimation(fragment.requireContext(), holder.binding.root)
|
||||
binding.itemEpisodeImage.loadImage(novel.coverUrl, 400, 0)
|
||||
|
||||
val typedValue = TypedValue()
|
||||
fragment.requireContext().theme?.resolveAttribute(
|
||||
com.google.android.material.R.attr.colorOnBackground,
|
||||
typedValue,
|
||||
true
|
||||
)
|
||||
val color = typedValue.data
|
||||
|
||||
val color =fragment.requireContext().getThemeColor(com.google.android.material.R.attr.colorOnBackground)
|
||||
binding.itemEpisodeTitle.text = novel.name
|
||||
binding.itemEpisodeFiller.text =
|
||||
if (downloadedCheckCallback.downloadedCheck(novel)) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ani.dantotsu.media.user
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
|
@ -15,6 +14,7 @@ import androidx.lifecycle.lifecycleScope
|
|||
import ani.dantotsu.R
|
||||
import ani.dantotsu.Refresh
|
||||
import ani.dantotsu.databinding.ActivityListBinding
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.hideSystemBarsExtendView
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
|
@ -37,15 +37,9 @@ class ListActivity : AppCompatActivity() {
|
|||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityListBinding.inflate(layoutInflater)
|
||||
|
||||
val typedValue = TypedValue()
|
||||
theme.resolveAttribute(com.google.android.material.R.attr.colorSurface, typedValue, true)
|
||||
val primaryColor = typedValue.data
|
||||
val typedValue3 = TypedValue()
|
||||
theme.resolveAttribute(com.google.android.material.R.attr.colorPrimary, typedValue3, true)
|
||||
val primaryTextColor = typedValue3.data
|
||||
val typedValue4 = TypedValue()
|
||||
theme.resolveAttribute(com.google.android.material.R.attr.colorOutline, typedValue4, true)
|
||||
val secondaryTextColor = typedValue4.data
|
||||
val primaryColor = getThemeColor(com.google.android.material.R.attr.colorSurface)
|
||||
val primaryTextColor = getThemeColor(com.google.android.material.R.attr.colorPrimary)
|
||||
val secondaryTextColor = getThemeColor(com.google.android.material.R.attr.colorOutline)
|
||||
|
||||
window.statusBarColor = primaryColor
|
||||
window.navigationBarColor = primaryColor
|
||||
|
|
|
@ -2,7 +2,7 @@ package ani.dantotsu.profile
|
|||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.util.TypedValue
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.util.ColorEditor
|
||||
import com.github.aachartmodel.aainfographics.aachartcreator.AAChartModel
|
||||
import com.github.aachartmodel.aainfographics.aachartcreator.AAChartStackingType
|
||||
|
@ -53,13 +53,7 @@ class ChartBuilder {
|
|||
scrollPos: Float? = null,
|
||||
normalize: Boolean = false
|
||||
): AAOptions {
|
||||
val typedValue = TypedValue()
|
||||
context.theme.resolveAttribute(
|
||||
com.google.android.material.R.attr.colorPrimary,
|
||||
typedValue,
|
||||
true
|
||||
)
|
||||
val primaryColor = typedValue.data
|
||||
val primaryColor = context.getThemeColor(com.google.android.material.R.attr.colorPrimary)
|
||||
var chartType = passedChartType
|
||||
var aaChartType = passedAaChartType
|
||||
var categories = passedCategories
|
||||
|
@ -309,31 +303,21 @@ class ChartBuilder {
|
|||
}
|
||||
|
||||
private fun setColors(aaOptions: AAOptions, context: Context) {
|
||||
val backgroundColor = TypedValue()
|
||||
context.theme.resolveAttribute(
|
||||
com.google.android.material.R.attr.colorSurfaceVariant,
|
||||
backgroundColor,
|
||||
true
|
||||
)
|
||||
val backgroundColor = context.getThemeColor(com.google.android.material.R.attr.colorSurfaceVariant)
|
||||
val backgroundStyle = AAStyle().color(
|
||||
AAColor.rgbaColor(
|
||||
Color.red(backgroundColor.data),
|
||||
Color.green(backgroundColor.data),
|
||||
Color.blue(backgroundColor.data),
|
||||
Color.red(backgroundColor),
|
||||
Color.green(backgroundColor),
|
||||
Color.blue(backgroundColor),
|
||||
1f
|
||||
)
|
||||
)
|
||||
val colorOnBackground = TypedValue()
|
||||
context.theme.resolveAttribute(
|
||||
com.google.android.material.R.attr.colorOnSurface,
|
||||
colorOnBackground,
|
||||
true
|
||||
)
|
||||
val colorOnBackground = context.getThemeColor(com.google.android.material.R.attr.colorOnSurface)
|
||||
val onBackgroundStyle = AAStyle().color(
|
||||
AAColor.rgbaColor(
|
||||
Color.red(colorOnBackground.data),
|
||||
Color.green(colorOnBackground.data),
|
||||
Color.blue(colorOnBackground.data),
|
||||
Color.red(colorOnBackground),
|
||||
Color.green(colorOnBackground),
|
||||
Color.blue(colorOnBackground),
|
||||
1.0f
|
||||
)
|
||||
)
|
||||
|
@ -342,9 +326,9 @@ class ChartBuilder {
|
|||
aaOptions.chart?.backgroundColor(backgroundStyle.color)
|
||||
aaOptions.tooltip?.backgroundColor(
|
||||
AAColor.rgbaColor(
|
||||
Color.red(backgroundColor.data),
|
||||
Color.green(backgroundColor.data),
|
||||
Color.blue(backgroundColor.data),
|
||||
Color.red(backgroundColor),
|
||||
Color.green(backgroundColor),
|
||||
Color.blue(backgroundColor),
|
||||
1.0f
|
||||
)
|
||||
)
|
||||
|
|
|
@ -2,9 +2,9 @@ package ani.dantotsu.profile
|
|||
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import ani.dantotsu.databinding.ActivitySingleStatBinding
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.initActivity
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.toast
|
||||
|
@ -20,9 +20,7 @@ class SingleStatActivity : AppCompatActivity() {
|
|||
setContentView(binding.root)
|
||||
val chartOptions = chartOptions
|
||||
if (chartOptions != null) {
|
||||
val typedvalue = TypedValue()
|
||||
theme.resolveAttribute(android.R.attr.windowBackground, typedvalue, true)
|
||||
chartOptions.chart?.backgroundColor = typedvalue.data
|
||||
chartOptions.chart?.backgroundColor = getThemeColor(android.R.attr.windowBackground)
|
||||
binding.chartView.aa_drawChartWithChartOptions(chartOptions)
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||
} else {
|
||||
|
|
|
@ -203,6 +203,7 @@ class SettingsAddonActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
},
|
||||
isVisible = torrentAddonManager.isAvailable()
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -2,8 +2,13 @@ package ani.dantotsu.settings.extensionprefs
|
|||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.graphics.Typeface
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.DialogPreference
|
||||
|
@ -11,7 +16,10 @@ import androidx.preference.EditTextPreference
|
|||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.forEach
|
||||
import androidx.preference.getOnBindEditTextListener
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import eu.kanade.tachiyomi.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
||||
import eu.kanade.tachiyomi.data.preference.SharedPreferencesDataStore
|
||||
|
@ -29,25 +37,19 @@ class AnimeSourcePreferencesFragment : PreferenceFragmentCompat() {
|
|||
snackString(e.message ?: "Unknown error")
|
||||
preferenceManager.createPreferenceScreen(requireContext())
|
||||
}
|
||||
//set background color
|
||||
val color = TypedValue()
|
||||
requireContext().theme.resolveAttribute(
|
||||
com.google.android.material.R.attr.backgroundColor,
|
||||
color,
|
||||
true
|
||||
)
|
||||
view?.setBackgroundColor(color.data)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(requireActivity()).applyTheme()
|
||||
}
|
||||
private var onCloseAction: (() -> Unit)? = null
|
||||
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
onCloseAction?.invoke()
|
||||
}
|
||||
|
||||
fun populateAnimePreferenceScreen(): PreferenceScreen {
|
||||
private fun populateAnimePreferenceScreen(): PreferenceScreen {
|
||||
val sourceId = requireArguments().getLong(SOURCE_ID)
|
||||
val source = Injekt.get<AnimeSourceManager>().get(sourceId) as? ConfigurableAnimeSource
|
||||
?: error("Source with id: $sourceId not found!")
|
||||
|
@ -63,7 +65,6 @@ class AnimeSourcePreferencesFragment : PreferenceFragmentCompat() {
|
|||
pref.dialogTitle = pref.title
|
||||
}
|
||||
|
||||
// Apply incognito IME for EditTextPreference
|
||||
if (pref is EditTextPreference) {
|
||||
val setListener = pref.getOnBindEditTextListener()
|
||||
pref.setOnBindEditTextListener {
|
||||
|
@ -72,7 +73,6 @@ class AnimeSourcePreferencesFragment : PreferenceFragmentCompat() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sourceScreen
|
||||
}
|
||||
|
||||
|
@ -104,13 +104,8 @@ class InitialAnimeSourcePreferencesFragment(
|
|||
preferenceManager.createPreferenceScreen(requireContext())
|
||||
}
|
||||
//set background color
|
||||
val color = TypedValue()
|
||||
requireContext().theme.resolveAttribute(
|
||||
com.google.android.material.R.attr.backgroundColor,
|
||||
color,
|
||||
true
|
||||
)
|
||||
view?.setBackgroundColor(color.data)
|
||||
val color = requireContext().getThemeColor(com.google.android.material.R.attr.backgroundColor,)
|
||||
view?.setBackgroundColor(color)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@ import android.content.Intent
|
|||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.databinding.StatisticsWidgetConfigureBinding
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import eltos.simpledialogfragment.SimpleDialog
|
||||
|
@ -174,29 +174,10 @@ class ProfileStatsConfigure : AppCompatActivity(),
|
|||
}
|
||||
|
||||
private fun themeColors() {
|
||||
val typedValueSurface = TypedValue()
|
||||
theme.resolveAttribute(
|
||||
com.google.android.material.R.attr.colorSurface,
|
||||
typedValueSurface,
|
||||
true
|
||||
)
|
||||
val backgroundColor = typedValueSurface.data
|
||||
|
||||
val typedValuePrimary = TypedValue()
|
||||
theme.resolveAttribute(
|
||||
com.google.android.material.R.attr.colorPrimary,
|
||||
typedValuePrimary,
|
||||
true
|
||||
)
|
||||
val textColor = typedValuePrimary.data
|
||||
|
||||
val typedValueOutline = TypedValue()
|
||||
theme.resolveAttribute(
|
||||
com.google.android.material.R.attr.colorOutline,
|
||||
typedValueOutline,
|
||||
true
|
||||
)
|
||||
val subTextColor = typedValueOutline.data
|
||||
val backgroundColor = getThemeColor(com.google.android.material.R.attr.colorSurface)
|
||||
val textColor = getThemeColor(com.google.android.material.R.attr.colorPrimary)
|
||||
val subTextColor = getThemeColor(com.google.android.material.R.attr.colorOutline)
|
||||
|
||||
getSharedPreferences(
|
||||
ProfileStatsWidget.getPrefsName(appWidgetId),
|
||||
|
|
|
@ -6,11 +6,11 @@ import android.content.Intent
|
|||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.databinding.UpcomingWidgetConfigureBinding
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import eltos.simpledialogfragment.SimpleDialog
|
||||
|
@ -157,29 +157,9 @@ class UpcomingWidgetConfigure : AppCompatActivity(),
|
|||
}
|
||||
|
||||
private fun themeColors() {
|
||||
val typedValueSurface = TypedValue()
|
||||
theme.resolveAttribute(
|
||||
com.google.android.material.R.attr.colorSurface,
|
||||
typedValueSurface,
|
||||
true
|
||||
)
|
||||
val backgroundColor = typedValueSurface.data
|
||||
|
||||
val typedValuePrimary = TypedValue()
|
||||
theme.resolveAttribute(
|
||||
com.google.android.material.R.attr.colorPrimary,
|
||||
typedValuePrimary,
|
||||
true
|
||||
)
|
||||
val textColor = typedValuePrimary.data
|
||||
|
||||
val typedValueOutline = TypedValue()
|
||||
theme.resolveAttribute(
|
||||
com.google.android.material.R.attr.colorOutline,
|
||||
typedValueOutline,
|
||||
true
|
||||
)
|
||||
val subTextColor = typedValueOutline.data
|
||||
val backgroundColor = getThemeColor(com.google.android.material.R.attr.colorSurface)
|
||||
val textColor = getThemeColor(com.google.android.material.R.attr.colorPrimary)
|
||||
val subTextColor = getThemeColor(com.google.android.material.R.attr.colorOutline)
|
||||
|
||||
getSharedPreferences(UpcomingWidget.PREFS_NAME, Context.MODE_PRIVATE).edit().apply {
|
||||
putInt(UpcomingWidget.PREF_BACKGROUND_COLOR, backgroundColor)
|
||||
|
|
|
@ -11,10 +11,8 @@ import android.graphics.drawable.Drawable
|
|||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.PowerManager
|
||||
import android.util.TypedValue
|
||||
import androidx.annotation.AttrRes
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.PermissionChecker
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.core.graphics.alpha
|
||||
|
@ -81,19 +79,7 @@ fun Context.getResourceColor(@AttrRes resource: Int, alphaFactor: Float = 1f): I
|
|||
return color
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
fun Context.getThemeColor(attr: Int): Int {
|
||||
val tv = TypedValue()
|
||||
return if (this.theme.resolveAttribute(attr, tv, true)) {
|
||||
if (tv.resourceId != 0) {
|
||||
ContextCompat.getColor(this, tv.resourceId)
|
||||
} else {
|
||||
tv.data
|
||||
}
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
val Context.powerManager: PowerManager
|
||||
get() = getSystemService()!!
|
||||
|
|
|
@ -965,4 +965,6 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
|
|||
<string name="cover">%1$s\ [Cover]</string>
|
||||
<string name="banner">%1$s\ [Banner]</string>
|
||||
<string name="your_story">Your Story</string>
|
||||
<string name="your_progress">Your Progress</string>
|
||||
<string name="logout_confirm">Are you sure you want to logout?</string>
|
||||
</resources>
|
||||
|
|
|
@ -80,12 +80,6 @@
|
|||
<item name="android:textSize">18sp</item>
|
||||
</style>
|
||||
|
||||
<style name="PreferenceTheme" parent="PreferenceThemeOverlay.v14.Material">
|
||||
<item name="android:fontFamily">@font/poppins_bold</item>
|
||||
<item name="android:textColor">?attr/colorPrimary</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
</style>
|
||||
|
||||
<style name="BottomNavBar" parent="">
|
||||
<!-- set background color to transparent -->
|
||||
<item name="android:background">@android:color/transparent</item>
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
<item name="windowNoTitle">true</item>
|
||||
<item name="android:windowContentTransitions">true</item>
|
||||
<item name="android:fontFamily">@font/poppins</item>
|
||||
<item name="preferenceTheme">@style/PreferenceTheme</item>
|
||||
<item name="android:dialogTheme">@style/MyPopup</item>
|
||||
<item name="android:alertDialogTheme">@style/MyPopup</item>
|
||||
<item name="android:alertDialogStyle">@style/MyPopup</item>
|
||||
<item name="shapeAppearanceLargeComponent">@style/ShapeAppearanceOverlay.Demo</item>
|
||||
<item name="android:ambientShadowAlpha">0.08</item>
|
||||
<item name="android:spotShadowAlpha">0.08</item>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue