Debug: extra count

pull/194/merge
M66B 4 years ago
parent 2f62075e10
commit e78419f6c4

@ -673,7 +673,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
drawerLayout.closeDrawer(drawerContainer); drawerLayout.closeDrawer(drawerContainer);
onMenuOperations(); onMenuOperations();
} }
}); }).setExtraCount(BuildConfig.DEBUG);
menus.add(navOperations); menus.add(navOperations);

@ -78,6 +78,7 @@ public class AdapterNavAccountFolder extends RecyclerView.Adapter<AdapterNavAcco
private View view; private View view;
private ImageView ivItem; private ImageView ivItem;
private ImageView ivBadge; private ImageView ivBadge;
private TextView tvCount;
private TextView tvItem; private TextView tvItem;
private TextView tvItemExtra; private TextView tvItemExtra;
private ImageView ivExtra; private ImageView ivExtra;
@ -89,6 +90,7 @@ public class AdapterNavAccountFolder extends RecyclerView.Adapter<AdapterNavAcco
view = itemView.findViewById(R.id.clItem); view = itemView.findViewById(R.id.clItem);
ivItem = itemView.findViewById(R.id.ivItem); ivItem = itemView.findViewById(R.id.ivItem);
ivBadge = itemView.findViewById(R.id.ivBadge); ivBadge = itemView.findViewById(R.id.ivBadge);
tvCount = itemView.findViewById(R.id.tvCount);
tvItem = itemView.findViewById(R.id.tvItem); tvItem = itemView.findViewById(R.id.tvItem);
tvItemExtra = itemView.findViewById(R.id.tvItemExtra); tvItemExtra = itemView.findViewById(R.id.tvItemExtra);
ivExtra = itemView.findViewById(R.id.ivExtra); ivExtra = itemView.findViewById(R.id.ivExtra);
@ -139,12 +141,14 @@ public class AdapterNavAccountFolder extends RecyclerView.Adapter<AdapterNavAcco
else else
count = account.unseen; count = account.unseen;
ivBadge.setVisibility(count == 0 || expanded ? View.GONE : View.VISIBLE);
tvCount.setVisibility(View.GONE);
Integer color = (account.folderName == null ? account.color : account.folderColor); Integer color = (account.folderName == null ? account.color : account.folderColor);
if (color == null || !ActivityBilling.isPro(context)) if (color == null || !ActivityBilling.isPro(context))
ivItem.clearColorFilter(); ivItem.clearColorFilter();
else else
ivItem.setColorFilter(color); ivItem.setColorFilter(color);
ivBadge.setVisibility(count == 0 || expanded ? View.GONE : View.VISIBLE);
String name = account.getName(context); String name = account.getName(context);
if (count == 0) if (count == 0)

@ -61,6 +61,7 @@ public class AdapterNavMenu extends RecyclerView.Adapter<AdapterNavMenu.ViewHold
private View view; private View view;
private ImageView ivItem; private ImageView ivItem;
private ImageView ivBadge; private ImageView ivBadge;
private TextView tvCount;
private TextView tvItem; private TextView tvItem;
private TextView tvItemExtra; private TextView tvItemExtra;
private ImageView ivExtra; private ImageView ivExtra;
@ -72,6 +73,7 @@ public class AdapterNavMenu extends RecyclerView.Adapter<AdapterNavMenu.ViewHold
view = itemView.findViewById(R.id.clItem); view = itemView.findViewById(R.id.clItem);
ivItem = itemView.findViewById(R.id.ivItem); ivItem = itemView.findViewById(R.id.ivItem);
ivBadge = itemView.findViewById(R.id.ivBadge); ivBadge = itemView.findViewById(R.id.ivBadge);
tvCount = itemView.findViewById(R.id.tvCount);
tvItem = itemView.findViewById(R.id.tvItem); tvItem = itemView.findViewById(R.id.tvItem);
tvItemExtra = itemView.findViewById(R.id.tvItemExtra); tvItemExtra = itemView.findViewById(R.id.tvItemExtra);
ivExtra = itemView.findViewById(R.id.ivExtra); ivExtra = itemView.findViewById(R.id.ivExtra);
@ -92,10 +94,16 @@ public class AdapterNavMenu extends RecyclerView.Adapter<AdapterNavMenu.ViewHold
ivItem.setImageResource(menu.getIcon()); ivItem.setImageResource(menu.getIcon());
Integer color = menu.getColor(); Integer color = menu.getColor();
ivItem.setImageTintList(ColorStateList.valueOf(color == null ? colorControlNormal : color)); ivItem.setImageTintList(ColorStateList.valueOf(color == null
? colorControlNormal : color));
Integer count = menu.getCount(); Integer count = menu.getCount();
ivBadge.setVisibility(count == null || count == 0 || expanded ? View.GONE : View.VISIBLE); ivBadge.setVisibility(count == null || count == 0 || expanded
? View.GONE : View.VISIBLE);
tvCount.setText(count == null ? null : Integer.toString(count));
tvCount.setVisibility(count == null || count == 0 || expanded || !menu.getExtraCount()
? View.GONE : View.VISIBLE);
if (count == null) if (count == null)
tvItem.setText(menu.getTitle()); tvItem.setText(menu.getTitle());

