diff --git a/app/src/main/java/eu/faircode/email/FixedImageButton.java b/app/src/main/java/eu/faircode/email/FixedImageButton.java index 55a4fe6801..90b6df0ecd 100644 --- a/app/src/main/java/eu/faircode/email/FixedImageButton.java +++ b/app/src/main/java/eu/faircode/email/FixedImageButton.java @@ -46,7 +46,7 @@ public class FixedImageButton extends AppCompatImageButton { try { super.onDraw(canvas); } catch (RuntimeException ex) { - Log.e(ex); + Log.e(new Throwable(Helper.getViewName(this), ex)); Context context = getContext(); Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24); d.setBounds(getDrawable().getBounds()); diff --git a/app/src/main/java/eu/faircode/email/FixedImageView.java b/app/src/main/java/eu/faircode/email/FixedImageView.java index cce57eea9d..d3bb81a08a 100644 --- a/app/src/main/java/eu/faircode/email/FixedImageView.java +++ b/app/src/main/java/eu/faircode/email/FixedImageView.java @@ -23,6 +23,7 @@ import android.content.Context; import android.graphics.Canvas; import android.graphics.drawable.Drawable; import android.util.AttributeSet; +import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -46,7 +47,7 @@ public class FixedImageView extends androidx.appcompat.widget.AppCompatImageView try { super.onDraw(canvas); } catch (RuntimeException ex) { - Log.e(ex); + Log.e(new Throwable(Helper.getViewName(this), ex)); Context context = getContext(); Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24); d.setBounds(getDrawable().getBounds()); diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 031db21c5e..08116222ca 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -68,6 +68,7 @@ import android.view.Menu; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.ViewParent; import android.view.ViewTreeObserver; import android.view.WindowManager; import android.view.accessibility.AccessibilityManager; @@ -1293,6 +1294,30 @@ public class Helper { imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } + static String getViewName(View view) { + StringBuilder sb = new StringBuilder(_getViewName(view)); + ViewParent parent = view.getParent(); + while (parent != null) { + if (parent instanceof View) + sb.insert(0, '/').insert(0, _getViewName((View) parent)); + parent = parent.getParent(); + } + return sb.toString(); + } + + private static String _getViewName(View view) { + if (view == null) + return ""; + int id = view.getId(); + if (id == View.NO_ID) + return ""; + try { + return view.getContext().getResources().getResourceEntryName(id); + } catch (Throwable ex) { + return ex.toString(); + } + } + // Formatting private static final DecimalFormat df = new DecimalFormat("@@");