Very early shot at batch message action UI

This commit is contained in:
Bao-Long Nguyen-Trong 2009-11-24 18:05:53 +00:00
parent 7aebe52ed1
commit e3727e1d91
9 changed files with 68 additions and 7 deletions

16
res/drawable/checkbox.xml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_focused="true"
android:drawable="@drawable/checkbox_on_background_focus_yellow" />
<item android:state_checked="false" android:state_focused="true"
android:drawable="@drawable/checkbox_off_background_focus_yellow" />
<item android:state_checked="false"
android:drawable="@drawable/checkbox_off_background" />
<item android:state_checked="true"
android:drawable="@drawable/checkbox_on_background" />
</selector>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/checkbox_label_background" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -13,7 +13,6 @@
android:layout_width="4dip"
android:layout_height="fill_parent"
android:layout_centerVertical="true" />
<CheckBox
android:id="@+id/flagged"
android:layout_width="wrap_content"
@ -23,6 +22,17 @@
android:layout_gravity="center_vertical"
android:layout_alignParentRight="true"
/>
<!-- http://stackoverflow.com/questions/1121192/android-custom-listview-unable-to-click-on-items -->
<CheckBox
android:id="@+id/selected_checkbox"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:button="@drawable/checkbox"
android:layout_toRightOf="@+id/chip"
android:layout_centerVertical="true"
android:focusable="false"
android:text=""
/>
<TextView
android:id="@+id/subject"
android:ellipsize="end"
@ -33,6 +43,7 @@
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:layout_toLeftOf="@id/flagged"
android:layout_toRightOf="@+id/selected_checkbox"
android:layout_marginRight="1dip" />
<TextView
android:id="@+id/date"
@ -57,7 +68,7 @@
android:textColor="?android:attr/textColorSecondary"
android:paddingLeft="12dip"
android:layout_toLeftOf="@id/date"
android:layout_alignParentLeft="true"
android:layout_toRightOf="@+id/selected_checkbox"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>

View File

@ -4,7 +4,6 @@ import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -18,7 +17,6 @@ import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Process;
import android.util.Config;
import android.util.Log;
import android.view.ContextMenu;
@ -41,6 +39,9 @@ import android.widget.Toast;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import com.android.email.K9ListActivity;
import com.android.email.Account;
import com.android.email.Email;
@ -1438,6 +1439,10 @@ public class MessageList extends K9ListActivity {
});
holder.chip.setBackgroundResource(colorChipResId);
holder.selected = (CheckBox) view.findViewById(R.id.selected_checkbox);
if (holder.selected!=null) {
holder.selected.setOnCheckedChangeListener(holder);
}
view.setTag(holder);
}
@ -1477,6 +1482,10 @@ public class MessageList extends K9ListActivity {
null, // top
message.hasAttachments ? mAttachmentIcon : null, // right
null); // bottom
holder.position = position;
if (holder.selected!=null) {
holder.selected.setChecked(message.selected);
}
} else {
holder.chip.getBackground().setAlpha(0);
holder.subject.setText("No subject");
@ -1485,6 +1494,10 @@ public class MessageList extends K9ListActivity {
holder.from.setTypeface(null, Typeface.NORMAL);
holder.date.setText("No date");
holder.from.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
holder.position = -1;
if (holder.selected!=null) {
holder.selected.setChecked(false);
}
}
return view;
}
@ -1564,11 +1577,15 @@ public class MessageList extends K9ListActivity {
public FolderInfoHolder folder;
public boolean selected;
// Empty constructor for comparison
public MessageInfoHolder() {}
public MessageInfoHolder() {
this.selected = false;
}
public MessageInfoHolder(Message m, FolderInfoHolder folder) {
this();
populate(m, folder);
}
@ -1686,14 +1703,25 @@ public class MessageList extends K9ListActivity {
}
}
class MessageViewHolder {
class MessageViewHolder
implements OnCheckedChangeListener {
public TextView subject;
public TextView preview;
public TextView from;
public TextView date;
public CheckBox flagged;
public View chip;
public CheckBox selected;
public int position = -1;
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (position!=-1) {
MessageInfoHolder message = (MessageInfoHolder) mAdapter.getItem(position);
message.selected = isChecked;
}
}
}
class FooterViewHolder {