@ -54,6 +54,7 @@ public class AdapterNavSearch extends RecyclerView.Adapter<AdapterNavSearch.View
private View view; private View view;
private ImageView ivItem; private ImageView ivItem;
private ImageView ivBadge; private ImageView ivBadge;
private TextView tvCount;
private TextView tvItem; private TextView tvItem;
private TextView tvItemExtra; private TextView tvItemExtra;
private ImageView ivExtra; private ImageView ivExtra;
@ -65,6 +66,7 @@ public class AdapterNavSearch extends RecyclerView.Adapter<AdapterNavSearch.View
view = itemView.findViewById(R.id.clItem); view = itemView.findViewById(R.id.clItem);
ivItem = itemView.findViewById(R.id.ivItem); ivItem = itemView.findViewById(R.id.ivItem);
ivBadge = itemView.findViewById(R.id.ivBadge); ivBadge = itemView.findViewById(R.id.ivBadge);
tvCount = itemView.findViewById(R.id.tvCount);
tvItem = itemView.findViewById(R.id.tvItem); tvItem = itemView.findViewById(R.id.tvItem);
tvItemExtra = itemView.findViewById(R.id.tvItemExtra); tvItemExtra = itemView.findViewById(R.id.tvItemExtra);
ivExtra = itemView.findViewById(R.id.ivExtra); ivExtra = itemView.findViewById(R.id.ivExtra);
@ -87,6 +89,7 @@ public class AdapterNavSearch extends RecyclerView.Adapter<AdapterNavSearch.View
ivItem.setColorFilter(search.color); ivItem.setColorFilter(search.color);
ivBadge.setVisibility(View.GONE); ivBadge.setVisibility(View.GONE);
tvCount.setVisibility(View.GONE);
tvItem.setText(search.name); tvItem.setText(search.name);
tvItemExtra.setVisibility(View.GONE); tvItemExtra.setVisibility(View.GONE);

