fix: bio color cleanup
This commit is contained in:
parent
fd39c4f391
commit
bb110be9ab
3 changed files with 8 additions and 19 deletions
|
@ -16,6 +16,7 @@ import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import ani.dantotsu.R
|
||||||
import ani.dantotsu.connections.anilist.ProfileViewModel
|
import ani.dantotsu.connections.anilist.ProfileViewModel
|
||||||
import ani.dantotsu.connections.anilist.api.Query
|
import ani.dantotsu.connections.anilist.api.Query
|
||||||
import ani.dantotsu.databinding.FragmentProfileBinding
|
import ani.dantotsu.databinding.FragmentProfileBinding
|
||||||
|
@ -59,27 +60,12 @@ class ProfileFragment : Fragment() {
|
||||||
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) {
|
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) {
|
||||||
model.setData(user.id)
|
model.setData(user.id)
|
||||||
}
|
}
|
||||||
val backGroundColorTypedValue = TypedValue()
|
|
||||||
val textColorTypedValue = TypedValue()
|
|
||||||
activity.theme.resolveAttribute(
|
|
||||||
android.R.attr.windowBackground,
|
|
||||||
backGroundColorTypedValue,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
activity.theme.resolveAttribute(
|
|
||||||
com.google.android.material.R.attr.colorOnBackground,
|
|
||||||
textColorTypedValue,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
binding.profileUserBio.settings.loadWithOverviewMode = true
|
binding.profileUserBio.settings.loadWithOverviewMode = true
|
||||||
binding.profileUserBio.settings.useWideViewPort = true
|
binding.profileUserBio.settings.useWideViewPort = true
|
||||||
binding.profileUserBio.setInitialScale(1)
|
binding.profileUserBio.setInitialScale(1)
|
||||||
Logger.log("Text color: ${textColorTypedValue.data} Background color: ${backGroundColorTypedValue.data}")
|
|
||||||
val styledHtml = getFullAniHTML(
|
val styledHtml = getFullAniHTML(
|
||||||
user.about ?: "",
|
user.about ?: "",
|
||||||
backGroundColorTypedValue.data,
|
activity.getColor(R.color.bg_opp)
|
||||||
textColorTypedValue.data
|
|
||||||
)
|
)
|
||||||
binding.profileUserBio.loadDataWithBaseURL(
|
binding.profileUserBio.loadDataWithBaseURL(
|
||||||
null,
|
null,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ani.dantotsu.util
|
package ani.dantotsu.util
|
||||||
|
|
||||||
import ani.dantotsu.util.ColorEditor.Companion.toCssColor
|
import ani.dantotsu.util.ColorEditor.Companion.toCssColor
|
||||||
|
import ani.dantotsu.util.ColorEditor.Companion.toHexColor
|
||||||
|
|
||||||
class AniMarkdown { //istg anilist has the worst api
|
class AniMarkdown { //istg anilist has the worst api
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -60,7 +61,7 @@ class AniMarkdown { //istg anilist has the worst api
|
||||||
return underlineToHtml(step3)
|
return underlineToHtml(step3)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getFullAniHTML(html: String, backGroundColor: Int, textColor: Int): String {
|
fun getFullAniHTML(html: String, textColor: Int): String {
|
||||||
val basicHtml = getBasicAniHTML(html)
|
val basicHtml = getBasicAniHTML(html)
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,7 +96,6 @@ class AniMarkdown { //istg anilist has the worst api
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
Logger.log(returnHtml)
|
|
||||||
return returnHtml
|
return returnHtml
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,8 +91,11 @@ class ColorEditor {
|
||||||
base += "${Color.green(this)}, "
|
base += "${Color.green(this)}, "
|
||||||
base += "${Color.blue(this)}, "
|
base += "${Color.blue(this)}, "
|
||||||
base += "${Color.alpha(this) / 255.0})"
|
base += "${Color.alpha(this) / 255.0})"
|
||||||
Logger.log("Color: $base")
|
|
||||||
return base
|
return base
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Int.toHexColor(): String {
|
||||||
|
return String.format("#%06X", 0xFFFFFF and this)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue