Larger buttons (2)

This commit is contained in:
M66B 2022-08-20 08:16:14 +02:00
parent faefc29572
commit 7741037edc
10 changed files with 74 additions and 52 deletions

View File

@ -7,7 +7,7 @@
### 1.1955 - 2022-08-18
* Added batch enable showing child folders in the navigation menu
* Added display option for large message action buttons
* Added menu item for larger message action buttons
* Small improvements and minor bug fixes
* Updated libraries
* Updated translations

View File

@ -7,7 +7,7 @@
### 1.1955 - 2022-08-18
* Added batch enable showing child folders in the navigation menu
* Added display option for large message action buttons
* Added menu item for larger message action buttons
* Small improvements and minor bug fixes
* Updated libraries
* Updated translations

View File

@ -889,26 +889,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibMore = vsBody.findViewById(R.id.ibMore);
vwEmpty = vsBody.findViewById(R.id.vwEmpty);
ibFlow = vsBody.findViewById(R.id.ibFlow);
if (large_buttons) {
int dp36 = Helper.dp2pixels(context, 42);
ConstraintLayout cl = (ConstraintLayout) ibFlow.getParent();
List<Integer> ids = new ArrayList<>();
for (int id : ibFlow.getReferencedIds())
ids.add(id);
for (int id : new int[]{
R.id.ibTools, R.id.vwEmpty,
R.id.ibFull, R.id.ibImages, R.id.ibAmp,
R.id.ibDecrypt, R.id.ibVerify})
ids.add(id);
for (int id : ids) {
View v = cl.findViewById(id);
ViewGroup.LayoutParams lparam = v.getLayoutParams();
lparam.width = dp36;
lparam.height = dp36;
}
}
ibTools = vsBody.findViewById(R.id.ibTools);
buttons = vsBody.findViewById(R.id.buttons);
@ -958,6 +938,24 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
grpAttachments = attachments.findViewById(R.id.grpAttachments);
grpImages = vsBody.findViewById(R.id.grpImages);
if (large_buttons) {
int dp36 = Helper.dp2pixels(context, 42);
List<Integer> ids = new ArrayList<>();
ids.addAll(Helper.fromIntArray(ibFlow.getReferencedIds()));
ids.addAll(Arrays.asList(R.id.ibTools, R.id.vwEmpty,
R.id.ibFull, R.id.ibImages, R.id.ibAmp,
R.id.ibDecrypt, R.id.ibVerify,
R.id.ibInfrastructure,
R.id.ibTrashBottom, R.id.ibArchiveBottom, R.id.ibMoveBottom,
R.id.ibSeenBottom));
for (int id : ids) {
View v = view.findViewById(id);
ViewGroup.LayoutParams lparam = v.getLayoutParams();
lparam.width = dp36;
lparam.height = dp36;
}
}
unwire();
wire();
}
@ -7131,7 +7129,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
AdapterMessage(Fragment parentFragment,
String type, boolean found, String searched, ViewType viewType,
boolean compact, int zoom, String sort, boolean ascending,
boolean compact, int zoom, boolean large_buttons, String sort, boolean ascending,
boolean filter_duplicates, boolean filter_trash,
final IProperties properties) {
this.parentFragment = parentFragment;
@ -7141,6 +7139,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.viewType = viewType;
this.compact = compact;
this.zoom = zoom;
this.large_buttons = large_buttons;
this.sort = sort;
this.ascending = ascending;
this.filter_duplicates = filter_duplicates;
@ -7244,7 +7243,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.preview = prefs.getBoolean("preview", false);
this.preview_italic = prefs.getBoolean("preview_italic", true);
this.preview_lines = prefs.getInt("preview_lines", 1);
this.large_buttons = prefs.getBoolean("large_buttons", false);
this.message_zoom = prefs.getInt("message_zoom", 100);
this.attachments_alt = prefs.getBoolean("attachments_alt", false);
this.thumbnails = prefs.getBoolean("thumbnails", true);
@ -7886,6 +7884,15 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
properties.refresh();
}
void setLargeButtons(boolean large_buttons) {
this.large_buttons = large_buttons;
if (rv != null) {
rv.getRecycledViewPool().clear();
rv.getLayoutManager().removeAllViews();
}
properties.refresh();
}
void setSort(String sort) {
if (!sort.equals(this.sort)) {
this.sort = sort;

View File

@ -1034,6 +1034,7 @@ public class FragmentMessages extends FragmentBase
boolean compact = prefs.getBoolean("compact", false);
int zoom = prefs.getInt("view_zoom", compact ? 0 : 1);
boolean large_buttons = prefs.getBoolean("large_buttons", false);
boolean outbox = EntityFolder.OUTBOX.equals(type);
boolean ascending = prefs.getBoolean(getSortOrder(getContext(), viewType, type), outbox);
boolean filter_duplicates = prefs.getBoolean("filter_duplicates", true);
@ -1044,7 +1045,7 @@ public class FragmentMessages extends FragmentBase
adapter = new AdapterMessage(
this, type, found, searched, viewType,
compact, zoom, sort, ascending,
compact, zoom, large_buttons, sort, ascending,
filter_duplicates, filter_trash,
iProperties);
if (viewType == AdapterMessage.ViewType.THREAD)
@ -5097,6 +5098,7 @@ public class FragmentMessages extends FragmentBase
boolean language_detection = prefs.getBoolean("language_detection", false);
String filter_language = prefs.getString("filter_language", null);
boolean perform_expunge = prefs.getBoolean("perform_expunge", true);
boolean large_buttons = prefs.getBoolean("large_buttons", false);
boolean compact = prefs.getBoolean("compact", false);
boolean confirm_links = prefs.getBoolean("confirm_links", true);
int zoom = prefs.getInt("view_zoom", compact ? 0 : 1);
@ -5204,14 +5206,17 @@ public class FragmentMessages extends FragmentBase
for (int i = 0; i <= padding; i++)
ssbPadding.append('+');
menu.findItem(R.id.menu_compact).setChecked(compact);
menu.findItem(R.id.menu_zoom).setTitle(ssbZoom);
PopupMenuLifecycle.insertIcon(context, menu.findItem(R.id.menu_zoom), false);
menu.findItem(R.id.menu_padding).setTitle(ssbPadding);
PopupMenuLifecycle.insertIcon(context, menu.findItem(R.id.menu_padding), false);
menu.findItem(R.id.menu_large_buttons)
.setChecked(large_buttons)
.setVisible(viewType == AdapterMessage.ViewType.THREAD);
menu.findItem(R.id.menu_compact).setChecked(compact);
menu.findItem(R.id.menu_theme).setVisible(viewType == AdapterMessage.ViewType.UNIFIED);
menu.findItem(R.id.menu_confirm_links)
@ -5353,6 +5358,9 @@ public class FragmentMessages extends FragmentBase
} else if (itemId == R.id.menu_padding) {
onMenuPadding();
return true;
} else if (itemId == R.id.menu_large_buttons) {
onMenuLargeButtons();
return true;
} else if (itemId == R.id.menu_compact) {
onMenuCompact();
return true;
@ -5652,6 +5660,13 @@ public class FragmentMessages extends FragmentBase
invalidateOptionsMenu();
}
private void onMenuLargeButtons() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean large_buttons = !prefs.getBoolean("large_buttons", false);
prefs.edit().putBoolean("large_buttons", large_buttons).apply();
adapter.setLargeButtons(large_buttons);
}
private void onMenuCompact() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean compact = !prefs.getBoolean("compact", false);