@ -62,6 +62,7 @@ public class AdapterNavUnified extends RecyclerView.Adapter<AdapterNavUnified.Vi
private View view; private View view;
private ImageView ivItem; private ImageView ivItem;
private ImageView ivBadge; private ImageView ivBadge;
private TextView tvCount;
private TextView tvItem; private TextView tvItem;
private TextView tvItemExtra; private TextView tvItemExtra;
private ImageView ivExtra; private ImageView ivExtra;
@ -73,6 +74,7 @@ public class AdapterNavUnified extends RecyclerView.Adapter<AdapterNavUnified.Vi
view = itemView.findViewById(R.id.clItem); view = itemView.findViewById(R.id.clItem);
ivItem = itemView.findViewById(R.id.ivItem); ivItem = itemView.findViewById(R.id.ivItem);
ivBadge = itemView.findViewById(R.id.ivBadge); ivBadge = itemView.findViewById(R.id.ivBadge);
tvCount = itemView.findViewById(R.id.tvCount);
tvItem = itemView.findViewById(R.id.tvItem); tvItem = itemView.findViewById(R.id.tvItem);
tvItemExtra = itemView.findViewById(R.id.tvItemExtra); tvItemExtra = itemView.findViewById(R.id.tvItemExtra);
ivExtra = itemView.findViewById(R.id.ivExtra); ivExtra = itemView.findViewById(R.id.ivExtra);
@ -111,6 +113,7 @@ public class AdapterNavUnified extends RecyclerView.Adapter<AdapterNavUnified.Vi
count = folder.unseen; count = folder.unseen;
ivBadge.setVisibility(count == 0 || expanded ? View.GONE : View.VISIBLE); ivBadge.setVisibility(count == 0 || expanded ? View.GONE : View.VISIBLE);
tvCount.setVisibility(View.GONE);
if (count == 0) if (count == 0)
tvItem.setText(EntityFolder.localizeType(context, folder.type)); tvItem.setText(EntityFolder.localizeType(context, folder.type));

@ -26,8 +26,9 @@ public class NavMenuItem {
private Integer color; private Integer color;
private int title; private int title;
private String subtitle = null; private String subtitle = null;
private int extraicon; private int extra_icon;
private Integer count = null; private Integer count = null;
private boolean extra_count = false;
private boolean warning = false; private boolean warning = false;
private boolean separated = false; private boolean separated = false;
private Runnable click; private Runnable click;
@ -57,7 +58,7 @@ public class NavMenuItem {
} }
NavMenuItem setExtraIcon(int icon) { NavMenuItem setExtraIcon(int icon) {
this.extraicon = icon; this.extra_icon = icon;
return this; return this;
} }
@ -67,6 +68,11 @@ public class NavMenuItem {
this.count = count; this.count = count;
} }
NavMenuItem setExtraCount(boolean value) {
this.extra_count = value;
return this;
}
NavMenuItem setExternal(boolean external) { NavMenuItem setExternal(boolean external) {
setExtraIcon(external ? R.drawable.twotone_open_in_new_24 : 0); setExtraIcon(external ? R.drawable.twotone_open_in_new_24 : 0);
return this; return this;
@ -99,13 +105,17 @@ public class NavMenuItem {
} }
int getExtraIcon() { int getExtraIcon() {
return this.extraicon; return this.extra_icon;
} }
Integer getCount() { Integer getCount() {
return this.count; return this.count;
} }
boolean getExtraCount() {
return this.extra_count;
}
boolean isSeparated() { boolean isSeparated() {
return this.separated; return this.separated;
} }
@ -141,8 +151,9 @@ public class NavMenuItem {
Objects.equals(this.color, other.color) && Objects.equals(this.color, other.color) &&
this.title == other.title && this.title == other.title &&
Objects.equals(this.subtitle, other.subtitle) && Objects.equals(this.subtitle, other.subtitle) &&
this.extraicon == other.extraicon && this.extra_icon == other.extra_icon &&
Objects.equals(this.count, other.count) && Objects.equals(this.count, other.count) &&
this.extra_count == other.extra_count &&
this.warning == other.warning && this.warning == other.warning &&
this.separated == other.separated); this.separated == other.separated);
} else } else
@ -151,6 +162,6 @@ public class NavMenuItem {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(icon, color, title, subtitle, extraicon, count, warning, separated); return Objects.hash(icon, color, title, subtitle, extra_icon, count, extra_count, warning, separated);
} }
} }

@ -31,6 +31,20 @@
app:layout_constraintStart_toStartOf="@+id/ivItem" app:layout_constraintStart_toStartOf="@+id/ivItem"
app:srcCompat="@drawable/badge" /> app:srcCompat="@drawable/badge" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:singleLine="true"
android:text="123"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorBadge"
android:textSize="10sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="@+id/ivItem"
app:layout_constraintTop_toTopOf="parent" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView
android:id="@+id/tvItem" android:id="@+id/tvItem"
android:layout_width="0dp" android:layout_width="0dp"

Loading…
Cancel
Save