Check for null extras before accessing previous screen extra
am: 1bb6c29
* commit '1bb6c29245bbef5b8dd1c68607acf14aec639be6':
Check for null extras before accessing previous screen extra
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index 7897782..2617abe 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -924,8 +924,8 @@
return;
}
- final int previousScreenType = getIntent().getExtras()
- .getInt(EXTRA_PREVIOUS_SCREEN_TYPE, ScreenType.UNKNOWN);
+ final int previousScreenType = getIntent().getIntExtra
+ (EXTRA_PREVIOUS_SCREEN_TYPE, ScreenType.UNKNOWN);
Logger.logScreenView(this, ScreenType.QUICK_CONTACT, previousScreenType);
if (CompatUtils.isLollipopCompatible()) {
diff --git a/tests/res/layout/quick_contact_tests.xml b/tests/res/layout/quick_contact_tests.xml
index aa0648e..71393cf 100644
--- a/tests/res/layout/quick_contact_tests.xml
+++ b/tests/res/layout/quick_contact_tests.xml
@@ -91,5 +91,11 @@
style="?android:attr/quickContactBadgeStyleSmallWindowLarge"
android:layout_marginLeft="4dip" />
</LinearLayout>
+ <Button
+ android:id="@android:id/button1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/quickContactIntent"
+ android:enabled="false"/>
</LinearLayout>
diff --git a/tests/res/values/donottranslate_strings.xml b/tests/res/values/donottranslate_strings.xml
index c1d4626..e675566 100644
--- a/tests/res/values/donottranslate_strings.xml
+++ b/tests/res/values/donottranslate_strings.xml
@@ -86,6 +86,7 @@
<string name="pinnedHeaderList">Pinned Headers</string>
<string name="quickContactTests">Quick Contact modes</string>
<string name="pickContact">Pick contact</string>
+ <string name="quickContactIntent">Start with Intent</string>
<string name="fillCallLogTest">Fill call log test</string>
<string name="addToCallLogButton">Add</string>
<string name="numberOfCallLogEntries">Number of call log entries to add:</string>
diff --git a/tests/src/com/android/contacts/tests/quickcontact/QuickContactTestsActivity.java b/tests/src/com/android/contacts/tests/quickcontact/QuickContactTestsActivity.java
index 5092487..1600744 100644
--- a/tests/src/com/android/contacts/tests/quickcontact/QuickContactTestsActivity.java
+++ b/tests/src/com/android/contacts/tests/quickcontact/QuickContactTestsActivity.java
@@ -23,6 +23,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract.Contacts;
+import android.provider.ContactsContract.QuickContact;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
@@ -45,6 +46,7 @@
private QuickContactBadge mMediumBadge2;
private QuickContactBadge mLargeBadge1;
private QuickContactBadge mLargeBadge2;
+ private Button mButton;
private Uri mContactUri;
@@ -63,6 +65,15 @@
mMediumBadge2 = (QuickContactBadge) findViewById(R.id.medium_badge2);
mLargeBadge1 = (QuickContactBadge) findViewById(R.id.large_badge1);
mLargeBadge2 = (QuickContactBadge) findViewById(R.id.large_badge2);
+ mButton = (Button) findViewById(android.R.id.button1);
+ mButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ final Intent intent = new Intent(QuickContact.ACTION_QUICK_CONTACT);
+ intent.setData(mContactUri);
+ startActivity(intent);
+ }
+ });
mPickContact.setOnClickListener(new OnClickListener() {
@Override
@@ -89,6 +100,7 @@
case REQUEST_CODE_PICK: {
mContactUri = data.getData();
assignUri();
+ mButton.setEnabled(true);
break;
}
}