WIP accepting generic intents with geo:// uri
This commit is contained in:
parent
15cea67818
commit
96b88a398c
17
.idea/deploymentTargetDropDown.xml
Normal file
17
.idea/deploymentTargetDropDown.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="deploymentTargetDropDown">
|
||||||
|
<runningDeviceTargetSelectedWithDropDown>
|
||||||
|
<Target>
|
||||||
|
<type value="RUNNING_DEVICE_TARGET" />
|
||||||
|
<deviceKey>
|
||||||
|
<Key>
|
||||||
|
<type value="VIRTUAL_DEVICE_PATH" />
|
||||||
|
<value value="$USER_HOME$/.android/avd/Nexus_4_API_30.avd" />
|
||||||
|
</Key>
|
||||||
|
</deviceKey>
|
||||||
|
</Target>
|
||||||
|
</runningDeviceTargetSelectedWithDropDown>
|
||||||
|
<timeTargetWasSelectedWithDropDown value="2021-09-30T18:16:49.313988Z" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -17,5 +17,3 @@ This work is heavily based on [matiasdelellis's Nextcloud SSO example](https://g
|
|||||||
|
|
||||||
![Screenshot 1](screenshots/1.png) ![Screenshot 1](screenshots/2.png)
|
![Screenshot 1](screenshots/1.png) ![Screenshot 1](screenshots/2.png)
|
||||||
|
|
||||||
Download it from [the releases page](https://github.com/penguin86/nextcloud-maps-client/releases)
|
|
||||||
|
|
||||||
|
@ -50,7 +50,17 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.detail.GeofavoriteDetailActivity"
|
android:name=".activity.detail.GeofavoriteDetailActivity"
|
||||||
android:theme="@style/AppTheme"/>
|
android:theme="@style/AppTheme">
|
||||||
|
<!-- 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>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.about.AboutActivity"
|
android:name=".activity.about.AboutActivity"
|
||||||
|
@ -59,6 +59,7 @@ import it.danieleverducci.nextcloudmaps.activity.main.MainActivityViewModel;
|
|||||||
import it.danieleverducci.nextcloudmaps.api.ApiProvider;
|
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 retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
@ -158,9 +159,20 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
|
|||||||
mGeofavorite.setDateModified(System.currentTimeMillis() / 1000);
|
mGeofavorite.setDateModified(System.currentTimeMillis() / 1000);
|
||||||
mViewHolder.hideActions();
|
mViewHolder.hideActions();
|
||||||
|
|
||||||
// Precompile location
|
if (getIntent().getData() != null) {
|
||||||
|
// Opened by external generic intent: parse URI
|
||||||
|
try {
|
||||||
|
double[] coords = GeoUriParser.parseUri(getIntent().getData());
|
||||||
|
mGeofavorite.setLat(coords[0]);
|
||||||
|
mGeofavorite.setLng(coords[1]);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Toast.makeText(this, R.string.error_unsupported_uri, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Precompile location with current one
|
||||||
getLocation();
|
getLocation();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mViewHolder.updateView(mGeofavorite);
|
mViewHolder.updateView(mGeofavorite);
|
||||||
|
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package it.danieleverducci.nextcloudmaps.utils;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
|
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.]+");
|
||||||
|
|
||||||
|
public static double[] parseUri(Uri uri) throws IllegalArgumentException {
|
||||||
|
Matcher m = PATTERN_GEO.matcher(uri.getPath());
|
||||||
|
if (m.find()) {
|
||||||
|
return new double[]{0, 0};
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("unable to parse uri");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -58,6 +58,7 @@
|
|||||||
<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="confirm">Save</string>
|
||||||
<string name="error_saving_geofavorite">Unable to save geofavorite</string>
|
<string name="error_saving_geofavorite">Unable to save geofavorite</string>
|
||||||
|
<string name="error_unsupported_uri">Unable to obtain coordinates from shared data</string>
|
||||||
<string name="geofavorite_saved">Geofavorite saved</string>
|
<string name="geofavorite_saved">Geofavorite saved</string>
|
||||||
<string name="incomplete_geofavorite">Incomplete geofavorite: Name and category are mandatory</string>
|
<string name="incomplete_geofavorite">Incomplete geofavorite: Name and category are mandatory</string>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user