Remove checkboxes from the multi-select UI
This commit is contained in:
parent
3743c57edd
commit
95eb62190a
3 changed files with 41 additions and 49 deletions
|
@ -5,8 +5,8 @@
|
|||
android:paddingRight="10dip"
|
||||
>
|
||||
|
||||
<FrameLayout android:id="@+id/contact_photo_frame"
|
||||
android:layout_width="wrap_content"
|
||||
<FrameLayout android:id="@+id/contact_photo_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
|
@ -14,21 +14,21 @@
|
|||
<QuickContactBadge android:id="@+id/contact_photo_badge"
|
||||
style="?android:attr/quickContactBadgeStyleWindowLarge"
|
||||
android:visibility="gone" />
|
||||
|
||||
|
||||
<ImageView android:id="@+id/contact_photo_image"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:cropToPadding="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:visibility="gone" />
|
||||
android:scaleType="centerCrop"
|
||||
android:visibility="gone" />
|
||||
</FrameLayout>
|
||||
|
||||
<CheckBox android:id="@+id/checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!--<CheckBox android:id="@+id/checkbox"-->
|
||||
<!--android:layout_width="wrap_content"-->
|
||||
<!--android:layout_height="wrap_content"-->
|
||||
<!--android:layout_alignParentRight="true"-->
|
||||
<!--android:layout_alignParentTop="true"-->
|
||||
<!--android:visibility="gone" />-->
|
||||
|
||||
<TextView android:id="@+id/from"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -40,10 +40,10 @@
|
|||
android:layout_marginLeft="5dip"
|
||||
android:layout_alignTop="@id/contact_photo_frame"
|
||||
android:layout_toRightOf="@id/contact_photo_frame"
|
||||
android:layout_toLeftOf="@id/checkbox"
|
||||
android:layout_alignWithParentIfMissing="true"
|
||||
android:ellipsize="marquee"
|
||||
android:textColor="#000000"/>
|
||||
<!--android:layout_toLeftOf="@id/checkbox"-->
|
||||
|
||||
|
||||
<TextView android:id="@+id/date"
|
||||
|
@ -54,7 +54,7 @@
|
|||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:singleLine="true"
|
||||
android:layout_alignBottom="@id/contact_photo_frame"
|
||||
android:layout_alignBottom="@id/contact_photo_frame"
|
||||
android:layout_alignParentRight="true"/>
|
||||
|
||||
<ImageView android:id="@+id/error"
|
||||
|
|
|
@ -25,6 +25,7 @@ import android.os.AsyncTask;
|
|||
import android.os.Bundle;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -54,7 +55,10 @@ public class ConversationListFragment extends SherlockListFragment
|
|||
|
||||
private ConversationSelectedListener listener;
|
||||
private MasterSecret masterSecret;
|
||||
private ActionMode actionMode;
|
||||
|
||||
private String queryFilter = "";
|
||||
private boolean batchMode = false;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||
|
@ -96,8 +100,15 @@ public class ConversationListFragment extends SherlockListFragment
|
|||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
if (v instanceof ConversationListItem) {
|
||||
ConversationListItem headerView = (ConversationListItem) v;
|
||||
handleCreateConversation(headerView.getThreadId(), headerView.getRecipients(),
|
||||
headerView.getDistributionType());
|
||||
Log.w("ConversationListFragment", "Batch mode: " + batchMode);
|
||||
if (!batchMode) {
|
||||
handleCreateConversation(headerView.getThreadId(), headerView.getRecipients(),
|
||||
headerView.getDistributionType());
|
||||
} else {
|
||||
ConversationListAdapter adapter = (ConversationListAdapter)getListAdapter();
|
||||
adapter.addToBatchSet(headerView.getThreadId());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,10 +142,11 @@ public class ConversationListFragment extends SherlockListFragment
|
|||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> arg0, View v, int position, long id) {
|
||||
ConversationListAdapter adapter = (ConversationListAdapter)getListAdapter();
|
||||
getSherlockActivity().startActionMode(ConversationListFragment.this);
|
||||
actionMode = getSherlockActivity().startActionMode(ConversationListFragment.this);
|
||||
batchMode = true;
|
||||
|
||||
adapter.initializeBatchMode(true);
|
||||
adapter.addToBatchSet(((ConversationListItem)v).getThreadId());
|
||||
adapter.addToBatchSet(((ConversationListItem) v).getThreadId());
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
return true;
|
||||
|
@ -183,6 +195,11 @@ public class ConversationListFragment extends SherlockListFragment
|
|||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
dialog.dismiss();
|
||||
if (actionMode != null) {
|
||||
actionMode.finish();
|
||||
actionMode = null;
|
||||
batchMode = false;
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
|
|
@ -32,8 +32,6 @@ import android.text.style.ForegroundColorSpan;
|
|||
import android.text.style.StyleSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.QuickContactBadge;
|
||||
import android.widget.RelativeLayout;
|
||||
|
@ -63,7 +61,6 @@ public class ConversationListItem extends RelativeLayout
|
|||
private TextView subjectView;
|
||||
private TextView fromView;
|
||||
private TextView dateView;
|
||||
private CheckBox checkbox;
|
||||
private long count;
|
||||
private boolean read;
|
||||
|
||||
|
@ -85,16 +82,14 @@ public class ConversationListItem extends RelativeLayout
|
|||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
this.subjectView = (TextView)findViewById(R.id.subject);
|
||||
this.fromView = (TextView)findViewById(R.id.from);
|
||||
this.dateView = (TextView)findViewById(R.id.date);
|
||||
this.checkbox = (CheckBox)findViewById(R.id.checkbox);
|
||||
this.subjectView = (TextView) findViewById(R.id.subject);
|
||||
this.fromView = (TextView) findViewById(R.id.from);
|
||||
this.dateView = (TextView) findViewById(R.id.date);
|
||||
|
||||
this.contactPhotoBadge = (QuickContactBadge)findViewById(R.id.contact_photo_badge);
|
||||
this.contactPhotoImage = (ImageView)findViewById(R.id.contact_photo_image);
|
||||
this.contactPhotoBadge = (QuickContactBadge) findViewById(R.id.contact_photo_badge);
|
||||
this.contactPhotoImage = (ImageView) findViewById(R.id.contact_photo_image);
|
||||
|
||||
initializeContactWidgetVisibility();
|
||||
intializeListeners();
|
||||
}
|
||||
|
||||
public void set(ThreadRecord thread, Set<Long> selectedThreads, boolean batchMode) {
|
||||
|
@ -112,12 +107,6 @@ public class ConversationListItem extends RelativeLayout
|
|||
if (thread.getDate() > 0)
|
||||
this.dateView.setText(DateUtils.getRelativeTimeSpanString(getContext(), thread.getDate(), false));
|
||||
|
||||
if (selectedThreads != null)
|
||||
this.checkbox.setChecked(selectedThreads.contains(threadId));
|
||||
|
||||
if (batchMode) checkbox.setVisibility(View.VISIBLE);
|
||||
else checkbox.setVisibility(View.GONE);
|
||||
|
||||
setBackground(read, batchMode);
|
||||
setContactPhoto(this.recipients.getPrimaryRecipient());
|
||||
}
|
||||
|
@ -126,10 +115,6 @@ public class ConversationListItem extends RelativeLayout
|
|||
this.recipients.removeListener(this);
|
||||
}
|
||||
|
||||
private void intializeListeners() {
|
||||
checkbox.setOnCheckedChangeListener(new CheckedChangedListener());
|
||||
}
|
||||
|
||||
private void initializeContactWidgetVisibility() {
|
||||
if (isBadgeEnabled()) {
|
||||
contactPhotoBadge.setVisibility(View.VISIBLE);
|
||||
|
@ -163,7 +148,7 @@ public class ConversationListItem extends RelativeLayout
|
|||
}
|
||||
|
||||
private void setBackground(boolean read, boolean batch) {
|
||||
if (batch && checkbox.isChecked()) {
|
||||
if (batch && selectedThreads.contains(threadId)) {
|
||||
setBackgroundResource(R.drawable.list_selected_holo_light);
|
||||
} else if (read) {
|
||||
setBackgroundResource(R.drawable.conversation_list_item_background_read);
|
||||
|
@ -207,16 +192,6 @@ public class ConversationListItem extends RelativeLayout
|
|||
return distributionType;
|
||||
}
|
||||
|
||||
private class CheckedChangedListener implements CompoundButton.OnCheckedChangeListener {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) selectedThreads.add(threadId);
|
||||
else selectedThreads.remove(threadId);
|
||||
|
||||
setBackground(read, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModified(Recipient recipient) {
|
||||
handler.post(new Runnable() {
|
||||
|
|
Loading…
Add table
Reference in a new issue