|
|
|
@ -17,11 +17,6 @@
|
|
|
|
|
|
|
|
|
|
package org.thoughtcrime.securesms.mms;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.R;
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
|
import android.view.View;
|
|
|
|
@ -30,6 +25,11 @@ import android.widget.ArrayAdapter;
|
|
|
|
|
import android.widget.ImageView;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.R;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class AttachmentTypeSelectorAdapter extends ArrayAdapter<AttachmentTypeSelectorAdapter.IconListItem> {
|
|
|
|
|
|
|
|
|
|
public static final int ADD_IMAGE = 1;
|
|
|
|
@ -42,7 +42,7 @@ public class AttachmentTypeSelectorAdapter extends ArrayAdapter<AttachmentTypeSe
|
|
|
|
|
private final Context context;
|
|
|
|
|
|
|
|
|
|
public AttachmentTypeSelectorAdapter(Context context) {
|
|
|
|
|
super(context, R.layout.icon_list_item, getItemList());
|
|
|
|
|
super(context, R.layout.icon_list_item, getItemList(context));
|
|
|
|
|
this.context = context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -50,66 +50,68 @@ public class AttachmentTypeSelectorAdapter extends ArrayAdapter<AttachmentTypeSe
|
|
|
|
|
return getItem(position).getCommand();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
|
|
TextView text;
|
|
|
|
|
ImageView image;
|
|
|
|
|
@Override
|
|
|
|
|
public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
|
|
TextView text;
|
|
|
|
|
ImageView image;
|
|
|
|
|
|
|
|
|
|
View view;
|
|
|
|
|
if (convertView == null) {
|
|
|
|
|
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
|
view = inflater.inflate(R.layout.icon_list_item, parent, false);
|
|
|
|
|
} else {
|
|
|
|
|
view = convertView;
|
|
|
|
|
}
|
|
|
|
|
View view;
|
|
|
|
|
if (convertView == null) {
|
|
|
|
|
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
|
view = inflater.inflate(R.layout.icon_list_item, parent, false);
|
|
|
|
|
} else {
|
|
|
|
|
view = convertView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
text = (TextView) view.findViewById(R.id.text1);
|
|
|
|
|
text.setText(getItem(position).getTitle());
|
|
|
|
|
text = (TextView) view.findViewById(R.id.text1);
|
|
|
|
|
text.setText(getItem(position).getTitle());
|
|
|
|
|
|
|
|
|
|
image = (ImageView) view.findViewById(R.id.icon);
|
|
|
|
|
image.setImageResource(getItem(position).getResource());
|
|
|
|
|
image = (ImageView) view.findViewById(R.id.icon);
|
|
|
|
|
image.setImageResource(getItem(position).getResource());
|
|
|
|
|
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<IconListItem> getItemList() {
|
|
|
|
|
List<IconListItem> data = new ArrayList<IconListItem>(7);
|
|
|
|
|
addItem(data, "Pictures", R.drawable.ic_launcher_gallery, ADD_IMAGE);
|
|
|
|
|
private static List<IconListItem> getItemList(Context context) {
|
|
|
|
|
List<IconListItem> data = new ArrayList<IconListItem>(7);
|
|
|
|
|
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_picture),
|
|
|
|
|
R.drawable.ic_attach_picture_holo_light, ADD_IMAGE);
|
|
|
|
|
// addItem(data, "Capture picture", R.drawable.ic_launcher_camera, TAKE_PICTURE);
|
|
|
|
|
addItem(data, "Videos", R.drawable.ic_launcher_video_player, ADD_VIDEO);
|
|
|
|
|
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_video),
|
|
|
|
|
R.drawable.ic_attach_video_holo_light, ADD_VIDEO);
|
|
|
|
|
// addItem(data, "Capture video", R.drawable.ic_launcher_camera_record, RECORD_VIDEO);
|
|
|
|
|
addItem(data, "Audio", R.drawable.ic_launcher_musicplayer_2, ADD_SOUND);
|
|
|
|
|
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_audio),
|
|
|
|
|
R.drawable.ic_attach_audio_holo_light, ADD_SOUND);
|
|
|
|
|
// addItem(data, "Record audio", R.drawable.ic_launcher_record_audio, RECORD_SOUND);
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void addItem(List<IconListItem> list, String text, int resource, int id) {
|
|
|
|
|
list.add(new IconListItem(text, resource, id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class IconListItem {
|
|
|
|
|
private final String mTitle;
|
|
|
|
|
private final int mResource;
|
|
|
|
|
private final int id;
|
|
|
|
|
|
|
|
|
|
public IconListItem(String title, int resource, int id) {
|
|
|
|
|
mResource = resource;
|
|
|
|
|
mTitle = title;
|
|
|
|
|
this.id = id;
|
|
|
|
|
}
|
|
|
|
|
public static class IconListItem {
|
|
|
|
|
private final String mTitle;
|
|
|
|
|
private final int mResource;
|
|
|
|
|
private final int id;
|
|
|
|
|
|
|
|
|
|
public int getCommand() {
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
public IconListItem(String title, int resource, int id) {
|
|
|
|
|
mResource = resource;
|
|
|
|
|
mTitle = title;
|
|
|
|
|
this.id = id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getTitle() {
|
|
|
|
|
return mTitle;
|
|
|
|
|
}
|
|
|
|
|
public int getCommand() {
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getResource() {
|
|
|
|
|
return mResource;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public String getTitle() {
|
|
|
|
|
return mTitle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getResource() {
|
|
|
|
|
return mResource;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|