Archive is now handled somewhat differently, so we can distinguish between 'archive' and 'not initialized'.
This commit is contained in:
parent
65c03bd638
commit
300da1730d
@ -54,14 +54,13 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.Serializable;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import ch.dissem.apps.abit.dialog.AddIdentityDialogFragment;
|
||||
import ch.dissem.apps.abit.dialog.FullNodeDialogActivity;
|
||||
import ch.dissem.apps.abit.listener.ActionBarListener;
|
||||
import ch.dissem.apps.abit.listener.ListSelectionListener;
|
||||
import ch.dissem.apps.abit.repository.AndroidMessageRepository;
|
||||
import ch.dissem.apps.abit.service.BitmessageService;
|
||||
import ch.dissem.apps.abit.service.Singleton;
|
||||
import ch.dissem.apps.abit.synchronization.SyncAdapter;
|
||||
@ -273,7 +272,7 @@ public class MainActivity extends AppCompatActivity
|
||||
final ArrayList<IDrawerItem> drawerItems = new ArrayList<>();
|
||||
drawerItems.add(new PrimaryDrawerItem()
|
||||
.withName(R.string.archive)
|
||||
.withTag(null)
|
||||
.withTag(AndroidMessageRepository.LABEL_ARCHIVE)
|
||||
.withIcon(CommunityMaterial.Icon.cmd_archive)
|
||||
);
|
||||
drawerItems.add(new DividerDrawerItem());
|
||||
@ -330,10 +329,6 @@ public class MainActivity extends AppCompatActivity
|
||||
startActivity(new Intent(MainActivity.this, SettingsActivity
|
||||
.class));
|
||||
break;
|
||||
case R.string.archive:
|
||||
selectedLabel = null;
|
||||
showSelectedLabel();
|
||||
break;
|
||||
case R.string.full_node:
|
||||
return true;
|
||||
}
|
||||
|
@ -100,8 +100,7 @@ public class MessageListFragment extends Fragment implements ListHolder {
|
||||
MainActivity activity = (MainActivity) getActivity();
|
||||
messageRepo = Singleton.getMessageRepository(activity);
|
||||
|
||||
currentLabel = activity.getSelectedLabel();
|
||||
doUpdateList(currentLabel);
|
||||
doUpdateList(activity.getSelectedLabel());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -119,15 +118,24 @@ public class MessageListFragment extends Fragment implements ListHolder {
|
||||
}
|
||||
|
||||
private void doUpdateList(final Label label) {
|
||||
if (label == null) {
|
||||
if (getActivity() instanceof ActionBarListener) {
|
||||
((ActionBarListener) getActivity()).updateTitle(getString(R.string.app_name));
|
||||
}
|
||||
adapter.setData(null, Collections.<Plaintext>emptyList());
|
||||
adapter.notifyDataSetChanged();
|
||||
return;
|
||||
}
|
||||
currentLabel = label;
|
||||
if (emptyTrashMenuItem != null) {
|
||||
emptyTrashMenuItem.setVisible(label != null && label.getType() == Label.Type.TRASH);
|
||||
emptyTrashMenuItem.setVisible(label.getType() == Label.Type.TRASH);
|
||||
}
|
||||
if (getActivity() instanceof ActionBarListener) {
|
||||
if (label != null) {
|
||||
((ActionBarListener) getActivity()).updateTitle(label.toString());
|
||||
ActionBarListener actionBarListener = (ActionBarListener) getActivity();
|
||||
if ("archive".equals(label.toString())) {
|
||||
actionBarListener.updateTitle(getString(R.string.archive));
|
||||
} else {
|
||||
((ActionBarListener) getActivity()).updateTitle(getString(R.string.archive));
|
||||
actionBarListener.updateTitle(label.toString());
|
||||
}
|
||||
}
|
||||
new AsyncTask<Void, Void, List<Plaintext>>() {
|
||||
|
@ -45,6 +45,7 @@ import ch.dissem.apps.abit.util.Assets;
|
||||
import ch.dissem.bitmessage.entity.Plaintext;
|
||||
import ch.dissem.bitmessage.entity.valueobject.Label;
|
||||
|
||||
import static ch.dissem.apps.abit.repository.AndroidMessageRepository.LABEL_ARCHIVE;
|
||||
import static ch.dissem.apps.abit.util.Strings.normalizeWhitespaces;
|
||||
|
||||
/**
|
||||
@ -199,7 +200,7 @@ public class SwipeableMessageAdapter
|
||||
|
||||
@Override
|
||||
public int onGetSwipeReactionType(ViewHolder holder, int position, int x, int y) {
|
||||
if (label == null || label.getType() == Label.Type.TRASH) {
|
||||
if (label == LABEL_ARCHIVE || label.getType() == Label.Type.TRASH) {
|
||||
return REACTION_CAN_SWIPE_LEFT | REACTION_CAN_NOT_SWIPE_RIGHT_WITH_RUBBER_BAND_EFFECT;
|
||||
}
|
||||
return REACTION_CAN_SWIPE_BOTH_H;
|
||||
@ -217,7 +218,7 @@ public class SwipeableMessageAdapter
|
||||
bgRes = R.drawable.bg_swipe_item_left;
|
||||
break;
|
||||
case DRAWABLE_SWIPE_RIGHT_BACKGROUND:
|
||||
if (label == null || label.getType() == Label.Type.TRASH) {
|
||||
if (label == LABEL_ARCHIVE || label.getType() == Label.Type.TRASH) {
|
||||
bgRes = R.drawable.bg_swipe_item_neutral;
|
||||
} else {
|
||||
bgRes = R.drawable.bg_swipe_item_right;
|
||||
|
@ -48,6 +48,8 @@ import static java.lang.String.valueOf;
|
||||
public class AndroidMessageRepository extends AbstractMessageRepository {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AndroidMessageRepository.class);
|
||||
|
||||
public static final Label LABEL_ARCHIVE = new Label("archive", null, 0);
|
||||
|
||||
private static final String TABLE_NAME = "Message";
|
||||
private static final String COLUMN_ID = "id";
|
||||
private static final String COLUMN_IV = "iv";
|
||||
@ -82,6 +84,15 @@ public class AndroidMessageRepository extends AbstractMessageRepository {
|
||||
this.context = ctx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Plaintext> findMessages(Label label) {
|
||||
if (label == LABEL_ARCHIVE) {
|
||||
return super.findMessages((Label) null);
|
||||
} else {
|
||||
return super.findMessages(label);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Label> findLabels(String where) {
|
||||
List<Label> result = new LinkedList<>();
|
||||
|
||||
@ -153,15 +164,18 @@ public class AndroidMessageRepository extends AbstractMessageRepository {
|
||||
public int countUnread(Label label) {
|
||||
String[] args;
|
||||
String where;
|
||||
if (label != null) {
|
||||
where = "id IN (SELECT message_id FROM Message_Label WHERE label_id=?) AND ";
|
||||
if (label == null){
|
||||
return 0;
|
||||
}
|
||||
if (label == LABEL_ARCHIVE) {
|
||||
where = "";
|
||||
args = new String[]{
|
||||
label.getId().toString(),
|
||||
Label.Type.UNREAD.name()
|
||||
};
|
||||
} else {
|
||||
where = "";
|
||||
where = "id IN (SELECT message_id FROM Message_Label WHERE label_id=?) AND ";
|
||||
args = new String[]{
|
||||
label.getId().toString(),
|
||||
Label.Type.UNREAD.name()
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user