kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
* Use and SP font size for marker labels on the map * Fix detekt issuepull/1637/head
rodzic
1a11c3351b
commit
5da827473a
|
@ -19,6 +19,7 @@ package com.geeksville.mesh.android
|
|||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.util.TypedValue
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.Toast
|
||||
|
||||
|
@ -35,3 +36,7 @@ fun Activity.hideKeyboard() {
|
|||
imm?.hideSoftInputFromWindow(v.windowToken, 0)
|
||||
}
|
||||
}
|
||||
|
||||
// Converts SP to pixels.
|
||||
fun Context.spToPx(sp: Float): Int =
|
||||
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, resources.displayMetrics).toInt()
|
||||
|
|
|
@ -22,6 +22,7 @@ import android.graphics.Color
|
|||
import android.graphics.Paint
|
||||
import android.graphics.RectF
|
||||
import android.view.MotionEvent
|
||||
import com.geeksville.mesh.android.spToPx
|
||||
import org.osmdroid.views.MapView
|
||||
import org.osmdroid.views.overlay.Marker
|
||||
import org.osmdroid.views.overlay.Polygon
|
||||
|
@ -31,6 +32,8 @@ class MarkerWithLabel(mapView: MapView?, label: String, emoji: String? = null) :
|
|||
companion object {
|
||||
private const val LABEL_CORNER_RADIUS = 12F
|
||||
private const val LABEL_Y_OFFSET = 100F
|
||||
private const val FONT_SIZE_SP = 14f
|
||||
private const val EMOJI_FONT_SIZE_SP = 20f
|
||||
}
|
||||
|
||||
private var nodeColor: Int = Color.GRAY
|
||||
|
@ -69,14 +72,14 @@ class MarkerWithLabel(mapView: MapView?, label: String, emoji: String? = null) :
|
|||
private val mLabel = label
|
||||
private val mEmoji = emoji
|
||||
private val textPaint = Paint().apply {
|
||||
textSize = 40f
|
||||
textSize = mapView?.context?.spToPx(FONT_SIZE_SP)?.toFloat() ?: 40f
|
||||
color = Color.DKGRAY
|
||||
isAntiAlias = true
|
||||
isFakeBoldText = true
|
||||
textAlign = Paint.Align.CENTER
|
||||
}
|
||||
private val emojiPaint = Paint().apply {
|
||||
textSize = 80f
|
||||
textSize = mapView?.context?.spToPx(EMOJI_FONT_SIZE_SP)?.toFloat() ?: 80f
|
||||
isAntiAlias = true
|
||||
textAlign = Paint.Align.CENTER
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue