From 910b38ec13f2e3f7fa648920e8fc62ff81669ef9 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 25 Aug 2016 22:41:33 +0200 Subject: [PATCH] add file provider to share files on android n --- src/main/AndroidManifest.xml | 156 ++++++++++-------- .../services/XmppConnectionService.java | 1 + .../ui/adapter/MessageAdapter.java | 5 +- src/main/res/xml/file_paths.xml | 4 + 4 files changed, 95 insertions(+), 71 deletions(-) create mode 100644 src/main/res/xml/file_paths.xml diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 963b138da..abc4b89de 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -1,24 +1,23 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + tools:node="remove" /> - + - - - - + + + + @@ -43,9 +42,9 @@ android:launchMode="singleTask" android:windowSoftInputMode="stateHidden"> - + - + - + - + - - + + - + - - + + - + - + - + - + + + @@ -90,107 +91,122 @@ + android:launchMode="singleTask" + android:screenOrientation="portrait" /> + android:launchMode="singleTask" + android:screenOrientation="portrait" /> + android:label="@string/change_presence" + android:launchMode="singleTask" + android:windowSoftInputMode="stateHidden|adjustResize" /> + android:label="@string/title_activity_settings" /> + android:label="@string/title_activity_choose_contact" /> + android:label="@string/title_activity_block_list" /> + android:label="@string/change_password_on_server" /> + android:launchMode="singleTask" /> + android:windowSoftInputMode="stateHidden|adjustResize" /> + android:windowSoftInputMode="stateHidden" /> + android:windowSoftInputMode="stateHidden" /> + android:windowSoftInputMode="stateHidden" /> + android:windowSoftInputMode="stateHidden" /> - + - + - + - + - + - + - + - + - + + + android:value=".services.ContactChooserTargetService" /> + android:windowSoftInputMode="stateAlwaysHidden" /> + tools:replace="android:theme" /> + android:value="eu.siacs.conversations.ui.SettingsActivity" /> - - - + + + + - + + + + + + + diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index d57176e47..9d2796e12 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -699,6 +699,7 @@ public class XmppConnectionService extends Service { private void directReply(Conversation conversation, String body) { Message message = new Message(conversation,body,conversation.getNextEncryption()); + message.markUnread(); if (message.getEncryption() == Message.ENCRYPTION_PGP) { getPgpEngine().encrypt(message, new UiCallback() { @Override diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java index 6763f3f52..bc706cdaf 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -11,6 +11,7 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; +import android.support.v4.content.FileProvider; import android.text.Spannable; import android.text.SpannableString; import android.text.Spanned; @@ -715,7 +716,9 @@ public class MessageAdapter extends ArrayAdapter { if (mime == null) { 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(); List infos = manager.queryIntentActivities(openIntent, 0); if (infos.size() == 0) { diff --git a/src/main/res/xml/file_paths.xml b/src/main/res/xml/file_paths.xml new file mode 100644 index 000000000..2a8bc7667 --- /dev/null +++ b/src/main/res/xml/file_paths.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file -- 2.45.2