Merge "Set package name on ACTION_PICK intent" into mnc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 4bee141..1a33284 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -18,10 +18,9 @@
package="com.android.contacts"
android:sharedUserId="android.uid.shared">
+ <uses-sdk android:minSdkVersion="MNC" android:targetSdkVersion="MNC" />
<original-package android:name="com.android.contacts" />
- <!-- Whenever a permission is added here, it should also be added to
- RequestPermissionsActivity so it can be requested at runtime. -->
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9e76bd3..936f093 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -397,6 +397,9 @@
<!-- String describing which account type a contact came from when editing it -->
<string name="account_type_format"><xliff:g id="source" example="Gmail">%1$s</xliff:g> contact</string>
+ <!-- String describing that a contact came from the google account type when editing it. -->
+ <string name="google_account_type_format"><xliff:g id="source" example="Google">%1$s</xliff:g> account</string>
+
<!-- String describing which account a contact came from when editing it -->
<string name="from_account_format"><xliff:g id="source" example="user@gmail.com">%1$s</xliff:g></string>
diff --git a/src/com/android/contacts/editor/CompactRawContactsEditorView.java b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
index ca2aa93..e2ecbd6 100644
--- a/src/com/android/contacts/editor/CompactRawContactsEditorView.java
+++ b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
@@ -345,8 +345,7 @@
// Get the account information for the default account RawContactDelta
final Pair<String,String> accountInfo = EditorUiUtils.getAccountInfo(getContext(),
- isUserProfile, defaultAccountRawContactDelta.getAccountName(),
- accountType.getDisplayLabel(getContext()));
+ isUserProfile, defaultAccountRawContactDelta.getAccountName(), accountType);
// Set the account information already
if (accountInfo == null) {
diff --git a/src/com/android/contacts/editor/EditorUiUtils.java b/src/com/android/contacts/editor/EditorUiUtils.java
index 301ce35..78f7a42 100644
--- a/src/com/android/contacts/editor/EditorUiUtils.java
+++ b/src/com/android/contacts/editor/EditorUiUtils.java
@@ -25,6 +25,8 @@
import android.text.TextUtils;
import android.util.Pair;
import com.android.contacts.R;
+import com.android.contacts.common.model.account.AccountType;
+import com.android.contacts.common.model.account.GoogleAccountType;
import com.android.contacts.common.model.dataitem.DataKind;
import com.google.common.collect.Maps;
@@ -85,24 +87,37 @@
* in no account information should be displayed. The account name may also be null.
*/
public static Pair<String,String> getAccountInfo(Context context, boolean isProfile,
- String accountName, CharSequence accountType) {
+ String accountName, AccountType accountType) {
+ CharSequence accountTypeDisplayLabel = accountType.getDisplayLabel(context);
+
if (isProfile) {
if (TextUtils.isEmpty(accountName)) {
return new Pair<>(
/* accountName =*/ null,
context.getString(R.string.local_profile_title));
- } else {
- return new Pair<>(
- accountName,
- context.getString(R.string.external_profile_title, accountType));
- }
- } else if (!TextUtils.isEmpty(accountName)) {
- if (TextUtils.isEmpty(accountType)) {
- accountType = context.getString(R.string.account_phone);
}
return new Pair<>(
- context.getString(R.string.from_account_format, accountName),
- context.getString(R.string.account_type_format, accountType));
+ accountName,
+ context.getString(R.string.external_profile_title, accountTypeDisplayLabel));
+ }
+ if (!TextUtils.isEmpty(accountName)) {
+ final String accountNameDisplayLabel =
+ context.getString(R.string.from_account_format, accountName);
+
+ if (TextUtils.isEmpty(accountTypeDisplayLabel)) {
+ accountTypeDisplayLabel = context.getString(R.string.account_phone);
+ }
+
+ if (GoogleAccountType.ACCOUNT_TYPE.equals(accountType.accountType)
+ && accountType.dataSet == null) {
+ return new Pair<>(
+ accountNameDisplayLabel,
+ context.getString(R.string.google_account_type_format,
+ accountTypeDisplayLabel));
+ }
+ return new Pair<>(
+ accountNameDisplayLabel,
+ context.getString(R.string.account_type_format, accountTypeDisplayLabel));
}
return null;
}
diff --git a/src/com/android/contacts/editor/LabeledEditorView.java b/src/com/android/contacts/editor/LabeledEditorView.java
index e2724a1..fe7ae0a 100644
--- a/src/com/android/contacts/editor/LabeledEditorView.java
+++ b/src/com/android/contacts/editor/LabeledEditorView.java
@@ -340,8 +340,6 @@
// Notify listener if applicable
notifyEditorListener();
-
- rebuildLabel();
}
protected void saveValue(String column, String value) {
diff --git a/src/com/android/contacts/editor/RawContactEditorView.java b/src/com/android/contacts/editor/RawContactEditorView.java
index 11f0c1e..6c55854 100644
--- a/src/com/android/contacts/editor/RawContactEditorView.java
+++ b/src/com/android/contacts/editor/RawContactEditorView.java
@@ -191,7 +191,7 @@
// Fill in the account info
final Pair<String,String> accountInfo = EditorUiUtils.getAccountInfo(getContext(),
- isProfile, state.getAccountName(), type.getDisplayLabel(getContext()));
+ isProfile, state.getAccountName(), type);
if (accountInfo == null) {
// Hide this view so the other text view will be centered vertically
mAccountHeaderNameTextView.setVisibility(View.GONE);
diff --git a/src/com/android/contacts/editor/RawContactReadOnlyEditorView.java b/src/com/android/contacts/editor/RawContactReadOnlyEditorView.java
index 7ae6aa7..d7b3dd0 100644
--- a/src/com/android/contacts/editor/RawContactReadOnlyEditorView.java
+++ b/src/com/android/contacts/editor/RawContactReadOnlyEditorView.java
@@ -28,6 +28,7 @@
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.util.AttributeSet;
+import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
@@ -114,32 +115,19 @@
mAccountType = state.getAccountType();
mDataSet = state.getDataSet();
- if (isProfile) {
- if (TextUtils.isEmpty(mAccountName)) {
- mAccountHeaderNameTextView.setVisibility(View.GONE);
- mAccountHeaderTypeTextView.setText(R.string.local_profile_title);
- } else {
- CharSequence accountType = type.getDisplayLabel(getContext());
- mAccountHeaderTypeTextView.setText(getContext().getString(
- R.string.external_profile_title,
- accountType));
- mAccountHeaderNameTextView.setText(mAccountName);
- }
+ final Pair<String,String> accountInfo = EditorUiUtils.getAccountInfo(getContext(),
+ isProfile, state.getAccountName(), type);
+ if (accountInfo == null) {
+ // Hide this view so the other text view will be centered vertically
+ mAccountHeaderNameTextView.setVisibility(View.GONE);
} else {
- CharSequence accountType = type.getDisplayLabel(getContext());
- if (TextUtils.isEmpty(accountType)) {
- accountType = getContext().getString(R.string.account_phone);
- }
- if (!TextUtils.isEmpty(mAccountName)) {
- mAccountHeaderNameTextView.setVisibility(View.VISIBLE);
- mAccountHeaderNameTextView.setText(
- getContext().getString(R.string.from_account_format, mAccountName));
- } else {
- // Hide this view so the other text view will be centered vertically
+ if (accountInfo.first == null) {
mAccountHeaderNameTextView.setVisibility(View.GONE);
+ } else {
+ mAccountHeaderNameTextView.setVisibility(View.VISIBLE);
+ mAccountHeaderNameTextView.setText(accountInfo.first);
}
- mAccountHeaderTypeTextView.setText(getContext().getString(R.string.account_type_format,
- accountType));
+ mAccountHeaderTypeTextView.setText(accountInfo.second);
}
updateAccountHeaderContentDescription();
diff --git a/src/com/android/contacts/interactions/CalendarInteractionsLoader.java b/src/com/android/contacts/interactions/CalendarInteractionsLoader.java
index c3927ce..4813866 100644
--- a/src/com/android/contacts/interactions/CalendarInteractionsLoader.java
+++ b/src/com/android/contacts/interactions/CalendarInteractionsLoader.java
@@ -2,6 +2,8 @@
import com.google.common.base.Preconditions;
+import com.android.contacts.common.util.PermissionsUtil;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -9,6 +11,7 @@
import java.util.List;
import java.util.Set;
+import android.Manifest.permission;
import android.content.AsyncTaskLoader;
import android.content.ContentValues;
import android.content.Context;
@@ -55,7 +58,8 @@
@Override
public List<ContactInteraction> loadInBackground() {
- if (mEmailAddresses == null || mEmailAddresses.size() < 1) {
+ if (!PermissionsUtil.hasPermission(getContext(), permission.READ_CALENDAR)
+ || mEmailAddresses == null || mEmailAddresses.size() < 1) {
return Collections.emptyList();
}
// Perform separate calendar queries for events in the past and future.
diff --git a/src/com/android/contacts/interactions/CallLogInteractionsLoader.java b/src/com/android/contacts/interactions/CallLogInteractionsLoader.java
index 46cd315..2340d3f 100644
--- a/src/com/android/contacts/interactions/CallLogInteractionsLoader.java
+++ b/src/com/android/contacts/interactions/CallLogInteractionsLoader.java
@@ -28,6 +28,8 @@
import com.google.common.annotations.VisibleForTesting;
+import com.android.contacts.common.util.PermissionsUtil;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -48,7 +50,9 @@
@Override
public List<ContactInteraction> loadInBackground() {
- if (!getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)
+ if (!PermissionsUtil.hasPhonePermissions(getContext())
+ || !getContext().getPackageManager()
+ .hasSystemFeature(PackageManager.FEATURE_TELEPHONY)
|| mPhoneNumbers == null || mPhoneNumbers.length <= 0 || mMaxToRetrieve <= 0) {
return Collections.emptyList();
}
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index 5bfbd10..d97d472 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -45,7 +45,6 @@
import android.os.Bundle;
import android.os.Trace;
import android.provider.CalendarContract;
-import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.Event;
import android.provider.ContactsContract.CommonDataKinds.GroupMembership;