97 Commits
Author SHA1 Message Date
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
Marcus Handte 70c9a07469 Release 1.0.3
LocationBasedServices/maptology/master This commit looks good
2019-09-13 21:51:59 +02:00
Marcus Handte 32d97e9c78 Fix geocoder, bump android version code.
LocationBasedServices/maptology/master This commit looks good
2019-09-13 21:31:22 +02:00
Marcus Handte 9ac137b9f7 Add package lock.
LocationBasedServices/maptology/master This commit looks good
2019-09-13 21:11:33 +02:00
Marcus Handte 204c1b3e7a Fix android lint errors.
LocationBasedServices/maptology/master There was a failure building this commit
2019-09-13 21:07:31 +02:00
Marcus Handte 4a13f36971 Fix android timings and revert geocoder changes.
LocationBasedServices/maptology/master There was a failure building this commit
Use time tick to work around samsung scheduling differences.
Revert deprecation warning fix in geocoder to support current wildfly version.
2019-09-13 21:00:39 +02:00
Marcus Handte e1022fb785 Replace set window with set exact.
LocationBasedServices/maptology/master This commit looks good
2019-08-08 18:38:27 +02:00
Marcus Handte 35785b719c Update to 1.0.3-SNAPSHOT
LocationBasedServices/maptology/master This commit looks good
2019-08-08 09:35:49 +02:00
Marcus Handte 4f85f70d3e Release 1.0.2
LocationBasedServices/maptology/master This commit looks good
2019-08-08 09:29:25 +02:00
Marcus Handte 5bb2e6fee6 Fix android scheduling and layouts.
LocationBasedServices/maptology/master This commit looks good
Closes #64 Hide password on login.
Closes #63 Fix scheduling on Android 9.
Remove unused import in statistics bean.
2019-08-08 09:20:12 +02:00
handte d577cadf39 Improve logging and statistics.
LocationBasedServices/maptology/master This commit looks good
Avoid logging of credentials, except for failing device tokens.
Increase severity of invalid logins to simplfy intrusion detection.
Generate statistics about released positions as part of admin view.
2019-08-07 20:15:43 +02:00
handte cb4b3331f4 Improve layout of place order select.
LocationBasedServices/maptology/master This commit looks good
2019-08-07 16:31:42 +02:00
handte 12c5d79686 Update to 1.0.2-SNAPSHOT
LocationBasedServices/maptology/master This commit looks good
2019-08-07 16:21:11 +02:00
Marcus Handte 1a1219625f Release 1.0.1
LocationBasedServices/maptology/master This commit looks good
2019-08-07 15:32:54 +02:00
Marcus Handte 7633ca1053 Migrate app to androidx.
LocationBasedServices/maptology/master This commit looks good
2019-08-07 15:18:32 +02:00
Marcus Handte 274b9cb259 Fix outer join, reduce android liniting warnings.
LocationBasedServices/maptology/master This commit looks good
Fix spelling in strings.
Move filter condition in on of outer join.
Fix layout issues and remove unused resources.
Add target api to settings fragment.
Increase version number of app.
2019-08-07 13:55:50 +02:00
handte 9876848156 Fix order query, add terms, fix app icon, support Android 9.
LocationBasedServices/maptology/master This commit looks good
Closes #62 Change place and visit join to outer join.
Closes #61 Add attribution and open source licenses to app and webapp.
Closes #60 Change icon shape of Android app.
Closes #59 Add missing foreground service permission.
2019-08-07 12:47:48 +02:00
handte e193eec1f8 Add user interface to webapp to sort places.
LocationBasedServices/maptology/master This commit looks good
Closes #57 Support to sort places
2019-08-06 18:28:51 +02:00
handte 8922e67858 Add configurable order criterion to place pages.
LocationBasedServices/maptology/master This commit looks good
2019-08-06 16:33:58 +02:00
Marcus Handte a86053b4e3 Finalize app layout improvements.
LocationBasedServices/maptology/master This commit looks good
Limit size of views on large screens and make sure they are centered.
Improve start screen proportions to improve looks on landscape mode.
2019-08-05 13:58:17 +02:00
Marcus Handte 44a1543c6d Add account linking to android app.
LocationBasedServices/maptology/master This commit looks good
Closes #55 Allow linking of accounts after initialization.
Improve recycler view layouts on 10+ inch tablets.
Improve drawer menu using groups and revert strings to verbs.
2019-08-05 11:19:22 +02:00
Marcus Handte f351ad1412 Improve handling of multiple headers.
LocationBasedServices/maptology/master This commit looks good
2019-08-05 09:14:19 +02:00
Marcus Handte 4aea00d0b0 Improve tests, add rest method to associate user and device.
LocationBasedServices/maptology/master This commit looks good
Impove test stability (hopefully) by using direct references to ejbs.
Add documentation to tests and improve naming in helper classes.
Add new api to associate an existing device with a user account.
2019-08-04 14:59:59 +02:00
Marcus Handte 8b9fdf6aa1 Remove outdated files.
LocationBasedServices/maptology/master This commit looks good
2019-08-04 12:08:17 +02:00
Marcus Handte 6429ee23ef Update to 1.0.1-SNAPSHOT
LocationBasedServices/maptology/master There was a failure building this commit
2019-08-04 12:05:50 +02:00
311 changed files with 32520 additions and 9101 deletions
Vendored
+9 -7
View File
@@ -7,8 +7,8 @@ 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
gradleBuild.useWrapper = true
environment {
ANDROID_SDK_ROOT = '/var/lib/android-sdk'
@@ -21,6 +21,7 @@ node {
}
def version = ''
def release = false
// configure the deployer based on the version
stage('Configure') {
@@ -28,10 +29,11 @@ node {
println "Version is: '${version}'"
if (version.endsWith("-SNAPSHOT")) {
println "Using internal-snapshots for publication."
gradleBuild.deployer server: server, repo: 'internal-snapshots'
gradleBuild.deployer server: server, repo: 'internal-snapshots'
} else {
println "Using internal-releases for publication."
gradleBuild.deployer server: server, repo: 'internal-releases'
gradleBuild.deployer server: server, repo: 'internal-releases'
release = true
}
}
@@ -57,13 +59,13 @@ node {
// deploy the build output on the server
stage ('Deploy') {
if (env.BRANCH_NAME == "master") {
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@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/"
sh "scp -i ${keyfile} site-ear/build/libs/site-ear-${version}.ear wildfly@apps.nes.uni-due.de:/opt/wildfly-17-maptology/standalone/deployments/maptology.ear"
sh "scp -i ${keyfile} android-app/build/outputs/apk/release/*.apk wildfly@apps.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."
}
}
+28 -14
View File
@@ -3,16 +3,16 @@ description = "Maptology Android App"
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation project(":android-feign")
implementation "com.android.support:support-v4:${versionSupport}"
implementation "com.android.support:appcompat-v7:${versionSupport}"
implementation "com.android.support:design:${versionSupport}"
implementation "com.android.support:preference-v7:${versionSupport}"
implementation "com.android.support:cardview-v7:${versionSupport}"
implementation "com.android.support:recyclerview-v7:${versionSupport}"
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}"
testImplementation "org.robolectric:shadows-supportv4:${versionRobolectric}"
testImplementation "androidx.test:core:${versionAndroidx}"
testImplementation "androidx.test:core:${versionAndroidxTest}"
}
configurations {
@@ -22,15 +22,18 @@ configurations {
}
android {
compileSdkVersion 28
compileSdkVersion 29
defaultConfig {
applicationId "com.maptology.android.app"
minSdkVersion 14
targetSdkVersion 28
versionCode 4
versionName "1.0.0"
targetSdkVersion 29
versionCode 11
versionName "${version}"
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resValue "string", "application_long", "Maptology"
resValue "string", "application_short", "Maptology"
}
signingConfigs {
@@ -44,14 +47,21 @@ 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
if (System.properties['android.keystore.password'] != null) signingConfig signingConfigs.release
}
debug {
applicationIdSuffix ".debug"
versionNameSuffix "-dbg"
resValue "string", "application_long", "Maptology (Debug)"
resValue "string", "application_short", "M (Debug)"
}
}
testOptions {
unitTests {
includeAndroidResources = true
@@ -62,6 +72,10 @@ android {
disable 'RtlSymmetry', 'RelativeOverlap'
// abortOnError false
}
dexOptions {
javaMaxHeapSize "512m"
}
}
tasks.register('makeEclipseDir') {
+10 -1
View File
@@ -9,6 +9,7 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_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" />
<!-- required for notification with LED lights, this is idiotic -->
<uses-permission android:name="android.permission.VIBRATE"/>
@@ -50,9 +51,11 @@
android:exported="false"
android:label="@string/application_long">
</activity>
<activity
android:launchMode="singleTask"
android:name=".MainActivity"
android:windowSoftInputMode="adjustResize"
android:exported="true"
android:label="@string/application_long">
</activity>
@@ -61,11 +64,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>
+3
View File
@@ -71,4 +71,7 @@
<p>Email: <a href="mailto:marcus.handte@uni-due.de">marcus.handte@uni-due.de</a></p>
<h2>Lizenzhinweise</h2>
<p>Grundlage unserer Kartendarstellung und unserer Adressauflösung sind die Daten der <a href="http://www.openstreetmap.org">OpenStreetMap</a>, die gemäß der <a href="https://opendatacommons.org/licenses/odbl/">Open Data Commons Open Database Lizenz</a> (ODbL) durch die <a href="https://osmfoundation.org/">OpenStreetMap Foundation</a> (OSMF) verfügbar sind (© OpenStreetMap-Mitwirkende). Die Visualisierung der Kartendaten erfolgt mit Hilfe einer Bibliothek zur Bilderzeugung der<a href="http://www.locoslab.com"> Locoslab GmbH</a>. Die Auflösung von Adressen wird ebenfalls über Werkzeuge der <a href="http://www.locoslab.com">Locoslab GmbH</a> bewerkstelligt. Weitere Hinweise zu den Lizenzen verwendeten Bibliotheken findest Du in den Einstellungen der Android App und am unteren Rand der Webanwendung.</p>
</body></html>
@@ -0,0 +1,301 @@
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);
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,14 +30,12 @@ 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 android.support.v4.app.ActivityCompat;
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.pm.PackageInfoCompat;
import androidx.core.app.ActivityCompat;
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.
@@ -66,7 +59,7 @@ public class LocationService extends Service {
/**
* The minimum time between two localization attempts.
*/
private static final long LOCALIZATION_TIMEOUT = 60000;
private static final long LOCALIZATION_TIMEOUT = 55000;
/**
* The time to wait for wifi scans.
@@ -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.
@@ -196,6 +170,17 @@ public class LocationService extends Service {
}
};
/**
* A broadcast receiver to receive timer ticks in the background.
*/
private BroadcastReceiver timeTickReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Tick received.");
onStartCommand(null, 0, 0);
}
};
/**
* A location listener that simply forwards its locations to
* the service.
@@ -234,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
@@ -259,30 +244,19 @@ public class LocationService extends Service {
*/
private Runnable timeoutListener = null;
@Override
public IBinder onBind(Intent intent) {
// do not support binding
return null;
}
@Override
@SuppressLint("InlinedApi")
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);
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_TAG);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
registerReceiver(idleModeReceiver, new IntentFilter(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED));
registerReceiver(timeTickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));
}
@Override
@@ -304,6 +278,7 @@ public class LocationService extends Service {
app.getRepository().uploadingLocations.removeValueListener(uploadListener);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
unregisterReceiver(idleModeReceiver);
unregisterReceiver(timeTickReceiver);
Log.d(TAG, "Releasing wake lock.");
if (wakeLock.isHeld()) wakeLock.release();
stopForeground(true);
@@ -312,32 +287,36 @@ 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;
}
if (!isPeriodicExecution(intent)) {
Log.d(TAG, "Scheduling periodic execution.");
scheduleExecution(this, localizationTime);
}
// ensure that localization is only running, if it is not
// running already or has been run only seconds ago
// start localization, if we are not running one already
long now = SystemClock.elapsedRealtime();
if (currentState == LocationState.IDLE) {
if (isDeviceIdle()) {
onDeviceIdle();
} else if (now - localizationTime > LOCALIZATION_TIMEOUT - 1000) {
if (now - localizationTime > LOCALIZATION_TIMEOUT / 2) {
Log.d(TAG, "Starting localization state machine.");
changeState();
} else {
Log.d(TAG, "Ignoring start request while timeout has not expired.");
if (isDeviceIdle()) {
onDeviceIdle();
}
Log.d(TAG, "Scheduling periodic execution.");
scheduleExecution(this, localizationTime);
}
} else {
Log.d(TAG, "Ignoring start request while service is " + currentState + ".");
@@ -345,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.
*/
@@ -437,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;
@@ -552,18 +521,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);
@@ -592,19 +557,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.
@@ -646,7 +598,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;
}
@@ -692,10 +644,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);
@@ -716,10 +668,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());
@@ -735,7 +684,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());
@@ -776,40 +725,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.
*
@@ -844,17 +759,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.
*
@@ -872,19 +776,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);
}
/**
@@ -914,43 +807,23 @@ 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 periodic execution.
* Schedules the service for the next execution.
*
* @param context The context used to schedule this.
*/
private static void scheduleExecution(Context context, long lastTime) {
PendingIntent pending = createIntent(context);
AlarmManager manager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
long now = SystemClock.elapsedRealtime();
long next = Math.max(0, (lastTime + LOCALIZATION_TIMEOUT) - now);
long next = Math.max(5000, (lastTime + LOCALIZATION_TIMEOUT) - now);
Log.d(TAG, "Updating alarm to execute in " + next + " ms.");
manager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + next, LOCALIZATION_TIMEOUT, pending);
// this is too imprecise on Android 9
//manager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + next, LOCALIZATION_TIMEOUT, pending);
PendingIntent pending = createIntent(context);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
manager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + next, pending);
} else {
manager.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + next, LOCALIZATION_TIMEOUT / 2, pending);
}
}
/**
@@ -980,66 +853,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,684 @@
package com.maptology.android.app;
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
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,12 +1,14 @@
package com.maptology.android.app;
import com.maptology.android.app.fragment.LoginFragment;
import com.maptology.android.app.fragment.AbstractLoginFragment;
import com.maptology.android.app.fragment.LoginCreateFragment;
import com.maptology.android.app.fragment.LoginUpdateFragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.appcompat.app.AppCompatActivity;
/**
* The activity to login or create a device. The
@@ -23,11 +25,25 @@ public class LoginActivity extends AppCompatActivity {
setContentView(R.layout.activity_login);
Fragment f = getSupportFragmentManager().findFragmentById(R.id.coordinator);
if (f == null) {
// do everything in the fragment
AbstractLoginFragment loginFragment = null;
if (getApp().getRepository().deviceHandle.getValue() == null) {
loginFragment = new LoginCreateFragment();
} else {
loginFragment = new LoginUpdateFragment();
}
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.coordinator, new LoginFragment());
ft.replace(R.id.coordinator, loginFragment);
ft.commit();
}
}
private MaptologyApp getApp() {
return (MaptologyApp) getApplicationContext();
}
@Override
protected void onDestroy() {
if (isFinishing()) getApp().getRepository().creatingDevice.setValue(null);
super.onDestroy();
}
}
@@ -18,19 +18,21 @@ import com.maptology.android.feign.model.User;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.PermissionChecker;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import androidx.annotation.NonNull;
import com.google.android.material.navigation.NavigationView;
import androidx.core.app.ActivityCompat;
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 android.util.Log;
import android.view.MenuItem;
import android.view.View;
@@ -86,6 +88,21 @@ public class MainActivity extends AppCompatActivity implements
}
};
/**
* Updates the visibility of the menu items based on the login state.
*/
private IValueListener<DeviceHandle> deviceListener = new IValueListener<DeviceHandle>() {
@Override
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);
connect.setVisible(newValue.getUser() == null);
webapp.setVisible(newValue.getUser() != null);
}
}
};
/**
* Navigation Drawer menu.
*/
@@ -109,7 +126,7 @@ public class MainActivity extends AppCompatActivity implements
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = (MaptologyApp) getApplicationContext();
LocationService.runService(this);
AbstractService.runService(this);
setTitle(R.string.application_short);
if (TabletUtil.isLandscapeTablet(this)) {
setContentView(R.layout.activity_main_tablet);
@@ -128,10 +145,12 @@ public class MainActivity extends AppCompatActivity implements
protected void onResume() {
super.onResume();
app.getRepository().user.addValueListener(userListener, true);
app.getRepository().deviceHandle.addValueListener(deviceListener, true);
}
@Override
protected void onPause() {
app.getRepository().deviceHandle.removeValueListener(deviceListener);
app.getRepository().user.removeValueListener(userListener);
super.onPause();
}
@@ -154,26 +173,27 @@ public class MainActivity extends AppCompatActivity implements
switch (item.getItemId()) {
case R.id.menu_notice:
setScreen(Screen.NOTICE);
closeDrawerIfNeeded();
break;
case R.id.menu_map:
setScreen(Screen.MAP);
closeDrawerIfNeeded();
break;
case R.id.menu_share:
createShare();
closeDrawerIfNeeded();
break;
case R.id.menu_manage:
setScreen(Screen.MANAGE);
closeDrawerIfNeeded();
break;
case R.id.menu_settings:
showSettings();
closeDrawerIfNeeded();
break;
case R.id.menu_connect:
showLogin();
break;
case R.id.menu_webapp:
showPlaces();
break;
}
closeDrawerIfNeeded();
return false;
}
});
@@ -242,8 +262,8 @@ 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) == PackageManager.PERMISSION_GRANTED &&
PermissionChecker.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
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);
@@ -348,6 +368,16 @@ public class MainActivity extends AppCompatActivity implements
showSlave(new SettingsFragment());
}
private void showLogin() {
startActivity(new Intent(this, LoginActivity.class));
}
private void showPlaces() {
// start browser to goto places
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.maptology_url_places)));
startActivity(intent);
}
private void showSlave(Fragment fragment) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.container, fragment);
@@ -1,6 +1,9 @@
package com.maptology.android.app;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.maptology.android.app.location.LocationStore;
import com.maptology.android.app.notice.NoticeStore;
@@ -16,7 +19,7 @@ import com.maptology.android.feign.model.Message;
import android.app.Application;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import android.util.Log;
import feign.RequestInterceptor;
import feign.RequestTemplate;
@@ -76,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);
}
}
};
@@ -195,6 +201,19 @@ public class MaptologyApp extends Application {
ApiClient client = new ApiClient();
client.setBasePath(getMaptologyUrl());
client.addAuthorization("basic", new BasicAuthRequestInterceptor(username, password));
if (repository.deviceHandle.getValue() != null) {
final String token = repository.deviceHandle.getValue().getToken();
client.addAuthorization("bearer", new RequestInterceptor() {
@Override
public void apply(RequestTemplate requestTemplate) {
Collection<String> headers = requestTemplate.headers().get("Authorization");
List<String> newHeaders = new ArrayList<>();
if (headers != null) newHeaders.addAll(headers);
newHeaders.add("Bearer " + token);
requestTemplate.header("Authorization", newHeaders);
}
});
}
return client.buildClient(DefaultApi.class);
}
@@ -5,15 +5,13 @@ import com.maptology.android.app.fragment.TermsFragment;
import com.maptology.android.app.model.Grant;
import com.maptology.android.app.repository.Repository;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
/**
@@ -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);
}
}
}
}
@@ -7,7 +7,7 @@ import com.maptology.android.app.util.DateFormatter;
import com.maptology.android.feign.model.Location;
import com.maptology.android.feign.model.ShareInfo;
import android.support.v7.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
@@ -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);
@@ -6,8 +6,8 @@ import com.maptology.android.app.model.Grant;
import com.maptology.android.app.share.ShareStore;
import android.database.Cursor;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -6,8 +6,8 @@ import com.maptology.android.app.notice.NoticeContract;
import com.maptology.android.app.util.DateFormatter;
import android.database.Cursor;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -6,8 +6,8 @@ import com.maptology.android.app.model.LocalShare;
import com.maptology.android.app.share.ShareStore;
import android.database.Cursor;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -4,8 +4,8 @@ import com.maptology.android.app.MaptologyApp;
import com.maptology.android.app.repository.Repository;
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.util.Log;
/**
@@ -1,72 +1,82 @@
package com.maptology.android.app.fragment;
import com.maptology.android.app.MainActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import androidx.appcompat.app.AlertDialog;
import android.text.method.PasswordTransformationMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.maptology.android.app.R;
import com.maptology.android.app.repository.AsyncError;
import com.maptology.android.app.repository.AsyncInteraction;
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.CreateDeviceTask;
import com.maptology.android.feign.model.DeviceHandle;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
/**
* Fragment that handles the login.
* A base class for fragment that handle the login.
*
* @author sarah
*/
public class LoginFragment extends AbstractFragment {
/**
* The listener that keeps track of the device creation.
*/
private IValueListener<DeviceHandle> deviceListener = new IValueListener<DeviceHandle>() {
@Override
public void onValueChanged(Value<DeviceHandle> source, DeviceHandle oldValue, DeviceHandle newValue) {
if (newValue != null) {
Intent intent = new Intent();
intent.setClass(getActivity(), MainActivity.class);
getActivity().startActivity(intent);
getActivity().finish();
}
}
};
public abstract class AbstractLoginFragment extends AbstractFragment {
private Button loginButton;
private Button noLoginButton;
private ImageButton passwordButton;
private TextView registerText;
private EditText usernameText;
private EditText passwordText;
private AlertDialog dialog;
private ProgressBar progressBar;
private int title;
private int explanation;
private int login;
private boolean passwordVisible = false;
/**
* The listener that listens to changes announced by the async task.
*/
private IValueListener<AsyncInteraction> creationListener = new IValueListener<AsyncInteraction>() {
private IValueListener<AsyncInteraction> loginListener = new IValueListener<AsyncInteraction>() {
@Override
public void onValueChanged(Value<AsyncInteraction> source, AsyncInteraction oldValue, AsyncInteraction newValue) {
onUpdateInteraction(newValue);
}
};
/**
* Creates a login fragment with the specified title resource,
* explanation resource and login button resource.
*
* @param title The string resource with the title.
* @param explanation The string resource with the explanation.
* @param login The string resource with the login button.
*/
public AbstractLoginFragment(int title, int explanation, int login) {
this.title = title;
this.explanation = explanation;
this.login = login;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_login, container, false);
TextView titleView = (TextView)view.findViewById(R.id.login_title);
titleView.setText(title);
TextView explainView = (TextView)view.findViewById(R.id.login_explain);
explainView.setText(explanation);
loginButton = (Button) view.findViewById(R.id.button_login);
loginButton.setText(login);
noLoginButton = (Button) view.findViewById(R.id.button_no_login);
registerText = (TextView) view.findViewById(R.id.text_register);
usernameText = (EditText) view.findViewById(R.id.input_username);
@@ -77,7 +87,6 @@ public class LoginFragment extends AbstractFragment {
public void onClick(View v) {
String username = usernameText.getText().toString();
String password = passwordText.getText().toString();
username = analyzeInput(username);
password = analyzeInput(password);
if (username == null || password == null) {
@@ -85,19 +94,22 @@ public class LoginFragment extends AbstractFragment {
builder.setMessage(R.string.login_failed_msg);
builder.setPositiveButton(android.R.string.ok, null);
builder.create().show();
return;
} else {
onLogin(username, password);
}
CreateDeviceTask task = new CreateDeviceTask(getApp(), username, password);
task.execute();
}
});
passwordButton = (ImageButton) view.findViewById(R.id.button_password);
passwordButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setPasswordVisible(!passwordVisible);
}
});
noLoginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getApp().getRepository().setAnalyzeable(false);
CreateDeviceTask task = new CreateDeviceTask(getApp());
task.execute();
onContinue();
}
});
registerText.setOnClickListener(new View.OnClickListener() {
@@ -111,6 +123,10 @@ public class LoginFragment extends AbstractFragment {
return view;
}
public abstract void onLogin(String username, String password);
public abstract void onContinue();
private void onUpdateInteraction(AsyncInteraction interaction) {
if (interaction == null) {
setEnabled(true);
@@ -151,6 +167,17 @@ public class LoginFragment extends AbstractFragment {
}
}
private void setPasswordVisible(boolean visible) {
if (visible) {
passwordButton.setImageResource(R.drawable.ic_visibility_off_black_24dp);
passwordText.setTransformationMethod(null);
} else {
passwordButton.setImageResource(R.drawable.ic_visibility_black_24dp);
passwordText.setTransformationMethod(new PasswordTransformationMethod());
}
this.passwordVisible = visible;
}
private void setEnabled(boolean enabled) {
loginButton.setEnabled(enabled);
noLoginButton.setEnabled(enabled);
@@ -158,6 +185,7 @@ public class LoginFragment extends AbstractFragment {
usernameText.setEnabled(enabled);
passwordText.setEnabled(enabled);
progressBar.setVisibility(enabled?View.GONE:View.VISIBLE);
if (!enabled) setPasswordVisible(false);
}
private String analyzeInput(String input) {
@@ -172,15 +200,13 @@ public class LoginFragment extends AbstractFragment {
public void onResume() {
super.onResume();
Repository repository = getRepository();
repository.creatingDevice.addValueListener(creationListener, true);
repository.deviceHandle.addValueListener(deviceListener, true);
repository.creatingDevice.addValueListener(loginListener, true);
}
@Override
public void onPause() {
Repository repository = getRepository();
repository.deviceHandle.removeValueListener(deviceListener);
repository.creatingDevice.removeValueListener(creationListener);
repository.creatingDevice.removeValueListener(loginListener);
super.onPause();
}
}
@@ -3,7 +3,7 @@ package com.maptology.android.app.fragment;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import androidx.fragment.app.DialogFragment;
/**
* A simple dialog with a date picker.
@@ -6,7 +6,7 @@ import com.maptology.android.app.map.MapMode;
import com.maptology.android.app.model.Grant;
import android.os.Bundle;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -7,13 +7,13 @@ import com.maptology.android.app.R;
import com.maptology.android.app.model.Grant;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.fragment.app.FragmentTransaction;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -15,10 +15,10 @@ import com.maptology.android.app.util.TabletUtil;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.Nullable;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -132,7 +132,7 @@ public class GrantListFragment extends AbstractFragment {
explainText = view.findViewById(R.id.fragment_list_grant_explain);
recyclerView = (RecyclerView) view.findViewById(R.id.grant_recycler);
int span = (TabletUtil.isLandscapeTablet(view.getContext()))?2:1;
recyclerView.setLayoutManager(new GridLayoutManager(container.getContext(), span));
recyclerView.setLayoutManager(new StaggeredGridLayoutManager(span, StaggeredGridLayoutManager.VERTICAL));
swipeRefreshLayout = (SwipeRefreshLayout)view.findViewById(R.id.fragment_grant_swipe);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
@@ -0,0 +1,71 @@
package com.maptology.android.app.fragment;
import com.maptology.android.app.MainActivity;
import com.maptology.android.app.R;
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.CreateDeviceTask;
import com.maptology.android.feign.model.DeviceHandle;
import android.content.Intent;
import androidx.appcompat.app.AlertDialog;
/**
* Fragment that handles the login.
*
* @author sarah
*/
public class LoginCreateFragment extends AbstractLoginFragment {
/**
* The listener that keeps track of the device creation.
*/
private IValueListener<DeviceHandle> deviceListener = new IValueListener<DeviceHandle>() {
@Override
public void onValueChanged(Value<DeviceHandle> source, DeviceHandle oldValue, DeviceHandle newValue) {
if (newValue != null) {
Intent intent = new Intent();
intent.setClass(getActivity(), MainActivity.class);
getActivity().startActivity(intent);
getActivity().finish();
}
}
};
/**
* Creates the fragment and sets the strings.
*/
public LoginCreateFragment() {
super(R.string.login_title_create, R.string.login_explain_create, R.string.login_button_create);
}
@Override
public void onLogin(String username, String password) {
CreateDeviceTask task = new CreateDeviceTask(getApp(), username, password);
task.execute();
}
@Override
public void onContinue() {
getApp().getRepository().setAnalyzeable(false);
CreateDeviceTask task = new CreateDeviceTask(getApp());
task.execute();
}
@Override
public void onResume() {
super.onResume();
Repository repository = getRepository();
repository.deviceHandle.addValueListener(deviceListener, true);
}
@Override
public void onPause() {
Repository repository = getRepository();
repository.deviceHandle.removeValueListener(deviceListener);
super.onPause();
}
}
@@ -0,0 +1,64 @@
package com.maptology.android.app.fragment;
import android.content.Intent;
import com.maptology.android.app.MainActivity;
import com.maptology.android.app.R;
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.UpdateDeviceTask;
import com.maptology.android.feign.model.DeviceHandle;
/**
* A fragment that enables the user to associate an existing device
* with an account.
*
* @author Marcus
*/
public class LoginUpdateFragment extends AbstractLoginFragment {
/**
* The listener that keeps track of the device updates.
*/
private IValueListener<DeviceHandle> deviceListener = new IValueListener<DeviceHandle>() {
@Override
public void onValueChanged(Value<DeviceHandle> source, DeviceHandle oldValue, DeviceHandle newValue) {
if (newValue != null && newValue.getUser() != null) {
getActivity().finish();
}
}
};
/**
* Creates the fragment and sets the strings.
*/
public LoginUpdateFragment() {
super(R.string.login_title_update, R.string.login_explain_update, R.string.login_button_update);
}
@Override
public void onLogin(String username, String password) {
UpdateDeviceTask task = new UpdateDeviceTask(getApp(), username, password);
task.execute();
}
@Override
public void onContinue() {
getActivity().finish();
}
@Override
public void onResume() {
super.onResume();
Repository repository = getRepository();
repository.deviceHandle.addValueListener(deviceListener, true);
}
@Override
public void onPause() {
Repository repository = getRepository();
repository.deviceHandle.removeValueListener(deviceListener);
super.onPause();
}
}
@@ -3,7 +3,7 @@ package com.maptology.android.app.fragment;
import com.maptology.android.app.R;
import android.os.Bundle;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -3,12 +3,12 @@ package com.maptology.android.app.fragment;
import com.maptology.android.app.R;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import androidx.annotation.Nullable;
import com.google.android.material.tabs.TabLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -1,10 +1,10 @@
package com.maptology.android.app.fragment;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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;
@@ -33,18 +33,16 @@ import com.maptology.android.feign.model.Coordinate;
import android.database.Cursor;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.util.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.
@@ -290,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
@@ -463,7 +461,7 @@ public class MapFragment extends AbstractFragment {
getRepository().mapMode.setValue(MapMode.values()[code]);
}
/**
* Applies the current map mode.
*/
@@ -8,10 +8,10 @@ import com.maptology.android.app.task.SyncNoticeTask;
import com.maptology.android.app.util.TabletUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.Nullable;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -89,7 +89,8 @@ public class NoticeListFragment extends AbstractFragment {
swipeLayout.setOnRefreshListener(refreshListener);
recyclerView = (RecyclerView)v.findViewById(R.id.fragment_notice_recycler);
int span = (TabletUtil.isLandscapeTablet(v.getContext()))?2:1;
recyclerView.setLayoutManager(new GridLayoutManager(container.getContext(), span));
StaggeredGridLayoutManager glm = new StaggeredGridLayoutManager(span, StaggeredGridLayoutManager.VERTICAL);
recyclerView.setLayoutManager(glm);
return v;
}
@@ -2,15 +2,16 @@
package com.maptology.android.app.fragment;
import java.text.SimpleDateFormat;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity;
import com.maptology.android.app.BuildConfig;
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;
import android.content.ActivityNotFoundException;
import android.content.Context;
@@ -21,12 +22,12 @@ import android.content.pm.PackageInfo;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v4.content.pm.PackageInfoCompat;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceFragmentCompat;
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen;
import androidx.core.content.pm.PackageInfoCompat;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceScreen;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -50,6 +51,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.
@@ -71,6 +82,11 @@ public class SettingsFragment extends PreferenceFragmentCompat {
*/
private static final String KEY_ABOUT_TERMS = "about_terms";
/**
* The key to show the oss licenses.
*/
private static final String KEY_ABOUT_LICENSES = "about_licenses";
/**
* Key to clear the cache.
*/
@@ -145,6 +161,10 @@ public class SettingsFragment extends PreferenceFragmentCompat {
bindReset();
bindClear();
bindTerms();
bindLicenses();
if (!isLoggerAvailable()) {
disableLogger();
}
return v;
}
@@ -159,6 +179,25 @@ public class SettingsFragment extends PreferenceFragmentCompat {
}
}
/**
* 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.
@@ -244,6 +283,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
* otherwise it will open the channel settings.
* @return The preference listener to trigger the action.
*/
@TargetApi(26)
private Preference.OnPreferenceClickListener createNotificationSettingsListener(final String packageName, final String channelId) {
return new Preference.OnPreferenceClickListener() {
@Override
@@ -328,6 +368,17 @@ public class SettingsFragment extends PreferenceFragmentCompat {
}
private void bindLicenses() {
setClickListener(KEY_ABOUT_LICENSES, new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
OssLicensesMenuActivity.setActivityTitle(getString(R.string.setting_about_licenses_title));
startActivity(new Intent(getApp(), OssLicensesMenuActivity.class));
return false;
}
});
}
/**
* Enables the developmentGroup mode.
*/
@@ -21,8 +21,8 @@ import android.app.TimePickerDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import androidx.annotation.Nullable;
import com.google.android.material.snackbar.Snackbar;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
@@ -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();
@@ -6,9 +6,9 @@ import com.maptology.android.app.model.LocalShare;
import com.maptology.android.app.util.TabletUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -81,7 +81,7 @@ public class ShareListFragment extends AbstractFragment {
explainText = view.findViewById(R.id.fragment_list_share_explain);
recyclerView = (RecyclerView) view.findViewById(R.id.share_recycler);
int span = (TabletUtil.isLandscapeTablet(view.getContext()))?2:1;
recyclerView.setLayoutManager(new GridLayoutManager(container.getContext(), span));
recyclerView.setLayoutManager(new StaggeredGridLayoutManager(span, StaggeredGridLayoutManager.VERTICAL));
return view;
}
@@ -9,7 +9,7 @@ import android.net.MailTo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -3,7 +3,7 @@ package com.maptology.android.app.fragment;
import android.app.Dialog;
import android.app.TimePickerDialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import androidx.fragment.app.DialogFragment;
/**
* A simple fragment that shows a time picker dialog.
@@ -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;
@@ -13,8 +13,8 @@ import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.util.Log;
/**
@@ -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.
*
@@ -6,8 +6,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.util.Log;
/**
@@ -12,8 +12,8 @@ import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.util.Log;
/**
@@ -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());
@@ -7,7 +7,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import android.content.Context;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import android.util.Log;
/**
@@ -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.
*/
@@ -167,6 +172,12 @@ public class Repository {
return getPreference(KEY_PRIVACY_LOCALIZE, R.bool.privacy_localize_default);
}
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.
*
@@ -3,8 +3,8 @@ package com.maptology.android.app.repository;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/**
* A value that can be observed by a value listener.
@@ -12,8 +12,8 @@ import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.util.Log;
/**
@@ -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());
@@ -19,8 +19,8 @@ import android.content.Intent;
import android.content.pm.PackageInfo;
import android.graphics.Color;
import android.os.Build;
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.pm.PackageInfoCompat;
import androidx.core.app.NotificationCompat;
import androidx.core.content.pm.PackageInfoCompat;
import android.util.Log;
/**
@@ -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 {
@@ -0,0 +1,162 @@
package com.maptology.android.app.task;
import android.os.Build;
import android.util.Log;
import com.maptology.android.app.MaptologyApp;
import com.maptology.android.app.R;
import com.maptology.android.app.repository.AsyncError;
import com.maptology.android.app.repository.AsyncInteraction;
import com.maptology.android.feign.model.Device;
import com.maptology.android.feign.model.DeviceHandle;
import com.maptology.android.feign.model.DeviceInfo;
import com.maptology.android.feign.model.User;
import java.net.HttpURLConnection;
import feign.FeignException;
/**
* A task that will associate an existing device with a user.
* The task will report the result through the repository.
*
* @author Marcus
*/
public class UpdateDeviceTask extends AbstractApiTask<Void, Void, AsyncError> {
/**
* The log tag for the task.
*/
private static final String TAG = "UpdateDeviceTask";
/**
* The error code for network errors.
*/
public static final int ERROR_NETWORK = 1;
/**
* The error code for login errors.
*/
public static final int ERROR_LOGIN = 2;
/**
* The error code if the device has been associated already.
*/
public static final int ERROR_UPDATE = 3;
/**
* The optional username.
*/
private String username;
/**
* The optional password.
*/
private String password;
/**
* The device that has been registered.
*/
private Device device;
/**
* The user that has been fetched.
*/
private User user;
/**
* Creates a create device task with the specified username and
* password.
*
* @param app The app.
* @param username The username.
* @param password The password.
*/
public UpdateDeviceTask(MaptologyApp app, String username, String password) {
super(app);
this.username = username;
this.password = password;
apiClient = app.getApiClient(username, password);
}
/**
* Executes the task.
*/
public void execute() {
app.getRepository().creatingDevice.setValue(new AsyncInteraction(false));
super.execute(new Void[0]);
}
@Override
protected AsyncError doInBackground(Void... voids) {
try {
user = apiClient.getCurrentUser();
Log.d(TAG, "Login success for " + username + " with id " + (user==null?"":user.getId()) + ".");
} catch (FeignException e) {
Log.d(TAG, "Login failure for user: " + e.status() + " " + e.getMessage());
return getError(e);
}
try {
device = apiClient.getCurrentDevice();
Log.d(TAG, "Login success for device with id " + (device==null?"":device.getId()) + ".");
} catch (FeignException e) {
Log.d(TAG, "Login failure for device:" + e.status() + " " + e.getMessage());
return getError(e);
}
try {
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());
return getError(e);
}
return null;
}
/**
* Converts a feign exception into an error.
*
* @param e The exception.
* @return The associated error.
*/
private AsyncError getError(FeignException e) {
if (e.status() == HttpURLConnection.HTTP_FORBIDDEN) {
return new AsyncError(ERROR_LOGIN, R.string.login_failed_msg);
} else if (e.status() == HttpURLConnection.HTTP_CONFLICT) {
return new AsyncError(ERROR_UPDATE, R.string.login_conflict_msg);
} else {
return new AsyncError(ERROR_NETWORK, R.string.login_device_failed);
}
}
@Override
protected void onPostExecute(AsyncError asyncError) {
AsyncInteraction interaction;
if (asyncError == null) {
interaction = new AsyncInteraction(true);
} else if (asyncError.getCode() == ERROR_LOGIN || asyncError.getCode() == ERROR_UPDATE){
// do not allow retry when username and password are wrong
interaction = new AsyncInteraction(asyncError);
} else {
// allow retry for everything else
final UpdateDeviceTask retry = new UpdateDeviceTask(app, username, password);
interaction = new AsyncInteraction(asyncError, new Runnable() {
@Override
public void run() {
retry.execute();
}
});
}
app.getRepository().creatingDevice.setValue(interaction);
DeviceHandle handle = app.getRepository().deviceHandle.getValue();
if (device != null && device.getUser() != null) {
Log.d(TAG, "Updating device handle.");
handle.setUser(device.getUser());
app.getRepository().deviceHandle.setValue(handle);
if (user != null && device.getUser().equals(user.getId())) {
Log.d(TAG, "Setting user directly.");
app.getRepository().user.setValue(user);
} else {
Log.d(TAG, "Setting user via task.");
new UpdateUserTask(app).execute();
}
}
}
}
@@ -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.
@@ -7,7 +7,7 @@ import com.maptology.android.app.R;
import android.content.Context;
import android.graphics.Color;
import android.support.design.widget.Snackbar;
import com.google.android.material.snackbar.Snackbar;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
@@ -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();
}
}
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM19,18H6c-2.21,0 -4,-1.79 -4,-4s1.79,-4 4,-4h0.71C7.37,7.69 9.48,6 12,6c3.04,0 5.5,2.46 5.5,5.5v0.5H19c1.66,0 3,1.34 3,3s-1.34,3 -3,3z"/>
</vector>
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M9.4,16.6L4.8,12l4.6,-4.6L8,6l-6,6 6,6 1.4,-1.4zM14.6,16.6l4.6,-4.6 -4.6,-4.6L16,6l6,6 -6,6 -1.4,-1.4z"/>
</vector>
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
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>
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M15,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM6,10L6,7L4,7v3L1,10v2h3v3h2v-3h3v-2L6,10zM15,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/>
</vector>
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z"/>
</vector>
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,7c2.76,0 5,2.24 5,5 0,0.65 -0.13,1.26 -0.36,1.83l2.92,2.92c1.51,-1.26 2.7,-2.89 3.43,-4.75 -1.73,-4.39 -6,-7.5 -11,-7.5 -1.4,0 -2.74,0.25 -3.98,0.7l2.16,2.16C10.74,7.13 11.35,7 12,7zM2,4.27l2.28,2.28 0.46,0.46C3.08,8.3 1.78,10.02 1,12c1.73,4.39 6,7.5 11,7.5 1.55,0 3.03,-0.3 4.38,-0.84l0.42,0.42L19.73,22 21,20.73 3.27,3 2,4.27zM7.53,9.8l1.55,1.55c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.66 1.34,3 3,3 0.22,0 0.44,-0.03 0.65,-0.08l1.55,1.55c-0.67,0.33 -1.41,0.53 -2.2,0.53 -2.76,0 -5,-2.24 -5,-5 0,-0.79 0.2,-1.53 0.53,-2.2zM11.84,9.02l3.15,3.15 0.02,-0.16c0,-1.66 -1.34,-3 -3,-3l-0.17,0.01z"/>
</vector>
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:id="@+id/coordinator">
</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/coordinator">
<android.support.v4.widget.DrawerLayout
<androidx.drawerlayout.widget.DrawerLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -20,7 +20,7 @@
android:orientation="vertical">
</FrameLayout>
<android.support.design.widget.NavigationView
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
@@ -30,5 +30,5 @@
</android.support.v4.widget.DrawerLayout>
</android.support.design.widget.CoordinatorLayout>
</androidx.drawerlayout.widget.DrawerLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
@@ -7,7 +7,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.NavigationView
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
@@ -17,7 +17,7 @@
<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
@@ -30,6 +30,6 @@
android:orientation="vertical">
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</LinearLayout>
@@ -9,7 +9,7 @@
android:layout_height="2dp"
android:background="@color/colorPrimary"/>
<android.support.v4.widget.NestedScrollView
<androidx.core.widget.NestedScrollView
android:orientation="vertical"
android:padding="@dimen/space_medium"
android:layout_width="match_parent"
@@ -20,5 +20,5 @@
android:layout_width="match_parent"
layout="@layout/view_detail_plain"/>
</android.support.v4.widget.NestedScrollView>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
@@ -7,11 +7,11 @@
<android.support.v4.view.ViewPager
<androidx.viewpager.widget.ViewPager
android:id="@+id/detail_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v4.view.ViewPager>
</androidx.viewpager.widget.ViewPager>
</LinearLayout>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_grant_swipe"
android:orientation="vertical"
@@ -7,15 +7,16 @@
android:layout_height="match_parent">
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/grant_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_margin="@dimen/margin_default"
android:id="@+id/fragment_list_grant_explain"
android:text="@string/grant_list_explain"
android:textAppearance="?android:attr/textAppearanceSmall"/>
</LinearLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- swipe refresh layout see https://developer.android.com/training/swipe/add-swipe-interface.html -->
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_notice_swipe"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/fragment_notice_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.SwipeRefreshLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
@@ -4,12 +4,13 @@
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/share_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_margin="@dimen/margin_default"
android:id="@+id/fragment_list_share_explain"
android:text="@string/share_list_explain"
@@ -1,33 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp">
<android.support.v7.widget.AppCompatTextView
android:text="@string/login_title"
android:layout_marginBottom="@dimen/space_medium"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ScrollView android:layout_width="match_parent" android:layout_height="wrap_content">
<ScrollView android:layout_width="@dimen/max_view_width"
android:fillViewport="true"
android:layout_centerHorizontal="true"
android:layout_height="wrap_content">
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_large"
android:orientation="vertical">
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/login_title"
tools:text="@string/login_title_create"
android:layout_marginBottom="@dimen/space_medium"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/login_explain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/space_medium"
android:text="@string/login_explain_account"
tools:text="@string/login_explain_create"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<android.support.v7.widget.AppCompatEditText
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/input_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -39,9 +43,15 @@
android:inputType="text"
style="@style/input"/>
<android.support.v7.widget.AppCompatEditText
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/space_large"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/input_password"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/space_medium"
android:drawableStart="@drawable/ic_lock_outline_black_24dp"
@@ -50,25 +60,37 @@
android:hint="@string/login_hint_password"
android:inputType="textPassword"
style="@style/input"/>
<ImageButton
android:id="@+id/button_password"
android:contentDescription="@string/login_password_show"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/space_medium"
android:background="@android:color/transparent"
android:src="@drawable/ic_visibility_black_24dp" />
</LinearLayout>
<android.support.v7.widget.AppCompatButton
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/button_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/space_medium"
android:layout_margin="@dimen/space_large"
android:theme="@style/button_highlighted"
android:text="@string/login_button_login"/>
tools:text="@string/login_button_create"/>
<android.support.v7.widget.AppCompatButton
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/button_no_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/space_medium"
android:layout_marginLeft="@dimen/space_large"
android:layout_marginRight="@dimen/space_large"
android:layout_marginBottom="@dimen/space_large"
android:theme="@style/button"
android:text="@string/login_button_continue"/>
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/text_register"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
@@ -81,7 +103,6 @@
</ScrollView>
</LinearLayout>
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
@@ -15,28 +15,31 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ImageView
android:id="@+id/icon_launch_person"
android:src="@drawable/icon_launch_person"
android:contentDescription="@null"
android:paddingBottom="60dp"
android:paddingRight="60dp"
android:paddingLeft="60dp"
android:adjustViewBounds="true"
android:layout_alignParentBottom="true"
android:scaleType="fitCenter"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="800dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:layout_height="wrap_content">
<ImageView
<ImageView
android:contentDescription="@null"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_marginTop="60dp"
android:src="@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"
android:contentDescription="@null"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:paddingBottom="40dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</RelativeLayout>
@@ -7,19 +7,19 @@
<android.support.v4.view.ViewPager
<androidx.viewpager.widget.ViewPager
android:id="@+id/manage_pager"
android:layout_weight="1.0"
android:layout_width="match_parent"
android:layout_height="0dp">
</android.support.v4.view.ViewPager>
</androidx.viewpager.widget.ViewPager>
<!-- funky: the tab layout draws the indicators at the bottom, but we
want them at the top. so we simply draw the view inverted (scaleY=-1)
and then we invert the tabs as well (see view_manage_tab
also funky: max width must be 0dp to ensure that the tabs will fill
the view on landscape -->
<android.support.design.widget.TabLayout
<com.google.android.material.tabs.TabLayout
android:id="@+id/manage_tab"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
@@ -38,14 +38,14 @@
android:focusable="true"
app:behavior_hideable="true"
app:behavior_peekHeight="72dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<TextView android:layout_width="match_parent" android:layout_height="match_parent"/>
</FrameLayout>
<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/buttonShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -59,7 +59,7 @@
style="@style/button_fab_highlighted"/>
<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/buttonMode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -73,4 +73,4 @@
style="@style/button_fab"/>
</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
@@ -7,28 +7,36 @@
<LinearLayout
android:id="@+id/share_editor"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_centerHorizontal="true"
android:layout_width="@dimen/max_view_width"
android:layout_height="match_parent">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/share_title"
android:text="@string/share_title_create"
android:layout_margin="@dimen/margin_default"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.v4.widget.NestedScrollView android:layout_width="match_parent"
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_gravity="center_horizontal"
android:fillViewport="true"
android:layout_height="0dp"
android:layout_weight="1.0">
<LinearLayout android:orientation="vertical"
android:layout_marginLeft="@dimen/margin_default"
android:layout_marginRight="@dimen/margin_default"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.AppCompatTextView
<TextView
android:id="@+id/share_title"
android:text="@string/share_title_create"
android:layout_marginTop="@dimen/margin_default"
android:layout_marginBottom="@dimen/margin_default"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/share_explain"
android:text="@string/share_explain_create"
android:layout_marginBottom="@dimen/space_medium"
@@ -36,7 +44,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatEditText
<androidx.appcompat.widget.AppCompatEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
@@ -50,7 +58,7 @@
android:drawableStart="@drawable/ic_message_black_24dp"
android:drawableLeft="@drawable/ic_message_black_24dp"/>
<android.support.v7.widget.AppCompatEditText
<androidx.appcompat.widget.AppCompatEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
@@ -71,12 +79,12 @@
android:layout_marginBottom="@dimen/space_medium"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:text="@string/share_creation_time"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/share_creation_date"
android:textAppearance="?android:attr/textAppearanceMedium"
android:gravity="end"
@@ -84,7 +92,7 @@
tools:text="1.1.2003"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/share_creation_time"
android:textAppearance="?android:attr/textAppearanceMedium"
android:gravity="end"
@@ -101,12 +109,12 @@
android:layout_marginBottom="@dimen/space_medium"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:text="@string/share_expiration_time"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/share_expiration_date"
android:textAppearance="@style/text_medium_hyperlink"
android:gravity="end"
@@ -114,7 +122,7 @@
tools:text="1.1.2003"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/share_expiration_time"
style="@style/text_medium_hyperlink"
android:gravity="end"
@@ -129,24 +137,22 @@
android:id="@+id/share_layout_link"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/space_large"
android:paddingRight="@dimen/space_large"
android:layout_marginBottom="@dimen/space_medium"
android:orientation="horizontal">
<View android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="0dp"/>
android:orientation="vertical">
<android.support.v7.widget.AppCompatButton
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/share_button_link"
android:text="@string/share_action_link"
android:drawableStart="@drawable/ic_link_black_24dp"
android:drawableLeft="@drawable/ic_link_black_24dp"
android:layout_weight="2"
android:paddingLeft="@dimen/space_large"
android:paddingRight="@dimen/space_large"
android:layout_gravity="center_horizontal"
android:theme="@style/button_highlighted"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<View android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="0dp"/>
</LinearLayout>
<LinearLayout
@@ -154,61 +160,68 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/space_medium"
android:orientation="horizontal">
android:orientation="vertical">
<android.support.v7.widget.AppCompatCheckBox
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/share_paused"
android:text="@string/share_paused"
android:textAppearance="@style/text_small_hyperlink"
android:textColor="@color/colorPrimary"
android:gravity="center"
android:layout_marginRight="@dimen/space_medium"
android:layout_marginLeft="@dimen/space_medium"
android:layout_width="match_parent"
android:layout_gravity="center_horizontal"
android:layout_marginRight="@dimen/space_large"
android:layout_marginLeft="@dimen/space_large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<View
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="0dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin_default"
android:layout_gravity="center_horizontal"
android:id="@+id/share_button_layout"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/share_button_delete"
android:text="@string/share_action_delete"
android:layout_weight="1"
android:drawableStart="@drawable/ic_delete_white_24dp"
android:drawableLeft="@drawable/ic_delete_white_24dp"
android:theme="@style/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/share_button_save"
android:text="@string/share_action_save"
android:layout_weight="1"
android:drawableStart="@drawable/ic_save_black_24dp"
android:drawableLeft="@drawable/ic_save_black_24dp"
android:theme="@style/button_highlighted"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/share_button_create"
android:text="@string/share_action_create"
android:layout_weight="1"
android:drawableStart="@drawable/ic_check_black_24dp"
android:drawableLeft="@drawable/ic_check_black_24dp"
android:theme="@style/button_highlighted"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</androidx.core.widget.NestedScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin_default"
android:id="@+id/share_button_layout"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatButton
android:id="@+id/share_button_delete"
android:text="@string/share_action_delete"
android:layout_weight="1"
android:drawableStart="@drawable/ic_delete_white_24dp"
android:drawableLeft="@drawable/ic_delete_white_24dp"
android:theme="@style/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatButton
android:id="@+id/share_button_save"
android:text="@string/share_action_save"
android:layout_weight="1"
android:drawableStart="@drawable/ic_save_black_24dp"
android:drawableLeft="@drawable/ic_save_black_24dp"
android:theme="@style/button_highlighted"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatButton
android:id="@+id/share_button_create"
android:text="@string/share_action_create"
android:layout_weight="1"
android:drawableStart="@drawable/ic_check_black_24dp"
android:drawableLeft="@drawable/ic_check_black_24dp"
android:theme="@style/button_highlighted"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<TextView
tools:text="The title is too long."
android:padding="@dimen/space_medium"
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:text="Pick an action"
@@ -4,9 +4,9 @@
xmlns:auto="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
<androidx.cardview.widget.CardView
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_gravity="top|center_horizontal"
auto:cardCornerRadius="@dimen/card_corner"
auto:cardElevation="@dimen/card_corner"
auto:cardUseCompatPadding="true"
@@ -22,5 +22,5 @@
android:layout_marginBottom="@dimen/card_margin"
android:layout_marginTop="@dimen/card_margin"
layout="@layout/view_detail_plain"/>
</android.support.v7.widget.CardView>
</androidx.cardview.widget.CardView>
</FrameLayout>
@@ -10,7 +10,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatImageView android:src="@drawable/ic_share_black_48dp"
<androidx.appcompat.widget.AppCompatImageView android:src="@drawable/ic_share_black_48dp"
android:id="@+id/view_detail_status"
android:paddingRight="4dp"
android:paddingEnd="4dp"
@@ -27,12 +27,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/share_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/view_detail_name"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Marcus Handte"
@@ -48,13 +48,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
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"/>
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/view_detail_creation_time"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="12/12/12 10:30"
@@ -70,12 +70,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/share_expiration_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/view_detail_expiration_time"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="12/12/12 10:30"
@@ -98,7 +98,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/view_detail_message_line">
<android.support.v7.widget.AppCompatImageView
<androidx.appcompat.widget.AppCompatImageView
android:src="@drawable/ic_message_black_24dp"
android:paddingLeft="14dp"
android:paddingRight="14dp"
@@ -106,7 +106,7 @@
android:contentDescription="@string/share_hint_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/view_detail_message"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Message"
@@ -121,7 +121,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/view_detail_destination_line">
<android.support.v7.widget.AppCompatImageView
<androidx.appcompat.widget.AppCompatImageView
android:contentDescription="@string/share_hint_message"
android:src="@drawable/ic_card_travel_black_24dp"
android:paddingLeft="14dp"
@@ -130,7 +130,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/view_detail_destination"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Destination"
@@ -145,7 +145,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/view_detail_position_line">
<android.support.v7.widget.AppCompatImageView
<androidx.appcompat.widget.AppCompatImageView
android:contentDescription="@string/share_hint_position"
android:src="@drawable/ic_gps_fixed_black_24dp"
android:paddingLeft="14dp"
@@ -154,7 +154,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/view_detail_position"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Available"
@@ -169,7 +169,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/view_detail_updated_line">
<android.support.v7.widget.AppCompatImageView
<androidx.appcompat.widget.AppCompatImageView
android:contentDescription="@string/share_hint_updated"
android:src="@drawable/ic_update_black_24dp"
android:paddingLeft="14dp"
@@ -178,7 +178,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/view_detail_updated"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Last update ..."
@@ -192,7 +192,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatImageView
<androidx.appcompat.widget.AppCompatImageView
android:contentDescription="@string/share_token"
android:src="@drawable/ic_vpn_key_black_24dp"
android:paddingLeft="14dp"
@@ -201,7 +201,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/view_detail_token"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="abcdefghijklmnopqrs"
@@ -20,7 +20,7 @@
android:layout_toStartOf="@android:id/text1"
tools:src="@drawable/ic_call_received_white_24dp"
android:id="@android:id/icon"/>
<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_centerInParent="true"
@@ -5,9 +5,9 @@
xmlns:auto="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
<androidx.cardview.widget.CardView
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_gravity="top|center_horizontal"
auto:cardCornerRadius="@dimen/card_corner"
auto:cardElevation="@dimen/card_corner"
auto:cardUseCompatPadding="true"
@@ -22,6 +22,7 @@
android:id="@+id/view_notice_title"
android:textAppearance="?android:attr/textAppearanceMedium"
android:gravity="start"
android:layout_marginBottom="@dimen/space_medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
@@ -75,5 +76,5 @@
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</androidx.cardview.widget.CardView>
</FrameLayout>
+34 -22
View File
@@ -3,26 +3,38 @@
xmlns:auto="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item android:title="@string/nav_notice"
android:id="@+id/menu_notice"
android:icon="@drawable/ic_message_black_24dp"
/>
<item android:title="@string/nav_map"
android:id="@+id/menu_map"
android:icon="@drawable/ic_map_black_24dp"
/>
<item android:title="@string/nav_share"
android:id="@+id/menu_share"
android:icon="@drawable/ic_share_black_24dp"
/>
<item android:title="@string/nav_manage"
android:id="@+id/menu_manage"
android:icon="@drawable/ic_import_export_black_24dp"
/>
<item android:title="@string/nav_settings"
android:id="@+id/menu_settings"
android:icon="@drawable/ic_settings_black_24dp"
/>
</group>
<group android:id="@+id/group_main" android:checkableBehavior="single" >
<item android:title="@string/nav_notice"
android:id="@+id/menu_notice"
android:icon="@drawable/ic_message_black_24dp"
/>
<item android:title="@string/nav_map"
android:id="@+id/menu_map"
android:icon="@drawable/ic_map_black_24dp"
/>
<item android:title="@string/nav_share"
android:id="@+id/menu_share"
android:icon="@drawable/ic_share_black_24dp"
/>
<item android:title="@string/nav_manage"
android:id="@+id/menu_manage"
android:icon="@drawable/ic_import_export_black_24dp"
/>
</group>
<group android:id="@+id/group_settings" android:checkableBehavior="single" >
<item android:title="@string/nav_settings"
android:id="@+id/menu_settings"
android:icon="@drawable/ic_settings_black_24dp"
/>
</group>
<group android:id="@+id/group_account" android:checkableBehavior="single" >
<item android:title="@string/nav_signin"
android:id="@+id/menu_connect"
android:icon="@drawable/ic_person_add_black_24dp" />
<item android:title="@string/nav_webapp"
android:id="@+id/menu_webapp"
android:icon="@drawable/ic_cloud_queue_black_24dp" />
</group>
</menu>
+2 -2
View File
@@ -6,11 +6,11 @@
<item android:title="@string/menu_grant_update_title"
android:id="@+id/menu_grant_update"
android:icon="@drawable/ic_update_white_24dp"
auto:showAsAction="ifRoom"
auto:showAsAction="ifRoom|withText"
/>
<item android:title="@string/menu_grant_delete_title"
android:id="@+id/menu_grant_delete"
android:icon="@drawable/ic_delete_sweep_white_24dp"
auto:showAsAction="ifRoom"
auto:showAsAction="ifRoom|withText"
/>
</menu>
+2 -2
View File
@@ -6,9 +6,9 @@
<item android:title="@string/menu_map_zoom_in_title"
android:id="@+id/menu_map_zoom_in"
android:icon="@drawable/ic_zoom_in_white_24dp"
auto:showAsAction="ifRoom"/>
auto:showAsAction="ifRoom|withText"/>
<item android:title="@string/menu_map_zoom_out_title"
android:id="@+id/menu_map_zoom_out"
android:icon="@drawable/ic_zoom_out_white_24dp"
auto:showAsAction="ifRoom"/>
auto:showAsAction="ifRoom|withText"/>
</menu>
@@ -6,6 +6,6 @@
<item android:title="@string/menu_notice_update_title"
android:id="@+id/menu_notice_update"
android:icon="@drawable/ic_update_white_24dp"
auto:showAsAction="ifRoom"
auto:showAsAction="ifRoom|withText"
/>
</menu>
+1 -1
View File
@@ -6,6 +6,6 @@
<item android:title="@string/menu_share_create_title"
android:id="@+id/menu_share_create"
android:icon="@drawable/ic_add_white_24dp"
auto:showAsAction="ifRoom"
auto:showAsAction="ifRoom|withText"
/>
</menu>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 14 KiB

+19 -7
View File
@@ -23,6 +23,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>
@@ -31,27 +32,34 @@
<string name="drawer_open">Navigationsmenü öffnen</string>
<string name="drawer_close">Navigationsmenü schließen</string>
<string name="drawer_title">Navigationsmenü</string>
<string name="nav_notice">Neues</string>
<string name="nav_map">Kartenansicht</string>
<string name="nav_notice">Neues erfahren</string>
<string name="nav_map">Karte anzeigen</string>
<string name="nav_share">Freigabe erstellen</string>
<string name="nav_manage">Freigaben verwalten</string>
<string name="nav_share_out">Erteilt</string>
<string name="nav_share_in">Erhalten</string>
<string name="nav_settings">Einstellungen</string>
<string name="nav_settings">Einstellungen ändern</string>
<string name="nav_signin">Konto verbinden</string>
<string name="nav_webapp">Orte anzeigen</string>
<string name="nav_user_none">Nutzung ohne Konto</string>
<string name="nav_user_error">Verbindungsfehler</string>
<!-- login and register -->
<string name="login_title">Geräteeinrichtung</string>
<string name="login_explain_account">Hallo! Damit wir Deinen Standort vor unbefugtem Zugriff schützen können, müssen wir Dein Gerät einrichten. Falls Du ein Konto hast, können wir das Gerät damit verbinden. Dadurch kannst Du über einen Webbrowser auf Deine Daten auch ohne App zugreifen.</string>
<string name="login_title_create">Geräteeinrichtung</string>
<string name="login_title_update">Kontoeinrichtung</string>
<string name="login_explain_create">Hallo! Damit wir Deinen Standort vor unbefugtem Zugriff schützen können, müssen wir Dein Gerät einrichten. Falls Du ein Konto hast, können wir das Gerät damit verbinden. Dadurch kannst Du über einen Webbrowser auf Deine Daten auch ohne App zugreifen.</string>
<string name="login_explain_update">Falls Du ein Konto hast, können wir Dein Gerät damit verbinden. Dadurch kannst Du über einen Webbrowser auf den Gerätestandort und den Standortverlauf jederzeit zugreifen.</string>
<string name="login_hint_user">Login</string>
<string name="login_hint_password">Passwort</string>
<string name="login_button_login">Anmelden und Gerät verbinden</string>
<string name="login_button_create">Anmelden und Gerät einrichten</string>
<string name="login_button_update">Anmelden und Gerät verbinden</string>
<string name="login_text_register">Falls Du noch keins hast, kannst Du Dir <b>hier</b> ein neues Konto anlegen.</string>
<string name="login_button_continue">Weiter ohne Anmeldung</string>
<string name="login_failed_msg">Deine Zugangsdaten stimmen vermutlich nicht. Schau sie Dir bitte nochmal an.</string>
<string name="login_button_retry">Nochmal</string>
<string name="login_device_failed">Einrichtung fehlgeschlagen. Hat Dein Gerät gerade kein Netz?</string>
<string name="login_conflict_msg">Dein Gerät ist bereits mit einem Konto verbunden.</string>
<string name="login_password_show">Passwort anzeigen oder verstecken</string>
<!-- shares and grants -->
<string name="share_title_create">Standortfreigabe erstellen</string>
@@ -113,6 +121,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>
@@ -124,10 +134,12 @@
<string name="setting_notification_app_title">Anwendung</string>
<string name="setting_notification_app_summary">Ermöglicht das Ein- und Ausblenden von Benachrichtigungen, die von der App erstellt werden.</string>
<string name="setting_notification_os_title">Android</string>
<string name="setting_notification_os_summary">Ermöglicht das Ein- und Ausblenden der Warnung des Betriebssystems über die Ausführung von Anwendungen im Hintegrund.</string>
<string name="setting_notification_os_summary">Ermöglicht das Ein- und Ausblenden der Warnung des Betriebssystems über die Ausführung von Anwendungen im Hintergrund.</string>
<string name="setting_category_about">Über</string>
<string name="setting_about_terms_title">Lizenz und Datenschutz</string>
<string name="setting_about_terms_summary">Zeigt die Lizenzbedinungen und die Datenschutzerklärung der App an.</string>
<string name="setting_about_licenses_title">Softwarebibliotheken</string>
<string name="setting_about_licenses_summary">Zeigt die Lizenzinformationen der Bibliotheken an, die zur Entwicklung der App genutzt wurden.</string>
<string name="setting_about_build_title">Version</string>
<string name="setting_about_build_summary">$code$ | $version$ @ $build$</string>
<string name="setting_category_development">Entwicklung</string>
@@ -5,6 +5,7 @@
<dimen name="space_large">16dp</dimen>
<dimen name="space_medium">8dp</dimen>
<dimen name="space_small">4dp</dimen>
<dimen name="max_view_width">600dp</dimen>
<dimen name="card_corner">4dp</dimen>
<dimen name="card_margin">8dp</dimen>
@@ -1,12 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
<string name="application_long" translatable="false">Maptology</string>
<string name="application_short" translatable="false">Maptology</string>
-->
<string name="maptology_url_default" translatable="false">https://www.maptology.com/api</string>
<string name="maptology_url_share" translatable="false">https://www.maptology.com/app/shares/</string>
<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>
+25 -12
View File
@@ -24,6 +24,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>
@@ -33,27 +34,35 @@
<string name="drawer_open">Open navigation</string>
<string name="drawer_close">Close navigation</string>
<string name="drawer_title">Navigation</string>
<string name="nav_notice">News</string>
<string name="nav_map">View Map</string>
<string name="nav_share">Create Share</string>
<string name="nav_manage">Manage Shares</string>
<string name="nav_notice">Read news</string>
<string name="nav_map">View map</string>
<string name="nav_share">Create share</string>
<string name="nav_manage">Manage shares</string>
<string name="nav_share_out">Created</string>
<string name="nav_share_in">Received</string>
<string name="nav_settings">Settings</string>
<string name="nav_user_none">Not signed in</string>
<string name="nav_user_error">Not connected</string>
<string name="nav_settings">Edit settings</string>
<string name="nav_signin">Link account</string>
<string name="nav_webapp">Show places</string>
<string name="nav_user_none">No account</string>
<string name="nav_user_error">No connection</string>
<!-- login and register -->
<string name="login_title">Device registration</string>
<string name="login_explain_account">Hi there! To protect your location, we must register your device. If you have an account, we can link your device to it, so you can access its location through a web browser.</string>
<string name="login_title_create">Device registration</string>
<string name="login_title_update">Account setup</string>
<string name="login_explain_create">Hi there! To protect your location, we must register your device. If you have an account, we can link your device to it, so you can access its location through a web browser.</string>
<string name="login_explain_update">If you have an account, we can link your device to it. This allows you to access the device location and its location history through a web browser at any time.</string>
<string name="login_hint_user">Username</string>
<string name="login_hint_password">Password</string>
<string name="login_button_login">Register with account</string>
<string name="login_button_create">Register with account</string>
<string name="login_button_update">Link with account</string>
<string name="login_text_register">You don\'t have an account yet? <b>Register here.</b></string>
<string name="login_button_continue">Continue without account</string>
<string name="login_failed_msg">Please check your username and password.</string>
<string name="login_button_retry">Retry</string>
<string name="login_device_failed">Please check your internet connection.</string>
<string name="login_conflict_msg">Your device is already connected with an account.</string>
<string name="login_password_show">Show or hide password</string>
<!-- shares and grants -->
<string name="share_title_create">New share</string>
@@ -61,10 +70,10 @@
<string name="share_hint_message">Message</string>
<string name="share_hint_destination">Destination</string>
<string name="share_added_time">Added on:</string>
<string name="share_creation_time">Create on</string>
<string name="share_creation_time">Created on</string>
<string name="share_expiration_time">Expires on</string>
<string name="share_name">Shared by</string>
<string name="share_name_none">an anonymous user</string>
<string name="share_name_none">anonymous user</string>
<string name="share_name_self">you</string>
<string name="share_token">Identifier:</string>
<string name="share_hint_position">Location status</string>
@@ -115,6 +124,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>
@@ -130,6 +141,8 @@
<string name="setting_category_about">About</string>
<string name="setting_about_terms_title">Terms</string>
<string name="setting_about_terms_summary">Shows the license terms and privacy policy of the app.</string>
<string name="setting_about_licenses_title">Libraries</string>
<string name="setting_about_licenses_summary">Shows licensing information about the libraries used by the app.</string>
<string name="setting_about_build_title">Version</string>
<string name="setting_about_build_summary">$code$ | $version$ @ $build$</string>
<string name="setting_category_development">Development</string>
@@ -1,11 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- text styles -->
<style name="text_large" parent="TextAppearance.AppCompat.Large">
<item name="android:textColor">@color/black</item>
<item name="android:textSize">24sp</item>
</style>
<style name="text_medium" parent="TextAppearance.AppCompat.Medium">
<item name="android:textColor">@color/black</item>
<item name="android:textSize">18sp</item>
@@ -13,18 +8,10 @@
<style name="text_small" parent="TextAppearance.AppCompat.Small">
<item name="android:textColor">@color/black</item>
</style>
<style name="text_large_inverse" parent="TextAppearance.AppCompat.Large.Inverse">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">24sp</item>
</style>
<style name="text_medium_inverse" parent="TextAppearance.AppCompat.Medium.Inverse">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">18sp</item>
</style>
<style name="text_small_inverse" parent="TextAppearance.AppCompat.Small.Inverse">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">14sp</item>
</style>
<style name="text_medium_hyperlink" parent="text_medium">
<item name="android:textColor">@color/colorPrimary</item>
<item name="android:textStyle">bold</item>
+11
View File
@@ -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"
@@ -46,6 +52,11 @@
android:key="about_terms"
android:summary="@string/setting_about_terms_summary"
android:title="@string/setting_about_terms_title" />
<Preference
android:icon="@drawable/ic_code_black_24dp"
android:key="about_licenses"
android:summary="@string/setting_about_licenses_summary"
android:title="@string/setting_about_licenses_title" />
<Preference
android:icon="@drawable/ic_perm_device_information_black_24dp"
android:key="about_build"
@@ -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);
@@ -1,6 +1,6 @@
package com.maptology.android.app.test.notice;
import android.support.v4.widget.SwipeRefreshLayout;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.maptology.android.app.R;
import com.maptology.android.app.fragment.NoticeListFragment;
import com.maptology.android.app.test.util.FragmentActivity;
@@ -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());
@@ -1,8 +1,8 @@
package com.maptology.android.app.test.util;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.appcompat.app.AppCompatActivity;
import android.widget.FrameLayout;
/**
+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"
}
+44 -49
View File
@@ -1,31 +1,39 @@
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.8.1'
classpath files('gradle/gradle-android-eclipse-1.1.jar')
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.10.0'
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.2'
classpath 'org.handte.gradle:gradle-android-eclipse:1.0.0'
}
repositories {
maven {
url "http://repository.jboss.org/nexus/content/groups/public/"
url = 'https://project.nes.uni-due.de/artifactory/releases';
credentials { username = 'public'; password = 'public' }
authentication { basic(BasicAuthentication) }
}
maven { url = 'https://project.nes.uni-due.de/artifactory/releases'; credentials { username = 'public'; password = 'public' } }
maven { url = 'https://project.nes.uni-due.de/artifactory/snaphsots'; credentials { username = 'public'; password = 'public'} }
mavenCentral()
jcenter()
google()
}
maven {
url = 'https://project.nes.uni-due.de/artifactory/snapshots';
credentials { username = 'public'; password = 'public' }
authentication { basic(BasicAuthentication) }
}
}
}
allprojects {
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
// set version for our project
group = 'com.maptology'
version = '1.0.0'
version = '1.0.6'
// 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'
@@ -37,26 +45,31 @@ allprojects {
// testing dependencies
versionJunit = '4.12'
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.2.0'
versionRobolectric = '4.3'
versionSupport = "28.0.0"
versionAndroidxCompat = '1.2.0'
versionAndroidxLegacy = '1.0.0'
versionAndroidxPreference = '1.1.1'
versionAndroidxCard = '1.0.0'
versionAndroidxRecycler = '1.1.0'
versionAndroidxMaterial = '1.2.0'
versionRobolectric = '4.3.1'
versionPlay = '17.0.0'
versionAndroidxTest = '1.2.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'
publishing {
publications {
@@ -78,17 +91,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'))
}
}
}
}
}
@@ -119,25 +121,16 @@ subprojects {
repositories {
maven {
url "http://repository.jboss.org/nexus/content/groups/public/"
url = 'https://project.nes.uni-due.de/artifactory/releases';
credentials { username = 'public'; password = 'public' }
authentication { basic(BasicAuthentication) }
}
maven { url = 'https://project.nes.uni-due.de/artifactory/releases'; credentials { username = 'public'; password = 'public' } }
maven { url = 'https://project.nes.uni-due.de/artifactory/snaphsots'; credentials { username = 'public'; password = 'public'} }
mavenCentral()
jcenter()
google()
maven {
url 'https://maven.repository.redhat.com/nexus/content/repositories/thirdparty-releases/'
}
maven {
name 'Gradle Tooling'
url 'https://repo.gradle.org/gradle/libs-releases/'
}
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
url = 'https://project.nes.uni-due.de/artifactory/snapshots';
credentials { username = 'public'; password = 'public' }
authentication { basic(BasicAuthentication) }
}
}
artifactoryPublish.dependsOn('build')
@@ -145,6 +138,8 @@ subprojects {
artifactoryPublish {
publications(publishing.publications.maven);
}
}
tasks.register("generatePomFileForMavenPublication") { }
tasks.register("build") { }
+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'
}
}
}

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