repurpose ImageDivet for avatar, minor lint, fix bitmap decoding

// FREEBIE
This commit is contained in:
Jake McGinty 2014-02-18 22:08:24 -08:00
parent 649f037ed8
commit 0688dd0c2c
41 changed files with 86 additions and 72 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1018 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1021 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 617 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 991 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1000 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 424 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 841 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -20,12 +20,13 @@
android:orientation="horizontal" android:orientation="horizontal"
android:gravity="center_vertical"> android:gravity="center_vertical">
<ImageView android:id="@+id/avatar" <org.thoughtcrime.securesms.components.ImageDivet android:id="@+id/avatar"
android:layout_width="70dp" android:layout_width="70dp"
android:layout_height="70dp" android:layout_height="70dp"
position="bottom_right"
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
android:background="@drawable/thin_border" android:src="@drawable/icon"
android:src="@drawable/icon"/> android:contentDescription="@string/GroupCreateActivity_avatar_content_description" />
<EditText android:id="@+id/group_name" <EditText android:id="@+id/group_name"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -20,7 +20,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center|center_vertical" android:gravity="center|center_vertical"
android:layout_marginTop="15dp" android:layout_marginTop="15dp"
android:text="@string/contact_selection_group_activity__no_contacts" android:text="@string/contact_selection_group_activity__finding_contacts"
android:textSize="20sp" /> android:textSize="20sp" />
</LinearLayout> </LinearLayout>

View File

@ -2,7 +2,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="@string/contact_selection__menu_finished" <item android:title="@string/contact_selection__menu_finished"
android:id="@+id/menu_selection_finished" android:id="@+id/menu_selection_finished"
android:icon="@drawable/ic_menu_done_holo_dark" android:icon="?menu_accept_icon"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
/> />

View File

@ -2,9 +2,9 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="CREATE" <item android:title="@string/GroupCreateActivity_menu_create_title"
android:id="@+id/menu_create_group" android:id="@+id/menu_create_group"
android:icon="@drawable/ic_menu_accept_holo_light" android:icon="?menu_accept_icon"
android:showAsAction="always|withText"/> android:showAsAction="always|withText"/>
</menu> </menu>

View File

@ -17,10 +17,9 @@
<attr name="conversation_received_text_secondary_color" format="reference|color"/> <attr name="conversation_received_text_secondary_color" format="reference|color"/>
<attr name="actionbar_icon" format="reference" /> <attr name="actionbar_icon" format="reference" />
<attr name="lower_right_divet" format="reference" />
<attr name="conversation_background" format="reference|color"/> <attr name="conversation_background" format="reference|color"/>
<attr name="conversation_avatar_divet_right" format="reference"/>
<attr name="conversation_avatar_divet_left" format="reference"/>
<attr name="conversation_editor_background" format="reference|color"/> <attr name="conversation_editor_background" format="reference|color"/>
<attr name="conversation_editor_text_color" format="reference|color"/> <attr name="conversation_editor_text_color" format="reference|color"/>
<attr name="conversation_send_button" format="reference"/> <attr name="conversation_send_button" format="reference"/>
@ -45,4 +44,5 @@
<attr name="menu_selectall_icon" format="reference" /> <attr name="menu_selectall_icon" format="reference" />
<attr name="menu_group_icon" format="reference" /> <attr name="menu_group_icon" format="reference" />
<attr name="menu_split_icon" format="reference" /> <attr name="menu_split_icon" format="reference" />
<attr name="menu_accept_icon" format="reference" />
</resources> </resources>

View File

