Show attachments size during composing MMS am: 519ae7e902
Change-Id: I9657d749f7aa58914d4c8958d57ff9cd0348b742
This commit is contained in:
@@ -88,8 +88,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<!-- Contains compose message bubble and character counter for SMS which should be left
|
<!-- Contains compose message bubble and character counter for SMS or attachments size
|
||||||
aligned -->
|
for MMS which should be left aligned -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
@@ -128,8 +128,8 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/char_counter"
|
android:id="@+id/message_body_size"
|
||||||
style="@style/ComposeMessageViewTextCounterStyle"
|
style="@style/ComposeMessageViewMessageBodySizeStyle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
|
|||||||
@@ -171,9 +171,9 @@
|
|||||||
<item name="android:layout_marginStart">4dp</item>
|
<item name="android:layout_marginStart">4dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="ComposeMessageViewTextCounterStyle">
|
<style name="ComposeMessageViewMessageBodySizeStyle">
|
||||||
<item name="android:textColor">@color/message_text_counter_color</item>
|
<item name="android:textColor">@color/message_body_size_text_color</item>
|
||||||
<item name="android:textSize">@dimen/message_text_counter_size</item>
|
<item name="android:textSize">@dimen/message_body_size_text_size</item>
|
||||||
<item name="android:fontFamily">sans-serif</item>
|
<item name="android:fontFamily">sans-serif</item>
|
||||||
<item name="android:layout_gravity">end|center_vertical</item>
|
<item name="android:layout_gravity">end|center_vertical</item>
|
||||||
<item name="android:paddingEnd">@dimen/compose_message_text_box_padding_side</item>
|
<item name="android:paddingEnd">@dimen/compose_message_text_box_padding_side</item>
|
||||||
|
|||||||
@@ -128,7 +128,7 @@
|
|||||||
<color name="fab_pressed_color">#3ea4dc</color>
|
<color name="fab_pressed_color">#3ea4dc</color>
|
||||||
<color name="fab_ripple">#40ffffff</color>
|
<color name="fab_ripple">#40ffffff</color>
|
||||||
|
|
||||||
<color name="message_text_counter_color">#555555</color>
|
<color name="message_body_size_text_color">#555555</color>
|
||||||
<color name="mms_indicator_color">#8BC34A</color>
|
<color name="mms_indicator_color">#8BC34A</color>
|
||||||
<color name="list_empty_text">#6d6d6d</color>
|
<color name="list_empty_text">#6d6d6d</color>
|
||||||
<color name="low_storage_action_item_color">#ff000000</color>
|
<color name="low_storage_action_item_color">#ff000000</color>
|
||||||
|
|||||||
@@ -116,7 +116,7 @@
|
|||||||
<dimen name="fab_elevation_pressed">6dp</dimen>
|
<dimen name="fab_elevation_pressed">6dp</dimen>
|
||||||
<dimen name="fab_bottom_margin">12dp</dimen>
|
<dimen name="fab_bottom_margin">12dp</dimen>
|
||||||
<dimen name="fab_left_right_margin">14dp</dimen>
|
<dimen name="fab_left_right_margin">14dp</dimen>
|
||||||
<dimen name="message_text_counter_size">12sp</dimen>
|
<dimen name="message_body_size_text_size">12sp</dimen>
|
||||||
|
|
||||||
<dimen name="vcard_detail_group_indicator_width">40dp</dimen>
|
<dimen name="vcard_detail_group_indicator_width">40dp</dimen>
|
||||||
<dimen name="mms_indicator_size">12sp</dimen>
|
<dimen name="mms_indicator_size">12sp</dimen>
|
||||||
|
|||||||
@@ -365,9 +365,9 @@
|
|||||||
<item name="android:dividerHeight">0dp</item>
|
<item name="android:dividerHeight">0dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="ComposeMessageViewTextCounterStyle">
|
<style name="ComposeMessageViewMessageBodySizeStyle">
|
||||||
<item name="android:textColor">@color/message_text_counter_color</item>
|
<item name="android:textColor">@color/message_body_size_text_color</item>
|
||||||
<item name="android:textSize">@dimen/message_text_counter_size</item>
|
<item name="android:textSize">@dimen/message_body_size_text_size</item>
|
||||||
<item name="android:fontFamily">sans-serif</item>
|
<item name="android:fontFamily">sans-serif</item>
|
||||||
<item name="android:layout_gravity">right|center_vertical</item>
|
<item name="android:layout_gravity">right|center_vertical</item>
|
||||||
<item name="android:paddingRight">@dimen/compose_message_text_box_padding_side</item>
|
<item name="android:paddingRight">@dimen/compose_message_text_box_padding_side</item>
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import android.text.InputFilter;
|
|||||||
import android.text.InputFilter.LengthFilter;
|
import android.text.InputFilter.LengthFilter;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
import android.text.format.Formatter;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@@ -67,7 +68,9 @@ import com.android.messaging.util.ContentType;
|
|||||||
import com.android.messaging.util.LogUtil;
|
import com.android.messaging.util.LogUtil;
|
||||||
import com.android.messaging.util.MediaUtil;
|
import com.android.messaging.util.MediaUtil;
|
||||||
import com.android.messaging.util.OsUtil;
|
import com.android.messaging.util.OsUtil;
|
||||||
|
import com.android.messaging.util.SafeAsyncTask;
|
||||||
import com.android.messaging.util.UiUtils;
|
import com.android.messaging.util.UiUtils;
|
||||||
|
import com.android.messaging.util.UriUtil;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -112,7 +115,7 @@ public class ComposeMessageView extends LinearLayout
|
|||||||
|
|
||||||
private PlainTextEditText mComposeEditText;
|
private PlainTextEditText mComposeEditText;
|
||||||
private PlainTextEditText mComposeSubjectText;
|
private PlainTextEditText mComposeSubjectText;
|
||||||
private TextView mCharCounter;
|
private TextView mMessageBodySize;
|
||||||
private TextView mMmsIndicator;
|
private TextView mMmsIndicator;
|
||||||
private SimIconView mSelfSendIcon;
|
private SimIconView mSelfSendIcon;
|
||||||
private ImageButton mSendButton;
|
private ImageButton mSendButton;
|
||||||
@@ -171,7 +174,7 @@ public class ComposeMessageView extends LinearLayout
|
|||||||
|
|
||||||
final int counterColor = mHost.overrideCounterColor();
|
final int counterColor = mHost.overrideCounterColor();
|
||||||
if (counterColor != -1) {
|
if (counterColor != -1) {
|
||||||
mCharCounter.setTextColor(counterColor);
|
mMessageBodySize.setTextColor(counterColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,7 +312,7 @@ public class ComposeMessageView extends LinearLayout
|
|||||||
mAttachmentPreview = (AttachmentPreview) findViewById(R.id.attachment_draft_view);
|
mAttachmentPreview = (AttachmentPreview) findViewById(R.id.attachment_draft_view);
|
||||||
mAttachmentPreview.setComposeMessageView(this);
|
mAttachmentPreview.setComposeMessageView(this);
|
||||||
|
|
||||||
mCharCounter = (TextView) findViewById(R.id.char_counter);
|
mMessageBodySize = (TextView) findViewById(R.id.message_body_size);
|
||||||
mMmsIndicator = (TextView) findViewById(R.id.mms_indicator);
|
mMmsIndicator = (TextView) findViewById(R.id.mms_indicator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,6 +483,8 @@ public class ComposeMessageView extends LinearLayout
|
|||||||
final String subject = data.getMessageSubject();
|
final String subject = data.getMessageSubject();
|
||||||
final String message = data.getMessageText();
|
final String message = data.getMessageText();
|
||||||
|
|
||||||
|
boolean hasAttachmentsChanged = false;
|
||||||
|
|
||||||
if ((changeFlags & DraftMessageData.MESSAGE_SUBJECT_CHANGED) ==
|
if ((changeFlags & DraftMessageData.MESSAGE_SUBJECT_CHANGED) ==
|
||||||
DraftMessageData.MESSAGE_SUBJECT_CHANGED) {
|
DraftMessageData.MESSAGE_SUBJECT_CHANGED) {
|
||||||
mComposeSubjectText.setText(subject);
|
mComposeSubjectText.setText(subject);
|
||||||
@@ -500,12 +505,13 @@ public class ComposeMessageView extends LinearLayout
|
|||||||
DraftMessageData.ATTACHMENTS_CHANGED) {
|
DraftMessageData.ATTACHMENTS_CHANGED) {
|
||||||
final boolean haveAttachments = mAttachmentPreview.onAttachmentsChanged(data);
|
final boolean haveAttachments = mAttachmentPreview.onAttachmentsChanged(data);
|
||||||
mHost.onAttachmentsChanged(haveAttachments);
|
mHost.onAttachmentsChanged(haveAttachments);
|
||||||
|
hasAttachmentsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((changeFlags & DraftMessageData.SELF_CHANGED) == DraftMessageData.SELF_CHANGED) {
|
if ((changeFlags & DraftMessageData.SELF_CHANGED) == DraftMessageData.SELF_CHANGED) {
|
||||||
updateOnSelfSubscriptionChange();
|
updateOnSelfSubscriptionChange();
|
||||||
}
|
}
|
||||||
updateVisualsOnDraftChanged();
|
updateVisualsOnDraftChanged(hasAttachmentsChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // From DraftMessageDataListener
|
@Override // From DraftMessageDataListener
|
||||||
@@ -624,7 +630,44 @@ public class ComposeMessageView extends LinearLayout
|
|||||||
mConversationDataModel.getData().getParticipantsLoaded();
|
mConversationDataModel.getData().getParticipantsLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class AsyncUpdateMessageBodySizeTask
|
||||||
|
extends SafeAsyncTask<List<MessagePartData>, Void, Long> {
|
||||||
|
|
||||||
|
private final Context mContext;
|
||||||
|
private final TextView mSizeTextView;
|
||||||
|
|
||||||
|
public AsyncUpdateMessageBodySizeTask(final Context context, final TextView tv) {
|
||||||
|
mContext = context;
|
||||||
|
mSizeTextView = tv;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Long doInBackgroundTimed(final List<MessagePartData>... params) {
|
||||||
|
final List<MessagePartData> attachments = params[0];
|
||||||
|
long totalSize = 0;
|
||||||
|
for (final MessagePartData attachment : attachments) {
|
||||||
|
final Uri contentUri = attachment.getContentUri();
|
||||||
|
if (contentUri != null) {
|
||||||
|
totalSize += UriUtil.getContentSize(attachment.getContentUri());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Long size) {
|
||||||
|
if (mSizeTextView != null) {
|
||||||
|
mSizeTextView.setText(Formatter.formatFileSize(mContext, size));
|
||||||
|
mSizeTextView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateVisualsOnDraftChanged() {
|
private void updateVisualsOnDraftChanged() {
|
||||||
|
updateVisualsOnDraftChanged(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateVisualsOnDraftChanged(boolean hasAttachmentsChanged) {
|
||||||
final String messageText = mComposeEditText.getText().toString();
|
final String messageText = mComposeEditText.getText().toString();
|
||||||
final DraftMessageData draftMessageData = mBinding.getData();
|
final DraftMessageData draftMessageData = mBinding.getData();
|
||||||
draftMessageData.setMessageText(messageText);
|
draftMessageData.setMessageText(messageText);
|
||||||
@@ -640,26 +683,39 @@ public class ComposeMessageView extends LinearLayout
|
|||||||
final boolean hasWorkingDraft = hasMessageText || hasSubject ||
|
final boolean hasWorkingDraft = hasMessageText || hasSubject ||
|
||||||
mBinding.getData().hasAttachments();
|
mBinding.getData().hasAttachments();
|
||||||
|
|
||||||
// Update the SMS text counter.
|
final List<MessagePartData> attachments = draftMessageData.getReadOnlyAttachments();
|
||||||
final int messageCount = draftMessageData.getNumMessagesToBeSent();
|
if (draftMessageData.getIsMms()) { // MMS case
|
||||||
final int codePointsRemaining = draftMessageData.getCodePointsRemainingInCurrentMessage();
|
if (draftMessageData.hasAttachments()) {
|
||||||
// Show the counter only if:
|
if (hasAttachmentsChanged) {
|
||||||
// - We are not in MMS mode
|
// Calculate message attachments size and show it.
|
||||||
// - We are going to send more than one message OR we are getting close
|
new AsyncUpdateMessageBodySizeTask(getContext(), mMessageBodySize)
|
||||||
boolean showCounter = false;
|
.executeOnThreadPool(attachments, null, null);
|
||||||
if (!draftMessageData.getIsMms() && (messageCount > 1 ||
|
} else {
|
||||||
codePointsRemaining <= CODEPOINTS_REMAINING_BEFORE_COUNTER_SHOWN)) {
|
// No update. Just show previous size.
|
||||||
showCounter = true;
|
mMessageBodySize.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if (showCounter) {
|
mMessageBodySize.setVisibility(View.INVISIBLE);
|
||||||
// Update the remaining characters and number of messages required.
|
}
|
||||||
final String counterText = messageCount > 1 ? codePointsRemaining + " / " +
|
} else { // SMS case
|
||||||
messageCount : String.valueOf(codePointsRemaining);
|
// Update the SMS text counter.
|
||||||
mCharCounter.setText(counterText);
|
final int messageCount = draftMessageData.getNumMessagesToBeSent();
|
||||||
mCharCounter.setVisibility(View.VISIBLE);
|
final int codePointsRemaining =
|
||||||
} else {
|
draftMessageData.getCodePointsRemainingInCurrentMessage();
|
||||||
mCharCounter.setVisibility(View.INVISIBLE);
|
// Show the counter only if we are going to send more than one message OR we are getting
|
||||||
|
// close.
|
||||||
|
if (messageCount > 1
|
||||||
|
|| codePointsRemaining <= CODEPOINTS_REMAINING_BEFORE_COUNTER_SHOWN) {
|
||||||
|
// Update the remaining characters and number of messages required.
|
||||||
|
final String counterText =
|
||||||
|
messageCount > 1
|
||||||
|
? codePointsRemaining + " / " + messageCount
|
||||||
|
: String.valueOf(codePointsRemaining);
|
||||||
|
mMessageBodySize.setText(counterText);
|
||||||
|
mMessageBodySize.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
mMessageBodySize.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the send message button. Self icon uri might be null if self participant data
|
// Update the send message button. Self icon uri might be null if self participant data
|
||||||
@@ -699,7 +755,6 @@ public class ComposeMessageView extends LinearLayout
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update the text hint on the message box depending on the attachment type.
|
// Update the text hint on the message box depending on the attachment type.
|
||||||
final List<MessagePartData> attachments = draftMessageData.getReadOnlyAttachments();
|
|
||||||
final int attachmentCount = attachments.size();
|
final int attachmentCount = attachments.size();
|
||||||
if (attachmentCount == 0) {
|
if (attachmentCount == 0) {
|
||||||
final SubscriptionListEntry subscriptionListEntry =
|
final SubscriptionListEntry subscriptionListEntry =
|
||||||
|
|||||||
Reference in New Issue
Block a user