Merge pull request #1260 from mcginty/message-layout-lint

Conversation item tweaks
This commit is contained in:
Moxie Marlinspike 2014-04-03 10:07:23 -07:00
commit 9e2f82954f
4 changed files with 41 additions and 91 deletions

View File

@ -48,47 +48,37 @@
android:background="?conversation_item_received_background" android:background="?conversation_item_received_background"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <TextView android:id="@+id/conversation_item_body"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="5dip" android:paddingTop="5dip"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:paddingRight="10dp" android:paddingRight="10dp"
android:orientation="horizontal"> android:textAppearance="?android:attr/textAppearanceSmall"
<ImageView android:id="@+id/key_exchange_indicator" android:textColor="?conversation_received_text_primary_color"
android:layout_width="wrap_content" android:textSize="16sp"
android:layout_height="wrap_content" android:autoLink="all"
android:src="@drawable/ic_menu_login" android:linksClickable="true" />
android:contentDescription="Key Exchange Indicator"
android:visibility="gone" />
<TextView android:id="@+id/conversation_item_body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?conversation_received_text_primary_color"
android:textSize="16sp"
android:autoLink="all"
android:linksClickable="true" />
</LinearLayout>
<FrameLayout android:id="@+id/mms_view" <FrameLayout android:id="@+id/mms_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone"> android:visibility="gone">
<ImageView android:id="@+id/image_view" <ImageView android:id="@+id/image_view"
android:layout_width="230dip" android:layout_width="230dip"
android:layout_height="174dip" android:layout_height="174dip"
android:layout_gravity="center" android:layout_gravity="center"
android:scaleType="centerInside" android:scaleType="centerInside"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:contentDescription="Message Media" android:contentDescription="@string/conversation_item__mms_image_description"
android:visibility="gone" /> android:visibility="gone" />
<ImageButton android:id="@+id/play_slideshow_button" <ImageButton android:id="@+id/play_slideshow_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:src="@drawable/mms_play_btn" android:src="@drawable/mms_play_btn"
android:contentDescription="Play Button" android:contentDescription="@string/conversation_item__play_button_description"
android:visibility="gone" /> android:visibility="gone" />
</FrameLayout> </FrameLayout>
@ -130,7 +120,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingRight="3dip" android:paddingRight="3dip"
android:src="?conversation_delivered_indicator" android:src="?conversation_delivered_indicator"
android:contentDescription="Delivered Indicator" android:contentDescription="@string/conversation_item_sent__delivered_description"
android:visibility="gone" /> android:visibility="gone" />
<ImageView android:id="@+id/sms_secure_indicator" <ImageView android:id="@+id/sms_secure_indicator"
@ -140,7 +130,7 @@
android:paddingRight="4dp" android:paddingRight="4dp"
android:paddingTop="2dp" android:paddingTop="2dp"
android:src="?menu_lock_icon_small" android:src="?menu_lock_icon_small"
android:contentDescription="Secure Message Indicator" android:contentDescription="@string/conversation_item__secure_message_description"
android:visibility="gone" /> android:visibility="gone" />
<TextView android:id="@+id/conversation_item_date" <TextView android:id="@+id/conversation_item_date"
@ -168,7 +158,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/ic_list_alert_sms_failed" android:src="@drawable/ic_list_alert_sms_failed"
android:contentDescription="Send Failed Indicator" android:contentDescription="@string/conversation_item_sent__send_failed_indicator_description"
android:visibility="gone" /> android:visibility="gone" />
</LinearLayout> </LinearLayout>

View File