@ -48,6 +48,9 @@
<string name="ConversationItem_received_and_processed_key_exchange_message">Received and processed key exchange message.</string> <string name="ConversationItem_received_and_processed_key_exchange_message">Received and processed key exchange message.</string>
<string name="ConversationItem_error_received_stale_key_exchange_message">Error, received stale key exchange message.</string> <string name="ConversationItem_error_received_stale_key_exchange_message">Error, received stale key exchange message.</string>
<string name="ConversationItem_received_key_exchange_message_click_to_process">Received key exchange message, click to process.</string> <string name="ConversationItem_received_key_exchange_message_click_to_process">Received key exchange message, click to process.</string>
<string name="ConversationItem_group_action_left">%1$s has left the group.</string>
<string name="ConversationItem_group_action_joined">%1$s have joined the group.</string>
<string name="ConversationItem_group_action_modify">%1$s has updated the group.</string>
<!-- ConversationActivity --> <!-- ConversationActivity -->
<string name="ConversationActivity_initiate_secure_session_question">Initiate Secure Session?</string> <string name="ConversationActivity_initiate_secure_session_question">Initiate Secure Session?</string>
@ -128,6 +131,9 @@
<string name="GroupCreateActivity_contacts_no_members">You need at least one person in your group!</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_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 a temporary image file.</string> <string name="GroupCreateActivity_file_io_exception">File I/O error, couldn\'t create a temporary image file.</string>
<string name="GroupCreateActivity_avatar_content_description">Group Avatar</string>
<string name="GroupCreateActivity_menu_create_title">Create Group</string>
<string name="GroupCreateActivity_creating_group">Creating %1$s&#8230;</string>
<!-- ImportFragment --> <!-- ImportFragment -->
<string name="ImportFragment_import_system_sms_database">Import System SMS Database?</string> <string name="ImportFragment_import_system_sms_database">Import System SMS Database?</string>

View File

@ -10,6 +10,7 @@
<item name="conversation_list_item_date_color">#ff999999</item> <item name="conversation_list_item_date_color">#ff999999</item>
<item name="actionbar_icon">@drawable/actionbar_icon_holo_light</item> <item name="actionbar_icon">@drawable/actionbar_icon_holo_light</item>
<item name="lower_right_divet">@drawable/divet_lower_right_dark</item>
<item name="conversation_group_member_name">#99000000</item> <item name="conversation_group_member_name">#99000000</item>
<item name="conversation_sent_text_primary_color">#ffeeeeee</item> <item name="conversation_sent_text_primary_color">#ffeeeeee</item>
@ -18,8 +19,6 @@
<item name="conversation_received_text_secondary_color">#33000000</item> <item name="conversation_received_text_secondary_color">#33000000</item>
<item name="conversation_background">#ffdddddd</item> <item name="conversation_background">#ffdddddd</item>
<item name="conversation_avatar_divet_right">@drawable/divet_right_light</item>
<item name="conversation_avatar_divet_left">@drawable/divet_left_light</item>
<item name="conversation_editor_background">#eeeeee</item> <item name="conversation_editor_background">#eeeeee</item>
<item name="conversation_editor_text_color">@color/edit_text_light_theme</item> <item name="conversation_editor_text_color">@color/edit_text_light_theme</item>
<item name="conversation_send_button">@drawable/ic_send_holo_light</item> <item name="conversation_send_button">@drawable/ic_send_holo_light</item>
@ -39,6 +38,7 @@
<item name="menu_trash_icon">@drawable/ic_menu_trash_holo_light</item> <item name="menu_trash_icon">@drawable/ic_menu_trash_holo_light</item>
<item name="menu_selectall_icon">@drawable/ic_menu_selectall_holo_light</item> <item name="menu_selectall_icon">@drawable/ic_menu_selectall_holo_light</item>
<item name="menu_split_icon">@drawable/ic_menu_split_holo_light</item> <item name="menu_split_icon">@drawable/ic_menu_split_holo_light</item>
<item name="menu_accept_icon">@drawable/ic_menu_accept_holo_light</item>
</style> </style>
@ -69,10 +69,9 @@
<item name="conversation_received_text_secondary_color">#33000000</item> <item name="conversation_received_text_secondary_color">#33000000</item>
<item name="actionbar_icon">@drawable/actionbar_icon_holo_dark</item> <item name="actionbar_icon">@drawable/actionbar_icon_holo_dark</item>
<item name="lower_right_divet">@drawable/divet_lower_right_light</item>
<item name="conversation_background">@color/black</item> <item name="conversation_background">@color/black</item>
<item name="conversation_avatar_divet_right">@drawable/divet_right_dark</item>
<item name="conversation_avatar_divet_left">@drawable/divet_left_dark</item>
<item name="conversation_editor_background">@color/black</item> <item name="conversation_editor_background">@color/black</item>
<item name="conversation_editor_text_color">@color/edit_text_dark_theme</item> <item name="conversation_editor_text_color">@color/edit_text_dark_theme</item>
<item name="conversation_send_button">@drawable/ic_send_holo_dark</item> <item name="conversation_send_button">@drawable/ic_send_holo_dark</item>
@ -91,6 +90,7 @@
<item name="menu_trash_icon">@drawable/ic_menu_trash_holo_dark</item> <item name="menu_trash_icon">@drawable/ic_menu_trash_holo_dark</item>
<item name="menu_selectall_icon">@drawable/ic_menu_selectall_holo_dark</item> <item name="menu_selectall_icon">@drawable/ic_menu_selectall_holo_dark</item>
<item name="menu_split_icon">@drawable/ic_menu_split_holo_dark</item> <item name="menu_split_icon">@drawable/ic_menu_split_holo_dark</item>
<item name="menu_accept_icon">@drawable/ic_menu_accept_holo_dark</item>
</style> </style>
<style name="TextSecure.DarkTheme.NavigationDrawer" <style name="TextSecure.DarkTheme.NavigationDrawer"

