6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | # see https://gradle.org/release-checksums/
7 | distributionSha256Sum=23e7d37e9bb4f8dabb8a3ea7fdee9dd0428b9b1a71d298aefd65b11dccea220f
8 |
--------------------------------------------------------------------------------
/geoIntentDemo/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/wiki/examples/hannover.geo-uri:
--------------------------------------------------------------------------------
1 | Hannover
2 | With a population of 518,000, Hanover is a major centre of Northern Germany and the country's thirteenth largest city. Hanover also hosts annual commercial trade fairs such as the Hanover Fair and the CeBIT.
3 |
4 |
5 | geo:52.366667,9.716667
6 |
7 | http://en.wikipedia.org/wiki/Hannover
8 |
9 | https://en.wikipedia.org/wiki/GPS_eXchange_Format
10 | http://www.topografix.com/gpx.asp
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/drawable-mdpi/btn_moreinfo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/androidTest/java/de/k3b/android/locationMapViewer/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package de.k3b.android.locationMapViewer;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/LocationMapViewer/src/test/java/de/k3b/util/ImageResizeTest.java:
--------------------------------------------------------------------------------
1 | package de.k3b.util;
2 |
3 | import org.junit.Assert;
4 | import org.junit.Test;
5 |
6 | public class ImageResizeTest {
7 |
8 | @Test
9 | public void getResizeFactor() {
10 | Assert.assertNull("to small", ImageResize.getResizeFactor(40,30,48));
11 | Assert.assertEquals("96 x 48", 0.5, ImageResize.getResizeFactor(96,48,48), 0.00001);
12 | Assert.assertEquals("48 x 96",0.5, ImageResize.getResizeFactor(48,96,48), 0.00001);
13 | }
14 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # built application files
2 | *.apk
3 | *.ap_
4 |
5 | # files for the dex VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # generated files
12 | bin/
13 | gen/
14 | gen-external-apklibs/
15 | target/
16 |
17 | # Local configuration file (sdk path, etc)
18 | local.properties
19 |
20 | # Eclipse project files
21 | .classpath
22 | .project
23 | .settings
24 |
25 | # Proguard folder generated by Eclipse
26 | proguard/
27 |
28 | # Intellij project files
29 | *.iml
30 | *.ipr
31 | *.iws
32 | .idea/
33 |
34 | # Gradle
35 | build/
36 | .gradle
37 |
38 | # vim swap files
39 | *.swp
40 | *.swo
41 | /gradle-app.setting
42 |
43 | /osmdroid-third-party/libs/maps.jar
44 | /osmdroid-android
45 | /download
46 | /.deleted
47 |
--------------------------------------------------------------------------------
/wiki/History.md:
--------------------------------------------------------------------------------
1 | # History
2 |
3 | ## Not released yet
4 |
5 | * added support for [geo-bookmarks](bookmarks)
6 | * added serbian translations (thanks to Mladen Pejakovic)
7 |
8 | * Bugfix #2 LMV is associated with all file types
9 | * New Feature #3 : Bookmark overlay to remember named geo-locations with zoom for quick navigation
10 | * Clicking on a marker in the [[map]] shows bubble with [Name](api#name), [Description](api#description) and [Link](api#)
11 | * Serbian and german translations
12 |
13 | ## [Version0.2.2.150321](https://github.com/k3b/LocationMapViewer/releases/tag/Version0.2.2.150321)
14 |
15 | * geo-uri support as viewer or picker
16 | * file support gpx und kml
17 | * Settings menu
18 | * Aboutbox
19 | * Released on FDroid
--------------------------------------------------------------------------------
/geoIntentDemo/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:/Program Files (x86)/sdk/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/geoIntentDemo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 29
5 |
6 | defaultConfig {
7 | applicationId "de.k3b.android.locationMapViewer.demo"
8 | minSdkVersion 14
9 | targetSdkVersion 26
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | compileOptions {
14 | sourceCompatibility JavaVersion.VERSION_1_7
15 | targetCompatibility JavaVersion.VERSION_1_7
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(dir: 'libs', include: ['*.jar'])
27 | }
28 |
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/full_description.txt:
--------------------------------------------------------------------------------
1 | The app has support for GPX and KML files, as
2 | well as the "geo URI scheme" and popular map
3 | services (google-maps, openstreetmap, yandex, ...).
4 |
5 | It can work offline (without Internet/WiFi) once
6 | geodata has been downloaded and cached.
7 |
8 | Other Android apps can use LocationMapViewer through an
9 | Intent-interface.
10 |
11 | Required Android Permissions:
12 |
13 | * INTERNET: to download map data from Open Streetmap Server
14 | * ACCESS_NETWORK_STATE and ACCESS_WIFI_STATE: to find out if wifi/internet is online to start downloaded geodata
15 | * WRITE_EXTERNAL_STORAGE (to cache downloaded map data in local file system and to load gpx/kml-Files to be displayed in the map)
16 | * ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION: to display my own location in the map
17 |
--------------------------------------------------------------------------------
/geoIntentDemo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/geoIntentDemo/src/main/resources/eu/lp0/slf4j/android/config.properties:
--------------------------------------------------------------------------------
1 | # /eu/lp0/slf4j/android/config.properties
2 | # contains logging configuration for https://github.com/lp0/slf4j-android
3 |
4 | # tag for the specified logger prefix:
5 | # tag.logger-prefix=TagName
6 | # With no tag configured, logger names are automatically compacted to fit the Android 23 character tag limit.
7 | tag.eu.lp0.slf4j.android=slf4j-android
8 | tag.org.slf4j=slf4j-api
9 |
10 | #tag.add2GoZip=k3b-android
11 | #tag.de.k3b.zip=k3b-ziblib
12 |
13 | # Set the log level for the specified logger prefix:
14 | # level.logger-prefix=SUPPRESS|ERROR|WARN|INFO|DEBUG|VERBOSE|NATIVE (default=native)
15 | level=verbose
16 |
17 | # Show the logger name in short, compact, long format, or show caller stack frame:
18 | # showName.logger-prefix=false|short|compact|long|caller
19 |
20 | # Show the current thread:
21 | # showThread.*=true|false (default=false)
22 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/resources/eu/lp0/slf4j/android/config.properties:
--------------------------------------------------------------------------------
1 | # /eu/lp0/slf4j/android/config.properties
2 | # contains logging configuration for https://github.com/lp0/slf4j-android
3 |
4 | # tag for the specified logger prefix:
5 | # tag.logger-prefix=TagName
6 | # With no tag configured, logger names are automatically compacted to fit the Android 23 character tag limit.
7 | tag.eu.lp0.slf4j.android=slf4j-android
8 | tag.org.slf4j=slf4j-api
9 |
10 | #tag.add2GoZip=k3b-android
11 | #tag.de.k3b.zip=k3b-ziblib
12 |
13 | # Set the log level for the specified logger prefix:
14 | # level.logger-prefix=SUPPRESS|ERROR|WARN|INFO|DEBUG|VERBOSE|NATIVE (default=native)
15 | level=verbose
16 |
17 | # Show the logger name in short, compact, long format, or show caller stack frame:
18 | # showName.logger-prefix=false|short|compact|long|caller
19 |
20 | # Show the current thread:
21 | # showThread.*=true|false (default=false)
22 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | /**
21 | * This Package defines non-portable, "Android only" code for LocationMapViewer.
22 | **/
23 | package de.k3b.android;
24 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # travis build for LocationMapViewer
2 | language: android
3 |
4 | jdk:
5 | - oraclejdk8
6 |
7 | addons:
8 | apt:
9 | packages:
10 | # graphviz to render javadoc uml
11 | # https://docs.travis-ci.com/user/multi-os/
12 | - graphviz
13 |
14 | android:
15 | components:
16 | # https://github.com/travis-ci/travis-ci/issues/5036
17 | - tools
18 |
19 | - android-23
20 |
21 | - add-on
22 | - extra
23 |
24 | before_install:
25 | # http://stackoverflow.com/questions/33820638/travis-yml-gradlew-permission-denied
26 | # must execute
27 | # git update-index --chmod=+x gradlew
28 | # instead of
29 | # - chmod +x gradlew
30 |
31 | # https://stackoverflow.com/questions/52274229/travis-ci-android-28-licenses-have-not-been-accepted
32 | # - yes | sdkmanager "platforms;android-28"
33 |
34 | - yes | sdkmanager "platforms;android-23"
35 | - yes | sdkmanager "platforms;android-28"
36 | - yes | sdkmanager "platforms;android-29"
37 |
38 | script:
39 | - jdk_switcher use oraclejdk8
40 | - ./gradlew assemble
41 |
--------------------------------------------------------------------------------
/LocationMapViewer/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:/Program Files (x86)/sdk/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | ###############
20 | # I use proguard only to remove unused stuff and to keep the app small.
21 | # I donot want to obfuscate (rename packages, classes, methods, ...) since this is open source
22 | -dontobfuscate
23 | -dontoptimize
24 | -keepnames class ** { *; }
25 | -keepnames interface ** { *; }
26 | -keepnames enum ** { *; }
27 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
22 | @android:color/black
23 | #FFCCCCCC
24 | #80CCCCCC
25 |
26 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/drawable/custom_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/widgets/IViewHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | package de.k3b.android.widgets;
21 |
22 | import android.view.View;
23 |
24 | /**
25 | * Allows to use findViewById() on {@link android.app.Dialog}, {@link android.app.Activity} and
26 | * {@link android.app.Fragment} with common code
27 | * Created by k3b on 26.03.2015.
28 | */
29 | public interface IViewHolder {
30 | T findViewById(int id);
31 | }
32 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/menu/location_map_viewer_21.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
28 |
--------------------------------------------------------------------------------
/wiki/bookmarks.md:
--------------------------------------------------------------------------------
1 | #LocationMapViewer bookmarks
2 |
3 | LocationMapViewer can store the current latitude/longitude/zoomlevel as named **bookmark**.
4 |
5 | Similar to a web browser you can return to any bookmarked latitude/longitude/zoomlevel
6 | by selecting it-s name.
7 |
8 | From the [map view](map) you reach the bookmarks by pressing the
9 |  symbol or
10 | through the menu "bookmarks" .
11 |
12 |
13 | 
14 |
15 |
16 |
17 |
18 | 
19 | 
20 | 
21 | 
22 | 
23 | 
24 | 
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
21 |
22 |
23 | 16dp
24 | 16dp
25 | 32px
26 | 32px
27 | 4px
28 |
29 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
21 |
22 |
25 | 64dp
26 |
27 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/util/ImageResize.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | package de.k3b.util;
21 |
22 | public class ImageResize {
23 | public static Double getResizeFactor(double width, double height, double targetSize) {
24 | if (width > 0 && height > 0 && (width > targetSize || height > targetSize)) {
25 | double scale = (width < height) ? width / height : height / width;
26 | return scale;
27 | }
28 |
29 | return null;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/layout/about_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
26 |
27 |
31 |
32 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/values/html.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
22 |
32 |
33 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/locationMapViewer/geobmp/GeoBmpDtoAndroid.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | package de.k3b.android.locationMapViewer.geobmp;
21 |
22 | import android.graphics.Bitmap;
23 |
24 | import java.io.Serializable;
25 |
26 | import de.k3b.geo.api.GeoPointDto;
27 | import de.k3b.geo.geobmp.GeoBmpDto;
28 |
29 | /**
30 | * a GeoPoint with a bitmap.
31 | *
32 | * Created by k3b on 24.03.2015.
33 | */
34 | public class GeoBmpDtoAndroid extends GeoBmpDto implements Serializable {
35 | public GeoBmpDtoAndroid() {};
36 | public GeoBmpDtoAndroid(GeoPointDto geoPointFromIntent) {
37 | super(geoPointFromIntent);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/menu/location_map_viewer.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
33 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/GuiUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 k3b
3 | *
4 | * This file is part of de.k3b.android.toGoZip (https://github.com/k3b/ToGoZip/) .
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 | package de.k3b.android;
20 |
21 | import android.content.Context;
22 | import android.content.pm.PackageManager.NameNotFoundException;
23 |
24 | /**
25 | * gui utils
26 | */
27 | public class GuiUtil {
28 | public static String getAppVersionName(final Context context) {
29 | try {
30 |
31 | final String versionName = context.getPackageManager()
32 | .getPackageInfo(context.getPackageName(), 0).versionName;
33 | return versionName;
34 | } catch (final NameNotFoundException e) {
35 | }
36 | return null;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/locationMapViewer/constants/Constants.java:
--------------------------------------------------------------------------------
1 | package de.k3b.android.locationMapViewer.constants;
2 |
3 | import android.os.Build;
4 |
5 | /**
6 | * This class contains constants used by the application.
7 | */
8 | public interface Constants {
9 | /** false: old android-2.3 or below that does not support actionbars */
10 | public static final boolean USE_ACTIONBAR = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB);
11 |
12 | // ===========================================================
13 | // keys for preferences
14 | // ===========================================================
15 |
16 | public static final String PREFS_TILE_SOURCE = "tilesource";
17 | public static final String PREFS_SHOW_LOCATION = "showLocation";
18 | public static final String PREFS_SHOW_MINIMAP = "showMiniMap";
19 | public static final String PREFS_CLUSTER_POINTS = "clusterPoints";
20 |
21 | public static final String PREFS_CURRENT_ZOOMLEVEL = "currentZoom";
22 | public static final String PREFS_CURRENT_NORTH = "currentNorth";
23 | public static final String PREFS_CURRENT_EAST = "currentEast";
24 |
25 | // public static final String PREFS_SHOW_GUESTURES = "guesturesEnable";
26 | public static final String PREFS_DEBUG_GUESTURES = "guesturesDebug";
27 |
28 | // ===========================================================
29 | // Methods
30 | // ===========================================================
31 | }
32 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
22 |
27 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
22 |
27 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/fastlane/lib/rename_screenshots.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | # Author: Torsten Grote
4 | # License: GPLv3 or later
5 | # source: 2020-04-16 https://github.com/grote/Transportr/blob/master/fastlane/rename_screenshots.py
6 |
7 | import glob
8 | import os
9 | import re
10 |
11 | METADATA_PATH = 'metadata/android'
12 | GLOB = '/*/images/phoneScreenshots/*.png'
13 |
14 | REGEX = re.compile(r'(^\d_\w+)_\d{13}\.png$')
15 | REGEX_IN_FILE = re.compile(r'(\d_\w+)_\d{13}\.png', re.MULTILINE)
16 | PATH = os.path.dirname(os.path.realpath(__file__))
17 |
18 |
19 | def main():
20 | for path in glob.glob("%s%s" % (os.path.join(PATH, METADATA_PATH), GLOB)):
21 | filename = os.path.basename(path)
22 | match = REGEX.match(filename)
23 | if match:
24 | directory = os.path.dirname(path)
25 | new_filename = "%s.png" % match.group(1)
26 | new_path = os.path.join(directory, new_filename)
27 | os.rename(path, new_path)
28 | print("Renaming\n %s\nto\n %s\n" % (path, new_path))
29 | else:
30 | print("Warning: Path did not match %s" % path)
31 |
32 | # rename fields also in screenshot overview file
33 | overview = os.path.join(PATH, METADATA_PATH, 'screenshots.html')
34 | with open(overview, 'r') as f:
35 | file_data = f.read()
36 |
37 | file_data = REGEX_IN_FILE.sub(r'\1.png', file_data)
38 |
39 | with open(overview, 'w') as f:
40 | f.write(file_data)
41 |
42 |
43 | if __name__ == "__main__":
44 | main()
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/widgets/Clipboard.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 k3b
3 | *
4 | * This file is part of de.k3b.android.toGoZip (https://github.com/k3b/ToGoZip/) .
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 | package de.k3b.android.widgets;
20 |
21 | import android.content.Context;
22 |
23 | /**
24 | * Helper to set text to android clipboard.
25 | *
26 | * Created by k3b on 17.11.2014.
27 | */
28 | public class Clipboard {
29 | public static void addToClipboard(Context context, CharSequence text) {
30 | // for compatibility reaons using depricated clipboard api. the non depricateded clipboard was not available before api 11.
31 | try {
32 | android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
33 | clipboard.setText(text);
34 | } catch (Exception e) {
35 | e.printStackTrace();
36 | }
37 | }
38 |
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/fastlane/lib/generate_changelog.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | # Author: Torsten Grote
4 | # License: GPLv3 or later
5 | # source: 2020-04-16 https://github.com/grote/Transportr/blob/master/fastlane/generate_changelog.py
6 |
7 | import os
8 | from xml.etree import ElementTree
9 |
10 |
11 | PATH = os.path.dirname(os.path.realpath(__file__))
12 | XML_PATH = os.path.join(PATH, '../app/src/main/res/xml')
13 | CHANGELOG_PATH = os.path.join(PATH, 'metadata/android/en-US/changelogs')
14 | START_VERSION_CODE = 100
15 | LIMIT = 500
16 |
17 |
18 | def main():
19 | changelog_file = os.path.join(XML_PATH, 'changelog_master.xml')
20 | if not os.path.isfile(changelog_file):
21 | print("Error: %s does not exist" % changelog_file)
22 | return
23 |
24 | print("Parsing %s..." % changelog_file)
25 | root = ElementTree.parse(changelog_file).getroot()
26 | for release in root:
27 | if release.tag == "release":
28 | store_release(release)
29 |
30 |
31 | def store_release(release):
32 | version_code = release.attrib['versioncode']
33 | if int(version_code) < START_VERSION_CODE:
34 | return
35 | version_file = os.path.join(CHANGELOG_PATH, version_code + '.txt')
36 | print("Writing to %s ..." % version_file)
37 | count = 0
38 | with open(version_file, 'w') as f:
39 | for change in release:
40 | text = '* ' + change.text + '\n'
41 | count = count + len(text)
42 | if count > LIMIT:
43 | print("Warning: Maximum length exceeded. Truncating...")
44 | text = text[:(LIMIT - count)]
45 | f.write(text)
46 |
47 |
48 | if __name__ == "__main__":
49 | main()
--------------------------------------------------------------------------------
/wiki/map.md:
--------------------------------------------------------------------------------
1 | #LocationMapViewer map view
2 |
3 | map
4 | poi
5 | green
6 | red
7 | yellow
8 | bubble
9 | symbol
10 | tilte
11 | text
12 | link
13 | menu
14 | favorites
15 | picker
16 | minimap
17 | zoom buttons [+] [-]
18 | zoom bar
19 |
20 | An app that can display geografic info in a map. It has support for **gpx** and **kml** files and [**geo-uri-s**](geo_intent_api)
21 | and can work offline (without internet/wifi)
22 | once geodata is downloaded and cached.
23 |
24 | Minimal requirements: Android 2.1 (Eclair, API 7), internet/wifi-connection to download geodata and a SD-Card to cache geodata
25 |
26 | Licence: [GPLv3](http://www.gnu.org/licenses/gpl-3.0)
27 |
28 | Requred permissions:
29 |
30 | * INTERNET: to download map data from Open Streetmap Server
31 | * ACCESS_NETWORK_STATE and ACCESS_WIFI_STATE: to find out if wifi/internet is online to start downloaded geodata
32 | * WRITE_EXTERNAL_STORAGE
33 | * to cache downloaded map data in local file system
34 | * to load gpx/kml-Files to be displayed in the map
35 | * ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION: to display my own location in the map, too
36 |
37 | The code uses [osmdroid library](https://github.com/osmdroid/osmdroid)
38 | with [osmbonuspack library](http://code.google.com/p/osmbonuspack/)
39 | to display maps from [Open Street Map](http://www.openstreetmap.org).
40 |
41 | LocationMapViewer is designed to be used by other apps. This means in Terms of [GPLv3](http://www.gnu.org/licenses/gpl-3.0) that your app
42 | that uses the Intent-Iterface [is not considered a Derived Work.](https://en.wikipedia.org/wiki/GPL_v3#Point_of_view:_linking_is_irrelevant)
43 |
44 | In other words: you can used LocationMapViewer as a [driver for your non gpl/non opensource app.](http://www.rosenlaw.com/lj19.htm).
45 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/test/resources/simplelogger.properties:
--------------------------------------------------------------------------------
1 | # SLF4J's SimpleLogger configuration file
2 | # Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err.
3 |
4 | # Default logging detail level for all instances of SimpleLogger.
5 | # Must be one of ("trace", "debug", "info", "warn", or "error").
6 | # If not specified, defaults to "info".
7 | #org.slf4j.simpleLogger.defaultLog=info
8 | org.slf4j.simpleLogger.defaultLogLevel=trace
9 |
10 | # Logging detail level for a SimpleLogger instance named "xxxxx".
11 | # Must be one of ("trace", "debug", "info", "warn", or "error").
12 | # If not specified, the default logging detail level is used.
13 | #org.slf4j.simpleLogger.log.xxxxx=
14 |
15 | # Set to true if you want the current date and timeOfMeasurement to be included in output messages.
16 | # Default is false, and will output the number of milliseconds elapsed since startup.
17 | #org.slf4j.simpleLogger.showDateTime=false
18 |
19 | # The date and timeOfMeasurement toUriString to be used in the output messages.
20 | # The pattern describing the date and timeOfMeasurement toUriString is the same that is used in java.text.SimpleDateFormat.
21 | # If the toUriString is not specified or is invalid, the default toUriString is used.
22 | # The default toUriString is yyyy-MM-dd HH:mm:ss:SSS Z.
23 | #org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z
24 |
25 | # Set to true if you want to output the current thread name.
26 | # Defaults to true.
27 | #org.slf4j.simpleLogger.showThreadName=true
28 |
29 | # Set to true if you want the Logger instance name to be included in output messages.
30 | # Defaults to true.
31 | #org.slf4j.simpleLogger.showLogName=true
32 |
33 | # Set to true if you want the last component of the name to be included in output messages.
34 | # Defaults to false.
35 | #org.slf4j.simpleLogger.showShortLogName=false
36 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/util/HtmlUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | package de.k3b.android.util;
21 |
22 | import android.os.Build;
23 | import android.text.Html;
24 |
25 | import java.util.regex.Pattern;
26 |
27 |
28 | public class HtmlUtils {
29 | // include multiline
30 | private static Pattern isHtml = Pattern.compile("<[a-zA-Z]+");
31 |
32 | // Pattern.DOTALL == mulitline matching; ".*?" anything non-greedy
33 | private static Pattern htmlComment = Pattern.compile("", Pattern.DOTALL);
34 | private static Pattern htmlImage = Pattern.compile("", Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
35 |
36 | public static CharSequence interpreteHtml(String html) {
37 | if (html != null && isHtml.matcher(html).find()) {
38 | String htmlSanitzied = htmlComment.matcher(html).replaceAll("");
39 | htmlSanitzied = htmlImage.matcher(htmlSanitzied).replaceAll("");
40 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
41 | return Html.fromHtml(htmlSanitzied, Html.FROM_HTML_MODE_COMPACT);
42 | } else {
43 | return Html.fromHtml(htmlSanitzied);
44 | }
45 | }
46 | return html;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/layout/geobmp_list_view_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
28 |
32 |
37 |
44 |
45 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/layout/bonuspack_bubble.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
16 |
20 |
28 |
35 |
36 |
43 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/layout/bonuspack_bubble_black.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
16 |
20 |
28 |
35 |
36 |
43 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/geo/geobmp/GeoBmpDto.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | package de.k3b.geo.geobmp;
21 |
22 | import java.io.Serializable;
23 |
24 | import de.k3b.geo.api.GeoPointDto;
25 | import de.k3b.geo.api.IGeoPointInfo;
26 | import de.k3b.geo.io.GeoFormatter;
27 |
28 | /**
29 | * a GeoPoint with a bitmap.
30 | *
31 | * Created by k3b on 24.03.2015.
32 | * @param either android.graphics.Bitmap or j2se Bitmap
33 | */
34 | public class GeoBmpDto extends GeoPointDto implements Serializable {
35 | public static final int WIDTH = 32;
36 | public static final int HEIGHT = 32;
37 | /** a bitmap representing the GeoPoint */
38 | private BITMAP bitmap = null;
39 |
40 | public GeoBmpDto() {}
41 |
42 | public GeoBmpDto(IGeoPointInfo src) {
43 | super(src);
44 | }
45 | /** a bitmap representing the GeoPoint */
46 | public BITMAP getBitmap() {
47 | return bitmap;
48 | }
49 |
50 | public GeoBmpDto setBitmap(BITMAP bitmap) {
51 | this.bitmap = bitmap;
52 | return this;
53 | }
54 |
55 | /** formatting helper: */
56 | public String getSummary() {
57 | return " (" +
58 | GeoFormatter.formatLatLon(this.getLatitude()) + "/" +
59 | GeoFormatter.formatLatLon(this.getLongitude())+ ") z=" + GeoFormatter.formatZoom(this.getZoomMin());
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/io/GeoConfig2.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 by k3b.
3 | *
4 | * This file is part of k3b-geoHelper library.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | /* TODO: remove this copy as it is already part of Geohelper */
20 | package de.k3b.io;
21 |
22 | public class GeoConfig2 {
23 | public static final int THUMBSIZE = 200;
24 |
25 | /* File extensions (lowercase) */
26 | public static final String EXT_ZIP = ".zip";
27 |
28 | public static final String EXT_KML = ".kml";
29 | public static final String EXT_KMZ = ".kmz";
30 | public static final String EXT_KMZ2 = EXT_KML+EXT_ZIP;
31 | public static final String[] EXT_ALL_KML = new String[]{EXT_KMZ, EXT_KMZ2, EXT_KML};
32 |
33 | public static final String EXT_GPX = ".gpx";
34 | public static final String EXT_GPZ = ".gpz";
35 | public static final String EXT_GPZ2 = EXT_GPX+EXT_ZIP;
36 | public static final String[] EXT_ALL_GPX = new String[]{EXT_GPZ, EXT_GPZ2, EXT_GPX};
37 |
38 | public static final String EXT_POI = ".poi";
39 | public static final String EXT_POZ = ".poz";
40 | public static final String EXT_POZ2 = EXT_POI+EXT_ZIP;
41 | public static final String[] EXT_ALL_POI = new String[]{EXT_POZ, EXT_POZ2, EXT_POI};
42 |
43 | public static final String[] EXT_ALL_ZIP = new String[]{EXT_GPZ,EXT_KMZ,EXT_POZ,EXT_ZIP};
44 | public static final String[] EXT_ALL = new String[]{
45 | EXT_GPZ,EXT_KMZ,EXT_POZ,
46 | EXT_GPZ2,EXT_KMZ2,EXT_POZ2,
47 | EXT_GPX,EXT_KML,EXT_POI};
48 |
49 | public static boolean isOneOf(String outFileName, String... suffixes) {
50 | String lowerCase = outFileName.toLowerCase();
51 | for (String ext : suffixes) {
52 | if (lowerCase.endsWith(ext)) return true;
53 | }
54 | return false;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/locationMapViewer/SettingsActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 k3b
3 | *
4 | * This file is part of de.k3b.android.LocationMapViewer (https://github.com/k3b/LocationMapViewer/) .
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 | package de.k3b.android.locationMapViewer;
20 |
21 | import android.app.Activity;
22 | import android.content.Intent;
23 | import android.os.Bundle;
24 | import android.preference.PreferenceActivity;
25 |
26 | import org.slf4j.Logger;
27 | import org.slf4j.LoggerFactory;
28 |
29 | import de.k3b.android.locationMapViewer.constants.Constants;
30 |
31 | /**
32 | * A {@link PreferenceActivity} that presents a set of application settings.
33 | *
34 | * See
35 | * Android Design: Settings for design guidelines and the Settings
37 | * API Guide for more information on developing a Settings UI.
38 | */
39 | public class SettingsActivity extends PreferenceActivity implements Constants {
40 | private static final Logger logger = LoggerFactory.getLogger(SettingsActivity.class);
41 | /**
42 | * public api to start settings-activity
43 | */
44 | public static void show(Activity context, int resultID) {
45 | final Intent i = new Intent(context, SettingsActivity.class);
46 | if (logger.isDebugEnabled()) logger.debug("show(resultID"+resultID+")");
47 |
48 | context.startActivityForResult(i, resultID);
49 | }
50 |
51 | @Override
52 | protected void onCreate(final Bundle savedInstanceState) {
53 | super.onCreate(savedInstanceState);
54 | this.addPreferencesFromResource(R.xml.preferences);
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/layout/geobmp_edit_name.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
25 |
29 |
30 |
36 |
37 |
44 |
51 |
52 |
53 |
60 |
69 |
70 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
22 |
26 |
33 |
34 |
35 |
38 |
39 |
45 |
46 |
48 |
49 |
51 |
52 |
55 |
56 |
60 |
61 |
63 |
65 |
67 |
68 | #888888
69 | #eeeeee
70 |
71 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/geo/geobmp/BookmarkUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | package de.k3b.geo.geobmp;
21 |
22 | import de.k3b.geo.api.IGeoPointInfo;
23 |
24 | /**
25 | * utils to handle bookmark items.
26 | *
27 | * Created by k3b on 27.03.2015.
28 | */
29 | public class BookmarkUtil {
30 | private static int id =1;
31 |
32 | /** clones item (i.e. currentPositon) and mark it as new */
33 | public static DTO createBookmark(DTO template) {
34 | DTO result = (DTO) template.clone();
35 | result
36 | .setBitmap(template.getBitmap())
37 | .setName("") // to be set in rename dialog
38 | .setDescription(null) // not a template
39 | .setId(null); // new item, not inserted yet
40 | return result;
41 | }
42 |
43 | public static boolean isBookmark(DTO item) {
44 | return ((item != null) && (item.getDescription() == null));
45 | }
46 |
47 | public static boolean isNew(DTO item) {
48 | return ((item != null) && (item.getId() == null));
49 | }
50 |
51 | public static boolean isValid(final IGeoPointInfo geoPointInfo) {
52 | return (geoPointInfo != null) && (geoPointInfo instanceof GeoBmpDto) && (isNotEmpty(geoPointInfo.getName()));
53 | }
54 |
55 | /**
56 | * sets data for NewItemPlaceholder
57 | */
58 | public static DTO markAsTemplate(final DTO template) {
59 | if (template != null) {
60 | final String newId = "#" + (id++);
61 | if (!isNotEmpty(template.getName())) {
62 | template.setName(newId);
63 | }
64 | if (!isNotEmpty(template.getId())) {
65 | template.setId(newId);
66 | }
67 | template.setDescription(template.getName());
68 | }
69 | return template;
70 | }
71 |
72 | public static boolean isNotEmpty(String name) {
73 | return (name != null) && (name.length() > 0);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/wiki/home.md:
--------------------------------------------------------------------------------
1 | #LocationMapViewer 
2 |
3 | An android app that can display geografic info in a [map](map).
4 |
5 | 
6 |
7 | ## Features:
8 |
9 | * Support for displaying [gpx](data#gpx), [kml](data#kml) or [poi](data#poi) files
10 | * Example: open a gpx or kml file in an android filemanager
11 | * Example: open a link to a gpx or kml file in an android webbrowser
12 | * Support for [geo-uri-s](data#geo)
13 | * Example: open a link to a geo uri in an android webbrowser.
14 | * <a href='geo:0,0?q=53.0,8.0(Hello)'>geo:0,0?q=53.0,8.0(Hello) </a>
15 | * Support for [geo-bookmarks](bookmarks)
16 | * to remember and quickly navigate to named latitude/longitude/zoomlevel
17 | * Can work offline (without internet/wifi) once geodata is downloaded and cached.
18 | * Other android apps can use LocationMapViewer through an [intent api](api#intent) ...
19 | * ... to show a map at certain [latitude longitude zoomlevel](data#region) with [points of interest](data#marker)
20 | * ... to pick a location from a map (i.e. "Where was this photo taken?")
21 |
22 | ### Table of content
23 |
24 | * The [map's user ingerface](map)
25 | * [geo-bookmarks](bookmarks) to remember and quickly navigate to named latitude/longitude/zoomlevel
26 | * Customizing LocationMapViewer: [settings](settings)
27 | * Supported [dataformats](data)
28 | * How other apps can use LocationMapViewer through the [intent api](api#intent)
29 |
30 | ### Minimal requirements:
31 |
32 | * Android 2.1 (Eclair, API 7),
33 | * internet/wifi-connection to download geodata and a SD-Card to cache geodata
34 | * Licence: [GPLv3](http://www.gnu.org/licenses/gpl-3.0)
35 |
36 | ### Requred permissions:
37 |
38 | * INTERNET: to download map data from Open Streetmap Server
39 | * ACCESS_NETWORK_STATE and ACCESS_WIFI_STATE: to find out if wifi/internet is online to start downloading mapdata
40 | * WRITE_EXTERNAL_STORAGE
41 | * to cache downloaded map data in local file system
42 | * to load gpx/kml-Files to be displayed in the map
43 | * ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION: to display my own location in the map
44 |
45 | The code uses [osmdroid library](https://github.com/osmdroid/osmdroid)
46 | with [osmbonuspack library](http://code.google.com/p/osmbonuspack/)
47 | to display maps from [Open Street Map](http://www.openstreetmap.org).
48 |
49 | LocationMapViewer is designed to be used by other apps. This means in Terms of [GPLv3](http://www.gnu.org/licenses/gpl-3.0) that your app
50 | that uses the Intent-Iterface [is not considered a Derived Work.](https://en.wikipedia.org/wiki/GPL_v3#Point_of_view:_linking_is_irrelevant)
51 |
52 | In other words: you can used LocationMapViewer as a [driver for your non gpl/non opensource app.](http://www.rosenlaw.com/lj19.htm).
53 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/locationMapViewer/RadiusMarkerClustererWithInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | package de.k3b.android.locationMapViewer;
21 |
22 | import android.content.Context;
23 | import android.graphics.Bitmap;
24 | import android.graphics.Canvas;
25 | import android.graphics.drawable.BitmapDrawable;
26 |
27 | import org.osmdroid.bonuspack.clustering.RadiusMarkerClusterer;
28 | import org.osmdroid.bonuspack.clustering.StaticCluster;
29 | import org.osmdroid.views.MapView;
30 | import org.osmdroid.views.overlay.Marker;
31 | import org.osmdroid.views.overlay.infowindow.InfoWindow;
32 |
33 | /**
34 | * Created by k3b on 29.01.2015.
35 | */
36 | public class RadiusMarkerClustererWithInfo extends RadiusMarkerClusterer {
37 | public RadiusMarkerClustererWithInfo(Context ctx) {
38 | super(ctx);
39 | }
40 |
41 | @Override public Marker buildClusterMarker(StaticCluster cluster, MapView mapView) {
42 | Marker m = new Marker(mapView);
43 | m.setPosition(cluster.getPosition());
44 |
45 | final InfoWindow infoWindow = (cluster.getSize() > 0) ? cluster.getItem(0).getInfoWindow() : null;
46 | m.setInfoWindow(infoWindow);
47 | m.setAnchor(mAnchorU, mAnchorV);
48 |
49 | final BitmapDrawable icon = getClusterMarkerIcon("" + cluster.getSize(), mapView);
50 | m.setIcon(icon);
51 |
52 | setRadius(48);
53 |
54 | return m;
55 | }
56 |
57 | /** calculates the icon for the clusterMarker (with text = number of items) */
58 | protected BitmapDrawable getClusterMarkerIcon(String text, MapView mapView) {
59 |
60 | // this works for android 4.4 but not thows an exception in android 2.1
61 | // Bitmap finalIcon = Bitmap.createBitmap(mClusterIcon.getWidth(), mClusterIcon.getHeight(), mClusterIcon.getConfig());
62 | // this works with android2.1
63 | Bitmap finalIcon = Bitmap.createBitmap(mClusterIcon.getWidth(), mClusterIcon.getHeight(), Bitmap.Config.ARGB_8888);
64 |
65 | Canvas iconCanvas = new Canvas(finalIcon);
66 | iconCanvas.drawBitmap(mClusterIcon, 0, 0, null);
67 | int textHeight = (int) (mTextPaint.descent() + mTextPaint.ascent());
68 | iconCanvas.drawText(text,
69 | mTextAnchorU * finalIcon.getWidth(),
70 | mTextAnchorV * finalIcon.getHeight() - textHeight / 2,
71 | mTextPaint);
72 | return new BitmapDrawable(mapView.getContext().getResources(), finalIcon);
73 | }
74 | }
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/locationMapViewer/geobmp/GeoBmpEditDialog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | package de.k3b.android.locationMapViewer.geobmp;
21 |
22 | import android.app.Dialog;
23 | import android.content.Context;
24 | import android.view.View;
25 | import android.widget.Button;
26 |
27 | import de.k3b.android.locationMapViewer.R;
28 | import de.k3b.android.widgets.IViewHolder;
29 | import de.k3b.geo.api.IGeoInfoHandler;
30 | import de.k3b.geo.api.IGeoPointInfo;
31 |
32 | /**
33 | * Edit a {@link de.k3b.geo.api.GeoPointDto} item
34 | *
35 | * Created by k3b on 23.03.2015.
36 | */
37 | public class GeoBmpEditDialog extends Dialog implements IGeoInfoHandler, IViewHolder {
38 | private final IGeoInfoHandler dialogResultConsumer;
39 |
40 | private final Button buttonSave;
41 | private final Button buttonCancel;
42 |
43 | private GeoBmpDtoAndroid currentItem = null;
44 |
45 | public GeoBmpEditDialog(Context context, IGeoInfoHandler dialogResultConsumer, int layoutID) {
46 | super(context);
47 | this.dialogResultConsumer = dialogResultConsumer;
48 | this.setContentView(layoutID); // R.layout.geobmp_edit);
49 |
50 | this.buttonSave = this.findViewById(R.id.cmd_save);
51 | this.buttonCancel = this.findViewById(R.id.cmd_cancel);
52 |
53 | this.buttonSave.setOnClickListener(new View.OnClickListener() {
54 | @Override
55 | public void onClick(final View v) {
56 | saveChangesAndExit(GeoBmpEditDialog.this.dialogResultConsumer);
57 | }
58 |
59 | });
60 | this.buttonCancel.setOnClickListener(new View.OnClickListener() {
61 | @Override
62 | public void onClick(final View v) {
63 | cancel();
64 | }
65 | });
66 | }
67 |
68 | @Override
69 | public boolean onGeoInfo(IGeoPointInfo geoInfo) {
70 | this.currentItem = (GeoBmpDtoAndroid) geoInfo;
71 |
72 | load(this.currentItem);
73 | return true;
74 | }
75 |
76 | void load(GeoBmpDtoAndroid currentItem) {
77 | GeoBmpBinder.toGui(this, currentItem);
78 | }
79 |
80 | private void save(GeoBmpDtoAndroid currentItem) {
81 | GeoBmpBinder.fromGui(this, currentItem);
82 | }
83 |
84 | private void saveChangesAndExit(final IGeoInfoHandler owner) {
85 | save(this.currentItem);
86 | if (owner != null) {
87 | owner.onGeoInfo(this.currentItem);
88 | }
89 | this.dismiss();
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/locationMapViewer/geobmp/GeoBmpFileRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | package de.k3b.android.locationMapViewer.geobmp;
21 |
22 | import android.graphics.BitmapFactory;
23 |
24 | import java.io.File;
25 | import java.io.IOException;
26 | import java.io.Writer;
27 |
28 | import de.k3b.android.GeoUtil;
29 | import de.k3b.geo.api.IGeoRepository;
30 | import de.k3b.geo.geobmp.BookmarkUtil;
31 | import de.k3b.geo.io.GeoFileRepository;
32 |
33 | /**
34 | * Created by k3b on 24.03.2015.
35 | */
36 | public class GeoBmpFileRepository extends GeoFileRepository {
37 | private final File iconDir;
38 |
39 | /**
40 | * connect repository to file
41 | *
42 | * @param file
43 | */
44 | public GeoBmpFileRepository(File file) {
45 | super(file, new GeoBmpDtoAndroid());
46 | this.iconDir = new File(file.getAbsolutePath() + ".icons");
47 | this.iconDir.mkdirs();
48 | }
49 |
50 | protected GeoBmpDtoAndroid loadItem(String line) {
51 | GeoBmpDtoAndroid geo = (GeoBmpDtoAndroid) super.loadItem(line);
52 | File bmpFile = getBmpFile(geo);
53 |
54 | if ((bmpFile != null) && (bmpFile.exists())) {
55 | geo.setBitmap(BitmapFactory.decodeFile(bmpFile.getAbsolutePath()));
56 | }
57 | return geo;
58 | }
59 |
60 | protected boolean saveItem(Writer writer, GeoBmpDtoAndroid geo) throws IOException {
61 | final boolean valid = super.saveItem(writer, geo);
62 |
63 | File bmpFile = (valid) ? getBmpFile(geo) : null;
64 |
65 | if ((bmpFile != null) && (geo.getBitmap() != null) && (!bmpFile.exists())) {
66 | GeoUtil.saveBitmapAsFile(geo.getBitmap(), bmpFile);
67 | }
68 | return valid;
69 | }
70 |
71 | private File getBmpFile(GeoBmpDtoAndroid geo) {
72 | if (geo == null) return null;
73 | final String id = geo.getId();
74 |
75 | if (BookmarkUtil.isNotEmpty(id)) {
76 | return new File(this.iconDir, id + ".icon");
77 | }
78 | return null;
79 | }
80 |
81 | /**
82 | * removes item from repository.
83 | *
84 | * @param item that should be removed
85 | * @return true if successful
86 | */
87 | @Override
88 | public IGeoRepository delete(GeoBmpDtoAndroid item) {
89 | File file = getBmpFile(item);
90 | if (file != null) file.delete();
91 |
92 | super.delete(item);
93 | return this;
94 | }
95 |
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/widgets/EditTextPreferenceWithSummary.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 k3b
3 | *
4 | * This file is part of de.k3b.android.toGoZip (https://github.com/k3b/ToGoZip/) .
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 | package de.k3b.android.widgets;
20 |
21 | import android.content.Context;
22 | import android.content.SharedPreferences;
23 | import android.preference.EditTextPreference;
24 | import android.preference.Preference;
25 | import android.preference.PreferenceManager;
26 | import android.util.AttributeSet;
27 | import android.util.Log;
28 | import android.view.View;
29 | import android.view.ViewGroup;
30 |
31 | /**
32 | * EditTextPreference that displays it's string-value in the Preference-summary line.
33 | */
34 | public class EditTextPreferenceWithSummary extends EditTextPreference {
35 | private final static String TAG = EditTextPreferenceWithSummary.class
36 | .getName();
37 |
38 | public EditTextPreferenceWithSummary(android.content.Context context, android.util.AttributeSet attrs, int defStyle) {
39 | super(context, attrs, defStyle);
40 | this.init();
41 | }
42 |
43 | public EditTextPreferenceWithSummary(final Context context,
44 | final AttributeSet attrs) {
45 | super(context, attrs);
46 | this.init();
47 | }
48 |
49 | public EditTextPreferenceWithSummary(final Context context) {
50 | super(context);
51 | this.init();
52 | }
53 |
54 | private void init() {
55 | Log.i(EditTextPreferenceWithSummary.TAG, "init");
56 | final SharedPreferences prefs = PreferenceManager
57 | .getDefaultSharedPreferences(this.getContext());
58 | final String currentText = prefs.getString("test", this.getText());
59 |
60 | this.setSummary(currentText);
61 |
62 | this.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
63 |
64 | @Override
65 | public boolean onPreferenceChange(final Preference preference,
66 | final Object newValue) {
67 | Log.i(EditTextPreferenceWithSummary.TAG,
68 | "display score changed to " + newValue);
69 | preference.setSummary(newValue.toString()); // getSummary());
70 | return true;
71 | }
72 | });
73 | }
74 |
75 | @Override
76 | public CharSequence getSummary() {
77 | return super.getSummary();
78 | }
79 |
80 | @Override
81 | protected View onCreateView(ViewGroup parent) {
82 | this.setSummary(this.getText());
83 | return super.onCreateView(parent);
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/layout/bubble_geo_point_dto.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
26 |
31 |
36 |
42 |
51 |
61 |
71 |
72 |
73 |
80 |
81 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto init
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto init
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :init
68 | @rem Get command-line arguments, handling Windows variants
69 |
70 | if not "%OS%" == "Windows_NT" goto win9xME_args
71 |
72 | :win9xME_args
73 | @rem Slurp the command line arguments.
74 | set CMD_LINE_ARGS=
75 | set _SKIP=2
76 |
77 | :win9xME_args_slurp
78 | if "x%~1" == "x" goto execute
79 |
80 | set CMD_LINE_ARGS=%*
81 |
82 | :execute
83 | @rem Setup the command line
84 |
85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
86 |
87 |
88 | @rem Execute Gradle
89 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
90 |
91 | :end
92 | @rem End local scope for the variables with windows NT shell
93 | if "%ERRORLEVEL%"=="0" goto mainEnd
94 |
95 | :fail
96 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
97 | rem the _cmd.exe /c_ return code!
98 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
99 | exit /b 1
100 |
101 | :mainEnd
102 | if "%OS%"=="Windows_NT" endlocal
103 |
104 | :omega
105 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/osmdroid/ZoomUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | package de.k3b.android.osmdroid;
21 |
22 | import org.osmdroid.api.IGeoPoint;
23 | import org.osmdroid.api.IMapController;
24 | import org.osmdroid.tileprovider.MapTileProviderBase;
25 | import org.osmdroid.util.GeoPoint;
26 | import org.osmdroid.util.TileSystem;
27 | import org.osmdroid.views.MapView;
28 |
29 | import de.k3b.geo.api.GeoPointDto;
30 |
31 | /**
32 | * Created by k3b on 16.03.2015.
33 | */
34 | public class ZoomUtil {
35 |
36 | public static final int NO_ZOOM = GeoPointDto.NO_ZOOM;
37 |
38 | /**
39 | * Similar to MapView.zoomToBoundingBox that seems to be to inexact.
40 | * @param mapView
41 | * @param zoom if NO_ZOOM (-1) zoom is calculated from min and max
42 | * @param min
43 | * @param max
44 | */
45 | public static void zoomTo(MapView mapView, double zoom, IGeoPoint min, IGeoPoint max) {
46 | MapTileProviderBase tileProvider = mapView.getTileProvider();
47 | IMapController controller = mapView.getController();
48 | IGeoPoint center = min;
49 |
50 | if (max != null) {
51 | center = new GeoPoint((max.getLatitude() + min.getLatitude()) / 2, (max.getLongitude() + min.getLongitude()) / 2);
52 |
53 | if (zoom == NO_ZOOM) {
54 | final double requiredMinimalGroundResolutionInMetersPerPixel = ((double) new GeoPoint(min.getLatitude(), min.getLongitude()).distanceToAsDouble(max)) / Math.min(mapView.getWidth(), mapView.getHeight());
55 | zoom = calculateZoom(center.getLatitude(), requiredMinimalGroundResolutionInMetersPerPixel, tileProvider.getMaximumZoomLevel(), tileProvider.getMinimumZoomLevel());
56 | }
57 | }
58 | if (zoom != NO_ZOOM) {
59 | controller.setZoom(zoom);
60 | }
61 |
62 | if (center != null) {
63 | controller.setCenter(center);
64 | }
65 | /*
66 | if (logger.isDebugEnabled()) {
67 | logger.debug("DelayedSetCenterZoom.execute({}: ({}) .. ({}),z={}) => ({}), z={} => {}",
68 | debugContext,
69 | min, max, mZoomLevel, center, zoom, getStatusForDebug());
70 | }
71 | */
72 | }
73 |
74 | private static int calculateZoom(double latitude, double requiredMinimalGroundResolutionInMetersPerPixel, int maximumZoomLevel, int minimumZoomLevel) {
75 | for (int zoom = maximumZoomLevel; zoom >= minimumZoomLevel; zoom--) {
76 | if (TileSystem.GroundResolution(latitude, zoom) > requiredMinimalGroundResolutionInMetersPerPixel)
77 | return zoom;
78 | }
79 |
80 | return NO_ZOOM;
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/xml/preferences.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
25 |
28 |
29 |
33 |
34 |
38 |
39 |
45 |
46 |
49 |
50 |
51 |
54 |
57 |
60 |
63 |
64 |
67 |
74 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/locationMapViewer/GeoPointMarkerInfoWindow.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | package de.k3b.android.locationMapViewer;
21 |
22 | import android.content.Intent;
23 | import android.net.Uri;
24 | import android.view.View;
25 | import android.widget.Button;
26 | import android.widget.TextView;
27 |
28 | //import org.osmdroid.bonuspack.overlays.Marker;
29 | //import org.osmdroid.bonuspack.overlays.MarkerInfoWindow;
30 | import org.osmdroid.views.MapView;
31 | import org.osmdroid.views.overlay.Marker;
32 | import org.osmdroid.views.overlay.infowindow.MarkerInfoWindow;
33 |
34 | import de.k3b.android.util.HtmlUtils;
35 | import de.k3b.geo.api.GeoPointDto;
36 |
37 | /**
38 | * Created by k3b on 17.04.2015.
39 | */ //7. Customizing the bubble behaviour
40 | class GeoPointMarkerInfoWindow extends MarkerInfoWindow implements View.OnClickListener {
41 | private GeoPointDto mSelectedPoi = null;
42 |
43 | public GeoPointMarkerInfoWindow(MapView mapView) {
44 | super(R.layout.bubble_geo_point_dto, mapView);
45 | }
46 |
47 | // View.OnClickListener
48 | public void onClick(View view) {
49 | if ((mSelectedPoi != null) && (mSelectedPoi.getLink() != null)) {
50 | Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(mSelectedPoi.getLink()));
51 | view.getContext().startActivity(myIntent);
52 | }
53 | }
54 |
55 | @Override
56 | public void onOpen(Object item) {
57 | super.onOpen(item);
58 | Marker marker = (Marker) item;
59 | mSelectedPoi = (GeoPointDto) marker.getRelatedObject();
60 | if (mSelectedPoi != null) {
61 | setText(R.id.bubble_title, mSelectedPoi.getName());
62 | setText(R.id.bubble_description, HtmlUtils.interpreteHtml(mSelectedPoi.getDescription()));
63 |
64 | if (mSelectedPoi.getLink() != null) {
65 | Button btn = (Button) (mView.findViewById(R.id.bubble_moreinfo));
66 | btn.setVisibility(View.VISIBLE);
67 | btn.setOnClickListener(this);
68 | }
69 |
70 | // R.id.bubble_image not implemented yet
71 | // R.id.bubble_subdescription not implemented
72 | /* !!!
73 | //8. put thumbnail image in bubble, fetching the thumbnail in background:
74 | if (mSelectedPoi.mThumbnailPath != null){
75 | ImageView imageView = (ImageView)mView.findViewById(R.id.bubble_image);
76 | mSelectedPoi.fetchThumbnailOnThread(imageView);
77 | }
78 | */
79 | }
80 | }
81 |
82 | private void setText(int resourceId, CharSequence value) {
83 | if (value != null) {
84 | TextView tv = (TextView) mView.findViewById(resourceId);
85 | tv.setVisibility(View.VISIBLE);
86 | tv.setText(value);
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/wiki/examples/hannover-gpx11.gpx:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 | Hannover(gpx)
15 |
16 | With a population of 518,000, Hanover is a major centre of
17 | Northern Germany and the country's thirteenth largest city. Hanover also
18 | hosts annual commercial trade fairs such as the Hanover Fair and the CeBIT.
19 |
20 |
21 |
22 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | Test
35 | This is no valid gpx11 content but will be understood by the parser
36 |
37 | https://github.com/k3b/LocationMapViewer/
38 |
39 |
40 |
41 | 2009-10-16T00:00:00Z
43 | https://github.com/k3b/LocationMapViewer/
44 | theName gpx10
45 | theDesc gpx10
46 |
47 |
48 |
49 |
50 |
51 |
52 | theDesc kml
53 | theName kml
54 |
55 |
56 | 9.3,52.3
57 | 2015-02-10T08:04:45.000Z
58 |
59 |
60 |
61 |
62 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 | 5
76 |
--------------------------------------------------------------------------------
/fastlane/lib/generate_metadata.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | # Author: Torsten Grote
4 | # License: GPLv3 or later
5 | # source : 2020-04-16 https://github.com/grote/Transportr/blob/master/fastlane/generate_metadata.py
6 |
7 | import os
8 | import shutil
9 | from xml.etree import ElementTree
10 |
11 |
12 | XML_PATH = '../app/src/main/res'
13 | METADATA_PATH = 'metadata/android'
14 | DEFAULT_LANG = 'en-US'
15 | LANG_MAP = {
16 | 'values': 'en-US',
17 | 'values-ca': 'ca',
18 | 'values-cs': 'cs-CZ',
19 | 'values-de': 'de-DE',
20 | 'values-el': 'el-GR',
21 | 'values-es': 'es-ES',
22 | 'values-eu': 'eu-ES',
23 | 'values-fr': 'fr-FR',
24 | 'values-hu': 'hu-HU',
25 | 'values-it': 'it-IT',
26 | 'values-ja': 'ja-JP',
27 | 'values-nl': 'nl-NL',
28 | 'values-pl': 'pl-PL',
29 | 'values-pt-rBR': 'pt-BR',
30 | 'values-ru': 'ru-RU',
31 | 'values-ta': 'ta-IN',
32 | 'values-tr': 'tr-TR',
33 | }
34 | PATH = os.path.dirname(os.path.realpath(__file__))
35 |
36 |
37 | def main():
38 | path = os.path.join(PATH, XML_PATH)
39 | for entry in os.listdir(path):
40 | directory = os.path.join(path, entry)
41 | if not os.path.isdir(directory) or entry not in LANG_MAP.keys():
42 | continue
43 | strings_file = os.path.join(directory, 'strings.xml')
44 | if not os.path.isfile(strings_file):
45 | print("Error: %s does not exist" % strings_file)
46 | continue
47 |
48 | print()
49 | print(LANG_MAP[entry])
50 | print("Parsing %s..." % strings_file)
51 | e = ElementTree.parse(strings_file).getroot()
52 | title = e.find('.//string[@name="google_play_title"]')
53 | short_desc = e.find('.//string[@name="google_play_short_desc"]')
54 | full_desc = e.find('.//string[@name="google_play_full_desc"]')
55 | if short_desc is None or full_desc is None:
56 | print("Warning: Skipping %s because of incomplete translation" % entry)
57 | continue
58 | if title is not None:
59 | save_file(title.text, LANG_MAP[entry], 'title.txt')
60 | else:
61 | directory_path = os.path.join(PATH, METADATA_PATH, LANG_MAP[entry])
62 | copy_title(directory_path)
63 | save_file(short_desc.text, LANG_MAP[entry], 'short_description.txt')
64 | save_file(full_desc.text, LANG_MAP[entry], 'full_description.txt')
65 |
66 |
67 | def save_file(text, directory, filename):
68 | directory_path = os.path.join(PATH, METADATA_PATH, directory)
69 | if not os.path.exists(directory_path):
70 | os.makedirs(directory_path)
71 | if filename == 'title.txt':
72 | limit = 50
73 | elif filename == 'short_description.txt':
74 | limit = 80
75 | else:
76 | limit = 4000
77 | text = clean_text(text, limit)
78 | file_path = os.path.join(directory_path, filename)
79 | print("Writing %s..." % file_path)
80 | with open(file_path, 'w') as f:
81 | f.write(text)
82 |
83 |
84 | def clean_text(text, limit=0):
85 | text = text.replace('\\\'', '\'')
86 | if limit != 0 and len(text) > limit:
87 | print("Warning: Text longer than %d characters, truncating..." % limit)
88 | text = text[:limit]
89 | return text
90 |
91 |
92 | def copy_title(directory):
93 | title_path = os.path.join(directory, 'title.txt')
94 | if os.path.exists(title_path):
95 | return
96 | default_title_path = os.path.join(directory, '..', DEFAULT_LANG, 'title.txt')
97 | shutil.copy(default_title_path, title_path)
98 |
99 |
100 | if __name__ == "__main__":
101 | main()
102 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/locationMapViewer/geobmp/GeoBmpEditActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | package de.k3b.android.locationMapViewer.geobmp;
21 |
22 | import android.app.Activity;
23 | import android.content.Intent;
24 | import android.os.Bundle;
25 | import android.view.View;
26 | import android.widget.Button;
27 |
28 | import de.k3b.android.locationMapViewer.R;
29 | import de.k3b.android.widgets.IViewHolder;
30 | import de.k3b.geo.api.IGeoInfoHandler;
31 | import de.k3b.geo.api.IGeoPointInfo;
32 |
33 | public class GeoBmpEditActivity extends Activity implements IGeoInfoHandler, IViewHolder {
34 | private IGeoInfoHandler dialogResultConsumer;
35 |
36 | private Button buttonSave;
37 | private Button buttonCancel;
38 |
39 | private GeoBmpDtoAndroid currentItem = null;
40 |
41 | @Override
42 | protected void onCreate(Bundle savedInstanceState) {
43 | super.onCreate(savedInstanceState);
44 | setContentView(R.layout.geobmp_edit);
45 |
46 | this.dialogResultConsumer = dialogResultConsumer;
47 | this.setContentView(R.layout.geobmp_edit);
48 |
49 | this.buttonSave = (Button) this.findViewById(R.id.cmd_save);
50 | this.buttonCancel = (Button) this.findViewById(R.id.cmd_cancel);
51 |
52 | this.buttonSave.setOnClickListener(new View.OnClickListener() {
53 | @Override
54 | public void onClick(final View v) {
55 | saveChangesAndExit(null);
56 | }
57 |
58 | });
59 | this.buttonCancel.setOnClickListener(new View.OnClickListener() {
60 | @Override
61 | public void onClick(final View v) {
62 | GeoBmpEditActivity.this.finish();
63 | }
64 | });
65 |
66 | }
67 |
68 | protected void onOkCLick() {
69 | this.save(this.currentItem);
70 | final Intent intent = this.getFinishIntent();
71 | this.setResult(R.id.cmd_save, intent);
72 | this.finish();
73 | }
74 |
75 | /**
76 | * @return Override with result intent with extra-paramaters for the caller
77 | */
78 | protected Intent getFinishIntent() {
79 | return null;
80 | /*
81 | final Intent intent = new Intent();
82 | intent.putExtra(Global.EXTRA_FILTER, this.filter);
83 | return intent;
84 | */
85 | }
86 |
87 | @Override
88 | public boolean onGeoInfo(IGeoPointInfo geoInfo) {
89 | this.currentItem = (GeoBmpDtoAndroid) geoInfo;
90 |
91 | load(this.currentItem);
92 | return true;
93 | }
94 |
95 | void load(GeoBmpDtoAndroid currentItem) {
96 | GeoBmpBinder.toGui(this, currentItem);
97 | }
98 |
99 | private void save(GeoBmpDtoAndroid currentItem) {
100 | GeoBmpBinder.fromGui(this, currentItem);
101 | }
102 |
103 | private void saveChangesAndExit(final IGeoInfoHandler owner) {
104 | save(this.currentItem);
105 | if (owner != null) {
106 | owner.onGeoInfo(this.currentItem);
107 | }
108 | this.finish();
109 | }
110 |
111 | }
112 |
--------------------------------------------------------------------------------
/wiki/toc.md:
--------------------------------------------------------------------------------
1 | # toc
2 |
3 | v [home](home)
4 | * The [map's user ingerface](map)
5 | * [geo-bookmarks](bookmarks) to remember and quickly navigate to named latitude/longitude/zoomlevel
6 | * Customizing LocationMapViewer: [settings](settings)
7 | v Supported [dataformats](data)
8 | v How other apps can use LocationMapViewer through the [intent api](api#intent)
9 |
10 | --------------------------
11 | [home](home)
12 | [Features](home#Features)
13 | [toc](home#toc)
14 | [requirements](home#requirements)
15 | [permissions](home#permissions)
16 |
17 | [map](map)
18 | [zoomlevel](map#z)
19 | [bookmark](map#bookmark) a region.
20 | [bubble](map#bubble)
21 | [poi-marker](map#marker).
22 | [">" button](map#link) if it has a url. Tabbing on this button opens the url.
23 |
24 | [LocationMapViewer API](api)
25 | [Intent Interface](api#intent)
26 | [What to do: **action**](api#action)
27 | [What and where to show: **data-uri** and **data-type**](api#uri)
28 | [Data-uri="geo:..."](api#geo)
29 | [Data-uri as local file-uri "file://..." or internet-uri "http:..." or "https:..."](api#file)
30 | [What title to show: **EXTRA_TITLE**](api#title)
31 | [Additional points-of-interest **EXTRA_POIS**](api#extra-pois)
32 | [Example LocationMapViewer as a geo-picker](api#example)
33 | [Legal stuff](gpl)
34 |
35 | [data](data)
36 | * Introduction
37 | * [region of the world](data#region)
38 | * [point-of-interest](data#marker)
39 | * [dataformats](data#dataformats)
40 | * [Geo uri](data#geo)
41 | * [gpx-1.0 and gpx-1.1](data#gpx)
42 | * [kml-2.2](data#kml)
43 | * [poi](data#poi)
44 | * [Data Fields](data#data)
45 | * [ll=lat,lon](data#ll) : Latitude(north), Longitude(east)
46 | * [n=name](data#n) : name, title or caption of the point
47 | * [d=description](data#d) : Information about the point.
48 | * [z=zoomLevel](data#z) : how much detail should be shown
49 | * [z2=ZoomMax](data#z2) : (not used yet. reserved for zoom intervalls)
50 | * [link](data#link) : url pointing to additional informations
51 | * [s=symbol](data#s) : symbol-id or url pointing to a symbol, preview-image, icon
52 | * [id=id](data#id) : unique number or value identifying the point.
53 | * [t=time](data#t) : that relates to the point
54 | * [geoUri](data#geoUri) : (xml only) contains info in geo-uri format
55 | * [infer=1](data#infer) : (xml with geoUri only) try to infer lat,lon and name from description
56 |
57 | images
58 |
59 | 
60 | 
61 | 
62 | 
63 | 
64 | 
65 | 
66 | 
67 | 
68 | 
69 | 
70 |
71 | 
72 | 
73 | 
74 | 
75 | 
76 |
77 |
78 | 
79 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
22 | OK
23 | Cancel
24 | Settings
25 | Map Overlays
26 | Show My Location
27 | Show Minimap
28 | Cluster Points
29 | checked neighbour point shown as one red point
30 | Current Position
31 | North
32 | East
33 | Zoom
34 | Debug/Development
35 | Enable Guestures Debug
36 | Guestures Debug Messages copied to clipboard and added to LogCat.
37 | About LocationMapViewer
38 | "
39 | LocationMapViewer
41 |
An app that can display geografic info in a map. It has
42 | support for gpx and kml
43 | files and geo-uri-s and can work offline
44 | (without internet/wifi) once geodata is downloaded and cached.
45 |
Other Android apps can use LocationMapViewer through an
46 | Intent interface (see
48 | GeoIntentDemo.java) or through html links similar to geo:0,0?q=53.0,8.0(Hello)
49 | (<a href="geo:0,0?q=53.0,8.0(Hello)">geo:0,0?q=53.0,8.0(Hello)</a>)
50 |
51 | ]]>
52 | "
53 |
54 |
55 | Bookmarks
56 | Bookmark
57 | Save
58 | Cancel
59 | Edit
60 | Rename
61 | Delete
62 | Close
63 |
64 | "Confirm Delete "
65 | "Are you sure you want to permanently delete \n\n %1$s ? \n\n This is NOT undoable.
66 | Yes
67 | No
68 | [Current Window]
69 | [Inital Window]
70 | "[GPS] "
71 |
72 | "Map Tiles (c) OpenStreetMap Contributors"
73 |
74 | Missing permisions
75 | Open File
76 |
77 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/values-fr/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
22 | OK
23 | Annuler
24 | Paramètres
25 | Couches de la carte
26 | Afficher ma position
27 | Afficher la mini-carte
28 | Groupes de points
29 | vérifier les points voisins affichés comme point rouge
30 | Position actuelle
31 | Nord
32 | Est
33 | Zoom
34 | Debug/Development
35 | Enable Guestures Debug
36 | Guestures Debug Messages copied to clipboard and added to LogCat.
37 | À propos de LocationMapViewer
38 | "
39 | LocationMapViewer
41 |
Une application permettant afficher des informations géographiques sur une carte. Elle
42 | supporte les fichiers gpx, kml
43 | et geo-uri-s et elle peut fonctionner hors-ligne
44 | (sans internet/wifi) une fois que les géodonnées ont été téléchargées et mises en cache.
45 |
D\'autres applications Android peuvent utiliser LocationMapViewer à travers une
46 | interface dédiée (voir
48 | GeoIntentDemo.java) ou au travers de liens html semblables à geo:0,0?q=53.0,8.0(Hello)
49 | (<a href="geo:0,0?q=53.0,8.0(Hello)">geo:0,0?q=53.0,8.0(Hello)</a>)
50 |
Апликација која може да прикаже географске податке на мапи
43 | Има подршку за gpx и kml
44 | фајлове и geo-uri-s може да ради без мреже
45 | (без интернета) ако су геоподаци преузети и кеширани.
46 |
Друге апликације могу да користе Прегледача локација преко
47 | Интент сучеља (погледајте
49 | GeoIntentDemo.java) или преко хтмл веза: geo:0,0?q=53.0,8.0(Здраво)
50 | (<a href="geo:0,0?q=53.0,8.0(Здраво)">geo:0,0?q=53.0,8.0(Здраво)</a>)
51 |
52 | ]]>
53 | "
54 |
55 |
56 | Обележивачи
57 | Обележи
58 | Сачувај
59 | Одустани
60 | Уреди
61 | Преименуј
62 | Обриши
63 | Затвори
64 |
65 | "Потврда брисања"
66 | "Желите ли заиста да обришете \n\n %1$s ? \n\n Ово НЕ МОЖЕ да се поништи.
67 | Да
68 | Не
69 | [Тренутни прозор]
70 | [Почетни прозор]
71 | "[ГПС]"
72 |
73 | "Плочице мапа (c) доприносиоци Опенстрит Мапе"
74 |
75 |
--------------------------------------------------------------------------------
/LocationMapViewer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'maven'
3 |
4 | android {
5 | compileSdkVersion 29
6 | defaultConfig {
7 | applicationId 'de.k3b.android.locationMapViewer'
8 | // api-16(JELLY_BEAN = 4.2) OSMDROID Library
9 | // api-19(KITKAT = Android-4.4) ACTION_OPEN_DOCUMENT
10 | // api-21(LOLLIPOP = Android-5) for ACTION_OPEN_DOCUMENT_TREE
11 | minSdkVersion 16
12 | targetSdkVersion 26
13 | // 0.2.2.150321 (2)
14 | // fdroid 06.5.2015 (3) versionName "0.3.3.150506"
15 | // fdroid 30.3.2016 (4) versionName "0.3.4.160330"
16 | // fdroid 13.8.2016 (5) versionName "0.3.5.160813"
17 | // fdroid 13.8.2016 (6) versionName "0.3.5.170911"
18 | // fdroid (7) versionName "0.3.7.210429" AO10 with verify error: wrong gradle-wrapper version
19 | // fdroid 21.05.2021 (8) versionName "0.3.7.210502" AO10 support
20 | // fdroid ??? (9) versionName "0.3.8.210625" added support for symbols and open kmz files (=kml in zip)
21 | // fdroid ??? (10) versionName "0.3.8.210702" fixed crash when opend with a geo uri (#18)
22 | versionName "0.3.8.210702"
23 | versionCode 10
24 | }
25 | buildTypes {
26 | debug {
27 | minifyEnabled false
28 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
29 | }
30 | release {
31 | shrinkResources true
32 | minifyEnabled true
33 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34 | }
35 | }
36 | compileOptions {
37 | sourceCompatibility JavaVersion.VERSION_1_7
38 | targetCompatibility JavaVersion.VERSION_1_7
39 | }
40 | productFlavors {
41 | }
42 | lintOptions {
43 | // http://stackoverflow.com/questions/31350350/generating-signed-apk-error7-missingtranslation-in-build-generated-res-gen
44 | // MissingTranslation : not all crowdwin translations are complete so ignore them
45 | // ValidFragment : local (dialog-)fragment class for customized direcotry picker is fragile but on rotation code makes shure that dialog is closed.
46 | // disable 'MissingTranslation','ValidFragment', 'ContentDescription', 'AndroidLintPluralsCandidate', 'AndroidLintRtlHardcoded'
47 | // disable 'MissingTranslation','ValidFragment', 'ContentDescription', 'ExpiredTargetSdkVersion'
48 | disable 'MissingTranslation','ContentDescription', 'ExpiredTargetSdkVersion'
49 |
50 | abortOnError false
51 | }
52 | }
53 |
54 | dependencies {
55 | implementation fileTree(dir: 'libs', include: ['*.jar'])
56 |
57 | implementation 'androidx.drawerlayout:drawerlayout:1.1.1'
58 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
59 | implementation 'androidx.annotation:annotation:1.2.0'
60 |
61 | // implementation 'com.github.k3b:k3b-geoHelper:1.1.5'
62 | // implementation 'com.github.k3b:k3b-geoHelper:master-SNAPSHOT'
63 | implementation 'com.github.k3b:k3b-geoHelper:v1.1.9'
64 | // implementation 'com.github.k3b:k3b-geoHelperAndroid:v1.1.9'
65 | // implementation 'com.github.k3b:k3b-geoHelper:1.1.6-SNAPSHOT'
66 | // implementation 'com.github.k3b:k3b-geoHelperAndroid:1.1.6-SNAPSHOT'
67 | // implementation 'com.github.k3b:k3b-geoHelper:WikipediaAndroid-SNAPSHOT'
68 | // implementation 'com.github.k3b:k3b-geoHelper:WikipediaAndroid-v1.1.4-gf51d7c7-63'
69 |
70 | // this is osmdroid
71 | // implementation project(':osmdroid-android') // local copy
72 | implementation 'org.osmdroid:osmdroid-android:6.1.11'
73 | // non local copy from repositories
74 |
75 | // implementation project(':OSMBonusPack').
76 | // Version must match osmdroid
77 | // see https://github.com/mkergall/Osmbonuspack/releases
78 | implementation 'com.github.MKergall:osmbonuspack:6.7.0'
79 |
80 | implementation 'org.slf4j:slf4j-api:1.7.7@jar'
81 | // include if you want to see debug/trace logmessages
82 | // implementation 'org.slf4j:slf4j-android:1.7.7@jar'
83 | // only error and warn
84 | implementation 'eu.lp0.slf4j:slf4j-android:1.7.7-1@jar'
85 | // implementation 'org.jetbrains:annotations-java5:15.0'
86 |
87 | testImplementation 'junit:junit:4.13.2'
88 | testImplementation 'org.slf4j:slf4j-simple:1.7.7@jar'
89 | }
90 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # LocationMapViewer 
2 |
3 | An Android app to display geographic information from url or local gpx/kml/kmz/zip file in a [map](map).
4 |
5 | It has support for **gpx**, **kml** and **kmz** files and **geo-uri-s**
6 | and can work offline (without internet/wifi)
7 | once geodata is downloaded and cached.
8 |
9 | 
10 |
11 | Other Android apps can use LocationMapViewer through an Intent interface
12 | (see [GeoIntentDemo.java](https://github.com/k3b/LocationMapViewer/blob/master/geoIntentDemo/src/main/java/de/k3b/android/locationMapViewer/demo/GeoIntentDemoActivity.java) )
13 | or through html links like <a href="geo:0,0?q=53.0,8.0(Hello)">geo:0,0?q=53.0,8.0(Hello)</a>
14 |
15 | ## Minimal requirements:
16 |
17 | * version v0.3.5.170911(6)
18 | * Android-2.3.7 - Android-7 (API 10ff)
19 | * version v0.3.7.210429
20 | * Android-4.1 and later (API 16ff)
21 | * compatible with android-10
22 | * internet/wifi-connection to download geodata and a SD-Card to cache geodata
23 |
24 | Licence: [GPLv3](http://www.gnu.org/licenses/gpl-3.0)
25 |
26 | ## Required permissions:
27 |
28 | * INTERNET: to download map data from Open Streetmap Server
29 | * ACCESS_NETWORK_STATE and ACCESS_WIFI_STATE: to find out if wifi/internet is online to start downloaded geodata
30 | * WRITE_EXTERNAL_STORAGE
31 | * to cache downloaded map data in local file system
32 | * to load gpx/kml-Files to be displayed in the map
33 | * ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION: to display my own location in the map, too
34 |
35 | The code uses [osmdroid library](https://github.com/osmdroid/osmdroid)
36 | with [osmbonuspack library](http://code.google.com/p/osmbonuspack/)
37 | to display maps from [Open Street Map](http://www.openstreetmap.org).
38 |
39 | ## Intent Interface
40 |
41 | Other Android apps can use LocationMapViewer as plug-in/device-driver through an Intent interface
42 | or through html-a-href-links.
43 |
44 | Examples:
45 |
46 | * uri=geo:... displays (and zomms to) a [geo uri](http://tools.ietf.org/html/draft-mayrhofer-geo-uri-00)
47 | * geo:0,0?q=53.0,8.0(Hello)
48 | * displays "hello" at the location lat=53.0 north and lon= 8.0 east.
49 | * in html you can use <a href="geo:0,0?q=53.0,8.0(Hello)">geo:0,0?q=53.0,8.0(Hello)</a>
50 | * this format is compatible with google-maps for android
51 | * geo:53.0,8.0?q=(Hello)
52 | * displays "hello" at the location lat=53.0 north and lon= 8.0 east
53 | * this format is **not** compatible with google-maps for android
54 | * geo:53.0,8.0?z=6
55 | * displays a pin at the location using zoomlevel "6"
56 | * uri=file:/path/to/waypoints.gpx
57 | * displays a xml+gpx waypointfile
58 | * uri=content:/path/to/waypoints.kml
59 | * displays a vnd.google-earth.kml+xml waypointfile
60 |
61 | LocationMapViewer can handle local files that end with
62 |
63 | * .kml, .kml.zip, .kmz (kml in zip)
64 | * .gpx, .gpx.zip, .gpz (gpx in zip)
65 | * .poi, .poi.zip, .poz (poi in zip)
66 |
67 | LocationMapViewer can handle http(s): and content: urls with mime
68 |
69 | * application/vnd.google-earth.kml+xml
70 | * application/vnd.google-earth.kmz
71 | * application/xml+kml
72 | * application/xml+gpx
73 | * application/xml+poi
74 | * application/zip+xml+kml
75 | * application/zip+xml+gpx
76 | * application/zip+xml+poi
77 |
78 | LocationMapViewer is designed to be used by other apps. This means in Terms of [GPLv3](http://www.gnu.org/licenses/gpl-3.0) that your app
79 | that uses the Intent-Iterface [is not considered a Derived Work.](https://en.wikipedia.org/wiki/GPL_v3#Point_of_view:_linking_is_irrelevant)
80 |
81 | In other words: you can used LocationMapViewer as a [driver for your non gpl/non opensource app.](http://www.rosenlaw.com/lj19.htm).
82 |
83 | For more informations see https://github.com/k3b/LocationMapViewer/wiki
84 |
85 | -----
86 |
87 | ## Donations:
88 |
89 | If you like this app please consider to donating to https://wiki.openstreetmap.org/wiki/Donations .
90 |
91 | Since android-developping is a hobby (and an education tool) i do not want any
92 | money for my apps so donation should go to projects I benefit from.
93 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/values-de/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
22 | OK
23 | Abbrechen
24 | Einstellungen
25 | Map Overlays
26 | Meine GPS Position anzeigen
27 | Zeige Übersichtskarte
28 | Benachbarte Punkte zusammenfassen
29 | Benachbarte Punkte als roten Punkt zusammenfassen
30 | Aktueller Ausschnitt
31 | Nord
32 | Ost
33 | Zoom
34 | Debug/Development
35 | Gesten Debuging
36 | Debug Meldungen der Gestenauswertungen werden ins Clipboard und ins LogCat kopiert.
37 | Über LocationMapViewer
38 | "
39 | LocationMapViewer
41 |
Eine App um Geo-Informatinen in einer Landkarte darzustellen. Sie kann die Formate
42 | gpx, kml, poi und geo-uri
43 | darstellen und arbeitet offline
44 | (ohne Internet/Wifi) sobald das Kartenmaterial geladen und gecached wurde.
45 |
Andere Android Apps können LocationMapViewer mit Hilfe des
46 | Intent Interfaces verwenden (see
48 | GeoIntentDemo.java) oder durch html Links wie geo:0,0?q=53.0,8.0(Ich bin ein geo link)
49 | (<a href="geo:0,0?q=53.0,8.0(Hello)">geo:0,0?q=53.0,8.0(Ich+bin+ein+geo+link)</a>)
50 |
51 | ]]>
52 | "
53 |
54 |
55 | Lesezeichen
56 | Lesezeichen
57 | Speichern
58 | Abbrechen
59 | Bearbeiten
60 | Umbenennen
61 | Löschen
62 | Schließen
63 |
64 | "Löschen bestätigen "
65 | "Wollen Sie dieses wirklich dauerhaft löschen? \n\n %1$s \n\n Das Löschen kann NICHT rückgängig gemacht werden.
66 | Ja
67 | Nein
68 | [Aktueller Ausschnitt]
69 | [Ursprünglicher Ausschnitt]
70 | "[GPS] "
71 |
72 | "Karte (c) OpenStreetMap Mitwirkende"
73 |
74 | Fehlende Berechtigung
75 |
76 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/GeoUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | package de.k3b.android;
21 |
22 | import android.graphics.Bitmap;
23 | import android.graphics.Canvas;
24 | import android.graphics.Matrix;
25 | import android.graphics.Paint;
26 |
27 | import org.osmdroid.api.IGeoPoint;
28 | import org.osmdroid.util.GeoPoint;
29 | import org.osmdroid.views.MapView;
30 |
31 | import java.io.File;
32 | import java.io.FileOutputStream;
33 |
34 | import de.k3b.geo.api.GeoPointDto;
35 | import de.k3b.geo.api.IGeoPointInfo;
36 |
37 | /**
38 | * Created by k3b on 18.03.2015.
39 | */
40 | public class GeoUtil {
41 | /** convert from osm {@link org.osmdroid.api.IGeoPoint} to k3b - {@link de.k3b.geo.api.GeoPointDto} */
42 | public static GeoPointDto createBookmark(IGeoPoint center, int zoomLevel, String name) {
43 | return createBookmark(center, zoomLevel, name, new GeoPointDto());
44 | }
45 |
46 | /** convert from osm {@link org.osmdroid.api.IGeoPoint} to k3b - {@link de.k3b.geo.api.GeoPointDto} */
47 | public static GeoPointDto createBookmark(IGeoPoint center, int zoomLevel, String name, GeoPointDto destination) {
48 | return destination
49 | .setLatitude(center.getLatitude())
50 | .setLongitude(center.getLongitude())
51 | .setZoomMin(zoomLevel)
52 | .setName(name);
53 | }
54 |
55 | /** convert to osm {@link org.osmdroid.api.IGeoPoint} from k3b - {@link de.k3b.geo.api.GeoPointDto} */
56 | public static IGeoPoint createOsmPoint(IGeoPointInfo geoInfo) {
57 | return new GeoPoint(geoInfo.getLatitude(), geoInfo.getLongitude());
58 | }
59 |
60 | // see http://stackoverflow.com/questions/19694642/outofmemory-exception-when-creating-bitmap-from-osm-mapview
61 | /** create {@link android.graphics.Bitmap} from {@link org.osmdroid.views.MapView} */
62 | public static Bitmap createBitmapFromMapView(final MapView mapview, final int newWidth, final int newHeight) {
63 | mapview.setDrawingCacheEnabled(true);
64 | Bitmap result = scaleBitmap(mapview.getDrawingCache(), newWidth, newHeight);
65 | mapview.setDrawingCacheEnabled(false);
66 | return result;
67 | }
68 |
69 | // see http://stackoverflow.com/questions/4821488/bad-image-quality-after-resizing-scaling-bitmap
70 | /** create a scaled-down {@link android.graphics.Bitmap} */
71 | public static Bitmap scaleBitmap(final Bitmap source, final int newWidth, final int newHeight) {
72 | Bitmap scaledBitmap = Bitmap.createBitmap(newWidth, newHeight, Bitmap.Config.ARGB_8888);
73 |
74 | float ratioX = newWidth / (float) source.getWidth();
75 | float ratioY = newHeight / (float) source.getHeight();
76 |
77 | Matrix scaleMatrix = new Matrix();
78 | scaleMatrix.setScale(ratioX, ratioY, 0, 0);
79 |
80 | Canvas canvas = new Canvas(scaledBitmap);
81 | canvas.setMatrix(scaleMatrix);
82 | canvas.drawBitmap(source, 0, 0, new Paint(Paint.FILTER_BITMAP_FLAG));
83 | return scaledBitmap;
84 | }
85 |
86 | public static void saveBitmapAsFile(final Bitmap bmp, File imageFile) {
87 | File dir = imageFile.getParentFile();
88 | if (!dir.exists()) {
89 | dir.mkdirs();
90 | }
91 | try {
92 | final FileOutputStream out = new FileOutputStream(imageFile);
93 | bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
94 | out.flush();
95 | out.close();
96 | } catch (final Exception e) {
97 | e.printStackTrace();
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/widgets/AboutDialogPreference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 k3b
3 | *
4 | * This file is part of de.k3b.android.toGoZip (https://github.com/k3b/ToGoZip/) .
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 | package de.k3b.android.widgets;
20 |
21 | import android.app.AlertDialog;
22 | import android.app.Dialog;
23 | import android.content.Context;
24 | import android.content.DialogInterface;
25 | import android.preference.DialogPreference;
26 | import android.util.AttributeSet;
27 | import android.view.View;
28 | import android.webkit.WebSettings;
29 | import android.webkit.WebView;
30 |
31 | import de.k3b.android.GuiUtil;
32 | import de.k3b.android.locationMapViewer.R;
33 |
34 | /**
35 | * html/Webview about preference entry showing
36 | * R.string.about_content with placeholders
37 | * $versionName$ and
38 | * $about$ (R.string.about_content_about)
39 | * Created by k3b on 11.11.2014.
40 | */
41 | public class AboutDialogPreference extends DialogPreference {
42 | private Context context;
43 |
44 | public AboutDialogPreference(Context context, AttributeSet attrs) {
45 | super(context, attrs);
46 | setDialogIcon(R.drawable.ic_launcher);
47 | setDialogTitle(R.string.about_summary);
48 | setDialogLayoutResource(R.layout.about_dialog);
49 | this.context = context;
50 |
51 | }
52 |
53 | @Override
54 | protected void onBindDialogView(View view) {
55 | super.onBindDialogView(view);
56 |
57 | setAboutText(this.context, (WebView) view.findViewById(R.id.content));
58 | }
59 |
60 | private static WebView setAboutText(Context context, WebView wv) {
61 | final WebSettings settings = wv.getSettings();
62 |
63 | // Fix for "Wrong charset in serbian translations" https://github.com/k3b/LocationMapViewer/issues/5
64 | // (for android 2.2) see http://stackoverflow.com/questions/4933069/android-webview-with-garbled-utf-8-characters
65 | settings.setDefaultTextEncodingName("utf-8");
66 | settings.setBuiltInZoomControls(true);
67 |
68 | String html = context.getResources().getString(R.string.about_content); // "some html here";
69 |
70 | final String versionName = GuiUtil.getAppVersionName(context);
71 | if (versionName != null) {
72 | html = html.replace("$versionName$", versionName);
73 | }
74 |
75 | html = html.replace("$about$",
76 | context.getText(R.string.about_content_about));
77 |
78 | // Fix for "Wrong charset in serbian translations" https://github.com/k3b/LocationMapViewer/issues/5
79 | // (for android 4.x) see http://stackoverflow.com/questions/4933069/android-webview-with-garbled-utf-8-characters
80 | wv.loadData(html, "text/html; charset=utf-8", "UTF-8");
81 | wv.setVerticalScrollBarEnabled(true);
82 |
83 | wv.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
84 | wv.setScrollbarFadingEnabled(false);
85 | return wv;
86 | }
87 |
88 | public static Dialog createAboutDialog(Context context) {
89 | final AlertDialog.Builder alert = new AlertDialog.Builder(context);
90 | alert.setTitle(R.string.about_summary);
91 | alert.setIcon(R.drawable.ic_launcher);
92 | alert.setNeutralButton(R.string.cancel,
93 | new DialogInterface.OnClickListener() {
94 |
95 | @Override
96 | public void onClick(
97 | final DialogInterface paramDialogInterface,
98 | final int paramInt) {
99 | paramDialogInterface.cancel();
100 |
101 | }
102 | }
103 | );
104 |
105 | final WebView wv = setAboutText(context, new WebView(context));
106 | alert.setView(wv);
107 |
108 | return alert.create();
109 | }
110 |
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/androidTest/java/de/k3b/android/locationMapViewer/de/k3b/android/util/AndroidStringTemplateTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | package de.k3b.android.locationMapViewer.de.k3b.android.util;
21 |
22 | import android.content.Context;
23 | import android.content.res.Resources;
24 | import android.test.ActivityTestCase;
25 | import android.util.Log;
26 |
27 | import junit.framework.Assert;
28 |
29 | import org.slf4j.Logger;
30 | import org.slf4j.LoggerFactory;
31 |
32 | import de.k3b.android.locationMapViewer.R;
33 | import de.k3b.android.util.AndroidStringTemplateEngine;
34 |
35 | /**
36 | * Created by k3b on 02.04.2015.
37 | */
38 | public class AndroidStringTemplateTests extends ActivityTestCase {
39 | private static final Logger logger = LoggerFactory.getLogger(AndroidStringTemplateTests.class);
40 |
41 | /**
42 | * Verifys that all template parameters in all string resources are vaild.
43 | */
44 | public void testAllTemplateLinks() {
45 | Context testContext = getInstrumentation().getTargetContext();
46 | Resources resourcesUnderTest = testContext.getResources();
47 |
48 | // collect all not found items
49 | AndroidStringTemplateEngine engine = new AndroidStringTemplateEngine(testContext);
50 | engine.sedDebugEnabled(true);
51 | for (int id : getAllStringResourceIds(R.string.class, resourcesUnderTest)) {
52 | try {
53 | engine.format(id);
54 | } catch (StackOverflowError err) {
55 | }
56 | }
57 |
58 | String errors = engine.getErrors();
59 | assertEquals(errors, 0, errors.length());
60 | }
61 |
62 | /**
63 | * Verifys that all template parameters in all string resources are vaild.
64 | */
65 | public void testSmokeTest() {
66 | Context testContext = getInstrumentation().getTargetContext();
67 | Resources resourcesUnderTest = testContext.getResources();
68 |
69 | AndroidStringTemplateEngine engine = new AndroidStringTemplateEngine(testContext);
70 |
71 | String valueToCheck = resourcesUnderTest.getString(R.string.app_name);
72 | String result = engine.format(valueToCheck);
73 |
74 |
75 | // logoutput does not work
76 | System.out.println(result);
77 | logger.info("string.help_bookmarks : \n{}", result);
78 | Log.i("TestRunner", result);
79 |
80 | }
81 |
82 | private int[] getAllStringResourceIds(Class stringClass, Resources resourcesUnderTest) {
83 | return new int[]{
84 | R.string.about_content,
85 | R.string.about_content_about,
86 | R.string.about_summary,
87 | R.string.app_name,
88 | R.string.cancel,
89 | R.string.cmd_cancel,
90 | R.string.cmd_no,
91 | R.string.cmd_save,
92 | R.string.cmd_yes,
93 | R.string.bookmark_template_current,
94 | R.string.bookmark_template_gps,
95 | R.string.bookmark_template_initial,
96 | R.string.format_question_delete,
97 | R.string.label_select,
98 | R.string.prefs_cat_overlays_title,
99 | R.string.prefs_cluster_points,
100 | R.string.prefs_cluster_points_description,
101 | R.string.prefs_current_east,
102 | R.string.prefs_current_header,
103 | R.string.prefs_current_north,
104 | R.string.prefs_current_zoom,
105 | R.string.prefs_guestures_debug_enable,
106 | R.string.prefs_guestures_debug_enable_description,
107 | R.string.prefs_header_development,
108 | R.string.prefs_showLocation_summary,
109 | R.string.prefs_showMiniMap_summary,
110 | R.string.title_activity_geopoint_edit,
111 | R.string.title_activity_settings,
112 | R.string.title_confirm_delete,
113 | R.string.title_delete,
114 | R.string.title_bookmark_edit,
115 | R.string.title_bookmark_list
116 | };
117 | }
118 |
119 | }
120 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/locationMapViewer/geobmp/GeoBmpListAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | package de.k3b.android.locationMapViewer.geobmp;
21 |
22 | import android.content.Context;
23 | import android.view.LayoutInflater;
24 | import android.view.View;
25 | import android.view.ViewGroup;
26 | import android.widget.ArrayAdapter;
27 | import android.widget.TextView;
28 |
29 | import java.util.List;
30 |
31 | import de.k3b.android.locationMapViewer.R;
32 | import de.k3b.geo.api.IGeoRepository;
33 |
34 | /** Adapter to display IGeoPointInfo in a ListView. */
35 | class GeoBmpListAdapter extends
36 | ArrayAdapter {
37 |
38 | /**
39 | * Corresponds to filter ignore catagory or edit to create a new category
40 | */
41 | public static final int NO_CATEGORY = -1;
42 |
43 | /**
44 | * The Resource used for the adapter
45 | */
46 | private final int viewId;
47 | private GeoBmpDtoAndroid currentSelecion;
48 |
49 | private int colorSelected;
50 | private int colorNotSelected;
51 |
52 | private GeoBmpListAdapter(final Context context,
53 | final int textViewResourceId, final List items) {
54 | super(context, textViewResourceId, items);
55 | this.viewId = textViewResourceId;
56 | colorSelected = context.getResources().getColor(R.color.list_overlay_selected);
57 | colorNotSelected = context.getResources().getColor(R.color.list_overlay_not_selected);
58 | }
59 |
60 | public static ArrayAdapter createAdapter(
61 | final Context context, final int viewId,
62 | final IGeoRepository repository,
63 | final GeoBmpDtoAndroid... additionalPoints
64 | ) {
65 | final List items = repository.reload();
66 |
67 | if (additionalPoints != null) {
68 | for(int index = additionalPoints.length -1; index >= 0; index--) {
69 | final GeoBmpDtoAndroid item = additionalPoints[index];
70 | if (item != null) {
71 | items.add(0, item);
72 | }
73 | }
74 | }
75 | return new GeoBmpListAdapter(context, viewId, items);
76 | }
77 |
78 | @Override
79 | public View getView(final int position, final View convertView,
80 | final ViewGroup parent) {
81 | final GeoBmpDtoAndroid obj = this.getItem(position);
82 |
83 | View itemView = convertView;
84 | if (itemView == null) {
85 | itemView = this.createItemView();
86 | }
87 |
88 | this.setItemContent(itemView, obj);
89 | return itemView;
90 | }
91 |
92 | private View createItemView() {
93 | View itemView;
94 | final LayoutInflater vi = (LayoutInflater) this.getContext()
95 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
96 | itemView = vi.inflate(this.viewId, null);
97 |
98 | return itemView;
99 | }
100 |
101 | private void setItemContent(final View itemView, final GeoBmpDtoAndroid dto) {
102 | if (dto != null) {
103 | GeoBmpBinder.toGui(itemView, dto);
104 |
105 | final int backgroundColor = ((this.currentSelecion == dto)) ? colorSelected : colorNotSelected;
106 | itemView.setBackgroundColor(backgroundColor);
107 | }
108 | }
109 |
110 | private void setTextViewContent(final TextView view, final String text) {
111 | if (view != null) {
112 | if ((text != null) && (text.length() > 0)) {
113 | view.setText(text);
114 | }
115 | }
116 | }
117 |
118 | public void setCurrentSelecion(GeoBmpDtoAndroid currentSelecion) {
119 | if (this.currentSelecion != currentSelecion) {
120 | this.currentSelecion = currentSelecion;
121 | notifyDataSetChanged();
122 | }
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/util/Unzip2.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 by k3b.
3 | *
4 | * This file is part of k3b-geoHelper library.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package de.k3b.util;
20 |
21 | import org.slf4j.Logger;
22 | import org.slf4j.LoggerFactory;
23 |
24 | import java.io.File;
25 | import java.io.FileOutputStream;
26 | import java.io.IOException;
27 | import java.io.InputStream;
28 | import java.io.OutputStream;
29 | import java.util.zip.ZipEntry;
30 | import java.util.zip.ZipInputStream;
31 |
32 | /* TODO: remove this copy as it is already part of Geohelper */
33 | public class Unzip2 {
34 | public static final String TAG = Unzip.class.getSimpleName();
35 | private static final Logger LOGGER = LoggerFactory.getLogger(TAG);
36 |
37 | // see https://stackoverflow.com/questions/1809007/best-way-to-detect-if-a-stream-is-zipped-in-java/68038770#68038770
38 | public static boolean isZipStream(InputStream inputStream) {
39 | if (inputStream == null || !inputStream.markSupported()) {
40 | throw new IllegalArgumentException("InputStream must support mark-reset. Use BufferedInputstream()");
41 | }
42 | boolean isZipped = false;
43 | try {
44 | inputStream.mark(64);
45 | isZipped = new ZipInputStream(inputStream).getNextEntry() != null;
46 | inputStream.reset();
47 | } catch (IOException ex) {
48 | // cannot be opend as zip.
49 | }
50 | return isZipped;
51 | }
52 |
53 | public static void unzip(String name, InputStream inputStream, File destinationDir) throws IOException {
54 | ZipInputStream zipInputStream = null;
55 | String message = "unzip('" + name +
56 | "' => '" + destinationDir + "') ";
57 | LOGGER.info( message);
58 |
59 | try {
60 | zipInputStream = new ZipInputStream(inputStream);
61 |
62 | for (ZipEntry zipEntry = zipInputStream.getNextEntry(); zipEntry != null; zipEntry = zipInputStream
63 | .getNextEntry()) {
64 | unzipEntry(zipInputStream, zipEntry, destinationDir);
65 | }
66 | } catch (IOException e) {
67 | LOGGER.error( "err " + message + e.getMessage(), e);
68 | throw new IOException(message, e);
69 | } finally {
70 | if (zipInputStream != null) zipInputStream.close();
71 | }
72 | }
73 |
74 | private static void unzipEntry(ZipInputStream zipInputStream, ZipEntry entry, File outputDir) throws IOException {
75 | if (entry.isDirectory()) {
76 | createDir(new File(outputDir, entry.getName()));
77 | return;
78 | }
79 |
80 | File outputFile = new File(outputDir, entry.getName());
81 | if (!outputFile.getParentFile().exists()) {
82 | createDir(outputFile.getParentFile());
83 | }
84 |
85 | String message = "unzipEntry(" + entry + ")[" + entry.getSize() + "] ";
86 | LOGGER.debug( message);
87 |
88 | OutputStream output = null;
89 | try {
90 | output = new FileOutputStream(outputFile);
91 | copy(zipInputStream, output);
92 | } catch (IOException e) {
93 | LOGGER.error( "err " + message + e.getMessage(), e);
94 | throw new IOException(message, e);
95 | } finally {
96 | // keep zipInputStream open for next entry-file
97 | if (output != null) output.close();
98 | }
99 |
100 | }
101 |
102 | private static void createDir(File dir) {
103 | if (dir.exists()) {
104 | return;
105 | }
106 | LOGGER.debug("Creating dir " + dir.getName());
107 |
108 | if (!dir.mkdirs()) {
109 | throw new RuntimeException("Can not create dir " + dir);
110 | }
111 | }
112 |
113 | private static void copy(InputStream input, OutputStream output) throws IOException {
114 | byte data[] = new byte[10240];
115 | int count;
116 |
117 | int total = 0;
118 | while ((count = input.read(data)) != -1) {
119 | output.write(data, 0, count);
120 | total += count;
121 | }
122 | output.flush();
123 | }
124 |
125 | public static void deleteRecursive(File f) {
126 | if (f != null && f.exists()) {
127 | if (f.isDirectory()) {
128 | for (File c : f.listFiles()) {
129 | deleteRecursive(c);
130 | }
131 | }
132 | f.delete();
133 | }
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/locationMapViewer/geobmp/GeoBmpBinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | package de.k3b.android.locationMapViewer.geobmp;
21 |
22 | import android.view.View;
23 | import android.widget.EditText;
24 | import android.widget.ImageView;
25 | import android.widget.TextView;
26 |
27 | import java.text.ParseException;
28 |
29 | import de.k3b.android.locationMapViewer.R;
30 | import de.k3b.android.widgets.IViewHolder;
31 | import de.k3b.geo.api.IGeoPointInfo;
32 | import de.k3b.geo.io.GeoFormatter;
33 | import de.k3b.util.IsoDateTimeParser;
34 |
35 | /**
36 | * Connects a {@link GeoBmpDtoAndroid} data element
37 | * with the corresponding gui elements.
38 | *
39 | * This implements convention over configuration.
40 | * gui elements have always the same R.id.
41 | *
42 | * Created by k3b on 26.03.2015.
43 | */
44 | public class GeoBmpBinder {
45 | /** hack for adapter in listview where i cannot controll the class generated */
46 | public static void toGui(final View gui, GeoBmpDtoAndroid item) {
47 | toGui(new IViewHolder() {
48 | @Override
49 | public View findViewById(int id) {
50 | return gui.findViewById(id);
51 | }
52 | }, item);
53 | }
54 |
55 | public static void toGui(IViewHolder gui, GeoBmpDtoAndroid item) {
56 | TextView textView;
57 |
58 | textView = (TextView) gui.findViewById(R.id.name);
59 | if (textView != null) textView.setText(item.getName());
60 |
61 | textView = (TextView) gui.findViewById(R.id.description);
62 | if (textView != null) textView.setText(item.getDescription());
63 |
64 | textView = (TextView) gui.findViewById(R.id.link);
65 | if (textView != null) textView.setText(item.getLink());
66 |
67 | textView = (TextView) gui.findViewById(R.id.id);
68 | if (textView != null) textView.setText(item.getId());
69 |
70 | textView = (TextView) gui.findViewById(R.id.latitude);
71 | if (textView != null) textView.setText(GeoFormatter.formatLatLon(item.getLatitude()));
72 |
73 | textView = (TextView) gui.findViewById(R.id.longitude);
74 | if (textView != null) textView.setText(GeoFormatter.formatLatLon(item.getLongitude()));
75 |
76 | textView = (TextView) gui.findViewById(R.id.zoom);
77 | if (textView != null) textView.setText(GeoFormatter.formatZoom(item.getZoomMin()));
78 |
79 | // read only fields
80 | textView = (TextView) gui.findViewById(R.id.time);
81 | if (textView != null) textView.setText(GeoFormatter.formatDate(item.getTimeOfMeasurement()));
82 |
83 | textView = (TextView) gui.findViewById(R.id.summary);
84 | if (textView != null) textView.setText(item.getSummary());
85 |
86 | final ImageView thumbnail = (ImageView) gui.findViewById(R.id.thumbnail);
87 | if (thumbnail != null) thumbnail.setImageBitmap(item.getBitmap());
88 | }
89 |
90 | public static void fromGui(IViewHolder gui, GeoBmpDtoAndroid currentItem) {
91 | EditText textView;
92 |
93 | // id and bitmap are not read from gui
94 |
95 | textView = (EditText) gui.findViewById(R.id.name);
96 | if (textView != null) currentItem.setName(getStringOrNull(textView));
97 |
98 | textView = (EditText) gui.findViewById(R.id.description);
99 | if (textView != null) currentItem.setDescription(getStringOrNull(textView));
100 |
101 | textView = (EditText) gui.findViewById(R.id.link);
102 | if (textView != null) currentItem.setLink(getStringOrNull(textView));
103 |
104 | textView = (EditText) gui.findViewById(R.id.latitude);
105 | if (textView != null) currentItem.setLatitude(getLatLon(textView));
106 |
107 | textView = (EditText) gui.findViewById(R.id.longitude);
108 | if (textView != null) currentItem.setLongitude(getLatLon(textView));
109 |
110 | textView = (EditText) gui.findViewById(R.id.time);
111 | if (textView != null) currentItem.setTimeOfMeasurement(IsoDateTimeParser.parse(textView.getText().toString()));
112 |
113 | textView = (EditText) gui.findViewById(R.id.zoom);
114 | if (textView != null) currentItem.setZoomMin(GeoFormatter.parseZoom (textView.getText().toString()));
115 | }
116 |
117 | private static String getStringOrNull(EditText edit) {
118 | String result = edit.getText().toString();
119 | if ((result != null) && (result.length() > 0)) return result;
120 | return null;
121 | }
122 |
123 | private static double getLatLon(EditText edit) {
124 | try {
125 | return GeoFormatter.parseLatOrLon(edit.getText().toString());
126 | } catch (ParseException e) {
127 | }
128 |
129 | return IGeoPointInfo.NO_LAT_LON;
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/java/de/k3b/android/locationMapViewer/geobmp/BookmarkListController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2021 by k3b.
3 | *
4 | * This file is part of LocationMapViewer.
5 | *
6 | * This program is free software: you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see
18 | */
19 |
20 | package de.k3b.android.locationMapViewer.geobmp;
21 |
22 | import android.content.Context;
23 | import android.view.View;
24 | import android.widget.AdapterView;
25 | import android.widget.ArrayAdapter;
26 | import android.widget.ListView;
27 |
28 | import java.util.List;
29 |
30 | import de.k3b.android.locationMapViewer.R;
31 | import de.k3b.geo.api.IGeoPointInfo;
32 | import de.k3b.geo.api.IGeoRepository;
33 | import de.k3b.geo.geobmp.BookmarkUtil;
34 |
35 | /**
36 | * Gui-type independendant handling to display/update a BookmarkList.
37 | * Should work with activity, dialog and fragment
38 | * Created by k3b on 13.04.2015.
39 | */
40 | public class BookmarkListController {
41 | private static final String BOOKMARKS_FILE_NAME = "favorites.txt";
42 |
43 | private GeoBmpDtoAndroid currentItem;
44 |
45 | public BookmarkListController setAdditionalPoints(GeoBmpDtoAndroid[] additionalPoints) {
46 | this.additionalPoints = additionalPoints;
47 | for (GeoBmpDtoAndroid template : this.additionalPoints) {
48 | BookmarkUtil.markAsTemplate(template);
49 | }
50 | return this;
51 | }
52 |
53 | interface OnSelChangedListener
54 | {
55 | void onSelChanged(GeoBmpDtoAndroid newSelection);
56 | }
57 |
58 | private final Context context;
59 | private final ListView listView;
60 | private final IGeoRepository repository;
61 | private GeoBmpDtoAndroid[] additionalPoints = null;
62 | private OnSelChangedListener selChangedListener = null;
63 |
64 | public BookmarkListController(Context context, final ListView listView) {
65 | this.context = context;
66 | this.listView = listView;
67 | this.repository = new GeoBmpFileRepository(this.context.getDatabasePath(BOOKMARKS_FILE_NAME));
68 |
69 | listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
70 | @Override
71 | public void onItemClick(AdapterView> adapterView, View view, int position, long id) {
72 | final GeoBmpDtoAndroid currenSelection = (GeoBmpDtoAndroid) listView.getItemAtPosition(position);
73 | setCurrentItem(currenSelection);
74 | }
75 | });
76 | /* does not work: onItemSelected is never called
77 | listView.setItemsCanFocus(true);
78 |
79 | listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
80 | @Override
81 | public void onItemSelected(AdapterView> adapterView, View childView,
82 | int position, long id) {
83 | onSelChanged((GeoBmpDtoAndroid) listView.getItemAtPosition(position));
84 | }
85 |
86 | @Override
87 | public void onNothingSelected(AdapterView> adapterView) {
88 | onSelChanged(null);
89 | }
90 | });
91 | */
92 | // this.registerForContextMenu(listView);
93 |
94 | }
95 |
96 | public void setSelChangedListener(OnSelChangedListener selChangedListener) {
97 | this.selChangedListener = selChangedListener;
98 | }
99 |
100 | public BookmarkListController reloadGuiFromRepository() {
101 | final ArrayAdapter adapter = GeoBmpListAdapter.createAdapter(this.context,
102 | R.layout.geobmp_list_view_row, repository, additionalPoints);
103 | this.listView.setAdapter(adapter);
104 | this.setCurrentItem(adapter.isEmpty() ? null : adapter.getItem(0));
105 | return this;
106 | }
107 |
108 |
109 | public void setCurrentItem(GeoBmpDtoAndroid newSelection) {
110 | final GeoBmpListAdapter listAdapter = (GeoBmpListAdapter) this.listView.getAdapter();
111 | listAdapter.setCurrentSelecion(newSelection);
112 |
113 | this.currentItem = newSelection;
114 |
115 | if (selChangedListener != null) {
116 | selChangedListener.onSelChanged(newSelection);
117 | }
118 | }
119 |
120 | public GeoBmpDtoAndroid getCurrentItem() {
121 | return currentItem;
122 | }
123 |
124 | public void update(IGeoPointInfo geoPointInfo) {
125 | if (BookmarkUtil.isValid(geoPointInfo)) {
126 | GeoBmpDtoAndroid item = (GeoBmpDtoAndroid) geoPointInfo;
127 | if (BookmarkUtil.isNew(item)) {
128 | item.setId(repository.createId());
129 | List items = this.repository.load();
130 | items.add(0, item);
131 | }
132 | this.repository.save();
133 | this.reloadGuiFromRepository();
134 | }
135 | }
136 |
137 | public void deleteCurrent() {
138 | repository.delete(currentItem);
139 | reloadGuiFromRepository();
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/layout/geobmp_edit.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
25 |
29 |
30 |
37 |
38 |
45 |
52 |
53 |
60 |
66 |
67 |
74 |
80 |
81 |
88 |
94 |
95 |
102 |
109 |
110 |
117 |
123 |
124 |
131 |
137 |
138 |
145 |
154 |
155 |
--------------------------------------------------------------------------------
/geoIntentDemo/src/main/res/layout/activity_geo_intent_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
13 |
23 |
32 |
33 |
42 |
43 |
52 |
53 |
63 |
64 |
73 |
74 |
84 |
85 |
96 |
97 |
103 |
109 |
110 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/geoIntentDemo/src/main/java/de/k3b/android/locationMapViewer/demo/GeoIntentDemoActivity.java:
--------------------------------------------------------------------------------
1 | package de.k3b.android.locationMapViewer.demo;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 | import android.os.Bundle;
7 | import android.view.Menu;
8 | import android.view.MenuItem;
9 | import android.view.View;
10 | import android.widget.Button;
11 | import android.widget.EditText;
12 | import android.widget.TextView;
13 | import android.widget.Toast;
14 |
15 | /**
16 | * This is a demo app for the LocationMapViewer intent interface.
17 | */
18 | public class GeoIntentDemoActivity extends Activity {
19 | private static final int ACTION_ID = 4711;
20 | private String appName;
21 | private EditText editMime;
22 | private EditText editUri;
23 | private EditText editTitle;
24 | private EditText editPois;
25 |
26 | /** Greate the gui to enter the parameters for LocationMapViewer. */
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | setContentView(R.layout.activity_geo_intent_demo);
31 | appName = getString(R.string.app_name) + ":";
32 |
33 | Button rundDemoView = (Button) findViewById(R.id.runDemo);
34 | Button rundDemoPick = (Button) findViewById(R.id.runDemoPick);
35 | editMime = (EditText) findViewById(R.id.editMime);
36 | editUri = (EditText) findViewById(R.id.editUri);
37 | editTitle = (EditText) findViewById(R.id.editTitle);
38 | editPois = (EditText) findViewById(R.id.editPOIs);
39 |
40 | rundDemoPick.setOnClickListener(new View.OnClickListener() {
41 | @Override
42 | public void onClick(View v) {
43 | startDemo(Intent.ACTION_PICK);
44 | }
45 | });
46 | rundDemoView.setOnClickListener(new View.OnClickListener() {
47 | @Override
48 | public void onClick(View v) {
49 | startDemo(null);
50 | }
51 | });
52 | }
53 |
54 | /** Gui dependant code */
55 | protected void startDemo(String action) {
56 | String uriString = editUri.getText().toString(); // "geo:53.2,8.8?q=(name)&z=1";
57 | String mimeString = editMime.getText().toString(); // null or */*
58 | if ((mimeString != null) && (mimeString.length() == 0)) mimeString = null;
59 | String title = editTitle.getText().toString(); // Example "where did you take the photo"
60 | String pois = editPois.getText().toString().trim();
61 |
62 |
63 | startDemo(uriString, mimeString, action, title, pois);
64 |
65 |
66 | /*
67 | startmapIntent("geo:53.2,8.8?q=(name)&z=1", null, Intent.ACTION_PICK, "where did you take the photo",
68 | "\n" +
69 | "");
72 | */
73 | }
74 |
75 | /**
76 | * Gui independant code: Shows how the LocationMapViewer (or other compatible apps) can be called.
77 | * @param uriString i.e. "geo:54.0,8.0?q=(Hello)"
78 | * @param mimeString i.e. null
79 | * @param action i.e. "android.intent.action.VIEW" or "android.intent.action.PICK"
80 | * @param title i.e. "where did you take the photo" or null
81 | */
82 | private void startDemo(String uriString, String mimeString, String action, String title, String pois) {
83 | Uri uri = Uri.parse(uriString);
84 | Intent mapIntent = new Intent();
85 | if (action != null) {
86 | mapIntent.setAction(action);
87 | }
88 |
89 | if ((title != null) && (title.length() > 0)) {
90 | mapIntent.putExtra(Intent.EXTRA_TITLE, title);
91 | }
92 |
93 | if ((pois != null) && (pois.length() > 0)) {
94 | mapIntent.putExtra("de.k3b.POIS", pois);
95 | }
96 |
97 | mapIntent.setDataAndType(uri, mimeString);
98 | Toast.makeText(this, appName + "Starting " + uriString + "-" + mapIntent.getType(), Toast.LENGTH_SHORT).show();
99 | try {
100 | startActivityForResult(Intent.createChooser(mapIntent,"Choose app to show location"), ACTION_ID);
101 | } catch (Exception e) {
102 | Toast.makeText(this, appName + e.getMessage(), Toast.LENGTH_SHORT).show();
103 | e.printStackTrace();
104 | }
105 | }
106 |
107 | /** Optional: Process the result location of the geo-picker */
108 | @Override
109 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
110 | String resultIntent = getUri(data);
111 | super.onActivityResult(requestCode, resultCode, data);
112 | final String result = "got result " + resultIntent;
113 | Toast.makeText(this, appName + result, Toast.LENGTH_LONG).show();
114 | TextView lastResult = (TextView) findViewById(R.id.labelLastResult);
115 | lastResult.setText(result);
116 | }
117 |
118 | private static String getUri(Intent src) {
119 | final Uri uri = (src != null) ? src.getData() : null;
120 | if (uri != null) return uri.toString();
121 |
122 | String intentUri = (src != null) ? src.toUri(Intent.URI_INTENT_SCHEME) : null;
123 | return intentUri;
124 | }
125 |
126 | @Override
127 | public boolean onCreateOptionsMenu(Menu menu) {
128 | // Inflate the menu; this adds items to the action bar if it is present.
129 | getMenuInflater().inflate(R.menu.menu_geo_intent_demo, menu);
130 | return true;
131 | }
132 |
133 | @Override
134 | public boolean onOptionsItemSelected(MenuItem item) {
135 | // Handle action bar item clicks here. The action bar will
136 | // automatically handle clicks on the Home/Up button, so long
137 | // as you specify a parent activity in AndroidManifest.xml.
138 | int id = item.getItemId();
139 |
140 | //noinspection SimplifiableIfStatement
141 | if (id == R.id.action_settings) {
142 | return true;
143 | }
144 |
145 | return super.onOptionsItemSelected(item);
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/LocationMapViewer/src/main/res/layout/mapview.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
25 |
26 |
27 |
31 |
40 |
50 |
51 |
59 |
60 |
66 |
67 |
68 |
76 |
77 |
78 |
86 |
87 |
97 |
98 |
99 |
102 |
111 |
112 |
115 |
116 |
117 |
122 |
123 |
128 |
129 |
134 |
135 |
136 |
137 |
138 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------