Modularize some map-related files (#3154)

This commit is contained in:
Phil Oliver 2025-09-19 19:12:26 -04:00 committed by GitHub
parent 00ee0db78a
commit 8b2e1e8b02
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 62 additions and 36 deletions

View file

@ -19,28 +19,17 @@ 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
/// show a toast
fun Context.toast(message: CharSequence) =
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
// / show a toast
fun Context.toast(message: CharSequence) = Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
/// Utility function to hide the soft keyboard per stack overflow
// / Utility function to hide the soft keyboard per stack overflow
fun Activity.hideKeyboard() {
// Check if no view has focus:
currentFocus?.let { v ->
val imm =
getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
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()
// Converts DP to pixels.
fun Context.dpToPx(dp: Float): Int =
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.displayMetrics).toInt()

View file

@ -41,7 +41,6 @@ import com.geeksville.mesh.android.prefs.MapPrefs
import com.geeksville.mesh.database.MeshLogRepository
import com.geeksville.mesh.database.entity.FirmwareRelease
import com.geeksville.mesh.database.entity.MeshLog
import com.geeksville.mesh.model.map.CustomTileSource
import com.geeksville.mesh.repository.api.DeviceHardwareRepository
import com.geeksville.mesh.repository.api.FirmwareReleaseRepository
import com.geeksville.mesh.repository.datastore.RadioConfigRepository
@ -64,6 +63,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.meshtastic.core.model.DeviceHardware
import org.meshtastic.core.navigation.NodesRoutes
import org.meshtastic.feature.map.model.CustomTileSource
import java.io.BufferedWriter
import java.io.FileNotFoundException
import java.io.FileWriter