View File

@ -25,7 +25,6 @@ import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
@ -61,7 +60,6 @@ import org.thoughtcrime.securesms.components.EmojiToggle;
import org.thoughtcrime.securesms.components.RecipientsPanel; import org.thoughtcrime.securesms.components.RecipientsPanel;
import org.thoughtcrime.securesms.contacts.ContactAccessor; import org.thoughtcrime.securesms.contacts.ContactAccessor;
import org.thoughtcrime.securesms.contacts.ContactAccessor.ContactData; import org.thoughtcrime.securesms.contacts.ContactAccessor.ContactData;
import org.thoughtcrime.securesms.contacts.ContactPhotoFactory;
import org.thoughtcrime.securesms.crypto.KeyExchangeInitiator; import org.thoughtcrime.securesms.crypto.KeyExchangeInitiator;
import org.thoughtcrime.securesms.crypto.KeyExchangeProcessor; import org.thoughtcrime.securesms.crypto.KeyExchangeProcessor;
import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.DatabaseFactory;
@ -496,7 +494,7 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
title = (!TextUtils.isEmpty(groupName)) ? groupName : getString(R.string.ConversationActivity_unnamed_group); title = (!TextUtils.isEmpty(groupName)) ? groupName : getString(R.string.ConversationActivity_unnamed_group);
final Bitmap avatar = getRecipients().getPrimaryRecipient().getContactPhoto(); final Bitmap avatar = getRecipients().getPrimaryRecipient().getContactPhoto();
if (avatar != null) { if (avatar != null) {
getSupportActionBar().setIcon(new BitmapDrawable(getResources(), BitmapUtil.getCroppedBitmap(avatar))); getSupportActionBar().setIcon(new BitmapDrawable(getResources(), BitmapUtil.getCircleCroppedBitmap(avatar)));
} }
} else { } else {
title = getString(R.string.ConversationActivity_group_conversation); title = getString(R.string.ConversationActivity_group_conversation);

View File

@ -34,7 +34,6 @@ import android.provider.ContactsContract.QuickContact;
import org.thoughtcrime.securesms.util.DateUtils; import org.thoughtcrime.securesms.util.DateUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log; import android.util.Log;
import android.util.Pair;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
@ -55,7 +54,6 @@ import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.service.SendReceiveService; import org.thoughtcrime.securesms.service.SendReceiveService;
import org.thoughtcrime.securesms.util.BitmapUtil; import org.thoughtcrime.securesms.util.BitmapUtil;
import org.thoughtcrime.securesms.util.Emoji; import org.thoughtcrime.securesms.util.Emoji;
import org.whispersystems.textsecure.util.Base64;
import org.whispersystems.textsecure.util.FutureTaskListener; import org.whispersystems.textsecure.util.FutureTaskListener;
import org.whispersystems.textsecure.util.ListenableFutureTask; import org.whispersystems.textsecure.util.ListenableFutureTask;
import org.whispersystems.textsecure.util.Util; import org.whispersystems.textsecure.util.Util;
@ -65,7 +63,6 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.List;
import static org.whispersystems.textsecure.push.PushMessageProtos.PushMessageContent.GroupContext; import static org.whispersystems.textsecure.push.PushMessageProtos.PushMessageContent.GroupContext;
@ -178,17 +175,19 @@ public class ConversationItem extends LinearLayout {
/// MessageRecord Attribute Parsers /// MessageRecord Attribute Parsers
private void setBodyText(MessageRecord messageRecord) { private void setBodyText(MessageRecord messageRecord) {
// TODO jake is going to fill these in
switch (messageRecord.getGroupAction()) { switch (messageRecord.getGroupAction()) {
case GroupContext.Type.QUIT_VALUE: case GroupContext.Type.QUIT_VALUE:
bodyText.setText(messageRecord.getIndividualRecipient().toShortString() + " has left the group."); bodyText.setText(context.getString(R.string.ConversationItem_group_action_left,
messageRecord.getIndividualRecipient().toShortString()));
return; return;
case GroupContext.Type.ADD_VALUE: case GroupContext.Type.ADD_VALUE:
case GroupContext.Type.CREATE_VALUE: case GroupContext.Type.CREATE_VALUE:
bodyText.setText(Util.join(GroupUtil.getSerializedArgumentMembers(messageRecord.getGroupActionArguments()), ", ") + " have joined the group."); bodyText.setText(context.getString(R.string.ConversationItem_group_action_joined,
Util.join(GroupUtil.getSerializedArgumentMembers(messageRecord.getGroupActionArguments()), ", ")));
return; return;
case GroupContext.Type.MODIFY_VALUE: case GroupContext.Type.MODIFY_VALUE:
bodyText.setText(messageRecord.getIndividualRecipient() + " has updated the group."); bodyText.setText(context.getString(R.string.ConversationItem_group_action_modify,
messageRecord.getIndividualRecipient()));
return; return;
} }
@ -254,11 +253,9 @@ public class ConversationItem extends LinearLayout {
} }
private void setNotificationMmsAttributes(NotificationMmsMessageRecord messageRecord) { private void setNotificationMmsAttributes(NotificationMmsMessageRecord messageRecord) {
String messageSize = String.format(getContext() String messageSize = String.format(context.getString(R.string.ConversationItem_message_size_d_kb),
.getString(R.string.ConversationItem_message_size_d_kb),
messageRecord.getMessageSize()); messageRecord.getMessageSize());
String expires = String.format(getContext() String expires = String.format(context.getString(R.string.ConversationItem_expires_s),
.getString(R.string.ConversationItem_expires_s),
DateUtils.getRelativeTimeSpanString(getContext(), DateUtils.getRelativeTimeSpanString(getContext(),
messageRecord.getExpiration(), messageRecord.getExpiration(),
false)); false));
@ -341,7 +338,7 @@ public class ConversationItem extends LinearLayout {
} }
private void setContactPhotoForRecipient(final Recipient recipient) { private void setContactPhotoForRecipient(final Recipient recipient) {
contactPhoto.setImageBitmap(BitmapUtil.getCroppedBitmap(recipient.getContactPhoto())); contactPhoto.setImageBitmap(BitmapUtil.getCircleCroppedBitmap(recipient.getContactPhoto()));
contactPhoto.setOnClickListener(new View.OnClickListener() { contactPhoto.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View File

@ -32,7 +32,6 @@ import android.text.style.StyleSpan;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.QuickContactBadge;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
@ -130,7 +129,7 @@ public class ConversationListItem extends RelativeLayout
private void setContactPhoto(final Recipient recipient) { private void setContactPhoto(final Recipient recipient) {
if (recipient == null) return; if (recipient == null) return;
contactPhotoImage.setImageBitmap(BitmapUtil.getCroppedBitmap(recipient.getContactPhoto())); contactPhotoImage.setImageBitmap(BitmapUtil.getCircleCroppedBitmap(recipient.getContactPhoto()));
contactPhotoImage.setOnClickListener(new View.OnClickListener() { contactPhotoImage.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View File

@ -17,7 +17,9 @@ import android.util.Pair;
import android.view.View; import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -36,6 +38,7 @@ import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
import org.thoughtcrime.securesms.recipients.Recipients; import org.thoughtcrime.securesms.recipients.Recipients;
import org.thoughtcrime.securesms.sms.MessageSender; import org.thoughtcrime.securesms.sms.MessageSender;
import org.thoughtcrime.securesms.util.ActionBarUtil; import org.thoughtcrime.securesms.util.ActionBarUtil;
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.GroupUtil; import org.thoughtcrime.securesms.util.GroupUtil;
@ -67,20 +70,23 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
private final static String TAG = GroupCreateActivity.class.getSimpleName(); private final static String TAG = GroupCreateActivity.class.getSimpleName();
public static final String MASTER_SECRET_EXTRA = "master_secret"; public static final String MASTER_SECRET_EXTRA = "master_secret";
private final DynamicTheme dynamicTheme = new DynamicTheme(); private final DynamicTheme dynamicTheme = new DynamicTheme();
private final DynamicLanguage dynamicLanguage = new DynamicLanguage(); private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
private static final String TEMP_PHOTO_FILE = "__tmp_group_create_avatar_photo.png"; private static final String TEMP_PHOTO_FILE = "__tmp_group_create_avatar_photo.tmp";
private static final int PICK_CONTACT = 1; private static final int PICK_CONTACT = 1;
private static final int PICK_AVATAR = 2; private static final int PICK_AVATAR = 2;
public static final int AVATAR_SIZE = 210;
private EditText groupName; private EditText groupName;
private ListView lv; private ListView lv;
private PushRecipientsPanel recipientsPanel; private PushRecipientsPanel recipientsPanel;
private ImageView avatar; private ImageView avatar;
private TextView creatingText;
private MasterSecret masterSecret; private MasterSecret masterSecret;
private Bitmap avatarBmp; private Bitmap avatarBmp;
@ -172,7 +178,13 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
private void initializeResources() { private void initializeResources() {
masterSecret = getIntent().getParcelableExtra(MASTER_SECRET_EXTRA); masterSecret = getIntent().getParcelableExtra(MASTER_SECRET_EXTRA);
lv = (ListView) findViewById(R.id.selected_contacts_list);
avatar = (ImageView) findViewById(R.id.avatar);
groupName = (EditText) findViewById(R.id.group_name); groupName = (EditText) findViewById(R.id.group_name);
creatingText = (TextView) findViewById(R.id.creating_group_text);
recipientsPanel = (PushRecipientsPanel) findViewById(R.id.recipients);
groupName.addTextChangedListener(new TextWatcher() { groupName.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { }
@ -187,7 +199,6 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
} }
}); });
lv = (ListView) findViewById(R.id.selected_contacts_list);
SelectedRecipientsAdapter adapter = new SelectedRecipientsAdapter(this, android.R.id.text1, new ArrayList<Recipient>()); SelectedRecipientsAdapter adapter = new SelectedRecipientsAdapter(this, android.R.id.text1, new ArrayList<Recipient>());
adapter.setOnRecipientDeletedListener(new SelectedRecipientsAdapter.OnRecipientDeletedListener() { adapter.setOnRecipientDeletedListener(new SelectedRecipientsAdapter.OnRecipientDeletedListener() {
@Override @Override
@ -197,7 +208,6 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
}); });
lv.setAdapter(adapter); lv.setAdapter(adapter);
recipientsPanel = (PushRecipientsPanel) findViewById(R.id.recipients);
recipientsPanel.setPanelChangeListener(new PushRecipientsPanel.RecipientsPanelChangedListener() { recipientsPanel.setPanelChangeListener(new PushRecipientsPanel.RecipientsPanelChangedListener() {
@Override @Override
public void onRecipientsPanelUpdate(Recipients recipients) { public void onRecipientsPanelUpdate(Recipients recipients) {
@ -210,7 +220,6 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
}); });
(findViewById(R.id.contacts_button)).setOnClickListener(new AddRecipientButtonListener()); (findViewById(R.id.contacts_button)).setOnClickListener(new AddRecipientButtonListener());
avatar = (ImageView) findViewById(R.id.avatar);
avatar.setOnClickListener(new View.OnClickListener() { avatar.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -219,8 +228,8 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
photoPickerIntent.putExtra("crop", "true"); photoPickerIntent.putExtra("crop", "true");
photoPickerIntent.putExtra("aspectX", 1); photoPickerIntent.putExtra("aspectX", 1);
photoPickerIntent.putExtra("aspectY", 1); photoPickerIntent.putExtra("aspectY", 1);
photoPickerIntent.putExtra("outputX", 210); photoPickerIntent.putExtra("outputX", AVATAR_SIZE);
photoPickerIntent.putExtra("outputY", 210); photoPickerIntent.putExtra("outputY", AVATAR_SIZE);
photoPickerIntent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri()); photoPickerIntent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri());
photoPickerIntent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString()); photoPickerIntent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString());
startActivityForResult(photoPickerIntent, PICK_AVATAR); startActivityForResult(photoPickerIntent, PICK_AVATAR);
@ -292,7 +301,8 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
findViewById(R.id.group_details_layout).setVisibility(View.GONE); findViewById(R.id.group_details_layout).setVisibility(View.GONE);
findViewById(R.id.creating_group_layout).setVisibility(View.VISIBLE); findViewById(R.id.creating_group_layout).setVisibility(View.VISIBLE);
findViewById(R.id.menu_create_group).setVisibility(View.GONE); findViewById(R.id.menu_create_group).setVisibility(View.GONE);
((TextView)findViewById(R.id.creating_group_text)).setText("Creating " + groupName.getText().toString() + "..."); if (groupName.getText() != null)
creatingText.setText(getString(R.string.GroupCreateActivity_creating_group, groupName.getText().toString()));
} }
private void disableWhisperGroupCreatingUi() { private void disableWhisperGroupCreatingUi() {
@ -312,7 +322,6 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
@Override @Override
public void onActivityResult(int reqCode, int resultCode, Intent data) { public void onActivityResult(int reqCode, int resultCode, Intent data) {
Log.w("ComposeMessageActivity", "onActivityResult called: " + resultCode + " , " + data);
super.onActivityResult(reqCode, resultCode, data); super.onActivityResult(reqCode, resultCode, data);
if (data == null || resultCode != Activity.RESULT_OK) if (data == null || resultCode != Activity.RESULT_OK)
@ -331,7 +340,7 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
addSelectedContact(recipient); addSelectedContact(recipient);
} }
} catch (RecipientFormattingException e) { } catch (RecipientFormattingException e) {
Log.w("GroupCreateActivity", e); Log.w(TAG, e);
} }
} }
} }
@ -339,10 +348,9 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
break; break;
case PICK_AVATAR: case PICK_AVATAR:
if(resultCode == RESULT_OK) { if(resultCode == RESULT_OK) {
File tempFile = getTempFile();
avatarBmp = BitmapFactory.decodeFile(tempFile.getAbsolutePath()); new DecodeCropAndSetAsyncTask().execute();
if (avatarBmp != null) avatar.setImageBitmap(avatarBmp);
tempFile.delete();
break; break;
} else { } else {
Log.i(TAG, "Avatar selection result was not RESULT_OK."); Log.i(TAG, "Avatar selection result was not RESULT_OK.");
@ -384,7 +392,7 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
} catch (RecipientFormattingException e) { } catch (RecipientFormattingException e) {
throw new AssertionError(e); throw new AssertionError(e);
} catch (MmsException e) { } catch (MmsException e) {
Log.w("GroupCreateActivity", e); Log.w(TAG, e);
groupDatabase.remove(groupId, TextSecurePreferences.getLocalNumber(this)); groupDatabase.remove(groupId, TextSecurePreferences.getLocalNumber(this));
throw new MmsException(e); throw new MmsException(e);
} }
@ -409,6 +417,22 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
return results; return results;
} }
private class DecodeCropAndSetAsyncTask extends AsyncTask<Void,Void,Bitmap> {
@Override
protected Bitmap doInBackground(Void... voids) {
File tempFile = getTempFile();
avatarBmp = BitmapUtil.getCircleCroppedBitmap(BitmapFactory.decodeFile(tempFile.getAbsolutePath()));
tempFile.delete();
return avatarBmp;
}
@Override
protected void onPostExecute(Bitmap result) {
if (avatarBmp != null) avatar.setImageBitmap(avatarBmp);
}
}
private class CreateMmsGroupAsyncTask extends AsyncTask<Void,Void,Long> { private class CreateMmsGroupAsyncTask extends AsyncTask<Void,Void,Long> {
@Override @Override
@ -460,10 +484,10 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
try { try {
return handleCreatePushGroup(name, avatarBytes, selectedContacts); return handleCreatePushGroup(name, avatarBytes, selectedContacts);
} catch (MmsException e) { } catch (MmsException e) {
Log.w("GroupCreateActivity", e); Log.w(TAG, e);
return new Pair<Long,Recipients>(RES_MMS_EXCEPTION, null); return new Pair<Long,Recipients>(RES_MMS_EXCEPTION, null);
} catch (InvalidNumberException e) { } catch (InvalidNumberException e) {
Log.w("GroupCreateActivity", e); Log.w(TAG, e);
return new Pair<Long,Recipients>(RES_BAD_NUMBER, null); return new Pair<Long,Recipients>(RES_BAD_NUMBER, null);
} }
} }

View File

@ -339,6 +339,7 @@ public class PushContactSelectionListFragment extends SherlockListFragment
public void onLoadFinished(Loader<Cursor> arg0, Cursor cursor) { public void onLoadFinished(Loader<Cursor> arg0, Cursor cursor) {
Cursor pushCursor = ContactAccessor.getInstance().getCursorForContactsWithPush(getActivity()); Cursor pushCursor = ContactAccessor.getInstance().getCursorForContactsWithPush(getActivity());
((CursorAdapter) getListAdapter()).changeCursor(new MergeCursor(new Cursor[]{pushCursor,cursor})); ((CursorAdapter) getListAdapter()).changeCursor(new MergeCursor(new Cursor[]{pushCursor,cursor}));
((TextView)getView().findViewById(android.R.id.empty)).setText(R.string.contact_selection_group_activity__no_contacts);
} }
@Override @Override

View File

@ -265,6 +265,7 @@ public class SingleContactSelectionListFragment extends SherlockListFragment
public void onLoadFinished(Loader<Cursor> arg0, Cursor cursor) { public void onLoadFinished(Loader<Cursor> arg0, Cursor cursor) {
Cursor pushCursor = ContactAccessor.getInstance().getCursorForContactsWithPush(getActivity()); Cursor pushCursor = ContactAccessor.getInstance().getCursorForContactsWithPush(getActivity());
((CursorAdapter) getListAdapter()).changeCursor(new MergeCursor(new Cursor[]{pushCursor,cursor})); ((CursorAdapter) getListAdapter()).changeCursor(new MergeCursor(new Cursor[]{pushCursor,cursor}));
((TextView)getView().findViewById(android.R.id.empty)).setText(R.string.contact_selection_group_activity__no_contacts);
} }
@Override @Override

View File

@ -12,7 +12,7 @@ import org.thoughtcrime.securesms.R;
public class ImageDivet extends ImageView { public class ImageDivet extends ImageView {
private static final float CORNER_OFFSET = 12F; private static final float CORNER_OFFSET = 12F;
private static final String[] POSITIONS = new String[] {"left", "right"}; private static final String[] POSITIONS = new String[] {"bottom_right"};
private Drawable drawable; private Drawable drawable;
@ -46,16 +46,12 @@ public class ImageDivet extends ImageView {
} }
private void setDrawable() { private void setDrawable() {
int attributes[] = new int[] {R.attr.conversation_avatar_divet_left, int attributes[] = new int[] {R.attr.lower_right_divet};
R.attr.conversation_avatar_divet_right};
TypedArray drawables = getContext().obtainStyledAttributes(attributes); TypedArray drawables = getContext().obtainStyledAttributes(attributes);
switch (position) { switch (position) {
case 0: case 0:
drawable = drawables.getDrawable(1);
break;
case 1:
drawable = drawables.getDrawable(0); drawable = drawables.getDrawable(0);
break; break;
} }
@ -98,26 +94,16 @@ public class ImageDivet extends ImageView {
} }
private void computeBounds(Canvas c) { private void computeBounds(Canvas c) {
final int left = 0;
final int top = 0;
final int right = getWidth(); final int right = getWidth();
final int bottom = getHeight();
final int cornerOffset = (int) getCloseOffset();
switch (position) { switch (position) {
case 1:
drawable.setBounds(
right - drawableIntrinsicWidth,
top + cornerOffset,
right,
top + cornerOffset + drawableIntrinsicHeight);
break;
case 0: case 0:
drawable.setBounds( drawable.setBounds(
left, right - drawableIntrinsicWidth,
top + cornerOffset, bottom - drawableIntrinsicHeight,
left + drawableIntrinsicWidth, right,
top + cornerOffset + drawableIntrinsicHeight); bottom);
break; break;
} }
} }

View File

@ -11,6 +11,7 @@ import android.graphics.Rect;
import android.net.Uri; import android.net.Uri;
import android.util.Log; import android.util.Log;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
@ -66,7 +67,7 @@ public class BitmapUtil {
options.inSampleSize = scaler; options.inSampleSize = scaler;
options.inJustDecodeBounds = false; options.inJustDecodeBounds = false;
Bitmap roughThumbnail = BitmapFactory.decodeStream(data, null, options); Bitmap roughThumbnail = BitmapFactory.decodeStream(new BufferedInputStream(data), null, options);
if (roughThumbnail == null) { if (roughThumbnail == null) {
throw new BitmapDecodingException("Decoded stream was null."); throw new BitmapDecodingException("Decoded stream was null.");
@ -103,7 +104,7 @@ public class BitmapUtil {
return options; return options;
} }
public static Bitmap getCroppedBitmap(Bitmap bitmap) { public static Bitmap getCircleCroppedBitmap(Bitmap bitmap) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Bitmap.Config.ARGB_8888); bitmap.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output); Canvas canvas = new Canvas(output);