View File

@ -152,7 +152,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private TextView tvPreviewLinesHint;
private SwitchCompat swAddresses;
private SwitchCompat swLargeButtons;
private TextView tvMessageZoom;
private SeekBar sbMessageZoom;
private SwitchCompat swOverviewMode;
@ -204,7 +203,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"subject_top", "subject_italic", "highlight_subject", "font_size_subject", "subject_ellipsize",
"keywords_header", "labels_header", "flags", "flags_background",
"preview", "preview_italic", "preview_lines",
"addresses", "large_buttons",
"addresses",
"message_zoom", "overview_mode", "override_width",
"hyphenation", "display_font", "contrast", "monospaced_pre",
"text_separators",
@ -312,7 +311,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
spPreviewLines = view.findViewById(R.id.spPreviewLines);
tvPreviewLinesHint = view.findViewById(R.id.tvPreviewLinesHint);
swAddresses = view.findViewById(R.id.swAddresses);
swLargeButtons = view.findViewById(R.id.swLargeButtons);
tvMessageZoom = view.findViewById(R.id.tvMessageZoom);
sbMessageZoom = view.findViewById(R.id.sbMessageZoom);
swOverviewMode = view.findViewById(R.id.swOverviewMode);
@ -1070,13 +1068,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
swLargeButtons.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("large_buttons", checked).apply();
}
});
sbMessageZoom.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
@ -1488,7 +1479,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
spPreviewLines.setEnabled(swPreview.isChecked());
swAddresses.setChecked(prefs.getBoolean("addresses", false));
swLargeButtons.setChecked(prefs.getBoolean("large_buttons", false));
int message_zoom = prefs.getInt("message_zoom", 100);
tvMessageZoom.setText(getString(R.string.title_advanced_message_text_zoom2, NF.format(message_zoom)));

