Loading res/layout/compact_account_info.xml +9 −1 Original line number Diff line number Diff line Loading @@ -21,10 +21,18 @@ android:id="@+id/account_container" android:layout_height="wrap_content" android:layout_width="match_parent" android:orientation="horizontal" android:background="?android:attr/selectableItemBackground" android:paddingStart="16dp" android:paddingTop="8dip" > <ImageView android:id="@+id/account_type_icon" android:layout_width="@dimen/detail_network_icon_size" android:layout_height="@dimen/detail_network_icon_size" android:layout_margin="16dip" android:layout_gravity="center_vertical" /> <LinearLayout android:layout_height="wrap_content" android:layout_width="0dp" Loading src/com/android/contacts/editor/CompactContactEditorFragment.java +3 −6 Original line number Diff line number Diff line Loading @@ -258,14 +258,11 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl } @Override public void onRawContactSelected(Uri uri, long rawContactId) { public void onRawContactSelected(Uri uri, long rawContactId, boolean isReadOnly) { final Activity activity = getActivity(); if (activity != null && !activity.isFinishing()) { final Intent intent = new Intent(activity, ContactEditorActivity.class); intent.setAction(ContactEditorBaseActivity.ACTION_EDIT); intent.setData(uri); intent.putExtra(ContactEditorFragment.INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE, rawContactId); final Intent intent = EditorIntents.createEditContactIntentForRawContact( activity, uri, rawContactId, isReadOnly); activity.startActivity(intent); } } Loading src/com/android/contacts/editor/CompactRawContactsEditorView.java +18 −12 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O /** * Invoked when a rawcontact from merged contacts is selected in editor. */ public void onRawContactSelected(Uri uri, long rawContactId); public void onRawContactSelected(Uri uri, long rawContactId, boolean isReadOnly); } /** Loading Loading @@ -379,6 +379,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O private View mAccountHeaderContainer; private TextView mAccountHeaderType; private TextView mAccountHeaderName; private ImageView mAccountHeaderIcon; // Account selector private View mAccountSelectorContainer; Loading Loading @@ -429,6 +430,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O mAccountHeaderContainer = findViewById(R.id.account_container); mAccountHeaderType = (TextView) findViewById(R.id.account_type); mAccountHeaderName = (TextView) findViewById(R.id.account_name); mAccountHeaderIcon = (ImageView) findViewById(R.id.account_type_icon); // Account selector mAccountSelectorContainer = findViewById(R.id.account_selector_container); Loading Loading @@ -793,6 +795,10 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O } mAccountHeaderType.setText(accountInfo.second); final AccountType primaryAccountType = mPrimaryRawContactDelta.getRawContactAccountType( getContext()); mAccountHeaderIcon.setImageDrawable(primaryAccountType.getDisplayIcon(getContext())); mAccountHeaderContainer.setContentDescription( EditorUiUtils.getAccountInfoContentDescription( accountInfo.first, accountInfo.second)); Loading Loading @@ -875,19 +881,19 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O public void onItemClick(AdapterView<?> parent, View view, int position, long id) { UiClosables.closeQuietly(popup); final RawContactDelta rawContactDelta = adapter.getItem(position); if (mListener != null) { final long rawContactId = adapter.getItemId(position); final Uri rawContactUri = ContentUris.withAppendedId( ContactsContract.RawContacts.CONTENT_URI, rawContactId); // Start new activity for the raw contact in selected account. final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT); intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE); ArrayList<ContentValues> values = rawContactDelta.getContentValues(); intent.putExtra(ContactsContract.Intents.Insert.DATA, values); final RawContactDelta rawContactDelta = adapter.getItem(position); final AccountTypeManager accountTypes = AccountTypeManager.getInstance( getContext()); final AccountType accountType = rawContactDelta.getAccountType( accountTypes); final boolean isReadOnly = !accountType.areContactsWritable(); if (mListener != null) { mListener.onRawContactSelected(rawContactUri, rawContactId); mListener.onRawContactSelected(rawContactUri, rawContactId, isReadOnly); } } }); Loading src/com/android/contacts/editor/ContactEditorBaseFragment.java +26 −2 Original line number Diff line number Diff line Loading @@ -128,6 +128,8 @@ abstract public class ContactEditorBaseFragment extends Fragment implements private static final String KEY_IS_EDIT = "isEdit"; private static final String KEY_EXISTING_CONTACT_READY = "existingContactDataReady"; private static final String KEY_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY = "isReadOnly"; // Phone option menus private static final String KEY_SEND_TO_VOICE_MAIL_STATE = "sendToVoicemailState"; private static final String KEY_ARE_PHONE_OPTIONS_CHANGEABLE = "arePhoneOptionsChangable"; Loading Loading @@ -182,6 +184,13 @@ abstract public class ContactEditorBaseFragment extends Fragment implements */ public static final String INTENT_EXTRA_PHOTO_ID = "photo_id"; /** * Intent key to pass the boolean value of if the raw contact id that should be displayed * in the full editor by itself is read-only. */ public static final String INTENT_EXTRA_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY = "raw_contact_display_alone_is_read_only"; /** * Intent extra to specify a {@link ContactEditor.SaveMode}. */ Loading Loading @@ -335,6 +344,7 @@ abstract public class ContactEditorBaseFragment extends Fragment implements // protected RawContactDeltaList mState; protected int mStatus; protected boolean mRawContactDisplayAloneIsReadOnly = false; // Whether to show the new contact blank form and if it's corresponding delta is ready. protected boolean mHasNewContact; Loading Loading @@ -474,6 +484,8 @@ abstract public class ContactEditorBaseFragment extends Fragment implements // Read state from savedState. No loading involved here mState = savedState.<RawContactDeltaList> getParcelable(KEY_EDIT_STATE); mStatus = savedState.getInt(KEY_STATUS); mRawContactDisplayAloneIsReadOnly = savedState.getBoolean( KEY_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY); mHasNewContact = savedState.getBoolean(KEY_HAS_NEW_CONTACT); mNewContactDataReady = savedState.getBoolean(KEY_NEW_CONTACT_READY); Loading Loading @@ -598,6 +610,8 @@ abstract public class ContactEditorBaseFragment extends Fragment implements outState.putBoolean(KEY_NEW_CONTACT_ACCOUNT_CHANGED, mNewContactAccountChanged); outState.putBoolean(KEY_IS_EDIT, mIsEdit); outState.putBoolean(KEY_EXISTING_CONTACT_READY, mExistingContactDataReady); outState.putBoolean(KEY_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY, mRawContactDisplayAloneIsReadOnly); outState.putBoolean(KEY_IS_USER_PROFILE, mIsUserProfile); Loading Loading @@ -764,6 +778,9 @@ abstract public class ContactEditorBaseFragment extends Fragment implements helpMenu.setVisible(false); } // Save menu is invisible when there's only one read only contact in the editor. saveMenu.setVisible(!mRawContactDisplayAloneIsReadOnly); // Hide telephony-related settings (ringtone, send to voicemail) // if we don't have a telephone or are editing a new contact. sendToVoiceMailMenu.setChecked(mSendToVoicemailState); Loading Loading @@ -1337,6 +1354,8 @@ abstract public class ContactEditorBaseFragment extends Fragment implements mIntentExtras.getInt(INTENT_EXTRA_MATERIAL_PALETTE_SECONDARY_COLOR)); } mPhotoId = mIntentExtras.getLong(INTENT_EXTRA_PHOTO_ID); mRawContactDisplayAloneIsReadOnly = mIntentExtras.getBoolean( INTENT_EXTRA_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY); } } Loading Loading @@ -1375,8 +1394,7 @@ abstract public class ContactEditorBaseFragment extends Fragment implements } } switch (saveMode) { case SaveMode.CLOSE: case SaveMode.COMPACT: { case SaveMode.CLOSE: { final Intent resultIntent; if (saveSucceeded && contactLookupUri != null) { final Uri lookupUri = maybeConvertToLegacyLookupUri( Loading @@ -1391,6 +1409,12 @@ abstract public class ContactEditorBaseFragment extends Fragment implements if (mListener != null) mListener.onSaveFinished(resultIntent); break; } case SaveMode.COMPACT: { // It is already saved, so prevent it from being saved again mStatus = Status.CLOSING; if (mListener != null) mListener.onSaveFinished(/* resultIntent= */ null); break; } case SaveMode.RELOAD: case SaveMode.JOIN: if (saveSucceeded && contactLookupUri != null) { Loading src/com/android/contacts/editor/ContactEditorFragment.java +7 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.widget.ListPopupWindow; import com.android.contacts.ContactSaveService; import com.android.contacts.R; import com.android.contacts.activities.ContactEditorActivity; import com.android.contacts.activities.ContactEditorBaseActivity.ContactEditor; import com.android.contacts.common.model.AccountTypeManager; import com.android.contacts.common.model.RawContactDelta; import com.android.contacts.common.model.RawContactDeltaList; Loading Loading @@ -168,6 +169,8 @@ public class ContactEditorFragment extends ContactEditorBaseFragment implements public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { return revert(); } else if (item.getItemId() == R.id.menu_save && mRawContactIdToDisplayAlone != -1) { return super.save(SaveMode.COMPACT); } return super.onOptionsItemSelected(item); } Loading Loading @@ -354,7 +357,7 @@ public class ContactEditorFragment extends ContactEditorBaseFragment implements private void bindPhotoHandler(BaseRawContactEditorView editor, AccountType type, RawContactDeltaList state) { final int mode; final boolean showIsPrimaryOption; boolean showIsPrimaryOption; if (type.areContactsWritable()) { if (editor.hasSetPhoto()) { mode = PhotoActionPopup.Modes.WRITE_ABLE_PHOTO; Loading @@ -372,6 +375,9 @@ public class ContactEditorFragment extends ContactEditorBaseFragment implements editor.getPhotoEditor().setShowPrimary(false); return; } if (mRawContactIdToDisplayAlone != -1) { showIsPrimaryOption = false; } final PhotoHandler photoHandler = new PhotoHandler(mContext, editor, mode, state); editor.getPhotoEditor().setEditorListener( (PhotoHandler.PhotoEditorListener) photoHandler.getListener()); Loading Loading
res/layout/compact_account_info.xml +9 −1 Original line number Diff line number Diff line Loading @@ -21,10 +21,18 @@ android:id="@+id/account_container" android:layout_height="wrap_content" android:layout_width="match_parent" android:orientation="horizontal" android:background="?android:attr/selectableItemBackground" android:paddingStart="16dp" android:paddingTop="8dip" > <ImageView android:id="@+id/account_type_icon" android:layout_width="@dimen/detail_network_icon_size" android:layout_height="@dimen/detail_network_icon_size" android:layout_margin="16dip" android:layout_gravity="center_vertical" /> <LinearLayout android:layout_height="wrap_content" android:layout_width="0dp" Loading
src/com/android/contacts/editor/CompactContactEditorFragment.java +3 −6 Original line number Diff line number Diff line Loading @@ -258,14 +258,11 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl } @Override public void onRawContactSelected(Uri uri, long rawContactId) { public void onRawContactSelected(Uri uri, long rawContactId, boolean isReadOnly) { final Activity activity = getActivity(); if (activity != null && !activity.isFinishing()) { final Intent intent = new Intent(activity, ContactEditorActivity.class); intent.setAction(ContactEditorBaseActivity.ACTION_EDIT); intent.setData(uri); intent.putExtra(ContactEditorFragment.INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE, rawContactId); final Intent intent = EditorIntents.createEditContactIntentForRawContact( activity, uri, rawContactId, isReadOnly); activity.startActivity(intent); } } Loading
src/com/android/contacts/editor/CompactRawContactsEditorView.java +18 −12 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O /** * Invoked when a rawcontact from merged contacts is selected in editor. */ public void onRawContactSelected(Uri uri, long rawContactId); public void onRawContactSelected(Uri uri, long rawContactId, boolean isReadOnly); } /** Loading Loading @@ -379,6 +379,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O private View mAccountHeaderContainer; private TextView mAccountHeaderType; private TextView mAccountHeaderName; private ImageView mAccountHeaderIcon; // Account selector private View mAccountSelectorContainer; Loading Loading @@ -429,6 +430,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O mAccountHeaderContainer = findViewById(R.id.account_container); mAccountHeaderType = (TextView) findViewById(R.id.account_type); mAccountHeaderName = (TextView) findViewById(R.id.account_name); mAccountHeaderIcon = (ImageView) findViewById(R.id.account_type_icon); // Account selector mAccountSelectorContainer = findViewById(R.id.account_selector_container); Loading Loading @@ -793,6 +795,10 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O } mAccountHeaderType.setText(accountInfo.second); final AccountType primaryAccountType = mPrimaryRawContactDelta.getRawContactAccountType( getContext()); mAccountHeaderIcon.setImageDrawable(primaryAccountType.getDisplayIcon(getContext())); mAccountHeaderContainer.setContentDescription( EditorUiUtils.getAccountInfoContentDescription( accountInfo.first, accountInfo.second)); Loading Loading @@ -875,19 +881,19 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O public void onItemClick(AdapterView<?> parent, View view, int position, long id) { UiClosables.closeQuietly(popup); final RawContactDelta rawContactDelta = adapter.getItem(position); if (mListener != null) { final long rawContactId = adapter.getItemId(position); final Uri rawContactUri = ContentUris.withAppendedId( ContactsContract.RawContacts.CONTENT_URI, rawContactId); // Start new activity for the raw contact in selected account. final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT); intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE); ArrayList<ContentValues> values = rawContactDelta.getContentValues(); intent.putExtra(ContactsContract.Intents.Insert.DATA, values); final RawContactDelta rawContactDelta = adapter.getItem(position); final AccountTypeManager accountTypes = AccountTypeManager.getInstance( getContext()); final AccountType accountType = rawContactDelta.getAccountType( accountTypes); final boolean isReadOnly = !accountType.areContactsWritable(); if (mListener != null) { mListener.onRawContactSelected(rawContactUri, rawContactId); mListener.onRawContactSelected(rawContactUri, rawContactId, isReadOnly); } } }); Loading
src/com/android/contacts/editor/ContactEditorBaseFragment.java +26 −2 Original line number Diff line number Diff line Loading @@ -128,6 +128,8 @@ abstract public class ContactEditorBaseFragment extends Fragment implements private static final String KEY_IS_EDIT = "isEdit"; private static final String KEY_EXISTING_CONTACT_READY = "existingContactDataReady"; private static final String KEY_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY = "isReadOnly"; // Phone option menus private static final String KEY_SEND_TO_VOICE_MAIL_STATE = "sendToVoicemailState"; private static final String KEY_ARE_PHONE_OPTIONS_CHANGEABLE = "arePhoneOptionsChangable"; Loading Loading @@ -182,6 +184,13 @@ abstract public class ContactEditorBaseFragment extends Fragment implements */ public static final String INTENT_EXTRA_PHOTO_ID = "photo_id"; /** * Intent key to pass the boolean value of if the raw contact id that should be displayed * in the full editor by itself is read-only. */ public static final String INTENT_EXTRA_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY = "raw_contact_display_alone_is_read_only"; /** * Intent extra to specify a {@link ContactEditor.SaveMode}. */ Loading Loading @@ -335,6 +344,7 @@ abstract public class ContactEditorBaseFragment extends Fragment implements // protected RawContactDeltaList mState; protected int mStatus; protected boolean mRawContactDisplayAloneIsReadOnly = false; // Whether to show the new contact blank form and if it's corresponding delta is ready. protected boolean mHasNewContact; Loading Loading @@ -474,6 +484,8 @@ abstract public class ContactEditorBaseFragment extends Fragment implements // Read state from savedState. No loading involved here mState = savedState.<RawContactDeltaList> getParcelable(KEY_EDIT_STATE); mStatus = savedState.getInt(KEY_STATUS); mRawContactDisplayAloneIsReadOnly = savedState.getBoolean( KEY_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY); mHasNewContact = savedState.getBoolean(KEY_HAS_NEW_CONTACT); mNewContactDataReady = savedState.getBoolean(KEY_NEW_CONTACT_READY); Loading Loading @@ -598,6 +610,8 @@ abstract public class ContactEditorBaseFragment extends Fragment implements outState.putBoolean(KEY_NEW_CONTACT_ACCOUNT_CHANGED, mNewContactAccountChanged); outState.putBoolean(KEY_IS_EDIT, mIsEdit); outState.putBoolean(KEY_EXISTING_CONTACT_READY, mExistingContactDataReady); outState.putBoolean(KEY_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY, mRawContactDisplayAloneIsReadOnly); outState.putBoolean(KEY_IS_USER_PROFILE, mIsUserProfile); Loading Loading @@ -764,6 +778,9 @@ abstract public class ContactEditorBaseFragment extends Fragment implements helpMenu.setVisible(false); } // Save menu is invisible when there's only one read only contact in the editor. saveMenu.setVisible(!mRawContactDisplayAloneIsReadOnly); // Hide telephony-related settings (ringtone, send to voicemail) // if we don't have a telephone or are editing a new contact. sendToVoiceMailMenu.setChecked(mSendToVoicemailState); Loading Loading @@ -1337,6 +1354,8 @@ abstract public class ContactEditorBaseFragment extends Fragment implements mIntentExtras.getInt(INTENT_EXTRA_MATERIAL_PALETTE_SECONDARY_COLOR)); } mPhotoId = mIntentExtras.getLong(INTENT_EXTRA_PHOTO_ID); mRawContactDisplayAloneIsReadOnly = mIntentExtras.getBoolean( INTENT_EXTRA_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY); } } Loading Loading @@ -1375,8 +1394,7 @@ abstract public class ContactEditorBaseFragment extends Fragment implements } } switch (saveMode) { case SaveMode.CLOSE: case SaveMode.COMPACT: { case SaveMode.CLOSE: { final Intent resultIntent; if (saveSucceeded && contactLookupUri != null) { final Uri lookupUri = maybeConvertToLegacyLookupUri( Loading @@ -1391,6 +1409,12 @@ abstract public class ContactEditorBaseFragment extends Fragment implements if (mListener != null) mListener.onSaveFinished(resultIntent); break; } case SaveMode.COMPACT: { // It is already saved, so prevent it from being saved again mStatus = Status.CLOSING; if (mListener != null) mListener.onSaveFinished(/* resultIntent= */ null); break; } case SaveMode.RELOAD: case SaveMode.JOIN: if (saveSucceeded && contactLookupUri != null) { Loading
src/com/android/contacts/editor/ContactEditorFragment.java +7 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.widget.ListPopupWindow; import com.android.contacts.ContactSaveService; import com.android.contacts.R; import com.android.contacts.activities.ContactEditorActivity; import com.android.contacts.activities.ContactEditorBaseActivity.ContactEditor; import com.android.contacts.common.model.AccountTypeManager; import com.android.contacts.common.model.RawContactDelta; import com.android.contacts.common.model.RawContactDeltaList; Loading Loading @@ -168,6 +169,8 @@ public class ContactEditorFragment extends ContactEditorBaseFragment implements public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { return revert(); } else if (item.getItemId() == R.id.menu_save && mRawContactIdToDisplayAlone != -1) { return super.save(SaveMode.COMPACT); } return super.onOptionsItemSelected(item); } Loading Loading @@ -354,7 +357,7 @@ public class ContactEditorFragment extends ContactEditorBaseFragment implements private void bindPhotoHandler(BaseRawContactEditorView editor, AccountType type, RawContactDeltaList state) { final int mode; final boolean showIsPrimaryOption; boolean showIsPrimaryOption; if (type.areContactsWritable()) { if (editor.hasSetPhoto()) { mode = PhotoActionPopup.Modes.WRITE_ABLE_PHOTO; Loading @@ -372,6 +375,9 @@ public class ContactEditorFragment extends ContactEditorBaseFragment implements editor.getPhotoEditor().setShowPrimary(false); return; } if (mRawContactIdToDisplayAlone != -1) { showIsPrimaryOption = false; } final PhotoHandler photoHandler = new PhotoHandler(mContext, editor, mode, state); editor.getPhotoEditor().setEditorListener( (PhotoHandler.PhotoEditorListener) photoHandler.getListener()); Loading