Fix item selection in drawer

This commit is contained in:
cketti 2018-10-24 03:14:02 +02:00
parent a6040a90fc
commit 387a668857
2 changed files with 9 additions and 4 deletions

View file

@ -464,9 +464,6 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
// regular LocalSearch object was passed
search = intent.hasExtra(EXTRA_SEARCH) ?
ParcelableUtil.unmarshall(intent.getByteArrayExtra(EXTRA_SEARCH), LocalSearch.CREATOR) : null;
if (search.getId().equals(SearchAccount.UNIFIED_INBOX)) {
drawer.selectUnifiedInbox();
}
noThreading = intent.getBooleanExtra(EXTRA_NO_THREADING, false);
}
@ -480,7 +477,6 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
search.addAccountUuid(messageReference.getAccountUuid());
String folderServerId = messageReference.getFolderServerId();
search.addAllowedFolder(folderServerId);
drawer.selectFolder(folderServerId);
}
if (search == null) {
@ -1700,6 +1696,8 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
singleFolderMode = singleAccountMode && folderServerIds.size() == 1;
if (singleFolderMode) {
drawer.selectFolder(folderServerIds.get(0));
} else if (search.getId().equals(SearchAccount.UNIFIED_INBOX)) {
drawer.selectUnifiedInbox();
} else {
drawer.selectFolder(null);
}

View file

@ -23,6 +23,7 @@ import com.mikepenz.materialdrawer.model.DividerDrawerItem;
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
public class K9Drawer {
// Bit shift for identifiers of user folders items, to leave space for other items
private static final short DRAWER_FOLDER_SHIFT = 2;
@ -47,6 +48,7 @@ public class K9Drawer {
private int iconFolderResId;
private final List<Long> userFolderDrawerIds = new ArrayList<>();
private boolean unifiedInboxSelected;
private String openedFolderServerId;
@ -175,6 +177,8 @@ public class K9Drawer {
if (openedFolderDrawerId != -1) {
drawer.setSelection(openedFolderDrawerId, false);
} else if (unifiedInboxSelected) {
selectUnifiedInbox();
}
}
@ -186,6 +190,7 @@ public class K9Drawer {
}
public void selectFolder(String folderServerId) {
unifiedInboxSelected = false;
openedFolderServerId = folderServerId;
for (long drawerId : userFolderDrawerIds) {
Folder folder = (Folder) drawer.getDrawerItem(drawerId).getTag();
@ -197,6 +202,8 @@ public class K9Drawer {
}
public void selectUnifiedInbox() {
unifiedInboxSelected = true;
openedFolderServerId = null;
drawer.setSelection(DRAWER_ID_UNIFIED_INBOX, false);
}