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