mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-31 20:25:38 +00:00
Added configurable card padding
This commit is contained in:
parent
a7df8a7639
commit
cb87ef9f80
5 changed files with 37 additions and 2 deletions
|
@ -6543,6 +6543,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
return this.zoom;
|
||||
}
|
||||
|
||||
void setPadding(int padding) {
|
||||
if (rv != null) {
|
||||
rv.getRecycledViewPool().clear();
|
||||
rv.getLayoutManager().removeAllViews();
|
||||
}
|
||||
properties.refresh();
|
||||
}
|
||||
|
||||
void setSort(String sort) {
|
||||
if (!sort.equals(this.sort)) {
|
||||
this.sort = sort;
|
||||
|
|
|
@ -4517,6 +4517,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
menu.findItem(R.id.menu_filter_duplicates).setChecked(filter_duplicates);
|
||||
|
||||
menu.findItem(R.id.menu_compact).setChecked(compact);
|
||||
menu.findItem(R.id.menu_padding).setVisible(cards);
|
||||
menu.findItem(R.id.menu_theme).setVisible(viewType == AdapterMessage.ViewType.UNIFIED);
|
||||
|
||||
menu.findItem(R.id.menu_select_all).setVisible(folder);
|
||||
|
@ -4623,6 +4624,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
} else if (itemId == R.id.menu_zoom) {
|
||||
onMenuZoom();
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_padding) {
|
||||
onMenuPadding();
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_compact) {
|
||||
onMenuCompact();
|
||||
return true;
|
||||
|
@ -4875,16 +4879,31 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
adapter.setZoom(zoom);
|
||||
}
|
||||
|
||||
private void onMenuPadding() {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
boolean compact = prefs.getBoolean("compact", false);
|
||||
int padding = prefs.getInt("view_padding", compact ? 0 : 1);
|
||||
padding = ++padding % 3;
|
||||
prefs.edit().putInt("view_padding", padding).apply();
|
||||
clearMeasurements();
|
||||
adapter.setPadding(padding);
|
||||
}
|
||||
|
||||
private void onMenuCompact() {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
boolean compact = !prefs.getBoolean("compact", false);
|
||||
prefs.edit().putBoolean("compact", compact).apply();
|
||||
|
||||
int zoom = (compact ? 0 : 1);
|
||||
prefs.edit().putInt("view_zoom", zoom).apply();
|
||||
int padding = (compact ? 0 : 1);
|
||||
prefs.edit()
|
||||
.putInt("view_zoom", zoom)
|
||||
.putInt("view_padding", padding)
|
||||
.apply();
|
||||
|
||||
adapter.setCompact(compact);
|
||||
adapter.setZoom(zoom);
|
||||
adapter.setPadding(padding);
|
||||
clearMeasurements();
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import androidx.preference.PreferenceManager;
|
|||
public class ViewCardOptional extends CardView {
|
||||
private boolean cards;
|
||||
private boolean compact;
|
||||
private int padding;
|
||||
private int margin;
|
||||
private int ident;
|
||||
private Integer color = null;
|
||||
|
@ -56,8 +57,9 @@ public class ViewCardOptional extends CardView {
|
|||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
cards = prefs.getBoolean("cards", true);
|
||||
compact = prefs.getBoolean("compact", false);
|
||||
padding = prefs.getInt("view_padding", compact ? 0 : 1);
|
||||
|
||||
margin = Helper.dp2pixels(context, compact ? 3 : 6);
|
||||
margin = Helper.dp2pixels(context, (padding + 1) * 3);
|
||||
|
||||
setRadius(cards ? margin : 0);
|
||||
setCardElevation(0);
|
||||
|
|
|
@ -130,6 +130,11 @@
|
|||
android:title="@string/title_zoom"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_padding"
|
||||
android:title="@string/title_padding"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_compact"
|
||||
android:checkable="true"
|
||||
|
|
|
@ -1391,6 +1391,7 @@
|
|||
|
||||
<string name="title_compact">Compact view</string>
|
||||
<string name="title_zoom">Text size</string>
|
||||
<string name="title_padding">Padding size</string>
|
||||
<string name="title_select_language">Select language</string>
|
||||
<string name="title_select_all">Select all</string>
|
||||
<string name="title_select_found">Select found</string>
|
||||
|
|
Loading…
Reference in a new issue