diff --git a/mobile/android/base/ClickableWhenDisabledEditText.java b/mobile/android/base/ClickableWhenDisabledEditText.java new file mode 100644 index 000000000000..ba73849e2305 --- /dev/null +++ b/mobile/android/base/ClickableWhenDisabledEditText.java @@ -0,0 +1,25 @@ +/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.gecko; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.widget.EditText; + +public class ClickableWhenDisabledEditText extends EditText { + public ClickableWhenDisabledEditText(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + if (!isEnabled() && event.getAction() == MotionEvent.ACTION_UP) { + return performClick(); + } + return super.onTouchEvent(event); + } +} diff --git a/mobile/android/base/CrashReporter.java b/mobile/android/base/CrashReporter.java index b2801ccdeb21..9ecaa81d448e 100644 --- a/mobile/android/base/CrashReporter.java +++ b/mobile/android/base/CrashReporter.java @@ -22,16 +22,20 @@ import java.nio.channels.FileChannel; import java.util.zip.GZIPOutputStream; import android.app.Activity; +import android.app.AlertDialog; import android.app.ProgressDialog; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Build; import android.os.Bundle; import android.os.Handler; +import android.text.TextUtils; import android.util.Log; import android.view.View; -import android.widget.Button; import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.EditText; public class CrashReporter extends Activity { @@ -108,8 +112,6 @@ public class CrashReporter extends Activity mProgressDialog = new ProgressDialog(this); mProgressDialog.setMessage(getString(R.string.sending_crash_report)); - final Button restartButton = (Button) findViewById(R.id.restart); - final Button closeButton = (Button) findViewById(R.id.close); String passedMinidumpPath = getIntent().getStringExtra(PASSED_MINI_DUMP_KEY); File passedMinidumpFile = new File(passedMinidumpPath); File pendingDir = new File(getFilesDir(), PENDING_SUFFIX); @@ -132,6 +134,66 @@ public class CrashReporter extends Activity editor.putBoolean(GeckoApp.PREFS_WAS_STOPPED, true); editor.putBoolean(GeckoApp.PREFS_CRASHED, true); editor.commit(); + + final CheckBox allowContactCheckBox = (CheckBox) findViewById(R.id.allow_contact); + final CheckBox includeUrlCheckBox = (CheckBox) findViewById(R.id.include_url); + final CheckBox sendReportCheckBox = (CheckBox) findViewById(R.id.send_report); + final EditText commentsEditText = (EditText) findViewById(R.id.comment); + final EditText emailEditText = (EditText) findViewById(R.id.email); + + sendReportCheckBox.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton checkbox, boolean isChecked) { + commentsEditText.setEnabled(isChecked); + commentsEditText.requestFocus(); + + includeUrlCheckBox.setEnabled(isChecked); + allowContactCheckBox.setEnabled(isChecked); + emailEditText.setEnabled(isChecked && allowContactCheckBox.isChecked()); + } + }); + + allowContactCheckBox.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton checkbox, boolean isChecked) { + // We need to check isEnabled() here because this listener is + // fired on rotation -- even when the checkbox is disabled. + emailEditText.setEnabled(checkbox.isEnabled() && isChecked); + emailEditText.requestFocus(); + } + }); + + emailEditText.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // Even if the email EditText is disabled, allow it to be + // clicked and focused. + if (sendReportCheckBox.isChecked() && !v.isEnabled()) { + allowContactCheckBox.setChecked(true); + v.setEnabled(true); + v.requestFocus(); + } + } + }); + } + + @Override + public void onBackPressed() { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage(R.string.crash_closing_alert); + builder.setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }); + builder.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + CrashReporter.this.finish(); + } + }); + builder.show(); } private void backgroundSendReport() { @@ -304,6 +366,16 @@ public class CrashReporter extends Activity sendPart(os, boundary, "Android_Logcat", readLogcat()); } + String comment = ((EditText) findViewById(R.id.comment)).getText().toString(); + if (!TextUtils.isEmpty(comment)) { + sendPart(os, boundary, "Comments", comment); + } + + if (((CheckBox) findViewById(R.id.allow_contact)).isChecked()) { + String email = ((EditText) findViewById(R.id.email)).getText().toString(); + sendPart(os, boundary, "Email", email); + } + sendFile(os, boundary, MINI_DUMP_PATH_KEY, minidumpFile); os.write(("\r\n--" + boundary + "--\r\n").getBytes()); os.flush(); diff --git a/mobile/android/base/Makefile.in b/mobile/android/base/Makefile.in index caca727613f9..b0c967433431 100644 --- a/mobile/android/base/Makefile.in +++ b/mobile/android/base/Makefile.in @@ -69,6 +69,7 @@ FENNEC_JAVA_FILES = \ CameraVideoResultHandler.java \ CanvasDelegate.java \ CheckableLinearLayout.java \ + ClickableWhenDisabledEditText.java \ SyncPreference.java \ db/BrowserDB.java \ db/LocalBrowserDB.java \ @@ -1044,6 +1045,7 @@ MOZ_ANDROID_DRAWABLES += \ mobile/android/base/resources/drawable/tab_thumbnail.xml \ mobile/android/base/resources/drawable/tabs_level.xml \ mobile/android/base/resources/drawable/tabs_panel_indicator.xml \ + mobile/android/base/resources/drawable/textbox_bg.xml \ mobile/android/base/resources/drawable/webapp_titlebar_bg.xml \ $(NULL) diff --git a/mobile/android/base/locales/en-US/android_strings.dtd b/mobile/android/base/locales/en-US/android_strings.dtd index c5c69a677d18..9786d9ebd880 100644 --- a/mobile/android/base/locales/en-US/android_strings.dtd +++ b/mobile/android/base/locales/en-US/android_strings.dtd @@ -14,15 +14,18 @@ - - - - + + + + + + + + + - - diff --git a/mobile/android/base/resources/drawable/textbox_bg.xml b/mobile/android/base/resources/drawable/textbox_bg.xml new file mode 100644 index 000000000000..bcc884a08ce8 --- /dev/null +++ b/mobile/android/base/resources/drawable/textbox_bg.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/mobile/android/base/resources/layout/crash_reporter.xml b/mobile/android/base/resources/layout/crash_reporter.xml index d8468e19a481..02e7b4ebc619 100644 --- a/mobile/android/base/resources/layout/crash_reporter.xml +++ b/mobile/android/base/resources/layout/crash_reporter.xml @@ -5,61 +5,118 @@ + android:layout_height="fill_parent" + android:fillViewport="true"> + android:background="@color/background_normal"> - - - - - - - + + + + + + + + + + + + + + + + + + + - + android:layout_gravity="bottom"> +