From 60a381430e99a3c462b67bbf332fce1e5c89afbe Mon Sep 17 00:00:00 2001
From: str4d <str4d@mail.i2p>
Date: Sat, 16 Jul 2016 02:56:34 +0000
Subject: [PATCH] Use full-screen overlay with microcopy instead of dialog to
 request report

---
 briar-android/AndroidManifest.xml             |   3 +-
 .../res/layout/activity_dev_report.xml        | 269 +++++++++++-------
 briar-android/res/values/strings.xml          |   7 +-
 .../android/report/DevReportActivity.java     |  60 ++--
 4 files changed, 208 insertions(+), 131 deletions(-)

diff --git a/briar-android/AndroidManifest.xml b/briar-android/AndroidManifest.xml
index 7c7be67ccf..0c7292f510 100644
--- a/briar-android/AndroidManifest.xml
+++ b/briar-android/AndroidManifest.xml
@@ -52,7 +52,8 @@
 			android:label="@string/crash_report_title"
 			android:launchMode="singleInstance"
 			android:process=":briar_error_handler"
-			android:theme="@style/BriarThemeNoActionBar.Default">
+			android:theme="@style/BriarThemeNoActionBar.Default"
+			android:windowSoftInputMode="stateHidden">
 		</activity>
 
 		<activity
diff --git a/briar-android/res/layout/activity_dev_report.xml b/briar-android/res/layout/activity_dev_report.xml
index 8d1c8ac39e..7f0a304d61 100644
--- a/briar-android/res/layout/activity_dev_report.xml
+++ b/briar-android/res/layout/activity_dev_report.xml
@@ -1,122 +1,201 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
+<FrameLayout
 	xmlns:android="http://schemas.android.com/apk/res/android"
 	xmlns:tools="http://schemas.android.com/tools"
 	android:layout_width="match_parent"
-	android:layout_height="match_parent"
-	android:orientation="vertical"
-	tools:context=".android.report.DevReportActivity">
+	android:layout_height="match_parent">
 
-	<android.support.v7.widget.Toolbar
-		android:id="@+id/toolbar"
-		style="@style/BriarToolbar"
+	<LinearLayout
 		android:layout_width="match_parent"
-		android:layout_height="wrap_content"/>
+		android:layout_height="match_parent"
+		android:orientation="vertical"
+		tools:context=".android.report.DevReportActivity">
 
-	<RelativeLayout
-		android:layout_width="match_parent"
-		android:layout_height="match_parent">
-
-		<LinearLayout
+		<android.support.v7.widget.Toolbar
+			android:id="@+id/toolbar"
+			style="@style/BriarToolbar"
 			android:layout_width="match_parent"
-			android:layout_height="wrap_content"
-			android:orientation="vertical"
-			android:paddingTop="@dimen/margin_medium">
+			android:layout_height="wrap_content"/>
 
-			<EditText
-				android:id="@+id/user_comment"
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:layout_marginEnd="@dimen/margin_large"
-				android:layout_marginLeft="@dimen/margin_large"
-				android:layout_marginRight="@dimen/margin_large"
-				android:layout_marginStart="@dimen/margin_large"
-				android:inputType="textMultiLine|textCapSentences"
-				tools:hint="@string/describe_crash"/>
-
-			<EditText
-				android:id="@+id/user_email"
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:layout_marginEnd="@dimen/margin_large"
-				android:layout_marginLeft="@dimen/margin_large"
-				android:layout_marginRight="@dimen/margin_large"
-				android:layout_marginStart="@dimen/margin_large"
-				android:layout_marginTop="@dimen/margin_small"
-				android:hint="@string/optional_contact_email"
-				android:inputType="textEmailAddress"
-				android:maxLines="1"/>
+		<RelativeLayout
+			android:layout_width="match_parent"
+			android:layout_height="match_parent">
 
 			<LinearLayout
 				android:layout_width="match_parent"
 				android:layout_height="wrap_content"
