~samwhited/oslp

94b5c4a96116b88d39ea78b9d8dd62b3046a3997 — Sam Whited 3 years ago dfe2de7
Allow opening geo URIs from other apps
M src/main/AndroidManifest.xml => src/main/AndroidManifest.xml +19 -14
@@ 1,8 1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          package="com.samwhited.opensharelocationplugin"
          android:installLocation="auto" >
    xmlns:tools="http://schemas.android.com/tools"
    package="com.samwhited.opensharelocationplugin"
    android:installLocation="auto">

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />


@@ 13,15 13,18 @@
    <application
        android:allowBackup="true"
        android:fullBackupContent="true"
        android:supportsRtl="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/ConversationsTheme"
        tools:ignore="UnusedAttribute">
        <meta-data android:name="THUNDERFOREST_MAPID" android:value="${apiKey}" />
        <meta-data
            android:name="THUNDERFOREST_MAPID"
            android:value="${apiKey}" />

        <activity
            android:name=".activities.ShareLocationActivity"
            android:label="@string/title_activity_share_location" >
            android:label="@string/title_activity_share_location">
            <intent-filter>
                <action android:name="eu.siacs.conversations.location.request" />



@@ 30,28 33,30 @@
        </activity>
        <activity
            android:name=".activities.ShowLocationActivity"
            android:label="@string/title_activity_show_location" >
            android:label="@string/title_activity_show_location">
            <intent-filter>
                <action android:name="eu.siacs.conversations.location.show" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <data android:scheme="geo" />

                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
                <data android:scheme="geo" />
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
            </intent-filter>
        </activity>
        <activity
            android:name=".activities.AboutActivity"
            android:label="@string/title_activity_about" >
        </activity>
            android:label="@string/title_activity_about" />
        <activity
            android:name=".activities.SettingsActivity"
            android:label="@string/title_activity_settings" >
        </activity>
            android:label="@string/title_activity_settings" />
    </application>

</manifest>

M src/main/java/com/samwhited/opensharelocationplugin/activities/ShowLocationActivity.java => src/main/java/com/samwhited/opensharelocationplugin/activities/ShowLocationActivity.java +19 -18
@@ 81,29 81,30 @@ public class ShowLocationActivity extends LocationActivity implements LocationLi
					// Attempt to set zoom level if the geo URI specifies it
					if (geoUri != null) {
						final HashMap<String, String> query = UriHelper.parseQueryString(geoUri.getQuery());

						// Check for zoom level.
						final String z = query.get("z");
						if (z != null) {
							try {
								mapController.setZoom(Double.valueOf(z));
							} catch (final Exception ignored) {
							}
						}

						// Check for the actual geo query.
						boolean posInQuery = false;
						final String q = query.get("q");
						if (q != null) {
							final Pattern latlng = Pattern.compile("/^([-+]?[0-9]+(\\.[0-9]+)?),([-+]?[0-9]+(\\.[0-9]+)?)(\\(.*\\))?/");
							final Matcher m = latlng.matcher(q);
							if (m.matches()) {
						if (query != null) {
							// Check for zoom level.
							final String z = query.get("z");
							if (z != null) {
								try {
									this.loc = new GeoPoint(Double.valueOf(m.group(1)), Double.valueOf(m.group(3)));
									posInQuery = true;
									mapController.setZoom(Double.valueOf(z));
								} catch (final Exception ignored) {
								}
							}

							// Check for the actual geo query.
							final String q = query.get("q");
							if (q != null) {
								final Pattern latlng = Pattern.compile("/^([-+]?[0-9]+(\\.[0-9]+)?),([-+]?[0-9]+(\\.[0-9]+)?)(\\(.*\\))?/");
								final Matcher m = latlng.matcher(q);
								if (m.matches()) {
									try {
										this.loc = new GeoPoint(Double.valueOf(m.group(1)), Double.valueOf(m.group(3)));
										posInQuery = true;
									} catch (final Exception ignored) {
									}
								}
							}
						}

						final String schemeSpecificPart = geoUri.getSchemeSpecificPart();