add file provider to share files on android n
This commit is contained in:
parent
b0cdc2745c
commit
910b38ec13
|
@ -1,24 +1,23 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="eu.siacs.conversations"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
package="eu.siacs.conversations">
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
|
||||||
|
|
||||||
<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.NFC"/>
|
<uses-permission android:name="android.permission.NFC" />
|
||||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||||
|
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.READ_PHONE_STATE"
|
android:name="android.permission.READ_PHONE_STATE"
|
||||||
tools:node="remove"/>
|
tools:node="remove" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
@ -26,14 +25,14 @@
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/ConversationsTheme"
|
android:theme="@style/ConversationsTheme"
|
||||||
tools:replace="android:label">
|
tools:replace="android:label">
|
||||||
<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>
|
||||||
|
|
||||||
|
@ -43,9 +42,9 @@
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:windowSoftInputMode="stateHidden">
|
android:windowSoftInputMode="stateHidden">
|
||||||
<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
|
||||||
|
@ -54,32 +53,34 @@
|
||||||
android:label="@string/title_activity_start_conversation"
|
android:label="@string/title_activity_start_conversation"
|
||||||
android:launchMode="singleTask">
|
android:launchMode="singleTask">
|
||||||
<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>
|
||||||
<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>
|
<intent-filter>
|
||||||
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
|
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
|
||||||
<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/" />
|
||||||
|
@ -90,107 +91,122 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.WelcomeActivity"
|
android:name=".ui.WelcomeActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:screenOrientation="portrait"
|
android:launchMode="singleTask"
|
||||||
android:launchMode="singleTask"/>
|
android:screenOrientation="portrait" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.MagicCreateActivity"
|
android:name=".ui.MagicCreateActivity"
|
||||||
android:label="@string/create_account"
|
android:label="@string/create_account"
|
||||||
android:screenOrientation="portrait"
|
android:launchMode="singleTask"
|
||||||
android:launchMode="singleTask"/>
|
android:screenOrientation="portrait" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.SetPresenceActivity"
|
android:name=".ui.SetPresenceActivity"
|
||||||
android:label="@string/change_presence"
|
|
||||||
android:configChanges="orientation|screenSize"
|
android:configChanges="orientation|screenSize"
|
||||||
android:windowSoftInputMode="stateHidden|adjustResize"
|
android:label="@string/change_presence"
|
||||||
android:launchMode="singleTask"/>
|
android:launchMode="singleTask"
|
||||||
|
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||||
<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.EditAccountActivity"
|
android:name=".ui.EditAccountActivity"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:windowSoftInputMode="stateHidden|adjustResize"/>
|
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ConferenceDetailsActivity"
|
android:name=".ui.ConferenceDetailsActivity"
|
||||||
android:label="@string/title_activity_conference_details"
|
android:label="@string/title_activity_conference_details"
|
||||||
android:windowSoftInputMode="stateHidden"/>
|
android:windowSoftInputMode="stateHidden" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ContactDetailsActivity"
|
android:name=".ui.ContactDetailsActivity"
|
||||||
android:label="@string/title_activity_contact_details"
|
android:label="@string/title_activity_contact_details"
|
||||||
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.VerifyOTRActivity"
|
android:name=".ui.VerifyOTRActivity"
|
||||||
android:label="@string/verify_otr"
|
android:label="@string/verify_otr"
|
||||||
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">
|
||||||
<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="de.duenndns.ssl.MemorizingActivity"
|
android:name="de.duenndns.ssl.MemorizingActivity"
|
||||||
android:theme="@style/ConversationsTheme"
|
android:theme="@style/ConversationsTheme"
|
||||||
tools:replace="android:theme"/>
|
tools:replace="android:theme" />
|
||||||
<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" />
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="com.soundcloud.android.crop.CropImageActivity"/>
|
<activity android:name="com.soundcloud.android.crop.CropImageActivity" />
|
||||||
<service android:name=".services.ExportLogsService"/>
|
|
||||||
<service android:name=".services.ContactChooserTargetService"
|
<service android:name=".services.ExportLogsService" />
|
||||||
android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE">
|
<service
|
||||||
|
android:name=".services.ContactChooserTargetService"
|
||||||
|
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>
|
||||||
|
|
||||||
|
<provider
|
||||||
|
android:name="android.support.v4.content.FileProvider"
|
||||||
|
android:authorities="eu.siacs.conversations.files"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/file_paths" />
|
||||||
|
</provider>
|
||||||
|
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
@ -699,6 +699,7 @@ public class XmppConnectionService extends Service {
|
||||||
|
|
||||||
private void directReply(Conversation conversation, String body) {
|
private void directReply(Conversation conversation, String body) {
|
||||||
Message message = new Message(conversation,body,conversation.getNextEncryption());
|
Message message = new Message(conversation,body,conversation.getNextEncryption());
|
||||||
|
message.markUnread();
|
||||||
if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
||||||
getPgpEngine().encrypt(message, new UiCallback<Message>() {
|
getPgpEngine().encrypt(message, new UiCallback<Message>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,6 +11,7 @@ import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.support.v4.content.FileProvider;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
@ -715,7 +716,9 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
if (mime == null) {
|
if (mime == null) {
|
||||||
mime = "*/*";
|
mime = "*/*";
|
||||||
}
|
}
|
||||||
openIntent.setDataAndType(Uri.fromFile(file), mime);
|
Uri uri = FileProvider.getUriForFile(activity,"eu.siacs.conversations.files",file);
|
||||||
|
openIntent.setDataAndType(uri, mime);
|
||||||
|
openIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
PackageManager manager = activity.getPackageManager();
|
PackageManager manager = activity.getPackageManager();
|
||||||
List<ResolveInfo> infos = manager.queryIntentActivities(openIntent, 0);
|
List<ResolveInfo> infos = manager.queryIntentActivities(openIntent, 0);
|
||||||
if (infos.size() == 0) {
|
if (infos.size() == 0) {
|
||||||
|
|
4
src/main/res/xml/file_paths.xml
Normal file
4
src/main/res/xml/file_paths.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<paths>
|
||||||
|
<external-path name="external" path="/"/>
|
||||||
|
</paths>
|
Loading…
Reference in a new issue