-				android:layout_marginEnd="@dimen/margin_large"
-				android:layout_marginLeft="@dimen/margin_large"
-				android:layout_marginRight="@dimen/margin_large"
-				android:layout_marginStart="@dimen/margin_large"
-				android:layout_marginTop="@dimen/margin_small"
-				android:gravity="center_vertical"
-				android:orientation="horizontal">
-
-				<TextView
-					android:id="@+id/debug_report"
-					android:layout_width="0dp"
+				android:orientation="vertical"
+				android:paddingTop="@dimen/margin_medium">
+
+				<EditText
+					android:id="@+id/user_comment"
+					android:layout_width="match_parent"
 					android:layout_height="wrap_content"
-					android:layout_weight="1"
-					android:text="@string/debug_report"
-					android:textColor="@color/briar_text_primary"/>
+					android:layout_marginEnd="@dimen/margin_large"
+					android:layout_marginLeft="@dimen/margin_large"
+					android:layout_marginRight="@dimen/margin_large"
+					android:layout_marginStart="@dimen/margin_large"
+					android:inputType="textMultiLine|textCapSentences"
+					tools:hint="@string/describe_crash"/>
 
-				<CheckBox
-					android:id="@+id/include_debug_report"
-					android:layout_width="0dp"
+				<EditText
+					android:id="@+id/user_email"
+					android:layout_width="match_parent"
 					android:layout_height="wrap_content"
-					android:layout_weight="1"
-					android:checked="false"
-					android:text="@string/include_debug_report"
-					android:visibility="gone"/>
-
-				<ImageView
-					android:id="@+id/chevron"
-					android:layout_width="wrap_content"
+					android:layout_marginEnd="@dimen/margin_large"
+					android:layout_marginLeft="@dimen/margin_large"
+					android:layout_marginRight="@dimen/margin_large"
+					android:layout_marginStart="@dimen/margin_large"
+					android:layout_marginTop="@dimen/margin_small"
+					android:hint="@string/optional_contact_email"
+					android:inputType="textEmailAddress"
+					android:maxLines="1"/>
+
+				<LinearLayout
+					android:layout_width="match_parent"
 					android:layout_height="wrap_content"
+					android:layout_marginEnd="@dimen/margin_large"
 					android:layout_marginLeft="@dimen/margin_large"
+					android:layout_marginRight="@dimen/margin_large"
 					android:layout_marginStart="@dimen/margin_large"
-					android:clickable="true"
-					android:src="@drawable/selector_chevron"
-					android:tint="@color/briar_button_positive"/>
+					android:layout_marginTop="@dimen/margin_small"
+					android:gravity="center_vertical"
+					android:orientation="horizontal">
 
-			</LinearLayout>
+					<TextView
+						android:id="@+id/debug_report"
+						android:layout_width="0dp"
+						android:layout_height="wrap_content"
+						android:layout_weight="1"
+						android:text="@string/debug_report"
+						android:textColor="@color/briar_text_primary"/>
 
-			<ScrollView
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:layout_marginTop="@dimen/margin_small">
+					<CheckBox
+						android:id="@+id/include_debug_report"
+						android:layout_width="0dp"
+						android:layout_height="wrap_content"
+						android:layout_weight="1"
+						android:checked="false"
+						android:text="@string/include_debug_report"
+						android:visibility="gone"/>
 
-				<LinearLayout
-					android:id="@+id/report_content"
+					<ImageView
+						android:id="@+id/chevron"
+						android:layout_width="wrap_content"
+						android:layout_height="wrap_content"
+						android:layout_marginLeft="@dimen/margin_large"
+						android:layout_marginStart="@dimen/margin_large"
+						android:clickable="true"
+						android:src="@drawable/selector_chevron"
+						android:tint="@color/briar_button_positive"/>
+
+				</LinearLayout>
+
+				<ScrollView
 					android:layout_width="match_parent"
 					android:layout_height="wrap_content"
