make show location depend on plugin setting
This commit is contained in:
parent
8e17fa285d
commit
949b77c353
|
@ -3,60 +3,72 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="eu.siacs.conversations">
|
package="eu.siacs.conversations">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
||||||
<uses-permission android:name="android.permission.READ_PROFILE" />
|
<uses-permission android:name="android.permission.READ_PROFILE"/>
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
<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"/>
|
||||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||||
|
|
||||||
<uses-feature android:name="android.hardware.location" android:required="false" />
|
<uses-feature
|
||||||
<uses-feature android:name="android.hardware.location.gps" android:required="false" />
|
android:name="android.hardware.location"
|
||||||
<uses-feature android:name="android.hardware.location.network" android:required="false" />
|
android:required="false"/>
|
||||||
|
<uses-feature
|
||||||
|
android:name="android.hardware.location.gps"
|
||||||
|
android:required="false"/>
|
||||||
|
<uses-feature
|
||||||
|
android:name="android.hardware.location.network"
|
||||||
|
android:required="false"/>
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA"/>
|
||||||
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
||||||
|
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.READ_PHONE_STATE"
|
android:name="android.permission.READ_PHONE_STATE"
|
||||||
tools:node="remove" />
|
tools:node="remove"/>
|
||||||
|
|
||||||
<uses-sdk tools:overrideLibrary="net.ypresto.androidtranscoder" />
|
<uses-sdk tools:overrideLibrary="net.ypresto.androidtranscoder"/>
|
||||||
|
|
||||||
<uses-feature android:name="android.hardware.camera" android:required="false" />
|
<uses-feature
|
||||||
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
|
android:name="android.hardware.camera"
|
||||||
|
android:required="false"/>
|
||||||
|
<uses-feature
|
||||||
|
android:name="android.hardware.camera.autofocus"
|
||||||
|
android:required="false"/>
|
||||||
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:networkSecurityConfig="@xml/network_security_configuration"
|
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
android:appCategory="social"
|
||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
android:networkSecurityConfig="@xml/network_security_configuration"
|
||||||
android:theme="@style/ConversationsTheme"
|
android:theme="@style/ConversationsTheme"
|
||||||
android:appCategory="social"
|
|
||||||
tools:replace="android:label"
|
tools:replace="android:label"
|
||||||
tools:targetApi="o">
|
tools:targetApi="o">
|
||||||
|
|
||||||
<meta-data android:name="com.google.android.gms.car.application"
|
<meta-data
|
||||||
android:resource="@xml/automotive_app_desc" />
|
android:name="com.google.android.gms.car.application"
|
||||||
|
android:resource="@xml/automotive_app_desc"/>
|
||||||
|
|
||||||
<service android:name=".services.XmppConnectionService" />
|
<service android:name=".services.XmppConnectionService"/>
|
||||||
|
|
||||||
<receiver android:name=".services.EventReceiver">
|
<receiver android:name=".services.EventReceiver">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||||
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
|
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
|
||||||
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
|
<action android:name="android.intent.action.ACTION_SHUTDOWN"/>
|
||||||
<action android:name="android.media.RINGER_MODE_CHANGED" />
|
<action android:name="android.media.RINGER_MODE_CHANGED"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ShareLocationActivity"
|
android:name=".ui.ShareLocationActivity"
|
||||||
android:label="@string/title_activity_share_location"/>
|
android:label="@string/title_activity_share_location"/>
|
||||||
|
@ -65,71 +77,61 @@
|
||||||
android:label="@string/search_messages"/>
|
android:label="@string/search_messages"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.RecordingActivity"
|
android:name=".ui.RecordingActivity"
|
||||||
android:theme="@style/ConversationsTheme.Dialog"
|
android:configChanges="orientation|screenSize"
|
||||||
android:configChanges="orientation|screenSize"/>
|
android:theme="@style/ConversationsTheme.Dialog"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ShowLocationActivity"
|
android:name=".ui.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" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ConversationActivity"
|
android:name=".ui.ConversationActivity"
|
||||||
android:theme="@style/SplashTheme">
|
android:theme="@style/SplashTheme">
|
||||||
<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
|
<activity
|
||||||
android:name=".ui.ConversationsActivity"
|
android:name=".ui.ConversationsActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:minWidth="300dp"
|
|
||||||
android:minHeight="300dp"
|
android:minHeight="300dp"
|
||||||
android:windowSoftInputMode="stateHidden" />
|
android:minWidth="300dp"
|
||||||
|
android:windowSoftInputMode="stateHidden"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ScanActivity"
|
android:name=".ui.ScanActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/ConversationsTheme.FullScreen"
|
android:theme="@style/ConversationsTheme.FullScreen"
|
||||||
android:windowSoftInputMode="stateAlwaysHidden" />
|
android:windowSoftInputMode="stateAlwaysHidden"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.UriHandlerActivity"
|
android:name=".ui.UriHandlerActivity"
|
||||||
android:label="@string/title_activity_start_conversation">
|
android:label="@string/title_activity_start_conversation">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
|
|
||||||
<data android:scheme="xmpp" />
|
<data android:scheme="xmpp"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter android:autoVerify="true">
|
<intent-filter android:autoVerify="true">
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
|
|
||||||
<data android:scheme="https" />
|
<data android:scheme="https"/>
|
||||||
<data android:host="conversations.im" />
|
<data android:host="conversations.im"/>
|
||||||
<data android:pathPrefix="/i/" />
|
<data android:pathPrefix="/i/"/>
|
||||||
<data android:pathPrefix="/j/" />
|
<data android:pathPrefix="/j/"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.SENDTO" />
|
<action android:name="android.intent.action.SENDTO"/>
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
|
||||||
<data android:scheme="imto" />
|
<data android:scheme="imto"/>
|
||||||
<data android:host="jabber" />
|
<data android:host="jabber"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
|
@ -137,7 +139,7 @@
|
||||||
android:label="@string/title_activity_start_conversation"
|
android:label="@string/title_activity_start_conversation"
|
||||||
android:launchMode="singleTop">
|
android:launchMode="singleTop">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
|
@ -150,93 +152,93 @@
|
||||||
android:launchMode="singleTask"/>
|
android:launchMode="singleTask"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.SettingsActivity"
|
android:name=".ui.SettingsActivity"
|
||||||
android:label="@string/title_activity_settings" />
|
android:label="@string/title_activity_settings"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ChooseContactActivity"
|
android:name=".ui.ChooseContactActivity"
|
||||||
android:label="@string/title_activity_choose_contact" />
|
android:label="@string/title_activity_choose_contact"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.BlocklistActivity"
|
android:name=".ui.BlocklistActivity"
|
||||||
android:label="@string/title_activity_block_list" />
|
android:label="@string/title_activity_block_list"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ChangePasswordActivity"
|
android:name=".ui.ChangePasswordActivity"
|
||||||
android:label="@string/change_password_on_server" />
|
android:label="@string/change_password_on_server"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ManageAccountActivity"
|
android:name=".ui.ManageAccountActivity"
|
||||||
android:label="@string/title_activity_manage_accounts"
|
android:label="@string/title_activity_manage_accounts"
|
||||||
android:launchMode="singleTask" />
|
android:launchMode="singleTask"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ShareViaAccountActivity"
|
android:name=".ui.ShareViaAccountActivity"
|
||||||
android:label="@string/title_activity_share_via_account"
|
android:label="@string/title_activity_share_via_account"
|
||||||
android:launchMode="singleTop" />
|
android:launchMode="singleTop"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.EditAccountActivity"
|
android:name=".ui.EditAccountActivity"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
android:windowSoftInputMode="stateHidden|adjustResize"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ConferenceDetailsActivity"
|
android:name=".ui.ConferenceDetailsActivity"
|
||||||
android:windowSoftInputMode="stateHidden" />
|
android:windowSoftInputMode="stateHidden"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ContactDetailsActivity"
|
android:name=".ui.ContactDetailsActivity"
|
||||||
android:windowSoftInputMode="stateHidden" />
|
android:windowSoftInputMode="stateHidden"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.PublishProfilePictureActivity"
|
android:name=".ui.PublishProfilePictureActivity"
|
||||||
android:label="@string/mgmt_account_publish_avatar"
|
android:label="@string/mgmt_account_publish_avatar"
|
||||||
android:windowSoftInputMode="stateHidden" />
|
android:windowSoftInputMode="stateHidden"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ShareWithActivity"
|
android:name=".ui.ShareWithActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:launchMode="singleTop">
|
android:launchMode="singleTop">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.SEND" />
|
<action android:name="android.intent.action.SEND"/>
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
|
||||||
<data android:mimeType="text/plain" />
|
<data android:mimeType="text/plain"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.SEND" />
|
<action android:name="android.intent.action.SEND"/>
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
|
||||||
<data android:mimeType="*/*" />
|
<data android:mimeType="*/*"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.SEND_MULTIPLE" />
|
<action android:name="android.intent.action.SEND_MULTIPLE"/>
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
|
||||||
<data android:mimeType="image/*" />
|
<data android:mimeType="image/*"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.service.chooser.chooser_target_service"
|
android:name="android.service.chooser.chooser_target_service"
|
||||||
android:value=".services.ContactChooserTargetService" />
|
android:value=".services.ContactChooserTargetService"/>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.TrustKeysActivity"
|
android:name=".ui.TrustKeysActivity"
|
||||||
android:label="@string/trust_omemo_fingerprints"
|
android:label="@string/trust_omemo_fingerprints"
|
||||||
android:windowSoftInputMode="stateAlwaysHidden" />
|
android:windowSoftInputMode="stateAlwaysHidden"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.AboutActivity"
|
android:name=".ui.AboutActivity"
|
||||||
android:label="@string/title_activity_about"
|
android:label="@string/title_activity_about"
|
||||||
android:parentActivityName=".ui.SettingsActivity">
|
android:parentActivityName=".ui.SettingsActivity">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value="eu.siacs.conversations.ui.SettingsActivity" />
|
android:value="eu.siacs.conversations.ui.SettingsActivity"/>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
<category android:name="android.intent.category.PREFERENCE" />
|
<category android:name="android.intent.category.PREFERENCE"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="com.soundcloud.android.crop.CropImageActivity" />
|
<activity android:name="com.soundcloud.android.crop.CropImageActivity"/>
|
||||||
<activity android:name=".ui.MemorizingActivity"/>
|
<activity android:name=".ui.MemorizingActivity"/>
|
||||||
|
|
||||||
<service android:name=".services.ExportLogsService" />
|
<service android:name=".services.ExportLogsService"/>
|
||||||
<service
|
<service
|
||||||
android:name=".services.ContactChooserTargetService"
|
android:name=".services.ContactChooserTargetService"
|
||||||
android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE">
|
android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.service.chooser.ChooserTargetService" />
|
<action android:name="android.service.chooser.ChooserTargetService"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
@ -247,18 +249,19 @@
|
||||||
android:grantUriPermissions="true">
|
android:grantUriPermissions="true">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
android:resource="@xml/file_paths" />
|
android:resource="@xml/file_paths"/>
|
||||||
</provider>
|
</provider>
|
||||||
<provider
|
<provider
|
||||||
android:authorities="${applicationId}.barcodes"
|
|
||||||
android:name=".services.BarcodeProvider"
|
android:name=".services.BarcodeProvider"
|
||||||
|
android:authorities="${applicationId}.barcodes"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:grantUriPermissions="true"/>
|
android:grantUriPermissions="true"/>
|
||||||
|
|
||||||
<activity android:name=".ui.ShortcutActivity"
|
<activity
|
||||||
|
android:name=".ui.ShortcutActivity"
|
||||||
android:label="@string/contact">
|
android:label="@string/contact">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.CREATE_SHORTCUT" />
|
<action android:name="android.intent.action.CREATE_SHORTCUT"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
|
@ -603,7 +603,7 @@ public class NotificationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private PendingIntent createShowLocationIntent(final Message message) {
|
private PendingIntent createShowLocationIntent(final Message message) {
|
||||||
Iterable<Intent> intents = GeoHelper.createGeoIntentsFromMessage(message);
|
Iterable<Intent> intents = GeoHelper.createGeoIntentsFromMessage(mXmppConnectionService, message);
|
||||||
for (Intent intent : intents) {
|
for (Intent intent : intents) {
|
||||||
if (intent.resolveActivity(mXmppConnectionService.getPackageManager()) != null) {
|
if (intent.resolveActivity(mXmppConnectionService.getPackageManager()) != null) {
|
||||||
return PendingIntent.getActivity(mXmppConnectionService, generateRequestCode(message.getConversation(), 18), intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
return PendingIntent.getActivity(mXmppConnectionService, generateRequestCode(message.getConversation(), 18), intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
|
|
@ -965,7 +965,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showLocation(Message message) {
|
public void showLocation(Message message) {
|
||||||
for (Intent intent : GeoHelper.createGeoIntentsFromMessage(message)) {
|
for (Intent intent : GeoHelper.createGeoIntentsFromMessage(activity, message)) {
|
||||||
if (intent.resolveActivity(getContext().getPackageManager()) != null) {
|
if (intent.resolveActivity(getContext().getPackageManager()) != null) {
|
||||||
getContext().startActivity(intent);
|
getContext().startActivity(intent);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.siacs.conversations.utils;
|
package eu.siacs.conversations.utils;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
@ -18,32 +19,34 @@ import eu.siacs.conversations.entities.Conversation;
|
||||||
import eu.siacs.conversations.entities.Conversational;
|
import eu.siacs.conversations.entities.Conversational;
|
||||||
import eu.siacs.conversations.entities.Message;
|
import eu.siacs.conversations.entities.Message;
|
||||||
import eu.siacs.conversations.ui.ShareLocationActivity;
|
import eu.siacs.conversations.ui.ShareLocationActivity;
|
||||||
|
import eu.siacs.conversations.ui.ShowLocationActivity;
|
||||||
|
|
||||||
public class GeoHelper {
|
public class GeoHelper {
|
||||||
|
|
||||||
private static final String SHARE_LOCATION_PACKAGE_NAME = "eu.siacs.conversations.location.request";
|
private static final String SHARE_LOCATION_PACKAGE_NAME = "eu.siacs.conversations.location.request";
|
||||||
|
private static final String SHOW_LOCATION_PACKAGE_NAME = "eu.siacs.conversations.location.show";
|
||||||
|
|
||||||
public static Pattern GEO_URI = Pattern.compile("geo:([\\-0-9.]+),([\\-0-9.]+)(?:,([\\-0-9.]+))?(?:\\?(.*))?", Pattern.CASE_INSENSITIVE);
|
public static Pattern GEO_URI = Pattern.compile("geo:([\\-0-9.]+),([\\-0-9.]+)(?:,([\\-0-9.]+))?(?:\\?(.*))?", Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
public static boolean isLocationPluginInstalled(Activity activity) {
|
public static boolean isLocationPluginInstalled(Context context) {
|
||||||
return new Intent(SHARE_LOCATION_PACKAGE_NAME).resolveActivity(activity.getPackageManager()) != null;
|
return new Intent(SHARE_LOCATION_PACKAGE_NAME).resolveActivity(context.getPackageManager()) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLocationPluginInstalledAndDesired(Activity activity) {
|
public static boolean isLocationPluginInstalledAndDesired(Context context) {
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
final boolean configured = preferences.getBoolean("use_share_location_plugin", activity.getResources().getBoolean(R.bool.use_share_location_plugin));
|
final boolean configured = preferences.getBoolean("use_share_location_plugin", context.getResources().getBoolean(R.bool.use_share_location_plugin));
|
||||||
return configured && isLocationPluginInstalled(activity);
|
return configured && isLocationPluginInstalled(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Intent getFetchIntent(Activity activity) {
|
public static Intent getFetchIntent(Context context) {
|
||||||
if (isLocationPluginInstalledAndDesired(activity)) {
|
if (isLocationPluginInstalledAndDesired(context)) {
|
||||||
return new Intent(SHARE_LOCATION_PACKAGE_NAME);
|
return new Intent(SHARE_LOCATION_PACKAGE_NAME);
|
||||||
} else {
|
} else {
|
||||||
return new Intent(activity, ShareLocationActivity.class);
|
return new Intent(context, ShareLocationActivity.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<Intent> createGeoIntentsFromMessage(Message message) {
|
public static ArrayList<Intent> createGeoIntentsFromMessage(Context context, Message message) {
|
||||||
final ArrayList<Intent> intents = new ArrayList<>();
|
final ArrayList<Intent> intents = new ArrayList<>();
|
||||||
Matcher matcher = GEO_URI.matcher(message.getBody());
|
Matcher matcher = GEO_URI.matcher(message.getBody());
|
||||||
if (!matcher.matches()) {
|
if (!matcher.matches()) {
|
||||||
|
@ -75,12 +78,13 @@ public class GeoHelper {
|
||||||
label = "";
|
label = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent locationPluginIntent = new Intent("eu.siacs.conversations.location.show");
|
if (isLocationPluginInstalledAndDesired(context)) {
|
||||||
locationPluginIntent.putExtra("latitude",latitude);
|
Intent locationPluginIntent = new Intent(SHOW_LOCATION_PACKAGE_NAME);
|
||||||
locationPluginIntent.putExtra("longitude",longitude);
|
locationPluginIntent.putExtra("latitude", latitude);
|
||||||
|
locationPluginIntent.putExtra("longitude", longitude);
|
||||||
if (message.getStatus() != Message.STATUS_RECEIVED) {
|
if (message.getStatus() != Message.STATUS_RECEIVED) {
|
||||||
locationPluginIntent.putExtra("jid",conversation.getAccount().getJid().toString());
|
locationPluginIntent.putExtra("jid", conversation.getAccount().getJid().toString());
|
||||||
locationPluginIntent.putExtra("name",conversation.getAccount().getJid().getLocal());
|
locationPluginIntent.putExtra("name", conversation.getAccount().getJid().getLocal());
|
||||||
} else {
|
} else {
|
||||||
Contact contact = message.getContact();
|
Contact contact = message.getContact();
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
|
@ -91,6 +95,12 @@ public class GeoHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
intents.add(locationPluginIntent);
|
intents.add(locationPluginIntent);
|
||||||
|
} else {
|
||||||
|
Intent intent = new Intent(context, ShowLocationActivity.class);
|
||||||
|
intent.putExtra("latitude", latitude);
|
||||||
|
intent.putExtra("longitude", longitude);
|
||||||
|
intents.add(intent);
|
||||||
|
}
|
||||||
|
|
||||||
Intent geoIntent = new Intent(Intent.ACTION_VIEW);
|
Intent geoIntent = new Intent(Intent.ACTION_VIEW);
|
||||||
geoIntent.setData(Uri.parse("geo:" + String.valueOf(latitude) + "," + String.valueOf(longitude) + "?q=" + String.valueOf(latitude) + "," + String.valueOf(longitude) + label));
|
geoIntent.setData(Uri.parse("geo:" + String.valueOf(latitude) + "," + String.valueOf(longitude) + "?q=" + String.valueOf(latitude) + "," + String.valueOf(longitude) + label));
|
||||||
|
|
Loading…
Reference in a new issue