fixing avatar selection when some gallery apps won't return any extras

but still succeed // FREEBIE
This commit is contained in:
Jake McGinty 2014-02-18 15:27:18 -08:00
parent 760c96171d
commit e05bacd8c3
2 changed files with 8 additions and 7 deletions

View File

@ -127,7 +127,7 @@
<string name="GroupCreateActivity_contacts_mms_exception">An unexpected error happened that has made group creation fail.</string>
<string name="GroupCreateActivity_contacts_no_members">You need at least one person in your group!</string>
<string name="GroupCreateActivity_contacts_invalid_number">One of the members of your group has a number that can\'t be read correctly. Please fix or remove that contact and try again.</string>
<string name="GroupCreateActivity_file_io_exception">File I/O error, couldn\'t create temporary image file</string>
<string name="GroupCreateActivity_file_io_exception">File I/O error, couldn\'t create a temporary image file.</string>
<!-- ImportFragment -->
<string name="ImportFragment_import_system_sms_database">Import System SMS Database?</string>

View File

@ -238,6 +238,7 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
File f = new File(Environment.getExternalStorageDirectory(), TEMP_PHOTO_FILE);
try {
f.createNewFile();
f.deleteOnExit();
} catch (IOException e) {
Log.e(TAG, "Error creating new temp file.", e);
Toast.makeText(getApplicationContext(), R.string.GroupCreateActivity_file_io_exception, Toast.LENGTH_SHORT).show();
@ -338,13 +339,13 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
break;
case PICK_AVATAR:
if(resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
if (extras != null) {
File tempFile = getTempFile();
avatarBmp = BitmapFactory.decodeFile(tempFile.getAbsolutePath());
avatar.setImageBitmap(avatarBmp);
}
File tempFile = getTempFile();
avatarBmp = BitmapFactory.decodeFile(tempFile.getAbsolutePath());
if (avatarBmp != null) avatar.setImageBitmap(avatarBmp);
tempFile.delete();
break;
} else {
Log.i(TAG, "Avatar selection result was not RESULT_OK.");
}
}
}