Fallback to account color for unified folder view / inboxes

pull/205/head
M66B 3 years ago
parent c711357f07
commit b694c1234e

@ -568,6 +568,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
case "folders":
fragment = new FragmentFolders();
args.putLong("account", account);
args.putBoolean("unified", true);
break;
case "primary":
fragment = new FragmentFolders();

@ -80,6 +80,7 @@ import java.util.Map;
public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder> {
private Fragment parentFragment;
private long account;
private boolean unified;
private boolean primary;
private boolean show_compact;
private boolean show_hidden;
@ -220,7 +221,10 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
tvName.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
if (listener == null) {
vwColor.setBackgroundColor(folder.color == null ? Color.TRANSPARENT : folder.color);
Integer color =
(folder.color == null && unified && EntityFolder.INBOX.equals(folder.type)
? folder.accountColor : folder.color);
vwColor.setBackgroundColor(color == null ? Color.TRANSPARENT : color);
vwColor.setVisibility(ActivityBilling.isPro(context) ? View.VISIBLE : View.GONE);
if (folder.sync_state == null || "requested".equals(folder.sync_state)) {
@ -1097,13 +1101,14 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
}
}
AdapterFolder(Fragment parentFragment, long account, boolean primary, boolean show_compact, boolean show_hidden, boolean show_flagged, IFolderSelectedListener listener) {
this(parentFragment.getContext(), parentFragment.getViewLifecycleOwner(), account, primary, show_compact, show_hidden, show_flagged, listener);
AdapterFolder(Fragment parentFragment, long account, boolean unified, boolean primary, boolean show_compact, boolean show_hidden, boolean show_flagged, IFolderSelectedListener listener) {
this(parentFragment.getContext(), parentFragment.getViewLifecycleOwner(), account, unified, primary, show_compact, show_hidden, show_flagged, listener);
this.parentFragment = parentFragment;
}
AdapterFolder(Context context, LifecycleOwner owner, long account, boolean primary, boolean show_compact, boolean show_hidden, boolean show_flagged, IFolderSelectedListener listener) {
AdapterFolder(Context context, LifecycleOwner owner, long account, boolean unified, boolean primary, boolean show_compact, boolean show_hidden, boolean show_flagged, IFolderSelectedListener listener) {
this.account = account;
this.unified = unified;
this.primary = primary;
this.show_compact = show_compact;
this.show_hidden = show_hidden;

@ -37,7 +37,7 @@ public interface DaoFolder {
@Query("SELECT folder.*" +
", account.id AS accountId, account.pop AS accountProtocol, account.`order` AS accountOrder" +
", account.name AS accountName, account.state AS accountState" +
", account.name AS accountName, account.color AS accountColor, account.state AS accountState" +
", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" +
", COUNT(DISTINCT message.id) AS messages" +
", COUNT(DISTINCT CASE WHEN message.content = 1 THEN message.id ELSE NULL END) AS content" +
@ -76,7 +76,7 @@ public interface DaoFolder {
@Transaction
@Query("SELECT folder.*" +
", account.id AS accountId, account.pop AS accountProtocol, account.`order` AS accountOrder" +
", account.name AS accountName, account.state AS accountState" +
", account.name AS accountName, account.color AS accountColor, account.state AS accountState" +
", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" +
", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" +
", COUNT(DISTINCT CASE WHEN message.content = 1 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS content" +
@ -99,7 +99,7 @@ public interface DaoFolder {
@Query("SELECT folder.*" +
", account.id AS accountId, account.pop AS accountProtocol, account.`order` AS accountOrder" +
", account.name AS accountName, account.state AS accountState" +
", account.name AS accountName, account.color AS accountColor, account.state AS accountState" +
", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" +
", COUNT(DISTINCT message.id) AS messages" +
", COUNT(DISTINCT CASE WHEN message.content = 1 THEN message.id ELSE NULL END) AS content" +
@ -137,7 +137,7 @@ public interface DaoFolder {
@Query("SELECT folder.*" +
", account.id AS accountId, account.pop AS accountProtocol, account.`order` AS accountOrder" +
", account.name AS accountName, account.state AS accountState" +
", account.name AS accountName, account.color AS accountColor, account.state AS accountState" +
", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" +
", COUNT(DISTINCT message.id) AS messages" +
", COUNT(DISTINCT CASE WHEN message.content = 1 THEN message.id ELSE NULL END) AS content" +

@ -132,7 +132,7 @@ public class FragmentDialogFolder extends FragmentDialogBase {
rvFolder.setLayoutManager(llm);
final AdapterFolder adapter = new AdapterFolder(context, getViewLifecycleOwner(),
account, false, false, false, false, new AdapterFolder.IFolderSelectedListener() {
account, false, false, false, false, false, new AdapterFolder.IFolderSelectedListener() {
@Override
public void onFolderSelected(@NonNull TupleFolderEx folder) {
String name = folder.getDisplayName(context, folder.parent_ref);

@ -103,6 +103,7 @@ public class FragmentFolders extends FragmentBase {
private boolean compact;
private long account;
private boolean unified = false;
private boolean imap = false;
private boolean primary;
private boolean show_hidden = false;
@ -126,6 +127,7 @@ public class FragmentFolders extends FragmentBase {
// Get arguments
Bundle args = getArguments();
account = args.getLong("account", -1);
unified = args.getBoolean("unified");
primary = args.getBoolean("primary");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
@ -205,7 +207,7 @@ public class FragmentFolders extends FragmentBase {
rvFolder.addItemDecoration(itemDecorator);
}
adapter = new AdapterFolder(this, account, primary, compact, show_hidden, show_flagged, null);
adapter = new AdapterFolder(this, account, unified, primary, compact, show_hidden, show_flagged, null);
rvFolder.setAdapter(adapter);
fabAdd.setOnClickListener(new View.OnClickListener() {

@ -41,6 +41,7 @@ public class TupleFolderEx extends EntityFolder implements Serializable {
public Integer accountProtocol;
public Integer accountOrder;
public String accountName;
public Integer accountColor;
public String accountState;
public int rules;
public int messages;
@ -69,6 +70,7 @@ public class TupleFolderEx extends EntityFolder implements Serializable {
Objects.equals(this.accountProtocol, other.accountProtocol) &&
Objects.equals(this.accountOrder, other.accountOrder) &&
Objects.equals(this.accountName, other.accountName) &&
Objects.equals(this.accountColor, other.accountColor) &&
Objects.equals(this.accountState, other.accountState) &&
this.rules == other.rules &&
this.messages == other.messages &&

Loading…
Cancel
Save