Skip to content
This repository has been archived by the owner on May 3, 2019. It is now read-only.

Commit

Permalink
auto import from //branches/cupcake/...@137873
Browse files Browse the repository at this point in the history
  • Loading branch information
The Android Open Source Project committed Mar 11, 2009
1 parent 72b7fda commit 836945d
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 77 deletions.
2 changes: 2 additions & 0 deletions Android.mk
Expand Up @@ -7,6 +7,8 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src)

LOCAL_PACKAGE_NAME := Mms

LOCAL_REQUIRED_MODULES := SoundRecorder

include $(BUILD_PACKAGE)

# This finds and builds the test apk as well, so a single make does both.
Expand Down
1 change: 1 addition & 0 deletions AndroidManifest.xml
Expand Up @@ -143,6 +143,7 @@
android:label="Edit slideshow" />

<activity android:name=".ui.SlideEditorActivity"
android:windowSoftInputMode="adjustResize"
android:label="Edit slide" />

<activity android:name=".ui.RecipientsPicker"
Expand Down
Binary file added res/drawable/ic_dialog_attach.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 35 additions & 34 deletions res/layout/slideshow_edit_item.xml
Expand Up @@ -37,55 +37,56 @@
android:layout_gravity="center_vertical"
android:orientation="vertical" >

<RelativeLayout
<TextView android:id="@+id/slide_number_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceLarge"
android:paddingLeft="5dip"/>

<TextView android:id="@+id/slide_number_text"
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView android:id="@+id/text_preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:paddingLeft="5dip"/>
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:visibility="gone"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?android:attr/textColorSecondary"
android:layout_weight=".4"
android:ellipsize="marquee"
android:maxLines="1" />

<LinearLayout
<TextView android:id="@+id/attachment_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" >

<TextView android:id="@+id/attachment_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingLeft="5dip"
android:textAppearance="?android:attr/textAppearanceSmall"
android:maxLines="1" />

<ImageView android:id="@+id/attachment_icon"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:paddingLeft="5dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?android:attr/textColorSecondary"
android:ellipsize="marquee"
android:layout_weight=".3"
android:maxLines="1" />

<TextView android:id="@+id/text_preview"
<ImageView android:id="@+id/attachment_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dip"
android:paddingRight="40dip"
android:textAppearance="?android:attr/textAppearanceSmall"
android:maxLines="1" />
android:paddingTop="5dip"
android:layout_weight="0" />

<TextView android:id="@+id/duration_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingLeft="5dip"
android:textAppearance="?android:attr/textAppearanceSmall"
android:maxLines="1" />
</RelativeLayout>
android:paddingLeft="10dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?android:attr/textColorSecondary"
android:maxLines="1"
android:layout_weight="0" />
</LinearLayout>
</LinearLayout>
</com.android.mms.ui.SlideListItemView>
8 changes: 4 additions & 4 deletions src/com/android/mms/transaction/MessagingNotification.java
Expand Up @@ -445,16 +445,16 @@ private static void notifyFailed(Context context, boolean isMms,

failedIntent = new Intent(context, ConversationList.class);
} else {
failedIntent = new Intent(context, ComposeMessageActivity.class);
failedIntent.putExtra("thread_id", threadId);
failedIntent.putExtra("undelivered_flag", true);

title = isDownload ?
context.getString(R.string.message_download_failed_title) :
context.getString(R.string.message_send_failed_title);

description = context.getString(R.string.message_failed_body);
threadId = (msgThreadId[0] != 0 ? msgThreadId[0] : 0);

failedIntent = new Intent(context, ComposeMessageActivity.class);
failedIntent.putExtra("thread_id", threadId);
failedIntent.putExtra("undelivered_flag", true);
}

