From 49d01e0ca3e77de396417603b735c3ccd6c16847 Mon Sep 17 00:00:00 2001 From: Peter Serwylo <peter@serwylo.com> Date: Sat, 2 Jan 2016 13:23:24 +1100 Subject: [PATCH 1/2] Use custom layout for ACRA report dialog, not default one. Styling the default dialog was difficult and it doesn't obey some of the guidelines provided by the Android design docs: https://www.google.com/design/spec/components/dialogs.html#dialogs-specs (see "Content Guidelines") This change introduces a custom dialog extending the base ACRA reporting activity. Specifically, it introduces a padding of 24dp around the dialog contents. --- F-Droid/AndroidManifest.xml | 3 +- F-Droid/res/layout/crash_report_dialog.xml | 36 +++++++++++++++ .../fdroid/fdroid/CrashReportActivity.java | 45 +++++++++++++++++++ F-Droid/src/org/fdroid/fdroid/FDroidApp.java | 4 +- 4 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 F-Droid/res/layout/crash_report_dialog.xml create mode 100644 F-Droid/src/org/fdroid/fdroid/CrashReportActivity.java diff --git a/F-Droid/AndroidManifest.xml b/F-Droid/AndroidManifest.xml index 76f6e7659..7e4efbac5 100644 --- a/F-Droid/AndroidManifest.xml +++ b/F-Droid/AndroidManifest.xml @@ -376,7 +376,8 @@ android:name="android.support.PARENT_ACTIVITY" android:value=".FDroid" /> </activity> - <activity android:name="org.acra.CrashReportDialog" + <activity + android:name="org.fdroid.fdroid.CrashReportActivity" android:theme="@style/AlertDialogThemeDark" android:process=":error_report" android:launchMode="singleInstance" diff --git a/F-Droid/res/layout/crash_report_dialog.xml b/F-Droid/res/layout/crash_report_dialog.xml new file mode 100644 index 000000000..6f40c1c9a --- /dev/null +++ b/F-Droid/res/layout/crash_report_dialog.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:paddingLeft="24dp" + android:paddingRight="24dp" + android:paddingBottom="24dp" + android:paddingTop="20dp" + > + + <TextView + android:id="@android:id/text1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/crash_dialog_text" + /> + + <TextView + android:id="@android:id/text2" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="20dp" + android:text="@string/crash_dialog_comment_prompt" + /> + + <EditText + android:id="@android:id/input" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:inputType="textMultiLine" + android:layout_marginTop="20dp" + /> + +</LinearLayout> \ No newline at end of file diff --git a/F-Droid/src/org/fdroid/fdroid/CrashReportActivity.java b/F-Droid/src/org/fdroid/fdroid/CrashReportActivity.java new file mode 100644 index 000000000..983383101 --- /dev/null +++ b/F-Droid/src/org/fdroid/fdroid/CrashReportActivity.java @@ -0,0 +1,45 @@ +package org.fdroid.fdroid; + +import android.content.DialogInterface; +import android.os.Bundle; +import android.support.v7.app.AlertDialog; +import android.widget.EditText; + +import org.acra.BaseCrashReportDialog; + +public class CrashReportActivity extends BaseCrashReportDialog implements DialogInterface.OnDismissListener, DialogInterface.OnClickListener { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + final AlertDialog dialog = new AlertDialog.Builder(this) + .setTitle(R.string.crash_dialog_title) + .setIcon(android.R.drawable.ic_dialog_alert) + .setView(R.layout.crash_report_dialog) + .setPositiveButton(R.string.ok, this) + .setNegativeButton(R.string.cancel, this) + .create(); + + dialog.setCanceledOnTouchOutside(false); + dialog.setOnDismissListener(this); + dialog.show(); + } + + @Override + public void onDismiss(DialogInterface dialog) { + finish(); + } + + @Override + public void onClick(DialogInterface dialog, int which) { + if (which == DialogInterface.BUTTON_POSITIVE) { + final String comment = ((EditText) findViewById(android.R.id.input)).getText().toString(); + sendCrash(comment, ""); + } else { + cancelReports(); + } + finish(); + } + +} \ No newline at end of file diff --git a/F-Droid/src/org/fdroid/fdroid/FDroidApp.java b/F-Droid/src/org/fdroid/fdroid/FDroidApp.java index 5e6b856ef..abbd702b4 100644 --- a/F-Droid/src/org/fdroid/fdroid/FDroidApp.java +++ b/F-Droid/src/org/fdroid/fdroid/FDroidApp.java @@ -67,9 +67,7 @@ import sun.net.www.protocol.bluetooth.Handler; @ReportsCrashes(mailTo = "reports@f-droid.org", mode = ReportingInteractionMode.DIALOG, - resDialogTitle = R.string.crash_dialog_title, - resDialogText = R.string.crash_dialog_text, - resDialogCommentPrompt = R.string.crash_dialog_comment_prompt + reportDialogClass = CrashReportActivity.class ) public class FDroidApp extends Application { From a99767f3a68f5ce4ca6b7690d857ce97cb408d3a Mon Sep 17 00:00:00 2001 From: Peter Serwylo <peter@serwylo.com> Date: Sun, 3 Jan 2016 15:48:44 +1100 Subject: [PATCH 2/2] Remove icon, add scroll view to crash report dialog. Scroll view helps with smaller screens. Alert dialog icons are not part of the material design spec so that was removed. --- F-Droid/res/layout/crash_report_dialog.xml | 57 +++++++++++-------- .../fdroid/fdroid/CrashReportActivity.java | 1 - 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/F-Droid/res/layout/crash_report_dialog.xml b/F-Droid/res/layout/crash_report_dialog.xml index 6f40c1c9a..6f0ebddb3 100644 --- a/F-Droid/res/layout/crash_report_dialog.xml +++ b/F-Droid/res/layout/crash_report_dialog.xml @@ -1,36 +1,43 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingLeft="24dp" - android:paddingRight="24dp" - android:paddingBottom="24dp" - android:paddingTop="20dp" > - <TextView - android:id="@android:id/text1" + <LinearLayout + android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/crash_dialog_text" - /> + android:paddingLeft="24dp" + android:paddingRight="24dp" + android:paddingBottom="24dp" + android:paddingTop="20dp" + > - <TextView - android:id="@android:id/text2" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="20dp" - android:text="@string/crash_dialog_comment_prompt" - /> + <TextView + android:id="@android:id/text1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/crash_dialog_text" + /> - <EditText - android:id="@android:id/input" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:inputType="textMultiLine" - android:layout_marginTop="20dp" - /> + <TextView + android:id="@android:id/text2" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="20dp" + android:text="@string/crash_dialog_comment_prompt" + /> -</LinearLayout> \ No newline at end of file + <EditText + android:id="@android:id/input" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:inputType="textMultiLine" + android:layout_marginTop="20dp" + /> + + </LinearLayout> + +</ScrollView> \ No newline at end of file diff --git a/F-Droid/src/org/fdroid/fdroid/CrashReportActivity.java b/F-Droid/src/org/fdroid/fdroid/CrashReportActivity.java index 983383101..91f83b2b9 100644 --- a/F-Droid/src/org/fdroid/fdroid/CrashReportActivity.java +++ b/F-Droid/src/org/fdroid/fdroid/CrashReportActivity.java @@ -15,7 +15,6 @@ public class CrashReportActivity extends BaseCrashReportDialog implements Dialog final AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(R.string.crash_dialog_title) - .setIcon(android.R.drawable.ic_dialog_alert) .setView(R.layout.crash_report_dialog) .setPositiveButton(R.string.ok, this) .setNegativeButton(R.string.cancel, this)