mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2025-12-24 00:07:48 -05:00
Modularize some map-related files (#3154)
This commit is contained in:
@@ -183,6 +183,7 @@ dependencies {
|
||||
implementation(projects.core.network)
|
||||
implementation(projects.core.prefs)
|
||||
implementation(projects.core.proto)
|
||||
implementation(projects.feature.map)
|
||||
|
||||
// Bundles
|
||||
implementation(libs.bundles.markdown)
|
||||
|
||||
@@ -72,9 +72,6 @@ import com.geeksville.mesh.copy
|
||||
import com.geeksville.mesh.database.entity.Packet
|
||||
import com.geeksville.mesh.model.Node
|
||||
import com.geeksville.mesh.model.UIViewModel
|
||||
import com.geeksville.mesh.model.map.CustomTileSource
|
||||
import com.geeksville.mesh.model.map.MarkerWithLabel
|
||||
import com.geeksville.mesh.model.map.clustering.RadiusMarkerClusterer
|
||||
import com.geeksville.mesh.ui.map.components.CacheLayout
|
||||
import com.geeksville.mesh.ui.map.components.DownloadButton
|
||||
import com.geeksville.mesh.ui.map.components.EditWaypointDialog
|
||||
@@ -84,11 +81,14 @@ import com.geeksville.mesh.util.addCopyright
|
||||
import com.geeksville.mesh.util.addScaleBarOverlay
|
||||
import com.geeksville.mesh.util.createLatLongGrid
|
||||
import com.geeksville.mesh.util.formatAgo
|
||||
import com.geeksville.mesh.util.zoomIn
|
||||
import com.geeksville.mesh.waypoint
|
||||
import com.google.accompanist.permissions.ExperimentalPermissionsApi // Added for Accompanist
|
||||
import com.google.accompanist.permissions.rememberMultiplePermissionsState // Added for Accompanist
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import org.meshtastic.feature.map.cluster.RadiusMarkerClusterer
|
||||
import org.meshtastic.feature.map.model.CustomTileSource
|
||||
import org.meshtastic.feature.map.model.MarkerWithLabel
|
||||
import org.meshtastic.feature.map.zoomIn
|
||||
import org.osmdroid.bonuspack.utils.BonusPackHelper.getBitmapFromVectorDrawable
|
||||
import org.osmdroid.config.Configuration
|
||||
import org.osmdroid.events.MapEventsReceiver
|
||||
|
||||
@@ -35,7 +35,7 @@ import androidx.lifecycle.LifecycleEventObserver
|
||||
import androidx.lifecycle.compose.LocalLifecycleOwner
|
||||
import com.geeksville.mesh.BuildConfig
|
||||
import com.geeksville.mesh.android.BuildUtils.errormsg
|
||||
import com.geeksville.mesh.util.requiredZoomLevel
|
||||
import org.meshtastic.feature.map.requiredZoomLevel
|
||||
import org.osmdroid.config.Configuration
|
||||
import org.osmdroid.tileprovider.tilesource.ITileSource
|
||||
import org.osmdroid.tileprovider.tilesource.TileSourceFactory
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -83,4 +83,5 @@ dependencies {
|
||||
kover(projects.core.navigation)
|
||||
kover(projects.core.network)
|
||||
kover(projects.core.prefs)
|
||||
kover(projects.feature.map)
|
||||
}
|
||||
25
feature/map/build.gradle.kts
Normal file
25
feature/map/build.gradle.kts
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2025 Meshtastic LLC
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.kover)
|
||||
alias(libs.plugins.meshtastic.android.library)
|
||||
}
|
||||
|
||||
android { namespace = "org.meshtastic.feature.map" }
|
||||
|
||||
dependencies { implementation(libs.bundles.osm) }
|
||||
@@ -15,14 +15,14 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.geeksville.mesh.model.map.clustering;
|
||||
package org.meshtastic.feature.map.cluster;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Point;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.geeksville.mesh.model.map.MarkerWithLabel;
|
||||
import org.meshtastic.feature.map.model.MarkerWithLabel;
|
||||
|
||||
import org.osmdroid.util.BoundingBox;
|
||||
import org.osmdroid.views.MapView;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.geeksville.mesh.model.map.clustering;
|
||||
package org.meshtastic.feature.map.cluster;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
@@ -27,7 +27,7 @@ import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.geeksville.mesh.model.map.MarkerWithLabel;
|
||||
import org.meshtastic.feature.map.model.MarkerWithLabel;
|
||||
|
||||
import org.osmdroid.bonuspack.R;
|
||||
import org.osmdroid.util.BoundingBox;
|
||||
@@ -15,9 +15,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.geeksville.mesh.model.map.clustering;
|
||||
package org.meshtastic.feature.map.cluster;
|
||||
|
||||
import com.geeksville.mesh.model.map.MarkerWithLabel;
|
||||
import org.meshtastic.feature.map.model.MarkerWithLabel;
|
||||
|
||||
import org.osmdroid.util.BoundingBox;
|
||||
import org.osmdroid.util.GeoPoint;
|
||||
@@ -15,8 +15,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.geeksville.mesh.util
|
||||
package org.meshtastic.feature.map
|
||||
|
||||
import android.content.Context
|
||||
import android.util.TypedValue
|
||||
import org.osmdroid.util.BoundingBox
|
||||
import org.osmdroid.util.GeoPoint
|
||||
import kotlin.math.log2
|
||||
@@ -69,3 +71,11 @@ fun BoundingBox.zoomIn(zoomFactor: Double): BoundingBox {
|
||||
center.longitude - newLonDiff / 2,
|
||||
)
|
||||
}
|
||||
|
||||
// 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()
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.geeksville.mesh.model.map
|
||||
package org.meshtastic.feature.map.model
|
||||
|
||||
import org.osmdroid.tileprovider.tilesource.ITileSource
|
||||
import org.osmdroid.tileprovider.tilesource.OnlineTileSourceBase
|
||||
@@ -15,15 +15,15 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.geeksville.mesh.model.map
|
||||
package org.meshtastic.feature.map.model
|
||||
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.graphics.RectF
|
||||
import android.view.MotionEvent
|
||||
import com.geeksville.mesh.android.dpToPx
|
||||
import com.geeksville.mesh.android.spToPx
|
||||
import org.meshtastic.feature.map.dpToPx
|
||||
import org.meshtastic.feature.map.spToPx
|
||||
import org.osmdroid.views.MapView
|
||||
import org.osmdroid.views.overlay.Marker
|
||||
import org.osmdroid.views.overlay.Polygon
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.geeksville.mesh.model.map
|
||||
package org.meshtastic.feature.map.model
|
||||
|
||||
import android.content.res.Resources
|
||||
import android.util.Log
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.geeksville.mesh.model.map
|
||||
package org.meshtastic.feature.map.model
|
||||
|
||||
import org.osmdroid.tileprovider.tilesource.OnlineTileSourceBase
|
||||
import org.osmdroid.tileprovider.tilesource.TileSourcePolicy
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.geeksville.mesh.model.map
|
||||
package org.meshtastic.feature.map.model
|
||||
|
||||
class CustomTileSource {
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.gradle.kotlin.dsl.maven
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
include(":app", ":core:model", ":core:navigation", ":core:network", ":core:prefs", ":core:proto", ":mesh_service_example")
|
||||
include(":app", ":core:model", ":core:navigation", ":core:network", ":core:prefs", ":core:proto", ":feature:map", ":mesh_service_example")
|
||||
rootProject.name = "MeshtasticAndroid"
|
||||
|
||||
// https://docs.gradle.org/current/userguide/declaring_dependencies.html#sec:type-safe-project-accessors
|
||||
|
||||
Reference in New Issue
Block a user