UX updates to read-only view of raw contact
am: 079598fa2e
Change-Id: I4adf86e974b8cadb6ae097550989bce6605d37ac
diff --git a/res/layout/item_read_only_field.xml b/res/layout/item_read_only_field.xml
index 3195b4c..e5444a4 100644
--- a/res/layout/item_read_only_field.xml
+++ b/res/layout/item_read_only_field.xml
@@ -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
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 29c92c2..20642fe 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -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>
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index 42ef513..54465fd 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -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 @@
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);
diff --git a/src/com/android/contacts/editor/RawContactEditorView.java b/src/com/android/contacts/editor/RawContactEditorView.java
index fe7894a..8df7c37 100644
--- a/src/com/android/contacts/editor/RawContactEditorView.java
+++ b/src/com/android/contacts/editor/RawContactEditorView.java
@@ -212,8 +212,8 @@
// 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 @@
// 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 @@
// 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 @@
}
private void setupEditorNormally() {
- addAccountInfo();
addKindSectionViews();
mMoreFields.setVisibility(hasMoreFields() ? View.VISIBLE : View.GONE);
@@ -600,7 +600,6 @@
private void addReadOnlyRawContactEditorViews() {
mKindSectionViews.removeAllViews();
- addAccountInfo();
final AccountTypeManager accountTypes = AccountTypeManager.getInstance(
getContext());
final AccountType type = mCurrentRawContactDelta.getAccountType(accountTypes);
@@ -713,18 +712,23 @@
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
- final String accountLabel = mIsUserProfile
- ? EditorUiUtils.getAccountHeaderLabelForMyProfile(getContext(), account)
- : account.getNameLabel().toString();
-
- addAccountHeader(accountLabel);
+ 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();
+ 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 @@
}
}
- 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 @@
// Set the content description
mAccountHeaderContainer.setContentDescription(
- EditorUiUtils.getAccountInfoContentDescription(accountLabel,
- selectorTitle));
+ EditorUiUtils.getAccountInfoContentDescription(primaryText,
+ secondaryText));
}
private void addAccountSelector(final RawContactDelta rawContactDelta) {