@ -29,7 +29,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/ic_list_alert_sms_failed" android:src="@drawable/ic_list_alert_sms_failed"
android:visibility="gone" android:visibility="gone"
android:contentDescription="Send Failed Indicator"/> android:contentDescription="@string/conversation_item_sent__send_failed_indicator_description"/>
<ImageView <ImageView
android:id="@+id/pending_approval_indicator" android:id="@+id/pending_approval_indicator"
@ -38,7 +38,7 @@
android:src="@drawable/ic_dialog_info_holo_light" android:src="@drawable/ic_dialog_info_holo_light"
android:visibility="gone" android:visibility="gone"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:contentDescription="Pending Approval"/> android:contentDescription="@string/conversation_item_sent__pending_approval_description"/>
</LinearLayout> </LinearLayout>
<LinearLayout android:id="@+id/conversation_item_parent" <LinearLayout android:id="@+id/conversation_item_parent"
@ -52,30 +52,16 @@
android:layout_marginRight="12dp" android:layout_marginRight="12dp"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout android:layout_width="wrap_content" <TextView android:id="@+id/conversation_item_body"
android:layout_height="wrap_content" android:autoLink="all"
android:orientation="horizontal" android:layout_width="wrap_content"
android:paddingTop="5dip"> android:layout_height="wrap_content"
android:paddingTop="5dip"
<TextView android:id="@+id/conversation_item_body" android:linksClickable="true"
android:autoLink="all" android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content" android:textColor="?conversation_sent_text_primary_color"
android:layout_height="wrap_content" android:textColorLink="?conversation_sent_text_primary_color"
android:linksClickable="true" android:textSize="16sp" />
android:textAppearance="?android:attr/textAppearanceSmall"
android:gravity="right"
android:textColor="?conversation_sent_text_primary_color"
android:textColorLink="?conversation_sent_text_primary_color"
android:textSize="16sp" />
<ImageView
android:id="@+id/key_exchange_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_menu_login"
android:visibility="gone"
android:contentDescription="Key Exchange Indicator"/>
</LinearLayout>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mms_view" android:id="@+id/mms_view"
@ -91,7 +77,7 @@
android:scaleType="centerInside" android:scaleType="centerInside"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:visibility="gone" android:visibility="gone"
android:contentDescription="Media Message"/> android:contentDescription="@string/conversation_item__mms_image_description"/>
<ImageButton <ImageButton
android:id="@+id/play_slideshow_button" android:id="@+id/play_slideshow_button"
@ -100,7 +86,7 @@
android:src="@drawable/mms_play_btn" android:src="@drawable/mms_play_btn"
android:layout_gravity="center" android:layout_gravity="center"
android:visibility="gone" android:visibility="gone"
android:contentDescription="Play Button"/> android:contentDescription="@string/conversation_item__play_button_description"/>
</FrameLayout> </FrameLayout>
@ -140,7 +126,7 @@
android:paddingRight="3dip" android:paddingRight="3dip"
android:src="?conversation_delivered_indicator" android:src="?conversation_delivered_indicator"
android:visibility="gone" android:visibility="gone"
android:contentDescription="Delivered Indicator"/> android:contentDescription="@string/conversation_item_sent__delivered_description"/>
<TextView android:id="@+id/group_message_status" <TextView android:id="@+id/group_message_status"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -175,7 +161,7 @@
android:visibility="gone" android:visibility="gone"
android:paddingLeft="4dp" android:paddingLeft="4dp"
android:paddingBottom="3dp" android:paddingBottom="3dp"
android:contentDescription="Secure Message Indicator" /> android:contentDescription="@string/conversation_item__secure_message_description" />
</LinearLayout> </LinearLayout>
@ -189,17 +175,6 @@
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
/> />
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/contact_photo"
android:layout_alignParentRight="true"
android:layout_width="40dp"
android:layout_height="40dp"
android:cropToPadding="true"
android:layout_marginRight="0dip"
android:padding="0dip"
android:scaleType="centerCrop"
android:visibility="gone" />
<TextView android:id="@+id/indicator_text" <TextView android:id="@+id/indicator_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@ -437,9 +437,17 @@
<string name="conversation_activity__send">Send</string> <string name="conversation_activity__send">Send</string>
<string name="conversation_activity__remove">Remove</string> <string name="conversation_activity__remove">Remove</string>
<!-- conversation_item -->
<string name="conversation_item__mms_image_description">Media Message</string>
<string name="conversation_item__play_button_description">Play Button</string>
<string name="conversation_item__secure_message_description">Secure Message Indicator</string>
<!-- conversation_item_sent --> <!-- conversation_item_sent -->
<string name="conversation_item_sent__download">Download</string> <string name="conversation_item_sent__download">Download</string>
<string name="conversation_item_sent__downloading">Downloading</string> <string name="conversation_item_sent__downloading">Downloading</string>
<string name="conversation_item_sent__send_failed_indicator_description">Send Failed Indicator</string>
<string name="conversation_item_sent__pending_approval_description">Pending Approval</string>
<string name="conversation_item_sent__delivered_description">Delivered Indicator</string>
<!-- conversation_item_received --> <!-- conversation_item_received -->
<string name="conversation_item_received__download">Download</string> <string name="conversation_item_received__download">Download</string>

