mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
parent
4932171bbf
commit
4cb2ac7b27
@ -524,6 +524,15 @@
|
|||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:authorities="org.thoughtcrime.provider.securesms.mms" />
|
android:authorities="org.thoughtcrime.provider.securesms.mms" />
|
||||||
|
|
||||||
|
<provider android:name="android.support.v4.content.FileProvider"
|
||||||
|
android:authorities="org.thoughtcrime.securesms.fileprovider"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
|
||||||
|
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_provider_paths" />
|
||||||
|
|
||||||
|
</provider>
|
||||||
|
|
||||||
<receiver android:name=".service.BootReceiver">
|
<receiver android:name=".service.BootReceiver">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||||
|
4
res/xml/file_provider_paths.xml
Normal file
4
res/xml/file_provider_paths.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<paths>
|
||||||
|
<external-cache-path name="external_cache" path="." />
|
||||||
|
</paths>
|
@ -50,6 +50,7 @@ import org.thoughtcrime.securesms.util.BitmapDecodingException;
|
|||||||
import org.thoughtcrime.securesms.util.BitmapUtil;
|
import org.thoughtcrime.securesms.util.BitmapUtil;
|
||||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
||||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||||
|
import org.thoughtcrime.securesms.util.FileProviderUtil;
|
||||||
import org.thoughtcrime.securesms.util.IntentUtils;
|
import org.thoughtcrime.securesms.util.IntentUtils;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
@ -376,7 +377,7 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Inje
|
|||||||
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
|
||||||
if (captureFile != null && cameraIntent.resolveActivity(getPackageManager()) != null) {
|
if (captureFile != null && cameraIntent.resolveActivity(getPackageManager()) != null) {
|
||||||
cameraIntent.putExtra(EXTRA_OUTPUT, Uri.fromFile(captureFile));
|
cameraIntent.putExtra(EXTRA_OUTPUT, FileProviderUtil.getUriFor(this, captureFile));
|
||||||
extraIntents.add(cameraIntent);
|
extraIntents.add(cameraIntent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,10 @@ import android.content.ContentUris;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.UriMatcher;
|
import android.content.UriMatcher;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.content.FileProvider;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.webkit.MimeTypeMap;
|
import android.webkit.MimeTypeMap;
|
||||||
|
|
||||||
@ -14,6 +16,7 @@ import org.thoughtcrime.securesms.crypto.DecryptingPartInputStream;
|
|||||||
import org.thoughtcrime.securesms.crypto.EncryptingPartOutputStream;
|
import org.thoughtcrime.securesms.crypto.EncryptingPartOutputStream;
|
||||||
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
|
import org.thoughtcrime.securesms.util.FileProviderUtil;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
import org.whispersystems.libsignal.InvalidMessageException;
|
import org.whispersystems.libsignal.InvalidMessageException;
|
||||||
|
|
||||||
@ -128,8 +131,8 @@ public class PersistentBlobProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Uri createForExternal(@NonNull String mimeType) throws IOException {
|
public Uri createForExternal(@NonNull String mimeType) throws IOException {
|
||||||
return Uri.fromFile(new File(getExternalDir(context),
|
File target = new File(getExternalDir(context), String.valueOf(System.currentTimeMillis()) + "." + getExtensionFromMimeType(mimeType));
|
||||||
String.valueOf(System.currentTimeMillis()) + "." + getExtensionFromMimeType(mimeType)));
|
return FileProviderUtil.getUriFor(context, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean delete(@NonNull Uri uri) {
|
public boolean delete(@NonNull Uri uri) {
|
||||||
|
21
src/org/thoughtcrime/securesms/util/FileProviderUtil.java
Normal file
21
src/org/thoughtcrime/securesms/util/FileProviderUtil.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package org.thoughtcrime.securesms.util;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.content.FileProvider;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class FileProviderUtil {
|
||||||
|
|
||||||
|
private static final String AUTHORITY = "org.thoughtcrime.securesms.fileprovider";
|
||||||
|
|
||||||
|
public static Uri getUriFor(@NonNull Context context, @NonNull File file) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return FileProvider.getUriForFile(context, AUTHORITY, file);
|
||||||
|
else return Uri.fromFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user