PendingIntent pendingIntent = PendingIntent.getActivity(
Expand Down
34 changes: 7 additions & 27 deletions src/com/android/mms/transaction/PushReceiver.java
Expand Up @@ -57,36 +57,10 @@ public class PushReceiver extends BroadcastReceiver {
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = DEBUG ? Config.LOGD : Config.LOGV;

private abstract class WakefulAsyncTask<Params,Progress,Result>
extends AsyncTask<Params,Progress,Result> {
private PowerManager.WakeLock mWakeLock;

public void useWakeLock(Context c, int wakeLockFlags, String tag) {
PowerManager pm = (PowerManager)c.getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(wakeLockFlags, tag);
mWakeLock.setReferenceCounted(false);
}

@Override
protected void onPreExecute() {
if (mWakeLock != null) {
mWakeLock.acquire();
}
}

@Override
protected void onPostExecute(Result result) {
if (mWakeLock != null) {
mWakeLock.release();
}
}
}

private class ReceivePushTask extends WakefulAsyncTask<Intent,Void,Void> {
private class ReceivePushTask extends AsyncTask<Intent,Void,Void> {
private Context mContext;
public ReceivePushTask(Context context) {
mContext = context;
useWakeLock(context, PowerManager.PARTIAL_WAKE_LOCK, "ReceivePushTask");
}

@Override
Expand Down Expand Up @@ -167,6 +141,12 @@ public void onReceive(Context context, Intent intent) {
Log.v(TAG, "Received PUSH Intent: " + intent);
}

// Hold a wake lock for 5 seconds, enough to give any
// services we start time to take their own wake locks.
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"MMS PushReceiver");
wl.acquire(5000);
new ReceivePushTask(context).execute(intent);
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/com/android/mms/ui/ComposeMessageActivity.java
Expand Up @@ -817,7 +817,8 @@ public void onCreateContextMenu(ContextMenu menu, View v,
Recipient r = ((RecipientContextMenuInfo) menuInfo).recipient;
RecipientsMenuClickListener l = new RecipientsMenuClickListener(r);

menu.setHeaderTitle(r.name);
String title = !TextUtils.isEmpty(r.name) ? r.name : r.number;
menu.setHeaderTitle(title);

if (r.person_id != -1) {
menu.add(0, MENU_VIEW_CONTACT, 0, R.string.menu_view_contact)
Expand Down Expand Up @@ -2105,7 +2106,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
}

if (!MmsConfig.DISABLE_MMS) {
if (isSubjectEditorVisible()) {
if (!isSubjectEditorVisible()) {
menu.add(0, MENU_ADD_SUBJECT, 0, R.string.add_subject).setIcon(
com.android.internal.R.drawable.ic_menu_edit);
}
Expand Down Expand Up @@ -2278,7 +2279,7 @@ private void addAttachment(int type) {

private void showAddAttachmentDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setIcon(R.drawable.ic_menu_attachment);
builder.setIcon(R.drawable.ic_dialog_attach);
builder.setTitle(R.string.add_attachment);

AttachmentTypeSelectorAdapter adapter = new AttachmentTypeSelectorAdapter(
Expand Down
13 changes: 9 additions & 4 deletions src/com/android/mms/ui/ConversationHeaderView.java
Expand Up @@ -171,18 +171,19 @@ public final void bind(Context context, final ConversationHeader ch) {
ConversationHeader oldHeader = getConversationHeader();
setConversationHeader(ch);

LayoutParams layoutParams = (LayoutParams)mAttachmentView.getLayoutParams();
LayoutParams attachmentLayout = (LayoutParams)mAttachmentView.getLayoutParams();
boolean hasError = ch.hasError();
// When there's an error icon, the attachment icon is left of the error icon.
// When there is not an error icon, the attachment icon is left of the date text.
// As far as I know, there's no way to specify that relationship in xml.
if (hasError) {
layoutParams.addRule(RelativeLayout.LEFT_OF, R.id.error);
attachmentLayout.addRule(RelativeLayout.LEFT_OF, R.id.error);
} else {
layoutParams.addRule(RelativeLayout.LEFT_OF, R.id.date);
attachmentLayout.addRule(RelativeLayout.LEFT_OF, R.id.date);
}

mAttachmentView.setVisibility(ch.hasAttachment() ? VISIBLE : GONE);
boolean hasAttachment = ch.hasAttachment();
mAttachmentView.setVisibility(hasAttachment ? VISIBLE : GONE);

// Date
mDateView.setText(ch.getDate());
Expand All @@ -201,6 +202,10 @@ public final void bind(Context context, final ConversationHeader ch) {

// Subject
mSubjectView.setText(ch.getSubject());
LayoutParams subjectLayout = (LayoutParams)mSubjectView.getLayoutParams();
// We have to make the subject left of whatever optional items are shown on the right.
subjectLayout.addRule(RelativeLayout.LEFT_OF, hasAttachment ? R.id.attachment :
(hasError ? R.id.error : R.id.date));

// Transmission error indicator.
mErrorIndicator.setVisibility(hasError ? VISIBLE : GONE);
Expand Down
9 changes: 8 additions & 1 deletion src/com/android/mms/ui/MessageUtils.java
Expand Up @@ -373,7 +373,7 @@ public static String formatTimeStampString(Context context, long when, boolean f
int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT |
DateUtils.FORMAT_ABBREV_ALL |
DateUtils.FORMAT_CAP_AMPM;

// If the message is from a different year, show the date and year.
if (then.year != now.year) {
format_flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE;
Expand All @@ -385,6 +385,13 @@ public static String formatTimeStampString(Context context, long when, boolean f
format_flags |= DateUtils.FORMAT_SHOW_TIME;
}

// If the caller has asked for full details, make sure to show the date
// and time no matter what we've determined above (but still make showing
// the year only happen if it is a different year from today).
if (fullFormat) {
format_flags |= (DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME);
}

return DateUtils.formatDateTime(context, when, format_flags);
}

Expand Down
18 changes: 14 additions & 4 deletions src/com/android/mms/ui/RecipientsEditor.java
Expand Up @@ -18,8 +18,10 @@
package com.android.mms.ui;

import com.android.mms.ui.RecipientList.Recipient;
import com.android.mms.util.ContactInfoCache;

import android.content.Context;
import android.provider.Telephony.Mms;
import android.text.Annotation;
import android.text.Editable;
import android.text.Layout;
Expand Down Expand Up @@ -146,14 +148,14 @@ protected ContextMenuInfo getContextMenuInfo() {
int end = mTokenizer.findTokenEnd(text, start);

if (end != start) {
Recipient r = getRecipientAt(getText(), start, end);
Recipient r = getRecipientAt(getText(), start, end, mContext);
return new RecipientContextMenuInfo(r);
}
}
return null;
}

private static Recipient getRecipientAt(Spanned sp, int start, int end) {
private static Recipient getRecipientAt(Spanned sp, int start, int end, Context context) {
Annotation[] a = sp.getSpans(start, end, Annotation.class);
String person_id = getAnnotation(a, "person_id");
String name = getAnnotation(a, "name");
Expand All @@ -167,8 +169,14 @@ private static Recipient getRecipientAt(Spanned sp, int start, int end) {
r.label = label;
r.bcc = bcc.equals("true");
r.number = TextUtils.isEmpty(number) ? TextUtils.substring(sp, start, end) : number;
r.nameAndNumber = Recipient.buildNameAndNumber(r.name, r.number);

if (TextUtils.isEmpty(r.name) && Mms.isEmailAddress(r.number)) {
ContactInfoCache cache = ContactInfoCache.getInstance();
r.name = cache.getDisplayName(context, r.number);
}

r.nameAndNumber = Recipient.buildNameAndNumber(r.name, r.number);

if (person_id.length() > 0) {
r.person_id = Long.parseLong(person_id);
} else {
Expand Down Expand Up @@ -213,10 +221,12 @@ private class RecipientsEditorTokenizer
private final LayoutInflater mInflater;
private final TextAppearanceSpan mLabelSpan;
private final TextAppearanceSpan mTypeSpan;
private final Context mContext;

RecipientsEditorTokenizer(Context context, MultiAutoCompleteTextView list) {
mInflater = LayoutInflater.from(context);
mList = list;
mContext = context;

final int size = android.R.style.TextAppearance_Small;
final int color = android.R.styleable.Theme_textColorSecondary;
Expand All @@ -234,7 +244,7 @@ public RecipientList getRecipientList() {
while (i < len + 1) {
if ((i == len) || (sp.charAt(i) == ',')) {
if (i > start) {
Recipient r = getRecipientAt(sp, start, i);
Recipient r = getRecipientAt(sp, start, i, mContext);

rl.add(r);
}
Expand Down
3 changes: 3 additions & 0 deletions src/com/android/mms/ui/SlideListItemView.java
Expand Up @@ -23,9 +23,11 @@
import android.graphics.Bitmap;
import android.media.MediaPlayer;
import android.net.Uri;
import android.text.TextUtils;
import android.text.method.HideReturnsTransformationMethod;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
Expand Down Expand Up @@ -95,6 +97,7 @@ public void setImageVisibility(boolean visible) {

public void setText(String name, String text) {
mTextPreview.setText(text);
mTextPreview.setVisibility(TextUtils.isEmpty(text) ? View.GONE : View.VISIBLE);
}

public void setTextVisibility(boolean visible) {
Expand Down
1 change: 1 addition & 0 deletions src/com/android/mms/ui/SlideshowEditActivity.java
Expand Up @@ -119,6 +119,7 @@ private View createAddSlideItem() {

text = (TextView) v.findViewById(R.id.text_preview);
text.setText(R.string.add_slide_hint);
text.setVisibility(View.VISIBLE);

ImageView image = (ImageView) v.findViewById(R.id.image_preview);
image.setImageResource(R.drawable.ic_launcher_slideshow_add_sms);
Expand Down

0 comments on commit 836945d

Please sign in to comment.