-					android:gravity="center_horizontal"
-					android:orientation="vertical"
-					android:paddingBottom="@dimen/listitem_height_one_line_avatar"
-					android:paddingEnd="@dimen/margin_large"
-					android:paddingLeft="@dimen/margin_large"
-					android:paddingRight="@dimen/margin_large"
-					android:paddingStart="@dimen/margin_large"
-					android:paddingTop="@dimen/margin_small"
-					android:visibility="gone"/>
-
-			</ScrollView>
-		</LinearLayout>
+					android:layout_marginTop="@dimen/margin_small">
+
+					<LinearLayout
+						android:id="@+id/report_content"
+						android:layout_width="match_parent"
+						android:layout_height="wrap_content"
+						android:gravity="center_horizontal"
+						android:orientation="vertical"
+						android:paddingBottom="@dimen/listitem_height_one_line_avatar"
+						android:paddingEnd="@dimen/margin_large"
+						android:paddingLeft="@dimen/margin_large"
+						android:paddingRight="@dimen/margin_large"
+						android:paddingStart="@dimen/margin_large"
+						android:paddingTop="@dimen/margin_small"
+						android:visibility="gone"/>
 
-		<ProgressBar
-			android:id="@+id/progress_wheel"
-			style="?android:attr/progressBarStyleLarge"
-			android:layout_width="wrap_content"
+				</ScrollView>
+			</LinearLayout>
+
+			<ProgressBar
+				android:id="@+id/progress_wheel"
+				style="?android:attr/progressBarStyleLarge"
+				android:layout_width="wrap_content"
+				android:layout_height="wrap_content"
+				android:layout_centerInParent="true"
+				android:indeterminate="true"
+				android:visibility="gone"/>
+
+		</RelativeLayout>
+	</LinearLayout>
+
+	<LinearLayout
+		android:id="@+id/request_report"
+		android:layout_width="match_parent"
+		android:layout_height="match_parent"
+		android:background="@android:color/background_light"
+		android:clickable="true"
+		android:gravity="center"
+		android:orientation="vertical"
+		android:padding="@dimen/margin_large"
+		android:visibility="gone">
+
+		<TextView
+			android:layout_width="match_parent"
 			android:layout_height="wrap_content"
-			android:layout_centerInParent="true"
-			android:indeterminate="true"
-			android:visibility="gone"/>
+			android:gravity="center"
+			android:text="@string/sad_face"
+			android:textColor="@color/briar_text_primary"
+			android:textSize="@dimen/text_size_xlarge"/>
 
-	</RelativeLayout>
-</LinearLayout>
\ No newline at end of file
+		<TextView
+			android:layout_width="match_parent"
+			android:layout_height="wrap_content"
+			android:layout_marginTop="@dimen/margin_large"
+			android:gravity="center"
+			android:text="@string/briar_crashed"
+			android:textColor="@color/briar_text_primary"
+			android:textSize="@dimen/text_size_large"/>
+
+		<TextView
+			android:layout_width="match_parent"
+			android:layout_height="wrap_content"
+			android:layout_marginTop="@dimen/margin_large"
+			android:gravity="center"
+			android:text="@string/not_your_fault"
+			android:textColor="@color/briar_text_secondary"/>
+
+		<TextView
+			android:layout_width="match_parent"
+			android:layout_height="wrap_content"
+			android:layout_marginTop="@dimen/margin_large"
+			android:gravity="center"
+			android:text="@string/please_send_report"
+			android:textColor="@color/briar_text_secondary"/>
+
+		<TextView
+			android:layout_width="match_parent"
+			android:layout_height="wrap_content"
+			android:layout_marginTop="@dimen/margin_large"
+			android:gravity="center"
+			android:text="@string/report_is_encrypted"
+			android:textColor="@color/briar_text_secondary"/>
+
+		<LinearLayout
+			android:layout_width="match_parent"
+			android:layout_height="wrap_content"
+			android:layout_marginTop="@dimen/margin_large"
+			android:gravity="center_horizontal">
+
+			<Button
+				android:id="@+id/declineButton"
+				style="@style/BriarButton.Default"
+				android:layout_width="wrap_content"
+				android:layout_height="wrap_content"
+				android:text="@string/dialog_button_decline"/>
+
+			<Button
+				android:id="@+id/acceptButton"
+				style="@style/BriarButton.Default"
+				android:layout_width="wrap_content"
+				android:layout_height="wrap_content"
+				android:text="@string/dialog_button_accept"/>
+		</LinearLayout>
+	</LinearLayout>
+</FrameLayout>
\ No newline at end of file
diff --git a/briar-android/res/values/strings.xml b/briar-android/res/values/strings.xml
index 8de4763514..c28639ac07 100644
--- a/briar-android/res/values/strings.xml
+++ b/briar-android/res/values/strings.xml
@@ -4,6 +4,11 @@
 	<string name="nav_drawer_close_description">Close the navigation drawer</string>
 	<string name="app_name">Briar</string>
 	<string name="crash_report_title">Briar Crash Report</string>
