1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-30 13:12:25 -05:00

Added a first-pass view optimized for high-rez devices with both select and star

This commit is contained in:
Jesse Vincent 2010-01-13 03:36:43 +00:00
parent 5617b629d3
commit 7ab9b8ee3c
3 changed files with 162 additions and 5 deletions

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widgets"
android:layout_alignParentRight="true"
android:paddingLeft="4dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<CheckBox
android:id="@+id/flagged"
android:focusable="false"
style="?android:attr/starStyle"
android:layout_gravity="center_vertical"
android:layout_height="15dip"
android:layout_width="15dip"
/>
<!-- http://stackoverflow.com/questions/1121192/android-custom-listview-unable-to-click-on-items
we want something a bit bigger than it is right now -->
<CheckBox
android:id="@+id/selected_checkbox"
android:layout_width="18dip"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:focusable="false"
android:button="@drawable/checkbox"
android:background="@drawable/checkbox_background"
/>
</LinearLayout>

View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:background="#cccccc"
android:paddingTop="2dip"
>
<View
android:id="@+id/chip"
android:background="@drawable/appointment_indicator_leftside_1"
android:layout_width="4dip"
android:layout_height="fill_parent"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
/>
<CheckBox
android:id="@+id/selected_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/chip"
android:focusable="false"
/>
<CheckBox
android:id="@+id/flagged"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
style="?android:attr/starStyle"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
/>
<TextView
android:id="@+id/subject"
android:ellipsize="end"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:layout_toLeftOf="@id/date"
android:layout_toRightOf="@+id/selected_checkbox"
android:layout_marginRight="1dip"
/>
<TextView
android:id="@+id/date"
android:textAppearance="?android:attr/textAppearanceSmall"
android:singleLine="true"
android:paddingLeft="5dip"
android:textColor="?android:attr/textColorSecondary"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
/>
<TextView
android:id="@+id/preview"
android:layout_below="@id/subject"
android:layout_toRightOf="@id/selected_checkbox"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorTertiary"
android:singleLine="false"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="10dip"
android:layout_toLeftOf="@id/flagged"
android:layout_marginRight="1dip"
android:bufferType="spannable"
/>
</RelativeLayout>

View File

@ -11,6 +11,11 @@ import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.text.SpannableString;
import android.text.Spannable;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.text.style.TextAppearanceSpan;
import android.util.Config;
import android.util.Log;
import android.view.*;
@ -74,6 +79,9 @@ public class MessageList
private ListView mListView;
private boolean mTouchView = true;
private int mSelectedWidget = WIDGET_FLAG;
private MessageListAdapter mAdapter;
@ -673,6 +681,8 @@ public class MessageList
public void cycleVisibleWidgets(boolean ascending)
{
if (mTouchView == true ) { return;}
if (ascending)
{
@ -753,7 +763,7 @@ public class MessageList
Button flagged = (Button) v.findViewById(R.id.flagged);
CheckBox selected = (CheckBox) v.findViewById(R.id.selected_checkbox);
if (flagged == null || selected == null)
if (mTouchView == true || flagged == null || selected == null)
{
return;
}
@ -1202,10 +1212,12 @@ public class MessageList
case R.id.batch_select_all:
setAllSelected(true);
toggleBatchButtons();
return true;
case R.id.batch_deselect_all:
setAllSelected(false);
toggleBatchButtons();
return true;
case R.id.batch_copy_op:
@ -1911,12 +1923,19 @@ public class MessageList
}
else
{
if (mTouchView)
{
view = mInflater.inflate(R.layout.message_list_item_touchable, parent, false);
view.setId(R.layout.message_list_item);
}
else {
view = mInflater.inflate(R.layout.message_list_item, parent, false);
view.setId(R.layout.message_list_item);
View widgetParent;
if (mLeftHanded == false)
{
widgetParent = view.findViewById(R.id.widgets_right);
widgetParent = view.findViewById(R.id.widgets_right);
}
else
{
@ -1925,6 +1944,7 @@ public class MessageList
View widgets = mInflater.inflate(R.layout.message_list_widgets,parent,false);
widgets.setId(R.id.widgets);
((LinearLayout) widgetParent).addView(widgets);
}
}
@ -1937,6 +1957,7 @@ public class MessageList
holder.from = (TextView) view.findViewById(R.id.from);
holder.date = (TextView) view.findViewById(R.id.date);
holder.chip = view.findViewById(R.id.chip);
holder.preview = (TextView) view.findViewById(R.id.preview);
holder.flagged = (CheckBox) view.findViewById(R.id.flagged);
holder.flagged.setOnClickListener(new OnClickListener()
{
@ -1989,8 +2010,27 @@ public class MessageList
holder.subject.setText(message.subject);
holder.from.setText(message.sender);
holder.from.setTypeface(null, message.read ? Typeface.NORMAL : Typeface.BOLD);
if (holder.preview != null) {
// in the touchable UI, we have previews
// otherwise, we have just a "from" line
// because text views can't wrap around each other(?)
// we compose a custom view containing the preview and the
// from
holder.preview.setText(message.sender+ " " + message.preview, TextView.BufferType.SPANNABLE);
Spannable str = (Spannable)holder.preview.getText();
// Create our span sections, and assign a format to each.
str.setSpan(new TextAppearanceSpan(null ,Typeface.BOLD ,-1, holder.subject.getTextColors(), holder.subject.getLinkTextColors()), 0, message.sender.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
} else {
holder.from.setText(message.sender);
holder.from.setTypeface(null, message.read ? Typeface.NORMAL : Typeface.BOLD);
}
holder.date.setText(message.date);
holder.subject.setCompoundDrawablesWithIntrinsicBounds(
message.answered ? mAnsweredIcon : null, // left
@ -2004,10 +2044,19 @@ public class MessageList
holder.chip.getBackground().setAlpha(0);
holder.subject.setText("No subject");
holder.subject.setTypeface(null, Typeface.NORMAL);
if (holder.preview != null) {
holder.preview.setText("No sender");
holder.preview.setTypeface(null, Typeface.NORMAL);
holder.preview.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
} else {
holder.from.setText("No sender");
holder.from.setTypeface(null, Typeface.NORMAL);
holder.date.setText("No date");
holder.from.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
}
holder.date.setText("No date");
//WARNING: Order of the next 2 lines matter
holder.position = -1;
holder.selected.setChecked(false);
@ -2089,6 +2138,8 @@ public class MessageList
public String compareCounterparty;
public String preview;
public String[] recipients;
public boolean hasAttachments;
@ -2177,6 +2228,7 @@ public class MessageList
this.uid = message.getUid();
this.message = m;
this.account = account;
this.preview = message.getPreview();
}
catch (MessagingException me)