mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #1470 from deltachat/fix_profile_selection
Fix profile selection
This commit is contained in:
@@ -8,8 +8,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
@@ -50,7 +48,6 @@ import org.thoughtcrime.securesms.util.IntentUtils;
|
||||
import org.thoughtcrime.securesms.util.Prefs;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
import org.thoughtcrime.securesms.util.views.Stub;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
@@ -336,8 +333,8 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Emoj
|
||||
|
||||
private Intent createAvatarSelectionIntent(@Nullable File captureFile, boolean includeClear, boolean includeCamera) {
|
||||
List<Intent> extraIntents = new LinkedList<>();
|
||||
Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
|
||||
galleryIntent.setType("image/*");
|
||||
Intent galleryIntent = new Intent(Intent.ACTION_PICK);
|
||||
galleryIntent.setDataAndType(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, "image/*");
|
||||
|
||||
if (!IntentUtils.isResolvable(CreateProfileActivity.this, galleryIntent)) {
|
||||
galleryIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
@@ -347,8 +344,15 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Emoj
|
||||
if (includeCamera) {
|
||||
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
|
||||
if (captureFile != null && cameraIntent.resolveActivity(getPackageManager()) != null) {
|
||||
cameraIntent.putExtra(EXTRA_OUTPUT, FileProviderUtil.getUriFor(this, captureFile));
|
||||
Uri captureUri = null;
|
||||
try {
|
||||
captureUri = FileProviderUtil.getUriFor(this, captureFile);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
|
||||
if (captureUri != null && cameraIntent.resolveActivity(getPackageManager()) != null) {
|
||||
cameraIntent.putExtra(EXTRA_OUTPUT, captureUri);
|
||||
extraIntents.add(cameraIntent);
|
||||
}
|
||||
}
|
||||
@@ -372,7 +376,7 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Emoj
|
||||
|
||||
if (hasCameraPermission) {
|
||||
try {
|
||||
captureFile = File.createTempFile("capture", "jpg", getExternalCacheDir());
|
||||
captureFile = File.createTempFile("capture", ".jpg", getExternalCacheDir());
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
captureFile = null;
|
||||
|
||||
@@ -460,8 +460,8 @@ public class AttachmentManager {
|
||||
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageCaptureUri);
|
||||
activity.startActivityForResult(captureIntent, requestCode);
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
Log.w(TAG, ioe);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
})
|
||||
.execute();
|
||||
@@ -485,8 +485,8 @@ public class AttachmentManager {
|
||||
captureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
activity.startActivityForResult(captureIntent, requestCode);
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
Log.w(TAG, ioe);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
})
|
||||
.execute();
|
||||
|
||||
@@ -114,8 +114,8 @@ public class PersistentBlobProvider {
|
||||
});
|
||||
}
|
||||
|
||||
public Uri createForExternal(@NonNull Context context, @NonNull String mimeType) throws IOException {
|
||||
File target = new File(getExternalDir(context), String.valueOf(System.currentTimeMillis()) + "." + getExtensionFromMimeType(mimeType));
|
||||
public Uri createForExternal(@NonNull Context context, @NonNull String mimeType) throws IOException, IllegalStateException, NullPointerException {
|
||||
File target = new File(getExternalDir(context), System.currentTimeMillis() + "." + getExtensionFromMimeType(mimeType));
|
||||
return FileProviderUtil.getUriFor(context, target);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class FileProviderUtil {
|
||||
|
||||
private static final String AUTHORITY = BuildConfig.APPLICATION_ID+".fileprovider";
|
||||
|
||||
public static Uri getUriFor(@NonNull Context context, @NonNull File file) {
|
||||
public static Uri getUriFor(@NonNull Context context, @NonNull File file) throws IllegalStateException, NullPointerException {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return FileProvider.getUriForFile(context, AUTHORITY, file);
|
||||
else return Uri.fromFile(file);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user