summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/drawable-hdpi/ic_attach_picture_holo_light.pngbin0 -> 858 bytes
-rw-r--r--res/drawable-hdpi/ic_attach_video_holo_light.pngbin0 -> 869 bytes
-rw-r--r--res/drawable-mdpi/ic_attach_picture_holo_light.pngbin0 -> 680 bytes
-rw-r--r--res/drawable-mdpi/ic_attach_video_holo_light.pngbin0 -> 723 bytes
-rw-r--r--res/drawable-xhdpi/ic_attach_picture_holo_light.pngbin0 -> 1064 bytes
-rw-r--r--res/drawable-xhdpi/ic_attach_video_holo_light.pngbin0 -> 1068 bytes
-rw-r--r--res/layout/icon_list_item.xml29
-rw-r--r--res/values/strings.xml8
-rw-r--r--src/com/android/mail/browse/AttachmentActionHandler.java17
-rw-r--r--src/com/android/mail/browse/AttachmentViewInterface.java17
-rw-r--r--src/com/android/mail/compose/AttachmentTypeSelectorAdapter.java120
-rw-r--r--src/com/android/mail/compose/ComposeActivity.java26
-rw-r--r--src/com/android/mail/ui/AttachmentTile.java17
13 files changed, 225 insertions, 9 deletions
diff --git a/res/drawable-hdpi/ic_attach_picture_holo_light.png b/res/drawable-hdpi/ic_attach_picture_holo_light.png
new file mode 100644
index 000000000..43e87440f
--- /dev/null
+++ b/res/drawable-hdpi/ic_attach_picture_holo_light.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_attach_video_holo_light.png b/res/drawable-hdpi/ic_attach_video_holo_light.png
new file mode 100644
index 000000000..fe31fe4a6
--- /dev/null
+++ b/res/drawable-hdpi/ic_attach_video_holo_light.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_attach_picture_holo_light.png b/res/drawable-mdpi/ic_attach_picture_holo_light.png
new file mode 100644
index 000000000..e66e04a93
--- /dev/null
+++ b/res/drawable-mdpi/ic_attach_picture_holo_light.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_attach_video_holo_light.png b/res/drawable-mdpi/ic_attach_video_holo_light.png
new file mode 100644
index 000000000..e2f96b093
--- /dev/null
+++ b/res/drawable-mdpi/ic_attach_video_holo_light.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_attach_picture_holo_light.png b/res/drawable-xhdpi/ic_attach_picture_holo_light.png
new file mode 100644
index 000000000..88118a8de
--- /dev/null
+++ b/res/drawable-xhdpi/ic_attach_picture_holo_light.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_attach_video_holo_light.png b/res/drawable-xhdpi/ic_attach_video_holo_light.png
new file mode 100644
index 000000000..9f70c4630
--- /dev/null
+++ b/res/drawable-xhdpi/ic_attach_video_holo_light.png
Binary files differ
diff --git a/res/layout/icon_list_item.xml b/res/layout/icon_list_item.xml
new file mode 100644
index 000000000..828852819
--- /dev/null
+++ b/res/layout/icon_list_item.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2012 Google Inc.
+ Licensed to The Android Open Source Project.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/text"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:paddingTop="1dip"
+ android:paddingBottom="1dip"
+ android:paddingLeft="9dip"
+ android:paddingRight="9dip"
+ android:drawablePadding="9dip"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:gravity="center_vertical"
+ android:textAppearance="?android:attr/textAppearanceLarge"/>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4c467e120..52fc0075b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -247,6 +247,14 @@
<string name="menu_photo_share_all">Share all</string>
<!-- Displayed in the action bar as a subtitle. Save in progress. [CHAR LIMIT=15] -->
<string name="saving">Saving&#8230;</string>
+ <!-- Attachment Type Selector Adapter. This string is an option in the "Attach" dialog [CHAR LIMIT=20] -->
+ <string name="attach_image">Pictures</string>
+ <!-- Attachment Type Selector Adapter. This string is an option in the "Attach" dialog [CHAR LIMIT=20] -->
+ <string name="attach_take_photo">Capture picture</string>
+ <!-- Attachment Type Selector Adapter. This string is an option in the "Attach" dialog [CHAR LIMIT=20] -->
+ <string name="attach_video">Videos</string>
+ <!-- Attachment Type Selector Adapter. This string is an option in the "Attach" dialog [CHAR LIMIT=20] -->
+ <string name="attach_record_video">Capture video</string>
<!-- Webview Context Menu Strings -->
<!-- Title of dialog for choosing which activity to share a link with. [CHAR LIMIT=50]-->
diff --git a/src/com/android/mail/browse/AttachmentActionHandler.java b/src/com/android/mail/browse/AttachmentActionHandler.java
index dbb679b68..2a9de927b 100644
--- a/src/com/android/mail/browse/AttachmentActionHandler.java
+++ b/src/com/android/mail/browse/AttachmentActionHandler.java
@@ -1,3 +1,20 @@
+/*
+ * Copyright (C) 2012 Google Inc.
+ * Licensed to The Android Open Source Project.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.android.mail.browse;
import android.app.ProgressDialog;
diff --git a/src/com/android/mail/browse/AttachmentViewInterface.java b/src/com/android/mail/browse/AttachmentViewInterface.java
index 5da876236..3fc84d147 100644
--- a/src/com/android/mail/browse/AttachmentViewInterface.java
+++ b/src/com/android/mail/browse/AttachmentViewInterface.java
@@ -1,3 +1,20 @@
+/*
+ * Copyright (C) 2012 Google Inc.
+ * Licensed to The Android Open Source Project.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.android.mail.browse;
public interface AttachmentViewInterface {
diff --git a/src/com/android/mail/compose/AttachmentTypeSelectorAdapter.java b/src/com/android/mail/compose/AttachmentTypeSelectorAdapter.java
new file mode 100644
index 000000000..00c907666
--- /dev/null
+++ b/src/com/android/mail/compose/AttachmentTypeSelectorAdapter.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2012 Google Inc.
+ * Licensed to The Android Open Source Project.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.mail.compose;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.android.mail.R;
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+
+public class AttachmentTypeSelectorAdapter extends BaseAdapter {
+
+ /**
+ * Backing list for the {@link AlertDialog}'s adapter.
+ */
+ public static final List<AttachmentType> ITEMS = ImmutableList.of(
+ new AttachmentType(
+ R.string.attach_image, R.drawable.ic_attach_picture_holo_light, "image/*"),
+ new AttachmentType(
+ R.string.attach_video, R.drawable.ic_attach_video_holo_light, "video/*"));
+
+ private final LayoutInflater mInflater;
+
+ public AttachmentTypeSelectorAdapter(Context context) {
+ super();
+ mInflater = LayoutInflater.from(context);
+ }
+
+ @Override
+ public int getCount() {
+ return ITEMS.size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return ITEMS.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ /**
+ * Make a view to hold each row.
+ *
+ * @see android.widget.ListAdapter#getView(int, android.view.View,
+ * android.view.ViewGroup)
+ */
+ public View getView(int position, View convertView, ViewGroup parent) {
+ // A ViewHolder keeps references to children views to avoid unneccessary calls
+ // to findViewById() on each row.
+ ViewHolder holder;
+
+ // When convertView is not null, we can reuse it directly, there is no need
+ // to reinflate it. We only inflate a new View when the convertView supplied
+ // by ListView is null.
+ if (convertView == null) {
+ convertView = mInflater.inflate(R.layout.icon_list_item, null);
+
+ // Creates a ViewHolder and store references to the two children views
+ // we want to bind data to.
+ holder = new ViewHolder();
+ holder.text = (TextView) convertView.findViewById(R.id.text);
+
+ convertView.setTag(holder);
+ } else {
+ // Get the ViewHolder back to get fast access to the TextView
+ // and the ImageView.
+ holder = (ViewHolder) convertView.getTag();
+ }
+
+ // Bind the data efficiently with the holder.
+ final AttachmentType attachmentType = ITEMS.get(position);
+
+ holder.text.setText(attachmentType.mTextId);
+ holder.text.setCompoundDrawablesWithIntrinsicBounds(attachmentType.mIconId, 0, 0, 0);
+
+ return convertView;
+ }
+
+ static class ViewHolder {
+ TextView text;
+ ImageView icon;
+ }
+
+ public static class AttachmentType {
+ public int mIconId;
+ public int mTextId;
+ public String mMimeType;
+
+ public AttachmentType(int textId, int iconId, String mimeType) {
+ mTextId = textId;
+ mIconId = iconId;
+ mMimeType = mimeType;
+ }
+ }
+}
diff --git a/src/com/android/mail/compose/ComposeActivity.java b/src/com/android/mail/compose/ComposeActivity.java
index 6bb8bfbfa..003f11360 100644
--- a/src/com/android/mail/compose/ComposeActivity.java
+++ b/src/com/android/mail/compose/ComposeActivity.java
@@ -1366,7 +1366,7 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
showCcBccViews();
break;
case R.id.add_attachment:
- doAttach();
+ openAttachmentTypeSelectionDialog();
break;
}
}
@@ -1418,7 +1418,7 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
boolean handled = true;
switch (id) {
case R.id.add_attachment:
- doAttach();
+ openAttachmentTypeSelectionDialog();
break;
case R.id.add_cc_bcc:
showCcBccViews();
@@ -1586,6 +1586,7 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
public ArrayList<SendOrSaveTask> mActiveTasks = Lists.newArrayList();
private int mRequestId;
private String mSignature;
+ private AttachmentTypeSelectorAdapter mAttachmentTypeSelectorAdapter;
@VisibleForTesting
public static class SendOrSaveMessage {
@@ -2124,16 +2125,23 @@ public class ComposeActivity extends Activity implements OnClickListener, OnNavi
// TODO: store the request map in user preferences.
}
- public void doAttach() {
+ public void openAttachmentTypeSelectionDialog() {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.add_file_attachment);
+ builder.setAdapter(new AttachmentTypeSelectorAdapter(this),
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int position) {
+ doAttach(position);
+ }
+ });
+ builder.show();
+ }
+
+ private void doAttach(int position) {
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
- if (android.provider.Settings.System.getInt(getContentResolver(),
- UIProvider.getAttachmentTypeSetting(), 0) != 0) {
- i.setType("*/*");
- } else {
- i.setType("image/*");
- }
+ i.setType(AttachmentTypeSelectorAdapter.ITEMS.get(position).mMimeType);
mAddingAttachment = true;
startActivityForResult(Intent.createChooser(i, getText(R.string.select_attachment_type)),
RESULT_PICK_ATTACHMENT);
diff --git a/src/com/android/mail/ui/AttachmentTile.java b/src/com/android/mail/ui/AttachmentTile.java
index bfb9e8300..6e9de71c2 100644
--- a/src/com/android/mail/ui/AttachmentTile.java
+++ b/src/com/android/mail/ui/AttachmentTile.java
@@ -1,3 +1,20 @@
+/*
+ * Copyright (C) 2012 Google Inc.
+ * Licensed to The Android Open Source Project.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.android.mail.ui;
import android.content.Context;