Fix CtsVerifier Proguard Issues
Remove the specification of click handlers via XML, since that technique
doesn't work when Proguard is enabled.
Change-Id: Ia16c4683d7d3399aab13bff3c223d7069daf00f7
diff --git a/apps/CtsVerifier/res/layout/main.xml b/apps/CtsVerifier/res/layout/main.xml
index 479cc1b..35f6f23 100644
--- a/apps/CtsVerifier/res/layout/main.xml
+++ b/apps/CtsVerifier/res/layout/main.xml
@@ -29,7 +29,6 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
- android:onClick="continueButtonClickHandler"
android:text="@string/continue_button_text"
/>
</RelativeLayout>
diff --git a/apps/CtsVerifier/res/layout/pass_fail_buttons.xml b/apps/CtsVerifier/res/layout/pass_fail_buttons.xml
index 5c64e31..d70e839 100644
--- a/apps/CtsVerifier/res/layout/pass_fail_buttons.xml
+++ b/apps/CtsVerifier/res/layout/pass_fail_buttons.xml
@@ -23,7 +23,6 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableTop="@drawable/fs_good"
- android:onClick="passFailButtonsClickHandler"
android:text="@string/pass_button_text"/>
<Button android:id="@+id/info_button"
@@ -39,7 +38,6 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableTop="@drawable/fs_error"
- android:onClick="passFailButtonsClickHandler"
android:text="@string/fail_button_text"/>
</LinearLayout>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/CtsVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/CtsVerifierActivity.java
index 9c0566e..5fd140f 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/CtsVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/CtsVerifierActivity.java
@@ -20,6 +20,7 @@
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
+import android.view.View.OnClickListener;
/** {@link Activity} that displays an introduction to the verifier. */
public class CtsVerifierActivity extends Activity {
@@ -29,9 +30,11 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
- }
-
- public void continueButtonClickHandler(View target) {
- startActivity(new Intent(this, TestListActivity.class));
+ findViewById(R.id.continue_button).setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ startActivity(new Intent(CtsVerifierActivity.this, TestListActivity.class));
+ }
+ });
}
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/PassFailButtons.java b/apps/CtsVerifier/src/com/android/cts/verifier/PassFailButtons.java
index 1c407b8..c070ec8 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/PassFailButtons.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/PassFailButtons.java
@@ -34,7 +34,8 @@
* <li>Include the pass fail buttons layout in your layout:
* <pre><include layout="@layout/pass_fail_buttons" /></pre>
* </li>
- * <li>Extend one of the activities to get the click handler for the buttons.</li>
+ * <li>Extend one of the activities and call setPassFailButtonClickListeners after
+ * setting your content view.</li>
* <li>Make sure to call setResult(RESULT_CANCEL) in your Activity initially.</li>
* <li>Optionally call setInfoTextResources to add an info button that will show a
* dialog with instructional text.</li>
@@ -46,6 +47,13 @@
private interface PassFailActivity {
/**
+ * Hooks up the pass and fail buttons to click listeners that will record the test results.
+ * <p>
+ * Call from {@link Activity#onCreate} after {@link Activity #setContentView(int)}.
+ */
+ void setPassFailButtonClickListeners();
+
+ /**
* Adds an initial informational dialog that appears when entering the test activity for
* the first time. Also enables the visibility of an "Info" button between the "Pass" and
* "Fail" buttons that can be clicked to show the information dialog again.
@@ -56,34 +64,40 @@
* @param messageId for the text shown in the dialog's body area
*/
void setInfoResources(int titleId, int messageId, int viewId);
-
- /**
- * Click handler for the pass and fail buttons. No need to call this ever as the XML
- * view layout will bind to this automatically.
- */
- void passFailButtonsClickHandler(View target);
}
public static class Activity extends android.app.Activity implements PassFailActivity {
- public void setInfoResources(int titleId, int messageId, int viewId) {
- setInfo(this, titleId, messageId, viewId);
+ public void setPassFailButtonClickListeners() {
+ setPassFailClickListeners(this);
}
- public void passFailButtonsClickHandler(View target) {
- setTestResultAndFinish(this, target);
+ public void setInfoResources(int titleId, int messageId, int viewId) {
+ setInfo(this, titleId, messageId, viewId);
}
}
public static class ListActivity extends android.app.ListActivity implements PassFailActivity {
+ public void setPassFailButtonClickListeners() {
+ setPassFailClickListeners(this);
+ }
+
public void setInfoResources(int titleId, int messageId, int viewId) {
setInfo(this, titleId, messageId, viewId);
}
+ }
- public void passFailButtonsClickHandler(View target) {
- setTestResultAndFinish(this, target);
- }
+ private static void setPassFailClickListeners(final android.app.Activity activity) {
+ View.OnClickListener clickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View target) {
+ setTestResultAndFinish(activity, target);
+ }
+ };
+
+ activity.findViewById(R.id.pass_button).setOnClickListener(clickListener);
+ activity.findViewById(R.id.fail_button).setOnClickListener(clickListener);
}
private static void setInfo(final android.app.Activity activity, final int titleId,
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audioquality/AudioQualityVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audioquality/AudioQualityVerifierActivity.java
index ce9c165..fd84cd3 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audioquality/AudioQualityVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audioquality/AudioQualityVerifierActivity.java
@@ -94,8 +94,8 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.aq_verifier_activity);
+ setPassFailButtonClickListeners();
setInfoResources(R.string.aq_verifier, R.string.aq_verifier_info, -1);
- setResult(RESULT_CANCELED);
mCalibrateButton = (Button) findViewById(R.id.calibrateButton);
mRunAllButton = (Button) findViewById(R.id.runAllButton);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
index c83a470..aad97ad 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
@@ -65,7 +65,7 @@
/**
* Constructor does not include 'present' because that's a detected
* value, and not set during creation.
- *
+ *
* @param name value for this.name
* @param required value for this.required
*/
@@ -92,8 +92,8 @@
};
/**
- * A list of all features added in FroYo (API=8) and Gingerbread (API=9).
- * Because we want to run on Eclair devices,
+ * A list of all features added in FroYo (API=8) and Gingerbread (API=9).
+ * Because we want to run on Eclair devices,
* we can't use static references to constants added later
* than Eclair. We could use Reflection, but we'd still need a list of
* string literals (for constant names) anyway, and there's little point in
@@ -129,8 +129,8 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fs_main);
+ setPassFailButtonClickListeners();
setInfoResources(R.string.feature_summary, R.string.feature_summary_info, R.layout.fs_info);
- setResult(RESULT_CANCELED);
// some values used to detect warn-able conditions involving multiple
// features
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerTestActivity.java
index 2100c0f..193f37e 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerTestActivity.java
@@ -41,7 +41,6 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setResult(RESULT_CANCELED);
mSensorManager = (SensorManager) getApplicationContext().getSystemService(
Context.SENSOR_SERVICE);
@@ -49,6 +48,7 @@
mListener = renderer;
setContentView(R.layout.pass_fail_gl);
+ setPassFailButtonClickListeners();
setInfoResources(R.string.snsr_accel_test, R.string.snsr_accel_test_info, -1);
mGLSurfaceView = (GLSurfaceView) findViewById(R.id.gl_surface_view);
mGLSurfaceView.setRenderer(renderer);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/MagnetometerTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/MagnetometerTestActivity.java
index 479a2fb..f3ba411 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/MagnetometerTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/MagnetometerTestActivity.java
@@ -40,7 +40,6 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setResult(RESULT_CANCELED);
mSensorManager = (SensorManager) getApplicationContext().getSystemService(
Context.SENSOR_SERVICE);
@@ -48,6 +47,7 @@
mListener = renderer;
setContentView(R.layout.pass_fail_gl);
+ setPassFailButtonClickListeners();
setInfoResources(R.string.snsr_mag_test, R.string.snsr_mag_test_info, -1);
mGLSurfaceView = (GLSurfaceView) findViewById(R.id.gl_surface_view);
mGLSurfaceView.setRenderer(renderer);