View File

@ -2879,6 +2879,20 @@ public class Helper {
return result;
}
static int[] toIntArray(List<Integer> list) {
int[] result = new int[list.size()];
for (int i = 0; i < list.size(); i++)
result[i] = list.get(i);
return result;
}
static List<Integer> fromIntArray(int[] array) {
List<Integer> result = new ArrayList<>();
for (int i = 0; i < array.length; i++)
result.add(array[i]);
return result;
}
static long[] toLongArray(List<Long> list) {
long[] result = new long[list.size()];
for (int i = 0; i < list.size(); i++)

View File

@ -1576,17 +1576,6 @@
app:layout_constraintTop_toBottomOf="@id/tvCaptionBody"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swLargeButtons"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_large_buttons"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAddresses"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvMessageZoom"
android:layout_width="0dp"
@ -1597,7 +1586,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swLargeButtons" />
app:layout_constraintTop_toBottomOf="@id/swAddresses" />
<SeekBar
android:id="@+id/sbMessageZoom"

View File

@ -147,6 +147,13 @@
android:title="@string/title_padding"
app:showAsAction="never" />
<item
android:id="@+id/menu_large_buttons"
android:checkable="true"
android:icon="@drawable/twotone_smart_button_24"
android:title="@string/title_large_buttons"
app:showAsAction="never" />
<item
android:id="@+id/menu_compact"
android:checkable="true"

View File

@ -558,7 +558,6 @@
<string name="title_advanced_preview_italic">Show message preview in italics</string>
<string name="title_advanced_preview_lines">Number of preview lines</string>
<string name="title_advanced_addresses">Expand address details by default</string>
<string name="title_advanced_large_buttons">Use larger buttons for message actions</string>
<string name="title_advanced_unzip">Show contents of compressed attachments</string>
<string name="title_advanced_attachments_alt">Show attachments after the message text</string>
<string name="title_advanced_thumbnails">Show image thumbnails after the message text</string>
@ -1630,6 +1629,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_large_buttons">Larger buttons</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>

View File

@ -7,7 +7,7 @@ Ledumahadi
1.1955 - 2022-08-18
* Added batch enable showing child folders in the navigation menu
* Added display option for large message action buttons
* Added menu item for larger message action buttons
* Small improvements and minor bug fixes
* Updated libraries
* Updated translations