From 4ea8c3b11220b2c2693241ee87754ce6d04177fc Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 11 Dec 2021 15:14:56 +0100 Subject: [PATCH] Prevent crash --- .../eu/faircode/email/FixedImageButton.java | 56 +++++++++++++++ .../eu/faircode/email/FixedImageView.java | 56 +++++++++++++++ app/src/main/res/layout/action_button.xml | 2 +- .../main/res/layout/action_button_text.xml | 2 +- app/src/main/res/layout/activity_eml.xml | 2 +- app/src/main/res/layout/activity_error.xml | 4 +- app/src/main/res/layout/dialog_add_image.xml | 2 +- app/src/main/res/layout/dialog_ask_again.xml | 2 +- app/src/main/res/layout/dialog_ask_move.xml | 2 +- .../main/res/layout/dialog_certificate.xml | 2 +- .../main/res/layout/dialog_contact_group.xml | 2 +- app/src/main/res/layout/dialog_deepl.xml | 2 +- .../res/layout/dialog_error_reporting.xml | 2 +- app/src/main/res/layout/dialog_first.xml | 4 +- .../main/res/layout/dialog_folder_select.xml | 4 +- app/src/main/res/layout/dialog_junk.xml | 12 ++-- app/src/main/res/layout/dialog_markdown.xml | 2 +- .../main/res/layout/dialog_nav_options.xml | 12 ++-- app/src/main/res/layout/dialog_open_link.xml | 12 ++-- .../main/res/layout/dialog_review_account.xml | 2 +- app/src/main/res/layout/dialog_search.xml | 16 ++--- app/src/main/res/layout/dialog_send.xml | 4 +- app/src/main/res/layout/dialog_setup.xml | 4 +- .../main/res/layout/dialog_show_images.xml | 4 +- app/src/main/res/layout/fragment_about.xml | 2 +- app/src/main/res/layout/fragment_compose.xml | 24 +++---- app/src/main/res/layout/fragment_folder.xml | 2 +- app/src/main/res/layout/fragment_folders.xml | 4 +- app/src/main/res/layout/fragment_identity.xml | 2 +- .../res/layout/fragment_legend_compose.xml | 22 +++--- .../res/layout/fragment_legend_folders.xml | 28 ++++---- .../res/layout/fragment_legend_messages.xml | 72 +++++++++---------- .../fragment_legend_synchronization.xml | 36 +++++----- app/src/main/res/layout/fragment_messages.xml | 18 ++--- .../res/layout/fragment_options_display.xml | 8 +-- .../layout/fragment_options_encryption.xml | 4 +- .../main/res/layout/fragment_options_misc.xml | 50 ++++++------- .../layout/fragment_options_notifications.xml | 16 ++--- .../res/layout/fragment_options_privacy.xml | 6 +- .../layout/fragment_options_synchronize.xml | 4 +- app/src/main/res/layout/fragment_pro.xml | 4 +- app/src/main/res/layout/fragment_rule.xml | 6 +- app/src/main/res/layout/fragment_setup.xml | 14 ++-- .../res/layout/include_message_addresses.xml | 12 ++-- .../layout/include_message_attachments.xml | 4 +- .../main/res/layout/include_message_body.xml | 12 ++-- .../res/layout/include_message_calendar.xml | 2 +- .../res/layout/include_message_compact.xml | 36 +++++----- .../res/layout/include_message_headers.xml | 4 +- .../res/layout/include_message_navigation.xml | 62 ++++++++-------- .../res/layout/include_message_normal.xml | 36 +++++----- app/src/main/res/layout/include_nav.xml | 22 +++--- app/src/main/res/layout/item_account.xml | 12 ++-- app/src/main/res/layout/item_answer.xml | 8 +-- app/src/main/res/layout/item_attachment.xml | 10 +-- .../main/res/layout/item_attachment_eml.xml | 6 +- app/src/main/res/layout/item_certificate.xml | 2 +- app/src/main/res/layout/item_contact.xml | 6 +- app/src/main/res/layout/item_folder.xml | 24 +++---- .../main/res/layout/item_folder_select.xml | 4 +- .../res/layout/item_folder_unselectable.xml | 4 +- app/src/main/res/layout/item_identity.xml | 10 +-- app/src/main/res/layout/item_image.xml | 2 +- app/src/main/res/layout/item_keyword.xml | 4 +- app/src/main/res/layout/item_nav.xml | 8 +-- app/src/main/res/layout/item_operation.xml | 2 +- app/src/main/res/layout/item_order.xml | 2 +- app/src/main/res/layout/item_rule.xml | 2 +- app/src/main/res/layout/spinner_contact.xml | 2 +- 69 files changed, 472 insertions(+), 360 deletions(-) create mode 100644 app/src/main/java/eu/faircode/email/FixedImageButton.java create mode 100644 app/src/main/java/eu/faircode/email/FixedImageView.java diff --git a/app/src/main/java/eu/faircode/email/FixedImageButton.java b/app/src/main/java/eu/faircode/email/FixedImageButton.java new file mode 100644 index 0000000000..55a4fe6801 --- /dev/null +++ b/app/src/main/java/eu/faircode/email/FixedImageButton.java @@ -0,0 +1,56 @@ +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 . + + Copyright 2018-2021 by Marcel Bokhorst (M66B) +*/ + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatImageButton; + +public class FixedImageButton extends AppCompatImageButton { + public FixedImageButton(@NonNull Context context) { + super(context); + } + + public FixedImageButton(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public FixedImageButton(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + protected void onDraw(Canvas canvas) { + try { + super.onDraw(canvas); + } catch (RuntimeException ex) { + Log.e(ex); + Context context = getContext(); + Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24); + d.setBounds(getDrawable().getBounds()); + d.draw(canvas); + } + } +} diff --git a/app/src/main/java/eu/faircode/email/FixedImageView.java b/app/src/main/java/eu/faircode/email/FixedImageView.java new file mode 100644 index 0000000000..cce57eea9d --- /dev/null +++ b/app/src/main/java/eu/faircode/email/FixedImageView.java @@ -0,0 +1,56 @@ +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 . + + Copyright 2018-2021 by Marcel Bokhorst (M66B) +*/ + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +public class FixedImageView extends androidx.appcompat.widget.AppCompatImageView { + + public FixedImageView(@NonNull Context context) { + super(context); + } + + public FixedImageView(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public FixedImageView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + protected void onDraw(Canvas canvas) { + try { + super.onDraw(canvas); + } catch (RuntimeException ex) { + Log.e(ex); + Context context = getContext(); + Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24); + d.setBounds(getDrawable().getBounds()); + d.draw(canvas); + } + } +} diff --git a/app/src/main/res/layout/action_button.xml b/app/src/main/res/layout/action_button.xml index f43b763f12..ce526e0892 100644 --- a/app/src/main/res/layout/action_button.xml +++ b/app/src/main/res/layout/action_button.xml @@ -1,5 +1,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -