Compare commits
97 Commits
v0.3.1
..
2ff66d46db
| Author | SHA1 | Date | |
|---|---|---|---|
|
2ff66d46db
|
|||
|
6cce1c6e25
|
|||
| d929397492 | |||
| 2217f80f72 | |||
| d062158c7c | |||
| 26dcfb8f34 | |||
| a0978d8a54 | |||
| fac521e0e3 | |||
| 5cf1f72d9c | |||
| ce1b921447 | |||
| 0de02c6d44 | |||
| 1bbf8d0c5c | |||
| 8b470c1927 | |||
| 904cafcf48 | |||
| 3361ec8965 | |||
| c5e05e4b8a | |||
| 25f7b05fd0 | |||
| 443e954c66 | |||
| 28258d8c15 | |||
| d74462a66c | |||
| 572095a7c3 | |||
| 32b005599a | |||
| 49e291881a | |||
| 5949099d91 | |||
| 13287f5b05 | |||
| acf5090489 | |||
| 7b26938efb | |||
| 0e8f9e2dfa | |||
| 513bc368b2 | |||
| a752a85a3f | |||
| 053f7401b8 | |||
| b6ce246a74 | |||
| ae9274d646 | |||
| 739399f54b | |||
| fd4a9c1f5d | |||
| d762ffe40a | |||
| ebbd4c823b | |||
| e1747b73f3 | |||
| e1b1adf9ad | |||
| a396406877 | |||
| ca2b7a7064 | |||
| fa65c33ec6 | |||
| a1d6f1dabe | |||
| 367d6d0a74 | |||
| b15236580b | |||
| 334b540721 | |||
| cd576ada12 | |||
| cf7d38d872 | |||
| a13e601eea | |||
| 7efd2a2f8b | |||
| 4f64ef00b9 | |||
| e595b12705 | |||
| 73f597fb54 | |||
| 3ac332535d | |||
| 4f59359f5e | |||
| 713e47b20a | |||
| 9dfcfa064a | |||
| 61263c191e | |||
| b7f61846e3 | |||
| 4aae6e90be | |||
| d5b6158364 | |||
| b9980206f5 | |||
| 6336c4d61b | |||
| 864802cdae | |||
| 907fcb4cb1 | |||
| d3a21c93c1 | |||
| f57abf150a | |||
| a40b64baca | |||
| 15c11a33ee | |||
| d888485fc2 | |||
| d009237679 | |||
| c3e2496596 | |||
| 607bbd0c2b | |||
| 90c4b998e7 | |||
| 8f054dd324 | |||
| 83b3b8a48d | |||
| e64b89bce6 | |||
| fd14eea4b9 | |||
| 065ef2bea6 | |||
| 308474246b | |||
| 96b88a398c | |||
| 15cea67818 | |||
| 9e89879d5c | |||
| a0c397b194 | |||
| cdb146bffb | |||
| 7ac35f21cf | |||
| 760f7f572a | |||
| 9aa2652059 | |||
| 718c654056 | |||
| 63b60a46ae | |||
| a694246a56 | |||
| 8b7e89f43b | |||
| cf7f96efad | |||
| b9dbde7f7c | |||
| 4592bb3382 | |||
| 88cf7711b0 | |||
| 82a5eb343b |
@@ -96,3 +96,10 @@ lint/generated/
|
|||||||
lint/outputs/
|
lint/outputs/
|
||||||
lint/tmp/
|
lint/tmp/
|
||||||
# lint/reports/
|
# lint/reports/
|
||||||
|
|
||||||
|
app/release/output-metadata.json
|
||||||
|
|
||||||
|
.idea/deploymentTargetDropDown.xml
|
||||||
|
.idea/misc.xml
|
||||||
|
.idea/deploymentTargetSelector.xml
|
||||||
|
.idea/other.xml
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<bytecodeTargetLevel target="11" />
|
<bytecodeTargetLevel target="21" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectMigrations">
|
||||||
|
<option name="MigrateToGradleLocalJavaHome">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="DesignSurface">
|
|
||||||
<option name="filePathToZoomLevelMap">
|
|
||||||
<map>
|
|
||||||
<entry key="../../../../layout/custom_preview.xml" value="0.5661458333333333" />
|
|
||||||
<entry key="app/src/main/res/drawable/floating_semitransparent_button_background.xml" value="0.512962962962963" />
|
|
||||||
<entry key="app/src/main/res/drawable/ic_map_pin.xml" value="0.6425925925925926" />
|
|
||||||
<entry key="app/src/main/res/drawable/ic_more.xml" value="0.6166666666666667" />
|
|
||||||
<entry key="app/src/main/res/drawable/ic_nav.xml" value="0.6083333333333333" />
|
|
||||||
<entry key="app/src/main/res/drawable/ic_share.xml" value="0.8828125" />
|
|
||||||
<entry key="app/src/main/res/layout/activity_geofavorite_detail.xml" value="0.4" />
|
|
||||||
<entry key="app/src/main/res/layout/activity_list_view.xml" value="0.5307291666666667" />
|
|
||||||
<entry key="app/src/main/res/layout/activity_main.xml" value="0.5307291666666667" />
|
|
||||||
<entry key="app/src/main/res/layout/item_geofav.xml" value="0.5307291666666667" />
|
|
||||||
<entry key="app/src/main/res/menu/list_context_menu.xml" value="0.41944444444444445" />
|
|
||||||
</map>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK" />
|
|
||||||
</project>
|
|
||||||
@@ -1,15 +1,36 @@
|
|||||||

|

|
||||||
|
|
||||||
# Nextcloud Maps Geobookmarks Android app
|
# Nextcloud Maps Geofavorites Android app
|
||||||
|
|
||||||
Android app to show your Nextcloud Maps geobookmarks list. Geobookmarks can be opened in all apps supporting geo links (i.e. Google Maps, Organic Maps etc...).
|
[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" alt="Get it on F-Droid" height="80">](https://f-droid.org/it/packages/it.danieleverducci.nextcloudmaps)
|
||||||
A new geobookmark can be created on current location.
|
[<img src="https://cdn.rawgit.com/steverichey/google-play-badge-svg/master/img/en_get.svg" height="80">](https://play.google.com/store/apps/details?id=it.danieleverducci.nextcloudmaps)
|
||||||
|
[<img src="https://raw.githubusercontent.com/andOTP/andOTP/master/assets/badges/get-it-on-github.png" height="80">](https://github.com/penguin86/nextcloud-maps-client/releases/latest)
|
||||||
|
|
||||||
|
(Always prefer [F-Droid](https://f-droid.org) build, when possible).
|
||||||
|
|
||||||
|
UNOFFICIAL and FOSS Nextcloud Maps client at its earliest stages of developement. Shows your Nextcloud Maps geofavorites in a list and a map.
|
||||||
|
Geofavorites can be opened in all apps supporting geo links (i.e. Google Maps, Organic Maps etc...).
|
||||||
|
A new geofavorite can be created on current location, by sharing a "geo:" uri from another app or manually picking from the map.
|
||||||
|
|
||||||
**Requires Maps app to be installed on the Nextcloud instance.**
|
**Requires Maps app to be installed on the Nextcloud instance.**
|
||||||
|
|
||||||
This work is heavily based on [matiasdelellis's Nextcloud SSO example](https://github.com/matiasdelellis/app-tutorial-android) to implement [Nextcloud single sign on](https://github.com/nextcloud/Android-SingleSignOn).
|
This work is heavily based on [matiasdelellis's Nextcloud SSO example](https://github.com/matiasdelellis/app-tutorial-android) to implement [Nextcloud single sign on](https://github.com/nextcloud/Android-SingleSignOn).
|
||||||
|
|
||||||
 
|
  
|
||||||
|
|
||||||
Download it from [the releases page](https://github.com/penguin86/nextcloud-maps-client/releases)
|
## Contributions
|
||||||
|
|
||||||
|
### Why isn't this hosted on GitHub?
|
||||||
|
|
||||||
|
I'm using a private git server just because I'm worried for the vast majority of open source code being hosted in a server property of Microsoft and being used to train theirs AI.
|
||||||
|
I didn't find a better option, BTW the Gitea project is working on implementing federation, so soon it will be possible to contribute using any other gitea server, selfhosted or not.
|
||||||
|
|
||||||
|
### How to contribute
|
||||||
|
|
||||||
|
The project is open to contribution, but with some limits:
|
||||||
|
|
||||||
|
- I'm sorry I can't accept AI-generated contributions. Reviewing a contribution requires time and effort from my side, while generating code with AI requires very little time and produces non reliable code that must be reviewed in detail. This is effectively shifting the work on my side, and in a forced way. If you feel you need a feature but you're not able to implement it by yourself, I prefer you to create an issue in the repository so I can implement it when I can, in a more mantainable way.
|
||||||
|
- I prefer to make project-wide changes (i.e. updating Android target, app name and icon, release number...) by myself.
|
||||||
|
|
||||||
|
To contribute, you'll have to create an account on this git instance. Unfortunately, I had to disable registration to avoid huge waves of fake accounts created by bots.
|
||||||
|
You can request an account writing to daniele.verducci@ichibi.eu
|
||||||
|
|||||||
@@ -18,14 +18,13 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 30
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "it.danieleverducci.nextcloudmaps"
|
applicationId "it.danieleverducci.nextcloudmaps"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 30
|
targetSdkVersion 34
|
||||||
versionCode 3
|
compileSdkVersion 34
|
||||||
versionName "0.3.1"
|
versionCode 9
|
||||||
|
versionName "0.4.0"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
@@ -37,13 +36,18 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
|
// Flag to enable support for the new language APIs
|
||||||
|
coreLibraryDesugaringEnabled true
|
||||||
|
// Sets Java compatibility to Java 8
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
dataBinding true
|
dataBinding true
|
||||||
|
buildConfig true
|
||||||
}
|
}
|
||||||
|
namespace 'it.danieleverducci.nextcloudmaps'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -54,28 +58,40 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||||
|
|
||||||
implementation 'com.android.support:design:30.0.1'
|
// Desugaring lib: see https://developer.android.com/studio/write/java8-support
|
||||||
implementation 'androidx.appcompat:appcompat:1.3.1'
|
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.2")
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
|
||||||
implementation "androidx.cardview:cardview:1.0.0"
|
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
|
|
||||||
implementation "androidx.preference:preference:1.1.1"
|
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.13.2'
|
implementation 'com.android.support:design:34.0.0'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
implementation 'androidx.appcompat:appcompat:1.7.0'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
implementation 'androidx.recyclerview:recyclerview:1.3.2'
|
||||||
|
implementation "androidx.cardview:cardview:1.0.0"
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
|
implementation "androidx.preference:preference:1.2.1"
|
||||||
|
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||||
|
|
||||||
// Retrofif2
|
// Retrofif2
|
||||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
implementation 'com.squareup.retrofit2:retrofit:2.11.0'
|
||||||
implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
|
implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
|
||||||
|
|
||||||
// Nextcloud SSO
|
// Nextcloud SSO
|
||||||
implementation "com.github.nextcloud:Android-SingleSignOn:0.5.6"
|
implementation "com.github.nextcloud:Android-SingleSignOn:1.3.2"
|
||||||
|
|
||||||
// OSMDroid
|
// OSMDroid
|
||||||
implementation 'org.osmdroid:osmdroid-android:6.1.10'
|
implementation 'org.osmdroid:osmdroid-android:6.1.18'
|
||||||
|
|
||||||
//Threeten-Backport (ports Java 8 Date API on Java 6+)
|
//Threeten-Backport (ports Java 8 Date API on Java 6+)
|
||||||
implementation 'org.threeten:threetenbp:1.5.1'
|
implementation 'org.threeten:threetenbp:1.5.1'
|
||||||
|
|
||||||
|
// https://mvnrepository.com/artifact/commons-io/commons-io
|
||||||
|
implementation 'commons-io:commons-io:2.13.0'
|
||||||
|
|
||||||
|
// Picasso (image loader)
|
||||||
|
implementation 'com.squareup.picasso:picasso:2.8'
|
||||||
|
|
||||||
|
configurations.all {
|
||||||
|
resolutionStrategy {
|
||||||
|
force 'commons-io:commons-io:2.11.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 2,
|
|
||||||
"artifactType": {
|
|
||||||
"type": "APK",
|
|
||||||
"kind": "Directory"
|
|
||||||
},
|
|
||||||
"applicationId": "it.danieleverducci.nextcloudmaps",
|
|
||||||
"variantName": "release",
|
|
||||||
"elements": [
|
|
||||||
{
|
|
||||||
"type": "SINGLE",
|
|
||||||
"filters": [],
|
|
||||||
"versionCode": 2,
|
|
||||||
"versionName": "0.2",
|
|
||||||
"outputFile": "app-release.apk"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<manifest
|
<manifest
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
package="it.danieleverducci.nextcloudmaps">
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
|
|
||||||
<queries>
|
<queries>
|
||||||
@@ -35,14 +35,16 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
|
|
||||||
<activity android:name=".activity.login.LoginActivity">
|
<activity android:name=".activity.login.LoginActivity"
|
||||||
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".activity.main.MainActivity">
|
<activity android:name=".activity.main.MainActivity"
|
||||||
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
@@ -50,6 +52,66 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.detail.GeofavoriteDetailActivity"
|
android:name=".activity.detail.GeofavoriteDetailActivity"
|
||||||
|
android:exported="true">
|
||||||
|
<!-- standard "geo" scheme -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
|
|
||||||
|
<data android:scheme="geo"/>
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<!-- Google Maps -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
|
<data android:scheme="google.navigation"/>
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
|
<data
|
||||||
|
android:host="maps.google.com"
|
||||||
|
android:scheme="https"/>
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
|
<data
|
||||||
|
android:host="www.google.com"
|
||||||
|
android:pathPrefix="/maps"
|
||||||
|
android:scheme="https"/>
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
|
<data
|
||||||
|
android:host="www.openstreetmap.org"
|
||||||
|
android:scheme="https"/>
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".activity.mappicker.MapPickerActivity"
|
||||||
|
android:exported="true"
|
||||||
|
android:theme="@style/AppTheme">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".activity.settings.SettingsActivity"
|
||||||
|
android:launchMode="singleTask"
|
||||||
android:theme="@style/AppTheme"/>
|
android:theme="@style/AppTheme"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package it.danieleverducci.nextcloudmaps.activity;
|
||||||
|
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import org.osmdroid.views.overlay.TilesOverlay;
|
||||||
|
|
||||||
|
public class NextcloudMapsStyledActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
// For whatever reason, android:windowLightStatusBar is ignored in styles.xml
|
||||||
|
int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||||
|
if (currentNightMode == Configuration.UI_MODE_NIGHT_YES)
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -30,8 +30,9 @@ import androidx.appcompat.widget.Toolbar;
|
|||||||
|
|
||||||
import it.danieleverducci.nextcloudmaps.BuildConfig;
|
import it.danieleverducci.nextcloudmaps.BuildConfig;
|
||||||
import it.danieleverducci.nextcloudmaps.R;
|
import it.danieleverducci.nextcloudmaps.R;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.NextcloudMapsStyledActivity;
|
||||||
|
|
||||||
public class AboutActivity extends AppCompatActivity {
|
public class AboutActivity extends NextcloudMapsStyledActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -62,6 +63,10 @@ public class AboutActivity extends AppCompatActivity {
|
|||||||
TextView tvIssues = findViewById(R.id.about_issues);
|
TextView tvIssues = findViewById(R.id.about_issues);
|
||||||
tvIssues.setText(Html.fromHtml(getString(R.string.about_issues, getString(R.string.url_issues))));
|
tvIssues.setText(Html.fromHtml(getString(R.string.about_issues, getString(R.string.url_issues))));
|
||||||
tvIssues.setOnClickListener(view -> openUtl(getString(R.string.url_issues)));
|
tvIssues.setOnClickListener(view -> openUtl(getString(R.string.url_issues)));
|
||||||
|
|
||||||
|
TextView tvMaps = findViewById(R.id.about_maps);
|
||||||
|
tvMaps.setText(Html.fromHtml(getString(R.string.about_maps)));
|
||||||
|
tvMaps.setOnClickListener(view -> openUtl(getString(R.string.url_maps)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package it.danieleverducci.nextcloudmaps.activity.detail;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.core.graphics.drawable.DrawableCompat;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import it.danieleverducci.nextcloudmaps.R;
|
||||||
|
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||||
|
|
||||||
|
public class CategoriesAdapter extends ArrayAdapter<String> {
|
||||||
|
|
||||||
|
public CategoriesAdapter(@NonNull Context context) {
|
||||||
|
super(context, R.layout.category_listitem, R.id.category_name, new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||||
|
View v = super.getView(position, convertView, parent);
|
||||||
|
TextView categoryName = v.findViewById(R.id.category_name);
|
||||||
|
Drawable backgroundDrawable = categoryName.getBackground();
|
||||||
|
DrawableCompat.setTint(
|
||||||
|
backgroundDrawable,
|
||||||
|
Geofavorite.categoryColorFromName(categoryName.getText().toString()) == 0
|
||||||
|
? v.getContext().getColor(R.color.defaultBrand)
|
||||||
|
: Geofavorite.categoryColorFromName(categoryName.getText().toString())
|
||||||
|
);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategoriesList(HashSet<String> categories) {
|
||||||
|
clear();
|
||||||
|
addAll(categories);
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -18,14 +18,14 @@
|
|||||||
package it.danieleverducci.nextcloudmaps.activity.detail;
|
package it.danieleverducci.nextcloudmaps.activity.detail;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.location.LocationListener;
|
import android.location.LocationListener;
|
||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -34,9 +34,10 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.appcompat.content.res.AppCompatResources;
|
import androidx.appcompat.content.res.AppCompatResources;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
|
import androidx.lifecycle.Observer;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import org.osmdroid.api.IMapController;
|
import org.osmdroid.api.IMapController;
|
||||||
@@ -47,36 +48,31 @@ import org.osmdroid.views.overlay.Marker;
|
|||||||
import org.threeten.bp.format.DateTimeFormatter;
|
import org.threeten.bp.format.DateTimeFormatter;
|
||||||
import org.threeten.bp.format.FormatStyle;
|
import org.threeten.bp.format.FormatStyle;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import it.danieleverducci.nextcloudmaps.R;
|
import it.danieleverducci.nextcloudmaps.R;
|
||||||
import it.danieleverducci.nextcloudmaps.activity.main.MainActivity;
|
import it.danieleverducci.nextcloudmaps.activity.NextcloudMapsStyledActivity;
|
||||||
import it.danieleverducci.nextcloudmaps.api.ApiProvider;
|
|
||||||
import it.danieleverducci.nextcloudmaps.databinding.ActivityGeofavoriteDetailBinding;
|
import it.danieleverducci.nextcloudmaps.databinding.ActivityGeofavoriteDetailBinding;
|
||||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||||
|
import it.danieleverducci.nextcloudmaps.utils.GeoUriParser;
|
||||||
import it.danieleverducci.nextcloudmaps.utils.IntentGenerator;
|
import it.danieleverducci.nextcloudmaps.utils.IntentGenerator;
|
||||||
import retrofit2.Call;
|
import it.danieleverducci.nextcloudmaps.utils.MapUtils;
|
||||||
import retrofit2.Callback;
|
|
||||||
import retrofit2.Response;
|
|
||||||
|
|
||||||
public class GeofavoriteDetailActivity extends AppCompatActivity implements LocationListener, ActivityCompat.OnRequestPermissionsResultCallback {
|
public class GeofavoriteDetailActivity extends NextcloudMapsStyledActivity implements LocationListener, ActivityCompat.OnRequestPermissionsResultCallback {
|
||||||
|
|
||||||
public static final String TAG = "GeofavDetail";
|
public static final String TAG = "GeofavDetail";
|
||||||
public static final String DEFAULT_CATEGORY = "Personal";
|
|
||||||
public static final int MINIMUM_ACCEPTABLE_ACCURACY = 50; // In meters
|
|
||||||
public static final String ARG_GEOFAVORITE = "geofav";
|
public static final String ARG_GEOFAVORITE = "geofav";
|
||||||
private static final int PERMISSION_REQUEST_CODE = 9999;
|
private static final int PERMISSION_REQUEST_CODE = 9999;
|
||||||
|
|
||||||
private ViewHolder mViewHolder;
|
private ViewHolder mViewHolder;
|
||||||
private Geofavorite mGeofavorite;
|
private Geofavorite mGeofavorite;
|
||||||
|
private GeofavoriteDetailActivityViewModel mViewModel;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// OSMDroid config
|
MapUtils.configOsmdroid(this);
|
||||||
Configuration.getInstance().load(getApplicationContext(),
|
|
||||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()));
|
|
||||||
|
|
||||||
mViewHolder = new ViewHolder(getLayoutInflater());
|
mViewHolder = new ViewHolder(getLayoutInflater());
|
||||||
setContentView(mViewHolder.getRootView());
|
setContentView(mViewHolder.getRootView());
|
||||||
@@ -108,24 +104,67 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMapClicked() {
|
public void onMapClicked() {
|
||||||
Toast.makeText(GeofavoriteDetailActivity.this, "TODO: Open map activity with pin", Toast.LENGTH_SHORT).show();
|
// TODO: Open map activity with pin
|
||||||
|
startActivity(IntentGenerator.newGeoUriIntent(GeofavoriteDetailActivity.this, mGeofavorite));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (getIntent().hasExtra(ARG_GEOFAVORITE)) {
|
mViewModel = new ViewModelProvider(this).get(GeofavoriteDetailActivityViewModel.class);
|
||||||
|
mViewModel.init(getApplicationContext());
|
||||||
|
mViewModel.getCategories().observe(this, new Observer<HashSet<String>>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(HashSet<String> categories) {
|
||||||
|
mViewHolder.setCategories(categories);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mViewModel.getIsUpdating().observe(this, new Observer<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(@Nullable Boolean updating) {
|
||||||
|
mViewHolder.setUpdating(updating);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mViewModel.getOnFinished().observe(this, new Observer<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(@Nullable Boolean success) {
|
||||||
|
if(success){
|
||||||
|
Toast.makeText(GeofavoriteDetailActivity.this, R.string.geofavorite_saved, Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(GeofavoriteDetailActivity.this, R.string.error_saving_geofavorite, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (getIntent().hasExtra(ARG_GEOFAVORITE) && getIntent().getIntExtra(ARG_GEOFAVORITE, 0) != 0) {
|
||||||
// Opening geofavorite from list
|
// Opening geofavorite from list
|
||||||
mGeofavorite = (Geofavorite) getIntent().getSerializableExtra(ARG_GEOFAVORITE);
|
mGeofavorite = mViewModel.getGeofavorite(
|
||||||
|
getIntent().getIntExtra(ARG_GEOFAVORITE, 0)
|
||||||
|
);
|
||||||
mViewHolder.hideAccuracy();
|
mViewHolder.hideAccuracy();
|
||||||
} else {
|
} else {
|
||||||
// New geofavorite
|
// New geofavorite
|
||||||
mGeofavorite = new Geofavorite();
|
mGeofavorite = new Geofavorite();
|
||||||
mGeofavorite.setCategory(DEFAULT_CATEGORY);
|
mGeofavorite.setCategory(Geofavorite.DEFAULT_CATEGORY);
|
||||||
mGeofavorite.setDateCreated(System.currentTimeMillis());
|
mGeofavorite.setDateCreated(System.currentTimeMillis() / 1000);
|
||||||
mGeofavorite.setDateModified(System.currentTimeMillis());
|
mGeofavorite.setDateModified(System.currentTimeMillis() / 1000);
|
||||||
mViewHolder.hideActions();
|
mViewHolder.hideActions();
|
||||||
|
|
||||||
// Precompile location
|
if (getIntent().getData() != null) {
|
||||||
getLocation();
|
// Opened by external generic intent: parse URI
|
||||||
|
try {
|
||||||
|
double[] coords = GeoUriParser.parseUri(getIntent().getData(), false);
|
||||||
|
mGeofavorite.setLat(coords[0]);
|
||||||
|
mGeofavorite.setLng(coords[1]);
|
||||||
|
mViewHolder.hideAccuracy();
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Log.e(TAG, e.getMessage());
|
||||||
|
Toast.makeText(this, R.string.error_unsupported_uri, Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Precompile location with current one
|
||||||
|
getLocation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mViewHolder.updateView(mGeofavorite);
|
mViewHolder.updateView(mGeofavorite);
|
||||||
@@ -169,35 +208,7 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Call<Geofavorite> call;
|
mViewModel.saveGeofavorite(mGeofavorite);
|
||||||
if (mGeofavorite.getId() == 0) {
|
|
||||||
// New geofavorite
|
|
||||||
call = ApiProvider.getAPI().createGeofavorite(mGeofavorite);
|
|
||||||
} else {
|
|
||||||
// Update existing geofavorite
|
|
||||||
call = ApiProvider.getAPI().updateGeofavorite(mGeofavorite.getId(), mGeofavorite);
|
|
||||||
}
|
|
||||||
call.enqueue(new Callback<Geofavorite>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(Call<Geofavorite> call, Response<Geofavorite> response) {
|
|
||||||
if (response.isSuccessful())
|
|
||||||
finish();
|
|
||||||
else
|
|
||||||
onGeofavoriteSaveFailed();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call<Geofavorite> call, Throwable t) {
|
|
||||||
onGeofavoriteSaveFailed();
|
|
||||||
Log.e(TAG, "Unable to update geofavorite: " + t.getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onGeofavoriteSaveFailed() {
|
|
||||||
runOnUiThread(() ->
|
|
||||||
Toast.makeText(GeofavoriteDetailActivity.this, R.string.error_saving_geofavorite, Toast.LENGTH_SHORT).show()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -281,7 +292,9 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
|||||||
private OnSubmitListener listener;
|
private OnSubmitListener listener;
|
||||||
private Marker mapMarker;
|
private Marker mapMarker;
|
||||||
|
|
||||||
|
|
||||||
public ViewHolder(LayoutInflater inflater) {
|
public ViewHolder(LayoutInflater inflater) {
|
||||||
|
|
||||||
this.binding = ActivityGeofavoriteDetailBinding.inflate(inflater);
|
this.binding = ActivityGeofavoriteDetailBinding.inflate(inflater);
|
||||||
this.binding.submitBt.setOnClickListener(this);
|
this.binding.submitBt.setOnClickListener(this);
|
||||||
this.binding.mapBt.setOnClickListener(this);
|
this.binding.mapBt.setOnClickListener(this);
|
||||||
@@ -290,9 +303,22 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
|||||||
this.binding.actionIconDelete.setOnClickListener(this);
|
this.binding.actionIconDelete.setOnClickListener(this);
|
||||||
this.binding.actionIconNav.setOnClickListener(this);
|
this.binding.actionIconNav.setOnClickListener(this);
|
||||||
|
|
||||||
|
// Set categories adapter
|
||||||
|
CategoriesAdapter categoriesAdapter = new CategoriesAdapter(binding.root.getContext());
|
||||||
|
this.binding.categoryAt.setAdapter(categoriesAdapter);
|
||||||
|
this.binding.categoryAt.setText(Geofavorite.DEFAULT_CATEGORY);
|
||||||
|
this.binding.categoryAtClear.setOnClickListener((v) -> {
|
||||||
|
if (this.binding.categoryAt.getText().toString().isEmpty())
|
||||||
|
this.binding.categoryAt.setText(Geofavorite.DEFAULT_CATEGORY);
|
||||||
|
else
|
||||||
|
this.binding.categoryAt.setText("");
|
||||||
|
});
|
||||||
|
|
||||||
// Set map properties
|
// Set map properties
|
||||||
this.binding.map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER);
|
this.binding.map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER);
|
||||||
this.binding.map.setMultiTouchControls(true);
|
this.binding.map.setMultiTouchControls(true);
|
||||||
|
MapUtils.setTheme(this.binding.map);
|
||||||
|
// this.binding.map.setTilesScaledToDpi(true);
|
||||||
|
|
||||||
// Create marker
|
// Create marker
|
||||||
mapMarker = new Marker(binding.map);
|
mapMarker = new Marker(binding.map);
|
||||||
@@ -307,16 +333,22 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
|||||||
|
|
||||||
public void updateView(Geofavorite item) {
|
public void updateView(Geofavorite item) {
|
||||||
binding.collapsingToolbar.setTitle(item.getName() != null ? item.getName() : getString(R.string.new_geobookmark));
|
binding.collapsingToolbar.setTitle(item.getName() != null ? item.getName() : getString(R.string.new_geobookmark));
|
||||||
binding.nameEt.setText(item.getName());
|
binding.nameEt.setText(item.getName() != null ? item.getName() : "");
|
||||||
binding.descriptionEt.setText(item.getComment());
|
binding.descriptionEt.setText(item.getComment() != null ? item.getComment() : "");
|
||||||
binding.createdTv.setText(item.getLocalDateCreated().format(dateFormatter));
|
binding.createdTv.setText(item.getLocalDateCreated().format(dateFormatter));
|
||||||
binding.modifiedTv.setText(item.getLocalDateCreated().format(dateFormatter));
|
binding.modifiedTv.setText(item.getLocalDateCreated().format(dateFormatter));
|
||||||
binding.categoryTv.setText(item.getCategory()); // TODO: Category spinner from existing categories
|
binding.categoryAt.setText(item.getCategory() != null ? item.getCategory() : Geofavorite.DEFAULT_CATEGORY);
|
||||||
updateViewCoords(item);
|
updateViewCoords(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateViewCoords(Geofavorite item) {
|
public void updateViewCoords(Geofavorite item) {
|
||||||
binding.coordsTv.setText(item.getCoordinatesString());
|
binding.coordsTv.setText(item.getCoordinatesString());
|
||||||
|
binding.coordsTv.setOnClickListener((v) -> {
|
||||||
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
ClipData clip = ClipData.newPlainText(item.getCoordinatesString(), item.getCoordinatesString());
|
||||||
|
clipboard.setPrimaryClip(clip);
|
||||||
|
Toast.makeText(GeofavoriteDetailActivity.this, R.string.coords_copied, Toast.LENGTH_SHORT).show();
|
||||||
|
});
|
||||||
|
|
||||||
// Center map
|
// Center map
|
||||||
GeoPoint position = new GeoPoint(item.getLat(), item.getLng());
|
GeoPoint position = new GeoPoint(item.getLat(), item.getLng());
|
||||||
@@ -331,21 +363,30 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
|||||||
public void updateModel(Geofavorite item) {
|
public void updateModel(Geofavorite item) {
|
||||||
item.setName(binding.nameEt.getText().toString());
|
item.setName(binding.nameEt.getText().toString());
|
||||||
item.setComment(binding.descriptionEt.getText().toString());
|
item.setComment(binding.descriptionEt.getText().toString());
|
||||||
|
item.setCategory(binding.categoryAt.getText().toString());
|
||||||
item.setDateModified(System.currentTimeMillis() / 1000);
|
item.setDateModified(System.currentTimeMillis() / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUpdating(boolean updating) {
|
||||||
|
binding.progress.setVisibility(updating ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
public void setAccuracy(float accuracy) {
|
public void setAccuracy(float accuracy) {
|
||||||
|
// Display accuracy in meters
|
||||||
binding.accuracyTv.setText(getString(R.string.accuracy).replace("{accuracy}", ((int)accuracy) + ""));
|
binding.accuracyTv.setText(getString(R.string.accuracy).replace("{accuracy}", ((int)accuracy) + ""));
|
||||||
// Color the accuracy background with a scale from red (MINIMUM_ACCEPTABLE_ACCURACY) to green (0 meters)
|
// Display accuracy in progress bar
|
||||||
float red = accuracy / MINIMUM_ACCEPTABLE_ACCURACY;
|
int accuracyPercent = (int)accuracy > 100 ? 0 : Math.abs((int)accuracy - 100);
|
||||||
if (red > 1.0f) red = 1.0f;
|
binding.accuracyProgress.setIndeterminate(false);
|
||||||
float green = 1.0f - red;
|
binding.accuracyProgress.setProgress(accuracyPercent);
|
||||||
if (Build.VERSION.SDK_INT >= 26)
|
}
|
||||||
binding.accuracyTv.setBackgroundColor(Color.rgb(red, green, 0.0f));
|
|
||||||
|
public void setCategories(HashSet<String> categories) {
|
||||||
|
((CategoriesAdapter)binding.categoryAt.getAdapter()).setCategoriesList(categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideAccuracy() {
|
public void hideAccuracy() {
|
||||||
binding.accuracyTv.setVisibility(View.GONE);
|
binding.accuracyTv.setVisibility(View.GONE);
|
||||||
|
binding.accuracyProgressContainer.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideActions() {
|
public void hideActions() {
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package it.danieleverducci.nextcloudmaps.activity.detail;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||||
|
import it.danieleverducci.nextcloudmaps.repository.GeofavoriteRepository;
|
||||||
|
|
||||||
|
public class GeofavoriteDetailActivityViewModel extends ViewModel {
|
||||||
|
private GeofavoriteRepository mRepo;
|
||||||
|
|
||||||
|
public void init(Context applicationContext) {
|
||||||
|
mRepo = GeofavoriteRepository.getInstance(applicationContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Geofavorite getGeofavorite(int id) {
|
||||||
|
return mRepo.getGeofavorite(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveGeofavorite(Geofavorite geofav) {
|
||||||
|
mRepo.saveGeofavorite(geofav);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<HashSet<String>> getCategories(){
|
||||||
|
return mRepo.getCategories();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<Boolean> getIsUpdating(){
|
||||||
|
return mRepo.isUpdating();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<Boolean> getOnFinished(){
|
||||||
|
return mRepo.onFinished();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -20,6 +20,8 @@ package it.danieleverducci.nextcloudmaps.activity.login;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
@@ -39,12 +41,14 @@ import com.nextcloud.android.sso.model.SingleSignOnAccount;
|
|||||||
import com.nextcloud.android.sso.ui.UiExceptionManager;
|
import com.nextcloud.android.sso.ui.UiExceptionManager;
|
||||||
|
|
||||||
import it.danieleverducci.nextcloudmaps.R;
|
import it.danieleverducci.nextcloudmaps.R;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.NextcloudMapsStyledActivity;
|
||||||
import it.danieleverducci.nextcloudmaps.activity.main.MainActivity;
|
import it.danieleverducci.nextcloudmaps.activity.main.MainActivity;
|
||||||
|
import it.danieleverducci.nextcloudmaps.api.API;
|
||||||
import it.danieleverducci.nextcloudmaps.api.ApiProvider;
|
import it.danieleverducci.nextcloudmaps.api.ApiProvider;
|
||||||
|
|
||||||
public class LoginActivity extends AppCompatActivity {
|
public class LoginActivity extends NextcloudMapsStyledActivity {
|
||||||
|
private static final String TAG = "LoginActivity";
|
||||||
|
|
||||||
protected ApiProvider mApi;
|
|
||||||
protected ProgressBar progress;
|
protected ProgressBar progress;
|
||||||
protected Button button;
|
protected Button button;
|
||||||
|
|
||||||
@@ -62,18 +66,25 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
openAccountChooser();
|
openAccountChooser();
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
Handler h = new Handler();
|
||||||
ssoAccount = SingleAccountHelper.getCurrentSingleSignOnAccount(getApplicationContext());
|
h.post(() -> {
|
||||||
SingleAccountHelper.setCurrentAccount(getApplicationContext(), ssoAccount.name);
|
try {
|
||||||
accountAccessDone();
|
ssoAccount = SingleAccountHelper.getCurrentSingleSignOnAccount(getApplicationContext());
|
||||||
} catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
|
SingleAccountHelper.applyCurrentAccount(getApplicationContext(), ssoAccount.name);
|
||||||
}
|
accountAccessDone();
|
||||||
|
} catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
|
||||||
|
Log.e(TAG, "Autologin: " + e.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
private void openAccountChooser() {
|
private void openAccountChooser() {
|
||||||
try {
|
try {
|
||||||
AccountImporter.pickNewAccount(this);
|
AccountImporter.pickNewAccount(this);
|
||||||
} catch (NextcloudFilesAppNotInstalledException | AndroidGetAccountsPermissionNotGranted e) {
|
} catch (NextcloudFilesAppNotInstalledException | AndroidGetAccountsPermissionNotGranted e) {
|
||||||
UiExceptionManager.showDialogForException(this, e);
|
UiExceptionManager.showDialogForException(this, e);
|
||||||
|
|
||||||
|
Log.e(TAG, "openAccountChooser: " + e.toString());
|
||||||
|
progress.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +108,7 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void accountAccessGranted(SingleSignOnAccount account) {
|
public void accountAccessGranted(SingleSignOnAccount account) {
|
||||||
Context l_context = getApplicationContext();
|
Context l_context = getApplicationContext();
|
||||||
SingleAccountHelper.setCurrentAccount(l_context, account.name);
|
SingleAccountHelper.applyCurrentAccount(l_context, account.name);
|
||||||
|
|
||||||
accountAccessDone();
|
accountAccessDone();
|
||||||
}
|
}
|
||||||
@@ -114,9 +125,6 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void accountAccessDone() {
|
private void accountAccessDone() {
|
||||||
Context l_context = getApplicationContext();
|
|
||||||
mApi = new ApiProvider(l_context);
|
|
||||||
|
|
||||||
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
|
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
||||||
|
|||||||
@@ -21,45 +21,45 @@
|
|||||||
package it.danieleverducci.nextcloudmaps.activity.main;
|
package it.danieleverducci.nextcloudmaps.activity.main;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Filter;
|
|
||||||
import android.widget.Filterable;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.core.graphics.drawable.DrawableCompat;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import org.threeten.bp.format.DateTimeFormatter;
|
import org.threeten.bp.format.DateTimeFormatter;
|
||||||
import org.threeten.bp.format.FormatStyle;
|
import org.threeten.bp.format.FormatStyle;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import it.danieleverducci.nextcloudmaps.R;
|
import it.danieleverducci.nextcloudmaps.R;
|
||||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||||
|
|
||||||
public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.GeofavoriteViewHolder> implements Filterable {
|
public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.GeofavoriteViewHolder> {
|
||||||
|
|
||||||
public static final String TAG = "GeofavoriteAdapter";
|
public static final String TAG = "GeofavoriteAdapter";
|
||||||
|
|
||||||
public static final int SORT_BY_TITLE = 0;
|
public static final int SORT_BY_TITLE = 0;
|
||||||
public static final int SORT_BY_CREATED = 1;
|
public static final int SORT_BY_CREATED = 1;
|
||||||
|
public static final int SORT_BY_CATEGORY = 2;
|
||||||
|
public static final int SORT_BY_DISTANCE = 3;
|
||||||
|
|
||||||
private Context context;
|
private final Context context;
|
||||||
private ItemClickListener itemClickListener;
|
private final ItemClickListener itemClickListener;
|
||||||
private DateTimeFormatter dateFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT);
|
private final DateTimeFormatter dateFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT);
|
||||||
|
|
||||||
private List<Geofavorite> geofavoriteList = new ArrayList<>();
|
private List<Geofavorite> items = new ArrayList<>();
|
||||||
private List<Geofavorite> geofavoriteListFiltered = new ArrayList<>();
|
|
||||||
private int sortRule = SORT_BY_CREATED;
|
private int sortRule = SORT_BY_CREATED;
|
||||||
|
|
||||||
// Contains the position of the element containing the overflow menu clicked
|
// Contains the position of the element containing the overflow menu clicked
|
||||||
@@ -71,26 +71,15 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setGeofavoriteList(@NonNull List<Geofavorite> geofavoriteList) {
|
public void setGeofavoriteList(@NonNull List<Geofavorite> geofavoriteList) {
|
||||||
this.geofavoriteList = geofavoriteList;
|
this.items.clear();
|
||||||
this.geofavoriteListFiltered = new ArrayList<>(geofavoriteList);
|
this.items.addAll(geofavoriteList);
|
||||||
|
|
||||||
performSort();
|
performSort();
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Geofavorite get(int position) {
|
public Geofavorite get(int position) {
|
||||||
return geofavoriteListFiltered.get(position);
|
return items.get(position);
|
||||||
}
|
|
||||||
|
|
||||||
public void removeById(int id) {
|
|
||||||
for (Geofavorite g : geofavoriteList) {
|
|
||||||
if (g.getId() == id) {
|
|
||||||
geofavoriteList.remove(g);
|
|
||||||
geofavoriteListFiltered.remove(g);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSortRule() {
|
public int getSortRule() {
|
||||||
@@ -113,59 +102,23 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull GeofavoriteViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull GeofavoriteViewHolder holder, int position) {
|
||||||
Geofavorite geofavorite = geofavoriteListFiltered.get(position);
|
Geofavorite geofavorite = items.get(position);
|
||||||
|
|
||||||
holder.tv_title.setText(Html.fromHtml(geofavorite.getName()));
|
holder.tv_category.setText(geofavorite.categoryLetter());
|
||||||
holder.tv_content.setText(geofavorite.getComment());
|
holder.setCategoryColor(
|
||||||
|
geofavorite.categoryColor() == 0 ? context.getColor(R.color.defaultBrand) : geofavorite.categoryColor());
|
||||||
|
holder.tv_title.setText(Html.fromHtml(geofavorite.getName() == null ? "" : geofavorite.getName()));
|
||||||
|
holder.tv_content.setText(geofavorite.getComment() == null ? "" : geofavorite.getComment());
|
||||||
holder.tv_date.setText(geofavorite.getLocalDateCreated().format(dateFormatter));
|
holder.tv_date.setText(geofavorite.getLocalDateCreated().format(dateFormatter));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return geofavoriteListFiltered.size();
|
return items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Filter getFilter() {
|
|
||||||
return filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
Filter filter = new Filter() {
|
|
||||||
@Override
|
|
||||||
// Run on Background thread.
|
|
||||||
protected FilterResults performFiltering(CharSequence charSequence) {
|
|
||||||
FilterResults filterResults = new FilterResults();
|
|
||||||
List <Geofavorite> filteredGeofavorites = new ArrayList<>();
|
|
||||||
|
|
||||||
if (charSequence.toString().isEmpty()) {
|
|
||||||
filteredGeofavorites.addAll(geofavoriteList);
|
|
||||||
} else {
|
|
||||||
for (Geofavorite geofavorite : geofavoriteList) {
|
|
||||||
String query = charSequence.toString().toLowerCase();
|
|
||||||
if (geofavorite.getName() != null && geofavorite.getName().toLowerCase().contains(query)) {
|
|
||||||
filteredGeofavorites.add(geofavorite);
|
|
||||||
} else if (geofavorite.getComment() != null && geofavorite.getComment().toLowerCase().contains(query)) {
|
|
||||||
filteredGeofavorites.add(geofavorite);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
filterResults.values = filteredGeofavorites;
|
|
||||||
return filterResults;
|
|
||||||
}
|
|
||||||
//Run on ui thread
|
|
||||||
@Override
|
|
||||||
protected void publishResults(CharSequence charSequence, FilterResults filterResults) {
|
|
||||||
geofavoriteListFiltered.clear();
|
|
||||||
geofavoriteListFiltered.addAll((Collection<? extends Geofavorite>) filterResults.values);
|
|
||||||
|
|
||||||
performSort();
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class GeofavoriteViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
class GeofavoriteViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
TextView tv_title, tv_content, tv_date;
|
TextView tv_category, tv_title, tv_content, tv_date;
|
||||||
ImageView bt_context_menu;
|
ImageView bt_context_menu;
|
||||||
ImageView bt_nav;
|
ImageView bt_nav;
|
||||||
|
|
||||||
@@ -175,6 +128,7 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
|||||||
GeofavoriteViewHolder(@NonNull View itemView, ItemClickListener itemClickListener) {
|
GeofavoriteViewHolder(@NonNull View itemView, ItemClickListener itemClickListener) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
|
tv_category = itemView.findViewById(R.id.tv_category);
|
||||||
tv_title = itemView.findViewById(R.id.title);
|
tv_title = itemView.findViewById(R.id.title);
|
||||||
tv_content = itemView.findViewById(R.id.content);
|
tv_content = itemView.findViewById(R.id.content);
|
||||||
tv_date = itemView.findViewById(R.id.date);
|
tv_date = itemView.findViewById(R.id.date);
|
||||||
@@ -192,24 +146,35 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
|||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
case R.id.geofav_context_menu_bt:
|
case R.id.geofav_context_menu_bt:
|
||||||
onOverflowIconClicked(view, getAdapterPosition());
|
onOverflowIconClicked(view, getBindingAdapterPosition());
|
||||||
break;
|
break;
|
||||||
case R.id.geofav_nav_bt:
|
case R.id.geofav_nav_bt:
|
||||||
if (itemClickListener != null)
|
if (itemClickListener != null)
|
||||||
itemClickListener.onItemNavClick(get(getAdapterPosition()));
|
itemClickListener.onItemNavClick(get(getBindingAdapterPosition()));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (itemClickListener != null)
|
if (itemClickListener != null)
|
||||||
itemClickListener.onItemClick(get(getAdapterPosition()));
|
itemClickListener.onItemClick(get(getBindingAdapterPosition()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCategoryColor(int ccTint) {
|
||||||
|
Drawable bg = DrawableCompat.wrap(this.tv_category.getContext().getDrawable(R.drawable.ic_list_pin));
|
||||||
|
this.tv_category.setBackground(bg);
|
||||||
|
DrawableCompat.setTint(bg, ccTint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void performSort() {
|
private void performSort() {
|
||||||
if (sortRule == SORT_BY_TITLE) {
|
if (sortRule == SORT_BY_TITLE) {
|
||||||
Collections.sort(geofavoriteListFiltered, Geofavorite.ByTitleAZ);
|
Collections.sort(items, Geofavorite.ByTitleAZ);
|
||||||
} else if (sortRule == SORT_BY_CREATED) {
|
} else if (sortRule == SORT_BY_CREATED) {
|
||||||
Collections.sort(geofavoriteListFiltered, Geofavorite.ByLastCreated);
|
Collections.sort(items, Geofavorite.ByLastCreated);
|
||||||
|
} else if (sortRule == SORT_BY_CATEGORY) {
|
||||||
|
Collections.sort(items, Geofavorite.ByCategory);
|
||||||
|
} else if (sortRule == SORT_BY_DISTANCE) {
|
||||||
|
Collections.sort(items, Geofavorite.ByDistance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package it.danieleverducci.nextcloudmaps.activity.main;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||||
|
import it.danieleverducci.nextcloudmaps.repository.GeofavoriteRepository;
|
||||||
|
|
||||||
|
public class GeofavoritesFragmentViewModel extends ViewModel {
|
||||||
|
private GeofavoriteRepository mRepo;
|
||||||
|
|
||||||
|
public void init(Context applicationContext) {
|
||||||
|
mRepo = GeofavoriteRepository.getInstance(applicationContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Geofavorite>> getGeofavorites(){
|
||||||
|
mRepo.updateGeofavorites();
|
||||||
|
return mRepo.getGeofavorites();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateGeofavorites() {
|
||||||
|
mRepo.updateGeofavorites();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<HashSet<String>> getCategories(){
|
||||||
|
return mRepo.getCategories();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteGeofavorite(Geofavorite geofav) {
|
||||||
|
mRepo.deleteGeofavorite(geofav);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<Boolean> getIsUpdating(){
|
||||||
|
return mRepo.isUpdating();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<Boolean> getOnFinished(){
|
||||||
|
return mRepo.onFinished();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,180 +17,139 @@
|
|||||||
|
|
||||||
package it.danieleverducci.nextcloudmaps.activity.main;
|
package it.danieleverducci.nextcloudmaps.activity.main;
|
||||||
|
|
||||||
import android.content.DialogInterface;
|
import android.Manifest;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.view.View;
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.appcompat.widget.AppCompatImageButton;
|
|
||||||
import androidx.appcompat.widget.AppCompatImageView;
|
|
||||||
import androidx.appcompat.widget.SearchView;
|
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
import androidx.core.view.GravityCompat;
|
import androidx.core.view.GravityCompat;
|
||||||
import androidx.drawerlayout.widget.DrawerLayout;
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
import androidx.preference.PreferenceManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
|
||||||
|
|
||||||
import com.google.android.material.card.MaterialCardView;
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import com.nextcloud.android.sso.helper.SingleAccountHelper;
|
import com.nextcloud.android.sso.helper.SingleAccountHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import it.danieleverducci.nextcloudmaps.R;
|
import it.danieleverducci.nextcloudmaps.R;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.NextcloudMapsStyledActivity;
|
||||||
import it.danieleverducci.nextcloudmaps.activity.about.AboutActivity;
|
import it.danieleverducci.nextcloudmaps.activity.about.AboutActivity;
|
||||||
import it.danieleverducci.nextcloudmaps.activity.detail.GeofavoriteDetailActivity;
|
import it.danieleverducci.nextcloudmaps.activity.detail.GeofavoriteDetailActivity;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.settings.SettingsActivity;
|
||||||
import it.danieleverducci.nextcloudmaps.activity.login.LoginActivity;
|
import it.danieleverducci.nextcloudmaps.activity.login.LoginActivity;
|
||||||
import it.danieleverducci.nextcloudmaps.activity.main.NavigationAdapter.NavigationItem;
|
import it.danieleverducci.nextcloudmaps.activity.main.NavigationAdapter.NavigationItem;
|
||||||
import it.danieleverducci.nextcloudmaps.activity.main.SortingOrderDialogFragment.OnSortingOrderListener;
|
import it.danieleverducci.nextcloudmaps.activity.mappicker.MapPickerActivity;
|
||||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
import it.danieleverducci.nextcloudmaps.api.ApiProvider;
|
||||||
import it.danieleverducci.nextcloudmaps.utils.IntentGenerator;
|
import it.danieleverducci.nextcloudmaps.fragments.GeofavoriteListFragment;
|
||||||
|
import it.danieleverducci.nextcloudmaps.fragments.GeofavoriteMapFragment;
|
||||||
|
import it.danieleverducci.nextcloudmaps.repository.GeofavoriteRepository;
|
||||||
|
import it.danieleverducci.nextcloudmaps.utils.SettingsManager;
|
||||||
|
|
||||||
import static android.view.View.GONE;
|
public class MainActivity extends NextcloudMapsStyledActivity {
|
||||||
import static android.view.View.VISIBLE;
|
|
||||||
import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.*;
|
|
||||||
import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.SORT_BY_CREATED;
|
|
||||||
import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.SORT_BY_TITLE;
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements MainView, OnSortingOrderListener {
|
|
||||||
|
|
||||||
private static final int INTENT_ADD = 100;
|
|
||||||
private static final int INTENT_EDIT = 200;
|
|
||||||
|
|
||||||
private static final String TAG = "MainActivity";
|
private static final String TAG = "MainActivity";
|
||||||
|
private static final int PERMISSION_REQUEST_CODE = 3890;
|
||||||
|
|
||||||
private static final String NAVIGATION_KEY_ADD_GEOFAVORITE = "add";
|
private static final String NAVIGATION_KEY_ADD_GEOFAVORITE_FROM_GPS = "add_from_gps";
|
||||||
|
private static final String NAVIGATION_KEY_ADD_GEOFAVORITE_FROM_MAP = "add_from_map";
|
||||||
private static final String NAVIGATION_KEY_SHOW_ABOUT = "about";
|
private static final String NAVIGATION_KEY_SHOW_ABOUT = "about";
|
||||||
|
private static final String NAVIGATION_KEY_SETTINGS = "settings";
|
||||||
private static final String NAVIGATION_KEY_SWITCH_ACCOUNT = "switch_account";
|
private static final String NAVIGATION_KEY_SWITCH_ACCOUNT = "switch_account";
|
||||||
|
|
||||||
private SharedPreferences preferences;
|
private ArrayList<OnGpsPermissionGrantedListener> onGpsPermissionGrantedListener = new ArrayList<>();
|
||||||
|
|
||||||
private DrawerLayout drawerLayout;
|
private DrawerLayout drawerLayout;
|
||||||
private Toolbar toolbar;
|
|
||||||
private MaterialCardView homeToolbar;
|
|
||||||
private SearchView searchView;
|
|
||||||
private SwipeRefreshLayout swipeRefresh;
|
|
||||||
private RecyclerView recyclerView;
|
|
||||||
private StaggeredGridLayoutManager layoutManager;
|
|
||||||
private FloatingActionButton fab;
|
|
||||||
|
|
||||||
private MainPresenter presenter;
|
private boolean isFabOpen = false;
|
||||||
private GeofavoriteAdapter geofavoriteAdapter;
|
|
||||||
private ItemClickListener rvItemClickListener;
|
|
||||||
|
|
||||||
NavigationAdapter navigationCommonAdapter;
|
NavigationAdapter navigationCommonAdapter;
|
||||||
|
|
||||||
@Override
|
public void openDrawer() {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
drawerLayout.openDrawer(GravityCompat.START);
|
||||||
super.onCreate(savedInstanceState);
|
}
|
||||||
setContentView(R.layout.activity_main);
|
|
||||||
|
|
||||||
preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
public void showMap() {
|
||||||
|
replaceFragment(new GeofavoriteMapFragment());
|
||||||
|
SettingsManager.setGeofavoriteListShownAsMap(this, true);
|
||||||
|
}
|
||||||
|
|
||||||
int sortRule = preferences.getInt(getString(R.string.setting_sort_by), SORT_BY_CREATED);
|
public void showList() {
|
||||||
boolean gridViewEnabled = preferences.getBoolean(getString(R.string.setting_grid_view_enabled), false);
|
replaceFragment(new GeofavoriteListFragment());
|
||||||
|
SettingsManager.setGeofavoriteListShownAsMap(this, false);
|
||||||
|
}
|
||||||
|
|
||||||
recyclerView = findViewById(R.id.recycler_view);
|
public void addOnGpsPermissionGrantedListener(OnGpsPermissionGrantedListener l) {
|
||||||
layoutManager = new StaggeredGridLayoutManager(gridViewEnabled ? 2 : 1, StaggeredGridLayoutManager.VERTICAL);
|
onGpsPermissionGrantedListener.add(l);
|
||||||
recyclerView.setLayoutManager(layoutManager);
|
}
|
||||||
|
|
||||||
presenter = new MainPresenter(this);
|
public void removeOnGpsPermissionGrantedListener(OnGpsPermissionGrantedListener l) {
|
||||||
|
onGpsPermissionGrantedListener.remove(l);
|
||||||
|
}
|
||||||
|
|
||||||
rvItemClickListener = new ItemClickListener() {
|
public void requestGpsPermissions() {
|
||||||
@Override
|
ActivityCompat.requestPermissions(
|
||||||
public void onItemClick(Geofavorite item) {
|
this,
|
||||||
showGeofavoriteDetailActivity(item);
|
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
|
||||||
}
|
PERMISSION_REQUEST_CODE
|
||||||
|
);
|
||||||
@Override
|
|
||||||
public void onItemShareClick(Geofavorite item) {
|
|
||||||
startActivity(Intent.createChooser(IntentGenerator.newShareIntent(MainActivity.this, item), getString(R.string.share_via)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemNavClick(Geofavorite item) {
|
|
||||||
startActivity(IntentGenerator.newGeoUriIntent(MainActivity.this, item));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemDeleteClick(Geofavorite item) {
|
|
||||||
showGeofavoriteDeteleDialog(item);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
geofavoriteAdapter = new GeofavoriteAdapter(getApplicationContext(), rvItemClickListener);
|
|
||||||
recyclerView.setAdapter(geofavoriteAdapter);
|
|
||||||
geofavoriteAdapter.setSortRule(sortRule);
|
|
||||||
|
|
||||||
swipeRefresh = findViewById(R.id.swipe_refresh);
|
|
||||||
swipeRefresh.setOnRefreshListener(() -> presenter.getGeofavorites());
|
|
||||||
|
|
||||||
fab = findViewById(R.id.add);
|
|
||||||
fab.setOnClickListener(view -> addGeofavorite());
|
|
||||||
|
|
||||||
toolbar = findViewById(R.id.toolbar);
|
|
||||||
homeToolbar = findViewById(R.id.home_toolbar);
|
|
||||||
|
|
||||||
searchView = findViewById(R.id.search_view);
|
|
||||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onQueryTextSubmit(String query) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onQueryTextChange(String query) {
|
|
||||||
geofavoriteAdapter.getFilter().filter(query);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
searchView.setOnCloseListener(() -> {
|
|
||||||
if (toolbar.getVisibility() == VISIBLE && TextUtils.isEmpty(searchView.getQuery())) {
|
|
||||||
updateToolbars(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
setupNavigationMenu();
|
|
||||||
|
|
||||||
homeToolbar.setOnClickListener(view -> updateToolbars(false));
|
|
||||||
|
|
||||||
AppCompatImageView sortButton = findViewById(R.id.sort_mode);
|
|
||||||
sortButton.setOnClickListener(view -> openSortingOrderDialogFragment(getSupportFragmentManager(), geofavoriteAdapter.getSortRule()));
|
|
||||||
|
|
||||||
drawerLayout = findViewById(R.id.drawerLayout);
|
|
||||||
AppCompatImageButton menuButton = findViewById(R.id.menu_button);
|
|
||||||
menuButton.setOnClickListener(view -> drawerLayout.openDrawer(GravityCompat.START));
|
|
||||||
|
|
||||||
AppCompatImageView viewButton = findViewById(R.id.view_mode);
|
|
||||||
viewButton.setOnClickListener(view -> {
|
|
||||||
boolean gridEnabled = layoutManager.getSpanCount() == 1;
|
|
||||||
onGridIconChosen(gridEnabled);
|
|
||||||
});
|
|
||||||
|
|
||||||
updateSortingIcon(sortRule);
|
|
||||||
updateGridIcon(gridViewEnabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
super.onStart();
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
|
||||||
// Update list
|
if (requestCode == PERMISSION_REQUEST_CODE && permissions[0].equals(Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||||
presenter.getGeofavorites();
|
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
for (OnGpsPermissionGrantedListener l : onGpsPermissionGrantedListener) {
|
||||||
|
l.onGpsPermissionGranted();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
boolean showMap = SettingsManager.isGeofavoriteListShownAsMap(this);
|
||||||
|
if (showMap)
|
||||||
|
showMap();
|
||||||
|
else
|
||||||
|
showList();
|
||||||
|
|
||||||
|
FloatingActionButton fab = findViewById(R.id.open_fab);
|
||||||
|
fab.setOnClickListener(view -> openFab(!this.isFabOpen));
|
||||||
|
|
||||||
|
fab = findViewById(R.id.add_from_gps);
|
||||||
|
fab.setOnClickListener(view -> addGeofavoriteFromGps());
|
||||||
|
|
||||||
|
fab = findViewById(R.id.add_from_map);
|
||||||
|
fab.setOnClickListener(view -> addGeofavoriteFromMap());
|
||||||
|
|
||||||
|
setupNavigationMenu();
|
||||||
|
|
||||||
|
drawerLayout = findViewById(R.id.drawerLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
openFab(false);
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void replaceFragment(Fragment fragment) {
|
||||||
|
FragmentManager manager = getSupportFragmentManager();
|
||||||
|
FragmentTransaction transaction = manager.beginTransaction();
|
||||||
|
transaction.replace(R.id.fragment_container, fragment);
|
||||||
|
transaction.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupNavigationMenu() {
|
private void setupNavigationMenu() {
|
||||||
@@ -198,20 +157,28 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti
|
|||||||
|
|
||||||
navigationCommonAdapter = new NavigationAdapter(this, item -> {
|
navigationCommonAdapter = new NavigationAdapter(this, item -> {
|
||||||
switch (item.id) {
|
switch (item.id) {
|
||||||
case NAVIGATION_KEY_ADD_GEOFAVORITE:
|
case NAVIGATION_KEY_ADD_GEOFAVORITE_FROM_GPS:
|
||||||
addGeofavorite();
|
addGeofavoriteFromGps();
|
||||||
|
break;
|
||||||
|
case NAVIGATION_KEY_ADD_GEOFAVORITE_FROM_MAP:
|
||||||
|
addGeofavoriteFromMap();
|
||||||
break;
|
break;
|
||||||
case NAVIGATION_KEY_SHOW_ABOUT:
|
case NAVIGATION_KEY_SHOW_ABOUT:
|
||||||
show_about();
|
show_about();
|
||||||
break;
|
break;
|
||||||
|
case NAVIGATION_KEY_SETTINGS:
|
||||||
|
show_settings();
|
||||||
|
break;
|
||||||
case NAVIGATION_KEY_SWITCH_ACCOUNT:
|
case NAVIGATION_KEY_SWITCH_ACCOUNT:
|
||||||
switch_account();
|
switch_account();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
navItems.add(new NavigationItem(NAVIGATION_KEY_ADD_GEOFAVORITE, getString(R.string.new_geobookmark), R.drawable.ic_add));
|
navItems.add(new NavigationItem(NAVIGATION_KEY_ADD_GEOFAVORITE_FROM_GPS, getString(R.string.new_geobookmark_gps), R.drawable.ic_add_gps));
|
||||||
|
navItems.add(new NavigationItem(NAVIGATION_KEY_ADD_GEOFAVORITE_FROM_MAP, getString(R.string.new_geobookmark_map), R.drawable.ic_add_map));
|
||||||
navItems.add(new NavigationItem(NAVIGATION_KEY_SHOW_ABOUT, getString(R.string.about), R.drawable.ic_info_grey));
|
navItems.add(new NavigationItem(NAVIGATION_KEY_SHOW_ABOUT, getString(R.string.about), R.drawable.ic_info_grey));
|
||||||
|
navItems.add(new NavigationItem(NAVIGATION_KEY_SETTINGS, getString(R.string.settings), R.drawable.ic_settings_grey));
|
||||||
navItems.add(new NavigationItem(NAVIGATION_KEY_SWITCH_ACCOUNT, getString(R.string.switch_account), R.drawable.ic_logout_grey));
|
navItems.add(new NavigationItem(NAVIGATION_KEY_SWITCH_ACCOUNT, getString(R.string.switch_account), R.drawable.ic_logout_grey));
|
||||||
navigationCommonAdapter.setItems(navItems);
|
navigationCommonAdapter.setItems(navItems);
|
||||||
|
|
||||||
@@ -219,133 +186,56 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti
|
|||||||
navigationMenuCommon.setAdapter(navigationCommonAdapter);
|
navigationMenuCommon.setAdapter(navigationCommonAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateToolbars(boolean disableSearch) {
|
private void addGeofavoriteFromGps() {
|
||||||
homeToolbar.setVisibility(disableSearch ? VISIBLE : GONE);
|
startActivity(
|
||||||
toolbar.setVisibility(disableSearch ? GONE : VISIBLE);
|
new Intent(this, GeofavoriteDetailActivity.class)
|
||||||
if (disableSearch) {
|
);
|
||||||
searchView.setQuery(null, true);
|
|
||||||
}
|
|
||||||
searchView.setIconified(disableSearch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openSortingOrderDialogFragment(FragmentManager supportFragmentManager, int sortOrder) {
|
private void addGeofavoriteFromMap() {
|
||||||
FragmentTransaction fragmentTransaction = supportFragmentManager.beginTransaction();
|
startActivity(
|
||||||
fragmentTransaction.addToBackStack(null);
|
new Intent(this, MapPickerActivity.class)
|
||||||
|
);
|
||||||
SortingOrderDialogFragment.newInstance(sortOrder).show(fragmentTransaction, SortingOrderDialogFragment.SORTING_ORDER_FRAGMENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void show_settings() {
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
startActivity(new Intent(this, SettingsActivity.class));
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
if (requestCode == INTENT_ADD && resultCode == RESULT_OK) {
|
|
||||||
presenter.getGeofavorites();
|
|
||||||
} else if (requestCode == INTENT_EDIT && resultCode == RESULT_OK) {
|
|
||||||
presenter.getGeofavorites();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addGeofavorite() {
|
|
||||||
startActivityForResult(
|
|
||||||
new Intent(this, GeofavoriteDetailActivity.class), INTENT_ADD);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void show_about() {
|
private void show_about() {
|
||||||
startActivity(new Intent(this, AboutActivity.class));
|
startActivity(new Intent(this, AboutActivity.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switch_account() {
|
public void switch_account() {
|
||||||
SingleAccountHelper.setCurrentAccount(this, null);
|
ApiProvider.logout();
|
||||||
|
GeofavoriteRepository.resetInstance();
|
||||||
|
SingleAccountHelper.applyCurrentAccount(this, null);
|
||||||
Intent intent = new Intent(MainActivity.this, LoginActivity.class);
|
Intent intent = new Intent(MainActivity.this, LoginActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void openFab(boolean open) {
|
||||||
public void showLoading() {
|
View fab = findViewById(R.id.open_fab);
|
||||||
swipeRefresh.setRefreshing(true);
|
View addFromGpsFab = findViewById(R.id.add_from_gps);
|
||||||
}
|
View addFromMapFab = findViewById(R.id.add_from_map);
|
||||||
|
|
||||||
@Override
|
if (open) {
|
||||||
public void hideLoading() {
|
this.isFabOpen = true;
|
||||||
swipeRefresh.setRefreshing(false);
|
fab.animate().rotation(45.0f);
|
||||||
}
|
addFromGpsFab.animate().translationY(-getResources().getDimension(R.dimen.fab_vertical_offset));
|
||||||
|
addFromMapFab.animate().translationY(-getResources().getDimension(R.dimen.fab_vertical_offset) * 2);
|
||||||
@Override
|
} else {
|
||||||
public void onGetResult(List<Geofavorite> geofavorite_list) {
|
this.isFabOpen = false;
|
||||||
geofavoriteAdapter.setGeofavoriteList(geofavorite_list);
|
fab.animate().rotation(0f);
|
||||||
}
|
addFromGpsFab.animate().translationY(0);
|
||||||
|
addFromMapFab.animate().translationY(0);
|
||||||
@Override
|
|
||||||
public void onGeofavoriteDeleted(int id) {
|
|
||||||
// Update list
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
geofavoriteAdapter.removeById(id);
|
|
||||||
Toast.makeText(MainActivity.this, R.string.list_geofavorite_deleted, Toast.LENGTH_LONG).show();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onErrorLoading(String message) {
|
|
||||||
Toast.makeText(MainActivity.this, R.string.list_geofavorite_connection_error, Toast.LENGTH_LONG).show();
|
|
||||||
Log.e(TAG, "Unable to obtain geofavorites list: " + message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSortingOrderChosen(int sortSelection) {
|
|
||||||
geofavoriteAdapter.setSortRule(sortSelection);
|
|
||||||
updateSortingIcon(sortSelection);
|
|
||||||
|
|
||||||
preferences.edit().putInt(getString(R.string.setting_sort_by), sortSelection).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateSortingIcon(int sortSelection) {
|
|
||||||
AppCompatImageView sortButton = findViewById(R.id.sort_mode);
|
|
||||||
switch (sortSelection) {
|
|
||||||
case SORT_BY_TITLE:
|
|
||||||
sortButton.setImageResource(R.drawable.ic_alphabetical_asc);
|
|
||||||
break;
|
|
||||||
case SORT_BY_CREATED:
|
|
||||||
sortButton.setImageResource(R.drawable.ic_modification_asc);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onGridIconChosen(boolean gridEnabled) {
|
public interface OnGpsPermissionGrantedListener {
|
||||||
layoutManager.setSpanCount(gridEnabled ? 2 : 1);
|
public void onGpsPermissionGranted();
|
||||||
updateGridIcon(gridEnabled);
|
|
||||||
|
|
||||||
preferences.edit().putBoolean(getString(R.string.setting_grid_view_enabled), gridEnabled).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateGridIcon(boolean gridEnabled) {
|
|
||||||
AppCompatImageView viewButton = findViewById(R.id.view_mode);
|
|
||||||
viewButton.setImageResource(gridEnabled ? R.drawable.ic_view_list : R.drawable.ic_view_module);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showGeofavoriteDeteleDialog(Geofavorite item) {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
||||||
builder.setMessage(getString(R.string.dialog_delete_message).replace("{name}", item.getName()))
|
|
||||||
.setTitle(R.string.dialog_delete_title)
|
|
||||||
.setPositiveButton(R.string.dialog_delete_delete, new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
presenter.deleteGeofavorite(item.getId());
|
|
||||||
dialog.dismiss();
|
|
||||||
// Callback is onGeofavoriteDeleted
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.dialog_delete_cancel, new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
AlertDialog ad = builder.create();
|
|
||||||
ad.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showGeofavoriteDetailActivity(Geofavorite item) {
|
|
||||||
Intent i = new Intent(this, GeofavoriteDetailActivity.class);
|
|
||||||
i.putExtra(GeofavoriteDetailActivity.ARG_GEOFAVORITE, item);
|
|
||||||
startActivity(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* Nextcloud Maps Geofavorites for Android
|
|
||||||
*
|
|
||||||
* @copyright Copyright (c) 2020 John Doe <john@doe.com>
|
|
||||||
* @author John Doe <john@doe.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package it.danieleverducci.nextcloudmaps.activity.main;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import it.danieleverducci.nextcloudmaps.api.ApiProvider;
|
|
||||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
|
||||||
import retrofit2.Call;
|
|
||||||
import retrofit2.Callback;
|
|
||||||
import retrofit2.Response;
|
|
||||||
|
|
||||||
public class MainPresenter {
|
|
||||||
private MainView view;
|
|
||||||
|
|
||||||
public MainPresenter(MainView view) {
|
|
||||||
this.view = view;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getGeofavorites() {
|
|
||||||
view.showLoading();
|
|
||||||
Call<List<Geofavorite>> call = ApiProvider.getAPI().getGeofavorites();
|
|
||||||
call.enqueue(new Callback<List<Geofavorite>>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(@NonNull Call<List<Geofavorite>> call, @NonNull Response<List<Geofavorite>> response) {
|
|
||||||
((AppCompatActivity) view).runOnUiThread(() -> {
|
|
||||||
view.hideLoading();
|
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
|
||||||
view.onGetResult(response.body());
|
|
||||||
} else {
|
|
||||||
((AppCompatActivity) view).runOnUiThread(() -> {
|
|
||||||
view.hideLoading();
|
|
||||||
view.onErrorLoading(response.raw().message());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(@NonNull Call<List<Geofavorite>> call, @NonNull Throwable t) {
|
|
||||||
((AppCompatActivity) view).runOnUiThread(() -> {
|
|
||||||
view.hideLoading();
|
|
||||||
view.onErrorLoading(t.getLocalizedMessage());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteGeofavorite(int id) {
|
|
||||||
view.showLoading();
|
|
||||||
Call<Geofavorite> call = ApiProvider.getAPI().deleteGeofavorite(id);
|
|
||||||
call.enqueue(new Callback<Geofavorite>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(Call<Geofavorite> call, Response<Geofavorite> response) {
|
|
||||||
view.hideLoading();
|
|
||||||
view.onGeofavoriteDeleted(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call<Geofavorite> call, Throwable t) {
|
|
||||||
view.hideLoading();
|
|
||||||
view.onErrorLoading(t.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* Nextcloud Maps Geofavorites for Android
|
|
||||||
*
|
|
||||||
* @copyright Copyright (c) 2020 John Doe <john@doe.com>
|
|
||||||
* @author John Doe <john@doe.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package it.danieleverducci.nextcloudmaps.activity.main;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
|
||||||
|
|
||||||
public interface MainView {
|
|
||||||
void showLoading();
|
|
||||||
void hideLoading();
|
|
||||||
void onGetResult(List<Geofavorite> geofavorites);
|
|
||||||
void onGeofavoriteDeleted(int id);
|
|
||||||
void onErrorLoading(String message);
|
|
||||||
}
|
|
||||||
@@ -80,15 +80,12 @@ public class NavigationAdapter extends RecyclerView.Adapter<NavigationAdapter.Vi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void bind(@NonNull NavigationItem item) {
|
private void bind(@NonNull NavigationItem item) {
|
||||||
int color = view.getResources().getColor(R.color.accent);
|
|
||||||
|
|
||||||
currentItem = item;
|
currentItem = item;
|
||||||
name.setText(item.label);
|
name.setText(item.label);
|
||||||
|
|
||||||
name.setTextColor(color);
|
|
||||||
|
|
||||||
icon.setImageDrawable(DrawableCompat.wrap(icon.getResources().getDrawable(item.icon)));
|
icon.setImageDrawable(DrawableCompat.wrap(icon.getResources().getDrawable(item.icon)));
|
||||||
icon.setColorFilter(color);
|
|
||||||
icon.setVisibility(View.VISIBLE);
|
icon.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import android.widget.ImageButton;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.graphics.drawable.DrawableCompat;
|
import androidx.core.graphics.drawable.DrawableCompat;
|
||||||
import androidx.fragment.app.DialogFragment;
|
import androidx.fragment.app.DialogFragment;
|
||||||
|
|
||||||
@@ -47,6 +48,7 @@ public class SortingOrderDialogFragment extends DialogFragment {
|
|||||||
public static final String SORTING_ORDER_FRAGMENT = "SORTING_ORDER_FRAGMENT";
|
public static final String SORTING_ORDER_FRAGMENT = "SORTING_ORDER_FRAGMENT";
|
||||||
private static final String KEY_SORT_ORDER = "SORT_ORDER";
|
private static final String KEY_SORT_ORDER = "SORT_ORDER";
|
||||||
|
|
||||||
|
private OnSortingOrderListener onSortingOrderListener;
|
||||||
private View mView;
|
private View mView;
|
||||||
private View[] mTaggedViews;
|
private View[] mTaggedViews;
|
||||||
private Button mCancel;
|
private Button mCancel;
|
||||||
@@ -89,15 +91,20 @@ public class SortingOrderDialogFragment extends DialogFragment {
|
|||||||
return mView;
|
return mView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOnSortingOrderListener(OnSortingOrderListener listener) {
|
||||||
|
this.onSortingOrderListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find all relevant UI elements and set their values.
|
* find all relevant UI elements and set their values.
|
||||||
|
* TODO: this is REALLY ugly.
|
||||||
*
|
*
|
||||||
* @param view the parent view
|
* @param view the parent view
|
||||||
*/
|
*/
|
||||||
private void setupDialogElements(View view) {
|
private void setupDialogElements(View view) {
|
||||||
mCancel = view.findViewById(R.id.cancel);
|
mCancel = view.findViewById(R.id.cancel);
|
||||||
|
|
||||||
mTaggedViews = new View[4];
|
mTaggedViews = new View[8];
|
||||||
mTaggedViews[0] = view.findViewById(R.id.sortByTitleAscending);
|
mTaggedViews[0] = view.findViewById(R.id.sortByTitleAscending);
|
||||||
mTaggedViews[0].setTag(GeofavoriteAdapter.SORT_BY_TITLE);
|
mTaggedViews[0].setTag(GeofavoriteAdapter.SORT_BY_TITLE);
|
||||||
mTaggedViews[1] = view.findViewById(R.id.sortByTitleAscendingText);
|
mTaggedViews[1] = view.findViewById(R.id.sortByTitleAscendingText);
|
||||||
@@ -106,6 +113,14 @@ public class SortingOrderDialogFragment extends DialogFragment {
|
|||||||
mTaggedViews[2].setTag(GeofavoriteAdapter.SORT_BY_CREATED);
|
mTaggedViews[2].setTag(GeofavoriteAdapter.SORT_BY_CREATED);
|
||||||
mTaggedViews[3] = view.findViewById(R.id.sortByCreationDateDescendingText);
|
mTaggedViews[3] = view.findViewById(R.id.sortByCreationDateDescendingText);
|
||||||
mTaggedViews[3].setTag(GeofavoriteAdapter.SORT_BY_CREATED);
|
mTaggedViews[3].setTag(GeofavoriteAdapter.SORT_BY_CREATED);
|
||||||
|
mTaggedViews[4] = view.findViewById(R.id.sortByCategoryAscending);
|
||||||
|
mTaggedViews[4].setTag(GeofavoriteAdapter.SORT_BY_CATEGORY);
|
||||||
|
mTaggedViews[5] = view.findViewById(R.id.sortByCategoryAscendingText);
|
||||||
|
mTaggedViews[5].setTag(GeofavoriteAdapter.SORT_BY_CATEGORY);
|
||||||
|
mTaggedViews[6] = view.findViewById(R.id.sortByDistanceAscending);
|
||||||
|
mTaggedViews[6].setTag(GeofavoriteAdapter.SORT_BY_DISTANCE);
|
||||||
|
mTaggedViews[7] = view.findViewById(R.id.sortByDistanceAscendingText);
|
||||||
|
mTaggedViews[7].setTag(GeofavoriteAdapter.SORT_BY_DISTANCE);
|
||||||
|
|
||||||
setupActiveOrderSelection();
|
setupActiveOrderSelection();
|
||||||
}
|
}
|
||||||
@@ -121,10 +136,10 @@ public class SortingOrderDialogFragment extends DialogFragment {
|
|||||||
if (view instanceof ImageButton) {
|
if (view instanceof ImageButton) {
|
||||||
Drawable normalDrawable = ((ImageButton) view).getDrawable();
|
Drawable normalDrawable = ((ImageButton) view).getDrawable();
|
||||||
Drawable wrapDrawable = DrawableCompat.wrap(normalDrawable);
|
Drawable wrapDrawable = DrawableCompat.wrap(normalDrawable);
|
||||||
DrawableCompat.setTint(wrapDrawable, this.getResources().getColor(R.color.defaultTint));
|
DrawableCompat.setTint(wrapDrawable, ContextCompat.getColor(getContext(), R.color.selector_item_selected));
|
||||||
}
|
}
|
||||||
if (view instanceof TextView) {
|
if (view instanceof TextView) {
|
||||||
((TextView)view).setTextColor(this.getResources().getColor(R.color.defaultTint));
|
((TextView)view).setTextColor(ContextCompat.getColor(getContext(), R.color.selector_item_selected));
|
||||||
((TextView)view).setTypeface(Typeface.DEFAULT_BOLD);
|
((TextView)view).setTypeface(Typeface.DEFAULT_BOLD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,8 +176,8 @@ public class SortingOrderDialogFragment extends DialogFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
dismissAllowingStateLoss();
|
dismissAllowingStateLoss();
|
||||||
((SortingOrderDialogFragment.OnSortingOrderListener) getActivity())
|
if (onSortingOrderListener != null)
|
||||||
.onSortingOrderChosen((int) v.getTag());
|
onSortingOrderListener.onSortingOrderChosen((int) v.getTag());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,223 @@
|
|||||||
|
package it.danieleverducci.nextcloudmaps.activity.mappicker;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.location.Location;
|
||||||
|
import android.location.LocationManager;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
|
||||||
|
import org.osmdroid.api.IGeoPoint;
|
||||||
|
import org.osmdroid.api.IMapController;
|
||||||
|
import org.osmdroid.events.MapListener;
|
||||||
|
import org.osmdroid.events.ScrollEvent;
|
||||||
|
import org.osmdroid.events.ZoomEvent;
|
||||||
|
import org.osmdroid.util.GeoPoint;
|
||||||
|
import org.osmdroid.views.CustomZoomButtonsController;
|
||||||
|
import org.osmdroid.views.MapView;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import it.danieleverducci.nextcloudmaps.R;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.NextcloudMapsStyledActivity;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.detail.GeofavoriteDetailActivity;
|
||||||
|
import it.danieleverducci.nextcloudmaps.databinding.ActivityMapPickerBinding;
|
||||||
|
import it.danieleverducci.nextcloudmaps.utils.GeoUriParser;
|
||||||
|
import it.danieleverducci.nextcloudmaps.utils.MapUtils;
|
||||||
|
|
||||||
|
public class MapPickerActivity extends NextcloudMapsStyledActivity {
|
||||||
|
public static final String TAG = "MapPickerActivity";
|
||||||
|
private static final int PERMISSION_REQUEST_CODE = 8888;
|
||||||
|
|
||||||
|
private ViewHolder mViewHolder;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
MapUtils.configOsmdroid(this);
|
||||||
|
|
||||||
|
mViewHolder = new MapPickerActivity.ViewHolder(getLayoutInflater());
|
||||||
|
mViewHolder.setViewEventListener(new ViewEventListener() {
|
||||||
|
@Override
|
||||||
|
public void onExitButtonPressed() {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfirmButtonPressed() {
|
||||||
|
double[] coords = mViewHolder.getCurrentCoordinates();
|
||||||
|
Uri geoUri = GeoUriParser.createGeoUri(coords[0], coords[1], null);
|
||||||
|
Intent i = new Intent(MapPickerActivity.this, GeofavoriteDetailActivity.class);
|
||||||
|
i.setData(geoUri);
|
||||||
|
startActivity(i);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Location l = getLastKnownPosition();
|
||||||
|
if (l != null)
|
||||||
|
mViewHolder.centerMapOn(l.getLatitude(), l.getLongitude());
|
||||||
|
|
||||||
|
setContentView(mViewHolder.getRootView());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* May return last known GPS position or null. Used to center the map.
|
||||||
|
* @return last known GPS position or null
|
||||||
|
*/
|
||||||
|
private Location getLastKnownPosition() {
|
||||||
|
// Check if user granted location permission
|
||||||
|
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
// User didn't grant permission. Ask it.
|
||||||
|
requestPermissions(new String[] {Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSION_REQUEST_CODE);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
LocationManager locationManager = (LocationManager)
|
||||||
|
getSystemService(Context.LOCATION_SERVICE);
|
||||||
|
// Try to use last available location
|
||||||
|
return locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ViewHolder implements View.OnClickListener {
|
||||||
|
private final ActivityMapPickerBinding binding;
|
||||||
|
private ViewEventListener listener;
|
||||||
|
|
||||||
|
private final MapView map;
|
||||||
|
private boolean coordsEditMode = false;
|
||||||
|
|
||||||
|
public ViewHolder(LayoutInflater inflater) {
|
||||||
|
this.binding = ActivityMapPickerBinding.inflate(inflater);
|
||||||
|
|
||||||
|
// Show confirm button on lat/lng edit
|
||||||
|
View.OnFocusChangeListener latlonFocusListener = new View.OnFocusChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onFocusChange(View view, boolean focused) {
|
||||||
|
if (!focused)
|
||||||
|
return;
|
||||||
|
|
||||||
|
(ViewHolder.this).coordsEditMode(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.binding.latEt.setOnFocusChangeListener(latlonFocusListener);
|
||||||
|
this.binding.lonEt.setOnFocusChangeListener(latlonFocusListener);
|
||||||
|
|
||||||
|
// Setup map
|
||||||
|
this.map = this.binding.map;
|
||||||
|
this.map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER);
|
||||||
|
this.map.setMultiTouchControls(true);
|
||||||
|
MapUtils.setTheme(this.map);
|
||||||
|
this.map.addMapListener(new MapListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onScroll(ScrollEvent event) {
|
||||||
|
// Disable edit mode
|
||||||
|
if ((ViewHolder.this).coordsEditMode)
|
||||||
|
(ViewHolder.this).coordsEditMode(false);
|
||||||
|
// Write coords on edittext
|
||||||
|
IGeoPoint igp = (ViewHolder.this).map.getMapCenter();
|
||||||
|
(ViewHolder.this).binding.latEt.setText(String.format(Locale.ENGLISH, "%.06f", igp.getLatitude()));
|
||||||
|
(ViewHolder.this).binding.lonEt.setText(String.format(Locale.ENGLISH, "%.06f", igp.getLongitude()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onZoom(ZoomEvent event) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
IMapController mapController = binding.map.getController();
|
||||||
|
mapController.setZoom(7.0f);
|
||||||
|
|
||||||
|
// Setup onClick
|
||||||
|
this.binding.latlonConfirmBtn.setOnClickListener(this);
|
||||||
|
this.binding.backBt.setOnClickListener(this);
|
||||||
|
this.binding.okBt.setOnClickListener(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setViewEventListener(ViewEventListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void centerMapOn(Double lat, Double lon ) {
|
||||||
|
IMapController mapController = binding.map.getController();
|
||||||
|
mapController.setCenter(new GeoPoint(lat, lon));
|
||||||
|
}
|
||||||
|
|
||||||
|
public View getRootView() {
|
||||||
|
return this.binding.root;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (view == this.binding.latlonConfirmBtn) {
|
||||||
|
this.coordsEditMode(false);
|
||||||
|
Double lat;
|
||||||
|
Double lon;
|
||||||
|
try {
|
||||||
|
lat = Double.parseDouble(this.binding.latEt.getText().toString());
|
||||||
|
lon = Double.parseDouble(this.binding.lonEt.getText().toString());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
Log.e(TAG, "Unable to parse coordinates: " + e.getLocalizedMessage());
|
||||||
|
Toast.makeText(MapPickerActivity.this, R.string.coordinates_parse_error, Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Validate coordinates
|
||||||
|
if (lon <= -180 || lon >= 180 || lat <= -90 || lat >= 90) {
|
||||||
|
Toast.makeText(MapPickerActivity.this, R.string.coordinates_invalid_error, Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Move map to coordinates
|
||||||
|
this.centerMapOn(lat, lon);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view == this.binding.backBt)
|
||||||
|
listener.onExitButtonPressed();
|
||||||
|
|
||||||
|
if (view == this.binding.okBt)
|
||||||
|
listener.onConfirmButtonPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double[] getCurrentCoordinates() {
|
||||||
|
IGeoPoint igp = (ViewHolder.this).map.getMapCenter();
|
||||||
|
return new double[]{igp.getLatitude(), igp.getLongitude()};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enters/exits coordinates edit mode.
|
||||||
|
* On exit, removes focus from the coordinates ET and hides the button
|
||||||
|
*/
|
||||||
|
private void coordsEditMode(boolean active) {
|
||||||
|
this.coordsEditMode = active;
|
||||||
|
View btn = this.binding.latlonConfirmBtn;
|
||||||
|
if (active) {
|
||||||
|
btn.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
this.binding.latEt.clearFocus();
|
||||||
|
this.binding.lonEt.clearFocus();
|
||||||
|
btn.setVisibility(View.GONE);
|
||||||
|
// Hide soft keyboard
|
||||||
|
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
imm.hideSoftInputFromWindow(btn.getWindowToken(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected interface ViewEventListener {
|
||||||
|
public void onExitButtonPressed();
|
||||||
|
public void onConfirmButtonPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Nextcloud Maps Geofavorites for Android
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package it.danieleverducci.nextcloudmaps.activity.settings;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.Switch;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.ActionBar;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
|
import it.danieleverducci.nextcloudmaps.R;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.NextcloudMapsStyledActivity;
|
||||||
|
import it.danieleverducci.nextcloudmaps.utils.SettingsManager;
|
||||||
|
|
||||||
|
public class SettingsActivity extends NextcloudMapsStyledActivity {
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_settings);
|
||||||
|
|
||||||
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
|
ActionBar actionBar = getSupportActionBar();
|
||||||
|
if (actionBar != null) {
|
||||||
|
actionBar.setDisplayShowTitleEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
Switch useGoogleMapsSwitch = findViewById(R.id.use_google_maps_switch);
|
||||||
|
useGoogleMapsSwitch.setChecked(SettingsManager.isUseGoogleMaps(this));
|
||||||
|
useGoogleMapsSwitch.setOnCheckedChangeListener((buttonView, isChecked) ->
|
||||||
|
SettingsManager.setUseGoogleMaps(SettingsActivity.this, isChecked)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onSupportNavigateUp() {
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ import android.content.Context;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.nextcloud.android.sso.api.NextcloudAPI;
|
import com.nextcloud.android.sso.api.NextcloudAPI;
|
||||||
@@ -35,47 +36,27 @@ import com.nextcloud.android.sso.model.SingleSignOnAccount;
|
|||||||
import retrofit2.NextcloudRetrofitApiBuilder;
|
import retrofit2.NextcloudRetrofitApiBuilder;
|
||||||
|
|
||||||
public class ApiProvider {
|
public class ApiProvider {
|
||||||
private final String TAG = ApiProvider.class.getCanonicalName();
|
private static final String TAG = ApiProvider.class.getCanonicalName();
|
||||||
|
|
||||||
@NonNull
|
|
||||||
protected Context context;
|
|
||||||
protected static API mApi;
|
protected static API mApi;
|
||||||
|
|
||||||
protected static String ssoAccountName;
|
@Nullable
|
||||||
|
public static API getAPI(Context context) {
|
||||||
|
if (mApi == null) {
|
||||||
|
try {
|
||||||
|
SingleSignOnAccount ssoAccount = SingleAccountHelper.getCurrentSingleSignOnAccount(context);
|
||||||
|
NextcloudAPI nextcloudAPI = new NextcloudAPI(context, ssoAccount, new GsonBuilder().create());
|
||||||
|
|
||||||
public ApiProvider(Context context) {
|
mApi = new NextcloudRetrofitApiBuilder(nextcloudAPI, API.mApiEndpoint).create(API.class);
|
||||||
this.context = context;
|
} catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
|
||||||
initSsoApi(new NextcloudAPI.ApiConnectedListener() {
|
Log.d(TAG, "setAccout() called with: ex = [" + e + "]");
|
||||||
@Override
|
|
||||||
public void onConnected() {
|
|
||||||
Log.d(TAG, "Connected to Nextcloud instance");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Exception ex) {
|
|
||||||
Log.d(TAG, "Unable to connect to Nextcloud instance: " + ex.toString());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initSsoApi(final NextcloudAPI.ApiConnectedListener callback) {
|
|
||||||
try {
|
|
||||||
SingleSignOnAccount ssoAccount = SingleAccountHelper.getCurrentSingleSignOnAccount(context);
|
|
||||||
NextcloudAPI nextcloudAPI = new NextcloudAPI(context, ssoAccount, new GsonBuilder().create(), callback);
|
|
||||||
|
|
||||||
ssoAccountName = ssoAccount.name;
|
|
||||||
mApi = new NextcloudRetrofitApiBuilder(nextcloudAPI, API.mApiEndpoint).create(API.class);
|
|
||||||
} catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
|
|
||||||
Log.d(TAG, "setAccout() called with: ex = [" + e + "]");
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static API getAPI() {
|
|
||||||
return mApi;
|
return mApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getAccountName() {
|
public static void logout() {
|
||||||
return ssoAccountName;
|
mApi = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
package it.danieleverducci.nextcloudmaps.fragments;
|
||||||
|
|
||||||
|
import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.SORT_BY_CATEGORY;
|
||||||
|
import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.SORT_BY_CREATED;
|
||||||
|
import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.SORT_BY_DISTANCE;
|
||||||
|
import static it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter.SORT_BY_TITLE;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.widget.AppCompatImageView;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
import androidx.lifecycle.Observer;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import it.danieleverducci.nextcloudmaps.R;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.main.MainActivity;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.main.SortingOrderDialogFragment;
|
||||||
|
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||||
|
import it.danieleverducci.nextcloudmaps.utils.GeofavoritesFilter;
|
||||||
|
import it.danieleverducci.nextcloudmaps.utils.SettingsManager;
|
||||||
|
|
||||||
|
public class GeofavoriteListFragment extends GeofavoritesFragment implements SortingOrderDialogFragment.OnSortingOrderListener {
|
||||||
|
|
||||||
|
private SwipeRefreshLayout swipeRefresh;
|
||||||
|
private GeofavoriteAdapter geofavoriteAdapter;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
View v = inflater.inflate(R.layout.fragment_geofavorite_list, container, false);
|
||||||
|
|
||||||
|
// Setup list
|
||||||
|
int sortRule = SettingsManager.getGeofavoriteListSortBy(requireContext());
|
||||||
|
|
||||||
|
RecyclerView recyclerView = v.findViewById(R.id.recycler_view);
|
||||||
|
LinearLayoutManager layoutManager = new LinearLayoutManager(requireContext());
|
||||||
|
recyclerView.setLayoutManager(layoutManager);
|
||||||
|
|
||||||
|
GeofavoriteAdapter.ItemClickListener rvItemClickListener = new GeofavoriteAdapter.ItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(Geofavorite item) {
|
||||||
|
openGeofavorite(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemShareClick(Geofavorite item) {
|
||||||
|
shareGeofavorite(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemNavClick(Geofavorite item) {
|
||||||
|
navigateToGeofavorite(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemDeleteClick(Geofavorite item) {
|
||||||
|
deleteGeofavorite(item);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
geofavoriteAdapter = new GeofavoriteAdapter(requireContext(), rvItemClickListener);
|
||||||
|
recyclerView.setAdapter(geofavoriteAdapter);
|
||||||
|
geofavoriteAdapter.setSortRule(sortRule);
|
||||||
|
|
||||||
|
// Register for data source events
|
||||||
|
mGeofavoritesFragmentViewModel.getIsUpdating().observe(getViewLifecycleOwner(), new Observer<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(@Nullable Boolean changed) {
|
||||||
|
if(Boolean.TRUE.equals(changed)){
|
||||||
|
swipeRefresh.setRefreshing(true);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
swipeRefresh.setRefreshing(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Setup view listeners
|
||||||
|
swipeRefresh = v.findViewById(R.id.swipe_refresh);
|
||||||
|
swipeRefresh.setOnRefreshListener(() ->
|
||||||
|
mGeofavoritesFragmentViewModel.updateGeofavorites());
|
||||||
|
|
||||||
|
AppCompatImageView sortButton = v.findViewById(R.id.sort_mode);
|
||||||
|
sortButton.setOnClickListener(view -> openSortingOrderDialogFragment(geofavoriteAdapter.getSortRule()));
|
||||||
|
|
||||||
|
View showMapButton = v.findViewById(R.id.view_mode_map);
|
||||||
|
showMapButton.setOnClickListener(View -> ((MainActivity)requireActivity()).showMap());
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
|
// Set icons
|
||||||
|
int sortRule = SettingsManager.getGeofavoriteListSortBy(requireContext());
|
||||||
|
updateSortingIcon(sortRule);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDatasetChange(List<Geofavorite> items) {
|
||||||
|
// Called when the items are loaded or a filtering happens
|
||||||
|
geofavoriteAdapter.setGeofavoriteList(items);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSortingOrderChosen(int sortSelection) {
|
||||||
|
geofavoriteAdapter.setSortRule(sortSelection);
|
||||||
|
updateSortingIcon(sortSelection);
|
||||||
|
|
||||||
|
SettingsManager.setGeofavoriteListSortBy(requireContext(), sortSelection);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openSortingOrderDialogFragment(int sortOrder) {
|
||||||
|
FragmentTransaction fragmentTransaction = requireActivity().getSupportFragmentManager().beginTransaction();
|
||||||
|
fragmentTransaction.addToBackStack(null);
|
||||||
|
|
||||||
|
SortingOrderDialogFragment sodf = SortingOrderDialogFragment.newInstance(sortOrder);
|
||||||
|
sodf.setOnSortingOrderListener(this);
|
||||||
|
sodf.show(fragmentTransaction, SortingOrderDialogFragment.SORTING_ORDER_FRAGMENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSortingIcon(int sortSelection) {
|
||||||
|
AppCompatImageView sortButton = requireView().findViewById(R.id.sort_mode);
|
||||||
|
switch (sortSelection) {
|
||||||
|
case SORT_BY_TITLE:
|
||||||
|
sortButton.setImageResource(R.drawable.ic_alphabetical_asc);
|
||||||
|
break;
|
||||||
|
case SORT_BY_CREATED:
|
||||||
|
sortButton.setImageResource(R.drawable.ic_modification_asc);
|
||||||
|
break;
|
||||||
|
case SORT_BY_CATEGORY:
|
||||||
|
sortButton.setImageResource(R.drawable.ic_category_asc);
|
||||||
|
break;
|
||||||
|
case SORT_BY_DISTANCE:
|
||||||
|
sortButton.setImageResource(R.drawable.ic_distance_asc);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,240 @@
|
|||||||
|
package it.danieleverducci.nextcloudmaps.fragments;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.content.res.AppCompatResources;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
|
import androidx.core.graphics.drawable.DrawableCompat;
|
||||||
|
import androidx.lifecycle.Observer;
|
||||||
|
|
||||||
|
import org.osmdroid.api.IMapController;
|
||||||
|
import org.osmdroid.events.MapEventsReceiver;
|
||||||
|
import org.osmdroid.util.GeoPoint;
|
||||||
|
import org.osmdroid.views.CustomZoomButtonsController;
|
||||||
|
import org.osmdroid.views.MapView;
|
||||||
|
import org.osmdroid.views.overlay.MapEventsOverlay;
|
||||||
|
import org.osmdroid.views.overlay.Marker;
|
||||||
|
import org.osmdroid.views.overlay.Overlay;
|
||||||
|
import org.osmdroid.views.overlay.infowindow.InfoWindow;
|
||||||
|
import org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider;
|
||||||
|
import org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import it.danieleverducci.nextcloudmaps.R;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.detail.GeofavoriteDetailActivity;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.main.MainActivity;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.mappicker.MapPickerActivity;
|
||||||
|
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||||
|
import it.danieleverducci.nextcloudmaps.utils.GeoUriParser;
|
||||||
|
import it.danieleverducci.nextcloudmaps.utils.MapUtils;
|
||||||
|
import it.danieleverducci.nextcloudmaps.utils.SettingsManager;
|
||||||
|
import it.danieleverducci.nextcloudmaps.views.GeofavMarkerInfoWindow;
|
||||||
|
|
||||||
|
public class GeofavoriteMapFragment extends GeofavoritesFragment implements MainActivity.OnGpsPermissionGrantedListener {
|
||||||
|
|
||||||
|
private MapView map;
|
||||||
|
private MyLocationNewOverlay mLocationOverlay;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
MapUtils.configOsmdroid(requireContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
View v = inflater.inflate(R.layout.fragment_geofavorite_map, container, false);
|
||||||
|
|
||||||
|
// Register listeners
|
||||||
|
v.findViewById(R.id.center_position).setOnClickListener((cpv) -> moveToUserPosition());
|
||||||
|
|
||||||
|
// Setup map
|
||||||
|
map = v.findViewById(R.id.map);
|
||||||
|
map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER);
|
||||||
|
map.setMultiTouchControls(true);
|
||||||
|
MapUtils.setTheme(map);
|
||||||
|
MapEventsOverlay meo = new MapEventsOverlay(new MapEventsReceiver() {
|
||||||
|
@Override
|
||||||
|
public boolean singleTapConfirmedHelper(GeoPoint p) {
|
||||||
|
InfoWindow.closeAllInfoWindowsOn(map);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean longPressHelper(GeoPoint p) {
|
||||||
|
// Create new geofavorite (go to geofav creation activity)
|
||||||
|
Uri geoUri = GeoUriParser.createGeoUri(p.getLatitude(), p.getLongitude(), null);
|
||||||
|
Intent i = new Intent(requireActivity(), GeofavoriteDetailActivity.class);
|
||||||
|
i.setData(geoUri);
|
||||||
|
startActivity(i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
map.getOverlays().add(0, meo);
|
||||||
|
showUserPosition();
|
||||||
|
|
||||||
|
// Setup view listeners
|
||||||
|
View showListButton = v.findViewById(R.id.view_mode_list);
|
||||||
|
showListButton.setOnClickListener(View -> ((MainActivity)requireActivity()).showList());
|
||||||
|
|
||||||
|
View loadingWall = v.findViewById(R.id.loading_wall);
|
||||||
|
|
||||||
|
// Register for data source events
|
||||||
|
mGeofavoritesFragmentViewModel.getIsUpdating().observe(getViewLifecycleOwner(), new Observer<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(@Nullable Boolean changed) {
|
||||||
|
if(Boolean.TRUE.equals(changed)){
|
||||||
|
loadingWall.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
loadingWall.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
|
||||||
|
((MainActivity)requireActivity()).addOnGpsPermissionGrantedListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDatasetChange(List<Geofavorite> items) {
|
||||||
|
clearAllMarkers();
|
||||||
|
for(Geofavorite gf : items)
|
||||||
|
addMarker(gf);
|
||||||
|
map.invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
|
||||||
|
((MainActivity)requireActivity()).removeOnGpsPermissionGrantedListener(this);
|
||||||
|
SettingsManager.setLastMapPosition(
|
||||||
|
requireContext(),
|
||||||
|
map.getMapCenter().getLatitude(),
|
||||||
|
map.getMapCenter().getLongitude(),
|
||||||
|
map.getZoomLevelDouble()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGpsPermissionGranted() {
|
||||||
|
showUserPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showUserPosition() {
|
||||||
|
// Center map on last position
|
||||||
|
double[] pos = SettingsManager.getLastMapPosition(requireContext());
|
||||||
|
IMapController mapController = map.getController();
|
||||||
|
mapController.setCenter(new GeoPoint(pos[0], pos[1]));
|
||||||
|
mapController.setZoom(pos[2]);
|
||||||
|
|
||||||
|
// Check if user granted location permission
|
||||||
|
if (ActivityCompat.checkSelfPermission(requireContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
|
||||||
|
ActivityCompat.checkSelfPermission(requireContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED
|
||||||
|
) {
|
||||||
|
// User didn't grant permission. Ask it.
|
||||||
|
((MainActivity)requireActivity()).requestGpsPermissions();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display user position on screen
|
||||||
|
mLocationOverlay = new MyLocationNewOverlay(new GpsMyLocationProvider(requireContext()), map);
|
||||||
|
Bitmap personIcon = ((BitmapDrawable)AppCompatResources.getDrawable(requireContext(), R.mipmap.ic_person)).getBitmap();
|
||||||
|
mLocationOverlay.setPersonIcon(personIcon);
|
||||||
|
mLocationOverlay.setDirectionIcon(personIcon);
|
||||||
|
mLocationOverlay.setPersonAnchor(.5f, .5f);
|
||||||
|
mLocationOverlay.setDirectionAnchor(.5f, .5f);
|
||||||
|
// On first gps fix, show "center to my position" icon
|
||||||
|
mLocationOverlay.runOnFirstFix(() -> {
|
||||||
|
if(getActivity() != null) {
|
||||||
|
getActivity().runOnUiThread(() -> {
|
||||||
|
getView().findViewById(R.id.center_position).setVisibility(View.VISIBLE);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mLocationOverlay.enableMyLocation();
|
||||||
|
map.getOverlays().add(mLocationOverlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
void moveToUserPosition() {
|
||||||
|
if (mLocationOverlay != null)
|
||||||
|
map.getController().animateTo(mLocationOverlay.getMyLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addMarker(Geofavorite geofavorite){
|
||||||
|
GeoPoint pos = new GeoPoint(geofavorite.getLat(), geofavorite.getLng());
|
||||||
|
|
||||||
|
// Set icon and color
|
||||||
|
Drawable icon = DrawableCompat.wrap(AppCompatResources.getDrawable(requireContext(), R.drawable.ic_map_pin));
|
||||||
|
DrawableCompat.setTint(icon, geofavorite.categoryColor() == 0 ? requireContext().getColor(R.color.defaultBrand) : geofavorite.categoryColor());
|
||||||
|
|
||||||
|
// Set infowindow (popup opened on marker click) and its listeners
|
||||||
|
GeofavMarkerInfoWindow iw = new GeofavMarkerInfoWindow(map, geofavorite);
|
||||||
|
iw.setOnGeofavMarkerInfoWindowClickListener(new GeofavMarkerInfoWindow.OnGeofavMarkerInfoWindowClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onGeofavMarkerInfoWindowEditClick() {
|
||||||
|
openGeofavorite(geofavorite);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onGeofavMarkerInfoWindowShareClick() {
|
||||||
|
shareGeofavorite(geofavorite);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onGeofavMarkerInfoWindowNavClick() {
|
||||||
|
navigateToGeofavorite(geofavorite);
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onGeofavMarkerInfoWindowDeleteClick() {
|
||||||
|
deleteGeofavorite(geofavorite);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Set marker
|
||||||
|
Marker m = new Marker(map);
|
||||||
|
m.setPosition(pos);
|
||||||
|
m.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
|
||||||
|
m.setIcon(icon);
|
||||||
|
m.setTitle(geofavorite.getName());
|
||||||
|
m.setSnippet(geofavorite.getComment());
|
||||||
|
m.setSubDescription(geofavorite.getCategory());
|
||||||
|
m.setInfoWindow(iw);
|
||||||
|
map.getOverlays().add(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearAllMarkers() {
|
||||||
|
// Close any open infowindow before removing related marker
|
||||||
|
InfoWindow.closeAllInfoWindowsOn(map);
|
||||||
|
// Remove all markers, leaving the other overlays (user position and tap listener ones)
|
||||||
|
for(Overlay o : map.getOverlays()) {
|
||||||
|
if (o instanceof Marker) {
|
||||||
|
map.getOverlays().remove(o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,270 @@
|
|||||||
|
package it.danieleverducci.nextcloudmaps.fragments;
|
||||||
|
|
||||||
|
import static android.view.View.GONE;
|
||||||
|
import static android.view.View.VISIBLE;
|
||||||
|
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.appcompat.widget.AppCompatImageButton;
|
||||||
|
import androidx.appcompat.widget.AppCompatImageView;
|
||||||
|
import androidx.appcompat.widget.SearchView;
|
||||||
|
import androidx.core.graphics.drawable.DrawableCompat;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.lifecycle.Observer;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
import com.nextcloud.android.sso.helper.SingleAccountHelper;
|
||||||
|
import com.nextcloud.android.sso.model.SingleSignOnAccount;
|
||||||
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import it.danieleverducci.nextcloudmaps.R;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.detail.CategoriesAdapter;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.detail.GeofavoriteDetailActivity;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.main.GeofavoritesFragmentViewModel;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.main.MainActivity;
|
||||||
|
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||||
|
import it.danieleverducci.nextcloudmaps.utils.GeofavoritesFilter;
|
||||||
|
import it.danieleverducci.nextcloudmaps.utils.IntentGenerator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Separates the specific list/map implementation details providing a standard interface
|
||||||
|
* to communicate with the activity
|
||||||
|
*/
|
||||||
|
public abstract class GeofavoritesFragment extends Fragment {
|
||||||
|
private final String TAG = "GeofavoritesFragment";
|
||||||
|
|
||||||
|
protected GeofavoritesFragmentViewModel mGeofavoritesFragmentViewModel;
|
||||||
|
private View toolbar;
|
||||||
|
private View homeToolbar;
|
||||||
|
private SearchView searchView;
|
||||||
|
private ImageButton filterButton;
|
||||||
|
private List<Geofavorite> geofavorites = new ArrayList<>();
|
||||||
|
private HashSet<String> categories = new HashSet<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
// Load data
|
||||||
|
mGeofavoritesFragmentViewModel = new ViewModelProvider(this).get(GeofavoritesFragmentViewModel.class);
|
||||||
|
mGeofavoritesFragmentViewModel.init(requireContext());
|
||||||
|
|
||||||
|
mGeofavoritesFragmentViewModel.getOnFinished().observe(this, new Observer<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(@Nullable Boolean success) {
|
||||||
|
if(success == null || !success){
|
||||||
|
Toast.makeText(requireContext(), R.string.list_geofavorite_connection_error, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
|
// Set views
|
||||||
|
AppCompatImageButton menuButton = view.findViewById(R.id.menu_button);
|
||||||
|
menuButton.setOnClickListener(v -> ((MainActivity)requireActivity()).openDrawer());
|
||||||
|
|
||||||
|
View userBadgeContainer = view.findViewById(R.id.user_badge_container);
|
||||||
|
userBadgeContainer.setOnClickListener(v -> showSwitchAccountDialog());
|
||||||
|
|
||||||
|
// Setup toolbar/searchbar
|
||||||
|
toolbar = view.findViewById(R.id.toolbar);
|
||||||
|
homeToolbar = view.findViewById(R.id.home_toolbar);
|
||||||
|
filterButton = view.findViewById(R.id.search_filter);
|
||||||
|
filterButton.setOnClickListener(v -> showCategoryFilterDialog());
|
||||||
|
|
||||||
|
searchView = view.findViewById(R.id.search_view);
|
||||||
|
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onQueryTextSubmit(String query) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onQueryTextChange(String query) {
|
||||||
|
onDatasetChange(
|
||||||
|
(new GeofavoritesFilter(geofavorites)).byText(query)
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mGeofavoritesFragmentViewModel.getGeofavorites().observe(getViewLifecycleOwner(), new Observer<List<Geofavorite>>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(List<Geofavorite> geofavorites) {
|
||||||
|
GeofavoritesFragment.this.geofavorites = geofavorites;
|
||||||
|
onDatasetChange(geofavorites);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mGeofavoritesFragmentViewModel.getCategories().observe(getViewLifecycleOwner(), new Observer<HashSet<String>>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(HashSet<String> categories) {
|
||||||
|
GeofavoritesFragment.this.categories = categories;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
searchView.setOnCloseListener(() -> {
|
||||||
|
if (toolbar.getVisibility() == VISIBLE && TextUtils.isEmpty(searchView.getQuery())) {
|
||||||
|
updateToolbars(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
homeToolbar.setOnClickListener(v -> updateToolbars(false));
|
||||||
|
// Set user badge (async)
|
||||||
|
Handler h = new Handler();
|
||||||
|
h.post(() -> {
|
||||||
|
try {
|
||||||
|
SingleSignOnAccount ssoAccount = SingleAccountHelper.getCurrentSingleSignOnAccount(requireContext());
|
||||||
|
String userBadgePath = ssoAccount.url + "/index.php/avatar/" + ssoAccount.userId + "/64";
|
||||||
|
if (getActivity() != null)
|
||||||
|
getActivity().runOnUiThread(
|
||||||
|
() -> Picasso.get().load(userBadgePath).into((AppCompatImageView)userBadgeContainer.findViewById(R.id.user_badge))
|
||||||
|
);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Unable to load user image: " + e.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
|
||||||
|
// Reset filter and update data
|
||||||
|
filterButton.setImageResource(R.drawable.ic_filter_off);
|
||||||
|
mGeofavoritesFragmentViewModel.updateGeofavorites();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
abstract public void onDatasetChange(List<Geofavorite> items);
|
||||||
|
|
||||||
|
|
||||||
|
protected void openGeofavorite(Geofavorite item) {
|
||||||
|
showGeofavoriteDetailActivity(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void shareGeofavorite(Geofavorite item) {
|
||||||
|
startActivity(Intent.createChooser(IntentGenerator.newShareIntent(requireActivity(), item), getString(R.string.share_via)));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void navigateToGeofavorite(Geofavorite item) {
|
||||||
|
startActivity(IntentGenerator.newGeoUriIntent(requireActivity(), item));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void deleteGeofavorite(Geofavorite item) {
|
||||||
|
showGeofavoriteDeteleDialog(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void showGeofavoriteDetailActivity(Geofavorite item) {
|
||||||
|
Intent i = new Intent(requireContext(), GeofavoriteDetailActivity.class);
|
||||||
|
i.putExtra(GeofavoriteDetailActivity.ARG_GEOFAVORITE, item.getId());
|
||||||
|
startActivity(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showGeofavoriteDeteleDialog(Geofavorite item) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(requireContext());
|
||||||
|
builder.setMessage(getString(R.string.dialog_delete_message).replace("{name}", item.getName() != null ? item.getName() : ""))
|
||||||
|
.setTitle(R.string.dialog_delete_title)
|
||||||
|
.setPositiveButton(R.string.dialog_delete_delete, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
mGeofavoritesFragmentViewModel.deleteGeofavorite(item);
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_delete_cancel, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AlertDialog ad = builder.create();
|
||||||
|
ad.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showSwitchAccountDialog() {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(requireContext());
|
||||||
|
builder.setMessage(R.string.dialog_logout_message)
|
||||||
|
.setTitle(R.string.dialog_logout_title)
|
||||||
|
.setPositiveButton(android.R.string.yes, (dialog, id) -> {
|
||||||
|
if (getActivity() != null)
|
||||||
|
((MainActivity) getActivity()).switch_account();
|
||||||
|
dialog.dismiss();
|
||||||
|
})
|
||||||
|
.setNegativeButton(android.R.string.no, (dialog, id) -> dialog.dismiss());
|
||||||
|
AlertDialog ad = builder.create();
|
||||||
|
ad.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showCategoryFilterDialog() {
|
||||||
|
if (categories.isEmpty()) {
|
||||||
|
Toast.makeText(requireContext(), R.string.filtering_unavailable, Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(requireContext());
|
||||||
|
builder.setTitle(R.string.filtering_dialog_title);
|
||||||
|
CategoriesAdapter ca = new CategoriesAdapter(requireContext());
|
||||||
|
ca.setCategoriesList(categories);
|
||||||
|
builder.setAdapter(ca, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
// Set filter button enabled icon and color
|
||||||
|
String categoryName = ca.getItem(which);
|
||||||
|
filterButton.setImageResource(R.drawable.ic_filter);
|
||||||
|
Drawable d = filterButton.getDrawable();
|
||||||
|
DrawableCompat.setTint(
|
||||||
|
d,
|
||||||
|
Geofavorite.categoryColorFromName(categoryName) == 0
|
||||||
|
? requireContext().getColor(R.color.defaultBrand)
|
||||||
|
: Geofavorite.categoryColorFromName(categoryName)
|
||||||
|
);
|
||||||
|
filterByCategory(categoryName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.setPositiveButton(R.string.filtering_dialog_cancel, (dialog, id) -> {
|
||||||
|
dialog.dismiss();
|
||||||
|
filterButton.setImageResource(R.drawable.ic_filter_off);
|
||||||
|
filterByCategory(null);
|
||||||
|
});
|
||||||
|
AlertDialog dialog = builder.create();
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateToolbars(boolean disableSearch) {
|
||||||
|
homeToolbar.setVisibility(disableSearch ? VISIBLE : GONE);
|
||||||
|
toolbar.setVisibility(disableSearch ? GONE : VISIBLE);
|
||||||
|
if (disableSearch) {
|
||||||
|
searchView.setQuery(null, true);
|
||||||
|
}
|
||||||
|
searchView.setIconified(disableSearch);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void filterByCategory(String category) {
|
||||||
|
onDatasetChange(
|
||||||
|
(new GeofavoritesFilter(geofavorites)).byCategory(category)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -20,14 +20,12 @@
|
|||||||
|
|
||||||
package it.danieleverducci.nextcloudmaps.model;
|
package it.danieleverducci.nextcloudmaps.model;
|
||||||
|
|
||||||
|
import android.graphics.Color;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.widget.TextView;
|
import android.widget.Filter;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.databinding.BaseObservable;
|
|
||||||
import androidx.databinding.Bindable;
|
|
||||||
import androidx.databinding.BindingAdapter;
|
|
||||||
|
|
||||||
import com.google.gson.annotations.Expose;
|
import com.google.gson.annotations.Expose;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
@@ -37,10 +35,16 @@ import org.threeten.bp.LocalDate;
|
|||||||
import org.threeten.bp.ZoneId;
|
import org.threeten.bp.ZoneId;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.List;
|
||||||
|
|
||||||
|
import it.danieleverducci.nextcloudmaps.utils.GeoUriParser;
|
||||||
|
|
||||||
public class Geofavorite implements Serializable {
|
public class Geofavorite implements Serializable {
|
||||||
|
public static final String DEFAULT_CATEGORY = "Personal";
|
||||||
|
private static final double EARTH_RADIUS = 6371; // https://en.wikipedia.org/wiki/Earth_radius
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSON Definition:
|
* JSON Definition:
|
||||||
* {
|
* {
|
||||||
@@ -150,18 +154,63 @@ public class Geofavorite implements Serializable {
|
|||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Comparator<Geofavorite> ByTitleAZ = (note, t1) -> note.name.compareTo(t1.name);
|
/**
|
||||||
public static Comparator<Geofavorite> ByLastCreated = (note, t1) -> t1.id - note.id;
|
* Comparators for list order
|
||||||
|
*/
|
||||||
|
public static Comparator<Geofavorite> ByTitleAZ = (gf0, gf1) -> gf0.name.compareTo(gf1.name);
|
||||||
|
public static Comparator<Geofavorite> ByLastCreated = (gf0, gf1) -> (int) (gf1.dateCreated - gf0.dateCreated);
|
||||||
|
public static Comparator<Geofavorite> ByCategory = (gf0, gf1) -> (gf0.category + gf0.name).compareTo(gf1.category + gf1.name);
|
||||||
|
public static Comparator<Geofavorite> ByDistance = (gf0, gf1) -> 0; // (int) ((gf1.getDistanceFrom(userPosition) - gf0.getDistanceFrom(userPosition)) * 1000);
|
||||||
|
|
||||||
public String getCoordinatesString() {
|
public String getCoordinatesString() {
|
||||||
return this.lat + " N, " + this.lng + " E";
|
return this.lat + " N, " + this.lng + " E";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Uri getGeoUri() {
|
public Uri getGeoUri() {
|
||||||
return Uri.parse("geo:" + this.lat + "," + this.lng + "(" + this.name + ")");
|
return GeoUriParser.createGeoUri(this.lat, this.lng, this.name);
|
||||||
|
}
|
||||||
|
public Uri getGmapsUri() {
|
||||||
|
return GeoUriParser.createGmapsUri(this.lat, this.lng);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean valid() {
|
public boolean valid() {
|
||||||
return getLat() != 0 && getLng() != 0 && getName() != null && getName().length() > 0;
|
return
|
||||||
|
getLat() != 0 && getLng() != 0 &&
|
||||||
|
getName() != null && getName().length() > 0 &&
|
||||||
|
getCategory() != null && getCategory().length() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the distance between the current Geofavorite and the provided one, in kilometers.
|
||||||
|
* @param other Geovavorite
|
||||||
|
* @return the distance in kilometers
|
||||||
|
*/
|
||||||
|
public double getDistanceFrom(Geofavorite other) {
|
||||||
|
double latDistance = (other.lat-lat) * Math.PI / 180;
|
||||||
|
double lonDistance = (other.lng-lng) * Math.PI / 180;
|
||||||
|
double a =
|
||||||
|
Math.sin(latDistance / 2) * Math.sin(latDistance / 2) +
|
||||||
|
Math.cos(lat * Math.PI / 180) * Math.cos(other.lat * Math.PI / 180) *
|
||||||
|
Math.sin(lonDistance / 2) * Math.sin(lonDistance / 2);
|
||||||
|
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
||||||
|
return EARTH_RADIUS * c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Based on Nextcloud Maps's getLetterColor util.
|
||||||
|
* Assigns a color to a category based on its two first letters.
|
||||||
|
*
|
||||||
|
* @see "https://github.com/nextcloud/maps/blob/master/src/utils.js"
|
||||||
|
* @return the generated color or null for the default category
|
||||||
|
*/
|
||||||
|
public int categoryColor() {
|
||||||
|
return categoryColorFromName(this.category);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String categoryLetter() {
|
||||||
|
if (category == null || category.length() == 0 || category.equals(DEFAULT_CATEGORY))
|
||||||
|
return "\u2022";
|
||||||
|
return category.substring(0,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@@ -169,4 +218,28 @@ public class Geofavorite implements Serializable {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "[" + getName() + " (" + getLat() + "," + getLng() + ")]";
|
return "[" + getName() + " (" + getLat() + "," + getLng() + ")]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Based on Nextcloud Maps's getLetterColor util.
|
||||||
|
* Assigns a color to a category based on its two first letters.
|
||||||
|
*
|
||||||
|
* @see "https://github.com/nextcloud/maps/blob/master/src/utils.js"
|
||||||
|
* @return the generated color or null for the default category
|
||||||
|
*/
|
||||||
|
public static int categoryColorFromName(String category) {
|
||||||
|
// If category is default, return null: will be used Nextcloud's accent
|
||||||
|
if (category == null || category.equals(DEFAULT_CATEGORY) || category.length() == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
float letter1Index = category.toLowerCase().charAt(0);
|
||||||
|
float letter2Index = category.toLowerCase().charAt(1);
|
||||||
|
float letterCoef = ((letter1Index * letter2Index) % 100) / 100;
|
||||||
|
float h = letterCoef * 360;
|
||||||
|
float s = 75 + letterCoef * 10;
|
||||||
|
float l = 50 + letterCoef * 10;
|
||||||
|
return Color.HSVToColor( new float[]{ Math.round(h), Math.round(s), Math.round(l) });
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,176 @@
|
|||||||
|
package it.danieleverducci.nextcloudmaps.repository;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import it.danieleverducci.nextcloudmaps.api.ApiProvider;
|
||||||
|
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||||
|
import it.danieleverducci.nextcloudmaps.utils.SingleLiveEvent;
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Singleton pattern
|
||||||
|
*/
|
||||||
|
public class GeofavoriteRepository {
|
||||||
|
|
||||||
|
private static final String TAG = "GeofavoriteRepository";
|
||||||
|
private static GeofavoriteRepository instance;
|
||||||
|
private MutableLiveData<List<Geofavorite>> mGeofavorites;
|
||||||
|
private MutableLiveData<HashSet<String>> mCategories = new MutableLiveData<HashSet<String>>();
|
||||||
|
private MutableLiveData<Boolean> mIsUpdating = new MutableLiveData<>(false);
|
||||||
|
private SingleLiveEvent<Boolean> mOnFinished = new SingleLiveEvent<>();
|
||||||
|
|
||||||
|
private Context applicationContext;
|
||||||
|
|
||||||
|
public GeofavoriteRepository(Context applicationContext) {
|
||||||
|
this.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GeofavoriteRepository getInstance(Context applicationContext) {
|
||||||
|
if(instance == null){
|
||||||
|
instance = new GeofavoriteRepository(applicationContext);
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void resetInstance() {
|
||||||
|
instance = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<List<Geofavorite>> getGeofavorites(){
|
||||||
|
if (mGeofavorites == null) {
|
||||||
|
mGeofavorites = new MutableLiveData<>();
|
||||||
|
mGeofavorites.setValue(new ArrayList<>());
|
||||||
|
}
|
||||||
|
return mGeofavorites;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<HashSet<String>> getCategories() {
|
||||||
|
return mCategories;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<Boolean> isUpdating() {
|
||||||
|
return mIsUpdating;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SingleLiveEvent<Boolean> onFinished() {
|
||||||
|
return mOnFinished;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateGeofavorites() {
|
||||||
|
mIsUpdating.postValue(true);
|
||||||
|
// Obtain geofavorites
|
||||||
|
Call<List<Geofavorite>> call = ApiProvider.getAPI(this.applicationContext).getGeofavorites();
|
||||||
|
call.enqueue(new Callback<List<Geofavorite>>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<List<Geofavorite>> call, @NonNull Response<List<Geofavorite>> response) {
|
||||||
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
|
mGeofavorites.postValue(response.body());
|
||||||
|
updateCategories(response.body());
|
||||||
|
mIsUpdating.postValue(false);
|
||||||
|
mOnFinished.postValue(true);
|
||||||
|
} else {
|
||||||
|
onFailure(call, new Throwable("Dataset is empty"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<List<Geofavorite>> call, @NonNull Throwable t) {
|
||||||
|
mIsUpdating.postValue(false);
|
||||||
|
mOnFinished.postValue(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public Geofavorite getGeofavorite(int id) {
|
||||||
|
for (Geofavorite g : mGeofavorites.getValue()) {
|
||||||
|
if (g.getId() == id)
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveGeofavorite(Geofavorite geofav) {
|
||||||
|
mIsUpdating.postValue(true);
|
||||||
|
Call<Geofavorite> call;
|
||||||
|
if (geofav.getId() == 0) {
|
||||||
|
// New geofavorite
|
||||||
|
call = ApiProvider.getAPI(this.applicationContext).createGeofavorite(geofav);
|
||||||
|
} else {
|
||||||
|
// Update existing geofavorite
|
||||||
|
call = ApiProvider.getAPI(this.applicationContext).updateGeofavorite(geofav.getId(), geofav);
|
||||||
|
}
|
||||||
|
call.enqueue(new Callback<Geofavorite>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<Geofavorite> call, Response<Geofavorite> response) {
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
List<Geofavorite> geofavs = mGeofavorites.getValue();
|
||||||
|
if (geofav.getId() != 0) {
|
||||||
|
geofavs.remove(geofav);
|
||||||
|
}
|
||||||
|
geofavs.add(response.body());
|
||||||
|
mGeofavorites.postValue(geofavs);
|
||||||
|
mIsUpdating.postValue(false);
|
||||||
|
mOnFinished.postValue(true);
|
||||||
|
} else {
|
||||||
|
mIsUpdating.postValue(false);
|
||||||
|
mOnFinished.postValue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<Geofavorite> call, Throwable t) {
|
||||||
|
Log.e(TAG, t.getMessage());
|
||||||
|
mIsUpdating.postValue(false);
|
||||||
|
mOnFinished.postValue(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteGeofavorite(Geofavorite geofav) {
|
||||||
|
mIsUpdating.postValue(true);
|
||||||
|
// Delete Geofavorite
|
||||||
|
Call<Geofavorite> call = ApiProvider.getAPI(this.applicationContext).deleteGeofavorite(geofav.getId());
|
||||||
|
call.enqueue(new Callback<Geofavorite>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<Geofavorite> call, Response<Geofavorite> response) {
|
||||||
|
List<Geofavorite> geofavs = mGeofavorites.getValue();
|
||||||
|
if (geofavs.remove(geofav)) {
|
||||||
|
mGeofavorites.postValue(geofavs);
|
||||||
|
mIsUpdating.postValue(false);
|
||||||
|
mOnFinished.postValue(true);
|
||||||
|
} else {
|
||||||
|
// Should never happen
|
||||||
|
mIsUpdating.postValue(false);
|
||||||
|
mOnFinished.postValue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<Geofavorite> call, Throwable t) {
|
||||||
|
mIsUpdating.postValue(false);
|
||||||
|
mOnFinished.postValue(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCategories(List<Geofavorite> geofavs) {
|
||||||
|
HashSet<String> categories = new HashSet<>();
|
||||||
|
for (Geofavorite g : geofavs) {
|
||||||
|
String cat = g.getCategory();
|
||||||
|
if (cat != null)
|
||||||
|
categories.add(cat);
|
||||||
|
}
|
||||||
|
mCategories.postValue(categories);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
package it.danieleverducci.nextcloudmaps.utils;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||||
|
|
||||||
|
public class GeoUriParser {
|
||||||
|
private static final Pattern PATTERN_GEO = Pattern.compile("geo:(-?[\\d.]+),(-?[\\d.]+)");
|
||||||
|
// Try to match not only geoUri but also Google Maps Uri
|
||||||
|
private static final Pattern PATTERN_BROAD = Pattern.compile(
|
||||||
|
"(?:@|&query=|&ce\nter=|geo:|#map=\\d{1,2}\\/)(-?\\d{1,2}\\.\\d+)(?:,|%2C|\\/)(-?\\d{1,3}\\.\\d{1,10})"
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses an URI into latitude and longitude
|
||||||
|
* @param uri to parse
|
||||||
|
* @param strict if true, the uri must be a valid geo: uri, otherwise a broader check is applied to include other uris, like Google Maps ones
|
||||||
|
* @return the parsed coordinates in an array [lat,lon]
|
||||||
|
* @throws IllegalArgumentException if the url could not be parsed
|
||||||
|
*/
|
||||||
|
public static double[] parseUri(Uri uri, boolean strict) throws IllegalArgumentException {
|
||||||
|
if (uri == null)
|
||||||
|
throw new IllegalArgumentException("no uri");
|
||||||
|
|
||||||
|
// Try to extract coordinates in uri string with regexp
|
||||||
|
Pattern pattern = strict ? PATTERN_GEO : PATTERN_BROAD;
|
||||||
|
Matcher m = pattern.matcher(uri.toString());
|
||||||
|
if (!m.find() || m.groupCount() != 2)
|
||||||
|
throw new IllegalArgumentException("unable to parse uri: unable to find coordinates in uri");
|
||||||
|
|
||||||
|
// Obtain coordinates from regexp result
|
||||||
|
String sLat = m.group(1);
|
||||||
|
String sLon = m.group(2);
|
||||||
|
double[] coords = null;
|
||||||
|
try {
|
||||||
|
// Check coordinates are numeric
|
||||||
|
coords = new double[]{Double.parseDouble(sLat), Double.parseDouble(sLon)};
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new IllegalArgumentException("unable to parse uri: coordinates are not double");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check coordinates validity
|
||||||
|
String error = checkCoordsValidity(coords[0], coords[1]);
|
||||||
|
if (error != null)
|
||||||
|
throw new IllegalArgumentException(error);
|
||||||
|
|
||||||
|
return coords;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Uri createGeoUri(double lat, double lon, String name) {
|
||||||
|
String error = checkCoordsValidity(lat, lon);
|
||||||
|
if (error != null)
|
||||||
|
throw new IllegalArgumentException(error);
|
||||||
|
|
||||||
|
String uriStr = "geo:" + lat + "," + lon;
|
||||||
|
if (name != null)
|
||||||
|
uriStr += "(" + name + ")";
|
||||||
|
return Uri.parse(uriStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Uri createGmapsUri(double lat, double lon) {
|
||||||
|
String error = checkCoordsValidity(lat, lon);
|
||||||
|
if (error != null)
|
||||||
|
throw new IllegalArgumentException(error);
|
||||||
|
|
||||||
|
String uriStr = "https://www.google.com/maps/search/?api=1&query=" + lat + "," + lon;
|
||||||
|
return Uri.parse(uriStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks a latitude/longitude is valid
|
||||||
|
* @param lat latitude
|
||||||
|
* @param lon longitude
|
||||||
|
* @return null if valid, a string containing an error otherwise
|
||||||
|
*/
|
||||||
|
private static String checkCoordsValidity(double lat, double lon) {
|
||||||
|
// Check coords validity
|
||||||
|
if (lon <= -180 || lon >= 180 )
|
||||||
|
return "Invalid longitude: " + lon;
|
||||||
|
if (lat <= -90 || lat >= 90)
|
||||||
|
return "Invalid latitude: " + lat;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package it.danieleverducci.nextcloudmaps.utils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||||
|
|
||||||
|
public class GeofavoritesFilter {
|
||||||
|
List<Geofavorite> items;
|
||||||
|
public GeofavoritesFilter(List<Geofavorite> items) {
|
||||||
|
this.items = items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Geofavorite> byText(String text) {
|
||||||
|
List<Geofavorite> filteredGeofavorites = new ArrayList<>();
|
||||||
|
|
||||||
|
if (text.isEmpty()) {
|
||||||
|
return items;
|
||||||
|
} else {
|
||||||
|
for (Geofavorite geofavorite : items) {
|
||||||
|
String query = text.toLowerCase();
|
||||||
|
if (geofavorite.getName() != null && geofavorite.getName().toLowerCase().contains(query)) {
|
||||||
|
filteredGeofavorites.add(geofavorite);
|
||||||
|
} else if (geofavorite.getComment() != null && geofavorite.getComment().toLowerCase().contains(query)) {
|
||||||
|
filteredGeofavorites.add(geofavorite);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filteredGeofavorites;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Geofavorite> byCategory(String category) {
|
||||||
|
List<Geofavorite> filteredGeofavorites = new ArrayList<>();
|
||||||
|
|
||||||
|
if (category == null) {
|
||||||
|
return items;
|
||||||
|
} else {
|
||||||
|
for (Geofavorite geofavorite : items) {
|
||||||
|
if (geofavorite.getCategory().equals(category)) {
|
||||||
|
filteredGeofavorites.add(geofavorite);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filteredGeofavorites;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package it.danieleverducci.nextcloudmaps.utils;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import it.danieleverducci.nextcloudmaps.R;
|
import it.danieleverducci.nextcloudmaps.R;
|
||||||
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||||
@@ -12,6 +13,7 @@ public class IntentGenerator {
|
|||||||
i.setAction(Intent.ACTION_SEND);
|
i.setAction(Intent.ACTION_SEND);
|
||||||
i.setType("text/plain");
|
i.setType("text/plain");
|
||||||
String shareMessage = context.getString(R.string.share_message)
|
String shareMessage = context.getString(R.string.share_message)
|
||||||
|
.replace("{title}", item.getName() == null ? context.getString(R.string.share_message_default_title) : item.getName())
|
||||||
.replace("{lat}", ""+item.getLat())
|
.replace("{lat}", ""+item.getLat())
|
||||||
.replace("{lng}", ""+item.getLng());
|
.replace("{lng}", ""+item.getLng());
|
||||||
i.putExtra(Intent.EXTRA_TEXT, shareMessage );
|
i.putExtra(Intent.EXTRA_TEXT, shareMessage );
|
||||||
@@ -21,7 +23,10 @@ public class IntentGenerator {
|
|||||||
public static Intent newGeoUriIntent(Context context, Geofavorite item) {
|
public static Intent newGeoUriIntent(Context context, Geofavorite item) {
|
||||||
Intent i = new Intent();
|
Intent i = new Intent();
|
||||||
i.setAction(Intent.ACTION_VIEW);
|
i.setAction(Intent.ACTION_VIEW);
|
||||||
i.setData(item.getGeoUri());
|
i.setData(
|
||||||
|
SettingsManager.isUseGoogleMaps(context)
|
||||||
|
? item.getGmapsUri() : item.getGeoUri()
|
||||||
|
);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package it.danieleverducci.nextcloudmaps.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import org.osmdroid.config.IConfigurationProvider;
|
||||||
|
import org.osmdroid.views.MapView;
|
||||||
|
import org.osmdroid.views.overlay.TilesOverlay;
|
||||||
|
|
||||||
|
import it.danieleverducci.nextcloudmaps.BuildConfig;
|
||||||
|
|
||||||
|
public class MapUtils {
|
||||||
|
|
||||||
|
public static void configOsmdroid(Context context) {
|
||||||
|
IConfigurationProvider osmdroidConfig = org.osmdroid.config.Configuration.getInstance();
|
||||||
|
osmdroidConfig.load(context,
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(context));
|
||||||
|
osmdroidConfig.setUserAgentValue(BuildConfig.APPLICATION_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setTheme(MapView mapView) {
|
||||||
|
int currentNightMode = mapView.getContext().getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||||
|
switch (currentNightMode) {
|
||||||
|
case Configuration.UI_MODE_NIGHT_NO:
|
||||||
|
// Night mode is not active, we're using the light theme
|
||||||
|
mapView.getOverlayManager().getTilesOverlay().setColorFilter(null);
|
||||||
|
break;
|
||||||
|
case Configuration.UI_MODE_NIGHT_YES:
|
||||||
|
// Night mode is active, we're using dark theme
|
||||||
|
mapView.getOverlayManager().getTilesOverlay().setColorFilter(TilesOverlay.INVERT_COLORS);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package it.danieleverducci.nextcloudmaps.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
import it.danieleverducci.nextcloudmaps.activity.main.GeofavoriteAdapter;
|
||||||
|
|
||||||
|
public class SettingsManager {
|
||||||
|
static private final String SETTING_SORT_BY = "SETTING_SORT_BY";
|
||||||
|
static private final String SETTING_LAST_SELECTED_LIST_VIEW = "SETTING_LAST_SELECTED_LIST_VIEW";
|
||||||
|
static private final String SETTING_LAST_MAP_POSITION_LAT = "SETTING_LAST_MAP_POSITION_LAT";
|
||||||
|
static private final String SETTING_LAST_MAP_POSITION_LNG = "SETTING_LAST_MAP_POSITION_LNG";
|
||||||
|
static private final String SETTING_LAST_MAP_POSITION_ZOOM = "SETTING_LAST_MAP_POSITION_ZOOM";
|
||||||
|
static private final String SETTING_USE_GOOGLE_MAPS = "SETTING_USE_GOOGLE_MAPS";
|
||||||
|
|
||||||
|
public static int getGeofavoriteListSortBy(Context context) {
|
||||||
|
return PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
.getInt(SETTING_SORT_BY, GeofavoriteAdapter.SORT_BY_CREATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setGeofavoriteListSortBy(Context context, int value) {
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
.edit().putInt(SETTING_SORT_BY, value).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isGeofavoriteListShownAsMap(Context context) {
|
||||||
|
return PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
.getBoolean(SETTING_LAST_SELECTED_LIST_VIEW, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setGeofavoriteListShownAsMap(Context context, boolean value) {
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
.edit().putBoolean(SETTING_LAST_SELECTED_LIST_VIEW, value).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the last saved position
|
||||||
|
* @param context
|
||||||
|
* @return double[lat,lng,zoom]
|
||||||
|
*/
|
||||||
|
public static double[] getLastMapPosition(Context context) {
|
||||||
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
return new double[] {
|
||||||
|
(double) sp.getFloat(SETTING_LAST_MAP_POSITION_LAT, 0.0f),
|
||||||
|
(double) sp.getFloat(SETTING_LAST_MAP_POSITION_LNG, 0.0f),
|
||||||
|
(double) sp.getFloat(SETTING_LAST_MAP_POSITION_ZOOM, 10.0f),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isUseGoogleMaps(Context context) {
|
||||||
|
return PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
.getBoolean(SETTING_USE_GOOGLE_MAPS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setUseGoogleMaps(Context context, boolean value) {
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
.edit().putBoolean(SETTING_USE_GOOGLE_MAPS, value).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setLastMapPosition(Context context, double lat, double lng, double zoom) {
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(context).edit()
|
||||||
|
.putFloat(SETTING_LAST_MAP_POSITION_LAT, (float)lat)
|
||||||
|
.putFloat(SETTING_LAST_MAP_POSITION_LNG, (float)lng)
|
||||||
|
.putFloat(SETTING_LAST_MAP_POSITION_ZOOM, (float)zoom)
|
||||||
|
.apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package it.danieleverducci.nextcloudmaps.utils;
|
||||||
|
|
||||||
|
import androidx.annotation.MainThread;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
import androidx.lifecycle.Observer;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events implementation in LiveData
|
||||||
|
* From: https://gist.github.com/teegarcs/319a3e7e4736a0cce8eba2216c52b0ca#file-singleliveevent
|
||||||
|
* @param <T>
|
||||||
|
*/
|
||||||
|
public class SingleLiveEvent<T> extends MutableLiveData<T> {
|
||||||
|
AtomicBoolean mPending = new AtomicBoolean(false);
|
||||||
|
|
||||||
|
@MainThread
|
||||||
|
@Override
|
||||||
|
public void setValue(T value) {
|
||||||
|
mPending.set(true);
|
||||||
|
super.setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MainThread
|
||||||
|
@Override
|
||||||
|
public void observe(@NonNull LifecycleOwner owner, @NonNull Observer<? super T> observer) {
|
||||||
|
super.observe(owner, new Observer<T>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(T t) {
|
||||||
|
if (mPending.compareAndSet(true, false)) {
|
||||||
|
observer.onChanged(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Util function for Void implementations.
|
||||||
|
*/
|
||||||
|
public void call() {
|
||||||
|
setValue(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package it.danieleverducci.nextcloudmaps.views;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.appcompat.content.res.AppCompatResources;
|
||||||
|
import androidx.core.graphics.drawable.DrawableCompat;
|
||||||
|
|
||||||
|
import org.osmdroid.views.MapView;
|
||||||
|
import org.osmdroid.views.overlay.infowindow.InfoWindow;
|
||||||
|
import org.osmdroid.views.overlay.infowindow.MarkerInfoWindow;
|
||||||
|
|
||||||
|
import it.danieleverducci.nextcloudmaps.R;
|
||||||
|
import it.danieleverducci.nextcloudmaps.model.Geofavorite;
|
||||||
|
|
||||||
|
public class GeofavMarkerInfoWindow extends MarkerInfoWindow implements View.OnClickListener {
|
||||||
|
private OnGeofavMarkerInfoWindowClickListener onGeofavMarkerInfoWindowClickListener;
|
||||||
|
|
||||||
|
public GeofavMarkerInfoWindow(MapView mapView, Geofavorite geofavorite) {
|
||||||
|
super(R.layout.infowindow_geofav, mapView);
|
||||||
|
Context context = getView().getContext();
|
||||||
|
|
||||||
|
// Set category color
|
||||||
|
View category = getView().findViewById(R.id.bubble_subdescription);
|
||||||
|
Drawable backgroundDrawable = category.getBackground();
|
||||||
|
DrawableCompat.setTint(backgroundDrawable, geofavorite.categoryColor() == 0 ? context.getColor(R.color.defaultBrand) : geofavorite.categoryColor());
|
||||||
|
|
||||||
|
// Set listeners
|
||||||
|
getView().findViewById(R.id.action_icon_share).setOnClickListener(this);
|
||||||
|
getView().findViewById(R.id.action_icon_nav).setOnClickListener(this);
|
||||||
|
getView().findViewById(R.id.action_icon_delete).setOnClickListener(this);
|
||||||
|
getView().findViewById(R.id.action_icon_edit).setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnGeofavMarkerInfoWindowClickListener(OnGeofavMarkerInfoWindowClickListener l) {
|
||||||
|
this.onGeofavMarkerInfoWindowClickListener = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onOpen(Object item) {
|
||||||
|
InfoWindow.closeAllInfoWindowsOn(getMapView());
|
||||||
|
super.onOpen(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (onGeofavMarkerInfoWindowClickListener == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (v.getId() == R.id.action_icon_share)
|
||||||
|
onGeofavMarkerInfoWindowClickListener.onGeofavMarkerInfoWindowShareClick();
|
||||||
|
|
||||||
|
if (v.getId() == R.id.action_icon_nav)
|
||||||
|
onGeofavMarkerInfoWindowClickListener.onGeofavMarkerInfoWindowNavClick();
|
||||||
|
|
||||||
|
if (v.getId() == R.id.action_icon_delete)
|
||||||
|
onGeofavMarkerInfoWindowClickListener.onGeofavMarkerInfoWindowDeleteClick();
|
||||||
|
|
||||||
|
if (v.getId() == R.id.action_icon_edit)
|
||||||
|
onGeofavMarkerInfoWindowClickListener.onGeofavMarkerInfoWindowEditClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public interface OnGeofavMarkerInfoWindowClickListener {
|
||||||
|
public void onGeofavMarkerInfoWindowEditClick();
|
||||||
|
public void onGeofavMarkerInfoWindowShareClick();
|
||||||
|
public void onGeofavMarkerInfoWindowNavClick();
|
||||||
|
public void onGeofavMarkerInfoWindowDeleteClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item
|
<item>
|
||||||
android:left="8dp"
|
|
||||||
android:right="8dp"
|
|
||||||
android:top="8dp"
|
|
||||||
android:bottom="8dp">
|
|
||||||
<shape
|
<shape
|
||||||
android:shape="oval">
|
android:shape="oval">
|
||||||
<solid android:color="@color/defaultBrandAlpha"/>
|
<solid android:color="@color/defaultBrandAlpha"/>
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="209.21dp"
|
||||||
|
android:height="45.14dp"
|
||||||
|
android:viewportWidth="209.21"
|
||||||
|
android:viewportHeight="45.14">
|
||||||
|
<path
|
||||||
|
android:pathData="m204.31,0.14c-0.97,0.02 -2.1,0.07 -3.3,0.15l8.18,-0.01c0,0 -1.81,-0.2 -4.89,-0.14zM201.01,0.29 L0.02,0.46c0,0 32.67,5.29 57.83,17.7 25.15,12.42 45.33,26.81 45.33,26.81 0,0 18.75,-13.75 38.46,-26.28 20.46,-13 49.14,-17.73 59.37,-18.41z"
|
||||||
|
android:strokeLineJoin="miter"
|
||||||
|
android:strokeWidth="0.264583"
|
||||||
|
android:fillColor="#000000"
|
||||||
|
android:strokeColor="#00000000"
|
||||||
|
android:strokeLineCap="butt"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?android:attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M20.94,11c-0.46,-4.17 -3.77,-7.48 -7.94,-7.94L13,1h-2v2.06c-1.13,0.12 -2.19,0.46 -3.16,0.97l1.5,1.5C10.16,5.19 11.06,5 12,5c3.87,0 7,3.13 7,7 0,0.94 -0.19,1.84 -0.52,2.65l1.5,1.5c0.5,-0.96 0.84,-2.02 0.97,-3.15L23,13v-2h-2.06zM3,4.27l2.04,2.04C3.97,7.62 3.25,9.23 3.06,11L1,11v2h2.06c0.46,4.17 3.77,7.48 7.94,7.94L11,23h2v-2.06c1.77,-0.2 3.38,-0.91 4.69,-1.98L19.73,21 21,19.73 4.27,3 3,4.27zM16.27,17.54C15.09,18.45 13.61,19 12,19c-3.87,0 -7,-3.13 -7,-7 0,-1.61 0.55,-3.09 1.46,-4.27l9.81,9.81z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?android:attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM20.94,11c-0.46,-4.17 -3.77,-7.48 -7.94,-7.94L13,1h-2v2.06C6.83,3.52 3.52,6.83 3.06,11L1,11v2h2.06c0.46,4.17 3.77,7.48 7.94,7.94L11,23h2v-2.06c4.17,-0.46 7.48,-3.77 7.94,-7.94L23,13v-2h-2.06zM12,19c-3.87,0 -7,-3.13 -7,-7s3.13,-7 7,-7 7,3.13 7,7 -3.13,7 -7,7z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM20.94,11c-0.46,-4.17 -3.77,-7.48 -7.94,-7.94L13,1h-2v2.06C6.83,3.52 3.52,6.83 3.06,11L1,11v2h2.06c0.46,4.17 3.77,7.48 7.94,7.94L11,23h2v-2.06c4.17,-0.46 7.48,-3.77 7.94,-7.94L23,13v-2h-2.06zM12,19c-3.87,0 -7,-3.13 -7,-7s3.13,-7 7,-7 7,3.13 7,7 -3.13,7 -7,7z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M20.5,3l-0.16,0.03L15,5.1 9,3 3.36,4.9c-0.21,0.07 -0.36,0.25 -0.36,0.48V20.5c0,0.28 0.22,0.5 0.5,0.5l0.16,-0.03L9,18.9l6,2.1 5.64,-1.9c0.21,-0.07 0.36,-0.25 0.36,-0.48V3.5c0,-0.28 -0.22,-0.5 -0.5,-0.5zM15,19l-6,-2.11V5l6,2.11V19z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?android:attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M12,2l-5.5,9h11z"/>
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M17.5,17.5m-4.5,0a4.5,4.5 0,1 1,9 0a4.5,4.5 0,1 1,-9 0"/>
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M3,13.5h8v8H3z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#000000"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#000000"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M16,1L4,1c-1.1,0 -2,0.9 -2,2v14h2L4,3h12L16,1zM19,5L8,5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h11c1.1,0 2,-0.9 2,-2L21,7c0,-1.1 -0.9,-2 -2,-2zM19,21L8,21L8,7h11v14z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?android:attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M21,3L3,10.53v0.98l6.84,2.65L12.48,21h0.98L21,3z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M4.25,5.61C6.27,8.2 10,13 10,13v6c0,0.55 0.45,1 1,1h2c0.55,0 1,-0.45 1,-1v-6c0,0 3.72,-4.8 5.74,-7.39C20.25,4.95 19.78,4 18.95,4H5.04C4.21,4 3.74,4.95 4.25,5.61z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M19.79,5.61C20.3,4.95 19.83,4 19,4H6.83l7.97,7.97L19.79,5.61z"/>
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M2.81,2.81L1.39,4.22L10,13v6c0,0.55 0.45,1 1,1h2c0.55,0 1,-0.45 1,-1v-2.17l5.78,5.78l1.41,-1.41L2.81,2.81z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="48dp"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.87 -3.13,-7 -7,-7z"/>
|
||||||
|
</vector>
|
||||||
@@ -1,10 +1,5 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||||
android:width="24dp"
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
android:height="24dp"
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
android:viewportWidth="24"
|
<path android:fillColor="@android:color/white" android:pathData="M17,1.01L7,1c-1.1,0 -1.99,0.9 -1.99,2v18c0,1.1 0.89,2 1.99,2h10c1.1,0 2,-0.9 2,-2L19,3c0,-1.1 -0.9,-1.99 -2,-1.99zM17,19L7,19L7,5h10v14zM12.8,13.22v1.75l3.2,-2.99L12.8,9v1.7c-3.11,0.43 -4.35,2.56 -4.8,4.7 1.11,-1.5 2.58,-2.18 4.8,-2.18z"/>
|
||||||
android:viewportHeight="24"
|
|
||||||
android:tint="?attr/colorControlNormal">
|
|
||||||
<path
|
|
||||||
android:fillColor="@android:color/white"
|
|
||||||
android:pathData="M20.5,3l-0.16,0.03L15,5.1 9,3 3.36,4.9c-0.21,0.07 -0.36,0.25 -0.36,0.48V20.5c0,0.28 0.22,0.5 0.5,0.5l0.16,-0.03L9,18.9l6,2.1 5.64,-1.9c0.21,-0.07 0.36,-0.25 0.36,-0.48V3.5c0,-0.28 -0.22,-0.5 -0.5,-0.5zM15,19l-6,-2.11V5l6,2.11V19z"/>
|
|
||||||
</vector>
|
</vector>
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?android:attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<!--
|
||||||
|
Material Design Settings icon by Google
|
||||||
|
Licensed under the Apache License, Version 2.0
|
||||||
|
https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
-->
|
||||||
|
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="#757575">
|
||||||
|
<path
|
||||||
|
android:fillColor="#757575"
|
||||||
|
android:pathData="M19.14,12.94c0.04,-0.3 0.06,-0.61 0.06,-0.94c0,-0.32 -0.02,-0.64 -0.07,-0.94l2.03,-1.58a0.49,0.49 0,0 0,0.12 -0.61l-1.92,-3.32a0.49,0.49 0,0 0,-0.59 -0.22l-2.39,0.96c-0.5,-0.38 -1.03,-0.7 -1.62,-0.94L14.4,2.81a0.48,0.48 0,0 0,-0.47 -0.41h-3.84c-0.24,0 -0.43,0.17 -0.47,0.41L9.25,5.35C8.66,5.59 8.12,5.92 7.63,6.29L5.24,5.33a0.49,0.49 0,0 0,-0.59 0.22L2.74,8.87a0.48,0.48 0,0 0,0.12 0.61l2.03,1.58C4.84,11.36 4.8,11.69 4.8,12s0.02,0.64 0.07,0.94l-2.03,1.58a0.49,0.49 0,0 0,-0.12 0.61l1.92,3.32c0.12,0.22 0.37,0.29 0.59,0.22l2.39,-0.96c0.5,0.38 1.03,0.7 1.62,0.94l0.36,2.54c0.05,0.24 0.24,0.41 0.48,0.41h3.84c0.24,0 0.44,-0.17 0.47,-0.41l0.36,-2.54c0.59,-0.24 1.13,-0.56 1.62,-0.94l2.39,0.96c0.22,0.08 0.47,0 0.59,-0.22l1.92,-3.32c0.12,-0.22 0.07,-0.47 -0.12,-0.61L19.14,12.94zM12,15.6A3.6,3.6 0,1 1,12 8.4a3.6,3.6 0,0 1,0 7.2z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M20.5,3l-0.16,0.03L15,5.1 9,3 3.36,4.9c-0.21,0.07 -0.36,0.25 -0.36,0.48V20.5c0,0.28 0.22,0.5 0.5,0.5l0.16,-0.03L9,18.9l6,2.1 5.64,-1.9c0.21,-0.07 0.36,-0.25 0.36,-0.48V3.5c0,-0.28 -0.22,-0.5 -0.5,-0.5zM15,19l-6,-2.11V5l6,2.11V19z"/>
|
||||||
|
</vector>
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
<!--
|
|
||||||
~ Nextcloud Maps Geofavorites for Android
|
|
||||||
~
|
|
||||||
~ This program is free software: you can redistribute it and/or modify
|
|
||||||
~ it under the terms of the GNU General Public License as published by
|
|
||||||
~ the Free Software Foundation, either version 3 of the License, or
|
|
||||||
~ (at your option) any later version.
|
|
||||||
~
|
|
||||||
~ This program is distributed in the hope that it will be useful,
|
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
~ GNU General Public License for more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License
|
|
||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
<vector
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:height="24dp"
|
|
||||||
android:width="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path android:fillColor="#FFFFFF"
|
|
||||||
android:pathData="M16,5V11H21V5M10,11H15V5H10M16,18H21V12H16M10,18H15V12H10M4,18H9V12H4M4,11H9V5H4V11Z" />
|
|
||||||
</vector>
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="@color/defaultBackground"/>
|
||||||
|
<stroke android:width="7dp" android:color="@color/defaultBrand" />
|
||||||
|
<corners android:radius="20dp"/>
|
||||||
|
</shape>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item>
|
||||||
|
<shape
|
||||||
|
android:shape="oval">
|
||||||
|
<solid android:color="@color/defaultBrand"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="#000" />
|
||||||
|
<padding android:left="10dp" android:top="3dp" android:right="10dp" android:bottom="3dp" />
|
||||||
|
<corners android:radius="20dp" />
|
||||||
|
</shape>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item>
|
||||||
|
<shape
|
||||||
|
android:shape="oval">
|
||||||
|
<solid android:color="@color/translucent"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<shape
|
||||||
|
android:innerRadius="0dp"
|
||||||
|
android:shape="oval"
|
||||||
|
android:useLevel="false">
|
||||||
|
<solid android:color="@android:color/transparent" />
|
||||||
|
<stroke
|
||||||
|
android:width="10dp"
|
||||||
|
android:color="@color/toolbar_background" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
<androidx.appcompat.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?android:attr/actionBarSize"
|
||||||
app:contentInsetStartWithNavigation="0dp"
|
app:contentInsetStartWithNavigation="0dp"
|
||||||
app:navigationIcon="@drawable/ic_back_grey"
|
app:navigationIcon="@drawable/ic_back_grey"
|
||||||
app:titleMarginStart="0dp"/>
|
app:titleMarginStart="0dp"/>
|
||||||
@@ -115,6 +115,20 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:text="@string/about_issues" />
|
android:text="@string/about_issues" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="?android:attr/listSeparatorTextViewStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/about_maps_title" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/about_maps"
|
||||||
|
style="?android:attr/editTextPreferenceStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:text="@string/about_maps" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
<androidx.appcompat.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?android:attr/actionBarSize"
|
||||||
app:contentInsetStart="0dp"
|
app:contentInsetStart="0dp"
|
||||||
app:layout_collapseMode="pin"
|
app:layout_collapseMode="pin"
|
||||||
android:background="@android:color/transparent">
|
android:background="@android:color/transparent">
|
||||||
@@ -51,13 +51,27 @@
|
|||||||
<!-- Back button -->
|
<!-- Back button -->
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/back_bt"
|
android:id="@+id/back_bt"
|
||||||
android:layout_width="?attr/actionBarSize"
|
android:layout_width="40dp"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="40dp"
|
||||||
android:padding="16dp"
|
android:layout_gravity="start"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:padding="8dp"
|
||||||
android:src="@drawable/ic_back_grey"
|
android:src="@drawable/ic_back_grey"
|
||||||
app:tint="@color/white"
|
app:tint="@color/white"
|
||||||
android:background="@drawable/floating_semitransparent_button_background"/>
|
android:background="@drawable/floating_semitransparent_button_background"/>
|
||||||
|
|
||||||
|
<!-- Save button -->
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/submit_bt"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:src="@drawable/ic_ok"
|
||||||
|
app:tint="@color/white"
|
||||||
|
android:background="@drawable/round_button_background"/>
|
||||||
|
|
||||||
</androidx.appcompat.widget.Toolbar>
|
</androidx.appcompat.widget.Toolbar>
|
||||||
|
|
||||||
|
|
||||||
@@ -77,15 +91,43 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="20dp">
|
android:padding="20dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/accuracy_progress_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:src="@drawable/ic_accuracy_fail"
|
||||||
|
app:tint="@color/disabled"/>
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/accuracy_progress"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:indeterminate="true"
|
||||||
|
style="@style/Widget.AppCompat.ProgressBar.Horizontal" />
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:src="@drawable/ic_accuracy_ok"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/accuracy_tv"
|
android:id="@+id/accuracy_tv"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginBottom="20dp"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:text="@string/accuracy"
|
android:text="@string/accuracy_nosignal"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@color/defaultBrand"/>
|
||||||
android:background="@android:color/darker_gray"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/action_icons"
|
android:id="@+id/action_icons"
|
||||||
@@ -100,7 +142,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:src="@drawable/ic_share"
|
android:src="@drawable/ic_share"
|
||||||
android:tint="@color/defaultBrand"/>
|
app:tint="@color/defaultBrand"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/action_icon_nav"
|
android:id="@+id/action_icon_nav"
|
||||||
@@ -109,7 +151,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:src="@drawable/ic_nav"
|
android:src="@drawable/ic_nav"
|
||||||
android:tint="@color/defaultBrand"/>
|
app:tint="@color/defaultBrand"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/action_icon_delete"
|
android:id="@+id/action_icon_delete"
|
||||||
@@ -118,7 +160,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:src="@drawable/ic_delete_grey"
|
android:src="@drawable/ic_delete_grey"
|
||||||
android:tint="@color/defaultBrand"
|
app:tint="@color/defaultBrand"
|
||||||
android:visibility="gone"/> <!-- TODO Implement delete -->
|
android:visibility="gone"/> <!-- TODO Implement delete -->
|
||||||
|
|
||||||
|
|
||||||
@@ -138,7 +180,8 @@
|
|||||||
android:textAppearance="@style/TextAppearance.AppCompat.Title"
|
android:textAppearance="@style/TextAppearance.AppCompat.Title"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:drawableLeft="@drawable/ic_edit"
|
android:drawableLeft="@drawable/ic_edit"
|
||||||
android:drawablePadding="5dp"/>
|
android:drawablePadding="5dp"
|
||||||
|
android:drawableTint="@color/defaultBrand"/>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/description_et"
|
android:id="@+id/description_et"
|
||||||
@@ -152,8 +195,44 @@
|
|||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:drawableLeft="@drawable/ic_edit"
|
android:drawableLeft="@drawable/ic_edit"
|
||||||
android:drawablePadding="5dp"
|
android:drawablePadding="5dp"
|
||||||
|
android:drawableTint="@color/defaultBrand"
|
||||||
android:hint="@string/description"/>
|
android:hint="@string/description"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginTop="20dp">
|
||||||
|
|
||||||
|
<AutoCompleteTextView
|
||||||
|
android:id="@+id/category_at"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:drawableLeft="@drawable/ic_category_asc"
|
||||||
|
android:drawablePadding="5dp"
|
||||||
|
android:drawableTint="@color/defaultBrand"
|
||||||
|
android:hint="@string/category"
|
||||||
|
android:completionThreshold="0"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/category_at_clear"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="3dp"
|
||||||
|
android:background="@color/transparent"
|
||||||
|
android:src="@drawable/ic_clear"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="@string/category_hint"
|
||||||
|
android:textSize="12sp"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -180,19 +259,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAlignment="textEnd" />
|
android:textAlignment="textEnd" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:text="@string/category" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/category_tv"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAlignment="textEnd" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -204,17 +270,16 @@
|
|||||||
android:id="@+id/coords_tv"
|
android:id="@+id/coords_tv"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAlignment="textEnd" />
|
android:textAlignment="textEnd"
|
||||||
|
app:drawableEndCompat="@drawable/ic_copy"
|
||||||
|
android:drawablePadding="10sp"/>
|
||||||
|
|
||||||
<Button
|
<ProgressBar
|
||||||
android:id="@+id/submit_bt"
|
android:id="@+id/progress"
|
||||||
style="@style/Widget.AppCompat.Button.Colored"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="60dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="50dp"
|
android:indeterminate="true"
|
||||||
android:text="@string/confirm"
|
android:visibility="gone"/>
|
||||||
app:backgroundTint="@color/defaultBrand"
|
|
||||||
android:onClick="onSubmit"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -15,152 +15,58 @@
|
|||||||
~ You should have received a copy of the GNU General Public License
|
~ You should have received a copy of the GNU General Public License
|
||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
<FrameLayout
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/activity_list_view"
|
|
||||||
android:background="@color/primary"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<androidx.fragment.app.FragmentContainerView
|
||||||
android:id="@+id/appBar"
|
android:id="@+id/fragment_container"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="?attr/actionBarSize"
|
|
||||||
app:elevation="0dp">
|
|
||||||
|
|
||||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
|
||||||
android:id="@+id/toolbar_layout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
app:contentScrim="?attr/colorPrimary"
|
|
||||||
app:layout_scrollFlags="scroll|enterAlways"
|
|
||||||
app:toolbarId="@+id/toolbar" >
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
|
||||||
android:id="@+id/toolbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:visibility="visible"
|
|
||||||
app:contentInsetStartWithNavigation="0dp"
|
|
||||||
app:titleMarginStart="0dp"
|
|
||||||
tools:title="@string/app_name">
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.SearchView
|
|
||||||
android:id="@+id/search_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
</androidx.appcompat.widget.SearchView>
|
|
||||||
|
|
||||||
</androidx.appcompat.widget.Toolbar>
|
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:id="@+id/home_toolbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="@dimen/spacer_2x"
|
|
||||||
android:layout_marginTop="@dimen/spacer_1hx"
|
|
||||||
android:layout_marginEnd="@dimen/spacer_2x"
|
|
||||||
android:layout_marginBottom="@dimen/spacer_1hx"
|
|
||||||
app:cardBackgroundColor="@color/appbar"
|
|
||||||
app:cardCornerRadius="@dimen/spacer_1x"
|
|
||||||
app:cardElevation="2dp"
|
|
||||||
app:strokeWidth="0dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageButton
|
|
||||||
android:id="@+id/menu_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="?attr/selectableItemBackgroundBorderless"
|
|
||||||
android:paddingStart="@dimen/spacer_1x"
|
|
||||||
android:paddingTop="@dimen/spacer_2x"
|
|
||||||
android:paddingEnd="@dimen/spacer_1x"
|
|
||||||
android:paddingBottom="@dimen/spacer_2x"
|
|
||||||
android:tint="?attr/colorAccent"
|
|
||||||
android:src="@drawable/ic_menu_grey"/>
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:id="@+id/search_text"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_marginStart="@dimen/spacer_1x"
|
|
||||||
android:layout_marginEnd="@dimen/spacer_1x"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:gravity="start"
|
|
||||||
android:lines="1"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:text="@string/search_in_all"/>
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
|
||||||
android:id="@+id/sort_mode"
|
|
||||||
android:layout_width="?attr/actionBarSize"
|
|
||||||
android:layout_height="?attr/actionBarSize"
|
|
||||||
android:layout_gravity="center_vertical|end"
|
|
||||||
android:background="?attr/selectableItemBackgroundBorderless"
|
|
||||||
android:contentDescription="@string/list_mode"
|
|
||||||
android:padding="@dimen/spacer_2x"
|
|
||||||
android:tint="?attr/colorAccent"
|
|
||||||
android:translationX="@dimen/spacer_1x"
|
|
||||||
android:src="@drawable/ic_alphabetical_asc" />
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
|
||||||
android:id="@+id/view_mode"
|
|
||||||
android:layout_width="?attr/actionBarSize"
|
|
||||||
android:layout_height="?attr/actionBarSize"
|
|
||||||
android:layout_gravity="center_vertical|end"
|
|
||||||
android:background="?attr/selectableItemBackgroundBorderless"
|
|
||||||
android:contentDescription="@string/list_mode"
|
|
||||||
android:padding="@dimen/spacer_2x"
|
|
||||||
android:tint="?attr/colorAccent"
|
|
||||||
android:translationX="@dimen/spacer_1x"
|
|
||||||
android:src="@drawable/ic_view_module" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
|
||||||
|
|
||||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
|
||||||
android:id="@+id/swipe_refresh"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_margin="@dimen/spacer_1hx"
|
android:name="it.danieleverducci.nextcloudmaps.fragments.GeofavoriteListFragment"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
tools:layout="@layout/fragment_geofavorite_list" />
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/recycler_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
app:layoutManager="androidx.recyclerview.widget.StaggeredGridLayoutManager"
|
|
||||||
app:spanCount="1"
|
|
||||||
tools:itemCount="3"
|
|
||||||
tools:listitem="@layout/item_geofav">
|
|
||||||
</androidx.recyclerview.widget.RecyclerView>
|
|
||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
|
||||||
|
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
|
||||||
|
|
||||||
|
<!-- Add from map FAB -->
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
android:id="@+id/add"
|
android:id="@+id/add_from_map"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_margin="24dp"
|
||||||
|
android:src="@drawable/ic_add_map"
|
||||||
|
app:backgroundTint="@color/defaultBrand"
|
||||||
|
app:fabSize="mini"
|
||||||
|
app:tint="@color/white"
|
||||||
|
tools:ignore="DuplicateClickableBoundsCheck"
|
||||||
|
android:contentDescription="@string/add_from_map" />
|
||||||
|
|
||||||
|
<!-- Add from current position FAB -->
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/add_from_gps"
|
||||||
|
android:layout_margin="24dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:fabSize="mini"
|
||||||
|
android:src="@drawable/ic_add_gps"
|
||||||
|
app:backgroundTint="@color/defaultBrand"
|
||||||
|
app:tint="@color/white"
|
||||||
|
android:contentDescription="@string/add_from_gps"/>
|
||||||
|
|
||||||
|
<!-- Main FAB -->
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/open_fab"
|
||||||
android:layout_margin="16dp"
|
android:layout_margin="16dp"
|
||||||
android:layout_gravity="bottom|end"
|
android:layout_gravity="bottom|end"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:src="@drawable/ic_add"
|
android:src="@drawable/ic_add"
|
||||||
app:backgroundTint="@color/defaultBrand"/>
|
app:backgroundTint="@color/defaultBrand"
|
||||||
|
app:tint="@color/white"
|
||||||
|
android:contentDescription="@string/open_fab"/>
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</FrameLayout>
|
||||||
@@ -46,8 +46,7 @@
|
|||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginBottom="48dp"
|
android:layout_marginBottom="48dp"
|
||||||
android:textSize="24sp"
|
android:textSize="24sp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"/>
|
||||||
android:textColor="@color/accent"/>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/chose_button"
|
android:id="@+id/chose_button"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
android:id="@+id/scrollView"
|
android:id="@+id/scrollView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?attr/colorPrimary">
|
android:background="?android:attr/colorPrimary">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -68,9 +68,11 @@
|
|||||||
android:id="@+id/app_name"
|
android:id="@+id/app_name"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_toEndOf="@id/logo"
|
android:layout_toEndOf="@id/logo"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
|
android:lines="2"
|
||||||
android:fontFamily="sans-serif-light"
|
android:fontFamily="sans-serif-light"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:text="@string/app_name"
|
android:text="@string/app_name"
|
||||||
|
|||||||
@@ -0,0 +1,107 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto" >
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/root"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<org.osmdroid.views.MapView
|
||||||
|
android:id="@+id/map"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginBottom="24dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:src="@drawable/ic_map_pin"
|
||||||
|
app:tint="@color/defaultBrand"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/back_bt"
|
||||||
|
android:layout_width="?android:attr/actionBarSize"
|
||||||
|
android:layout_height="?android:attr/actionBarSize"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:src="@drawable/ic_back_grey"
|
||||||
|
app:tint="@color/text_color"
|
||||||
|
android:background="@drawable/unselected_floating_semitransparent_button_background"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ok_bt"
|
||||||
|
android:layout_width="?android:attr/actionBarSize"
|
||||||
|
android:layout_height="?android:attr/actionBarSize"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:src="@drawable/ic_ok"
|
||||||
|
app:tint="@color/white"
|
||||||
|
android:background="@drawable/round_button_background"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:background="@color/defaultBrandAlpha">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/lat_et"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:lines="1"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
|
android:textColor="@color/white"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="°N"
|
||||||
|
android:textColor="@color/white"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/lon_et"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:lines="1"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
|
android:textColor="@color/white"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="°E"
|
||||||
|
android:textColor="@color/white"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/latlon_confirm_btn"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:src="@drawable/ic_ok"
|
||||||
|
app:tint="@color/white"
|
||||||
|
android:background="@drawable/round_button_background"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
</layout>
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Nextcloud Maps Geofavorites for Android
|
||||||
|
~
|
||||||
|
~ This program is free software: you can redistribute it and/or modify
|
||||||
|
~ it under the terms of the GNU General Public License as published by
|
||||||
|
~ the Free Software Foundation, either version 3 of the License, or
|
||||||
|
~ (at your option) any later version.
|
||||||
|
~
|
||||||
|
~ This program is distributed in the hope that it will be useful,
|
||||||
|
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
~ GNU General Public License for more details.
|
||||||
|
~
|
||||||
|
~ You should have received a copy of the GNU General Public License
|
||||||
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
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:background="@color/primary"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/appBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?android:attr/actionBarSize"
|
||||||
|
app:contentInsetStartWithNavigation="0dp"
|
||||||
|
app:navigationIcon="@drawable/ic_back_grey"
|
||||||
|
app:titleMarginStart="0dp"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="@dimen/spacer_2x">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:padding="10dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:text="@string/settings_use_google_maps"
|
||||||
|
style="?android:attr/editTextPreferenceStyle"/>
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/use_google_maps_switch"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="visible"
|
||||||
|
app:contentInsetStartWithNavigation="0dp"
|
||||||
|
app:titleMarginStart="0dp"
|
||||||
|
tools:title="@string/app_name">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.SearchView
|
||||||
|
android:id="@+id/search_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="30dp"
|
||||||
|
android:layout_marginEnd="30dp"
|
||||||
|
android:background="@color/translucent">
|
||||||
|
</androidx.appcompat.widget.SearchView>
|
||||||
|
|
||||||
|
</androidx.appcompat.widget.Toolbar>
|
||||||
|
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:id="@+id/home_toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/spacer_2x"
|
||||||
|
android:layout_marginTop="@dimen/spacer_1hx"
|
||||||
|
android:layout_marginEnd="@dimen/spacer_2x"
|
||||||
|
android:layout_marginBottom="@dimen/spacer_1hx"
|
||||||
|
app:cardBackgroundColor="@color/toolbar_background"
|
||||||
|
app:cardCornerRadius="30dp"
|
||||||
|
app:cardElevation="2dp"
|
||||||
|
app:strokeWidth="0dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
|
android:id="@+id/menu_button"
|
||||||
|
android:layout_width="?android:attr/actionBarSize"
|
||||||
|
android:layout_height="?android:attr/actionBarSize"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:layout_gravity="center_vertical|start"
|
||||||
|
android:paddingStart="@dimen/spacer_1x"
|
||||||
|
android:paddingTop="@dimen/spacer_2x"
|
||||||
|
android:paddingEnd="@dimen/spacer_1x"
|
||||||
|
android:paddingBottom="@dimen/spacer_2x"
|
||||||
|
android:tint="@color/text_color"
|
||||||
|
android:src="@drawable/ic_menu_grey"
|
||||||
|
android:contentDescription="@string/menu"/>
|
||||||
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
android:id="@+id/search_text"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginStart="@dimen/spacer_1x"
|
||||||
|
android:layout_marginEnd="@dimen/spacer_1x"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="start"
|
||||||
|
android:lines="1"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:text="@string/search_in_all"/>
|
||||||
|
|
||||||
|
<!-- Filter button -->
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/search_filter"
|
||||||
|
android:layout_width="?android:attr/actionBarSize"
|
||||||
|
android:layout_height="?android:attr/actionBarSize"
|
||||||
|
android:src="@drawable/ic_filter_off"
|
||||||
|
app:tint="@color/inactive"
|
||||||
|
android:background="@color/transparent"/>
|
||||||
|
|
||||||
|
<!-- User badge -->
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/user_badge_container"
|
||||||
|
android:layout_width="?android:attr/actionBarSize"
|
||||||
|
android:layout_height="?android:attr/actionBarSize">
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/user_badge"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="10dp"/>
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@drawable/user_badge_mask"/>
|
||||||
|
</FrameLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
</FrameLayout>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout
|
||||||
|
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="wrap_content"
|
||||||
|
android:paddingLeft="20dp"
|
||||||
|
android:paddingRight="20dp"
|
||||||
|
android:paddingTop="10dp"
|
||||||
|
android:paddingBottom="10dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/category_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:lines="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:text="Lorem ipsum"
|
||||||
|
app:drawableLeftCompat="@drawable/ic_category_asc"
|
||||||
|
android:drawablePadding="8sp"
|
||||||
|
android:drawableTint="@color/white"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:background="@drawable/rounded_label_background"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/activity_list_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/appBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:elevation="0dp">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
app:contentScrim="?android:attr/colorPrimary"
|
||||||
|
app:layout_scrollFlags="scroll|enterAlways"
|
||||||
|
app:toolbarId="@+id/toolbar" >
|
||||||
|
|
||||||
|
<include layout="@layout/app_toolbar"/>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginTop="?android:attr/actionBarSize"
|
||||||
|
android:paddingTop="20dp"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/sort_mode"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/floating_bar_height"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:contentDescription="@string/list_mode"
|
||||||
|
android:paddingStart="@dimen/spacer_2x"
|
||||||
|
android:paddingEnd="@dimen/spacer_2x"
|
||||||
|
android:tint="@color/text_color"
|
||||||
|
android:src="@drawable/ic_alphabetical_asc" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/view_mode_map"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/floating_bar_height"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:contentDescription="@string/list_mode"
|
||||||
|
android:paddingStart="@dimen/spacer_2x"
|
||||||
|
android:paddingEnd="@dimen/spacer_2x"
|
||||||
|
android:tint="@color/text_color"
|
||||||
|
android:src="@drawable/ic_view_map" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
|
android:id="@+id/swipe_refresh"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/recycler_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.StaggeredGridLayoutManager"
|
||||||
|
app:spanCount="1"
|
||||||
|
tools:itemCount="3"
|
||||||
|
tools:listitem="@layout/item_geofav">
|
||||||
|
</androidx.recyclerview.widget.RecyclerView>
|
||||||
|
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/activity_list_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<org.osmdroid.views.MapView
|
||||||
|
android:id="@+id/map"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/loading_wall"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/translucent"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
|
android:id="@+id/appBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:elevation="0dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<include layout="@layout/app_toolbar"/>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/view_mode_list"
|
||||||
|
android:layout_width="@dimen/floating_bar_height"
|
||||||
|
android:layout_height="@dimen/floating_bar_height"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:layout_marginEnd="@dimen/spacer_2x"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
android:background="@drawable/unselected_floating_semitransparent_button_background"
|
||||||
|
android:contentDescription="@string/list_mode"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:tint="@color/text_color"
|
||||||
|
android:src="@drawable/ic_view_list" />
|
||||||
|
|
||||||
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/center_position"
|
||||||
|
android:layout_width="@dimen/floating_bar_height"
|
||||||
|
android:layout_height="@dimen/floating_bar_height"
|
||||||
|
android:layout_marginRight="100dp"
|
||||||
|
android:layout_marginBottom="25dp"
|
||||||
|
android:layout_gravity="bottom|right"
|
||||||
|
android:background="@drawable/unselected_floating_semitransparent_button_background"
|
||||||
|
android:padding="5dp"
|
||||||
|
android:tint="@color/text_color"
|
||||||
|
android:src="@drawable/ic_add_gps"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minWidth="250dp"
|
||||||
|
android:background="@drawable/infowindow_geofav_background"
|
||||||
|
android:padding="7dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<!-- Geofavorite title -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/bubble_title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/defaultBrand"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:lines="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
style="@style/TextAppearance.GeofavoriteInfowindow"
|
||||||
|
android:text="Lorem"/>
|
||||||
|
|
||||||
|
<!-- Geofavorite description -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/bubble_description"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:text="Lorem ipsum"/>
|
||||||
|
|
||||||
|
<!-- Geofavorite category -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/bubble_subdescription"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:lines="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:text="Lorem ipsum"
|
||||||
|
app:drawableLeftCompat="@drawable/ic_category_asc"
|
||||||
|
android:drawablePadding="8sp"
|
||||||
|
android:drawableTint="@color/white"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:background="@drawable/rounded_label_background"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/action_icon_share"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:src="@drawable/ic_share"
|
||||||
|
app:tint="@color/defaultBrand"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/action_icon_nav"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:src="@drawable/ic_nav"
|
||||||
|
app:tint="@color/defaultBrand"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/action_icon_delete"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:src="@drawable/ic_delete_grey"
|
||||||
|
app:tint="@color/defaultBrand"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/action_icon_edit"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:src="@drawable/ic_edit"
|
||||||
|
app:tint="@color/defaultBrand"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/bubble_image"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="10dp"
|
||||||
|
android:layout_marginTop="-1dp"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:src="@drawable/geofav_infowindow_pointer"
|
||||||
|
app:tint="@color/defaultBrand" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="90dp"
|
android:layout_height="90dp"
|
||||||
@@ -26,19 +27,25 @@
|
|||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true">
|
android:focusable="true">
|
||||||
|
|
||||||
<ImageView
|
<TextView
|
||||||
android:layout_width="32dp"
|
android:id="@+id/tv_category"
|
||||||
android:layout_height="32dp"
|
android:layout_width="64dp"
|
||||||
android:layout_marginStart="12dp"
|
android:layout_height="64dp"
|
||||||
android:contentDescription="@null"
|
android:layout_marginStart="4dp"
|
||||||
android:layout_weight="0"
|
android:layout_weight="0"
|
||||||
android:src="@mipmap/ic_launcher"/>
|
android:background="@drawable/ic_list_pin"
|
||||||
|
android:gravity="top|center"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:textSize="28dp"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:drawableTint="@color/defaultBrand" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
|
|
||||||
@@ -99,7 +106,7 @@
|
|||||||
android:layout_weight="0"
|
android:layout_weight="0"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:src="@drawable/ic_nav"
|
android:src="@drawable/ic_nav"
|
||||||
android:tint="@color/secondary_text_color" /> <!-- TODO: app:tint is not working -->
|
app:tint="@color/secondary_text_color" /> <!-- TODO: app:tint is not working -->
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/geofav_context_menu_bt"
|
android:id="@+id/geofav_context_menu_bt"
|
||||||
@@ -108,6 +115,6 @@
|
|||||||
android:layout_weight="0"
|
android:layout_weight="0"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:src="@drawable/ic_more"
|
android:src="@drawable/ic_more"
|
||||||
android:tint="@color/secondary_text_color" /> <!-- TODO: app:tint is not working -->
|
app:tint="@color/secondary_text_color" /> <!-- TODO: app:tint is not working -->
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
@@ -33,7 +34,8 @@
|
|||||||
android:contentDescription="@null"
|
android:contentDescription="@null"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
android:src="@drawable/ic_time_grey"/>
|
android:src="@drawable/ic_time_grey"
|
||||||
|
app:tint="@color/text_color"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/navigationItemLabel"
|
android:id="@+id/navigationItemLabel"
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
~ Nextcloud Maps Geofavorites for Android
|
|
||||||
~
|
|
||||||
~ This program is free software: you can redistribute it and/or modify
|
|
||||||
~ it under the terms of the GNU General Public License as published by
|
|
||||||
~ the Free Software Foundation, either version 3 of the License, or
|
|
||||||
~ (at your option) any later version.
|
|
||||||
~
|
|
||||||
~ This program is distributed in the hope that it will be useful,
|
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
~ GNU General Public License for more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License
|
|
||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
|
||||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
|
||||||
</adaptive-icon>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
~ Nextcloud Maps Geofavorites for Android
|
|
||||||
~
|
|
||||||
~ This program is free software: you can redistribute it and/or modify
|
|
||||||
~ it under the terms of the GNU General Public License as published by
|
|
||||||
~ the Free Software Foundation, either version 3 of the License, or
|
|
||||||
~ (at your option) any later version.
|
|
||||||
~
|
|
||||||
~ This program is distributed in the hope that it will be useful,
|
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
~ GNU General Public License for more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License
|
|
||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
|
||||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
|
||||||
</adaptive-icon>
|
|
||||||
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 18 KiB |
@@ -16,8 +16,9 @@
|
|||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/root"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/root"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minWidth="300dp"
|
android:minWidth="300dp"
|
||||||
@@ -57,7 +58,8 @@
|
|||||||
android:paddingEnd="@dimen/standard_half_padding"
|
android:paddingEnd="@dimen/standard_half_padding"
|
||||||
android:paddingBottom="@dimen/standard_half_padding"
|
android:paddingBottom="@dimen/standard_half_padding"
|
||||||
android:contentDescription="@string/menu_item_sort_by_title_a_z"
|
android:contentDescription="@string/menu_item_sort_by_title_a_z"
|
||||||
android:src="@drawable/ic_alphabetical_asc" />
|
android:src="@drawable/ic_alphabetical_asc"
|
||||||
|
app:tint="@color/selector_item_unselected"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/sortByTitleAscendingText"
|
android:id="@+id/sortByTitleAscendingText"
|
||||||
@@ -72,7 +74,8 @@
|
|||||||
android:paddingBottom="@dimen/standard_half_padding"
|
android:paddingBottom="@dimen/standard_half_padding"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="@string/menu_item_sort_by_title_a_z"
|
android:text="@string/menu_item_sort_by_title_a_z"
|
||||||
android:textSize="@dimen/two_line_primary_text_size"/>
|
android:textSize="@dimen/two_line_primary_text_size"
|
||||||
|
android:textColor="@color/text_color"/>
|
||||||
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
@@ -92,7 +95,8 @@
|
|||||||
android:paddingEnd="@dimen/standard_half_padding"
|
android:paddingEnd="@dimen/standard_half_padding"
|
||||||
android:paddingBottom="@dimen/standard_half_padding"
|
android:paddingBottom="@dimen/standard_half_padding"
|
||||||
android:contentDescription="@string/menu_item_sort_by_date_newest_first"
|
android:contentDescription="@string/menu_item_sort_by_date_newest_first"
|
||||||
android:src="@drawable/ic_modification_asc"/>
|
android:src="@drawable/ic_modification_asc"
|
||||||
|
app:tint="@color/selector_item_unselected"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/sortByCreationDateDescendingText"
|
android:id="@+id/sortByCreationDateDescendingText"
|
||||||
@@ -107,7 +111,83 @@
|
|||||||
android:paddingBottom="@dimen/standard_half_padding"
|
android:paddingBottom="@dimen/standard_half_padding"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="@string/menu_item_sort_by_date_newest_first"
|
android:text="@string/menu_item_sort_by_date_newest_first"
|
||||||
android:textSize="@dimen/two_line_primary_text_size" />
|
android:textSize="@dimen/two_line_primary_text_size"
|
||||||
|
android:textColor="@color/selector_item_unselected" />
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/standard_half_margin">
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/sortByCategoryAscending"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:background="@color/transparent"
|
||||||
|
android:paddingStart="@dimen/standard_padding"
|
||||||
|
android:paddingTop="@dimen/standard_half_padding"
|
||||||
|
android:paddingEnd="@dimen/standard_half_padding"
|
||||||
|
android:paddingBottom="@dimen/standard_half_padding"
|
||||||
|
android:contentDescription="@string/menu_item_sort_by_category_a_z"
|
||||||
|
android:src="@drawable/ic_category_asc"
|
||||||
|
app:tint="@color/selector_item_unselected"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/sortByCategoryAscendingText"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:ellipsize="middle"
|
||||||
|
android:paddingStart="@dimen/zero"
|
||||||
|
android:paddingTop="@dimen/standard_half_padding"
|
||||||
|
android:paddingEnd="@dimen/standard_half_padding"
|
||||||
|
android:paddingBottom="@dimen/standard_half_padding"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="@string/menu_item_sort_by_category_a_z"
|
||||||
|
android:textSize="@dimen/two_line_primary_text_size"
|
||||||
|
android:textColor="@color/selector_item_unselected" />
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/standard_half_margin"
|
||||||
|
android:visibility="gone"> <!-- TODO: complete sorting by distance -->
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/sortByDistanceAscending"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:background="@color/transparent"
|
||||||
|
android:paddingStart="@dimen/standard_padding"
|
||||||
|
android:paddingTop="@dimen/standard_half_padding"
|
||||||
|
android:paddingEnd="@dimen/standard_half_padding"
|
||||||
|
android:paddingBottom="@dimen/standard_half_padding"
|
||||||
|
android:contentDescription="@string/menu_item_sort_by_distance_nearest_first"
|
||||||
|
android:src="@drawable/ic_distance_asc"
|
||||||
|
app:tint="@color/selector_item_unselected"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/sortByDistanceAscendingText"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:ellipsize="middle"
|
||||||
|
android:paddingStart="@dimen/zero"
|
||||||
|
android:paddingTop="@dimen/standard_half_padding"
|
||||||
|
android:paddingEnd="@dimen/standard_half_padding"
|
||||||
|
android:paddingBottom="@dimen/standard_half_padding"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="@string/menu_item_sort_by_distance_nearest_first"
|
||||||
|
android:textSize="@dimen/two_line_primary_text_size"
|
||||||
|
android:textColor="@color/selector_item_unselected" />
|
||||||
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
@@ -125,7 +205,9 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/common_cancel"
|
android:text="@string/common_cancel"
|
||||||
android:layout_marginTop="@dimen/standard_half_margin"/>
|
android:textAllCaps="false"
|
||||||
|
android:layout_marginTop="@dimen/standard_half_margin"
|
||||||
|
style="@style/Widget.AppCompat.Button.ButtonBar.AlertDialog"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 962 B |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
@@ -0,0 +1,112 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Nextcloud Maps Geofavorites for Android
|
||||||
|
~
|
||||||
|
~ This program is free software: you can redistribute it and/or modify
|
||||||
|
~ it under the terms of the GNU General Public License as published by
|
||||||
|
~ the Free Software Foundation, either version 3 of the License, or
|
||||||
|
~ (at your option) any later version.
|
||||||
|
~
|
||||||
|
~ This program is distributed in the hope that it will be useful,
|
||||||
|
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
~ GNU General Public License for more details.
|
||||||
|
~
|
||||||
|
~ You should have received a copy of the GNU General Public License
|
||||||
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<!-- App strings -->
|
||||||
|
<string name="app_name">Maps Geofavorites</string>
|
||||||
|
<string name="welcome">Benvenuto su Nextcloud Maps Geofavorites</string>
|
||||||
|
|
||||||
|
<!-- Login Activity -->
|
||||||
|
<string name="choose_account">Scegli account</string>
|
||||||
|
|
||||||
|
<!-- Geofavorites list -->
|
||||||
|
<string name="new_geobookmark">Nuovo geosegnalibro</string>
|
||||||
|
<string name="about">Informazioni</string>
|
||||||
|
<string name="switch_account">Cambia account</string>
|
||||||
|
<string name="list_mode">Lista</string>
|
||||||
|
<string name="search_in_all">Cerca per nome</string>
|
||||||
|
<string name="share_via">Condividi via</string>
|
||||||
|
<string name="share_message">{title}: {lat}°N, {lng}°E https://www.openstreetmap.org/#map=17/{lat}/{lng}</string>
|
||||||
|
<string name="share_message_default_title">Posizione condivisa:</string>
|
||||||
|
<string name="list_context_menu_share">Condividi</string>
|
||||||
|
<string name="list_context_menu_delete">Elimina</string>
|
||||||
|
<string name="dialog_delete_title">Elimina geosegnalibro</string>
|
||||||
|
<string name="dialog_delete_message">Stai per eliminare il geosegnalibro {name}. Procedere?</string>
|
||||||
|
<string name="dialog_delete_delete">Elimina</string>
|
||||||
|
<string name="dialog_delete_cancel">Mantieni</string>
|
||||||
|
<string name="dialog_logout_title">Cambia account</string>
|
||||||
|
<string name="dialog_logout_message">Vuoi cambiare account?</string>
|
||||||
|
<string name="list_geofavorite_deleted">Geosegnalibro eliminato</string>
|
||||||
|
<string name="list_geofavorite_connection_error">Impossibile ottenere la lista dei geosegnalibri</string>
|
||||||
|
<string name="filtering_unavailable">Il filtro per categoria non è disponibile al momento</string>
|
||||||
|
<string name="filtering_dialog_title">Filtra per categoria</string>
|
||||||
|
<string name="filtering_dialog_cancel">Mostra tutti</string>
|
||||||
|
|
||||||
|
<!-- Sort dialog -->
|
||||||
|
<string name="sort_by">Ordina per</string>
|
||||||
|
<string name="menu_item_sort_by_title_a_z">A - Z</string>
|
||||||
|
<string name="menu_item_sort_by_date_newest_first">Più recenti</string>
|
||||||
|
<string name="menu_item_sort_by_category_a_z">Categoria</string>
|
||||||
|
<string name="menu_item_sort_by_distance_nearest_first">Distanza</string>
|
||||||
|
|
||||||
|
<!-- Geofavorites detail -->
|
||||||
|
<string name="name">Nome</string>
|
||||||
|
<string name="description">Descrizione</string>
|
||||||
|
<string name="created">Creato</string>
|
||||||
|
<string name="modified">Modificato</string>
|
||||||
|
<string name="category">Categoria</string>
|
||||||
|
<string name="coords">Coordinate</string>
|
||||||
|
<string name="accuracy">Accuratezza: {accuracy} m</string>
|
||||||
|
<string name="accuracy_nosignal">Nessun segnale GPS!</string>
|
||||||
|
<string name="location_permission_required">Per creare un geosegnalibro è necessario consentire l\'accesso alla posizione.</string>
|
||||||
|
<string name="category_hint">Scrivi il nome per creare una nuova categoria</string>
|
||||||
|
<string name="error_saving_geofavorite">Impossibile salvare il geosegnalibro</string>
|
||||||
|
<string name="error_unsupported_uri">Impossibile ottenere le coordinate dai dati ricevuti</string>
|
||||||
|
<string name="geofavorite_saved">Geosegnalibro salvato</string>
|
||||||
|
<string name="incomplete_geofavorite">Geosegnalibro incompleto: nome e categoria sono obbligatori</string>
|
||||||
|
<string name="coords_copied">Coordinate copiate nella clipboard</string>
|
||||||
|
|
||||||
|
<!-- Map picker activity -->
|
||||||
|
<string name="coordinates_parse_error">Le coordinate dovrebbero essere nel formato xx.xxxxxx</string>
|
||||||
|
<string name="coordinates_invalid_error">Coordinate non valide</string>
|
||||||
|
<string name="coordinates_north">°N</string>
|
||||||
|
<string name="coordinates_east">°E</string>
|
||||||
|
|
||||||
|
<!-- About -->
|
||||||
|
<string name="about_version_title">Versione</string>
|
||||||
|
<string name="about_version">Stai usando la versione <strong>%1$s</strong></string>
|
||||||
|
<string name="about_source_title">Codice sorgente</string>
|
||||||
|
<string name="about_source">Questo progetto è disponibile su GitHub: <a href="%1$s">%1$s</a></string>
|
||||||
|
<string name="about_issues_title">Segnalazioni</string>
|
||||||
|
<string name="about_issues">Puoi segnalare bugs, proporre migliorie o richiedere nuove funzionalità sul GitHub issue tracker: <a href="%1$s">%1$s</a></string>
|
||||||
|
<string name="about_maps_title">Mappe</string>
|
||||||
|
<string name="about_maps">Questa app usa i server e le tiles di OpenStreetMap. Non accetto donazioni per questa app, ma raccomando piuttosto di donare a <a href="%1$s">OpenStreetMap</a>, poiché questa applicazione non potrebbe esistere senza di loro.</string>
|
||||||
|
<string name="about_app_license_title">Licenza</string>
|
||||||
|
<string name="about_app_license">Questa applicazione è rilasciata sotto licenza GNU GENERAL PUBLIC LICENSE v3+.</string>
|
||||||
|
<string name="about_app_license_button">Mostra licenza</string>
|
||||||
|
|
||||||
|
<!-- Common strings -->
|
||||||
|
<string name="common_yes">Si</string>
|
||||||
|
<string name="common_cancel">Annulla</string>
|
||||||
|
|
||||||
|
<!-- URLs -->
|
||||||
|
<string name="url_source" translatable="false">https://github.com/penguin86/nextcloud-maps-client</string>
|
||||||
|
<string name="url_issues" translatable="false">https://github.com/penguin86/nextcloud-maps-client/issues</string>
|
||||||
|
<string name="url_license" translatable="false">https://raw.githubusercontent.com/penguin86/nextcloud-maps-client/master/LICENSE</string>
|
||||||
|
<string name="url_maps" translatable="false">https://donate.openstreetmap.org</string>
|
||||||
|
|
||||||
|
<!-- Menu -->
|
||||||
|
<string name="new_geobookmark_gps">Crea dalla posizione corrente</string>
|
||||||
|
<string name="new_geobookmark_map">Crea dalla mappa</string>
|
||||||
|
|
||||||
|
<!-- Accessibility (content descriptions) -->
|
||||||
|
<string name="open_fab">Aggiungi</string>
|
||||||
|
<string name="add_from_gps">Crea dalla posizione corrente</string>
|
||||||
|
<string name="add_from_map">Crea dalla mappa</string>
|
||||||
|
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="text_color">#eee</color>
|
||||||
|
<color name="disabled">#888</color>
|
||||||
|
<color name="defaultBackground">#000</color>
|
||||||
|
<color name="translucent">#C000</color>
|
||||||
|
|
||||||
|
<!-- Toolbar -->
|
||||||
|
<color name="toolbar_background">#211e28</color>
|
||||||
|
</resources>
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="AppTheme" parent="BaseTheme">
|
<style name="AppTheme" parent="BaseTheme">
|
||||||
<item name="android:statusBarColor">?attr/colorPrimary</item>
|
<item name="android:statusBarColor">?android:attr/colorPrimary</item>
|
||||||
<item name="android:windowLightStatusBar">true</item>
|
<item name="android:windowLightStatusBar">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -19,9 +19,9 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="AppTheme" parent="BaseTheme">
|
<style name="AppTheme" parent="BaseTheme">
|
||||||
<item name="android:statusBarColor">?attr/colorPrimary</item>
|
<item name="android:statusBarColor">?android:attr/colorPrimary</item>
|
||||||
<item name="android:windowLightStatusBar">true</item>
|
<item name="android:windowLightStatusBar">true</item>
|
||||||
<item name="android:navigationBarColor">?attr/colorPrimary</item>
|
<item name="android:navigationBarColor">?android:attr/colorPrimary</item>
|
||||||
<item name="android:windowLightNavigationBar">true</item>
|
<item name="android:windowLightNavigationBar">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -19,17 +19,26 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<!-- Generic Colors -->
|
<!-- Generic Colors -->
|
||||||
<color name="primary">#ffffff</color>
|
<color name="primary">#ffffff</color>
|
||||||
<color name="accent">#121212</color>
|
|
||||||
<color name="transparent">#00000000</color>
|
<color name="transparent">#00000000</color>
|
||||||
|
<color name="translucent">#AEFFFFFF</color>
|
||||||
<color name="defaultBrand">#0082C9</color>
|
<color name="defaultBrand">#0082C9</color>
|
||||||
<color name="defaultBrandAlpha">#550082C9</color>
|
<color name="defaultBrandAlpha">#550082C9</color>
|
||||||
<color name="appbar">@android:color/white</color>
|
<color name="disabled">#666</color>
|
||||||
<color name="defaultTint">#202124</color>
|
<color name="systemBar">@color/defaultBackground</color>
|
||||||
|
<color name="defaultBackground">#fff</color>
|
||||||
|
<color name="inactive">#ccc</color>
|
||||||
|
|
||||||
<!-- List Colors -->
|
<!-- List Colors -->
|
||||||
<color name="text_color">#333333</color>
|
<color name="text_color">#333</color>
|
||||||
<color name="secondary_text_color">#666666</color>
|
<color name="secondary_text_color">@color/disabled</color>
|
||||||
|
|
||||||
|
<!-- Selectors text/tint colors -->
|
||||||
|
<color name="selector_item_selected">@color/defaultBrand</color>
|
||||||
|
<color name="selector_item_unselected">@color/disabled</color>
|
||||||
|
|
||||||
<!-- Generic Colors -->
|
<!-- Generic Colors -->
|
||||||
<color name="white">#fff</color>
|
<color name="white">#fff</color>
|
||||||
|
|
||||||
|
<!-- Toolbar -->
|
||||||
|
<color name="toolbar_background">@color/defaultBackground</color>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -36,4 +36,10 @@
|
|||||||
<dimen name="two_line_primary_text_size">16sp</dimen>
|
<dimen name="two_line_primary_text_size">16sp</dimen>
|
||||||
<dimen name="two_line_secondary_text_size">12sp</dimen>
|
<dimen name="two_line_secondary_text_size">12sp</dimen>
|
||||||
|
|
||||||
|
<!-- FAB dimensions -->
|
||||||
|
<dimen name="fab_vertical_offset">75dp</dimen>
|
||||||
|
|
||||||
|
<!-- Floating bar below search bar -->
|
||||||
|
<dimen name="floating_bar_height">36dp</dimen>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -17,36 +17,43 @@
|
|||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<!-- App strings -->
|
<!-- App strings -->
|
||||||
<string name="app_name">Maps Geobookmarks</string>
|
<string name="app_name">Maps Geofavorites</string>
|
||||||
<string name="welcome">Welcome to Nextcloud Maps Geobookmarks</string>
|
<string name="welcome">Welcome to Nextcloud Maps Geofavorites</string>
|
||||||
|
|
||||||
<!-- Login Activity -->
|
<!-- Login Activity -->
|
||||||
<string name="choose_account">Choose account</string>
|
<string name="choose_account">Choose account</string>
|
||||||
|
|
||||||
<!-- Geobookmarks list -->
|
<!-- Geofavorites list -->
|
||||||
<string name="new_geobookmark">New geobookmark</string>
|
<string name="new_geobookmark">New geofavorite</string>
|
||||||
<string name="about">About</string>
|
<string name="about">About</string>
|
||||||
<string name="switch_account">Switch account</string>
|
<string name="switch_account">Switch account</string>
|
||||||
<string name="list_mode">List</string>
|
<string name="list_mode">List</string>
|
||||||
<string name="search_in_all">Search by name</string>
|
<string name="search_in_all">Search by name</string>
|
||||||
<string name="share_via">Share via</string>
|
<string name="share_via">Share via</string>
|
||||||
<string name="share_message">Check out this place: {lat}°N, {lng}°E https://www.openstreetmap.org/#map=17/{lat}/{lng}</string>
|
<string name="share_message">{title}: {lat}°N, {lng}°E https://www.openstreetmap.org/#map=17/{lat}/{lng}</string>
|
||||||
|
<string name="share_message_default_title">Check out this place:</string>
|
||||||
<string name="list_context_menu_share">Share</string>
|
<string name="list_context_menu_share">Share</string>
|
||||||
<string name="list_context_menu_delete">Delete</string>
|
<string name="list_context_menu_delete">Delete</string>
|
||||||
<string name="dialog_delete_title">Delete geobookmark</string>
|
<string name="dialog_delete_title">Delete geofavorite</string>
|
||||||
<string name="dialog_delete_message">You are about to delete geobookmark {name}. Proceed?</string>
|
<string name="dialog_delete_message">You are about to delete geofavorite {name}. Proceed?</string>
|
||||||
<string name="dialog_delete_delete">Delete</string>
|
<string name="dialog_delete_delete">Delete</string>
|
||||||
<string name="dialog_delete_cancel">Maintain</string>
|
<string name="dialog_delete_cancel">Maintain</string>
|
||||||
|
<string name="dialog_logout_title">Switch account</string>
|
||||||
|
<string name="dialog_logout_message">Do you want to switch account?</string>
|
||||||
<string name="list_geofavorite_deleted">Geofavorite deleted</string>
|
<string name="list_geofavorite_deleted">Geofavorite deleted</string>
|
||||||
<string name="list_geofavorite_connection_error">Unable to obtain geofavorites list</string>
|
<string name="list_geofavorite_connection_error">Unable to obtain geofavorites list</string>
|
||||||
|
<string name="filtering_unavailable">Category filtering is unavailable at the moment</string>
|
||||||
|
<string name="filtering_dialog_title">Filter by category</string>
|
||||||
|
<string name="filtering_dialog_cancel">Show all</string>
|
||||||
|
|
||||||
<!-- Sort dialog -->
|
<!-- Sort dialog -->
|
||||||
<string name="sort_by">Sort by</string>
|
<string name="sort_by">Sort by</string>
|
||||||
<string name="menu_item_sort_by_title_a_z">A - Z</string>
|
<string name="menu_item_sort_by_title_a_z">A - Z</string>
|
||||||
<string name="menu_item_sort_by_date_newest_first">Newest first</string>
|
<string name="menu_item_sort_by_date_newest_first">Newest first</string>
|
||||||
<string name="menu_item_sort_by_distance">Distance</string>
|
<string name="menu_item_sort_by_category_a_z">Category</string>
|
||||||
|
<string name="menu_item_sort_by_distance_nearest_first">Distance</string>
|
||||||
|
|
||||||
<!-- Geobookmarks detail -->
|
<!-- Geofavorites detail -->
|
||||||
<string name="name">Name</string>
|
<string name="name">Name</string>
|
||||||
<string name="description">Description</string>
|
<string name="description">Description</string>
|
||||||
<string name="created">Created</string>
|
<string name="created">Created</string>
|
||||||
@@ -54,10 +61,20 @@
|
|||||||
<string name="category">Category</string>
|
<string name="category">Category</string>
|
||||||
<string name="coords">Coordinates</string>
|
<string name="coords">Coordinates</string>
|
||||||
<string name="accuracy">Accuracy: {accuracy} m</string>
|
<string name="accuracy">Accuracy: {accuracy} m</string>
|
||||||
|
<string name="accuracy_nosignal">No GPS signal!</string>
|
||||||
<string name="location_permission_required">Location permission is required to create a geofavorite.</string>
|
<string name="location_permission_required">Location permission is required to create a geofavorite.</string>
|
||||||
<string name="confirm">Save</string>
|
<string name="category_hint">Write the name to create a new category</string>
|
||||||
<string name="error_saving_geofavorite">Unable to save geofavorite</string>
|
<string name="error_saving_geofavorite">Unable to save geofavorite</string>
|
||||||
<string name="incomplete_geofavorite">Incomplete geofavorite: Name and GPS coordinates are mandatory</string>
|
<string name="error_unsupported_uri">Unable to obtain coordinates from shared data</string>
|
||||||
|
<string name="geofavorite_saved">Geofavorite saved</string>
|
||||||
|
<string name="incomplete_geofavorite">Incomplete geofavorite: Name and category are mandatory</string>
|
||||||
|
<string name="coords_copied">Coordinates have been copied to the clipboard</string>
|
||||||
|
|
||||||
|
<!-- Map picker activity -->
|
||||||
|
<string name="coordinates_parse_error">Coordinates should be in format xx.xxxxxx</string>
|
||||||
|
<string name="coordinates_invalid_error">Invalid coordinates</string>
|
||||||
|
<string name="coordinates_north">°N</string>
|
||||||
|
<string name="coordinates_east">°E</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about_version_title">Version</string>
|
<string name="about_version_title">Version</string>
|
||||||
@@ -66,6 +83,8 @@
|
|||||||
<string name="about_source">This project is hosted on GitHub: <a href="%1$s">%1$s</a></string>
|
<string name="about_source">This project is hosted on GitHub: <a href="%1$s">%1$s</a></string>
|
||||||
<string name="about_issues_title">Issues</string>
|
<string name="about_issues_title">Issues</string>
|
||||||
<string name="about_issues">You can report bugs, enhancement proposals and feature requests at the GitHub issue tracker: <a href="%1$s">%1$s</a></string>
|
<string name="about_issues">You can report bugs, enhancement proposals and feature requests at the GitHub issue tracker: <a href="%1$s">%1$s</a></string>
|
||||||
|
<string name="about_maps_title">Maps</string>
|
||||||
|
<string name="about_maps">This app uses Open Street Maps tiles and servers to display the map. I do not accept any donation for this app, but strongly encourage to make any donation to <a href="%1$s">OpenStreetMap</a>, as this application could not exist without them.</string>
|
||||||
<string name="about_app_license_title">App license</string>
|
<string name="about_app_license_title">App license</string>
|
||||||
<string name="about_app_license">This application is licensed under the GNU GENERAL PUBLIC LICENSE v3+.</string>
|
<string name="about_app_license">This application is licensed under the GNU GENERAL PUBLIC LICENSE v3+.</string>
|
||||||
<string name="about_app_license_button">View license</string>
|
<string name="about_app_license_button">View license</string>
|
||||||
@@ -76,11 +95,22 @@
|
|||||||
|
|
||||||
<!-- URLs -->
|
<!-- URLs -->
|
||||||
<string name="url_source" translatable="false">https://github.com/penguin86/nextcloud-maps-client</string>
|
<string name="url_source" translatable="false">https://github.com/penguin86/nextcloud-maps-client</string>
|
||||||
<string name="url_issues" translatable="false">https://github.com/penguin86/nextcloud-maps-client/issues/new/choose</string>
|
<string name="url_issues" translatable="false">https://github.com/penguin86/nextcloud-maps-client/issues</string>
|
||||||
<string name="url_license" translatable="false">https://raw.githubusercontent.com/penguin86/nextcloud-maps-client/master/LICENSE</string>
|
<string name="url_license" translatable="false">https://raw.githubusercontent.com/penguin86/nextcloud-maps-client/master/LICENSE</string>
|
||||||
|
<string name="url_maps" translatable="false">https://donate.openstreetmap.org</string>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<string name="setting_sort_by">SETTING_SORT_BY</string>
|
<string name="settings">Settings</string>
|
||||||
<string name="setting_grid_view_enabled">SETTING_GRID_VIEW_ENABLED</string>
|
<string name="settings_use_google_maps">Always open with Google Maps</string>
|
||||||
|
<string name="settings_use_google_maps_summary">When disabled, a generic geo: URI will be used instead</string>
|
||||||
|
|
||||||
|
<!-- Menu -->
|
||||||
|
<string name="new_geobookmark_gps">New from current position</string>
|
||||||
|
<string name="new_geobookmark_map">New from map</string>
|
||||||
|
|
||||||
|
<!-- Accessibility (content descriptions) -->
|
||||||
|
<string name="open_fab">Add geofavorite</string>
|
||||||
|
<string name="add_from_gps">Add geofavorite at current GPS position</string>
|
||||||
|
<string name="add_from_map">Add geofavorite from map</string>
|
||||||
|
<string name="menu">Open menu</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -17,38 +17,28 @@
|
|||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="BaseTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
|
<style name="BaseTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||||
<!-- Customize your theme here. -->
|
<item name="colorAccent">@color/defaultBrand</item>
|
||||||
<item name="colorPrimary">@color/primary</item>
|
<item name="colorControlNormal">?android:attr/colorAccent</item>
|
||||||
<!-- <item name="android:textColorPrimary">@color/white</item>-->
|
|
||||||
<item name="colorPrimaryDark">@color/primary</item>
|
|
||||||
<item name="colorAccent">@color/accent</item>
|
|
||||||
<item name="android:actionModeBackground">?attr/colorPrimary</item>
|
|
||||||
<item name="colorControlNormal">?attr/colorAccent</item>
|
|
||||||
<item name="windowActionModeOverlay">true</item>
|
<item name="windowActionModeOverlay">true</item>
|
||||||
<item name="toolbarStyle">@style/toolbarStyle</item>
|
<!-- App bar -->
|
||||||
|
<item name="colorPrimary">@color/systemBar</item>
|
||||||
|
<!-- Generic background -->
|
||||||
|
<item name="android:windowBackground">@color/defaultBackground</item>
|
||||||
|
|
||||||
|
<item name="alertDialogTheme">@style/AlertDialogTheme</item>
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppTheme" parent="BaseTheme"/>
|
<style name="AppTheme" parent="BaseTheme"/>
|
||||||
|
|
||||||
<style name="EditorTheme" parent="Theme.AppCompat.DayNight.DarkActionBar">
|
<style name="SplashTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
|
||||||
<!-- Customize your theme here. -->
|
|
||||||
<item name="colorPrimary">@android:color/transparent</item>
|
|
||||||
<item name="colorPrimaryDark">@color/accent</item>
|
|
||||||
<item name="colorAccent">@color/accent</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
<item name="windowActionBar">false</item>
|
<item name="windowActionBar">false</item>
|
||||||
<item name="windowNoTitle">true</item>
|
<item name="windowNoTitle">true</item>
|
||||||
<item name="android:windowFullscreen">true</item>
|
<item name="android:windowFullscreen">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="toolbarStyle" parent="@style/Widget.AppCompat.Toolbar">
|
|
||||||
<item name="android:background">?attr/colorPrimary</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<!-- Geofavorite detail text appearances -->
|
<!-- Geofavorite detail text appearances -->
|
||||||
|
|
||||||
<style name="TextAppearance.GeofavoriteDetail.Header.Expanded" parent="TextAppearance.Design.CollapsingToolbar.Expanded">
|
<style name="TextAppearance.GeofavoriteDetail.Header.Expanded" parent="TextAppearance.Design.CollapsingToolbar.Expanded">
|
||||||
@@ -60,4 +50,22 @@
|
|||||||
<item name="android:textColor">@color/white</item>
|
<item name="android:textColor">@color/white</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="TextAppearance.GeofavoriteInfowindow" parent="TextAppearance.AppCompat.Title">
|
||||||
|
<item name="android:textColor">@color/white</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<!-- Alertdialogs -->
|
||||||
|
<style name="AlertDialogTheme" parent="ThemeOverlay.MaterialComponents.Dialog.Alert">
|
||||||
|
<item name="buttonBarNegativeButtonStyle">@style/NegativeButtonStyle</item>
|
||||||
|
<item name="buttonBarPositiveButtonStyle">@style/PositiveButtonStyle</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="NegativeButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
|
||||||
|
<item name="android:textColor">@color/inactive</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="PositiveButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
|
||||||
|
<item name="android:textColor">@color/defaultBrand</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -22,10 +22,10 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.2.2'
|
classpath 'com.android.tools.build:gradle:9.2.1'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
@@ -35,7 +35,7 @@ buildscript {
|
|||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||