From 2170d291a2eb8bed579e45c43af3614510fb7039 Mon Sep 17 00:00:00 2001 From: str4d Date: Fri, 15 Jul 2016 23:36:37 +0000 Subject: [PATCH 1/5] Hide debug report by default for both crash reports and feedback --- .../res/layout/activity_dev_report.xml | 38 +++++++++++++++++-- briar-android/res/values/strings.xml | 1 + .../android/report/DevReportActivity.java | 12 ++++-- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/briar-android/res/layout/activity_dev_report.xml b/briar-android/res/layout/activity_dev_report.xml index 257025596..b8bb74b12 100644 --- a/briar-android/res/layout/activity_dev_report.xml +++ b/briar-android/res/layout/activity_dev_report.xml @@ -53,8 +53,7 @@ android:inputType="textEmailAddress" android:maxLines="1"/> - + android:gravity="center_vertical" + android:orientation="horizontal"> + + + + + + + + + android:paddingTop="@dimen/margin_small" + android:visibility="gone"/> diff --git a/briar-android/res/values/strings.xml b/briar-android/res/values/strings.xml index 5e15fa7b2..0820b287c 100644 --- a/briar-android/res/values/strings.xml +++ b/briar-android/res/values/strings.xml @@ -8,6 +8,7 @@ Describe what happened Enter your feedback Optional contact email + Debug report: Include debug report? Could not load report data. Report saved. It will be sent the next time you log into Briar. diff --git a/briar-android/src/org/briarproject/android/report/DevReportActivity.java b/briar-android/src/org/briarproject/android/report/DevReportActivity.java index 6eb535a92..3419920a8 100644 --- a/briar-android/src/org/briarproject/android/report/DevReportActivity.java +++ b/briar-android/src/org/briarproject/android/report/DevReportActivity.java @@ -71,6 +71,7 @@ public class DevReportActivity extends BaseCrashReportDialog private EditText userCommentView = null; private EditText userEmailView = null; private CheckBox includeDebugReport = null; + private View chevron = null; private LinearLayout report = null; private View progress = null; private View share = null; @@ -97,7 +98,9 @@ public class DevReportActivity extends BaseCrashReportDialog TextView title = (TextView) findViewById(R.id.title); userCommentView = (EditText) findViewById(R.id.user_comment); userEmailView = (EditText) findViewById(R.id.user_email); + TextView debugReport = (TextView) findViewById(R.id.debug_report); includeDebugReport = (CheckBox) findViewById(R.id.include_debug_report); + chevron = findViewById(R.id.chevron); report = (LinearLayout) findViewById(R.id.report_content); progress = findViewById(R.id.progress_wheel); share = findViewById(R.id.share_dev_report); @@ -107,13 +110,14 @@ public class DevReportActivity extends BaseCrashReportDialog userCommentView.setHint(isFeedback() ? R.string.enter_feedback : R.string.describe_crash); + debugReport.setVisibility(isFeedback() ? GONE : VISIBLE); includeDebugReport.setVisibility(isFeedback() ? VISIBLE : GONE); - report.setVisibility(isFeedback() ? GONE : VISIBLE); - includeDebugReport.setOnClickListener(new View.OnClickListener() { + chevron.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (includeDebugReport.isChecked()) + chevron.setSelected(!chevron.isSelected()); + if (chevron.isSelected()) refresh(); else report.setVisibility(GONE); @@ -137,7 +141,7 @@ public class DevReportActivity extends BaseCrashReportDialog public void onResume() { super.onResume(); if (!isFeedback() && !reviewing) showCrashDialog(); - if (!isFeedback() || includeDebugReport.isChecked()) refresh(); + if (chevron.isSelected()) refresh(); } @Override From 23eb5acafa1cafb56db4445977ad55433c21c041 Mon Sep 17 00:00:00 2001 From: str4d Date: Sat, 16 Jul 2016 00:35:59 +0000 Subject: [PATCH 2/5] Use AppCompatDelegate to add AppCompat support to BaseCrashReportDialog subclass This enables the toolbar to be used as an action bar, and tinting of UI elements like checkboxes. --- briar-android/AndroidManifest.xml | 3 +- .../res/layout/activity_dev_report.xml | 14 ++--- .../android/report/DevReportActivity.java | 61 +++++++++++++++++-- 3 files changed, 63 insertions(+), 15 deletions(-) diff --git a/briar-android/AndroidManifest.xml b/briar-android/AndroidManifest.xml index 702e7e697..7c7be67cc 100644 --- a/briar-android/AndroidManifest.xml +++ b/briar-android/AndroidManifest.xml @@ -51,7 +51,8 @@ android:finishOnTaskLaunch="true" android:label="@string/crash_report_title" android:launchMode="singleInstance" - android:process=":briar_error_handler"> + android:process=":briar_error_handler" + android:theme="@style/BriarThemeNoActionBar.Default"> + android:orientation="vertical" + tools:context=".android.report.DevReportActivity"> - - - + android:layout_height="wrap_content"/> excludedFields; private EditText userCommentView = null; @@ -77,11 +81,20 @@ public class DevReportActivity extends BaseCrashReportDialog private View share = null; private boolean reviewing = false; + private AppCompatDelegate getDelegate() { + if (delegate == null) { + delegate = AppCompatDelegate.create(this, null); + } + return delegate; + } + @Override public void onCreate(Bundle state) { + getDelegate().installViewFactory(); + getDelegate().onCreate(state); super.onCreate(state); - setContentView(R.layout.activity_dev_report); + getDelegate().setContentView(R.layout.activity_dev_report); sharedPreferencesFactory = new SharedPreferencesFactory( getApplicationContext(), getConfig()); @@ -95,7 +108,9 @@ public class DevReportActivity extends BaseCrashReportDialog } } - TextView title = (TextView) findViewById(R.id.title); + Toolbar tb = (Toolbar) findViewById(R.id.toolbar); + getDelegate().setSupportActionBar(tb); + userCommentView = (EditText) findViewById(R.id.user_comment); userEmailView = (EditText) findViewById(R.id.user_email); TextView debugReport = (TextView) findViewById(R.id.debug_report); @@ -105,8 +120,10 @@ public class DevReportActivity extends BaseCrashReportDialog progress = findViewById(R.id.progress_wheel); share = findViewById(R.id.share_dev_report); - title.setText(isFeedback() ? R.string.feedback_title : - R.string.crash_report_title); + //noinspection ConstantConditions + getDelegate().getSupportActionBar().setTitle( + isFeedback() ? R.string.feedback_title : + R.string.crash_report_title); userCommentView.setHint(isFeedback() ? R.string.enter_feedback : R.string.describe_crash); @@ -137,6 +154,12 @@ public class DevReportActivity extends BaseCrashReportDialog reviewing = state.getBoolean(STATE_REVIEWING, false); } + @Override + public void onPostCreate(Bundle state) { + super.onPostCreate(state); + getDelegate().onPostCreate(state); + } + @Override public void onResume() { super.onResume(); @@ -144,12 +167,42 @@ public class DevReportActivity extends BaseCrashReportDialog if (chevron.isSelected()) refresh(); } + @Override + protected void onPostResume() { + super.onPostResume(); + getDelegate().onPostResume(); + } + + @Override + public void onTitleChanged(CharSequence title, int color) { + super.onTitleChanged(title, color); + getDelegate().setTitle(title); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + getDelegate().onConfigurationChanged(newConfig); + } + @Override public void onSaveInstanceState(Bundle state) { super.onSaveInstanceState(state); state.putBoolean(STATE_REVIEWING, reviewing); } + @Override + public void onStop() { + super.onStop(); + getDelegate().onStop(); + } + + @Override + public void onDestroy() { + super.onDestroy(); + getDelegate().onDestroy(); + } + @Override public void onBackPressed() { closeReport(); From 827fd0aebbfc88039f368b611f5bda2ba09c1b84 Mon Sep 17 00:00:00 2001 From: str4d Date: Sat, 16 Jul 2016 02:01:34 +0000 Subject: [PATCH 3/5] Move send action from FAB into toolbar --- .../res/layout/activity_dev_report.xml | 14 ------- briar-android/res/menu/dev_report_actions.xml | 12 ++++++ briar-android/res/values/strings.xml | 1 + .../android/report/DevReportActivity.java | 40 ++++++++++++++----- 4 files changed, 43 insertions(+), 24 deletions(-) create mode 100644 briar-android/res/menu/dev_report_actions.xml diff --git a/briar-android/res/layout/activity_dev_report.xml b/briar-android/res/layout/activity_dev_report.xml index 37fac97b8..8d1c8ac39 100644 --- a/briar-android/res/layout/activity_dev_report.xml +++ b/briar-android/res/layout/activity_dev_report.xml @@ -118,19 +118,5 @@ android:indeterminate="true" android:visibility="gone"/> - - \ No newline at end of file diff --git a/briar-android/res/menu/dev_report_actions.xml b/briar-android/res/menu/dev_report_actions.xml new file mode 100644 index 000000000..0567cb5d6 --- /dev/null +++ b/briar-android/res/menu/dev_report_actions.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/briar-android/res/values/strings.xml b/briar-android/res/values/strings.xml index 0820b287c..8de476351 100644 --- a/briar-android/res/values/strings.xml +++ b/briar-android/res/values/strings.xml @@ -11,6 +11,7 @@ Debug report: Include debug report? Could not load report data. + Send report Report saved. It will be sent the next time you log into Briar. Signed into Briar Touch to open Briar. diff --git a/briar-android/src/org/briarproject/android/report/DevReportActivity.java b/briar-android/src/org/briarproject/android/report/DevReportActivity.java index 26dcaafae..01eea151a 100644 --- a/briar-android/src/org/briarproject/android/report/DevReportActivity.java +++ b/briar-android/src/org/briarproject/android/report/DevReportActivity.java @@ -10,8 +10,10 @@ import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatDelegate; import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; -import android.view.View.OnClickListener; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.EditText; @@ -78,7 +80,7 @@ public class DevReportActivity extends BaseCrashReportDialog private View chevron = null; private LinearLayout report = null; private View progress = null; - private View share = null; + private MenuItem sendReport = null; private boolean reviewing = false; private AppCompatDelegate getDelegate() { @@ -118,7 +120,6 @@ public class DevReportActivity extends BaseCrashReportDialog chevron = findViewById(R.id.chevron); report = (LinearLayout) findViewById(R.id.report_content); progress = findViewById(R.id.progress_wheel); - share = findViewById(R.id.share_dev_report); //noinspection ConstantConditions getDelegate().getSupportActionBar().setTitle( @@ -140,12 +141,6 @@ public class DevReportActivity extends BaseCrashReportDialog report.setVisibility(GONE); } }); - share.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - processReport(); - } - }); String userEmail = prefs.getString(ACRA.PREF_USER_EMAIL_ADDRESS, ""); userEmailView.setText(userEmail); @@ -173,6 +168,31 @@ public class DevReportActivity extends BaseCrashReportDialog getDelegate().onPostResume(); } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu items for use in the action bar + MenuInflater inflater = getDelegate().getMenuInflater(); + inflater.inflate(R.menu.dev_report_actions, menu); + sendReport = menu.findItem(R.id.action_send_report); + + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(final MenuItem item) { + // Handle presses on the action bar items + switch (item.getItemId()) { + case android.R.id.home: + onBackPressed(); + return true; + case R.id.action_send_report: + processReport(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + @Override public void onTitleChanged(CharSequence title, int color) { super.onTitleChanged(title, color); @@ -305,7 +325,7 @@ public class DevReportActivity extends BaseCrashReportDialog private void processReport() { userCommentView.setEnabled(false); userEmailView.setEnabled(false); - share.setEnabled(false); + sendReport.setEnabled(false); progress.setVisibility(VISIBLE); final boolean includeReport = !isFeedback() || includeDebugReport.isChecked(); From 60a381430e99a3c462b67bbf332fce1e5c89afbe Mon Sep 17 00:00:00 2001 From: str4d Date: Sat, 16 Jul 2016 02:56:34 +0000 Subject: [PATCH 4/5] Use full-screen overlay with microcopy instead of dialog to request report --- briar-android/AndroidManifest.xml | 3 +- .../res/layout/activity_dev_report.xml | 283 +++++++++++------- briar-android/res/values/strings.xml | 7 +- .../android/report/DevReportActivity.java | 60 ++-- 4 files changed, 215 insertions(+), 138 deletions(-) diff --git a/briar-android/AndroidManifest.xml b/briar-android/AndroidManifest.xml index 7c7be67cc..0c7292f51 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"> - + android:layout_height="match_parent"> - + android:layout_height="match_parent" + android:orientation="vertical" + tools:context=".android.report.DevReportActivity"> - - - + android:layout_height="wrap_content"/> - - - + + android:orientation="vertical" + android:paddingTop="@dimen/margin_medium"> - - - - - - - - - - - + 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"/> - - + - + + + + + + + + + + + + + + + + + + + + + + + + + android:gravity="center" + android:text="@string/sad_face" + android:textColor="@color/briar_text_primary" + android:textSize="@dimen/text_size_xlarge"/> - - \ No newline at end of file + + + + + + + + + + +