View File

@ -57,7 +57,6 @@ import org.thoughtcrime.securesms.util.DateUtils;
import org.thoughtcrime.securesms.util.Emoji; import org.thoughtcrime.securesms.util.Emoji;
import org.thoughtcrime.securesms.util.Dialogs; import org.thoughtcrime.securesms.util.Dialogs;
import org.whispersystems.textsecure.crypto.MasterSecret; import org.whispersystems.textsecure.crypto.MasterSecret;
import org.whispersystems.textsecure.storage.Session;
import org.whispersystems.textsecure.util.FutureTaskListener; import org.whispersystems.textsecure.util.FutureTaskListener;
import org.whispersystems.textsecure.util.ListenableFutureTask; import org.whispersystems.textsecure.util.ListenableFutureTask;
@ -109,7 +108,6 @@ public class ConversationItem extends LinearLayout {
private TextView groupStatusText; private TextView groupStatusText;
private ImageView secureImage; private ImageView secureImage;
private ImageView failedImage; private ImageView failedImage;
private ImageView keyImage;
private ImageView contactPhoto; private ImageView contactPhoto;
private ImageView deliveredImage; private ImageView deliveredImage;
private View triangleTick; private View triangleTick;
@ -149,14 +147,13 @@ public class ConversationItem extends LinearLayout {
this.groupStatusText = (TextView) findViewById(R.id.group_message_status); this.groupStatusText = (TextView) findViewById(R.id.group_message_status);
this.secureImage = (ImageView)findViewById(R.id.sms_secure_indicator); this.secureImage = (ImageView)findViewById(R.id.sms_secure_indicator);
this.failedImage = (ImageView)findViewById(R.id.sms_failed_indicator); this.failedImage = (ImageView)findViewById(R.id.sms_failed_indicator);
this.keyImage = (ImageView)findViewById(R.id.key_exchange_indicator);
this.mmsContainer = findViewById(R.id.mms_view); this.mmsContainer = findViewById(R.id.mms_view);
this.mmsThumbnail = (ImageView)findViewById(R.id.image_view); this.mmsThumbnail = (ImageView)findViewById(R.id.image_view);
this.mmsDownloadButton = (Button) findViewById(R.id.mms_download_button); this.mmsDownloadButton = (Button) findViewById(R.id.mms_download_button);
this.mmsDownloadingLabel = (TextView) findViewById(R.id.mms_label_downloading); this.mmsDownloadingLabel = (TextView) findViewById(R.id.mms_label_downloading);
this.contactPhoto = (ImageView)findViewById(R.id.contact_photo); this.contactPhoto = (ImageView)findViewById(R.id.contact_photo);
this.deliveredImage = (ImageView)findViewById(R.id.delivered_indicator); this.deliveredImage = (ImageView)findViewById(R.id.delivered_indicator);
this.conversationParent = (View) findViewById(R.id.conversation_item_parent); this.conversationParent = findViewById(R.id.conversation_item_parent);
this.triangleTick = findViewById(R.id.triangle_tick); this.triangleTick = findViewById(R.id.triangle_tick);
this.pendingIndicator = (ImageView)findViewById(R.id.pending_approval_indicator); this.pendingIndicator = (ImageView)findViewById(R.id.pending_approval_indicator);
this.backgroundDrawables = context.obtainStyledAttributes(STYLE_ATTRIBUTES); this.backgroundDrawables = context.obtainStyledAttributes(STYLE_ATTRIBUTES);
@ -265,7 +262,7 @@ public class ConversationItem extends LinearLayout {
indicatorText.setVisibility(messageRecord.isPendingSmsFallback() ? View.VISIBLE : View.GONE); indicatorText.setVisibility(messageRecord.isPendingSmsFallback() ? View.VISIBLE : View.GONE);
} }
secureImage.setVisibility(messageRecord.isSecure() ? View.VISIBLE : View.GONE); secureImage.setVisibility(messageRecord.isSecure() ? View.VISIBLE : View.GONE);
keyImage.setVisibility(messageRecord.isKeyExchange() ? View.VISIBLE : View.GONE); bodyText.setCompoundDrawablesWithIntrinsicBounds(0, 0, messageRecord.isKeyExchange() ? R.drawable.ic_menu_login : 0, 0);
deliveredImage.setVisibility(!messageRecord.isKeyExchange() && messageRecord.isDelivered() ? View.VISIBLE : View.GONE); deliveredImage.setVisibility(!messageRecord.isKeyExchange() && messageRecord.isDelivered() ? View.VISIBLE : View.GONE);
mmsThumbnail.setVisibility(View.GONE); mmsThumbnail.setVisibility(View.GONE);
@ -409,6 +406,7 @@ public class ConversationItem extends LinearLayout {
} }
private void setContactPhotoForRecipient(final Recipient recipient) { private void setContactPhotoForRecipient(final Recipient recipient) {
if (contactPhoto == null) return;
contactPhoto.setImageBitmap(BitmapUtil.getCircleCroppedBitmap(recipient.getContactPhoto())); contactPhoto.setImageBitmap(BitmapUtil.getCircleCroppedBitmap(recipient.getContactPhoto()));
contactPhoto.setOnClickListener(new View.OnClickListener() { contactPhoto.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -480,7 +478,7 @@ public class ConversationItem extends LinearLayout {
mediaScannerConnection = new MediaScannerConnection(context, this); mediaScannerConnection = new MediaScannerConnection(context, this);
mediaScannerConnection.connect(); mediaScannerConnection.connect();
} catch (IOException ioe) { } catch (IOException ioe) {
Log.w("ConversationItem", ioe); Log.w(TAG, ioe);
this.obtainMessage(FAILURE).sendToTarget(); this.obtainMessage(FAILURE).sendToTarget();
} }
} }
@ -571,7 +569,7 @@ public class ConversationItem extends LinearLayout {
} }
private void fireIntent() { private void fireIntent() {
Log.w("ConversationItem", "Clicked: " + slide.getUri() + " , " + slide.getContentType()); Log.w(TAG, "Clicked: " + slide.getUri() + " , " + slide.getContentType());
Intent intent = new Intent(Intent.ACTION_VIEW); Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setDataAndType(slide.getUri(), slide.getContentType()); intent.setDataAndType(slide.getUri(), slide.getContentType());
@ -693,25 +691,4 @@ public class ConversationItem extends LinearLayout {
}); });
builder.show(); builder.show();
} }
private void handleAbortSecureSession() {
if (!messageRecord.isSecure()) return;
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.ConversationActivity_abort_secure_session_confirmation);
builder.setIcon(Dialogs.resolveIcon(context, R.attr.dialog_alert_icon));
builder.setCancelable(true);
builder.setMessage(R.string.ConversationActivity_are_you_sure_that_you_want_to_abort_this_secure_session_question);
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (messageRecord.getRecipients().isSingleRecipient()) {
Recipient recipient = messageRecord.getRecipients().getPrimaryRecipient();
Session.abortSessionFor(context, recipient);
}
}
});
builder.setNegativeButton(R.string.no, null);
builder.show();
}
} }