fix: correct hi-res icon size

Also fix some deprecated calls.
This commit is contained in:
Anna 2021-07-05 03:52:54 -04:00
parent 2da9616b2b
commit 48772e0e1d
7 changed files with 17 additions and 29 deletions

View File

@ -3,22 +3,6 @@
<option name="LINE_SEPARATOR" value="&#10;" />
<option name="RIGHT_MARGIN" value="0" />
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
<package name="java.util" alias="false" withSubpackages="false" />
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
<package name="io.ktor" alias="false" withSubpackages="true" />
</value>
</option>
<option name="PACKAGES_IMPORT_LAYOUT">
<value>
<package name="" alias="false" withSubpackages="true" />
<package name="java" alias="false" withSubpackages="true" />
<package name="javax" alias="false" withSubpackages="true" />
<package name="kotlin" alias="false" withSubpackages="true" />
<package name="" alias="true" withSubpackages="true" />
</value>
</option>
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" />
<option name="WRAP_EXPRESSION_BODY_FUNCTIONS" value="0" />
@ -155,4 +139,4 @@
<option name="WRAP_ON_TYPING" value="0" />
</codeStyleSettings>
</code_scheme>
</component>
</component>

View File

@ -21,6 +21,8 @@ data class RelayRegister(
if (this === other) {
return true
}
@Suppress("ImplicitThis")
if (this.javaClass != other?.javaClass) {
return false
}

View File

@ -70,8 +70,8 @@ class PlayerDetailFragment : Fragment() {
binding.job.text = player.jobName?.let { jobName ->
jobName
.split(' ')
.joinToString(" ") {
it.capitalize(Locale.getDefault())
.joinToString(" ") { word ->
word.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
}
}
@ -98,6 +98,10 @@ class PlayerDetailFragment : Fragment() {
return binding.root
}
private val searchResultsJson = Json {
this.ignoreUnknownKeys = true
}
private suspend fun downloadPlayerPortrait(player: Player): Bitmap? {
// create the http client and build the xivapi url for searching for this player
val client = HttpClient(Android) {
@ -124,9 +128,7 @@ class PlayerDetailFragment : Fragment() {
val jsonBytes: ByteArray = client.get(url.toString())
val json = jsonBytes.decodeToString()
// parse the search results into a class
val data: CharacterSearchResults = Json {
this.ignoreUnknownKeys = true
}.decodeFromString(json)
val data: CharacterSearchResults = this@PlayerDetailFragment.searchResultsJson.decodeFromString(json)
// if there were no results, return false (will try again on next zone change)
if (data.results.isEmpty()) {
imageChannel.send(null)

View File

@ -1,9 +1,9 @@
package io.annaclemens.xivchat.ui.servers.scan
import kotlin.time.Duration
import kotlin.time.ExperimentalTime
import kotlin.time.TimeMark
import kotlin.time.TimeSource
import kotlin.time.seconds
@OptIn(ExperimentalUnsignedTypes::class, ExperimentalTime::class)
data class ScannedServer(
@ -18,7 +18,7 @@ data class ScannedServer(
this.timestamp = TimeSource.Monotonic.markNow()
}
fun hasExpired() = this.timestamp.elapsedNow() >= 10.seconds
fun hasExpired() = this.timestamp.elapsedNow() >= Duration.seconds(10)
override fun equals(other: Any?): Boolean {
if (this === other) return true

View File

@ -43,7 +43,7 @@ class ServerScannerService : Service() {
private lateinit var runner: ServerScanner
private val handler = Handler(Looper.getMainLooper())
override fun onBind(intent: Intent?): IBinder? {
override fun onBind(intent: Intent?): IBinder {
return this.binder
}

View File

@ -18,7 +18,7 @@ class MessageFilter(private val filters: Set<FilterType>) {
}
val filterString = this.filterString
if (filterString != null && message.spans(null, null)?.contains(filterString, ignoreCase = true) != true) {
if (filterString != null && !message.spans(null, null).contains(filterString, ignoreCase = true)) {
return false
}

View File

@ -18,7 +18,7 @@ import io.noties.markwon.Markwon
@ExperimentalUnsignedTypes
class SeString {
companion object {
fun chunksToSpans(chunks: List<Chunk>, markdown: Markwon?, context: Context?): Spanned? {
fun chunksToSpans(chunks: List<Chunk>, markdown: Markwon?, context: Context?): Spanned {
val builder = SpannableStringBuilder()
for (chunk in chunks) {
@ -33,8 +33,8 @@ class SeString {
val bounds = iconBounds(chunk.index.toInt()) ?: continue
val fontIcon = ContextCompat.getDrawable(context, R.drawable.fonticon_ps4) ?: continue
val cropped = CroppedDrawable(fontIcon, bounds).apply {
val width = (bounds.width() * context.resources.displayMetrics.density).toInt()
val height = (bounds.height() * context.resources.displayMetrics.density).toInt()
val width = (bounds.width() * context.resources.displayMetrics.density / 2).toInt()
val height = (bounds.height() * context.resources.displayMetrics.density / 2).toInt()
this.bounds = Rect(0, 0, width, height)
}
val imageSpan = CentredImageSpan(cropped)