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
|
@ -23,12 +23,12 @@
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<CheckBox android:id="@+id/checkbox"
|
<!--<CheckBox android:id="@+id/checkbox"-->
|
||||||
android:layout_width="wrap_content"
|
<!--android:layout_width="wrap_content"-->
|
||||||
android:layout_height="wrap_content"
|
<!--android:layout_height="wrap_content"-->
|
||||||
android:layout_alignParentRight="true"
|
<!--android:layout_alignParentRight="true"-->
|
||||||
android:layout_alignParentTop="true"
|
<!--android:layout_alignParentTop="true"-->
|
||||||
android:visibility="gone" />
|
<!--android:visibility="gone" />-->
|
||||||
|
|
||||||
<TextView android:id="@+id/from"
|
<TextView android:id="@+id/from"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -40,10 +40,10 @@
|
||||||
android:layout_marginLeft="5dip"
|
android:layout_marginLeft="5dip"
|
||||||
android:layout_alignTop="@id/contact_photo_frame"
|
android:layout_alignTop="@id/contact_photo_frame"
|
||||||
android:layout_toRightOf="@id/contact_photo_frame"
|
android:layout_toRightOf="@id/contact_photo_frame"
|
||||||
android:layout_toLeftOf="@id/checkbox"
|
|
||||||
android:layout_alignWithParentIfMissing="true"
|
android:layout_alignWithParentIfMissing="true"
|
||||||
android:ellipsize="marquee"
|
android:ellipsize="marquee"
|
||||||
android:textColor="#000000"/>
|
android:textColor="#000000"/>
|
||||||
|
<!--android:layout_toLeftOf="@id/checkbox"-->
|
||||||
|
|
||||||
|
|
||||||
<TextView android:id="@+id/date"
|
<TextView android:id="@+id/date"
|
||||||
|
|
|
@ -25,6 +25,7 @@ import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -54,7 +55,10 @@ public class ConversationListFragment extends SherlockListFragment
|
||||||
|
|
||||||
private ConversationSelectedListener listener;
|
private ConversationSelectedListener listener;
|
||||||
private MasterSecret masterSecret;
|
private MasterSecret masterSecret;
|
||||||
|
private ActionMode actionMode;
|
||||||
|
|
||||||
private String queryFilter = "";
|
private String queryFilter = "";
|
||||||
|
private boolean batchMode = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
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) {
|
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||||
if (v instanceof ConversationListItem) {
|
if (v instanceof ConversationListItem) {
|
||||||
ConversationListItem headerView = (ConversationListItem) v;
|
ConversationListItem headerView = (ConversationListItem) v;
|
||||||
|
Log.w("ConversationListFragment", "Batch mode: " + batchMode);
|
||||||
|
if (!batchMode) {
|
||||||
handleCreateConversation(headerView.getThreadId(), headerView.getRecipients(),
|
handleCreateConversation(headerView.getThreadId(), headerView.getRecipients(),
|
||||||
headerView.getDistributionType());
|
headerView.getDistributionType());
|
||||||
|
} else {
|
||||||
|
ConversationListAdapter adapter = (ConversationListAdapter)getListAdapter();
|
||||||
|
adapter.addToBatchSet(headerView.getThreadId());
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +142,8 @@ public class ConversationListFragment extends SherlockListFragment
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemLongClick(AdapterView<?> arg0, View v, int position, long id) {
|
public boolean onItemLongClick(AdapterView<?> arg0, View v, int position, long id) {
|
||||||
ConversationListAdapter adapter = (ConversationListAdapter)getListAdapter();
|
ConversationListAdapter adapter = (ConversationListAdapter)getListAdapter();
|
||||||
getSherlockActivity().startActionMode(ConversationListFragment.this);
|
actionMode = getSherlockActivity().startActionMode(ConversationListFragment.this);
|
||||||
|
batchMode = true;
|
||||||
|
|
||||||
adapter.initializeBatchMode(true);
|
adapter.initializeBatchMode(true);
|
||||||
adapter.addToBatchSet(((ConversationListItem) v).getThreadId());
|
adapter.addToBatchSet(((ConversationListItem) v).getThreadId());
|
||||||
|
@ -183,6 +195,11 @@ public class ConversationListFragment extends SherlockListFragment
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void result) {
|
protected void onPostExecute(Void result) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
if (actionMode != null) {
|
||||||
|
actionMode.finish();
|
||||||
|
actionMode = null;
|
||||||
|
batchMode = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,6 @@ import android.text.style.ForegroundColorSpan;
|
||||||
import android.text.style.StyleSpan;
|
import android.text.style.StyleSpan;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.CompoundButton;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.QuickContactBadge;
|
import android.widget.QuickContactBadge;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
@ -63,7 +61,6 @@ public class ConversationListItem extends RelativeLayout
|
||||||
private TextView subjectView;
|
private TextView subjectView;
|
||||||
private TextView fromView;
|
private TextView fromView;
|
||||||
private TextView dateView;
|
private TextView dateView;
|
||||||
private CheckBox checkbox;
|
|
||||||
private long count;
|
private long count;
|
||||||
private boolean read;
|
private boolean read;
|
||||||
|
|
||||||
|
@ -88,13 +85,11 @@ public class ConversationListItem extends RelativeLayout
|
||||||
this.subjectView = (TextView) findViewById(R.id.subject);
|
this.subjectView = (TextView) findViewById(R.id.subject);
|
||||||
this.fromView = (TextView) findViewById(R.id.from);
|
this.fromView = (TextView) findViewById(R.id.from);
|
||||||
this.dateView = (TextView) findViewById(R.id.date);
|
this.dateView = (TextView) findViewById(R.id.date);
|
||||||
this.checkbox = (CheckBox)findViewById(R.id.checkbox);
|
|
||||||
|
|
||||||
this.contactPhotoBadge = (QuickContactBadge) findViewById(R.id.contact_photo_badge);
|
this.contactPhotoBadge = (QuickContactBadge) findViewById(R.id.contact_photo_badge);
|
||||||
this.contactPhotoImage = (ImageView) findViewById(R.id.contact_photo_image);
|
this.contactPhotoImage = (ImageView) findViewById(R.id.contact_photo_image);
|
||||||
|
|
||||||
initializeContactWidgetVisibility();
|
initializeContactWidgetVisibility();
|
||||||
intializeListeners();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(ThreadRecord thread, Set<Long> selectedThreads, boolean batchMode) {
|
public void set(ThreadRecord thread, Set<Long> selectedThreads, boolean batchMode) {
|
||||||
|
@ -112,12 +107,6 @@ public class ConversationListItem extends RelativeLayout
|
||||||
if (thread.getDate() > 0)
|
if (thread.getDate() > 0)
|
||||||
this.dateView.setText(DateUtils.getRelativeTimeSpanString(getContext(), thread.getDate(), false));
|
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);
|
setBackground(read, batchMode);
|
||||||
setContactPhoto(this.recipients.getPrimaryRecipient());
|
setContactPhoto(this.recipients.getPrimaryRecipient());
|
||||||
}
|
}
|
||||||
|
@ -126,10 +115,6 @@ public class ConversationListItem extends RelativeLayout
|
||||||
this.recipients.removeListener(this);
|
this.recipients.removeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void intializeListeners() {
|
|
||||||
checkbox.setOnCheckedChangeListener(new CheckedChangedListener());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeContactWidgetVisibility() {
|
private void initializeContactWidgetVisibility() {
|
||||||
if (isBadgeEnabled()) {
|
if (isBadgeEnabled()) {
|
||||||
contactPhotoBadge.setVisibility(View.VISIBLE);
|
contactPhotoBadge.setVisibility(View.VISIBLE);
|
||||||
|
@ -163,7 +148,7 @@ public class ConversationListItem extends RelativeLayout
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBackground(boolean read, boolean batch) {
|
private void setBackground(boolean read, boolean batch) {
|
||||||
if (batch && checkbox.isChecked()) {
|
if (batch && selectedThreads.contains(threadId)) {
|
||||||
setBackgroundResource(R.drawable.list_selected_holo_light);
|
setBackgroundResource(R.drawable.list_selected_holo_light);
|
||||||
} else if (read) {
|
} else if (read) {
|
||||||
setBackgroundResource(R.drawable.conversation_list_item_background_read);
|
setBackgroundResource(R.drawable.conversation_list_item_background_read);
|
||||||
|
@ -207,16 +192,6 @@ public class ConversationListItem extends RelativeLayout
|
||||||
return distributionType;
|
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
|
@Override
|
||||||
public void onModified(Recipient recipient) {
|
public void onModified(Recipient recipient) {
|
||||||
handler.post(new Runnable() {
|
handler.post(new Runnable() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue