Detect and select unified inbox in drawer

This commit is contained in:
williamvds 2018-10-21 13:31:58 +01:00
parent 58598c07cc
commit 02b253b0f1
No known key found for this signature in database
GPG key ID: 7A4DF5A8CDBD49C7
3 changed files with 26 additions and 0 deletions

View file

@ -23,6 +23,7 @@ import android.os.Parcelable;
public class LocalSearch implements SearchSpecification {
private String id;
private String mName;
private boolean mPredefined;
private boolean mManualSearch = false;
@ -103,6 +104,16 @@ public class LocalSearch implements SearchSpecification {
this.mName = name;
}
/**
* Set the ID of the search. This is used to identify a unified inbox
* search
*
* @param id ID to set
*/
public void setId(String id) {
this.id = id;
}
/**
* Add a new account to the search. When no accounts are
* added manually we search all accounts on the device.
@ -301,6 +312,15 @@ public class LocalSearch implements SearchSpecification {
return (mName == null) ? "" : mName;
}
/**
* Returns the ID of the search
*
* @return The ID of the search
*/
public String getId() {
return (id == null) ? "" : id;
}
/**
* Checks if this search was hard coded and shipped with K-9
*
@ -364,6 +384,7 @@ public class LocalSearch implements SearchSpecification {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(id);
dest.writeString(mName);
dest.writeByte((byte) (mPredefined ? 1 : 0));
dest.writeByte((byte) (mManualSearch ? 1 : 0));
@ -386,6 +407,7 @@ public class LocalSearch implements SearchSpecification {
};
public LocalSearch(Parcel in) {
id = in.readString();
mName = in.readString();
mPredefined = (in.readByte() == 1);
mManualSearch = (in.readByte() == 1);

View file

@ -34,6 +34,7 @@ public class SearchAccount implements BaseAccount {
CoreResourceProvider resourceProvider = DI.get(CoreResourceProvider.class);
String name = resourceProvider.searchUnifiedInboxTitle();
LocalSearch tmpSearch = new LocalSearch(name);
tmpSearch.setId(UNIFIED_INBOX);
tmpSearch.and(SearchField.INTEGRATE, "1", Attribute.EQUALS);
return new SearchAccount(UNIFIED_INBOX, tmpSearch, name, resourceProvider.searchUnifiedInboxDetail());
}

View file

@ -476,6 +476,9 @@ 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);
}