Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec37c52b authored by Walter Jang's avatar Walter Jang Committed by Android Git Automerger
Browse files

am c4cecc7e: Show google account types on editor as "account" instead of "contact"

* commit 'c4cecc7e':
  Show google account types on editor as "account" instead of "contact"
parents d41c78e6 c4cecc7e
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -397,6 +397,9 @@
    <!-- String describing which account type a contact came from when editing it -->
    <!-- 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 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 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>
    <string name="from_account_format"><xliff:g id="source" example="user@gmail.com">%1$s</xliff:g></string>


+1 −2
Original line number Original line Diff line number Diff line
@@ -345,8 +345,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O


        // Get the account information for the default account RawContactDelta
        // Get the account information for the default account RawContactDelta
        final Pair<String,String> accountInfo = EditorUiUtils.getAccountInfo(getContext(),
        final Pair<String,String> accountInfo = EditorUiUtils.getAccountInfo(getContext(),
                isUserProfile, defaultAccountRawContactDelta.getAccountName(),
                isUserProfile, defaultAccountRawContactDelta.getAccountName(), accountType);
                accountType.getDisplayLabel(getContext()));


        // Set the account information already
        // Set the account information already
        if (accountInfo == null) {
        if (accountInfo == null) {
+25 −10
Original line number Original line Diff line number Diff line
@@ -25,6 +25,8 @@ import android.content.Context;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.Pair;
import android.util.Pair;
import com.android.contacts.R;
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.android.contacts.common.model.dataitem.DataKind;
import com.google.common.collect.Maps;
import com.google.common.collect.Maps;


@@ -85,24 +87,37 @@ public class EditorUiUtils {
     * in no account information should be displayed. The account name may also be null.
     * in no account information should be displayed. The account name may also be null.
     */
     */
    public static Pair<String,String> getAccountInfo(Context context, boolean isProfile,
    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 (isProfile) {
            if (TextUtils.isEmpty(accountName)) {
            if (TextUtils.isEmpty(accountName)) {
                return new Pair<>(
                return new Pair<>(
                        /* accountName =*/ null,
                        /* accountName =*/ null,
                        context.getString(R.string.local_profile_title));
                        context.getString(R.string.local_profile_title));
            } else {
            }
            return new Pair<>(
            return new Pair<>(
                    accountName,
                    accountName,
                        context.getString(R.string.external_profile_title, accountType));
                    context.getString(R.string.external_profile_title, accountTypeDisplayLabel));
        }
        }
        } else if (!TextUtils.isEmpty(accountName)) {
        if (!TextUtils.isEmpty(accountName)) {
            if (TextUtils.isEmpty(accountType)) {
            final String accountNameDisplayLabel =
                accountType = context.getString(R.string.account_phone);
                    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<>(
            return new Pair<>(
                    context.getString(R.string.from_account_format, accountName),
                    accountNameDisplayLabel,
                    context.getString(R.string.account_type_format, accountType));
                    context.getString(R.string.account_type_format, accountTypeDisplayLabel));
        }
        }
        return null;
        return null;
    }
    }
+1 −1
Original line number Original line Diff line number Diff line
@@ -191,7 +191,7 @@ public class RawContactEditorView extends BaseRawContactEditorView {


        // Fill in the account info
        // Fill in the account info
        final Pair<String,String> accountInfo = EditorUiUtils.getAccountInfo(getContext(),
        final Pair<String,String> accountInfo = EditorUiUtils.getAccountInfo(getContext(),
                isProfile, state.getAccountName(), type.getDisplayLabel(getContext()));
                isProfile, state.getAccountName(), type);
        if (accountInfo == null) {
        if (accountInfo == null) {
            // Hide this view so the other text view will be centered vertically
            // Hide this view so the other text view will be centered vertically
            mAccountHeaderNameTextView.setVisibility(View.GONE);
            mAccountHeaderNameTextView.setVisibility(View.GONE);
+10 −22
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ import android.provider.ContactsContract.RawContacts;
import android.telephony.PhoneNumberUtils;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnClickListener;
@@ -114,32 +115,19 @@ public class RawContactReadOnlyEditorView extends BaseRawContactEditorView
        mAccountType = state.getAccountType();
        mAccountType = state.getAccountType();
        mDataSet = state.getDataSet();
        mDataSet = state.getDataSet();


        if (isProfile) {
        final Pair<String,String> accountInfo = EditorUiUtils.getAccountInfo(getContext(),
            if (TextUtils.isEmpty(mAccountName)) {
                isProfile, state.getAccountName(), type);
        if (accountInfo == null) {
            // Hide this view so the other text view will be centered vertically
            mAccountHeaderNameTextView.setVisibility(View.GONE);
            mAccountHeaderNameTextView.setVisibility(View.GONE);
                mAccountHeaderTypeTextView.setText(R.string.local_profile_title);
        } else {
        } else {
                CharSequence accountType = type.getDisplayLabel(getContext());
            if (accountInfo.first == null) {
                mAccountHeaderTypeTextView.setText(getContext().getString(
                mAccountHeaderNameTextView.setVisibility(View.GONE);
                        R.string.external_profile_title,
                        accountType));
                mAccountHeaderNameTextView.setText(mAccountName);
            }
            } else {
            } 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.setVisibility(View.VISIBLE);
                mAccountHeaderNameTextView.setText(
                mAccountHeaderNameTextView.setText(accountInfo.first);
                        getContext().getString(R.string.from_account_format, mAccountName));
            } else {
                // Hide this view so the other text view will be centered vertically
                mAccountHeaderNameTextView.setVisibility(View.GONE);
            }
            }
            mAccountHeaderTypeTextView.setText(getContext().getString(R.string.account_type_format,
            mAccountHeaderTypeTextView.setText(accountInfo.second);
                    accountType));
        }
        }
        updateAccountHeaderContentDescription();
        updateAccountHeaderContentDescription();