+	<string name="sad_face" translatable="false">:-(</string>
+	<string name="briar_crashed">Sorry, Briar has crashed.</string>
+	<string name="not_your_fault">This is not your fault.</string>
+	<string name="please_send_report">Please help us build a better Briar by sending us a crash report.</string>
+	<string name="report_is_encrypted">We promise that the report is encrypted and sent securely.</string>
 	<string name="feedback_title">Feedback</string>
 	<string name="describe_crash">Describe what happened</string>
 	<string name="enter_feedback">Enter your feedback</string>
@@ -243,8 +248,6 @@
 	<string name="dialog_message_connect_panic_app">Are you sure that you want to allow %1$s to trigger destructive panic button actions?</string>
 	<string name="dialog_title_welcome">Welcome to Briar</string>
 	<string name="dialog_welcome_message">Add a contact to start communicating securely or press the icon in the upper left corner of the screen for more options.</string>
-	<string name="dialog_title_share_crash_report">Briar has crashed</string>
-	<string name="dialog_message_share_crash_report">Would you like to review the crash report and send it to the developers? It will be stored encrypted on your device until the next time you log into Briar, and then sent securely to the developers.</string>
 	<string name="dialog_title_leave_forum">Confirm Leaving Forum</string>
 	<string name="dialog_message_leave_forum">Are you sure that you want to leave this forum? Contacts you have shared this forum with might get cut off from receiving updates for this forum.</string>
 	<string name="dialog_button_ok">OK</string>
diff --git a/briar-android/src/org/briarproject/android/report/DevReportActivity.java b/briar-android/src/org/briarproject/android/report/DevReportActivity.java
index 01eea151a2..b938cdadff 100644
--- a/briar-android/src/org/briarproject/android/report/DevReportActivity.java
+++ b/briar-android/src/org/briarproject/android/report/DevReportActivity.java
@@ -1,12 +1,11 @@
 package org.briarproject.android.report;
 
-import android.content.DialogInterface;
+import android.content.Context;
 import android.content.SharedPreferences;
 import android.content.res.Configuration;
 import android.os.AsyncTask;
 import android.os.Build;
 import android.os.Bundle;
-import android.support.v7.app.AlertDialog;
 import android.support.v7.app.AppCompatDelegate;
 import android.support.v7.widget.Toolbar;
 import android.view.LayoutInflater;
@@ -14,6 +13,7 @@ import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
+import android.view.inputmethod.InputMethodManager;
 import android.widget.CheckBox;
 import android.widget.CompoundButton;
 import android.widget.EditText;
@@ -37,7 +37,6 @@ import java.util.Map.Entry;
 import java.util.Set;
 import java.util.logging.Logger;
 
-import static android.content.DialogInterface.BUTTON_POSITIVE;
 import static android.view.View.GONE;
 import static android.view.View.INVISIBLE;
 import static android.view.View.VISIBLE;
@@ -51,9 +50,7 @@ import static org.acra.ReportField.REPORT_ID;
 import static org.acra.ReportField.STACK_TRACE;
 
 public class DevReportActivity extends BaseCrashReportDialog
-		implements DialogInterface.OnClickListener,
-		DialogInterface.OnCancelListener,
-		CompoundButton.OnCheckedChangeListener {
+		implements CompoundButton.OnCheckedChangeListener {
 
 	private static final Logger LOG =
 			Logger.getLogger(DevReportActivity.class.getName());
@@ -113,6 +110,7 @@ public class DevReportActivity extends BaseCrashReportDialog
 		Toolbar tb = (Toolbar) findViewById(R.id.toolbar);
 		getDelegate().setSupportActionBar(tb);
 
+		final View requestReport = findViewById(R.id.request_report);
 		userCommentView = (EditText) findViewById(R.id.user_comment);
 		userEmailView = (EditText) findViewById(R.id.user_email);
 		TextView debugReport = (TextView) findViewById(R.id.debug_report);
@@ -131,6 +129,25 @@ public class DevReportActivity extends BaseCrashReportDialog
 		debugReport.setVisibility(isFeedback() ? GONE : VISIBLE);
 		includeDebugReport.setVisibility(isFeedback() ? VISIBLE : GONE);
 
+		findViewById(R.id.acceptButton).setOnClickListener(
+				new View.OnClickListener() {
+					@Override
+					public void onClick(View v) {
+						reviewing = true;
+						requestReport.setVisibility(GONE);
+						((InputMethodManager) getSystemService(
+								Context.INPUT_METHOD_SERVICE))
+								.showSoftInput(userCommentView,
+										InputMethodManager.SHOW_FORCED);
+					}
+				});
+		findViewById(R.id.declineButton).setOnClickListener(
+				new View.OnClickListener() {
+					@Override
+					public void onClick(View v) {
+						closeReport();
+					}
+				});
 		chevron.setOnClickListener(new View.OnClickListener() {
 			@Override
 			public void onClick(View v) {
@@ -146,7 +163,10 @@ public class DevReportActivity extends BaseCrashReportDialog
 		userEmailView.setText(userEmail);
 
 		if (state != null)
-			reviewing = state.getBoolean(STATE_REVIEWING, false);
+			reviewing = state.getBoolean(STATE_REVIEWING, isFeedback());
+
+		if (!isFeedback() && !reviewing)
+			requestReport.setVisibility(VISIBLE);
 	}
 
 	@Override
@@ -158,7 +178,6 @@ public class DevReportActivity extends BaseCrashReportDialog
 	@Override
 	public void onResume() {
 		super.onResume();
-		if (!isFeedback() && !reviewing) showCrashDialog();
 		if (chevron.isSelected()) refresh();
 	}
 
@@ -228,17 +247,6 @@ public class DevReportActivity extends BaseCrashReportDialog
 		closeReport();
 	}
 
-	@Override
-	public void onClick(DialogInterface dialog, int which) {
-		if (which == BUTTON_POSITIVE) dialog.dismiss();
-		else dialog.cancel();
-	}
-
-	@Override
-	public void onCancel(DialogInterface dialog) {
-		closeReport();
-	}
-
 	@Override
 	public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
 		ReportField field = (ReportField) buttonView.getTag();
@@ -253,20 +261,6 @@ public class DevReportActivity extends BaseCrashReportDialog
 		return getException() instanceof UserFeedback;
 	}
 
-	private void showCrashDialog() {
-		AlertDialog.Builder builder = new AlertDialog.Builder(this,
-				R.style.BriarDialogTheme);
-		builder.setTitle(R.string.dialog_title_share_crash_report)
-				.setIcon(R.drawable.ic_warning_black_24dp)
-				.setMessage(R.string.dialog_message_share_crash_report)
-				.setPositiveButton(R.string.dialog_button_ok, this)
-				.setNegativeButton(R.string.cancel_button, this);
-		AlertDialog dialog = builder.create();
-		dialog.setCanceledOnTouchOutside(false);
-		dialog.setOnCancelListener(this);
-		dialog.show();
-	}
-
 	private void refresh() {
 		report.setVisibility(INVISIBLE);
 		progress.setVisibility(VISIBLE);
-- 
GitLab