89 Commits
Author SHA1 Message Date
handte 21fbca36fe Update to 1.0.8-SNAPSHOT.
LocationBasedServices/maptology/pipeline/head This commit looks good
2021-06-30 21:44:44 +02:00
handte cb507e9a8c Release 1.0.7
LocationBasedServices/maptology/pipeline/head This commit looks good
2021-06-30 21:43:22 +02:00
handte e32460116f Fix linting issues, add dark theme.
LocationBasedServices/maptology/pipeline/head This commit looks good
2021-06-30 21:35:58 +02:00
handte cfb2fcbe2f Update app permissions to support Android 10 and 11.
LocationBasedServices/maptology/pipeline/head This commit looks good
2021-06-30 20:20:06 +02:00
handte 4ea3d60932 Adjust deployment paths to new servers.
LocationBasedServices/maptology/pipeline/head This commit looks good
2021-05-17 13:35:02 +02:00
handte 6c4ca9d622 Add background localization permission.
LocationBasedServices/maptology/pipeline/head This commit looks good
2021-02-15 21:13:34 +01:00
handte 62d0331a32 Fix comment.
LocationBasedServices/maptology/pipeline/head This commit looks good
2021-01-26 00:15:12 +01:00
handte 5553dd4757 Remove artifactory plugin from gradle build.
LocationBasedServices/maptology/pipeline/head This commit looks good
2021-01-25 23:14:00 +01:00
handte 3f89f50492 Remove string interpolation in jenkinsfile.
LocationBasedServices/maptology/pipeline/head This commit looks good
2021-01-25 22:55:04 +01:00
handte b96615419e Replace artifactory deployment with nexus.
LocationBasedServices/maptology/pipeline/head This commit looks good
2021-01-25 22:44:44 +01:00
handte e1b5c70fb7 Switch to maven repo to nexus.
LocationBasedServices/maptology/pipeline/head This commit looks good
2021-01-25 22:15:03 +01:00
handte 11f5d372b6 Upgrade to Angular 11.
LocationBasedServices/maptology/pipeline/head This commit looks good
Upgrade dependencies to Angular 11.
Replace saturn date range picker with new material component.
2020-12-17 23:44:03 +01:00
handte bbe51ebbf4 Update Android app, fix linting issues, reduce build time.
LocationBasedServices/maptology/pipeline/head This commit looks good
2020-12-17 22:20:19 +01:00
handte 8319f56304 Rename projects in Eclipse.
LocationBasedServices/maptology/pipeline/head This commit looks good
2020-12-11 19:15:07 +01:00
Marcus Handte e9704b46f6 Update Android plugin, fix deprecation warnings in login module.
LocationBasedServices/maptology/pipeline/head This commit looks good
2020-08-16 12:30:14 +02:00
handte 34a98136be Update to 1.0.7-SNAPSHOT.
LocationBasedServices/maptology/pipeline/head This commit looks good
2020-08-13 12:03:14 +02:00
handte f8d1a96d0b Release 1.0.6
LocationBasedServices/maptology/pipeline/head This commit looks good
2020-08-13 12:01:57 +02:00
handte c5b69a12e7 Update to 1.0.6-SNAPSHOT.
LocationBasedServices/maptology/pipeline/head This commit looks good
2020-08-13 11:02:33 +02:00
handte 08db82b1f7 Release 1.0.5
LocationBasedServices/maptology/pipeline/head This commit looks good
2020-08-13 11:01:02 +02:00
handte fcd899f25f Change carta urls to point to local installation.
LocationBasedServices/maptology/pipeline/head This commit looks good
2020-08-13 10:21:52 +02:00
Marcus Handte 85c026fa8f Upgrade gradle, plugins, android dependencies and angular code generator.
LocationBasedServices/maptology/pipeline/head This commit looks good
Upgrade gralde to latest version recommended by android studio.
Remove outdated android options in gradle properties.
Upgrade outdated gradle plugins to support npm downloads.
Upgrade android app dependencies to latest versions.
Make logger service constants static final.
Replace angular client generator with swagger codegen.
Adapt angular code to new client.
Integrate proxy config and basehref into angular cli configuration.
Change jenkinsfile to only deploy releases.
Change jenkinsfile to use gradle wrapper instead of fixed version.
Remove dots from user emails to not confuse simple email clients.
2020-06-20 10:28:43 +02:00
handte 8f7aeec0ab Update deployment location, add tools.
LocationBasedServices/maptology/pipeline/head This commit looks good
2020-05-01 00:10:59 +02:00
handte d3ba3f570a Rename public tables.
LocationBasedServices/maptology/master This commit looks good
2020-04-23 23:24:44 +02:00
handte 3c63e9530f Rename timestamp columns.
LocationBasedServices/maptology/master This commit looks good
2020-04-23 22:23:56 +02:00
handte cc66a682f0 Added column length definitions.
LocationBasedServices/maptology/master This commit looks good
2020-04-23 21:27:06 +02:00
Adriano Markovic f5691ef3a3 [66] #REFACTOR 'layout: user'
LocationBasedServices/maptology/angular-layout-refactoring This commit looks good
LocationBasedServices/maptology/master This commit looks good
{Added css flex classes.}
2020-03-18 13:04:09 +01:00
Adriano Markovic 8e3dc80fb8 [66] #REFACTOR 'layout: tables'
LocationBasedServices/maptology/angular-layout-refactoring This commit looks good
{Revised layouts and solved linter issues with time-sheet.service.ts.}
2020-02-26 16:24:27 +01:00
Adriano Markovic 20108b282d [66] #REFACTOR 'layout: user'
LocationBasedServices/maptology/angular-layout-refactoring This commit looks good
{Layout revised.}
2020-02-26 13:24:50 +01:00
Adriano Markovic aac6c5f5f3 [66] #REFACTOR 'layout: export'
{Revised the layout of the exort component.}
2020-02-26 12:05:52 +01:00
Adriano Markovic 3b644cece3 [66] #REFACTOR 'Layout: tables'
{Table view layout revised.}
2020-02-26 11:36:05 +01:00
Adriano Markovic 6b5f01a573 [66] #REFACTOR 'layout: privileges'
{Layout revised. Added content-layout.}
2020-02-26 11:13:07 +01:00
Adriano Markovic 98212476f4 Removed old templates. 2020-02-26 10:36:08 +01:00
Adriano Markovic eac84438f1 [66] #REFACTOR 'Component Renamed' 2020-02-26 10:34:01 +01:00
Adriano Markovic dfacfd4ff4 [66] #REFACTOR 'layout: notices'
LocationBasedServices/maptology/angular-layout-refactoring This commit looks good
{Revised layout.}
2020-02-25 21:06:56 +01:00
Adriano Markovic 301578f241 [66] #REFACTOR 'layout: timesheet'
{Revised layout.}
2020-02-25 21:05:59 +01:00
Adriano Markovic 41dc0030c3 [misc] #REFACTOR 'layout: drawer'
{Moved the timesheet nav button up.}
2020-02-25 21:04:46 +01:00
Adriano Markovic 73ea8185a4 [66] #IMPLEMENT 'layout: header'
{Implemented the layout header layout and revised the basic layout.}
2020-02-25 21:03:52 +01:00
Adriano Markovic ff89c9a7cc [66] #REFACTOR 'component:time-sheet'
LocationBasedServices/maptology/angular-layout-refactoring This commit looks good
{Layout revised.}
2020-02-19 22:08:28 +01:00
Adriano Markovic 7451e492c6 [66] #IMPLEMENT 'component:basic-layout'
{Basic layout component added and global stylesheet revised. }
2020-02-19 22:07:04 +01:00
Adriano Markovic cf1cdb653b [65] #CLEANUP
LocationBasedServices/maptology/master This commit looks good
LocationBasedServices/maptology/angular-time-sheet-feature This commit looks good
2020-02-14 19:59:21 +01:00
Adriano Markovic 850f8add53 [ng9-UPG] 'Update ngx-gauge' 2020-02-14 19:31:29 +01:00
Adriano Markovic 0d577ee938 [ng9-UPG] 'Update @angular/flex-layout' 2020-02-14 19:25:31 +01:00
Adriano Markovic fc7f9f0ed4 [ng9-UPG] 'Update @angular/material' 2020-02-14 19:16:15 +01:00
Adriano Markovic 6d140284fa [ng9-UPG] 'Update core & cli to Angular 9' 2020-02-14 18:40:29 +01:00
Adriano Markovic 4e31cdcad7 [ng9-UPG] 'Update core@8 & cli@8' 2020-02-14 18:07:07 +01:00
Adriano Markovic 2d1bf8a3bc Merge branch 'angular-time-sheet-feature'
LocationBasedServices/maptology/master This commit looks good
2020-02-14 17:28:27 +01:00
Adriano Markovic c49fe8fcb4 #REFACTOR 'Drawer Component'
{Changed mat-list -> mat-nav-list.}
2020-02-14 17:23:19 +01:00
Adriano Markovic cf74b4fdc8 [65] #IMPLEMENT 'Time capping function'
LocationBasedServices/maptology/angular-time-sheet-feature This commit looks good
{- Finished the time capping functionality which subtracts the break time from the working time if there has been no time gaps.
 - Documented and cleaned up the code.}
2020-02-14 16:37:16 +01:00
Adriano Markovic bf90db3620 [65] #REFACTOR 'Layout and Service'
LocationBasedServices/maptology/angular-time-sheet-feature This commit looks good
{- Layout completely revised. Responsivness is now done through flex box.
 - TimeSheetService functions cleaned up.}
2020-02-14 02:04:39 +01:00
Adriano Markovic 6bd1076e75 [65] #IMPLEMENT 'Export Functionality'
LocationBasedServices/maptology/angular-time-sheet-feature This commit looks good
{- Export function added (.csv, .json).
 - Minor fixes in layout and code. }
2020-02-12 23:52:14 +01:00
Adriano Markovic 0772ea42d8 [65] #FIX 'function: TimeSheetData Accumulation'
LocationBasedServices/maptology/angular-time-sheet-feature This commit looks good
{Fixed the issue with the wrong accumulation of the time sheet data.}
2020-02-11 15:13:09 +01:00
Adriano Markovic 751f3f17e6 [65] #REFACTORE 'service:TimeSheetService'
LocationBasedServices/maptology/angular-time-sheet-feature This commit looks good
{ Refactored mapV2TsByDay method.
  Used higher-order array methods to map visits to time sheets. }
