Browse Source

Added folders separator in navigation menu

main
M66B 5 years ago
parent
commit
36d1fb5154
2 changed files with 42 additions and 23 deletions
  1. +26
    -23
      app/src/main/java/eu/faircode/email/ActivityView.java
  2. +16
    -0
      app/src/main/res/layout/item_drawer_separator.xml

+ 26
- 23
app/src/main/java/eu/faircode/email/ActivityView.java View File

@ -143,7 +143,7 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
if (accounts == null)
accounts = new ArrayList<>();
ArrayAdapterDrawer drawerArray = new ArrayAdapterDrawer(ActivityView.this, R.layout.item_drawer);
ArrayAdapterDrawer drawerArray = new ArrayAdapterDrawer(ActivityView.this);
final Collator collator = Collator.getInstance(Locale.getDefault());
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc
@ -156,23 +156,25 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
});
for (EntityAccount account : accounts)
drawerArray.add(new DrawerItem(-1, R.drawable.baseline_folder_24, account.name, account.id));
drawerArray.add(new DrawerItem(R.layout.item_drawer, -1, R.drawable.baseline_folder_24, account.name, account.id));
drawerArray.add(new DrawerItem(ActivityView.this, R.drawable.baseline_settings_applications_24, R.string.menu_setup));
drawerArray.add(new DrawerItem(R.layout.item_drawer_separator));
drawerArray.add(new DrawerItem(ActivityView.this, R.layout.item_drawer, R.drawable.baseline_settings_applications_24, R.string.menu_setup));
if (PreferenceManager.getDefaultSharedPreferences(ActivityView.this).getBoolean("debug", false))
drawerArray.add(new DrawerItem(ActivityView.this, R.drawable.baseline_list_24, R.string.menu_operations));
drawerArray.add(new DrawerItem(ActivityView.this, R.layout.item_drawer, R.drawable.baseline_list_24, R.string.menu_operations));
if (getIntentPrivacy().resolveActivity(getPackageManager()) != null)
drawerArray.add(new DrawerItem(ActivityView.this, R.drawable.baseline_account_box_24, R.string.menu_privacy));
drawerArray.add(new DrawerItem(ActivityView.this, R.layout.item_drawer, R.drawable.baseline_account_box_24, R.string.menu_privacy));
if (getIntentFAQ().resolveActivity(getPackageManager()) != null)
drawerArray.add(new DrawerItem(ActivityView.this, R.drawable.baseline_question_answer_24, R.string.menu_faq));
drawerArray.add(new DrawerItem(ActivityView.this, R.layout.item_drawer, R.drawable.baseline_question_answer_24, R.string.menu_faq));
drawerArray.add(new DrawerItem(ActivityView.this, R.drawable.baseline_help_24, R.string.menu_about));
drawerArray.add(new DrawerItem(ActivityView.this, R.layout.item_drawer, R.drawable.baseline_help_24, R.string.menu_about));
if (getIntentOtherApps().resolveActivity(getPackageManager()) != null)
drawerArray.add(new DrawerItem(ActivityView.this, R.drawable.baseline_get_app_24, R.string.menu_other));
drawerArray.add(new DrawerItem(ActivityView.this, R.layout.item_drawer, R.drawable.baseline_get_app_24, R.string.menu_other));
drawerList.setAdapter(drawerArray);
}
@ -463,18 +465,25 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
}
private class DrawerItem {
private int layout;
private int id;
private int icon;
private String title;
private Object data;
DrawerItem(Context context, int icon, int title) {
DrawerItem(int layout) {
this.layout = layout;
}
DrawerItem(Context context, int layout, int icon, int title) {
this.layout = layout;
this.id = title;
this.icon = icon;
this.title = context.getString(title);
}
DrawerItem(int id, int icon, String title, Object data) {
DrawerItem(int layout, int id, int icon, String title, Object data) {
this.layout = layout;
this.id = id;
this.icon = icon;
this.title = title;
@ -491,28 +500,22 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
}
private static class ArrayAdapterDrawer extends ArrayAdapter<DrawerItem> {
private int resource;
ArrayAdapterDrawer(@NonNull Context context, int resource) {
super(context, resource);
this.resource = resource;
ArrayAdapterDrawer(@NonNull Context context) {
super(context, -1);
}
@NonNull
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
View row;
if (null == convertView)
row = LayoutInflater.from(getContext()).inflate(this.resource, null);
else
row = convertView;
DrawerItem item = getItem(position);
View row = LayoutInflater.from(getContext()).inflate(item.layout, null);
ImageView iv = row.findViewById(R.id.ivItem);
TextView tv = row.findViewById(R.id.tvItem);
iv.setImageResource(item.icon);
tv.setText(item.title);
if (iv != null)
iv.setImageResource(item.icon);
if (tv != null)
tv.setText(item.title);
return row;
}


+ 16
- 0
app/src/main/res/layout/item_drawer_separator.xml View File

@ -0,0 +1,16 @@
<?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">
<View
android:id="@+id/vSeparatorAddress"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_marginBottom="6dp"
android:layout_marginTop="6dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

Loading…
Cancel
Save