mirror of https://github.com/M66B/FairEmail.git
parent
3f391a2ddd
commit
6fdc1cae50
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,206 @@
|
|||||||
|
package eu.faircode.email;
|
||||||
|
|
||||||
|
/*
|
||||||
|
This file is part of FairEmail.
|
||||||
|
|
||||||
|
FairEmail is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
FairEmail is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Copyright 2018-2019 by Marcel Bokhorst (M66B)
|
||||||
|
*/
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
import androidx.recyclerview.widget.DiffUtil;
|
||||||
|
import androidx.recyclerview.widget.ListUpdateCallback;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class AdapterNavAccount extends RecyclerView.Adapter<AdapterNavAccount.ViewHolder> {
|
||||||
|
private Context context;
|
||||||
|
private LifecycleOwner owner;
|
||||||
|
private LayoutInflater inflater;
|
||||||
|
|
||||||
|
private List<TupleAccountEx> items = new ArrayList<>();
|
||||||
|
|
||||||
|
private NumberFormat nf = NumberFormat.getNumberInstance();
|
||||||
|
|
||||||
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
|
private View view;
|
||||||
|
private ImageView ivItem;
|
||||||
|
private TextView tvItem;
|
||||||
|
|
||||||
|
ViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
|
||||||
|
view = itemView.findViewById(R.id.clItem);
|
||||||
|
ivItem = itemView.findViewById(R.id.ivItem);
|
||||||
|
tvItem = itemView.findViewById(R.id.tvItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void wire() {
|
||||||
|
view.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unwire() {
|
||||||
|
view.setOnClickListener(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bindTo(TupleAccountEx account) {
|
||||||
|
ivItem.setImageResource("connected".equals(account.state)
|
||||||
|
? account.primary ? R.drawable.baseline_folder_special_24 : R.drawable.baseline_folder_24
|
||||||
|
: R.drawable.baseline_folder_open_24);
|
||||||
|
if (account.color == null)
|
||||||
|
ivItem.clearColorFilter();
|
||||||
|
else
|
||||||
|
ivItem.setColorFilter(account.color);
|
||||||
|
|
||||||
|
if (account.unseen == 0)
|
||||||
|
tvItem.setText(account.name);
|
||||||
|
else
|
||||||
|
tvItem.setText(context.getString(R.string.title_name_count,
|
||||||
|
account.name, nf.format(account.unseen)));
|
||||||
|
|
||||||
|
tvItem.setTextColor(Helper.resolveColor(context,
|
||||||
|
account.unseen == 0 ? android.R.attr.textColorSecondary : R.attr.colorUnread));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
int pos = getAdapterPosition();
|
||||||
|
if (pos == RecyclerView.NO_POSITION)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TupleAccountEx account = items.get(pos);
|
||||||
|
if (account == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
||||||
|
lbm.sendBroadcast(
|
||||||
|
new Intent(ActivityView.ACTION_VIEW_FOLDERS)
|
||||||
|
.putExtra("id", account.id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AdapterNavAccount(Context context, LifecycleOwner owner) {
|
||||||
|
this.context = context;
|
||||||
|
this.owner = owner;
|
||||||
|
this.inflater = LayoutInflater.from(context);
|
||||||
|
setHasStableIds(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(@NonNull List<TupleAccountEx> accounts) {
|
||||||
|
Log.i("Set nav accounts=" + accounts.size());
|
||||||
|
|
||||||
|
DiffUtil.DiffResult diff = DiffUtil.calculateDiff(new DiffCallback(items, accounts), false);
|
||||||
|
|
||||||
|
items = accounts;
|
||||||
|
|
||||||
|
diff.dispatchUpdatesTo(new ListUpdateCallback() {
|
||||||
|
@Override
|
||||||
|
public void onInserted(int position, int count) {
|
||||||
|
Log.i("Inserted @" + position + " #" + count);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRemoved(int position, int count) {
|
||||||
|
Log.i("Removed @" + position + " #" + count);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMoved(int fromPosition, int toPosition) {
|
||||||
|
Log.i("Moved " + fromPosition + ">" + toPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChanged(int position, int count, Object payload) {
|
||||||
|
Log.i("Changed @" + position + " #" + count);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
diff.dispatchUpdatesTo(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DiffCallback extends DiffUtil.Callback {
|
||||||
|
private List<TupleAccountEx> prev = new ArrayList<>();
|
||||||
|
private List<TupleAccountEx> next = new ArrayList<>();
|
||||||
|
|
||||||
|
DiffCallback(List<TupleAccountEx> prev, List<TupleAccountEx> next) {
|
||||||
|
this.prev.addAll(prev);
|
||||||
|
this.next.addAll(next);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOldListSize() {
|
||||||
|
return prev.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNewListSize() {
|
||||||
|
return next.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
|
||||||
|
TupleAccountEx a1 = prev.get(oldItemPosition);
|
||||||
|
TupleAccountEx a2 = next.get(newItemPosition);
|
||||||
|
return a1.id.equals(a2.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
|
||||||
|
TupleAccountEx a1 = prev.get(oldItemPosition);
|
||||||
|
TupleAccountEx a2 = next.get(newItemPosition);
|
||||||
|
return Objects.equals(a1.name, a2.name) &&
|
||||||
|
Objects.equals(a1.color, a2.color) &&
|
||||||
|
a1.unseen == a2.unseen &&
|
||||||
|
Objects.equals(a1.state, a2.state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return items.get(position).id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return items.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull
|
||||||
|
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
return new ViewHolder(inflater.inflate(R.layout.item_nav, parent, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||||
|
holder.unwire();
|
||||||
|
TupleAccountEx account = items.get(position);
|
||||||
|
holder.bindTo(account);
|
||||||
|
holder.wire();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,225 @@
|
|||||||
|
package eu.faircode.email;
|
||||||
|
|
||||||
|
/*
|
||||||
|
This file is part of FairEmail.
|
||||||
|
|
||||||
|
FairEmail is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
FairEmail is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Copyright 2018-2019 by Marcel Bokhorst (M66B)
|
||||||
|
*/
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
import androidx.recyclerview.widget.DiffUtil;
|
||||||
|
import androidx.recyclerview.widget.ListUpdateCallback;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.text.Collator;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class AdapterNavFolder extends RecyclerView.Adapter<AdapterNavFolder.ViewHolder> {
|
||||||
|
private Context context;
|
||||||
|
private LifecycleOwner owner;
|
||||||
|
private LayoutInflater inflater;
|
||||||
|
|
||||||
|
private List<TupleFolderNav> items = new ArrayList<>();
|
||||||
|
|
||||||
|
private NumberFormat nf = NumberFormat.getNumberInstance();
|
||||||
|
|
||||||
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
|
private View view;
|
||||||
|
private ImageView ivItem;
|
||||||
|
private TextView tvItem;
|
||||||
|
|
||||||
|
ViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
|
||||||
|
view = itemView.findViewById(R.id.clItem);
|
||||||
|
ivItem = itemView.findViewById(R.id.ivItem);
|
||||||
|
tvItem = itemView.findViewById(R.id.tvItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void wire() {
|
||||||
|
view.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unwire() {
|
||||||
|
view.setOnClickListener(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bindTo(TupleFolderNav folder) {
|
||||||
|
ivItem.setImageResource("connected".equals(folder.state)
|
||||||
|
? R.drawable.baseline_folder_24
|
||||||
|
: R.drawable.baseline_folder_open_24);
|
||||||
|
if (folder.color == null)
|
||||||
|
ivItem.clearColorFilter();
|
||||||
|
else
|
||||||
|
ivItem.setColorFilter(folder.color);
|
||||||
|
|
||||||
|
int count = (EntityFolder.OUTBOX.equals(folder.type) ? folder.operations : folder.unseen);
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
tvItem.setText(folder.getDisplayName(context));
|
||||||
|
else
|
||||||
|
tvItem.setText(context.getString(R.string.title_name_count,
|
||||||
|
folder.getDisplayName(context), nf.format(count)));
|
||||||
|
|
||||||
|
tvItem.setTextColor(Helper.resolveColor(context,
|
||||||
|
count == 0 ? android.R.attr.textColorSecondary : R.attr.colorUnread));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
int pos = getAdapterPosition();
|
||||||
|
if (pos == RecyclerView.NO_POSITION)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TupleFolderNav folder = items.get(pos);
|
||||||
|
if (folder == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
||||||
|
lbm.sendBroadcast(
|
||||||
|
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
|
||||||
|
.putExtra("account", folder.account)
|
||||||
|
.putExtra("folder", folder.id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AdapterNavFolder(Context context, LifecycleOwner owner) {
|
||||||
|
this.context = context;
|
||||||
|
this.owner = owner;
|
||||||
|
this.inflater = LayoutInflater.from(context);
|
||||||
|
setHasStableIds(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(@NonNull List<TupleFolderNav> folders) {
|
||||||
|
Log.i("Set nav folders=" + folders.size());
|
||||||
|
|
||||||
|
final Collator collator = Collator.getInstance(Locale.getDefault());
|
||||||
|
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc
|
||||||
|
|
||||||
|
Collections.sort(folders, new Comparator<EntityFolder>() {
|
||||||
|
@Override
|
||||||
|
public int compare(EntityFolder f1, EntityFolder f2) {
|
||||||
|
int o = Boolean.compare(EntityFolder.OUTBOX.equals(f1.type), EntityFolder.OUTBOX.equals(f2.type));
|
||||||
|
if (o != 0)
|
||||||
|
return o;
|
||||||
|
|
||||||
|
String name1 = f1.getDisplayName(context);
|
||||||
|
String name2 = f2.getDisplayName(context);
|
||||||
|
return collator.compare(name1, name2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
DiffUtil.DiffResult diff = DiffUtil.calculateDiff(new DiffCallback(items, folders), false);
|
||||||
|
|
||||||
|
items = folders;
|
||||||
|
|
||||||
|
diff.dispatchUpdatesTo(new ListUpdateCallback() {
|
||||||
|
@Override
|
||||||
|
public void onInserted(int position, int count) {
|
||||||
|
Log.i("Inserted @" + position + " #" + count);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRemoved(int position, int count) {
|
||||||
|
Log.i("Removed @" + position + " #" + count);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMoved(int fromPosition, int toPosition) {
|
||||||
|
Log.i("Moved " + fromPosition + ">" + toPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChanged(int position, int count, Object payload) {
|
||||||
|
Log.i("Changed @" + position + " #" + count);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
diff.dispatchUpdatesTo(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DiffCallback extends DiffUtil.Callback {
|
||||||
|
private List<TupleFolderNav> prev = new ArrayList<>();
|
||||||
|
private List<TupleFolderNav> next = new ArrayList<>();
|
||||||
|
|
||||||
|
DiffCallback(List<TupleFolderNav> prev, List<TupleFolderNav> next) {
|
||||||
|
this.prev.addAll(prev);
|
||||||
|
this.next.addAll(next);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOldListSize() {
|
||||||
|
return prev.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNewListSize() {
|
||||||
|
return next.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
|
||||||
|
TupleFolderNav f1 = prev.get(oldItemPosition);
|
||||||
|
TupleFolderNav f2 = next.get(newItemPosition);
|
||||||
|
return f1.id.equals(f2.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
|
||||||
|
TupleFolderNav f1 = prev.get(oldItemPosition);
|
||||||
|
TupleFolderNav f2 = next.get(newItemPosition);
|
||||||
|
return f1.equals(f2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return items.get(position).id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return items.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull
|
||||||
|
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
return new ViewHolder(inflater.inflate(R.layout.item_nav, parent, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||||
|
holder.unwire();
|
||||||
|
TupleFolderNav folder = items.get(position);
|
||||||
|
holder.bindTo(folder);
|
||||||
|
holder.wire();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,200 @@
|
|||||||
|
package eu.faircode.email;
|
||||||
|
|
||||||
|
/*
|
||||||
|
This file is part of FairEmail.
|
||||||
|
|
||||||
|
FairEmail is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
FairEmail is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Copyright 2018-2019 by Marcel Bokhorst (M66B)
|
||||||
|
*/
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
|
import androidx.recyclerview.widget.DiffUtil;
|
||||||
|
import androidx.recyclerview.widget.ListUpdateCallback;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AdapterNavMenu extends RecyclerView.Adapter<AdapterNavMenu.ViewHolder> {
|
||||||
|
private Context context;
|
||||||
|
private LifecycleOwner owner;
|
||||||
|
private LayoutInflater inflater;
|
||||||
|
|
||||||
|
private List<NavMenuItem> items = new ArrayList<>();
|
||||||
|
|
||||||
|
private NumberFormat nf = NumberFormat.getNumberInstance();
|
||||||
|
|
||||||
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||||
|
private View view;
|
||||||
|
private ImageView ivItem;
|
||||||
|
private TextView tvItem;
|
||||||
|
|
||||||
|
ViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
|
||||||
|
view = itemView.findViewById(R.id.clItem);
|
||||||
|
ivItem = itemView.findViewById(R.id.ivItem);
|
||||||
|
tvItem = itemView.findViewById(R.id.tvItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void wire() {
|
||||||
|
view.setOnClickListener(this);
|
||||||
|
view.setOnLongClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unwire() {
|
||||||
|
view.setOnClickListener(null);
|
||||||
|
view.setOnLongClickListener(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bindTo(NavMenuItem menu) {
|
||||||
|
ivItem.setImageResource(menu.getIcon());
|
||||||
|
|
||||||
|
if (menu.getCount() == null)
|
||||||
|
tvItem.setText(menu.getTitle());
|
||||||
|
else
|
||||||
|
tvItem.setText(context.getString(R.string.title_name_count,
|
||||||
|
context.getString(menu.getTitle()), nf.format(menu.getCount())));
|
||||||
|
|
||||||
|
tvItem.setTextColor(Helper.resolveColor(context,
|
||||||
|
menu.getCount() == null ? android.R.attr.textColorSecondary : R.attr.colorUnread));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
int pos = getAdapterPosition();
|
||||||
|
if (pos == RecyclerView.NO_POSITION)
|
||||||
|
return;
|
||||||
|
|
||||||
|
NavMenuItem menu = items.get(pos);
|
||||||
|
menu.onClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
int pos = getAdapterPosition();
|
||||||
|
if (pos == RecyclerView.NO_POSITION)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NavMenuItem menu = items.get(pos);
|
||||||
|
return menu.onLongClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AdapterNavMenu(Context context, LifecycleOwner owner) {
|
||||||
|
this.context = context;
|
||||||
|
this.owner = owner;
|
||||||
|
this.inflater = LayoutInflater.from(context);
|
||||||
|
setHasStableIds(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(@NonNull List<NavMenuItem> menus) {
|
||||||
|
Log.i("Set nav menus=" + menus.size());
|
||||||
|
|
||||||
|
DiffUtil.DiffResult diff = DiffUtil.calculateDiff(new DiffCallback(items, menus), false);
|
||||||
|
|
||||||
|
items = menus;
|
||||||
|
|
||||||
|
diff.dispatchUpdatesTo(new ListUpdateCallback() {
|
||||||
|
@Override
|
||||||
|
public void onInserted(int position, int count) {
|
||||||
|
Log.i("Inserted @" + position + " #" + count);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRemoved(int position, int count) {
|
||||||
|
Log.i("Removed @" + position + " #" + count);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMoved(int fromPosition, int toPosition) {
|
||||||
|
Log.i("Moved " + fromPosition + ">" + toPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChanged(int position, int count, Object payload) {
|
||||||
|
Log.i("Changed @" + position + " #" + count);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
diff.dispatchUpdatesTo(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DiffCallback extends DiffUtil.Callback {
|
||||||
|
private List<NavMenuItem> prev = new ArrayList<>();
|
||||||
|
private List<NavMenuItem> next = new ArrayList<>();
|
||||||
|
|
||||||
|
DiffCallback(List<NavMenuItem> prev, List<NavMenuItem> next) {
|
||||||
|
this.prev.addAll(prev);
|
||||||
|
this.next.addAll(next);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOldListSize() {
|
||||||
|
return prev.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNewListSize() {
|
||||||
|
return next.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
|
||||||
|
NavMenuItem m1 = prev.get(oldItemPosition);
|
||||||
|
NavMenuItem m2 = next.get(newItemPosition);
|
||||||
|
return m1.getTitle() == m2.getTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
|
||||||
|
NavMenuItem m1 = prev.get(oldItemPosition);
|
||||||
|
NavMenuItem m2 = next.get(newItemPosition);
|
||||||
|
return m1.equals(m2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return items.get(position).getTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return items.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull
|
||||||
|
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
return new ViewHolder(inflater.inflate(R.layout.item_nav, parent, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||||
|
holder.unwire();
|
||||||
|
NavMenuItem menu = items.get(position);
|
||||||
|
holder.bindTo(menu);
|
||||||
|
holder.wire();
|
||||||
|
}
|
||||||
|
}
|
@ -1,91 +0,0 @@
|
|||||||
package eu.faircode.email;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DrawerAdapter extends ArrayAdapter<DrawerItem> {
|
|
||||||
private boolean collapsed;
|
|
||||||
private List<DrawerItem> items = new ArrayList<>();
|
|
||||||
|
|
||||||
DrawerAdapter(@NonNull Context context, boolean collapsed) {
|
|
||||||
super(context, -1);
|
|
||||||
this.collapsed = collapsed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
|
|
||||||
DrawerItem item = getItem(position);
|
|
||||||
|
|
||||||
View row = item.isCollapsible() && collapsed
|
|
||||||
? new View(getContext())
|
|
||||||
: LayoutInflater.from(getContext()).inflate(item.getLayout(), null);
|
|
||||||
|
|
||||||
ImageView iv = row.findViewById(R.id.ivItem);
|
|
||||||
TextView tv = row.findViewById(R.id.tvItem);
|
|
||||||
ImageView expander = row.findViewById(R.id.ivExpander);
|
|
||||||
|
|
||||||
if (iv != null) {
|
|
||||||
iv.setImageResource(item.getIcon());
|
|
||||||
if (item.getColor() != null)
|
|
||||||
iv.setColorFilter(item.getColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tv != null) {
|
|
||||||
tv.setText(item.getTitle(getContext()));
|
|
||||||
|
|
||||||
tv.setTextColor(Helper.resolveColor(getContext(),
|
|
||||||
item.getHighlight() ? R.attr.colorUnread : android.R.attr.textColorSecondary));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (expander != null)
|
|
||||||
expander.setImageLevel(collapsed ? 1 /* more */ : 0 /* less */);
|
|
||||||
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set(boolean collapsed) {
|
|
||||||
this.collapsed = collapsed;
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void set(List<DrawerItem> items) {
|
|
||||||
this.items = items;
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCount() {
|
|
||||||
return items.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public DrawerItem getItem(int position) {
|
|
||||||
if (position < items.size())
|
|
||||||
return items.get(position);
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasStableIds() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getItemId(int position) {
|
|
||||||
DrawerItem item = getItem(position);
|
|
||||||
return (item == null ? 0 : item.getId());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,95 +0,0 @@
|
|||||||
package eu.faircode.email;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
public class DrawerItem {
|
|
||||||
private long id;
|
|
||||||
private int menu;
|
|
||||||
private int layout;
|
|
||||||
private int icon;
|
|
||||||
private Integer color;
|
|
||||||
private int resid;
|
|
||||||
private String title;
|
|
||||||
private boolean highlight;
|
|
||||||
private boolean collapsible = false;
|
|
||||||
|
|
||||||
DrawerItem(long id) {
|
|
||||||
this.id = id;
|
|
||||||
this.layout = R.layout.item_drawer_separator;
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawerItem(long id, int resid) {
|
|
||||||
this.id = id;
|
|
||||||
this.menu = resid;
|
|
||||||
this.layout = R.layout.item_drawer_expander;
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawerItem(long id, int icon, int resid) {
|
|
||||||
this.id = id;
|
|
||||||
this.menu = resid;
|
|
||||||
this.layout = R.layout.item_drawer;
|
|
||||||
this.icon = icon;
|
|
||||||
this.resid = resid;
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawerItem(long id, int menu, int icon, String title, boolean highlight) {
|
|
||||||
this.id = id;
|
|
||||||
this.menu = menu;
|
|
||||||
this.layout = R.layout.item_drawer;
|
|
||||||
this.icon = icon;
|
|
||||||
this.title = title;
|
|
||||||
this.highlight = highlight;
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawerItem(long id, int icon, String title, Integer color, boolean highlight) {
|
|
||||||
this.id = id;
|
|
||||||
this.layout = R.layout.item_drawer;
|
|
||||||
this.icon = icon;
|
|
||||||
this.color = color;
|
|
||||||
this.title = title;
|
|
||||||
this.highlight = highlight;
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawerItem setCollapsible() {
|
|
||||||
this.collapsible = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getLayout() {
|
|
||||||
return this.layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
long getId() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isEnabled() {
|
|
||||||
return (this.layout != R.layout.item_drawer_separator);
|
|
||||||
}
|
|
||||||
|
|
||||||
int getMenuId() {
|
|
||||||
return this.menu;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getIcon() {
|
|
||||||
return this.icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer getColor() {
|
|
||||||
return this.color;
|
|
||||||
}
|
|
||||||
|
|
||||||
String getTitle(Context context) {
|
|
||||||
if (this.title == null && resid > 0)
|
|
||||||
this.title = context.getString(resid);
|
|
||||||
return this.title;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean getHighlight() {
|
|
||||||
return this.highlight;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isCollapsible() {
|
|
||||||
return this.collapsible;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,65 @@
|
|||||||
|
package eu.faircode.email;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class NavMenuItem {
|
||||||
|
private int icon;
|
||||||
|
private int title;
|
||||||
|
private Integer count = null;
|
||||||
|
private Runnable click;
|
||||||
|
private Runnable longClick;
|
||||||
|
|
||||||
|
NavMenuItem(int icon, int title, Runnable click) {
|
||||||
|
this.icon = icon;
|
||||||
|
this.title = title;
|
||||||
|
this.click = click;
|
||||||
|
}
|
||||||
|
|
||||||
|
NavMenuItem(int icon, int title, Runnable click, Runnable longClick) {
|
||||||
|
this.icon = icon;
|
||||||
|
this.title = title;
|
||||||
|
this.click = click;
|
||||||
|
this.longClick = longClick;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setCount(Integer count) {
|
||||||
|
if (count != null && count == 0)
|
||||||
|
count = null;
|
||||||
|
this.count = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getIcon() {
|
||||||
|
return this.icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getTitle() {
|
||||||
|
return this.title;
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer getCount() {
|
||||||
|
return this.count;
|
||||||
|
}
|
||||||
|
|
||||||
|
void onClick() {
|
||||||
|
click.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean onLongClick() {
|
||||||
|
if (longClick != null)
|
||||||
|
longClick.run();
|
||||||
|
return (longClick != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(@Nullable Object obj) {
|
||||||
|
if (obj instanceof NavMenuItem) {
|
||||||
|
NavMenuItem other = (NavMenuItem) obj;
|
||||||
|
return (this.icon == other.icon &&
|
||||||
|
this.title == other.title &&
|
||||||
|
Objects.equals(this.count, other.count));
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package eu.faircode.email;
|
||||||
|
|
||||||
|
/*
|
||||||
|
This file is part of FairEmail.
|
||||||
|
|
||||||
|
FairEmail is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
FairEmail is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Copyright 2018-2019 by Marcel Bokhorst (M66B)
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class TupleFolderNav extends EntityFolder implements Serializable {
|
||||||
|
public Integer color; // account
|
||||||
|
public int unseen;
|
||||||
|
public int operations;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj instanceof TupleFolderNav) {
|
||||||
|
TupleFolderNav other = (TupleFolderNav) obj;
|
||||||
|
return (super.equals(obj) &&
|
||||||
|
Objects.equals(this.color, other.color) &&
|
||||||
|
this.unseen == other.unseen &&
|
||||||
|
this.operations == other.operations);
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvAccount"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:nestedScrollingEnabled="false"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/vSeparatorAccount"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?attr/colorSeparator"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/rvAccount" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvFolder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:nestedScrollingEnabled="false"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/vSeparatorAccount" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/vSeparatorFolder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?attr/colorSeparator"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/rvFolder" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvMenu"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:nestedScrollingEnabled="false"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/vSeparatorFolder" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/vSeparatorMenu"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?attr/colorSeparator"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/rvMenu" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivExpander"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:contentDescription="@string/title_legend_expander"
|
||||||
|
android:src="@drawable/expander"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/vSeparatorMenu" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvMenuExtra1"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:nestedScrollingEnabled="false"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/ivExpander" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/vSeparatorMenuExtra"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?attr/colorSeparator"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/rvMenuExtra1" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvMenuExtra2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:nestedScrollingEnabled="false"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/vSeparatorMenuExtra" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -1,34 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/ivItem"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="12dp"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:src="@drawable/baseline_mail_outline_24"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvItem"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="12dp"
|
|
||||||
android:layout_marginEnd="12dp"
|
|
||||||
android:ellipsize="start"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:minHeight="48dp"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:text="Menu item"
|
|
||||||
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/ivItem"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/ivExpander"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical|center_horizontal"
|
|
||||||
android:contentDescription="@string/title_legend_expander"
|
|
||||||
android:src="@drawable/expander"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingTop="6dp"
|
|
||||||
android:paddingBottom="6dp">
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/vSeparator"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:background="?attr/colorSeparator"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/clItem"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivItem"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:src="@drawable/baseline_mail_outline_24"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvItem"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:layout_marginEnd="12dp"
|
||||||
|
android:ellipsize="start"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:minHeight="48dp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="Nav item"
|
||||||
|
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/ivItem"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</FrameLayout>
|
Loading…
Reference in new issue