2020-01-28 15:39:10 +01:00
Adriano Markovic 7885c7bb3c [65] #FIX 'service:TimeSheetService'
LocationBasedServices/maptology/angular-time-sheet-feature This commit looks good
{ Problem with wrong calculated working time after grouping data by days fixed. }
2020-01-27 01:09:56 +01:00
Adriano Markovic 899b651ab1 [65] #FIX 'service:TimeSheetService'
{ Fixed problem with overlapping days. }
2020-01-26 22:28:54 +01:00
Adriano Markovic 4d40e47492 [65] #IMPLEMENT 'service:TimeSheetService'
LocationBasedServices/maptology/angular-time-sheet-feature This commit looks good
{ Adde a single and grouped mapping functionality to the time sheet table. }
2020-01-22 23:08:12 +01:00
Adriano Markovic 281831dbc9 [65] #IMPLEMENT 'service:TimeSheetService'
LocationBasedServices/maptology/angular-time-sheet-feature This commit looks good
{ Started implementing the service for the time sheet feature and revised the layout. }
2020-01-21 22:25:27 +01:00
Adriano Markovic 2e9107dbc0 [65] #REFACTORE 2020-01-16 16:57:20 +01:00
Adriano Markovic fa4714169a [65] #IMPLEMENT 'component:PlacesDialog'
LocationBasedServices/maptology/angular-time-sheet-feature This commit looks good
{ Implemented dialog widget for picking out places which are returned to the time-sheet view as a list. }
2020-01-16 04:58:41 +01:00
Adriano Markovic 3ff2bf8d21 [misc] #FIX 'localization'
LocationBasedServices/maptology/angular-time-sheet-feature This commit looks good
{ Fixed label naming }
2020-01-15 08:20:06 +01:00
Marcus Handte b728be2f86 Migrate to jakarta-ee 8 apis.
LocationBasedServices/maptology/master This commit looks good
2020-01-09 23:55:16 +01:00
Adriano Markovic d10ceef29b [65] #IMPLEMENT 'component:TimeSheet'
LocationBasedServices/maptology/angular-time-sheet-feature This commit looks good
{ Created the TimeSheetComponent and the .html-Layout }
2020-01-09 00:27:36 +01:00
Adriano Markovic 92f7027ca4 Added localization to the chart widget of the devices-position view.
LocationBasedServices/maptology/master This commit looks good
2020-01-07 08:16:11 +01:00
Adriano Markovic afe4776f59 Merge branch 'master' of https://project.nes.uni-due.de/gitea/lbs/maptology
LocationBasedServices/maptology/master This commit looks good
2020-01-05 21:27:58 +01:00
Adriano Markovic 06fb703f31 Implemented chart widget and added it to the device-positions view. 2020-01-05 21:27:33 +01:00
Marcus Handte a1fc342862 Add documenation and cleanup code.
LocationBasedServices/maptology/master This commit looks good
2019-12-05 21:19:07 +01:00
Marcus Handte ac06575858 Added simple analysis tools.
LocationBasedServices/maptology/master This commit looks good
2019-12-05 21:16:48 +01:00
handte 58485d2db2 Add missing version to ejb jar manifest.
LocationBasedServices/maptology/master This commit looks good
2019-11-30 23:49:51 +01:00
handte 0abb3e2663 Fix api version and description.
LocationBasedServices/maptology/master This commit looks good
2019-11-30 23:31:03 +01:00
handte 9c2934926f Updated and customized swagger ui.
LocationBasedServices/maptology/master This commit looks good
2019-11-30 23:00:44 +01:00
Marcus Handte 9a9bc07051 Change url and redeploy.
LocationBasedServices/maptology/master This commit looks good
2019-11-30 12:53:34 +01:00
handte bf635a00ed Fix url.
LocationBasedServices/maptology/master This commit looks good
2019-11-30 12:28:54 +01:00
handte 4c5ff0d9e1 Update swagger ui.
LocationBasedServices/maptology/master This commit looks good
2019-11-30 12:17:45 +01:00
Marcus Handte 80f3195e32 Update to 1.0.5-SNAPSHOT.
LocationBasedServices/maptology/master This commit looks good
2019-11-26 16:19:18 +01:00
handte 524802d209 Release 1.0.4
LocationBasedServices/maptology/master This commit looks good
2019-11-26 15:39:31 +01:00
Marcus Handte 95116a30fd Bugfix in app, disallow devices to use position service.
LocationBasedServices/maptology/master This commit looks good
2019-11-19 22:24:31 +01:00
Marcus Handte 077cecb670 Change device update api, add tests, fix version, add migration.
LocationBasedServices/maptology/master This commit looks good
2019-11-19 19:06:02 +01:00
Marcus Handte 6e5c90acd9 Finished data logger, fix position bean bug.
LocationBasedServices/maptology/master This commit looks good
2019-11-18 21:39:50 +01:00
Marcus Handte c2b52164d9 Downgrade broken gradle plugin.
LocationBasedServices/maptology/master This commit looks good
2019-11-18 15:26:46 +01:00
Marcus Handte efd893de8a Continued logger implementation.
LocationBasedServices/maptology/master This commit looks good
2019-11-11 18:18:16 +01:00
Marcus Handte 5ab1224dcf Change code generators, fix regression.
LocationBasedServices/maptology/master This commit looks good
2019-11-09 23:39:48 +01:00
Marcus Handte 7da98783c4 Update oss plugin, reduce dex memory consumption.
LocationBasedServices/maptology/master This commit looks good
Switch oss gradle plugin to custom build to get rid of warnings.
Reduce dex memory from 1g to 512m to avoid out of memory issues.
2019-11-09 22:27:33 +01:00
Marcus Handte 3447709f01 Upgrade android gradle plugin.
LocationBasedServices/maptology/master This commit looks good
2019-11-09 20:58:36 +01:00
handte 509baeaf00 Removed buildSrc, continued implementation of logger.
LocationBasedServices/maptology/master This commit looks good
Removed buildSrc to speed up Android plugin.
Refactored position service and added more logger code.
2019-11-01 18:23:01 +01:00
handte 72767c4a87 Added scientist integration, fixes for daylight savings time.
LocationBasedServices/maptology/master This commit looks good
Extended role management to support scientist role.
Added user interface to let scientists and admins view individual position updates.
Modified date computation to fix issues with daylight savings time.
2019-10-30 12:33:13 +01:00
handte f1d01741f6 Extended position service for data logging.
LocationBasedServices/maptology/master This commit looks good
Added endpoints and database extensions for data logging.
Renamed history service api to match position api.
Changed web app to use new api.
Switched android minifier from proguard to r8.
Added delta codec for sensor data compression.
Started implementing data logger service (unfinished).
2019-10-29 17:49:05 +01:00
Marcus Handte 7b5d96f6b9 Fixed test instabilities, added android eclipse plugin.
LocationBasedServices/maptology/master This commit looks good
2019-10-25 10:08:42 +02:00
handte 7085f910f7 Fix deployment path name.
LocationBasedServices/maptology/master This commit looks good
2019-09-18 16:11:32 +02:00
Marcus Handte c2e25c0945 Change deployment directories.
LocationBasedServices/maptology/master This commit looks good
2019-09-18 14:30:49 +02:00
Marcus Handte 2f2de2eba7 Update to 1.0.4-SNAPSHOT
LocationBasedServices/maptology/master This commit looks good
2019-09-13 21:54:31 +02:00
285 changed files with 22421 additions and 2083 deletions
Vendored
+16 -28
View File
@@ -3,13 +3,6 @@
// this groovy script is executed by jenkins
node {
def gradleInfo
def server = Artifactory.server 'project.nes.uni-due.de'
def gradleBuild = Artifactory.newGradleBuild()
gradleBuild.tool = 'gradle-5.5.1'
gradleBuild.usesPlugin = true
environment {
ANDROID_SDK_ROOT = '/var/lib/android-sdk'
}
@@ -21,49 +14,44 @@ node {
}
def version = ''
def release = false
// configure the deployer based on the version
stage('Configure') {
version = sh(returnStdout: true, script: "./gradlew properties -q | grep \"version:\" | awk '{print \$2}'", label: "Detecting project version.").trim()
println "Version is: '${version}'"
if (version.endsWith("-SNAPSHOT")) {
println "Using internal-snapshots for publication."
gradleBuild.deployer server: server, repo: 'internal-snapshots'
} else {
println "Using internal-releases for publication."
gradleBuild.deployer server: server, repo: 'internal-releases'
}
println "Version is: '${version}'"
release = (! version.endsWith("-SNAPSHOT"))
}
// build the source code with gradle
stage('Build') {
withCredentials([string(credentialsId: 'maptology-keystore-password', variable: 'PASSWD')]) {
def switches = "-Djenkins.build.number=${env.BUILD_NUMBER} -Dandroid.keystore.password=${PASSWD}".toString()
gradleInfo = gradleBuild.run buildFile: 'build.gradle', tasks: 'clean build', switches: switches
sh(script: './gradlew -Djenkins.build.number=' + env.BUILD_NUMBER + ' -Dandroid.keystore.password=$PASSWD clean build', label: "Building project.")
}
}
// deploy the maven publications to artifactory
// deploy the maven publications to nexus
stage ('Publish') {
if (env.BRANCH_NAME == "master") {
withCredentials([string(credentialsId: 'maptology-keystore-password', variable: 'PASSWD')]) {
def switches = "-Djenkins.build.number=${env.BUILD_NUMBER} -Dandroid.keystore.password=${PASSWD}".toString()
gradleInfo = gradleBuild.run buildFile: 'build.gradle', tasks: 'artifactoryPublish', switches: switches
}
withCredentials([string(credentialsId: 'jenkins-nexus-password', variable: 'NEXUS')]) {
withCredentials([string(credentialsId: 'maptology-keystore-password', variable: 'PASSWD')]) {
sh(script: './gradlew -Djenkins.build.number=' + env.BUILD_NUMBER + ' -Dandroid.keystore.password=$PASSWD -Djenkins.nexus.password=$NEXUS publishAllPublicationsToMavenRepository', label: "Publishing project.")
}
}
} else {
echo "Skipping deployment for non-master branch."
echo "Skipping publication for non-master branch."
}
}
// deploy the build output on the server
stage ('Deploy') {
if (env.BRANCH_NAME == "master") {
withCredentials([sshUserPrivateKey(credentialsId: "maptology-server-key", keyFileVariable: "keyfile")]) {
sh "scp -i ${keyfile} site-ear/build/libs/site-ear-${version}.ear wildfly@srv.nes.uni-due.de:~/standalone/deployments/maptology.ear"
sh "scp -i ${keyfile} android-app/build/outputs/apk/release/*.apk wildfly@srv.nes.uni-due.de:/opt/android/"
if (env.BRANCH_NAME == "master" && release) {
withCredentials([sshUserPrivateKey(credentialsId: "maptology-server-key", keyFileVariable: "KEYFILE")]) {
sh 'scp -i $KEYFILE site-ear/build/libs/site-ear-' + version + '.ear wildfly@apps-pro.nes.uni-due.de:/opt/wildfly-21-maptology/standalone/deployments/maptology.ear'
sh 'scp -i $KEYFILE android-app/build/outputs/apk/release/*.apk wildfly@apps-pro.nes.uni-due.de:/opt/android/maptology/'
}
} else {
echo "Skipping deployment for non-master branch."
echo "Skipping deployment for non-master branch or non-release build."
}
}
+17 -13
View File
@@ -3,12 +3,12 @@ description = "Maptology Android App"
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation project(":android-feign")
implementation "androidx.legacy:legacy-support-v4:${versionAndroidx}"
implementation "androidx.appcompat:appcompat:${versionAndroidx}"
implementation "androidx.preference:preference:${versionAndroidx}"
implementation "androidx.cardview:cardview:${versionAndroidx}"
implementation "androidx.recyclerview:recyclerview:${versionAndroidx}"
implementation "com.google.android.material:material:${versionAndroidx}"
implementation "androidx.legacy:legacy-support-v4:${versionAndroidxLegacy}"
implementation "androidx.appcompat:appcompat:${versionAndroidxCompat}"
implementation "androidx.preference:preference:${versionAndroidxPreference}"
implementation "androidx.cardview:cardview:${versionAndroidxCard}"
implementation "androidx.recyclerview:recyclerview:${versionAndroidxRecycler}"
implementation "com.google.android.material:material:${versionAndroidxMaterial}"
implementation "com.google.android.gms:play-services-oss-licenses:${versionPlay}"
testImplementation "junit:junit:${versionJunit}"
testImplementation "org.robolectric:robolectric:${versionRobolectric}"
@@ -22,12 +22,12 @@ configurations {
}
android {
compileSdkVersion 28
compileSdkVersion 30
defaultConfig {
applicationId "com.maptology.android.app"
minSdkVersion 14
targetSdkVersion 28
versionCode 8
targetSdkVersion 30
versionCode 13
versionName "${version}"
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -47,7 +47,6 @@ android {
buildTypes {
release {
useProguard false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// add signing config if key is provided via system property
@@ -73,13 +72,18 @@ android {
disable 'RtlSymmetry', 'RelativeOverlap'
// abortOnError false
}
dexOptions {
javaMaxHeapSize "512m"
}
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
tasks.register('makeEclipseDir') {
doLast {
file('build/generated/source/aidl/debug').mkdirs();
file('build/generated/source/r/debug').mkdirs();
file('build/generated/source/aidl/debug').mkdirs()
file('build/generated/source/r/debug').mkdirs()
}
}
+8 -1
View File
@@ -7,6 +7,7 @@
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
@@ -64,11 +65,17 @@
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<receiver android:name=".UpdateReceiver">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter>
</receiver>
<receiver android:name=".NoticeReceiver" android:exported="false">
<intent-filter>
<action android:name="com.maptology.android.app.NOTICE_SYNC"/>
</intent-filter>
</receiver>
<service android:name=".LocationService"/>
<service android:name=".LocationService"/>
<service android:name=".LoggerService"/>
</application>
</manifest>
@@ -0,0 +1,306 @@
package com.maptology.android.app;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.location.LocationManager;
import android.os.BatteryManager;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
import androidx.core.content.pm.PackageInfoCompat;
import com.maptology.android.app.task.UploadLocationTask;
import com.maptology.android.feign.model.Coordinate;
import com.maptology.android.feign.model.DeviceHandle;
/**
* An abstract base class for the location and logger
* service to share common functions without duplicating
* code.
*
* @author Marcus
*/
public abstract class AbstractService extends Service {
/**
* The channel id of the localization channel.
*/
private static final String CHANNEL_ID = "localization";
/**
* The application.
*/
protected MaptologyApp app;
/**
* The location manager to capture locations.
*/
protected LocationManager locationManager;
/**
* The handler to process timeouts in the ui thread.
*/
protected Handler handler;
@Nullable
@Override
public IBinder onBind(Intent intent) {
// nothing to bind to
return null;
}
@Override
public void onCreate() {
super.onCreate();
handler = new Handler();
app = (MaptologyApp)getApplicationContext();
createNotificationChannel(app);
locationManager = (LocationManager)getSystemService(LOCATION_SERVICE);
}
/**
* Determines whether the location is sharable.
*
* @return True if sharable, false otherwise.
*/
protected boolean isSharable() {
return app.getRepository().isSharable();
}
/**
* Determines whether the location is analyzable.
*
* @return True if analyzable.
*/
protected boolean isAnalyzable() {
DeviceHandle handle = app.getRepository().deviceHandle.getValue();
boolean hasUser = handle != null && handle.getUser() != null;
return hasUser && app.getRepository().isAnalyzeable();
}
/**
* Returns the app version or -1 if an error occurs.
*
* @return The app version.
*/
protected long getVersion() {
try {
PackageInfo info = this.getPackageManager().getPackageInfo(getPackageName(), 0);
return PackageInfoCompat.getLongVersionCode(info);
} catch (PackageManager.NameNotFoundException e) {
return -1;
}
}
/**
* Determines whether the gps provider can be used.
*
* @return True if gps is available, enabled and we have all permissions.
*/
protected boolean canUseGps() {
boolean gps = app.getRepository().canUseGps();
return gps && canUseProvider(LocationManager.GPS_PROVIDER);
}
/**
* Determines whether a particular location provider can be used.
*
* @param provider The provider.
* @return True if we have all permissions and the provider is available and enabled.
*/
protected boolean canUseProvider(String provider) {
return hasLocationPermissions() && locationManager.getAllProviders().contains(provider);
}
/**
* Determines whether the app has the permissions to capture location.
*
* @return True if the app has permission to capture locations.
*/
protected boolean hasLocationPermissions() {
return ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED &&
ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
}
/**
* Updates the coordinate displayed in the user interface.
*
* @param longitude The longitude.
* @param latitude The latitude.
*/
protected void setCoordinate(double longitude, double latitude) {
Coordinate c = new Coordinate();
c.setLatitude(latitude);
c.setLongitude(longitude);
app.getRepository().gpsPosition.setValue(c);
}
/**
* Updates the locations, if an upload task is not running already.
*/
protected void onUploadUpdates() {
// upload the location, if the upload is not yet running
boolean uploading = app.getRepository().uploadingLocations.getValue();
DeviceHandle handle = app.getRepository().deviceHandle.getValue();
updateNotification(R.string.localization_notification_upload);
if (!uploading && handle != null ) {
UploadLocationTask task = new UploadLocationTask(app);
task.execute();
}
}
/**
* Returns the id for the foreground service notification.
*
* @return The notification id.
*/
protected abstract int getNotificationId();
/**
* Updates the foreground service notification with new text.
*
* @param content The content.
*/
protected void updateNotification(int content) {
Notification notification = getNotification(content);
NotificationManager manager = (NotificationManager)app.getSystemService(NOTIFICATION_SERVICE);
manager.notify(getNotificationId(), notification);
}
/**
* Returns the notification that is displayed during upload.
*
* @param content The notification content (res id).
* @return The notification.
*/
protected Notification getNotification(int content) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(app, CHANNEL_ID)
.setContentTitle(getText(R.string.localization_notification_title))
.setContentText(getText(content))
.setOngoing(true)
.setContentIntent(PendingIntent.getActivity(app, 445, new Intent(app, StartActivity.class), PendingIntent.FLAG_UPDATE_CURRENT))
.setSmallIcon(R.drawable.icon_notification_small);
return builder.build();
}
/**
* Creates a notification channel for the app.
*
* @param app The app to retrieve the notification manager.
*/
public static void createNotificationChannel(MaptologyApp app) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = app.getString(R.string.localization_channel_name);
String description = app.getString(R.string.localization_channel_description);
int importance = NotificationManager.IMPORTANCE_LOW;
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
channel.setDescription(description);
NotificationManager notificationManager = app.getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(channel);
}
}
/**
* Starts the service, if it is not running already.
*
* @param context The context.
*/
public static void runService(Context context) {
if (!isLocalizable(context) || !hasDevice(context)) return;
Intent intent = new Intent();
if (isLoggable(context) && isPowerCordPlugged(context)) {
intent.setClass(context, LoggerService.class);
} else {
intent.setClass(context, LocationService.class);
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
context.startService(intent);
} else {
context.startForegroundService(intent);
}
}
/**
* Stops all services unconditionally.
*
* @param context The context.
*/
public static void stopServices(Context context) {
for (Class<?> service : new Class[] { LocationService.class, LoggerService.class }) {
Intent intent = new Intent();
intent.setClass(context, service);
context.stopService(intent);
}
}
/**
* Determines whether the data logging is enabled.
*
* @param context The context.
* @return True if data logging is enabled, false otherwise.
*/
protected static boolean isLoggable(Context context) {
MaptologyApp app = (MaptologyApp)context.getApplicationContext();
return app.getRepository().isLoggable();
}
/**
* Determines whether the device localization is enabled.
*
* @param context The context.
* @return True if localization is enabled, false otherwise.
*/
protected static boolean isLocalizable(Context context) {
MaptologyApp app = (MaptologyApp)context.getApplicationContext();
return app.getRepository().isLocalizable();
}
/**
* Determines whether there is a device handle.
*
* @return True if there is a device handle, false otherwise.
*/
protected static boolean hasDevice(Context context) {
MaptologyApp app = (MaptologyApp)context.getApplicationContext();
return (app.getRepository().deviceHandle.getValue() != null);
}
/**
* Determines whether the power cord is plugged based on the
* information contained in the battery intent.
*
* @param context The context to fetch the intent.
* @return True if the power cord is plugged, false otherwise.
*/
protected static boolean isPowerCordPlugged(Context context) {
Intent intent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
int p = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
if (Build.VERSION.SDK_INT < 17) {
return p == BatteryManager.BATTERY_PLUGGED_AC ||
p == BatteryManager.BATTERY_PLUGGED_USB;
} else {
return p == BatteryManager.BATTERY_PLUGGED_AC ||
p == BatteryManager.BATTERY_PLUGGED_USB ||
p == BatteryManager.BATTERY_PLUGGED_WIRELESS;
}
}
}
@@ -28,7 +28,7 @@ public class BootReceiver extends BroadcastReceiver {
MaptologyApp app = (MaptologyApp)context.getApplicationContext();
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
NoticeReceiver.schedulePeriodicSync(app);
LocationService.runService(app);
AbstractService.runService(app);
}
}
}
@@ -5,8 +5,8 @@ import java.util.ArrayList;
import java.util.List;
import com.maptology.android.app.location.LocationState;
import com.maptology.android.app.model.Network;
import com.maptology.android.app.model.Position;
import com.maptology.android.app.location.LocationNetwork;
import com.maptology.android.app.location.LocationPosition;
import com.maptology.android.app.repository.IValueListener;
import com.maptology.android.app.repository.Value;
import com.maptology.android.app.task.UploadLocationTask;
@@ -15,13 +15,8 @@ import com.maptology.android.feign.model.DeviceHandle;
import com.maptology.android.feign.model.ReleasedLocation;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -35,12 +30,10 @@ import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.SystemClock;
import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
import androidx.core.content.pm.PackageInfoCompat;
import android.util.Log;
@@ -50,7 +43,7 @@ import android.util.Log;
*
* @author Marcus
*/
public class LocationService extends Service {
public class LocationService extends AbstractService {
/**
* The code for the alarm.
@@ -124,25 +117,11 @@ public class LocationService extends Service {
*/
private static final String TAG = "LocationService";
/**
* The channel id of the localization channel.
*/
private static final String CHANNEL_ID = "localization";
/**
* The notification id of the foreground service indicator.
*/
private static final int NOTIFICATION_ID = 5544;
/**
* The application.
*/
private MaptologyApp app;
/**
* The location manager to capture locations.
*/
private LocationManager locationManager;
/**
* The wifi manager to perform wifi scans and request wifi locks.
*/
@@ -152,11 +131,6 @@ public class LocationService extends Service {
*/
private PowerManager powerManager;
/**
* The handler to process timeouts in the ui thread.
*/
private Handler handler;
/**
* The current state of the service.
*/
@@ -165,7 +139,7 @@ public class LocationService extends Service {
/**
* The current list of networks.
*/
private List<Network> currentNetworks = null;
private List<LocationNetwork> currentNetworks = null;
/**
* The time of the last localization attempt of the service.
@@ -245,7 +219,7 @@ public class LocationService extends Service {
};
/**
* A listern that deactivates the service when the upload completes.
* A listener that deactivates the service when the upload completes.
*/
private IValueListener<Boolean> uploadListener = new IValueListener<Boolean>() {
@Override
@@ -270,23 +244,12 @@ public class LocationService extends Service {
*/
private Runnable timeoutListener = null;
@Override
public IBinder onBind(Intent intent) {
// do not support binding
return null;
}
@Override
public void onCreate() {
Log.d(TAG, "Creating location service.");
super.onCreate();
handler = new Handler();
app = (MaptologyApp) getApplicationContext();
createNotificationChannel(app);
startForeground(NOTIFICATION_ID, getNotification(R.string.localization_notification_idle));
app.getRepository().uploadingLocations.addValueListener(uploadListener);
locationManager = (LocationManager) app.getSystemService(LOCATION_SERVICE);
wifiManager = (WifiManager) app.getSystemService(WIFI_SERVICE);
wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_SCAN_ONLY, TAG);
powerManager = (PowerManager) app.getSystemService(POWER_SERVICE);
@@ -324,16 +287,22 @@ public class LocationService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (!app.getRepository().isLocalizable()) {
if (!isLocalizable(this)) {
Log.d(TAG, "Stopping since localization is disabled.");
cancelExecution(this);
stopSelf();
return START_NOT_STICKY;
} else if (!hasDeviceHandle()) {
} else if (!hasDevice(this)) {
Log.d(TAG, "Stopping since device is not available.");
cancelExecution(this);
stopSelf();
return START_NOT_STICKY;
} else if (isLoggable(this) && isPowerCordPlugged(this)) {
Log.d(TAG, "Switching to logger service.");
cancelExecution(this);
stopSelf();
runService(app);
return START_NOT_STICKY;
}
// start localization, if we are not running one already
long now = SystemClock.elapsedRealtime();
@@ -355,16 +324,6 @@ public class LocationService extends Service {
return START_STICKY;
}
/**
* Determines whether there is a device handle.
*
* @return True if there is a device handle, false otherwise.
*/
private boolean hasDeviceHandle() {
return (app.getRepository().deviceHandle.getValue() != null);
}
/**
* Triggers a state change to the next logical state of the state machine.
*/
@@ -447,7 +406,7 @@ public class LocationService extends Service {
* already.
*
* @param success True to indicate success, false to indicate
* an unrecovable failure.
* an unrecoverable failure.
*/
private void resetState(boolean success) {
currentState = LocationState.IDLE;
@@ -499,8 +458,17 @@ public class LocationService extends Service {
* @return True if gps permissions are set.
*/
private boolean hasGpsPermissions() {
return ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
List<String> permissions = new ArrayList<>();
permissions.add(Manifest.permission.ACCESS_FINE_LOCATION);
permissions.add(Manifest.permission.ACCESS_COARSE_LOCATION);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
permissions.add(Manifest.permission.ACCESS_BACKGROUND_LOCATION);
}
boolean granted = true;
for (String permission: permissions) {
granted &= ActivityCompat.checkSelfPermission(this, permission) == PackageManager.PERMISSION_GRANTED;
}
return granted;
}
/**
@@ -562,18 +530,14 @@ public class LocationService extends Service {
changeState();
} else {
Log.d(TAG, "Starting cache lookup.");
Position p = app.getLocationStore().findPosition(currentNetworks, NETWORK_MINIMUM, MAXIMUM_WIFI_DEVIATION);
LocationPosition p = app.getLocationStore().findPosition(currentNetworks, NETWORK_MINIMUM, MAXIMUM_WIFI_DEVIATION);
if (p != null) {
long now = System.currentTimeMillis();
p.setUsageTime(now);
if (isFresh(p)) {
Log.d(TAG, "Using cached location.");
// update the user interface
// update the user interface
Coordinate c = new Coordinate();
c.setLatitude(p.getLatitude());
c.setLongitude(p.getLongitude());
app.getRepository().gpsPosition.setValue(c);
setCoordinate(p.getLongitude(), p.getLatitude());
// create a release
ReleasedLocation update = createLocation();
update.setAvailability(ReleasedLocation.AvailabilityEnum.CACHED);
@@ -602,19 +566,6 @@ public class LocationService extends Service {
}
}
/**
* Updates the locations, if an upload task is not running already.
*/
private void onUploadUpdates() {
// upload the location, if the upload is not yet running
boolean uploading = app.getRepository().uploadingLocations.getValue();
DeviceHandle handle = app.getRepository().deviceHandle.getValue();
updateNotification(R.string.localization_notification_upload);
if (!uploading && handle != null ) {
UploadLocationTask task = new UploadLocationTask(app);
task.execute();
}
}
/**
* Creates an idle position update, unless we already created it.
@@ -656,7 +607,7 @@ public class LocationService extends Service {
* @param p The position to check.
* @return True if the position is young enough, false if it is too old.
*/
private boolean isFresh(Position p) {
private boolean isFresh(LocationPosition p) {
return p.getUsageTime() - p.getCreationTime() <= MAXIMUM_CACHE_DURATION;
}
@@ -702,10 +653,10 @@ public class LocationService extends Service {
* @param results The results.
*/
private void setScan(List<ScanResult> results) {
List<Network> networks = new ArrayList<>();
List<LocationNetwork> networks = new ArrayList<>();
for (ScanResult r: results) {
if (r.level >= MINIMUM_WIFI_RSSI) {
Network n = new Network();
LocationNetwork n = new LocationNetwork();
n.setBssid(r.BSSID);
n.setRssi(r.level);
networks.add(n);
@@ -726,10 +677,7 @@ public class LocationService extends Service {
if (currentState == LocationState.GPS) cleanupGps();
if (currentState == LocationState.NET) cleanupNet();
// update the user interface
Coordinate c = new Coordinate();
c.setLatitude(location.getLatitude());
c.setLongitude(location.getLongitude());
app.getRepository().gpsPosition.setValue(c);
setCoordinate(location.getLongitude(), location.getLatitude());
// create final location
ReleasedLocation update = createLocation();
update.setCoordinate(new Coordinate());
@@ -745,7 +693,7 @@ public class LocationService extends Service {
onStoreUpdate(update);
// store location in cache
if (hasMinimumNetworks()) {
Position p = new Position();
LocationPosition p = new LocationPosition();
p.setLatitude(location.getLatitude());
p.setLongitude(location.getLongitude());
p.setCreationTime(System.currentTimeMillis());
@@ -786,40 +734,6 @@ public class LocationService extends Service {
return location;
}
/**
* Determines whether the location is sharable.
*
* @return True if sharable, false otherwise.
*/
private boolean isSharable() {
return app.getRepository().isSharable();
}
/**
* Determines whether the location is analyzable.
*
* @return True if analyzable.
*/
private boolean isAnalyzable() {
DeviceHandle handle = app.getRepository().deviceHandle.getValue();
boolean hasUser = handle != null && handle.getUser() != null;
return hasUser && app.getRepository().isAnalyzeable();
}
/**
* Returns the app version or -1 if an error occurs.
*
* @return The app version.
*/
private long getVersion() {
try {
PackageInfo info = this.getPackageManager().getPackageInfo(getPackageName(), 0);
return PackageInfoCompat.getLongVersionCode(info);
} catch (PackageManager.NameNotFoundException e) {
return -1;
}
}
/**
* Determines whether the current networks exceed the minimum network threshold.
*
@@ -854,17 +768,6 @@ public class LocationService extends Service {
}
}
/**
* Determines whether the gps provider can be used.
*
* @return True if gps is available, enabled and we have all permissions.
*/
private boolean canUseGps() {
boolean gps = app.getRepository().canUseGps();
if (!gps) Log.d(TAG, "Gps is manually disabled.");
return gps && canUseProvider(LocationManager.GPS_PROVIDER);
}
/**
* Determines whether the network provider can be used.
*
@@ -882,19 +785,8 @@ public class LocationService extends Service {
* @param provider The provider.
* @return True if we have all permissions and the provider is available and enabled.
*/
private boolean canUseProvider(String provider) {
return hasLocationPermissions() && locationManager.getAllProviders().contains(provider) &&
locationManager.isProviderEnabled(provider);
}
/**
* Determines whether the app has the permissions to capture location.
*
* @return True if the app has permission to capture locations.
*/
private boolean hasLocationPermissions() {
return ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED &&
ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
protected boolean canUseProvider(String provider) {
return super.canUseProvider(provider) && locationManager.isProviderEnabled(provider);
}
/**
@@ -923,32 +815,6 @@ public class LocationService extends Service {
}
}
/**
* Starts the service, if it is not running already.
*
* @param context The context.
*/
public static void runService(Context context) {
Intent intent = new Intent();
intent.setClass(context, LocationService.class);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
context.startService(intent);
} else {
context.startForegroundService(intent);
}
}
/**
* Stops the service unconditionally.
*
* @param context The context.
*/
public static void stopService(Context context) {
Intent intent = new Intent();
intent.setClass(context, LocationService.class);
context.stopService(intent);
}
/**
* Schedules the service for the next execution.
*
@@ -996,66 +862,8 @@ public class LocationService extends Service {
}
}
/**
* Determines whether the intent is a periodic execution.
*
* @param intent The intent.
* @return True if the intent is a periodic execution by the alarm manager.
*/
private static boolean isPeriodicExecution(Intent intent) {
try {
if (intent == null) return false;
return intent.getBooleanExtra(EXTRA_ALARM, false);
} catch (Exception e) {
Log.d(TAG, "Invalid intent, cannot extract alarm although it is defined.");
return false;
}
@Override
protected int getNotificationId() {
return NOTIFICATION_ID;
}
/**
* Updates the foreground service notification with new text.
*
* @param content The content.
*/
private void updateNotification(int content) {
Notification notification = getNotification(content);
NotificationManager manager = (NotificationManager)app.getSystemService(NOTIFICATION_SERVICE);
manager.notify(NOTIFICATION_ID, notification);
}
/**
* Returns the notification that is displayed during upload.
*
* @param content The notification content (res id).
* @return The notification.
*/
private Notification getNotification(int content) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(app, CHANNEL_ID)
.setContentTitle(getText(R.string.localization_notification_title))
.setContentText(getText(content))
.setOngoing(true)
.setContentIntent(PendingIntent.getActivity(app, 445, new Intent(app, StartActivity.class), PendingIntent.FLAG_UPDATE_CURRENT))
.setSmallIcon(R.drawable.icon_notification_small);
return builder.build();
}
/**
* Creates a notification channel for the app.
*
* @param app The app to retrieve the notification manager.
*/
public static void createNotificationChannel(MaptologyApp app) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = app.getString(R.string.localization_channel_name);
String description = app.getString(R.string.localization_channel_description);
int importance = NotificationManager.IMPORTANCE_LOW;
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
channel.setDescription(description);
NotificationManager notificationManager = app.getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(channel);
}
}
}
@@ -0,0 +1,686 @@
package com.maptology.android.app;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
import android.os.PowerManager;
import android.util.Log;
import com.maptology.android.app.repository.IValueListener;
import com.maptology.android.app.repository.Value;
import com.maptology.android.app.util.DeltaCodec;
import com.maptology.android.feign.model.Coordinate;
import com.maptology.android.feign.model.ReleasedLocation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* A service for data logger configurations.
*
* @author Marcus
*/
public class LoggerService extends AbstractService {
/**
* The key for the detailed gps data.
*/
private static final String METADATA_GPS = "gps";
/**
* The key for the acceleration sensor.
*/
private static final String METADATA_ACCELEROMETER = "accel";
/**
* The key for the gyroscope.
*/
private static final String METADATA_GYROSCOPE = "gyro";
/**
* The key for the magnetometer.
*/
private static final String METADATA_MAGNETOMETER = "magnet";
/**
* The notification id of the foreground service indicator.
*/
private static final int NOTIFICATION_ID = 5545;
/**
* The log tag for the service.
*/
private static final String TAG = "LoggerService";
/**
* The tag for the cpu wakelock.
*/
private static final String WAKELOCK_TAG = "maptology:logger";
/**
* The approximate delay between two sensor values
* in milliseconds (10/sec).
*/
private static int SAMPLING_DELAY_SENSOR = 100;
/**
* The approximate delay between two gps values
* in milliseconds (1/sec).
*/
private static int SAMPLING_DELAY_GPS = 1000;
/**
* The number of digits kept for sensors.
*/
private static int PRECISION_SENSOR = 7;
/**
* The amount of time between the creation of a
* position update in milliseconds.
*/
private static int UPDATE_DELAY = 60000;
/**
* A scale factor to ensure that there are enough data bins,
* even if the update generation process is not executed at
* exactly the right frequency. 2 means that we provide twice
* as many data bins as we would require if the timing is perfect.
*/
private int UPDATE_FACTOR = 2;
/**
* A gps listener that memorizes a number of locations.
*/
private GpsListener gpsListener;
/**
* A listener that is attached to the acceleration sensor.
*/
private SensorListener accelerometerListener = new SensorListener(3, PRECISION_SENSOR, UPDATE_DELAY * UPDATE_FACTOR / SAMPLING_DELAY_SENSOR);
/**
* A listener that is attached to the gyroscope sensor.
*/
private SensorListener gyroscopeListener = new SensorListener(3, PRECISION_SENSOR, UPDATE_DELAY * UPDATE_FACTOR / SAMPLING_DELAY_SENSOR);
/**
* A listener that is attached to the magnetometer sensor.
*/
private SensorListener magnetometerListener = new SensorListener(3, PRECISION_SENSOR, UPDATE_DELAY * UPDATE_FACTOR / SAMPLING_DELAY_SENSOR);
/**
* The cpu wake lock.
*/
private PowerManager.WakeLock wakeLock;
/**
* The sensor manager.
*/
private SensorManager sensorManager;
/**
* A listener that deactivates the service when the upload completes.
*/
private IValueListener<Boolean> uploadListener = new IValueListener<Boolean>() {
@Override
public void onValueChanged(Value<Boolean> source, Boolean oldValue, Boolean newValue) {
if (!newValue) updateNotification(R.string.localization_notification_logger);
else updateNotification(R.string.localization_notification_upload);
}
};
/**
* The listener that will capture the data.
*/
private Runnable captureListener = new Runnable() {
@Override
public void run() {
onCapture();
}
};
@Override
@SuppressLint("WakelockTimeout") // the device is plugged, so we can ignore safely the energy usage
public void onCreate() {
super.onCreate();
gpsListener = new GpsListener(LocationManager.GPS_PROVIDER, UPDATE_DELAY * UPDATE_FACTOR / SAMPLING_DELAY_GPS);
startForeground(NOTIFICATION_ID, getNotification(R.string.localization_notification_logger));
app.getRepository().uploadingLocations.addValueListener(uploadListener, true);
sensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
PowerManager pm = (PowerManager)getSystemService(POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_TAG);
wakeLock.acquire();
prepareCapture();
}
/**
* Flushes all listeners and registers the listeners that are not registered
* already and can be registered due to sensor availability and schedules the
* next capturing iteration.
*/
public void prepareCapture() {
flushListeners();
registerSensorListeners();
registerGpsListener();
Log.d(TAG, "Scheduling capture operation.");
handler.postDelayed(captureListener, UPDATE_DELAY);
}
/**
* Called when the timeout expires and an update must be created,
* stored and possibly uploaded.
*/
public void onCapture() {
Log.d(TAG, "Performing capture operation.");
try {
long start = System.currentTimeMillis();
ReleasedLocation location = gpsListener.getLocation();
Map<String, String> metadata = new HashMap<>();
if (magnetometerListener.isRegistered()) metadata.put(METADATA_MAGNETOMETER, magnetometerListener.encode());
if (accelerometerListener.isRegistered()) metadata.put(METADATA_ACCELEROMETER, accelerometerListener.encode());
if (gyroscopeListener.isRegistered()) metadata.put(METADATA_GYROSCOPE, gyroscopeListener.encode());
if (gpsListener.isRegistered()) metadata.put(METADATA_GPS, gpsListener.encode());
int length = 0;
for (String s: metadata.keySet()) {
Log.d(TAG, "Metadata " + s + " size is " + metadata.get(s).length() + " bytes.");
length += metadata.get(s).length();
}
Log.d(TAG, "Total sensor data size is " + length + " bytes.");
location.setMetadata(metadata);
app.getLocationStore().addUpdate(location);
app.getRepository().lastUpdate.setValue(location);
Log.d(TAG, "Total duration for packaging is " + (System.currentTimeMillis() - start) + " ms.");
onUploadUpdates();
} finally {
if (isLocalizable(this) && isLoggable(this) && isPowerCordPlugged(this)) {
Log.d(TAG, "Preparing next capture operation.");
prepareCapture();
} else {
Log.d(TAG, "Switching to localization service.");
stopSelf();
runService(app);
}
}
}
@Override
public void onDestroy() {
app.getRepository().uploadingLocations.removeValueListener(uploadListener);
handler.removeCallbacks(captureListener);
unregisterGpsListener();
unregisterSensorListeners();
if (wakeLock.isHeld()) wakeLock.release();
stopForeground(true);
super.onDestroy();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (! isLocalizable(this)) {
Log.d(TAG, "Stopping since localization is disabled.");
stopSelf();
return START_NOT_STICKY;
} else if (!hasDevice(this)) {
Log.d(TAG, "Stopping since device is not available.");
stopSelf();
return START_NOT_STICKY;
}
return START_STICKY;
}
/**
* Executes a flush operation on all listeners.
*/
private void flushListeners() {
gpsListener.flush();
accelerometerListener.flush();
magnetometerListener.flush();
gyroscopeListener.flush();
}
/**
* Registers the gps listener, if that is possible and did not happen already.
*/
private void registerGpsListener() {
if (!gpsListener.isRegistered() && canUseGps()) {
try {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, SAMPLING_DELAY_GPS, 0, gpsListener);
gpsListener.setRegistered(true);
} catch (SecurityException e) {
Log.e(TAG, "Failed to register gps listener.", e);
}
}
}
/**
* Unregisters the gps listener, if it was registered successfully already.
*/
private void unregisterGpsListener() {
if (gpsListener.isRegistered()) {
locationManager.removeUpdates(gpsListener);
gpsListener.setRegistered(false);
}
}
/**
* Registers all sensor listeners for the sensors that are available.
*/
private void registerSensorListeners() {
registerSensorListener(Sensor.TYPE_ACCELEROMETER, accelerometerListener);
registerSensorListener(Sensor.TYPE_GYROSCOPE, gyroscopeListener);
registerSensorListener(Sensor.TYPE_MAGNETIC_FIELD, magnetometerListener);
}
/**
* Registers the sensor listener for the specified sensor type, if the sensor
* is available.
*
* @param sensorType The sensor type.
* @param listener The listener.
*/
private void registerSensorListener(int sensorType, SensorListener listener) {
if (listener.isRegistered()) return;
Sensor sensor = sensorManager.getDefaultSensor(sensorType);
if (sensor != null) {
int period = SAMPLING_DELAY_SENSOR * 1000;
if (Build.VERSION.SDK_INT > 21) {
period = Math.max(sensor.getMinDelay(), Math.min(sensor.getMaxDelay(), period));
}
boolean registered = sensorManager.registerListener(listener, sensor, period);
listener.setRegistered(registered);
}
}
/**
* Unregisters all sensor listeners that are registered.
*/
private void unregisterSensorListeners() {
unregisterSensorListener(accelerometerListener);
unregisterSensorListener(gyroscopeListener);
unregisterSensorListener(magnetometerListener);
}
/**
* Unregisters a particular sensor listener, if it was registered already.
*
* @param listener The listener to unregister.
*/
private void unregisterSensorListener(SensorListener listener) {
if (listener.isRegistered()) {
sensorManager.unregisterListener(listener);
listener.setRegistered(false);
}
}
/**
* Returns the id of the service's foreground notification.
*
* @return The notification id.
*/
@Override
protected int getNotificationId() {
return NOTIFICATION_ID;
}
/**
* A location listener that memorizes it's first location and
* enables the retrieval of a string-encoded trace.
*
* @author Marcus
*/
private class GpsListener implements LocationListener {
/**
* The flag for a valid accuracy.
*/
private static final int FLAG_ACCURACY = 1;
/**
* The flag for a valid altitude.
*/
private static final int FLAG_ALTITUDE = 2;
/**
* The flag for a valid bearing.
*/
private static final int FLAG_BEARING = 8;
/**
* The flag for a valid speed.
*/
private static final int FLAG_SPEED = 16;
/**
* The flag for a valid speed accuracy.
*/
private static final int FLAG_SPEED_ACCURACY = 32;
/**
* The flag for a valid vertical accuracy.
*/
private static final int FLAG_VERTICAL_ACCURACY = 64;
/**
* The flag for a valid bearing accuracy.
*/
private static final int FLAG_BEARING_ACCURACY = 128;
/**
* The delta codec.
*/
private DeltaCodec codec;
/**
* The unused data items.
*/
private List<long[]> cache;
/**
* The used data items.
*/
private List<long[]> data;
/**
* The first location since the flush.
*/
private ReleasedLocation location;
/**
* The location provider name.
*/
private String provider;
/**
* A flag to indicate whether the listener is
* registered.
*/
private boolean registered;
/**
* Creates a position listener with
* the specified limit on positions.
*
* @param limit The limit.
* @param provider The location provider name.
*/
GpsListener(String provider, int limit) {
int values = Math.max(1, limit);
this.provider = provider;
cache = new ArrayList<>(values);
data = new ArrayList<>(values);
codec = new DeltaCodec(11);
for (int i = 0; i < values; i++) {
// time, flags, 9 values
cache.add(new long[11]);
}
flush();
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) { }
@Override
public void onProviderEnabled(String provider) { }
@Override
public void onProviderDisabled(String provider) { }
@Override
public void onLocationChanged(Location location) {
if (this.location.getAvailability() != ReleasedLocation.AvailabilityEnum.FRESH) {
this.location.setAvailability(ReleasedLocation.AvailabilityEnum.FRESH);
this.location.setTimestamp(location.getTime());
this.location.setCoordinate(new Coordinate());
this.location.getCoordinate().setLatitude(location.getLatitude());
this.location.getCoordinate().setLongitude(location.getLongitude());
setCoordinate(location.getLongitude(), location.getLatitude());
if (location.hasAccuracy()) this.location.setAccuracy((double)location.getAccuracy());
if (location.hasAltitude()) this.location.setAltitude(location.getAltitude());
if (location.hasBearing()) this.location.setBearing((double)location.getBearing());
if (location.hasSpeed()) this.location.setSpeed((double)location.getSpeed());
}
long[] next = remove();
next[0] = location.getTime();
next[1] = getFlags(location);
next[2] = Math.round(location.getLongitude() * 10e6);
next[3] = Math.round(location.getLatitude() * 10e6);
next[4] = Math.round(location.getAccuracy() * 10e3);
next[5] = Math.round(location.getAltitude() * 10e3);
next[6] = Math.round(location.getBearing() * 10e3);
next[7] = Math.round(location.getSpeed() * 10e3);
if (Build.VERSION.SDK_INT >= 26) {
next[8] = Math.round(location.getSpeedAccuracyMetersPerSecond() * 10e3);
next[9] = Math.round(location.getVerticalAccuracyMeters() * 10e3);
next[10] = Math.round(location.getBearingAccuracyDegrees() * 10e3);
}
data.add(next);
}
/**
* Encodes the hasXXX values into a flag vector.
*
* @param location The location.
* @return The long representing the flags.
*/
private long getFlags(Location location) {
long flags = 0;
if (location.hasAccuracy()) flags += FLAG_ACCURACY;
if (location.hasAltitude()) flags += FLAG_ALTITUDE;
if (location.hasBearing()) flags += FLAG_BEARING;
if (location.hasSpeed()) flags += FLAG_SPEED;
if (Build.VERSION.SDK_INT >= 26) {
if (location.hasSpeedAccuracy()) flags += FLAG_SPEED_ACCURACY;
if (location.hasVerticalAccuracy()) flags += FLAG_VERTICAL_ACCURACY;
if (location.hasBearingAccuracy()) flags += FLAG_BEARING_ACCURACY;
}
return flags;
}
/**
* Returns the next entry to encode sensor data.
*
* @return The next entry removed either from cache
* or from the data segment.
*/
private long[] remove() {
if (cache.size() > 0) {
return cache.remove(cache.size() - 1);
} else {
return data.remove(0);
}
}
/**
* Returns the last location since the
* flush.
*
* @return The location.
*/
public ReleasedLocation getLocation() {
return location;
}
/**
* Encodes the current sensor data as a string.
*
* @return The sensor data.
*/
public String encode() {
return codec.encode(data);
}
/**
* Flushes the sensor data buffer.
*/
public void flush() {
cache.addAll(data);
data.clear();
location = new ReleasedLocation();
location.setTimestamp(System.currentTimeMillis());
location.setAvailability(ReleasedLocation.AvailabilityEnum.UNABLE);
location.setSharable(isSharable());
location.setAnalyzable(isAnalyzable());
location.setVersion((int)getVersion());
location.setProvider(provider);
}
/**
* Determines whether the listener is registered.
*
* @return True if registered, false otherwise.
*/
public boolean isRegistered() {
return registered;
}
/**
* Sets the flag to indicate whether the listener is registered.
*
* @param registered True if registered, false otherwise.
*/
public void setRegistered(boolean registered) {
this.registered = registered;
}
}
/**
* A listener for sensor data that performs delta encoding.
*
* @author Marcus
*/
private static class SensorListener implements SensorEventListener {
/**
* The delta codec.
*/
private DeltaCodec codec;
/**
* The precision.
*/
private double multiplier;
/**
* The unused data items.
*/
private List<long[]> cache;
/**
* The used data items.
*/
private List<long[]> data;
/**
* A flag to indicate whether the listener is registered.
*/
private boolean registered;
/**
* Creates a new sensor listener that will buffer
* at most limit values
*
* @param length The length of the senor data generated
* by the sensor. For a 3D sensor, this would be 3.
* @param precision The precision of the sensor data in
* decimal digits. For encoding, the data will be multiplied
* with 10^precision. Thus, for decoding, the data must
* be divided by the same precision.
* @param limit The maximum number of elements to keep in
* the buffer.
*/
public SensorListener(int length, int precision, int limit) {
multiplier = Math.pow(10, precision);
// timestamp, accuracy, values
int values = Math.max(1, limit);
cache = new ArrayList<>(values);
data = new ArrayList<>(values);
codec = new DeltaCodec(2 + length);
for (int i = 0; i < values; i++) {
cache.add(new long[2 + length]);
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// nothing to be done
}
@Override
public void onSensorChanged(SensorEvent event) {
if (data.size() > 0) {
long prev = data.get(data.size() - 1)[0];
long diff = event.timestamp / 1000 - prev;
if (diff / 1000 < SAMPLING_DELAY_SENSOR) return;
}
long[] next = remove();
next[0] = event.timestamp / 1000;
next[1] = event.accuracy;
for (int i = 0, s = event.values.length; i < s; i++) {
next[2 + i] = Math.round(event.values[i] * multiplier);
}
data.add(next);
}
/**
* Returns the next entry to encode sensor data.
*
* @return The next entry removed either from cache
* or from the data segment.
*/
private long[] remove() {
if (cache.size() > 0) {
return cache.remove(cache.size() - 1);
} else {
return data.remove(0);
}
}
/**
* Encodes the current sensor data.
*
* @return The sensor data.
*/
public String encode() {
Log.d(TAG, "Data size is: " + data.size());
return codec.encode(data);
}
/**
* Flushes the sensor data buffer.
*/
public void flush() {
cache.addAll(data);
data.clear();
}
/**
* Determines whether the listener is registered.
*
* @return True if registered, false otherwise.
*/
public boolean isRegistered() {
return registered;
}
/**
* Sets the flag to indicate whether the listener is registered.
*
* @param registered True if registered, false otherwise.
*/
public void setRegistered(boolean registered) {
this.registered = registered;
}
}
}
@@ -1,5 +1,7 @@
package com.maptology.android.app;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
import com.maptology.android.app.fragment.GrantListFragment;
import com.maptology.android.app.fragment.ManageFragment;
import com.maptology.android.app.fragment.MapFragment;
@@ -10,6 +12,7 @@ import com.maptology.android.app.fragment.ShareListFragment;
import com.maptology.android.app.fragment.TermsFragment;
import com.maptology.android.app.model.LocalShare;
import com.maptology.android.app.repository.IValueListener;
import com.maptology.android.app.repository.Repository;
import com.maptology.android.app.repository.Value;
import com.maptology.android.app.task.UpdateUserTask;
import com.maptology.android.app.util.TabletUtil;
@@ -18,21 +21,28 @@ import com.maptology.android.feign.model.User;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.NonNull;
import com.google.android.material.navigation.NavigationView;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.core.content.PermissionChecker;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.PreferenceManager;
import android.provider.Settings;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
@@ -96,13 +106,28 @@ public class MainActivity extends AppCompatActivity implements
public void onValueChanged(Value<DeviceHandle> source, DeviceHandle oldValue, DeviceHandle newValue) {
if (newValue != null) {
MenuItem webapp = navigationView.getMenu().findItem(R.id.menu_webapp);
MenuItem connect =navigationView.getMenu().findItem(R.id.menu_connect);
MenuItem connect = navigationView.getMenu().findItem(R.id.menu_connect);
connect.setVisible(newValue.getUser() == null);
webapp.setVisible(newValue.getUser() != null);
}
}
};
/**
* A listener that performs a permission check whenever the user enables localization.
*/
private SharedPreferences.OnSharedPreferenceChangeListener preferenceListener =new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (Repository.KEY_PRIVACY_LOCALIZE.equals(key)) {
if (sharedPreferences.getBoolean(key, false)) {
checkPermissions();
}
}
}
};
/**
* Navigation Drawer menu.
*/
@@ -122,11 +147,17 @@ public class MainActivity extends AppCompatActivity implements
*/
private MaptologyApp app;
/**
* The preferences to keep on watching the localization state.
*/
private SharedPreferences prefs;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = (MaptologyApp) getApplicationContext();
LocationService.runService(this);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
AbstractService.runService(this);
setTitle(R.string.application_short);
if (TabletUtil.isLandscapeTablet(this)) {
setContentView(R.layout.activity_main_tablet);
@@ -137,7 +168,6 @@ public class MainActivity extends AppCompatActivity implements
setScreen(Screen.MAP);
}
createNavigationDrawer();
checkPermissions();
new UpdateUserTask(app).execute();
}
@@ -146,10 +176,12 @@ public class MainActivity extends AppCompatActivity implements
super.onResume();
app.getRepository().user.addValueListener(userListener, true);
app.getRepository().deviceHandle.addValueListener(deviceListener, true);
prefs.registerOnSharedPreferenceChangeListener(preferenceListener);
}
@Override
protected void onPause() {
prefs.unregisterOnSharedPreferenceChangeListener(preferenceListener);
app.getRepository().deviceHandle.removeValueListener(deviceListener);
app.getRepository().user.removeValueListener(userListener);
super.onPause();
@@ -170,28 +202,21 @@ public class MainActivity extends AppCompatActivity implements
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_notice:
setScreen(Screen.NOTICE);
break;
case R.id.menu_map:
setScreen(Screen.MAP);
break;
case R.id.menu_share:
createShare();
break;
case R.id.menu_manage:
setScreen(Screen.MANAGE);
break;
case R.id.menu_settings:
showSettings();
break;
case R.id.menu_connect:
showLogin();
break;
case R.id.menu_webapp:
showPlaces();
break;
int itemId = item.getItemId();
if (itemId == R.id.menu_notice) {
setScreen(Screen.NOTICE);
} else if (itemId == R.id.menu_map) {
setScreen(Screen.MAP);
} else if (itemId == R.id.menu_share) {
createShare();
} else if (itemId == R.id.menu_manage) {
setScreen(Screen.MANAGE);
} else if (itemId == R.id.menu_settings) {
showSettings();
} else if (itemId == R.id.menu_connect) {
showLogin();
} else if (itemId == R.id.menu_webapp) {
showPlaces();
}
closeDrawerIfNeeded();
return false;
@@ -236,7 +261,6 @@ public class MainActivity extends AppCompatActivity implements
super.onDrawerClosed(view);
setTitle(R.string.application_short);
}
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
setTitle(R.string.drawer_title);
@@ -262,30 +286,91 @@ public class MainActivity extends AppCompatActivity implements
* Method to request location permission for the app.
*/
private void checkPermissions() {
boolean permissionGranted = PermissionChecker.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PermissionChecker.PERMISSION_GRANTED &&
PermissionChecker.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
if (!permissionGranted) {
Log.d(TAG, "Requesting permissions.");
ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, CODE_REQUEST_PERMISSIONS);
if (! app.getRepository().isLocalizable()) return;
boolean coarse = ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
boolean fine = ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
if (!(coarse && fine)) {
Log.d(TAG, "Requesting foreground localization.");
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION)) {
PermissionDialogFragment dialog = new PermissionDialogFragment();
dialog.setForeground(true);
getSupportFragmentManager().beginTransaction().add(dialog, "foreground").commit();
} else {
requestForegroundLocalization();
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){
boolean background = ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_BACKGROUND_LOCATION) == PackageManager.PERMISSION_GRANTED;
if (!background){
Log.d(TAG, "Requesting background localization.");
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_BACKGROUND_LOCATION)) {
PermissionDialogFragment dialog = new PermissionDialogFragment();
dialog.setForeground(false);
getSupportFragmentManager().beginTransaction().add(dialog, "background").commit();
} else {
requestBackgroundLocalization();
}
}
}
}
/**
* Request the foreground localization permission.
*/
private void requestForegroundLocalization() {
ActivityCompat.requestPermissions(this, new String[] {
Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION
}, CODE_REQUEST_PERMISSIONS);
}
/**
* Request background localization permission.
*/
private void requestBackgroundLocalization() {
ActivityCompat.requestPermissions(this, new String[] {
Manifest.permission.ACCESS_BACKGROUND_LOCATION
}, CODE_REQUEST_PERMISSIONS);
}
/**
* Cancels the localization request.
*/
private void cancelLocalization() {
app.getRepository().setLocalizable(false);
AbstractService.stopServices(this);
Snackbar.make(findViewById(R.id.coordinator), R.string.permission_missing,
Snackbar.LENGTH_LONG).setAction(R.string.permission_configure, v -> {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivity(intent);
}).show();
}
/**
* Method handles the requested permission (whether it was given or not).
*
* @param requestCode requestCode identifies requested permission
* @param permissions permissions The permissions.
* @param grantResults results The results for the permissions.
* @param requestCode Identifies requested permission.
* @param permissions The permissions.
* @param grantResults The results for the permissions.
*/
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case CODE_REQUEST_PERMISSIONS: {
StringBuilder b = new StringBuilder();
for (int i = 0, s = Math.min(permissions.length, grantResults.length); i < s; i++) {
b.append(permissions[i] + " " + (grantResults[i] == PackageManager.PERMISSION_GRANTED) + "\n");
boolean granted = true;
for (int i = 0; i < grantResults.length; i++) {
boolean value = grantResults[i] == PackageManager.PERMISSION_GRANTED;
granted &= value;
Log.d(TAG, permissions[i] + ": " + value);
}
Log.d(TAG, "All permissions granted: " + granted);
if (!granted) {
cancelLocalization();
} else {
checkPermissions();
}
Log.d(TAG, "Permission result:\n" + b.toString());
break;
}
default:
@@ -413,4 +498,46 @@ public class MainActivity extends AppCompatActivity implements
MANAGE
}
/**
* A dialog to explain the permissions.
*/
public static class PermissionDialogFragment extends DialogFragment {
/**
* Marks the fragment either as foreground or background.
*
* @param foreground True for foreground, false for background.
*/
public void setForeground(boolean foreground) {
Bundle b = new Bundle();
b.putBoolean("foreground", foreground);
setArguments(b);
}
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
boolean foreground = getArguments().getBoolean("foreground");
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity());
builder.setTitle(R.string.permission_required);
builder.setMessage(foreground ? R.string.permission_foreground_explain : R.string.permission_background_explain);
builder.setPositiveButton(android.R.string.ok, (dialog, which) -> {
if (foreground) {
((MainActivity)getActivity()).requestForegroundLocalization();
} else {
((MainActivity)getActivity()).requestBackgroundLocalization();
}
});
builder.setNegativeButton(android.R.string.cancel, (dialog, which) -> {
dialog.dismiss();
});
builder.setOnCancelListener(dialog -> ((MainActivity)getActivity()).cancelLocalization());
return builder.create();
}
}
}
@@ -79,10 +79,13 @@ public class MaptologyApp extends Application {
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (Repository.KEY_PRIVACY_LOCALIZE.equals(key)) {
if (sharedPreferences.getBoolean(key, false)) {
LocationService.runService(MaptologyApp.this);
AbstractService.runService(MaptologyApp.this);
} else {
LocationService.stopService(MaptologyApp.this);
AbstractService.stopServices(MaptologyApp.this);
}
} else if (Repository.KEY_PRIVACY_LOGGABLE.equals(key)) {
AbstractService.stopServices(MaptologyApp.this);
AbstractService.runService(MaptologyApp.this);
}
}
};
@@ -0,0 +1,35 @@
package com.maptology.android.app;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
/**
* A broadcast receiver that receives messages on package replacements.
*
* @author Marcus
*/
public class UpdateReceiver extends BroadcastReceiver {
/**
* The log tag for this class.
*/
private static final String TAG = "UpdateReceiver";
@Override
public void onReceive(Context context, Intent intent) {
// should not happen but nobody likes crashing apps in background
if (intent == null || context == null) return;
Log.d(TAG, "Received an intent with action " + intent.getAction() + ".");
if (context.getApplicationContext() instanceof MaptologyApp) {
if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) {
Log.d(TAG, "Restarting services due to my package replacement.");
NoticeReceiver.schedulePeriodicSync((MaptologyApp)context.getApplicationContext());
AbstractService.runService(context);
}
}
}
}
@@ -184,7 +184,7 @@ public class DetailViewHolder extends RecyclerView.ViewHolder {
setText(positionText, null, positionLine);
if (share.getExpirationTime() < System.currentTimeMillis()) {
statusImage.setImageResource(R.drawable.ic_alarm_off_black_48dp);
} else if (share.getPaused()) {
} else if (share.isPaused()) {
statusImage.setImageResource(R.drawable.ic_pause_black_48dp);
} else {
statusImage.setImageResource(R.drawable.ic_share_black_48dp);
@@ -3,6 +3,8 @@ package com.maptology.android.app.fragment;
import java.util.ArrayList;
import java.util.List;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.locoslab.android.leafless.IMapStateListener;
import com.locoslab.android.leafless.ITouchListener;
import com.locoslab.android.leafless.MapOptions;
@@ -31,18 +33,16 @@ import com.maptology.android.feign.model.Coordinate;
import android.database.Cursor;
import android.os.Bundle;
import android.os.Handler;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.fragment.app.FragmentTransaction;
import androidx.collection.LongSparseArray;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.collection.LongSparseArray;
import androidx.fragment.app.FragmentTransaction;
/**
* A fragment that displays a map.
@@ -288,7 +288,7 @@ public class MapFragment extends AbstractFragment {
// apply the state
getRepository().mapState.getValue().applyTo(map);
// add a tile layer
map.addLayer(new TileLayer(new TileLayerOptions("https://cloud.locoslab.com/carta/restful-services/tile/{z}/{x}/{y}.png")));
map.addLayer(new TileLayer(new TileLayerOptions("https://www.maptology.com/carta/tile/{z}/{x}/{y}.png")));
// add map interaction
map.addShortTapListener(new ITouchListener() {
@Override
@@ -461,7 +461,7 @@ public class MapFragment extends AbstractFragment {
getRepository().mapMode.setValue(MapMode.values()[code]);
}
/**
* Applies the current map mode.
*/
@@ -9,6 +9,7 @@ import com.maptology.android.app.MaptologyApp;
import com.maptology.android.app.R;
import com.maptology.android.app.repository.Repository;
import com.maptology.android.feign.model.DeviceHandle;
import com.maptology.android.feign.model.User;
import android.annotation.TargetApi;
import android.app.AlertDialog;
@@ -16,16 +17,19 @@ import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import androidx.core.content.pm.PackageInfoCompat;
import androidx.preference.CheckBoxPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
import android.util.Log;
import android.view.LayoutInflater;
@@ -50,6 +54,16 @@ public class SettingsFragment extends PreferenceFragmentCompat {
void showTerms();
}
/**
* The name of the scientist role that enables the data logger.
*/
private static final String ROLE_SCIENTIST = "scientist";
/**
* The name of the admin role that enables the data logger.
*/
private static final String ROLE_ADMIN = "admin";
/**
* The number of times a user must click the version button to switch
* between developer mode and non-developer mode.
@@ -133,6 +147,18 @@ public class SettingsFragment extends PreferenceFragmentCompat {
*/
private PreferenceGroup developmentGroup;
/**
* A listener for shared preferences.
*/
private SharedPreferences.OnSharedPreferenceChangeListener preferenceListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (Repository.KEY_PRIVACY_LOCALIZE.equals(key)) {
updateLocalize();
}
}
};
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
@@ -151,6 +177,9 @@ public class SettingsFragment extends PreferenceFragmentCompat {
bindClear();
bindTerms();
bindLicenses();
if (!isLoggerAvailable()) {
disableLogger();
}
return v;
}
@@ -165,6 +194,48 @@ public class SettingsFragment extends PreferenceFragmentCompat {
}
}
@Override
public void onResume() {
super.onResume();
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(preferenceListener);
updateLocalize();
}
@Override
public void onPause() {
super.onPause();
PreferenceManager.getDefaultSharedPreferences(getContext()).unregisterOnSharedPreferenceChangeListener(preferenceListener);
}
private void updateLocalize() {
CheckBoxPreference p = findPreference(Repository.KEY_PRIVACY_LOCALIZE);
if (p != null) {
boolean state = getApp().getRepository().isLocalizable();
if (p.isChecked() != state) {
p.setChecked(state);
}
}
}
/**
* Determines whether the logger switch is available.
*
* @return True if available, false otherwise.
*/
private boolean isLoggerAvailable() {
User user = getRepository().user.getValue();
if (user == null || user.getRoles() == null) return false;
else return user.getRoles().contains(ROLE_ADMIN) || user.getRoles().contains(ROLE_SCIENTIST);
}
private void disableLogger() {
Preference logger = findPreference(Repository.KEY_PRIVACY_LOGGABLE);
if (logger != null) {
logger.getParent().removePreference(logger);
}
}
/**
* Updates the version information by reading out the package version and
* the build date of classes.dex.
@@ -344,7 +344,7 @@ public class ShareFragment extends AbstractFragment implements DatePickerDialog.
expirationDateView.setText(format.asDate(share.getExpirationTime()));
creationTimeView.setText(format.asTime(share.getCreationTime()));
creationDateView.setText(format.asDate(share.getCreationTime()));
pausedBox.setChecked(share.getPaused());
pausedBox.setChecked(share.isPaused());
messageText.setText(share.getMessage());
messageText.setSelection(messageText.getText().length());
messageText.clearFocus();
@@ -83,12 +83,18 @@ public class TermsFragment extends AbstractFragment {
View acceptView = view.findViewById(R.id.fragment_terms_accept);
acceptView.setVisibility(getRepository().isTermsAccepted()?View.GONE:View.VISIBLE);
final CheckBox permissionCheckbox = (CheckBox) view.findViewById(R.id.permission_checkbox_start);
Button continueButton = (Button) view.findViewById(R.id.start_button_continue);
final Button continueButton = (Button) view.findViewById(R.id.start_button_continue);
continueButton.setEnabled(permissionCheckbox.isChecked());
permissionCheckbox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
continueButton.setEnabled(permissionCheckbox.isChecked());
}
});
continueButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getRepository().setTermsAccepted(true);
getRepository().setShareable(permissionCheckbox.isChecked());
if (continueListener != null) continueListener.onClick(v);
}
});
@@ -11,7 +11,7 @@ public class LocationContract {
/**
* The table to store the released locations when they
* are captured. This table is required to handle
* transient network failsures.
* transient network failures.
*/
public class Update {
/**
@@ -72,6 +72,33 @@ public class LocationContract {
public static final String VERSION = "version";
}
/**
* The table to store the metadata for updates.
*/
public class Metadata {
/**
* The name of the table.
*/
public static final String TABLE = "location_metadata";
/**
* The id of the row.
*/
public static final String ID = "_id";
/**
* The id of the update to which this metadata refers to.
*/
public static final String UPDATE_ID = "update_id";
/**
* The tag describing the metadata type.
*/
public static final String TAG = "tag";
/**
* The value containing the actual data.
*/
public static final String VALUE = "value";
}
/**
* The table to store locations with their associated
* networks so that we do not have to compute them
@@ -150,7 +177,7 @@ public class LocationContract {
/**
* The db schema version.
*/
public static int VERSION = 6;
public static int VERSION = 7;
/**
* The name of the database.
@@ -5,6 +5,8 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import com.maptology.android.app.notice.NoticeContract;
/**
* Implements an sqlite open helper for the the location db.
*
@@ -99,6 +101,33 @@ public class LocationHelper extends SQLiteOpenHelper {
*/
private static String SQL_DROP_UPDATE = "DROP TABLE IF EXISTS " + LocationContract.Update.TABLE;
/**
* Creates the metadata table.
*/
private static String SQL_CREATE_METADATA = "CREATE TABLE " + LocationContract.Metadata.TABLE + " ( "
+ LocationContract.Metadata.ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ LocationContract.Metadata.TAG + " TEXT, "
+ LocationContract.Metadata.VALUE + " TEXT, "
+ LocationContract.Metadata.UPDATE_ID + " INTEGER NOT NULL "
+ "REFERENCES " + LocationContract.Update.TABLE + " ( " + LocationContract.Update.ID + " ) ON DELETE CASCADE"
+ " )";
/**
* Drops the metadata table.
*/
private static String SQL_DROP_METADATA = "DROP TABLE IF EXISTS " + LocationContract.Metadata.TABLE;
/**
* Creates an index over the metadata update id to resolve the foreign key.
*/
private static String SQL_INDEX_METADATA_UI = "CREATE INDEX " + LocationContract.Metadata.TABLE + "_UI "
+ "ON " + LocationContract.Metadata.TABLE + " ( " +LocationContract.Metadata.UPDATE_ID +" )";
/**
* Drops the index on the metadata's update id.
*/
private static String SQL_DROP_METADATA_UI = "DROP INDEX IF EXISTS " + LocationContract.Metadata.TABLE + "_UI";
/**
* Creates a new helper from the context.
*
@@ -130,11 +159,13 @@ public class LocationHelper extends SQLiteOpenHelper {
try {
// create tables
db.execSQL(SQL_CREATE_UPDATE);
db.execSQL(SQL_CREATE_METADATA);
db.execSQL(SQL_CREATE_POSITION);
db.execSQL(SQL_CREATE_NETWORK);
// create indexes
db.execSQL(SQL_INDEX_POSITION_UT);
db.execSQL(SQL_INDEX_NETWORK_BS);
db.execSQL(SQL_INDEX_METADATA_UI);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
@@ -153,20 +184,36 @@ public class LocationHelper extends SQLiteOpenHelper {
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.d(TAG, "Migrating database from " + oldVersion + " to " + newVersion + ".");
// a quite crude "upgrade" script
db.beginTransaction();
try {
// drop indexes
db.execSQL(SQL_DROP_NETWORK_BS);
db.execSQL(SQL_DROP_POSITION_UT);
// drop tables
db.execSQL(SQL_DROP_NETWORK);
db.execSQL(SQL_DROP_POSITION);
db.execSQL(SQL_DROP_UPDATE);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (oldVersion == 6 && newVersion == 7) {
// only add new table from 6 to 7
db.beginTransaction();
try {
db.execSQL(SQL_CREATE_METADATA);
db.execSQL(SQL_INDEX_METADATA_UI);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
} else {
// otherwise recreate database
db.beginTransaction();
try {
// drop indexes
db.execSQL(SQL_DROP_METADATA_UI);
db.execSQL(SQL_DROP_NETWORK_BS);
db.execSQL(SQL_DROP_POSITION_UT);
// drop tables
db.execSQL(SQL_DROP_NETWORK);
db.execSQL(SQL_DROP_POSITION);
db.execSQL(SQL_DROP_METADATA);
db.execSQL(SQL_DROP_UPDATE);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
// recreate everything
onCreate(db);
}
// recreate everything
onCreate(db);
}
}
@@ -1,11 +1,11 @@
package com.maptology.android.app.model;
package com.maptology.android.app.location;
/**
* A stored network.
*
* @author Marcus
*/
public class Network {
public class LocationNetwork {
/**
* The id in the database.
@@ -1,4 +1,4 @@
package com.maptology.android.app.model;
package com.maptology.android.app.location;
import java.util.ArrayList;
import java.util.HashMap;
@@ -10,7 +10,7 @@ import java.util.Map;
*
* @author Marcus
*/
public class Position {
public class LocationPosition {
/**
* The id of the position.
@@ -19,7 +19,7 @@ public class Position {
/**
* The networks of the position.
*/
private List<Network> networks = new ArrayList<>();
private List<LocationNetwork> networks = new ArrayList<>();
/**
* The longitude of the position.
*/
@@ -72,7 +72,7 @@ public class Position {
*
* @return The list of networks.
*/
public List<Network> getNetworks() {
public List<LocationNetwork> getNetworks() {
return networks;
}
@@ -209,13 +209,13 @@ public class Position {
* @param maximumDeviation The maximum deviation to consider a network as matching.
* @return The number of matching networks.
*/
public int getMatches(List<Network> networks, int maximumDeviation) {
public int getMatches(List<LocationNetwork> networks, int maximumDeviation) {
Map<String, Integer> bssids = new HashMap<>();
for (Network n: this.networks) {
for (LocationNetwork n: this.networks) {
bssids.put(n.getBssid(), n.getRssi());
}
int count = 0;
for (Network n: networks) {
for (LocationNetwork n: networks) {
if (bssids.containsKey(n.getBssid()) && Math.abs(n.getRssi() - bssids.get(n.getBssid())) <= maximumDeviation) {
count += 1;
}
@@ -229,15 +229,15 @@ public class Position {
* @param networks The networks.
* @return The squared distance sum in vector space.
*/
public long getDistance(List<Network> networks) {
Map<String, Network> nets = new HashMap<>();
for (Network n: this.networks) {
public long getDistance(List<LocationNetwork> networks) {
Map<String, LocationNetwork> nets = new HashMap<>();
for (LocationNetwork n: this.networks) {
nets.put(n.getBssid(), n);
}
long distance = 0;
for (Network n: networks) {
for (LocationNetwork n: networks) {
int rssiOut = -100;
Network o = nets.get(n.getBssid());
LocationNetwork o = nets.get(n.getBssid());
if (o != null) {
rssiOut = o.getRssi();
}
@@ -261,7 +261,7 @@ public class Position {
b.append("ALTITUDE(" + altitude + ") ");
b.append("ACCURACY(" + accuracy + ") ");
b.append("NETWORKS( ");
for (Network n: networks) {
for (LocationNetwork n: networks) {
b.append(n.toString());
b.append(" ");
}
@@ -1,10 +1,10 @@
package com.maptology.android.app.location;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.maptology.android.app.model.Network;
import com.maptology.android.app.model.Position;
import com.maptology.android.feign.model.Coordinate;
import com.maptology.android.feign.model.ReleasedLocation;
@@ -56,7 +56,7 @@ public class LocationStore {
*
* @param p The position to add.
*/
public void addPosition(Position p) {
public void addPosition(LocationPosition p) {
if (db == null) return;
db.beginTransaction();
try {
@@ -73,7 +73,7 @@ public class LocationStore {
// get the position id
p.setId(getPositionId());
// add the networks
for (Network n: p.getNetworks()) {
for (LocationNetwork n: p.getNetworks()) {
addNetwork(p.getId(), n);
}
db.setTransactionSuccessful();
@@ -100,6 +100,13 @@ public class LocationStore {
return getCreatedId(LocationContract.Network.TABLE);
}
/**
* Returns the last created update id.
*
* @return The last created update id.
*/
private long getUpdateId() { return getCreatedId(LocationContract.Update.TABLE); }
/**
* Returns the last created id of the specified table.
*
@@ -123,7 +130,7 @@ public class LocationStore {
* @param position The position.
* @param n The network.
*/
private void addNetwork(long position, Network n) {
private void addNetwork(long position, LocationNetwork n) {
ContentValues values = new ContentValues();
values.put(LocationContract.Network.POSITION, position);
values.put(LocationContract.Network.BSSID, n.getBssid());
@@ -138,8 +145,8 @@ public class LocationStore {
* @param position The position.
* @return The list of networks.
*/
private List<Network> getNetworks(long position) {
List<Network> result = new ArrayList<>();
private List<LocationNetwork> getNetworks(long position) {
List<LocationNetwork> result = new ArrayList<>();
if (db == null) return result;
Cursor c = db.query(LocationContract.Network.TABLE, new String[] {
LocationContract.Network.ID,
@@ -148,7 +155,7 @@ public class LocationStore {
}, LocationContract.Network.POSITION + " = " + position, null, null, null, null);
while (c.moveToNext()) {
Network n = new Network();
LocationNetwork n = new LocationNetwork();
n.setId(c.getLong(0));
n.setBssid(c.getString(1));
n.setRssi(c.getInt(2));
@@ -174,7 +181,7 @@ public class LocationStore {
* @param updateNetworks True to update the networks, false
* to update only the position.
*/
public void setPosition(Position p, boolean updateNetworks) {
public void setPosition(LocationPosition p, boolean updateNetworks) {
if (db == null) return;
db.beginTransaction();
try {
@@ -189,7 +196,7 @@ public class LocationStore {
db.update(LocationContract.Position.TABLE, values, LocationContract.Position.ID + " = " + p.getId(), null);
if (updateNetworks) {
removeNetworks(p.getId());
for (Network n: p.getNetworks()) {
for (LocationNetwork n: p.getNetworks()) {
addNetwork(p.getId(), n);
}
}
@@ -205,8 +212,8 @@ public class LocationStore {
* @param id The id to load.
* @return The position with its networks.
*/
public Position getPosition(long id) {
Position result = null;
public LocationPosition getPosition(long id) {
LocationPosition result = null;
if (db == null) return result;
db.beginTransaction();
try {
@@ -221,7 +228,7 @@ public class LocationStore {
LocationContract.Position.ID + " = " + id,
null, null, null, null);
if (c.moveToNext()) {
result = new Position();
result = new LocationPosition();
result.setId(id);
result.setLatitude(c.getDouble(0));
result.setLongitude(c.getDouble(1));
@@ -267,7 +274,7 @@ public class LocationStore {
* @param maximumDeviation The maximum deviation of rssi values to consider a network matching.
* @return The position or null, if no match is good enough.
*/
public Position findPosition(List<Network> networks, int minimumMatching, int maximumDeviation) {
public LocationPosition findPosition(List<LocationNetwork> networks, int minimumMatching, int maximumDeviation) {
if (networks.size() == 0 || networks.size() < minimumMatching) return null;
if (db == null) return null;
StringBuilder b = new StringBuilder();
@@ -279,7 +286,7 @@ public class LocationStore {
b.append(", ");
}
}
Position best = null;
LocationPosition best = null;
int matches = 0;
double distance = 0;
db.beginTransaction();
@@ -289,7 +296,7 @@ public class LocationStore {
LocationContract.Network.BSSID + " IN (" + b.toString() + ")",
null, null, null, null, null);
while (c.moveToNext()) {
Position p = getPosition(c.getLong(0));
LocationPosition p = getPosition(c.getLong(0));
if (p != null) {
long d = p.getDistance(networks);
int m = p.getMatches(networks, maximumDeviation);
@@ -356,10 +363,29 @@ public class LocationStore {
values.put(LocationContract.Update.ACCURACY, location.getAccuracy());
values.put(LocationContract.Update.BEARING, location.getBearing());
values.put(LocationContract.Update.SPEED, location.getSpeed());
values.put(LocationContract.Update.ANALYZABLE, location.getAnalyzable()==null?0:(location.getAnalyzable()?1:0));
values.put(LocationContract.Update.SHARABLE, location.getSharable()==null?0:(location.getSharable()?1:0));
values.put(LocationContract.Update.ANALYZABLE, location.isAnalyzable()==null?0:(location.isAnalyzable()?1:0));
values.put(LocationContract.Update.SHARABLE, location.isSharable()==null?0:(location.isSharable()?1:0));
values.put(LocationContract.Update.VERSION, location.getVersion()==null?0:location.getVersion());
db.insert(LocationContract.Update.TABLE, null, values);
addMetadata(getUpdateId(), location.getMetadata());
}
/**
* Stores the meta for the update id.
*
* @param updateId The update id.
* @param metadata The metadata to store.
*/
private void addMetadata(long updateId, Map<String, String> metadata) {
if (metadata != null) {
for (Map.Entry<String, String> entry: metadata.entrySet()) {
ContentValues values = new ContentValues();
values.put(LocationContract.Metadata.UPDATE_ID, updateId);
values.put(LocationContract.Metadata.TAG, entry.getKey());
values.put(LocationContract.Metadata.VALUE, entry.getValue());
db.insert(LocationContract.Metadata.TABLE, null, values);
}
}
}
/**
@@ -405,11 +431,35 @@ public class LocationStore {
cor.setLongitude(c.getDouble(11));
r.setCoordinate(cor);
}
r.setMetadata(getMetadata(id));
}
c.close();;
return r;
}
/**
* Returns the metadata stored for the update.
*
* @param updateId The update id.
* @return The metadata (never null).
*/
private Map<String, String> getMetadata(long updateId) {
Map<String, String> result = new HashMap<>();
if (db == null) return result;
Cursor c = db.query(LocationContract.Metadata.TABLE, new String[]{
LocationContract.Metadata.TAG,
LocationContract.Metadata.VALUE
}, LocationContract.Metadata.UPDATE_ID + " = " + updateId, null, null, null, null);
while (c.moveToNext()) {
String tag = c.isNull(0)?null:c.getString(0);
String value = c.isNull(1)?null:c.getString(1);
result.put(tag, value);
}
c.close();
return result;
}
/**
* Removes the update with the specified id.
*
@@ -418,6 +468,17 @@ public class LocationStore {
public void removeUpdate(long id) {
if (db == null) return;
db.execSQL("DELETE FROM " + LocationContract.Update.TABLE + " WHERE " + LocationContract.Update.ID + " = " + id);
removeMetadata(id);
}
/**
* Removes the metadata fr the update with the specified id.
*
* @param updateId The id of the update.
*/
private void removeMetadata(long updateId) {
if (db == null) return;
db.execSQL("DELETE FROM " + LocationContract.Metadata.TABLE + " WHERE " + LocationContract.Metadata.UPDATE_ID + " = " + updateId);
}
/**
@@ -447,6 +508,13 @@ public class LocationStore {
return getCount(LocationContract.Network.TABLE);
}
/**
* Returns the number of entries in the metadata table.
*
* @return The number of metadata entries.
*/
public long getMetadataCount() { return getCount(LocationContract.Metadata.TABLE); }
/**
* Returns the element count in the table.
*
@@ -104,7 +104,7 @@ public class NoticeStore {
}
ContentValues values = new ContentValues();
values.put(NoticeContract.Notice.ID, notice.getId());
values.put(NoticeContract.Notice.ANNOUNCED, notice.getAnnounced());
values.put(NoticeContract.Notice.ANNOUNCED, notice.isAnnounced());
values.put(NoticeContract.Notice.CREATION_TIME, notice.getCreationTime());
values.put(NoticeContract.Notice.MODIFICATION_TIME, notice.getModificationTime());
values.put(NoticeContract.Notice.EXPIRATION_TIME, notice.getExpirationTime());
@@ -10,7 +10,7 @@ import com.maptology.android.feign.model.User;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import androidx.preference.PreferenceManager;
/**
@@ -38,6 +38,11 @@ public class Repository {
*/
public static final String KEY_PRIVACY_LOCALIZE = "privacy_localize";
/**
* The key to globally enable or disable the high precision logger service.
*/
public static final String KEY_PRIVACY_LOGGABLE = "privacy_loggable";
/**
* The key to memorize whether we are in development mode.
*/
@@ -144,9 +149,9 @@ public class Repository {
*/
public Repository(Context context) {
this.context = context;
this.deviceHandle = new PersistentValue<DeviceHandle>(this, new JacksonSerializer<DeviceHandle>(DeviceHandle.class), "device.json");
this.user = new PersistentValue<User>(this, new JacksonSerializer<User>(User.class), "user.json");
this.lastUpdate = new PersistentValue<ReleasedLocation>(this, new JacksonSerializer<ReleasedLocation>(ReleasedLocation.class), "update.json");
this.deviceHandle = new PersistentValue<>(this, new JacksonSerializer<>(DeviceHandle.class), "device.json");
this.user = new PersistentValue<>(this, new JacksonSerializer<>(User.class), "user.json");
this.lastUpdate = new PersistentValue<>(this, new JacksonSerializer<>(ReleasedLocation.class), "update.json");
}
/**
@@ -167,6 +172,24 @@ public class Repository {
return getPreference(KEY_PRIVACY_LOCALIZE, R.bool.privacy_localize_default);
}
/**
* Enables or disables localization.
*
* @param value True to enable, false to disable.
*/
public void setLocalizable(boolean value) {
setPreference(KEY_PRIVACY_LOCALIZE, value);
}
/**
* Determines whether logging is enabled.
*
* @return True if logging is enabled, false otherwise.
*/
public boolean isLoggable() {
return getPreference(KEY_PRIVACY_LOGGABLE, R.bool.privacy_loggable_default);
}
/**
* Sets whether the user has allowed that his positions can be used for research.
*
@@ -164,9 +164,9 @@ public class ShareStore {
values.put(ShareContract.Share.MESSAGE, share.getMessage());
values.put(ShareContract.Share.DESTINATION, share.getDestination());
values.put(ShareContract.Share.TOKEN, share.getToken());
values.put(ShareContract.Share.PAUSED, share.getPaused() ? 1 : 0);
values.put(ShareContract.Share.PAUSED, share.isPaused() ? 1 : 0);
values.put(ShareContract.Share.DEVICE, share.getDevice());
values.put(ShareContract.Share.DELETED, share.getDeleted() ? 1 : 0);
values.put(ShareContract.Share.DELETED, share.isDeleted() ? 1 : 0);
if (!exists) {
values.put(ShareContract.Share.ID, share.getId());
database.insert(ShareContract.Share.TABLE, null, values);
@@ -83,11 +83,11 @@ public class CreateShareTask extends AbstractApiTask<Void, Void, AsyncError> {
super.onPostExecute(asyncError);
if (app.getRepository().updatingShare.getValue() != interaction) return;
if (asyncError == null) {
share.setDeleted(createdShare.getDeleted());
share.setDeleted(createdShare.isDeleted());
share.setId(createdShare.getId());
share.setToken(createdShare.getToken());
share.setDestination(createdShare.getDestination());
share.setPaused(createdShare.getPaused());
share.setPaused(createdShare.isPaused());
share.setModificationTime(createdShare.getModificationTime());
share.setCreationTime(createdShare.getCreationTime());
share.setDevice(createdShare.getDevice());
@@ -150,7 +150,7 @@ public class SyncNoticeTask extends AbstractApiTask<Void, Void, List<Notice>> {
Log.d(TAG, "Received a notice without id (this is a problem, fix it).");
continue;
}
if (n.getDeleted() != null && n.getDeleted()) {
if (n.isDeleted() != null && n.isDeleted()) {
// delete outdated data
store.removeNotice(n.getId());
} else {
@@ -101,7 +101,7 @@ public class UpdateDeviceTask extends AbstractApiTask<Void, Void, AsyncError> {
return getError(e);
}
try {
device = apiClient.setCurrentDeviceUser();
device = apiClient.setCurrentUserDevice(device);
Log.d(TAG, "Device associated for user id " + device.getUser() + ".");
} catch (FeignException e) {
Log.d(TAG, "Device creation failure: " + e.status() + " " + e.getMessage());
@@ -41,7 +41,7 @@ public class UploadLocationTask extends AbstractApiTask<Void, Void, Void> {
/**
* The maximum number of locations to be uploaded in one batch.
*/
private static final int MAXIMUM_BATCH_SIZE = 100;
private static final int MAXIMUM_BATCH_SIZE = 5;
/**
* The respository of the app.
@@ -0,0 +1,131 @@
package com.maptology.android.app.util;
import java.util.ArrayList;
import java.util.List;
/**
* A delta compression codec based on Google's WGS84 encoder that
* supports multiple data streams to encode other data than latitude
* and longitude values. Callers must supply the number of streams
* encoded in the data and the streams must exhibit the same number
* of data items.
*
* @author Marcus
*/
public class DeltaCodec {
/**
* The number of streams to encode or decode.
*/
private int streams;
/**
* Creates a delta compressor for the specified number of streams.
*
* @param streams The number of streams to encode in the string.
*/
public DeltaCodec(int streams) {
this.streams = streams;
}
/**
* Returns the number of streams expected by this codec.
*
* @return The number of streams.
*/
public int getStreams() {
return streams;
}
/**
* Encodes a list of values into a string.
*
* @param values The values consisting of arrays that represent
* the individual streams.
* @return The string.
*/
public String encode(List<long[]> values) {
StringBuilder builder = new StringBuilder();
long[] previous = new long[streams];
for (int i = 0, s = values.size(); i < s; i++) {
long[] current = values.get(i);
for (int j = 0; j < streams; j++) {
long delta = current[j] - previous[j];
builder.append(encodeSignedNumber(delta));
previous[j] = current[j];
}
}
return builder.toString();
}
/**
* Extracts the list of data from an encoded string.
*
* @param encoded The encoded string.
* @param data An optional list of data items to be reused
* to avoid object allocations. Can be null.
* @return The list of data items representing the streams.
*/
public List<long[]> decode(String encoded, List<long[]> data) {
List<long[]> list = new ArrayList<>();
int index = 0;
int length = encoded.length();
long[] current = new long[streams];
while (index < length) {
long[] next;
if (data != null && data.size() > 0) {
next = data.remove(0);
} else {
next = new long[streams];
}
long c;
for (int i = 0; i < streams; i++) {
long shift = 0;
long result = 0;
do {
c = encoded.charAt(index++) - 63;
result |= (c & 0x1f) << shift;
shift += 5;
} while (c >= 0x20);
long delta = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
current[i] += delta;
next[i] = current[i];
}
list.add(next);
}
return list;
}
/**
* Encodes a signed number as string.
*
* @param num The number.
* @return The string.
*/
private static String encodeSignedNumber(long num) {
long sgn_num = num << 1;
if (num < 0) {
sgn_num = ~(sgn_num);
}
return (encodeNumber(sgn_num));
}
/**
* Encodes an unsigned number as string.
*
* @param num The number.
* @return The string.
*/
private static String encodeNumber(long num) {
StringBuilder encodeString = new StringBuilder();
while (num >= 0x20) {
int nextValue = (int)(0x20 | (num & 0x1f)) + 63;
encodeString.append((char) (nextValue));
num >>= 5;
}
num += 63;
encodeString.append((char) (num));
return encodeString.toString();
}
}

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 86 KiB

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 134 KiB

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

@@ -1,4 +1,6 @@
<vector android:height="48dp" android:viewportHeight="24.0"
<vector
android:tint="?attr/colorControlNormal"
android:height="48dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M12,6c3.87,0 7,3.13 7,7 0,0.84 -0.16,1.65 -0.43,2.4l1.52,1.52c0.58,-1.19 0.91,-2.51 0.91,-3.92 0,-4.97 -4.03,-9 -9,-9 -1.41,0 -2.73,0.33 -3.92,0.91L9.6,6.43C10.35,6.16 11.16,6 12,6zM22,5.72l-4.6,-3.86 -1.29,1.53 4.6,3.86L22,5.72zM2.92,2.29L1.65,3.57 2.98,4.9l-1.11,0.93 1.42,1.42 1.11,-0.94 0.8,0.8C3.83,8.69 3,10.75 3,13c0,4.97 4.02,9 9,9 2.25,0 4.31,-0.83 5.89,-2.2l2.2,2.2 1.27,-1.27L3.89,3.27l-0.97,-0.98zM16.47,18.39C15.26,19.39 13.7,20 12,20c-3.87,0 -7,-3.13 -7,-7 0,-1.7 0.61,-3.26 1.61,-4.47l9.86,9.86zM8.02,3.28L6.6,1.86l-0.86,0.71 1.42,1.42 0.86,-0.71z"/>
</vector>
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,6 @@
<vector android:height="48dp" android:viewportHeight="24.0"
<vector
android:tint="?attr/colorControlNormal"
android:height="48dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M20.94,11c-0.46,-4.17 -3.77,-7.48 -7.94,-7.94V1h-2v2.06C6.83,3.52 3.52,6.83 3.06,11H1v2h2.06c0.46,4.17 3.77,7.48 7.94,7.94V23h2v-2.06c4.17,-0.46 7.48,-3.77 7.94,-7.94H23v-2h-2.06zM12,19c-3.87,0 -7,-3.13 -7,-7s3.13,-7 7,-7 7,3.13 7,7 -3.13,7 -7,7z"/>
</vector>
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,6 @@
<vector android:height="48dp" android:viewportHeight="24.0"
<vector
android:tint="?attr/colorControlNormal"
android:height="48dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.87 -3.13,-7 -7,-7zM12,11.5c-1.38,0 -2.5,-1.12 -2.5,-2.5s1.12,-2.5 2.5,-2.5 2.5,1.12 2.5,2.5 -1.12,2.5 -2.5,2.5z"/>
</vector>
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M15.9,5c-0.17,0 -0.32,0.09 -0.41,0.23l-0.07,0.15 -5.18,11.65c-0.16,0.29 -0.26,0.61 -0.26,0.96 0,1.11 0.9,2.01 2.01,2.01 0.96,0 1.77,-0.68 1.96,-1.59l0.01,-0.03L16.4,5.5c0,-0.28 -0.22,-0.5 -0.5,-0.5zM1,9l2,2c2.88,-2.88 6.79,-4.08 10.53,-3.62l1.19,-2.68C9.89,3.84 4.74,5.27 1,9zM21,11l2,-2c-1.64,-1.64 -3.55,-2.82 -5.59,-3.57l-0.53,2.82c1.5,0.62 2.9,1.53 4.12,2.75zM17,15l2,-2c-0.8,-0.8 -1.7,-1.42 -2.66,-1.89l-0.55,2.92c0.42,0.27 0.83,0.59 1.21,0.97zM5,13l2,2c1.13,-1.13 2.56,-1.79 4.03,-2l1.28,-2.88c-2.63,-0.08 -5.3,0.87 -7.31,2.88z"/>
</vector>
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector android:height="48dp" android:viewportHeight="24.0"
<vector android:tint="?attr/colorControlNormal"
android:height="48dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M6,19h4L10,5L6,5v14zM14,5v14h4L18,5h-4z"/>
</vector>
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,4 @@
<vector android:height="48dp" android:viewportHeight="24.0"
<vector android:tint="?attr/colorControlNormal" android:height="48dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
</vector>
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="48dp"
android:height="48dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -11,6 +11,7 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:itemIconTint="@color/white"
android:id="@+id/drawer_layout">
<FrameLayout
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -14,7 +15,7 @@
android:layout_margin="@dimen/space_large"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/login_title"
tools:text="@string/login_title_create"
android:layout_marginBottom="@dimen/space_medium"
@@ -23,7 +24,7 @@
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/login_explain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -31,10 +32,11 @@
tools:text="@string/login_explain_create"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<androidx.appcompat.widget.AppCompatEditText
<EditText
android:id="@+id/input_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="username"
android:drawableStart="@drawable/ic_perm_identity_black_24dp"
android:drawableLeft="@drawable/ic_perm_identity_black_24dp"
android:drawablePadding="@dimen/space_medium"
@@ -48,8 +50,9 @@
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/space_large"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatEditText
<EditText
android:id="@+id/input_password"
android:autofillHints="password"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
@@ -67,10 +70,10 @@
android:layout_height="wrap_content"
android:padding="@dimen/space_medium"
android:background="@android:color/transparent"
android:src="@drawable/ic_visibility_black_24dp" />
app:srcCompat="@drawable/ic_visibility_black_24dp" />
</LinearLayout>
<androidx.appcompat.widget.AppCompatButton
<Button
android:id="@+id/button_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -78,7 +81,7 @@
android:theme="@style/button_highlighted"
tools:text="@string/login_button_create"/>
<androidx.appcompat.widget.AppCompatButton
<Button
android:id="@+id/button_no_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -88,7 +91,7 @@
android:theme="@style/button"
android:text="@string/login_button_continue"/>
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/text_register"
android:gravity="center"
android:layout_width="match_parent"
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:background="@drawable/bg_launch_gradient"
android:layout_width="match_parent"
@@ -8,7 +9,7 @@
<ImageView
android:id="@+id/icon_launch_map"
android:contentDescription="@string/application_long"
android:src="@drawable/icon_launch_map"
app:srcCompat="@drawable/icon_launch_map"
android:layout_alignParentBottom="true"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
@@ -24,14 +25,14 @@
<ImageView
android:contentDescription="@null"
android:src="@drawable/icon_launch_text"
app:srcCompat="@drawable/icon_launch_text"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ImageView
android:id="@+id/icon_launch_person"
android:src="@drawable/icon_launch_person"
app:srcCompat="@drawable/icon_launch_person"
android:contentDescription="@null"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
@@ -29,8 +29,8 @@
app:tabMode="fixed"
app:tabGravity="fill"
app:elevation="6dp"
app:tabTextColor="?android:attr/textColorPrimaryInverse"
app:tabSelectedTextColor="?android:attr/textColorPrimaryInverse"
app:tabTextColor="@color/white"
app:tabSelectedTextColor="@color/colorAccent"
app:tabIndicatorColor="@color/colorAccent"
android:minHeight="?attr/actionBarSize"/>
@@ -53,9 +53,10 @@
android:layout_marginEnd="@dimen/space_medium"
app:layout_dodgeInsetEdges="bottom"
app:layout_insetEdge="bottom"
android:contentDescription="@string/map_share"
app:layout_anchorGravity="top|right"
app:layout_anchor="@id/detail_sheet"
android:src="@drawable/ic_share_black_24dp"
app:srcCompat="@drawable/ic_share_black_24dp"
style="@style/button_fab_highlighted"/>
@@ -66,10 +67,10 @@
android:layout_marginRight="@dimen/space_medium"
android:layout_marginEnd="@dimen/space_medium"
android:layout_marginBottom="64dp"
android:contentDescription="@string/nav_share"
android:contentDescription="@string/map_mode"
app:layout_anchor="@id/buttonShare"
app:layout_anchorGravity="top|right"
android:src="@drawable/ic_gps_not_fixed_black_24dp"
app:srcCompat="@drawable/ic_gps_not_fixed_black_24dp"
style="@style/button_fab"/>
@@ -36,7 +36,7 @@
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/share_explain"
android:text="@string/share_explain_create"
android:layout_marginBottom="@dimen/space_medium"
@@ -44,9 +44,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatEditText
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"
android:maxLines="1"
android:drawablePadding="@dimen/space_medium"
android:textAppearance="?android:attr/textAppearanceMedium"
@@ -58,9 +59,10 @@
android:drawableStart="@drawable/ic_message_black_24dp"
android:drawableLeft="@drawable/ic_message_black_24dp"/>
<androidx.appcompat.widget.AppCompatEditText
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"
android:maxLines="1"
android:drawablePadding="@dimen/space_medium"
android:maxLength="140"
@@ -79,12 +81,12 @@
android:layout_marginBottom="@dimen/space_medium"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:text="@string/share_creation_time"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/share_creation_date"
android:textAppearance="?android:attr/textAppearanceMedium"
android:gravity="end"
@@ -92,7 +94,7 @@
tools:text="1.1.2003"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/share_creation_time"
android:textAppearance="?android:attr/textAppearanceMedium"
android:gravity="end"
@@ -109,12 +111,12 @@
android:layout_marginBottom="@dimen/space_medium"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:text="@string/share_expiration_time"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/share_expiration_date"
android:textAppearance="@style/text_medium_hyperlink"
android:gravity="end"
@@ -122,7 +124,7 @@
tools:text="1.1.2003"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/share_expiration_time"
style="@style/text_medium_hyperlink"
android:gravity="end"
@@ -142,7 +144,7 @@
android:layout_marginBottom="@dimen/space_medium"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatButton
<Button
android:id="@+id/share_button_link"
android:text="@string/share_action_link"
android:drawableStart="@drawable/ic_link_black_24dp"
@@ -162,7 +164,7 @@
android:paddingTop="@dimen/space_medium"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatCheckBox
<CheckBox
android:id="@+id/share_paused"
android:text="@string/share_paused"
android:textAppearance="@style/text_small_hyperlink"
@@ -187,7 +189,7 @@
android:layout_gravity="center_horizontal"
android:id="@+id/share_button_layout"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatButton
<Button
android:id="@+id/share_button_delete"
android:text="@string/share_action_delete"
android:layout_weight="1"
@@ -196,7 +198,7 @@
android:theme="@style/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatButton
<Button
android:id="@+id/share_button_save"
android:text="@string/share_action_save"
android:layout_weight="1"
@@ -205,7 +207,7 @@
android:theme="@style/button_highlighted"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatButton
<Button
android:id="@+id/share_button_create"
android:text="@string/share_action_create"
android:layout_weight="1"
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.AppCompatTextView
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:text="Pick an action"
android:id="@+id/dialog_text"
android:drawableLeft="@drawable/ic_launch_black_24dp"
android:drawableStart="@drawable/ic_launch_black_24dp"
app:drawableStartCompat="@drawable/ic_launch_black_24dp"
android:drawablePadding="@dimen/space_large"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
@@ -1,4 +1,5 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/view_detail_plain"
android:layout_width="match_parent"
@@ -10,7 +11,8 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatImageView android:src="@drawable/ic_share_black_48dp"
<ImageView app:srcCompat="@drawable/ic_share_black_48dp"
android:contentDescription="@null"
android:id="@+id/view_detail_status"
android:paddingRight="4dp"
android:paddingEnd="4dp"
@@ -27,12 +29,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/share_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/view_detail_name"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Marcus Handte"
@@ -48,13 +50,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/view_detail_creation_label"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/share_creation_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/view_detail_creation_time"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="12/12/12 10:30"
@@ -70,12 +72,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/share_expiration_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/view_detail_expiration_time"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="12/12/12 10:30"
@@ -98,15 +100,15 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/view_detail_message_line">
<androidx.appcompat.widget.AppCompatImageView
android:src="@drawable/ic_message_black_24dp"
<ImageView
app:srcCompat="@drawable/ic_message_black_24dp"
android:paddingLeft="14dp"
android:paddingRight="14dp"
android:alpha="0.75"
android:contentDescription="@string/share_hint_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/view_detail_message"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Message"
@@ -121,16 +123,16 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/view_detail_destination_line">
<androidx.appcompat.widget.AppCompatImageView
<ImageView
android:contentDescription="@string/share_hint_message"
android:src="@drawable/ic_card_travel_black_24dp"
app:srcCompat="@drawable/ic_card_travel_black_24dp"
android:paddingLeft="14dp"
android:paddingRight="14dp"
android:alpha="0.75"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/view_detail_destination"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Destination"
@@ -145,16 +147,16 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/view_detail_position_line">
<androidx.appcompat.widget.AppCompatImageView
<ImageView
android:contentDescription="@string/share_hint_position"
android:src="@drawable/ic_gps_fixed_black_24dp"
app:srcCompat="@drawable/ic_gps_fixed_black_24dp"
android:paddingLeft="14dp"
android:paddingRight="14dp"
android:alpha="0.75"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/view_detail_position"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Available"
@@ -169,16 +171,16 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/view_detail_updated_line">
<androidx.appcompat.widget.AppCompatImageView
<ImageView
android:contentDescription="@string/share_hint_updated"
android:src="@drawable/ic_update_black_24dp"
app:srcCompat="@drawable/ic_update_black_24dp"
android:paddingLeft="14dp"
android:paddingRight="14dp"
android:alpha="0.75"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/view_detail_updated"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Last update ..."
@@ -192,16 +194,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatImageView
<ImageView
android:contentDescription="@string/share_token"
android:src="@drawable/ic_vpn_key_black_24dp"
app:srcCompat="@drawable/ic_vpn_key_black_24dp"
android:paddingLeft="14dp"
android:paddingRight="14dp"
android:alpha="0.75"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/view_detail_token"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="abcdefghijklmnopqrs"
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/icon_header"
app:srcCompat="@drawable/icon_header"
android:contentDescription="@null"
android:scaleType="centerCrop" />
@@ -25,6 +26,7 @@
android:layout_height="wrap_content"
tools:text="Sony Xperia Foo"
android:layout_gravity="end"
android:textColor="@color/white"
android:id="@+id/view_header_device"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
/>
@@ -32,6 +34,7 @@
android:layout_height="wrap_content"
android:id="@+id/view_header_username"
android:layout_gravity="end"
android:textColor="@color/white"
tools:text="John Doe"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
android:textStyle="bold"/>
@@ -19,8 +19,9 @@
android:layout_toLeftOf="@android:id/text1"
android:layout_toStartOf="@android:id/text1"
tools:src="@drawable/ic_call_received_white_24dp"
app:tint="@color/white"
android:id="@android:id/icon"/>
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_centerInParent="true"
@@ -5,11 +5,20 @@
<string name="terms_button_accept">Bedingungen annehmen</string>
<string name="terms_permisson_checkbox">Erlaubst Du uns die anonyme Nutzung Deiner Positionsdaten für Forschungszwecke? Du kannst Deine Wahl jederzeit in den Einstellungen der App ändern.</string>
<string name="permission_required">Berechtigung erforderlich</string>
<string name="permission_foreground_explain">Damit Du Deinen Standort in der Karte anzeigen und mit anderen teilen kannst, benötigt Maptology die Berechtigung zum Zugriff auf Deinen Standort.</string>
<string name="permission_background_explain">Damit Du Deinen Standort auch dann teilen kannst, wenn Du die App nicht geöffnet hast, benötigt Maptology die Berechtigung zur Standortbestimmung im Hintergrund.</string>
<string name="permission_missing">Für die Standortbestimmung fehlt eine wichtige Berechtigung.</string>
<string name="permission_configure">Ändern</string>
<!-- a language code that we will use to detect the translation currently active -->
<string name="language_code">de</string>
<!-- map constants -->
<string name="map_attribution">Kartendaten: &#169; OpenStreetMap | Visualisierung: &#169; Locoslab GmbH</string>
<string name="map_share">Freigabe erstellen</string>
<string name="map_mode">Ansicht ändern</string>
<!-- constants used in the notice related views -->
<string name="menu_notice_update_title">Aktualisieren</string>
@@ -23,6 +32,7 @@
<string name="localization_notification_wifi">Suche Wi-Fi Netze</string>
<string name="localization_notification_net">Bestimme Netzstandort</string>
<string name="localization_notification_upload">Teile Standort</string>
<string name="localization_notification_logger">Erfasse Sensordaten</string>
<string name="localization_channel_name">Standortbestimmung</string>
<string name="localization_channel_description">Benachrichtigungen über die Standortbestimmung im Hintergrund.</string>
@@ -120,6 +130,8 @@
<string name="setting_category_privacy">Datenschutz</string>
<string name="setting_privacy_localize_title">Standortbestimmung</string>
<string name="setting_privacy_localize_summary">Aktiviert die Standortbestimmung und -freigabe im Hintergrund. Deaktivierung beendet die Standortbestimmung vollständig.</string>
<string name="setting_privacy_loggable_title">Sensorerfassung</string>
<string name="setting_privacy_loggable_summary">Aktiviert die automatische Erfassung von Sensordaten im Hintergrund, sobald das Gerät mit Strom versorgt wird.</string>
<string name="setting_privacy_share_title">Standortveröffentlichung</string>
<string name="setting_privacy_share_summary">Erlaubt die anonyme Nutzung aller Standortdaten zu Forschungszwecken. Bei Deaktivierung erfolgt keine Nutzung durch uns und die Zugriffskontrolle erfolgt nur auf Basis Deiner Freigaben.</string>
<string name="setting_privacy_analyze_title">Standortanalyse</string>
@@ -10,6 +10,7 @@
<string name="maptology_url_register" translatable="false">https://www.maptology.com/app/register</string>
<string name="maptology_url_places" translatable="false">https://www.maptology.com/app/places</string>
<bool name="privacy_localize_default">true</bool>
<bool name="privacy_loggable_default">false</bool>
<bool name="privacy_analyze_default">false</bool>
<bool name="privacy_share_default">false</bool>
<bool name="terms_accepted_default">false</bool>
@@ -5,11 +5,19 @@
<string name="terms_button_accept">Accept conditions</string>
<string name="terms_permisson_checkbox">Do you want to share your location anonymously for research? You can change your decision in the settings at any time.</string>
<string name="permission_required">Permission required</string>
<string name="permission_foreground_explain">Maptology needs permission to access your location to be able to display it on a map and to share it with your friends.</string>
<string name="permission_background_explain">Maptology needs permission to access your location in the background, so you can share your location even when you are not using the app.</string>
<string name="permission_missing">Localization is missing an important permission.</string>
<string name="permission_configure">Setup</string>
<!-- a language code that we will use to detect the translation currently active -->
<string name="language_code">en</string>
<!-- map constants -->
<string name="map_attribution">Map data: &#169; OpenStreetMap | Visualization: &#169; Locoslab GmbH</string>
<string name="map_share">Create share</string>
<string name="map_mode">Change view</string>
<!-- constants used in the notice related views -->
<string name="menu_notice_update_title">Update</string>
@@ -24,6 +32,7 @@
<string name="localization_notification_gps">Acquiring GPS position</string>
<string name="localization_notification_wifi">Scanning Wi-Fi networks</string>
<string name="localization_notification_net">Acquiring net-based position</string>
<string name="localization_notification_logger">Receiving sensor data</string>
<string name="localization_notification_upload">Uploading location</string>
<string name="localization_channel_name">Localization</string>
@@ -123,6 +132,8 @@
<string name="setting_category_privacy">Privacy</string>
<string name="setting_privacy_localize_title">Localization</string>
<string name="setting_privacy_localize_summary">Enables background localization and location-sharing. If disabled, the application will no longer try to determine your location.</string>
<string name="setting_privacy_loggable_title">Sensing</string>
<string name="setting_privacy_loggable_summary">Enables automatic sensor data capturing, whenever the device is connected to an external power source.</string>
<string name="setting_privacy_share_title">Research</string>
<string name="setting_privacy_share_summary">Allows us to analyze your locations for research purposes. If disabled, we will not analyze your location data and access is controlled only through your shares.</string>
<string name="setting_privacy_analyze_title">Analysis</string>
+3 -2
View File
@@ -1,13 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.MaptologyTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="Theme.MaptologyTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="actionBarStyle">@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="preferenceTheme">@style/settingsTheme</item>
</style>
<style name="Theme.MaptologyTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<style name="Theme.MaptologyTheme.NoActionBar" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
@@ -8,6 +8,12 @@
android:defaultValue="@bool/privacy_localize_default"
android:summary="@string/setting_privacy_localize_summary"
android:title="@string/setting_privacy_localize_title" />
<CheckBoxPreference
android:icon="@drawable/ic_network_check_black_24dp"
android:key="privacy_loggable"
android:defaultValue="@bool/privacy_loggable_default"
android:summary="@string/setting_privacy_loggable_summary"
android:title="@string/setting_privacy_loggable_title" />
<CheckBoxPreference
android:icon="@drawable/ic_share_black_24dp"
android:key="privacy_share"
@@ -0,0 +1,74 @@
package com.maptology.android.app.test.codec;
import com.maptology.android.app.util.DeltaCodec;
import org.junit.Assert;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
/**
* Test cases for the delta codec.
*
* @author Marcus
*/
public class DeltaCodecTest {
/**
* Tests that the delta codec can encode and decode data.
*/
@Test
public void testReadWriteDeltaCodec() {
for (int i = 1; i < 5; i++) {
DeltaCodec codec = new DeltaCodec(i);
List<long[]> expected = generateTestData(i, 100);
String encoded = codec.encode(expected);
List<long[]> actual = codec.decode(encoded, new ArrayList<long[]>());
assertEquals(expected, actual);
}
}
/**
* Generates some random data for the tests.
*
* @param length The length of the arrays.
* @param size The size of the list.
* @return The list with arrays of the specified length.
*/
public List<long[]> generateTestData(int length, int size) {
List<long[]> result = new ArrayList<>();
for (int i = 0; i < size; i++) {
long[] data = new long[length];
result.add(data);
for (int j = 0; j < data.length; j++) {
data[j] = i * j;
if (i % 2 == 0) data[j] = -data[j];
}
}
return result;
}
/**
* Ensures that the two lists of arrays are identical in terms of contents.
*
* @param expected The expected list.
* @param actual The actual list.
*/
public void assertEquals(List<long[]> expected, List<long[]> actual) {
Assert.assertEquals("Size must match.", expected.size(), actual.size());
for (int i = 0; i < expected.size(); i++) {
long[] e = expected.get(i);
long[] a = actual.get(i);
Assert.assertEquals("Length must match.", e.length, a.length);
for (int j = 0; j < e.length; j++)
Assert.assertEquals("Value must match.", e[j], a[j]);
}
}
}
@@ -5,8 +5,8 @@ import android.location.LocationManager;
import androidx.test.core.app.ApplicationProvider;
import com.maptology.android.app.location.LocationStore;
import com.maptology.android.app.model.Network;
import com.maptology.android.app.model.Position;
import com.maptology.android.app.location.LocationNetwork;
import com.maptology.android.app.location.LocationPosition;
import com.maptology.android.feign.model.Coordinate;
import com.maptology.android.feign.model.ReleasedLocation;
import org.junit.Assert;
@@ -18,6 +18,7 @@ import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowLog;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
@@ -43,22 +44,27 @@ public class LocationStoreTest {
ReleasedLocation r1 = createLocation(1);
store.addUpdate(r1);
Assert.assertEquals("Should contain one entry.", 1, store.getUpdateCount());
Assert.assertEquals("Should contain two entries", 2, store.getMetadataCount());
List<Long> ids = store.getUpdates(100);
Assert.assertEquals("Should contain one entry.", 1, ids.size());
ReleasedLocation loaded = store.getUpdate(ids.get(0));
Assert.assertNotNull("Loaded should exist.", loaded);
System.out.println(loaded.getMetadata());
assertEquals(r1, loaded);
ReleasedLocation r2 = createLocation(2);
store.addUpdate(r2);
ids = store.getUpdates(100);
Assert.assertEquals("Should contain two entries.", 2, ids.size());
Assert.assertEquals("Should contain two entries", 4, store.getMetadataCount());
loaded = store.getUpdate(ids.get(1));
Assert.assertNotNull("Loaded should exist.", loaded);
assertEquals(r2, loaded);
store.removeUpdate(ids.get(0));
Assert.assertEquals("Should contain one entry.", 1, store.getUpdateCount());
Assert.assertEquals("Should contain two entries", 2, store.getMetadataCount());
store.removeUpdate(ids.get(1));
Assert.assertEquals("Should contain no entries", 0, store.getUpdateCount());
Assert.assertEquals("Should contain two entries", 0, store.getMetadataCount());
}
/**
@@ -82,6 +88,9 @@ public class LocationStoreTest {
r.setAnalyzable(true);
r.setVersion(12);
r.setAccuracy(1d);
r.setMetadata(new HashMap<String, String>());
r.getMetadata().put("key_a", "value_a");
r.getMetadata().put("key_b", "value_b");
return r;
}
@@ -103,22 +112,26 @@ public class LocationStoreTest {
Assert.assertEquals("Speeed should match.", e.getSpeed(), a.getSpeed());
Assert.assertEquals("Alt should match.", e.getAltitude(), a.getAltitude());
Assert.assertEquals("Bearing should match.", e.getBearing(), a.getBearing());
Assert.assertEquals("Share should match.", e.getSharable(), a.getSharable());
Assert.assertEquals("Analyze should match.", e.getAnalyzable(), a.getAnalyzable());
Assert.assertEquals("Share should match.", e.isSharable(), a.isSharable());
Assert.assertEquals("Analyze should match.", e.isAnalyzable(), a.isAnalyzable());
Assert.assertEquals("Version should match.", e.getVersion(), a.getVersion());
Assert.assertEquals("Accuracy should match.", e.getAccuracy(), a.getAccuracy());
Assert.assertEquals("Metadata should have same size.", e.getMetadata().size(), a.getMetadata().size());
for (String key: e.getMetadata().keySet()) {
Assert.assertEquals("Metadata value should match.", e.getMetadata().get(key), a.getMetadata().get(key));
}
}
@Test
public void testAddGetDeletePositions() {
LocationStore store = new LocationStore(ApplicationProvider.getApplicationContext());
Position p = createPosition(1);
LocationPosition p = createPosition(1);
p.getNetworks().addAll(createNetworks(5, "xyz"));
store.addPosition(p);
Assert.assertEquals("Should have one position.", 1, store.getPositionCount());
Assert.assertEquals("Should have 5 networks.", 5, store.getNetworkCount());
Position same = store.getPosition(p.getId());
LocationPosition same = store.getPosition(p.getId());
Assert.assertNotNull("Should be able to load stored position.", same);
}
@@ -128,7 +141,7 @@ public class LocationStoreTest {
* @param e The expected position.
* @param a The actual position.
*/
private void assertEquals(Position e, Position a) {
private void assertEquals(LocationPosition e, LocationPosition a) {
Assert.assertEquals("Should have same id.", e.getId(), a.getId());
Assert.assertEquals("Should have same usage.", e.getUsageTime(), a.getUsageTime());
Assert.assertEquals("Should have same time.", e.getCreationTime(), a.getCreationTime());
@@ -138,8 +151,8 @@ public class LocationStoreTest {
Assert.assertEquals("Should have same prec.", e.getAccuracy(), a.getAccuracy());
Assert.assertEquals("Should have same provider.", e.getProvider(), a.getProvider());
Assert.assertEquals("Should have same networks.", e.getNetworks().size(), a.getNetworks().size());
n: for (Network n: e.getNetworks()) {
for (Network x: a.getNetworks()) {
n: for (LocationNetwork n: e.getNetworks()) {
for (LocationNetwork x: a.getNetworks()) {
if (n.getBssid().equals(x.getBssid())) {
Assert.assertEquals("Should have same rssi", n.getRssi(), x.getRssi());
continue n;
@@ -155,8 +168,8 @@ public class LocationStoreTest {
* @param time The time to set.
* @return The position.
*/
private Position createPosition(long time) {
Position p = new Position();
private LocationPosition createPosition(long time) {
LocationPosition p = new LocationPosition();
p.setUsageTime(time);
p.setAltitude(2d);
p.setCreationTime(time);
@@ -174,10 +187,10 @@ public class LocationStoreTest {
* @param prefix The prefix.
* @return The list of networks.
*/
private List<Network> createNetworks(int count, String prefix) {
List<Network> result = new ArrayList<>();
private List<LocationNetwork> createNetworks(int count, String prefix) {
List<LocationNetwork> result = new ArrayList<>();
for (int i = 0; i < count; i++) {
Network n = new Network();
LocationNetwork n = new LocationNetwork();
n.setBssid(prefix + Integer.toString(i));
n.setRssi(i);
result.add(n);
@@ -52,7 +52,7 @@ public class NoticeStoreTest {
Assert.assertEquals("Creation time should be same.", notice.getCreationTime(), fetched.getCreationTime());
Assert.assertEquals("Modification time should be same.", notice.getModificationTime(), fetched.getModificationTime());
Assert.assertEquals("Expiration time should be same.", notice.getExpirationTime(), fetched.getExpirationTime());
Assert.assertEquals("Announced should be same.", notice.getAnnounced(), fetched.getAnnounced());
Assert.assertEquals("Announced should be same.", notice.isAnnounced(), fetched.isAnnounced());
Assert.assertEquals("Messages should be same.", notice.getMessages().size(), fetched.getMessages().size());
store.removeNotice(notice.getId());
Notice deleted = store.getNotice(notice.getId());
+15 -23
View File
@@ -1,5 +1,5 @@
plugins {
id 'org.detoeuf.swagger-codegen' version '1.7.4'
id 'org.hidetake.swagger.generator' version '2.18.1'
}
description = "Maptology Android Feign"
@@ -14,36 +14,28 @@ dependencies {
compile "io.github.openfeign:feign-core:9.4.0"
compile "io.github.openfeign:feign-jackson:9.4.0"
compileOnly "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.1"
swaggerCodegen 'io.swagger:swagger-codegen-cli:2.4.9'
}
sourceSets.main.java.srcDirs = ['src/main/java', 'build/swagger/src/main/java']
swagger {
inputSpec = file(project(':common-api:').buildDir.path + '/swagger/maptology.json')
outputDir = file("${project.buildDir}/swagger")
lang = 'java'
library = 'feign'
additionalProperties = [
'invokerPackage' : 'com.maptology.android.feign',
'modelPackage' : 'com.maptology.android.feign.model',
'apiPackage' : 'com.maptology.android.feign.api',
'dateLibrary' : 'java8'
]
systemProperties = [
'apis' : '',
'models' : '',
'supportingFiles' : 'false',
'modelDocs' : 'false',
'apiTests' : 'false',
'modelTests' : 'false'
]
swaggerSources {
mowesta {
inputFile = file(project(':common-api:').buildDir.path + '/swagger/maptology.json')
code {
outputDir = file("${project.buildDir}/swagger")
language = 'java'
configFile = file('config.json')
components = ['models', 'apis']
}
}
}
// require api build to access swagger definition
tasks['swagger'].dependsOn(project(':common-api').tasks['build'])
tasks['resolveSwaggerTemplate'].dependsOn(project(':common-api').tasks['build'])
// require swagger code gen before compilation
compileJava.dependsOn('swagger')
compileJava.dependsOn('generateSwaggerCode')
+7
View File
@@ -0,0 +1,7 @@
{
"library": "feign",
"modelPackage": "com.maptology.android.feign.model",
"apiPackage": "com.maptology.android.feign.api",
"invokerPackage": "com.maptology.android.feign",
"dateLibrary": "java8"
}
+68 -49
View File
@@ -1,36 +1,31 @@
buildscript {
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.8.1'
classpath 'com.google.android.gms:oss-licenses-plugin:0.9.5'
classpath files('gradle/gradle-android-eclipse-1.1.jar')
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.4'
classpath 'org.handte.gradle:gradle-android-eclipse:1.0.0'
}
repositories {
maven {
url = 'https://project.nes.uni-due.de/artifactory/releases';
url = 'https://project.nes.uni-due.de/nexus/repository/maven-public';
credentials { username = 'public'; password = 'public' }
authentication { basic(BasicAuthentication) }
}
maven {
url = 'https://project.nes.uni-due.de/artifactory/snaphsots';
credentials { username = 'public'; password = 'public' }
}
maven { url "http://repository.jboss.org/nexus/content/groups/public/" }
google()
mavenCentral()
jcenter()
}
}
allprojects {
apply plugin: 'maven-publish'
// set version for our project
group = 'com.maptology'
version = '1.0.3'
version = '1.0.8-SNAPSHOT'
// set versions for our libraries
ext {
// api dependencies
versionJavaee = '7.0'
versionJavaee = '8.0.0'
versionJaxb = '2.3.1'
versionAnnotation = '1.3.2'
versionSwagger = '1.5.22'
@@ -40,28 +35,31 @@ allprojects {
versionWildfly = '17.0.1.Final'
versionPicketbox = '5.0.3.Final'
// testing dependencies
versionJunit = '4.12'
versionJunit = '4.13.1'
versionArquillianContainer = '2.2.0.Final'
versionArquillianJunit = '1.4.1.Final'
versionArquillianJunit = '1.5.0.Final'
// thorntail dependencies
versionH2database = '1.4.196'
versionThorntail = '2.5.0.Final'
// android stuff
versionAndroidx = '1.0.0'
versionRobolectric = '4.3'
versionAndroidxCompat = '1.3.0'
versionAndroidxLegacy = '1.0.0'
versionAndroidxPreference = '1.1.1'
versionAndroidxCard = '1.0.0'
versionAndroidxRecycler = '1.2.1'
versionAndroidxMaterial = '1.3.0'
versionRobolectric = '4.3.1'
versionPlay = '17.0.0'
versionAndroidxTest = '1.2.0'
versionAndroidxTest = '1.4.0'
}
}
subprojects {
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'eclipse'
if (name.equals('android-app')) {
apply plugin: 'com.greensopinion.gradle-android-eclipse'
apply plugin: 'org.handte.gradle-android-eclipse'
apply plugin: 'com.android.application'
apply plugin: 'com.google.android.gms.oss-licenses-plugin'
@@ -85,17 +83,6 @@ subprojects {
configurations.eclipseTestConfig,
]
downloadSources = true
file {
beforeMerged { classpath ->
classpath.entries.add(new org.gradle.plugins.ide.eclipse.model.SourceFolder("build/generated/not_namespaced_r_class_sources/debug/processDebugResources/r/", "bin"))
}
whenMerged { classpath ->
classpath.entries.removeAll {
return ('con'.equals(it.getKind()) && it.getPath().startsWith('org.eclipse.jdt.launching.JRE_CONTAINER'))
}
}
}
}
}
@@ -126,25 +113,57 @@ subprojects {
repositories {
maven {
url = 'https://project.nes.uni-due.de/artifactory/releases';
url = 'https://project.nes.uni-due.de/nexus/repository/maven-public';
credentials { username = 'public'; password = 'public' }
authentication { basic(BasicAuthentication) }
}
maven {
url = 'https://project.nes.uni-due.de/artifactory/snaphsots';
credentials { username = 'public'; password = 'public' }
}
maven { url "http://repository.jboss.org/nexus/content/groups/public/" }
google()
mavenCentral()
jcenter()
}
artifactoryPublish.dependsOn('build')
artifactoryPublish {
publications(publishing.publications.maven);
publishing {
repositories {
maven {
url = version.endsWith('SNAPSHOT') ?
"https://project.nes.uni-due.de/nexus/repository/maven-snapshots" :
"https://project.nes.uni-due.de/nexus/repository/maven-releases"
credentials { username = 'jenkins'; password = System.properties['jenkins.nexus.password'] }
authentication { basic(BasicAuthentication) }
}
}
}
// rename subprojects in eclipse to avoid collisions with other projects
eclipse.project.name = 'maptology-' + project.name
}
tasks.register("generatePomFileForMavenPublication") { }
tasks.register("build") { }
// aquire locks to ensure that service-ejb and service-war are not running tests in parallel
def lock = new java.util.concurrent.locks.ReentrantLock()
def available = lock.newCondition()
def busy = new java.util.concurrent.atomic.AtomicBoolean()
def serializedTasks = []
def sequentialProjects = [ 'service-ejb', 'service-war' ]
gradle.taskGraph.beforeTask {
if (it.name == 'test' && it.project.name in sequentialProjects) {
serializedTasks << it
it.doFirst {
lock.lock()
while (busy.get()) {
available.await()
}
busy.set(true)
lock.unlock()
}
}
}
gradle.taskGraph.afterTask {
if (it in serializedTasks) {
lock.lock()
busy.set(false)
available.signal()
lock.unlock()
}
}
+14 -7
View File
@@ -6,8 +6,8 @@ description = 'Maptology Common Api'
dependencies {
testCompile "junit:junit:${versionJunit}"
compileOnly "javax.xml.bind:jaxb-api:${versionJaxb}"
compileOnly "javax:javaee-api:${versionJavaee}"
compile "javax.xml.bind:jaxb-api:${versionJaxb}"
compileOnly "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}"
compileOnly "io.swagger:swagger-annotations:${versionSwagger}"
compileOnly "com.fasterxml.jackson.core:jackson-annotations:${versionJackson}"
}
@@ -17,7 +17,7 @@ sourceSets {
test.compileClasspath += configurations.compileOnly
}
// generate swagger documenation from api using a plugin
// generate swagger documentation from api using a plugin
swagger {
apiSource {
attachSwaggerArtifact = true
@@ -29,24 +29,26 @@ swagger {
'com.maptology.api.device.IDeviceService',
'com.maptology.api.share.IShareService',
'com.maptology.api.location.ILocationService',
'com.maptology.api.position.IPositionService',
'com.maptology.api.privilege.IPrivilegeService',
'com.maptology.api.history.IHistoryService'
]
schemes = [ 'http', 'https']
host = 'www.maptology.com'
basePath = '/api'
info {
title = 'Maptology Service'
version = "${version}"
description = 'Maptology Service'
version = project.version
description = 'The application programming interface of Maptology.'
termsOfService = 'https://maptology.com/terms-of-service'
contact {
email = 'nes-admin@uni-due.de'
name = 'NES Universität Duisburg-Essen'
name = 'Networked Embedded Systems'
url = 'https://www.nes.uni-due.de'
}
license {
url = 'https://www.maptology.com/license'
name = 'Proprietary'
name = 'Maptology License'
}
}
swaggerFileName = 'maptology'
@@ -68,6 +70,11 @@ swagger {
description = 'Operations requiring admin privileges.'
type = 'basic'
}
securityDefinition {
name = 'scientist'
description = 'Operations requiring scientist privileges.'
type = 'basic'
}
}
}
@@ -46,7 +46,7 @@ public class PageConfig {
/**
* The maximum number of elements on the page.
*/
@ApiParam(name="pageSize", value="The maximum number of elements on the page.", defaultValue="20", allowableValues="range[1,100]")
@ApiParam(name="pageSize", value="The maximum number of elements on the page.", defaultValue="20", allowableValues="range[1,1000]")
@Min(1)
@Max(1000)
@QueryParam("pageSize")
@@ -38,6 +38,10 @@ public class Tags {
*/
public static final String VISIT = "Visit";
/**
* The tag for position endpoints.
*/
public static final String POSITION = "Position";
/**
* Tag for notice, log and version endpoints.
@@ -17,6 +17,11 @@ public class Authorizations {
* Basic auth for regular users.
*/
public static final String USER = "user";
/**
* Basic auth for scientists.
*/
public static final String SCIENTIST = "scientist";
/**
* Bearer auth for devices.

Some files were not shown because too many files have changed in this diff Show More