make show location depend on plugin setting

This commit is contained in:
Daniel Gultsch 2018-05-01 12:55:11 +02:00
parent 8e17fa285d
commit 949b77c353
4 changed files with 135 additions and 122 deletions

View File

@ -3,60 +3,72 @@
xmlns:tools="http://schemas.android.com/tools"
package="eu.siacs.conversations">
<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_CONTACTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<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_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<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_CONTACTS"/>
<uses-permission android:name="android.permission.READ_PROFILE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<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_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-feature android:name="android.hardware.location" 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-feature
android:name="android.hardware.location"
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.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 android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-feature
android:name="android.hardware.camera"
android:required="false"/>
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false"/>
<application
android:networkSecurityConfig="@xml/network_security_configuration"
android:allowBackup="true"
android:appCategory="social"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_configuration"
android:theme="@style/ConversationsTheme"
android:appCategory="social"
tools:replace="android:label"
tools:targetApi="o">
<meta-data android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />
<meta-data
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">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
<action android:name="android.media.RINGER_MODE_CHANGED" />
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
<action android:name="android.intent.action.ACTION_SHUTDOWN"/>
<action android:name="android.media.RINGER_MODE_CHANGED"/>
</intent-filter>
</receiver>
<activity
android:name=".ui.ShareLocationActivity"
android:label="@string/title_activity_share_location"/>
@ -65,71 +77,61 @@
android:label="@string/search_messages"/>
<activity
android:name=".ui.RecordingActivity"
android:theme="@style/ConversationsTheme.Dialog"
android:configChanges="orientation|screenSize"/>
android:configChanges="orientation|screenSize"
android:theme="@style/ConversationsTheme.Dialog"/>
<activity
android:name=".ui.ShowLocationActivity"
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>
android:label="@string/title_activity_show_location"/>
<activity
android:name=".ui.ConversationActivity"
android:theme="@style/SplashTheme">
<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>
</activity>
<activity
android:name=".ui.ConversationsActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:minWidth="300dp"
android:minHeight="300dp"
android:windowSoftInputMode="stateHidden" />
android:minWidth="300dp"
android:windowSoftInputMode="stateHidden"/>
<activity
android:name=".ui.ScanActivity"
android:screenOrientation="portrait"
android:theme="@style/ConversationsTheme.FullScreen"
android:windowSoftInputMode="stateAlwaysHidden" />
android:windowSoftInputMode="stateAlwaysHidden"/>
<activity
android:name=".ui.UriHandlerActivity"
android:label="@string/title_activity_start_conversation">
<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.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="xmpp" />
<data android:scheme="xmpp"/>
</intent-filter>
<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.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="https" />
<data android:host="conversations.im" />
<data android:pathPrefix="/i/" />
<data android:pathPrefix="/j/" />
<data android:scheme="https"/>
<data android:host="conversations.im"/>
<data android:pathPrefix="/i/"/>
<data android:pathPrefix="/j/"/>
</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:host="jabber" />
<data android:scheme="imto"/>
<data android:host="jabber"/>
</intent-filter>
</activity>
<activity
@ -137,7 +139,7 @@
android:label="@string/title_activity_start_conversation"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.VIEW"/>
</intent-filter>
</activity>
<activity
@ -150,93 +152,93 @@
android:launchMode="singleTask"/>
<activity
android:name=".ui.SettingsActivity"
android:label="@string/title_activity_settings" />
android:label="@string/title_activity_settings"/>
<activity
android:name=".ui.ChooseContactActivity"
android:label="@string/title_activity_choose_contact" />
android:label="@string/title_activity_choose_contact"/>
<activity
android:name=".ui.BlocklistActivity"
android:label="@string/title_activity_block_list" />
android:label="@string/title_activity_block_list"/>
<activity
android:name=".ui.ChangePasswordActivity"
android:label="@string/change_password_on_server" />
android:label="@string/change_password_on_server"/>
<activity
android:name=".ui.ManageAccountActivity"
android:label="@string/title_activity_manage_accounts"
android:launchMode="singleTask" />
android:launchMode="singleTask"/>
<activity
android:name=".ui.ShareViaAccountActivity"
android:label="@string/title_activity_share_via_account"
android:launchMode="singleTop" />
android:launchMode="singleTop"/>
<activity
android:name=".ui.EditAccountActivity"
android:launchMode="singleTop"
android:windowSoftInputMode="stateHidden|adjustResize" />
android:windowSoftInputMode="stateHidden|adjustResize"/>
<activity
android:name=".ui.ConferenceDetailsActivity"
android:windowSoftInputMode="stateHidden" />
android:windowSoftInputMode="stateHidden"/>
<activity
android:name=".ui.ContactDetailsActivity"
android:windowSoftInputMode="stateHidden" />
android:windowSoftInputMode="stateHidden"/>
<activity
android:name=".ui.PublishProfilePictureActivity"
android:label="@string/mgmt_account_publish_avatar"
android:windowSoftInputMode="stateHidden" />
android:windowSoftInputMode="stateHidden"/>
<activity
android:name=".ui.ShareWithActivity"
android:label="@string/app_name"
android:launchMode="singleTop">
<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>
<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>
<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>
<meta-data
android:name="android.service.chooser.chooser_target_service"
android:value=".services.ContactChooserTargetService" />
android:value=".services.ContactChooserTargetService"/>
</activity>
<activity
android:name=".ui.TrustKeysActivity"
android:label="@string/trust_omemo_fingerprints"
android:windowSoftInputMode="stateAlwaysHidden" />
android:windowSoftInputMode="stateAlwaysHidden"/>
<activity
android:name=".ui.AboutActivity"
android:label="@string/title_activity_about"
android:parentActivityName=".ui.SettingsActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="eu.siacs.conversations.ui.SettingsActivity" />
android:value="eu.siacs.conversations.ui.SettingsActivity"/>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.PREFERENCE" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.PREFERENCE"/>
</intent-filter>
</activity>
<activity android:name="com.soundcloud.android.crop.CropImageActivity" />
<activity android:name="com.soundcloud.android.crop.CropImageActivity"/>
<activity android:name=".ui.MemorizingActivity"/>
<service android:name=".services.ExportLogsService" />
<service android:name=".services.ExportLogsService"/>
<service
android:name=".services.ContactChooserTargetService"
android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE">
<intent-filter>
<action android:name="android.service.chooser.ChooserTargetService" />
<action android:name="android.service.chooser.ChooserTargetService"/>
</intent-filter>
</service>
@ -247,18 +249,19 @@
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
android:resource="@xml/file_paths"/>
</provider>
<provider
android:authorities="${applicationId}.barcodes"
android:name=".services.BarcodeProvider"
android:authorities="${applicationId}.barcodes"
android:exported="false"
android:grantUriPermissions="true"/>
<activity android:name=".ui.ShortcutActivity"
<activity
android:name=".ui.ShortcutActivity"
android:label="@string/contact">
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
<action android:name="android.intent.action.CREATE_SHORTCUT"/>
</intent-filter>
</activity>
</application>

