Merge branch 'master' of github.com:WhisperSystems/TextSecure

Conflicts:
	src/org/thoughtcrime/securesms/GroupCreateActivity.java
	src/org/thoughtcrime/securesms/database/GroupDatabase.java
This commit is contained in:
Moxie Marlinspike 2014-02-24 00:23:40 -08:00
commit d5f0415907
3 changed files with 22 additions and 24 deletions

View File

@ -599,11 +599,10 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
}
} else {
title = getString(R.string.ConversationActivity_group_conversation);
int size = getRecipients().getRecipientsList().size();
subtitle = (size == 1) ? getString(R.string.ConversationActivity_d_recipients_in_group_singular)
: String.format(getString(R.string.ConversationActivity_d_recipients_in_group), size);
}
int size = getRecipients().getRecipientsList().size();
subtitle = (size == 1) ? getString(R.string.ConversationActivity_d_recipients_in_group_singular)
: String.format(getString(R.string.ConversationActivity_d_recipients_in_group),
getRecipients().getRecipientsList().size());
} else {
title = getString(R.string.ConversationActivity_compose_message);
subtitle = "";

View File

@ -9,7 +9,6 @@ import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.text.Editable;
import android.text.TextUtils;
@ -81,7 +80,7 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
private final DynamicTheme dynamicTheme = new DynamicTheme();
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
private static final String TEMP_PHOTO_FILE = "__tmp_group_create_avatar_photo.tmp";
private File pendingFile = null;
private static final int PICK_CONTACT = 1;
private static final int PICK_AVATAR = 2;
@ -266,7 +265,7 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
photoPickerIntent.putExtra("aspectY", 1);
photoPickerIntent.putExtra("outputX", AVATAR_SIZE);
photoPickerIntent.putExtra("outputY", AVATAR_SIZE);
photoPickerIntent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri());
photoPickerIntent.putExtra(MediaStore.EXTRA_OUTPUT, getAvatarTempUri());
photoPickerIntent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString());
startActivityForResult(photoPickerIntent, PICK_AVATAR);
}
@ -275,23 +274,20 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
((RecipientsEditor)findViewById(R.id.recipients_text)).setHint(R.string.recipients_panel__add_member);
}
private Uri getTempUri() {
return Uri.fromFile(getTempFile());
private Uri getAvatarTempUri() {
return Uri.fromFile(createAvatarTempFile());
}
private File getTempFile() {
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
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();
}
private File createAvatarTempFile() {
try {
File f = File.createTempFile("avatar", ".tmp", getFilesDir());
pendingFile = f;
f.setWritable(true, false);
f.deleteOnExit();
return f;
} else {
} catch (IOException ioe) {
Log.e(TAG, "Error creating new temp file.", ioe);
Toast.makeText(getApplicationContext(), R.string.GroupCreateActivity_file_io_exception, Toast.LENGTH_SHORT).show();
return null;
}
}
@ -503,9 +499,11 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
@Override
protected Bitmap doInBackground(Void... voids) {
File tempFile = getTempFile();
avatarBmp = BitmapUtil.getCircleCroppedBitmap(BitmapFactory.decodeFile(tempFile.getAbsolutePath()));
tempFile.delete();
if (pendingFile != null) {
avatarBmp = BitmapUtil.getCircleCroppedBitmap(BitmapFactory.decodeFile(pendingFile.getAbsolutePath()));
pendingFile.delete();
pendingFile = null;
}
return avatarBmp;
}

View File

@ -105,6 +105,7 @@ public class BitmapUtil {
}
public static Bitmap getCircleCroppedBitmap(Bitmap bitmap) {
if (bitmap == null) return null;
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output);