diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-08-25 22:41:33 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-08-26 22:28:58 +0200 |
commit | da12042acdb4fc94e542ff098e72fdc2618cc6b4 (patch) | |
tree | f98ea91cb1b16ac5e1e825839ec07422d22f7143 /src | |
parent | 1fb9dcb42760d4fd8a94ffa0813eff38be91dd5b (diff) |
add file provider to share files on android n
Diffstat (limited to '')
-rw-r--r-- | src/main/AndroidManifest.xml | 138 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 1 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java | 5 | ||||
-rw-r--r-- | src/main/res/xml/file_paths.xml | 4 |
4 files changed, 78 insertions, 70 deletions
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index e3007ddef..3b2d3174f 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ <?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="de.pixart.messenger" > + xmlns:tools="http://schemas.android.com/tools" + package="de.pixart.messenger"> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> @@ -15,54 +15,52 @@ <uses-permission android:name="android.permission.NFC"/> <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/> <uses-permission android:name="android.permission.RECORD_AUDIO"/> - <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> - <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> - <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> + <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="com.android.alarm.permission.SET_ALARM"/> <uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove"/> <application + android:name="android.support.multidex.MultiDexApplication" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" - android:theme="@style/ConversationsTheme" - android:name="android.support.multidex.MultiDexApplication" android:largeHeap="true" + android:theme="@style/ConversationsTheme" tools:replace="android:label"> - <service android:name="de.pixart.messenger.services.XmppConnectionService"/> <receiver android:name="de.pixart.messenger.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.intent.action.MY_PACKAGE_REPLACED" /> - <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.intent.action.MY_PACKAGE_REPLACED"/> + <action android:name="android.media.RINGER_MODE_CHANGED"/> </intent-filter> <intent-filter> - <action android:name="android.intent.action.PACKAGE_REPLACED" /> - <data android:scheme="package" android:path="de.pixart.messenger" /> + <action android:name="android.intent.action.PACKAGE_REPLACED"/> + <data + android:path="de.pixart.messenger" + android:scheme="package"/> </intent-filter> </receiver> - <receiver android:name="de.pixart.messenger.services.AlarmReceiver"> </receiver> - <activity android:name="de.pixart.messenger.ui.StartUI" android:configChanges="orientation|screenSize" - android:theme="@style/Theme.AppCompat.Light.NoActionBar" android:label="@string/app_name" android:launchMode="singleTask" + android:theme="@style/Theme.AppCompat.Light.NoActionBar" android:windowSoftInputMode="stateHidden"> <intent-filter> <action android:name="android.intent.action.MAIN"/> - <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> @@ -76,10 +74,9 @@ android:name="de.pixart.messenger.ui.StartConversationActivity" android:configChanges="orientation|screenSize" android:label="@string/title_activity_start_conversation" - android:launchMode="singleTask" > + android:launchMode="singleTask"> <intent-filter> <action android:name="android.intent.action.SENDTO"/> - <category android:name="android.intent.category.DEFAULT"/> <data android:scheme="imto"/> @@ -95,38 +92,37 @@ </intent-filter> <intent-filter> <action android:name="android.nfc.action.NDEF_DISCOVERED"/> - <category android:name="android.intent.category.DEFAULT"/> - <data android:scheme="xmpp"/> </intent-filter> <intent-filter android:autoVerify="true"> - <action android:name="android.intent.action.VIEW" /> - <category android:name="android.intent.category.DEFAULT" /> - <category android:name="android.intent.category.BROWSABLE" /> - <data android:scheme="https" /> - <data android:host="jabber.pix-art.de" /> - <data android:pathPrefix="/i/" /> - <data android:pathPrefix="/j/" /> - </intent-filter> + <action android:name="android.intent.action.VIEW"/> + + <category android:name="android.intent.category.DEFAULT"/> + <category android:name="android.intent.category.BROWSABLE"/> + <data android:scheme="https"/> + <data android:host="jabber.pix-art.de"/> + <data android:pathPrefix="/i/"/> + <data android:pathPrefix="/j/"/> + </intent-filter> </activity> <activity android:name="de.pixart.messenger.ui.WelcomeActivity" android:label="@string/app_name" - android:screenOrientation="portrait" - android:launchMode="singleTask"/> + android:launchMode="singleTask" + android:screenOrientation="portrait"/> <activity android:name="de.pixart.messenger.ui.MagicCreateActivity" android:label="@string/create_account" - android:screenOrientation="portrait" - android:launchMode="singleTask"/> + android:launchMode="singleTask" + android:screenOrientation="portrait"/> <activity android:name="de.pixart.messenger.ui.SetPresenceActivity" - android:label="@string/change_presence" android:configChanges="orientation|screenSize" - android:windowSoftInputMode="stateHidden|adjustResize" - android:launchMode="singleTask"/> + android:label="@string/change_presence" + android:launchMode="singleTask" + android:windowSoftInputMode="stateHidden|adjustResize"/> <activity android:name="de.pixart.messenger.ui.SettingsActivity" android:label="@string/title_activity_settings"/> @@ -168,77 +164,70 @@ android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.SEND"/> - <category android:name="android.intent.category.DEFAULT"/> - <data android:mimeType="text/plain"/> </intent-filter> <intent-filter> <action android:name="android.intent.action.SEND"/> - <category android:name="android.intent.category.DEFAULT"/> - <data android:mimeType="*/*"/> </intent-filter> <intent-filter> <action android:name="android.intent.action.SEND_MULTIPLE"/> - <category android:name="android.intent.category.DEFAULT"/> - <data android:mimeType="image/*"/> </intent-filter> + <meta-data android:name="android.service.chooser.chooser_target_service" android:value=".services.ContactChooserTargetService"/> </activity> <activity - android:theme="@style/ConversationsDialog" android:name="de.pixart.messenger.ui.RecordingActivity" + android:configChanges="orientation|screenSize" android:label="@string/app_name" - android:configChanges="orientation|screenSize"> + android:theme="@style/ConversationsDialog"> <intent-filter> - <action android:name="android.provider.MediaStore.RECORD_SOUND" /> - <category android:name="android.intent.category.DEFAULT" /> + <action android:name="android.provider.MediaStore.RECORD_SOUND"/> + <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </activity> + <meta-data android:name="com.google.android.gms.version" - android:value="@integer/google_play_services_version" /> + android:value="@integer/google_play_services_version"/> <meta-data android:name="com.google.android.maps.v2.API_KEY" - android:value="@string/google_maps_api_key" /> + android:value="@string/google_maps_api_key"/> <activity android:name="de.pixart.messenger.ui.ShareLocationActivity" - android:label="@string/share_location" > + android:label="@string/share_location"> <intent-filter> - <action android:name="de.pixart.messenger.location.request" /> - <category android:name="android.intent.category.DEFAULT" /> + <action android:name="de.pixart.messenger.location.request"/> + <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </activity> - <activity android:name="de.pixart.messenger.ui.ShowLocationActivity" - android:label="@string/show_location" > + android:label="@string/show_location"> <intent-filter> - <action android:name="de.pixart.messenger.location.show" /> - <category android:name="android.intent.category.DEFAULT" /> + <action android:name="de.pixart.messenger.location.show"/> + <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </activity> - <activity android:name="de.pixart.messenger.ui.ShowFullscreenMessageActivity" android:configChanges="orientation|screenSize"> - </activity> <activity android:name="de.pixart.messenger.ui.TrustKeysActivity" android:label="@string/trust_omemo_fingerprints" - android:windowSoftInputMode="stateAlwaysHidden" /> + android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:name="de.duenndns.ssl.MemorizingActivity" android:theme="@style/ConversationsTheme" - tools:replace="android:theme" /> + tools:replace="android:theme"/> <activity android:name="de.pixart.messenger.ui.AboutActivity" android:label="@string/title_activity_about" @@ -250,20 +239,31 @@ <activity android:name="de.pixart.messenger.ui.UpdaterActivity" android:configChanges="orientation|screenSize" + android:label="@string/title_activity_updater" android:launchMode="singleTask" - android:theme="@style/ConversationsTheme" - android:label="@string/title_activity_updater" > + android:theme="@style/ConversationsTheme"> </activity> - <activity android:name="com.soundcloud.android.crop.CropImageActivity" /> - <service android:name="de.pixart.messenger.services.UpdaterWebService" /> - <service android:name="de.pixart.messenger.services.CheckAppVersionService" /> + <activity android:name="com.soundcloud.android.crop.CropImageActivity"/> + + <service android:name="de.pixart.messenger.services.UpdaterWebService"/> + <service android:name="de.pixart.messenger.services.CheckAppVersionService"/> <service android:name="de.pixart.messenger.services.ExportLogsService"/> - <service android:name="de.pixart.messenger.services.ContactChooserTargetService" - android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE"> + <service + android:name="de.pixart.messenger.services.ContactChooserTargetService" + android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE"> <intent-filter> <action android:name="android.service.chooser.ChooserTargetService"/> </intent-filter> </service> - </application> + <provider + android:name="android.support.v4.content.FileProvider" + android:authorities="de.pixart.messenger.files" + android:exported="false" + android:grantUriPermissions="true"> + <meta-data + android:name="android.support.FILE_PROVIDER_PATHS" + android:resource="@xml/file_paths"/> + </provider> + </application> </manifest> diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index d074bf1fe..d49d1f68b 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -697,6 +697,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<Message>() { @Override diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index 4efdf6701..9b0f02696 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -12,6 +12,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; @@ -804,7 +805,9 @@ public class MessageAdapter extends ArrayAdapter<Message> { if (mime == null) { mime = "*/*"; } - openIntent.setDataAndType(Uri.fromFile(file), mime); + Uri uri = FileProvider.getUriForFile(activity,"de.pixart.messenger.files",file); + openIntent.setDataAndType(uri, mime); + openIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); PackageManager manager = activity.getPackageManager(); List<ResolveInfo> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<paths> + <external-path name="external" path="/"/> +</paths>
\ No newline at end of file |