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

Commit fd30f853 authored by Gary Mai's avatar Gary Mai Committed by Android (Google) Code Review
Browse files

Merge "UX updates to read-only view of raw contact" into ub-contactsdialer-h-dev

parents 25251581 079598fa
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/editor_account_left_margin"
        android:orientation="vertical">

        <TextView
+7 −2
Original line number Diff line number Diff line
@@ -720,6 +720,11 @@
         at a pre-determined text size. [CHAR LIMIT=20] -->
    <string name="contact_editor_title_existing_contact">Edit contact</string>

    <!-- Title of the editor activity when viewing a read-only raw contact. The char
         limit is short and cannot be increased, since this needs to be displayed in a single line
         at a pre-determined text size. [CHAR LIMIT=20] -->
    <string name="contact_editor_title_read_only_contact">View only</string>

    <!-- Dialog title when the user is selecting a raw contact to edit.  [CHAR LIMIT=128] -->
    <string name="contact_editor_pick_raw_contact_dialog_title">Choose linked contact</string>

@@ -832,8 +837,8 @@
    <!-- Label for the account selector to indicate which account a contact will be saved to. [CHAR LIMIT=30] -->
    <string name="editor_account_selector_title">Saving to</string>

    <!-- Label for the account selector to indicate which read-only account is being viewed. [CHAR LIMIT=30] -->
    <string name="editor_account_selector_read_only_title">Viewing</string>
    <!-- Label for the account selector to indicate the current information comes from a read-only account. [CHAR LIMIT=50] -->
    <string name="editor_account_selector_read_only_title">Contact info from <xliff:g id="account">%s</xliff:g> is not editable</string>

    <!-- Content description for the account selector to indicate which account a contact will be saved to. [CHAR LIMIT=NONE] -->
    <string name="editor_account_selector_description">Currently saving to <xliff:g id="account_name">%s</xliff:g>. Double-tap to pick a different account.</string>
+8 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.contacts.editor;

import android.accounts.Account;
import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
import android.app.LoaderManager;
@@ -1240,6 +1241,13 @@ public class ContactEditorFragment extends Fragment implements
        editorView.setState(mState, mMaterialPalette, mViewIdGenerator,
                mHasNewContact, mIsUserProfile, mAccountWithDataSet,
                mRawContactIdToDisplayAlone);
        if (isEditingReadOnlyRawContact()) {
            final ActionBar actionBar = getEditorActivity().getActionBar();
            if (actionBar != null) {
                actionBar.setTitle(R.string.contact_editor_title_read_only_contact);
                actionBar.setHomeAsUpIndicator(R.drawable.ic_back_arrow);
            }
        }

        // Set up the photo widget
        editorView.setPhotoListener(this);
+23 −28
Original line number Diff line number Diff line
@@ -212,8 +212,8 @@ public class RawContactEditorView extends LinearLayout implements View.OnClickLi

    // Account header
    private View mAccountHeaderContainer;
    private TextView mAccountHeaderType;
    private TextView mAccountHeaderName;
    private TextView mAccountHeaderPrimaryText;
    private TextView mAccountHeaderSecondaryText;
    private ImageView mAccountHeaderIcon;
    private ImageView mAccountHeaderExpanderIcon;

@@ -254,8 +254,8 @@ public class RawContactEditorView extends LinearLayout implements View.OnClickLi

        // Account header
        mAccountHeaderContainer = findViewById(R.id.account_header_container);
        mAccountHeaderType = (TextView) findViewById(R.id.account_type);
        mAccountHeaderName = (TextView) findViewById(R.id.account_name);
        mAccountHeaderPrimaryText = (TextView) findViewById(R.id.account_type);
        mAccountHeaderSecondaryText = (TextView) findViewById(R.id.account_name);
        mAccountHeaderIcon = (ImageView) findViewById(R.id.account_type_icon);
        mAccountHeaderExpanderIcon = (ImageView) findViewById(R.id.account_expander_icon);

@@ -489,6 +489,7 @@ public class RawContactEditorView extends LinearLayout implements View.OnClickLi

        // Setup the view
        addPhotoView();
        setAccountInfo();
        if (isReadOnlyRawContact()) {
            // We're want to display the inputs fields for a single read only raw contact
            addReadOnlyRawContactEditorViews();
@@ -499,7 +500,6 @@ public class RawContactEditorView extends LinearLayout implements View.OnClickLi
    }

    private void setupEditorNormally() {
        addAccountInfo();
        addKindSectionViews();

        mMoreFields.setVisibility(hasMoreFields() ? View.VISIBLE : View.GONE);
@@ -600,7 +600,6 @@ public class RawContactEditorView extends LinearLayout implements View.OnClickLi

    private void addReadOnlyRawContactEditorViews() {
        mKindSectionViews.removeAllViews();
        addAccountInfo();
        final AccountTypeManager accountTypes = AccountTypeManager.getInstance(
                getContext());
        final AccountType type = mCurrentRawContactDelta.getAccountType(accountTypes);
@@ -713,18 +712,23 @@ public class RawContactEditorView extends LinearLayout implements View.OnClickLi
        mKindSectionViews.addView(field);
    }

    private void addAccountInfo() {
        mAccountHeaderContainer.setVisibility(View.GONE);

    private void setAccountInfo() {
        final AccountDisplayInfo account =
                mAccountDisplayInfoFactory.getAccountDisplayInfoFor(mCurrentRawContactDelta);

        // Get the account information for the primary raw contact delta
        if (isReadOnlyRawContact()) {
            final String accountType = account.getTypeLabel().toString();
            setAccountHeader(accountType,
                    getResources().getString(
                            R.string.editor_account_selector_read_only_title, accountType));
        } else {
            final String accountLabel = mIsUserProfile
                    ? EditorUiUtils.getAccountHeaderLabelForMyProfile(getContext(), account)
                    : account.getNameLabel().toString();

        addAccountHeader(accountLabel);
            setAccountHeader(getResources().getString(R.string.editor_account_selector_title),
                    accountLabel);
        }

        // If we're saving a new contact and there are multiple accounts, add the account selector.
        final List<AccountWithDataSet> accounts =
@@ -734,18 +738,9 @@ public class RawContactEditorView extends LinearLayout implements View.OnClickLi
        }
    }

    private void addAccountHeader(String accountLabel) {
        mAccountHeaderContainer.setVisibility(View.VISIBLE);

        // Set the account name
        mAccountHeaderName.setVisibility(View.VISIBLE);
        mAccountHeaderName.setText(accountLabel);

        // Set the account type
        final String selectorTitle = getResources().getString(isReadOnlyRawContact() ?
                R.string.editor_account_selector_read_only_title :
                R.string.editor_account_selector_title);
        mAccountHeaderType.setText(selectorTitle);
    private void setAccountHeader(String primaryText, String secondaryText) {
        mAccountHeaderPrimaryText.setText(primaryText);
        mAccountHeaderSecondaryText.setText(secondaryText);

        // Set the icon
        final AccountType accountType =
@@ -754,8 +749,8 @@ public class RawContactEditorView extends LinearLayout implements View.OnClickLi

        // Set the content description
        mAccountHeaderContainer.setContentDescription(
                EditorUiUtils.getAccountInfoContentDescription(accountLabel,
                        selectorTitle));
                EditorUiUtils.getAccountInfoContentDescription(primaryText,
                        secondaryText));
    }

    private void addAccountSelector(final RawContactDelta rawContactDelta) {