View File

@ -603,7 +603,7 @@ public class NotificationService {
}
private PendingIntent createShowLocationIntent(final Message message) {
Iterable<Intent> intents = GeoHelper.createGeoIntentsFromMessage(message);
Iterable<Intent> intents = GeoHelper.createGeoIntentsFromMessage(mXmppConnectionService, message);
for (Intent intent : intents) {
if (intent.resolveActivity(mXmppConnectionService.getPackageManager()) != null) {
return PendingIntent.getActivity(mXmppConnectionService, generateRequestCode(message.getConversation(), 18), intent, PendingIntent.FLAG_UPDATE_CURRENT);

View File

@ -965,7 +965,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
}
public void showLocation(Message message) {
for (Intent intent : GeoHelper.createGeoIntentsFromMessage(message)) {
for (Intent intent : GeoHelper.createGeoIntentsFromMessage(activity, message)) {
if (intent.resolveActivity(getContext().getPackageManager()) != null) {
getContext().startActivity(intent);
return;

View File

@ -1,6 +1,7 @@
package eu.siacs.conversations.utils;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
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.Message;
import eu.siacs.conversations.ui.ShareLocationActivity;
import eu.siacs.conversations.ui.ShowLocationActivity;
public class GeoHelper {
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 boolean isLocationPluginInstalled(Activity activity) {
return new Intent(SHARE_LOCATION_PACKAGE_NAME).resolveActivity(activity.getPackageManager()) != null;
public static boolean isLocationPluginInstalled(Context context) {
return new Intent(SHARE_LOCATION_PACKAGE_NAME).resolveActivity(context.getPackageManager()) != null;
}
public static boolean isLocationPluginInstalledAndDesired(Activity activity) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
final boolean configured = preferences.getBoolean("use_share_location_plugin", activity.getResources().getBoolean(R.bool.use_share_location_plugin));
return configured && isLocationPluginInstalled(activity);
public static boolean isLocationPluginInstalledAndDesired(Context context) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
final boolean configured = preferences.getBoolean("use_share_location_plugin", context.getResources().getBoolean(R.bool.use_share_location_plugin));
return configured && isLocationPluginInstalled(context);
}
public static Intent getFetchIntent(Activity activity) {
if (isLocationPluginInstalledAndDesired(activity)) {
public static Intent getFetchIntent(Context context) {
if (isLocationPluginInstalledAndDesired(context)) {
return new Intent(SHARE_LOCATION_PACKAGE_NAME);
} 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<>();
Matcher matcher = GEO_URI.matcher(message.getBody());
if (!matcher.matches()) {
@ -75,12 +78,13 @@ public class GeoHelper {
label = "";
}
Intent locationPluginIntent = new Intent("eu.siacs.conversations.location.show");
locationPluginIntent.putExtra("latitude",latitude);
locationPluginIntent.putExtra("longitude",longitude);
if (isLocationPluginInstalledAndDesired(context)) {
Intent locationPluginIntent = new Intent(SHOW_LOCATION_PACKAGE_NAME);
locationPluginIntent.putExtra("latitude", latitude);
locationPluginIntent.putExtra("longitude", longitude);
if (message.getStatus() != Message.STATUS_RECEIVED) {
locationPluginIntent.putExtra("jid",conversation.getAccount().getJid().toString());
locationPluginIntent.putExtra("name",conversation.getAccount().getJid().getLocal());
locationPluginIntent.putExtra("jid", conversation.getAccount().getJid().toString());
locationPluginIntent.putExtra("name", conversation.getAccount().getJid().getLocal());
} else {
Contact contact = message.getContact();
if (contact != null) {
@ -91,6 +95,12 @@ public class GeoHelper {
}
}
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);
geoIntent.setData(Uri.parse("geo:" + String.valueOf(latitude) + "," + String.valueOf(longitude) + "?q=" + String.valueOf(latitude) + "," + String.valueOf(longitude) + label));