Skip to content

Commit

Permalink
Merge pull request #165 from bailuk/stage
Browse files Browse the repository at this point in the history
Release v1.26
  • Loading branch information
bailuk authored Jul 15, 2024
2 parents 37f1e75 + 0389d40 commit 122fa65
Show file tree
Hide file tree
Showing 117 changed files with 7,386 additions and 2,572 deletions.
6 changes: 5 additions & 1 deletion aat-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ android {
targetSdk = 33

// Version Code can not be taken from from variable (f-droid version checker fail)
versionCode = 39
versionCode = 40
versionName = appVersionName
applicationId = appId
}
Expand Down Expand Up @@ -81,6 +81,10 @@ dependencies {
val mapsForgeVersion: String by project


// Android support only Junit 4
// https://mvnrepository.com/artifact/junit/junit
testImplementation("junit:junit:4.12")

// MapsForge Android
implementation("org.mapsforge:mapsforge-map-android:$mapsForgeVersion")
implementation("com.caverock:androidsvg:1.4")
Expand Down
4 changes: 1 addition & 3 deletions aat-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@
<service android:name="ch.bailu.aat.services.OneService" >
</service>


<provider android:name="ch.bailu.aat.providers.GpxProvider"
<provider android:name="ch.bailu.aat.providers.GpxSendViewProvider"
android:authorities="${applicationId}.gpx"
android:exported="true">
</provider>
Expand All @@ -197,6 +196,5 @@
<action android:name="android.content.action.DOCUMENTS_PROVIDER" />
</intent-filter>
</provider>

</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ abstract class AbsOsmApiActivity : ActivityContext(), View.OnClickListener {
addTarget(list!!, InfoID.FILE_VIEW)

appContext.broadcaster.register(
onFileTaskChanged,
AppBroadcaster.FILE_BACKGROUND_TASK_CHANGED
AppBroadcaster.FILE_BACKGROUND_TASK_CHANGED,
onFileTaskChanged
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import ch.bailu.aat.util.ui.theme.UiTheme
import ch.bailu.aat.views.bar.MainControlBar
import ch.bailu.aat.views.layout.ContentView
import ch.bailu.aat.views.layout.LabelTextView
import ch.bailu.aat.views.msg.permission.DataDirectoryPermissionInfoView
import ch.bailu.aat.views.msg.permission.LocationPermissionInfoView
import ch.bailu.aat.views.preferences.SolidIndexListView
import ch.bailu.aat.views.preferences.VerticalScrollView
import ch.bailu.aat_lib.dispatcher.AppBroadcaster
Expand Down Expand Up @@ -44,10 +46,19 @@ class MainActivity : ActivityContext() {
private fun createViews() {
val contentView = ContentView(this, theme)
contentView.add(createButtonBar())
contentView.add(permissionInfo())
contentView.addW(createActionList())
setContentView(contentView)
}

private fun permissionInfo(): View {
return LinearLayout(this).apply {
orientation = LinearLayout.VERTICAL
addView(LocationPermissionInfoView(this@MainActivity, theme))
addView(DataDirectoryPermissionInfoView(this@MainActivity, appContext.dataDirectory, theme))
}
}

private fun createActionList(): View {
val list = VerticalScrollView(this)
list.add(SolidIndexListView(this, SolidPreset(appContext.storage), theme))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ class AndroidAppConfig : AppConfig() {

// Version Code can not be taken from from variable (f-droid version checker fail)
override val appVersionCode = BuildConfig.VERSION_CODE

override val appId: String
get() = BuildConfig.APPLICATION_ID
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AndroidBroadcaster(private val context: Context) : Broadcaster {
context.sendBroadcast(AppIntent.toIntent(action, *args))
}

override fun register(broadcastReceiver: BroadcastReceiver, action: String) {
override fun register(action: String, broadcastReceiver: BroadcastReceiver) {
if (!observers.containsKey(broadcastReceiver)) {
val receiver = object : android.content.BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SensorSource(private val services: ServicesInterface, private val broadcas
}

override fun onResume() {
broadcaster.register(onSensorUpdated, changedAction)
broadcaster.register(changedAction, onSensorUpdated)
}

override fun getIID(): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import ch.bailu.aat_lib.map.edge.Position
import ch.bailu.aat_lib.map.layer.gpx.GpxDynLayer
import ch.bailu.aat_lib.preferences.StorageInterface
import ch.bailu.aat_lib.resources.Res
import ch.bailu.aat_lib.service.ServicesInterface

class EditorBarLayer(
appContext: AppContext,
private val appContext: AppContext,
context: Context,
private val mcontext: MapContext,
dispatcher: DispatcherInterface,
Expand All @@ -35,15 +34,10 @@ class EditorBarLayer(
private val down: View = bar.addImageButton(R.drawable.go_down)
private val undo: View = bar.addImageButton(R.drawable.edit_redo)
private val redo: View = bar.addImageButton(R.drawable.edit_redo)
private val services: ServicesInterface
private val selector: EditorNodeViewLayer
private val content: GpxDynLayer
private val content: GpxDynLayer = GpxDynLayer(appContext.storage, mcontext, appContext.services)
private val selector = EditorNodeViewLayer(appContext, context, mcontext, edit)

init {
services = appContext.services
content = GpxDynLayer(appContext.storage, mcontext, appContext.services)
selector = EditorNodeViewLayer(appContext, context, mcontext, edit)

ToolTip.set(add, Res.str().tt_edit_add())
ToolTip.set(remove, Res.str().tt_edit_remove())
ToolTip.set(up, Res.str().tt_edit_up())
Expand Down Expand Up @@ -73,30 +67,22 @@ class EditorBarLayer(
}
}

override fun onClick(v: View) {
super.onClick(v)
override fun onClick(view: View) {
super.onClick(view)
val editor = edit.editor
if (v === add) {
val p = mcontext.getMapView().getMapViewPosition().center
editor.add(
GpxPoint(
p,
services.elevationService.getElevation(p.latitudeE6, p.longitudeE6).toFloat(),
0
)
)
} else if (v === remove) {
editor.remove()
} else if (v === up){
editor.up()
} else if (v === down){
editor.down()
} else if (v === undo){
editor.undo()
} else if (v === redo){
editor.redo()
} else if (v === menu){
EditorMenu(v.context, services, editor, edit.file).showAsPopup(v.context, v)

when(view) {
add -> {
val pos = mcontext.getMapView().getMapViewPosition().center
val ele = appContext.services.elevationService.getElevation(pos.latitudeE6, pos.longitudeE6).toFloat()
editor.add(GpxPoint(pos, ele,0))
}
remove -> editor.remove()
up -> editor.up()
down -> editor.down()
undo -> editor.undo()
redo -> editor.redo()
menu -> EditorMenu(appContext, view.context, editor, edit.file).showAsPopup(view.context, view)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import ch.bailu.aat.preferences.Storage
import ch.bailu.aat.util.fs.AndroidFileAction
import ch.bailu.aat.util.ui.theme.AppTheme
import ch.bailu.aat.util.ui.tooltip.ToolTip
import ch.bailu.aat.views.image.PreviewView
import ch.bailu.aat.views.bar.ControlBar
import ch.bailu.aat.views.image.PreviewView
import ch.bailu.aat_lib.app.AppContext
import ch.bailu.aat_lib.description.AverageSpeedDescription
import ch.bailu.aat_lib.description.CaloriesDescription
Expand Down Expand Up @@ -132,7 +132,10 @@ class FileControlBarLayer(
SolidDirectoryQuery(Storage(acontext), FocAndroidFactory(acontext)).position.setValue(index)
iterator.moveToPosition(index)
selectedFile = iterator.info.file
preview.setFilePath(selectedFile)
val file = selectedFile
if (file is Foc) {
preview.setFilePath(file)
}
markupBuilder.appendHeader(iterator.info.file.name)
for (d in summaryData) {
d.onContentUpdated(iterator.infoID, iterator.info)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package ch.bailu.aat.map.mapsforge

import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Color
import ch.bailu.aat.dispatcher.AndroidBroadcaster
import ch.bailu.aat.map.MapDensity
import ch.bailu.aat.preferences.Storage
import ch.bailu.aat.util.graphic.AndroidSyncTileBitmap
import ch.bailu.aat_lib.app.AppContext
import ch.bailu.aat_lib.app.AppGraphicFactory
import ch.bailu.aat_lib.dispatcher.AppBroadcaster
import ch.bailu.aat_lib.gpx.GpxInformation
import ch.bailu.aat_lib.gpx.InfoID
import ch.bailu.aat_lib.lib.color.ColorInterface
import ch.bailu.aat_lib.logger.AppLog
import ch.bailu.aat_lib.map.layer.gpx.GpxDynLayer
import ch.bailu.aat_lib.map.tile.MapTileInterface
import ch.bailu.aat_lib.map.tile.MapsForgeTileLayer
import ch.bailu.aat_lib.map.tile.TileProvider
import ch.bailu.aat_lib.map.tile.source.CacheOnlySource
Expand All @@ -28,13 +26,12 @@ import org.mapsforge.core.model.BoundingBox
import org.mapsforge.core.model.Dimension
import org.mapsforge.core.model.MapPosition
import org.mapsforge.core.model.Point
import org.mapsforge.map.android.graphics.AndroidGraphicFactory
import org.mapsforge.map.util.LayerUtil
import org.mapsforge.map.util.MapPositionUtil
import org.mapsforge.map.view.FrameBuffer
import org.mapsforge.map.view.FrameBufferHA3

class MapsForgePreview(context: Context, appContext: AppContext, info: GpxInformation, out: Foc):
class MapsForgePreview(context: Context, private val appContext: AppContext, info: GpxInformation, out: Foc):
MapsForgeViewBase(appContext, context, MapsForgePreview::class.java.simpleName, MapDensity()),
MapPreviewInterface {

Expand All @@ -51,9 +48,9 @@ class MapsForgePreview(context: Context, appContext: AppContext, info: GpxInform
provider = TileProvider(appContext, getSource(SolidRenderTheme(appContext.mapDirectory, appContext)))

val tileLayer = MapsForgeTileLayer(appContext.services, provider, appContext.tilePainter)
add(tileLayer, tileLayer)
add(tileLayer)

val gpxLayer = GpxDynLayer(Storage(getContext()), getMContext(), appContext.services)
val gpxLayer = GpxDynLayer(appContext.storage, getMContext(), appContext.services)
add(gpxLayer)
attachLayers()
gpxLayer.onContentUpdated(InfoID.FILE_VIEW, info)
Expand Down Expand Up @@ -88,7 +85,7 @@ class MapsForgePreview(context: Context, appContext: AppContext, info: GpxInform
return object : FrameBufferHA3(
model.frameBufferModel,
model.displayModel,
AndroidGraphicFactory.INSTANCE
AppGraphicFactory.instance()
) {
override fun getDrawingBitmap(): Bitmap? {
return null
Expand All @@ -103,36 +100,33 @@ class MapsForgePreview(context: Context, appContext: AppContext, info: GpxInform
* End of "prevent MapView from drawing" hack
*/

private fun generateBitmap(): AndroidSyncTileBitmap {
val bitmap = AndroidSyncTileBitmap()
private fun generateBitmap(): MapTileInterface {
val bitmap = appContext.createMapTile()

bitmap.set(BITMAP_SIZE, false)
if (bitmap.androidBitmap != null) {
val c = bitmap.androidCanvas
val canvas = AndroidGraphicFactory.createGraphicContext(c)
bitmap.androidBitmap?.eraseColor(Color.BLACK)
if (bitmap.isLoaded()) {
val canvas = bitmap.getCanvas()
bitmap.getBitmap()?.setBackgroundColor(ColorInterface.BLACK)
for (layer in layerManager.layers) {
layer.draw(bounding, mapPosition.zoomLevel, canvas, tlPoint)
}
}
return bitmap
}

@SuppressLint("WrongThread")
override fun generateBitmapFile() {
val bitmap = generateBitmap()
try {
imageFile.openW()?.use { out ->
bitmap.androidBitmap?.compress(android.graphics.Bitmap.CompressFormat.PNG, 90, out)
AndroidBroadcaster.broadcast(
context,
bitmap.getBitmap()?.compress(out)
appContext.broadcaster.broadcast(
AppBroadcaster.FILE_CHANGED_ONDISK,
imageFile,
imageFile.path,
javaClass.name
)
}
} catch (e: Exception) {
AppLog.e(context, e)
AppLog.e(this, e)
}
bitmap.free()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MapsForgeView(
private val foreground = MapsForgeForeground(appContext, this, getMContext(), MapDensity(context), layers)

init {
add(stack, stack)
add(stack)
add(pos)

isClickable = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ open class MapsForgeViewBase(
private val mcontext: MapsForgeContext
private val services: ServicesInterface
private val storage: Storage
var areServicesUp = false
var isVisible = false
private var areServicesUp = false
private var isVisible = false
val layers = ArrayList<MapLayerInterface>(10)
private var areLayersAttached = false

Expand All @@ -43,7 +43,7 @@ open class MapsForgeViewBase(
model.displayModel.setFixedTileSize(d.tileSize)
services = appContext.services
mcontext = MapsForgeContext(appContext, this, key, d)
add(mcontext, mcontext)
add(mcontext)
storage = Storage(context)
mapScaleBar.isVisible = false
setBuiltInZoomControls(false)
Expand All @@ -54,8 +54,14 @@ open class MapsForgeViewBase(
}

override fun add(layer: MapLayerInterface) {
val wrapper = LayerWrapper(services, mcontext, layer)
add(wrapper, layer)
val wrapper: Layer = if (layer is Layer) {
layer
} else {
LayerWrapper(services, mcontext, layer)
}
addLayer(wrapper)
layers.add(layer)
if (areLayersAttached) layer.onAttached()
}

override fun getMContext(): MapContext {
Expand All @@ -71,12 +77,6 @@ open class MapsForgeViewBase(
return model.mapViewPosition
}

fun add(mfLayer: Layer, layer: MapLayerInterface) {
addLayer(mfLayer)
layers.add(layer)
if (areLayersAttached) layer.onAttached()
}

override fun zoomOut() {
model.mapViewPosition.zoomOut()
}
Expand Down Expand Up @@ -174,7 +174,8 @@ open class MapsForgeViewBase(
/* FIXME: this is a workaround to a bug:
* Sometimes the LayerManager thread is still running after calling destroyAll().
* This happens when MapView was never attached to window.
* Same problem with the Animator thread of MapViewPosition. */layerManager.finish()
* Same problem with the Animator thread of MapViewPosition. */
layerManager.finish()
getMapViewPosition().destroy()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MapsForgeViewStatic(context: Context, appContext: AppContext) : MapsForgeV
) {
init {
val tiles: MapsForgeTileLayerStackConfigured = BackgroundOnly(this, appContext)
add(tiles, tiles)
add(tiles)
isClickable = false
}
}
Loading

0 comments on commit 122fa65

Please sign in to comment.