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

Commit 96e87fd6 authored by Daniel Lehmann's avatar Daniel Lehmann
Browse files

Use existence of editor as indicator whether source is editable.

Bug:3093621

Change-Id: I3ba344667ce1b0f2da6847d783c0ac90f36ebd8f
parent 4b70a37f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -551,7 +551,7 @@ public class ContactDetailFragment extends Fragment implements FragmentKeyListen
                mRawContactIds.add(rawContactId);
            }
            AccountType type = accountTypes.getAccountType(accountType, dataSet);
            if (type == null || !type.readOnly) {
            if (type == null || type.areContactsWritable()) {
                mWritableRawContactIds.add(rawContactId);
            }

@@ -1944,7 +1944,7 @@ public class ContactDetailFragment extends Fragment implements FragmentKeyListen
                    AccountTypeManager.getInstance(mContext);
            final AccountType type = accountTypes.getAccountType(accountType, dataSet);
            // Offline or non-writeable account? Nothing to fix
            if (type == null || type.readOnly) return false;
            if (type == null || !type.areContactsWritable()) return false;

            // Check whether the contact is in the default group
            boolean isInDefaultGroup = false;
+1 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ public class AggregationSuggestionView extends LinearLayout {
                return true;
            }
            AccountType type = accountTypes.getAccountType(accountType, dataSet);
            if (!type.readOnly) {
            if (type.areContactsWritable()) {
                return true;
            }
        }
+16 −16
Original line number Diff line number Diff line
@@ -519,7 +519,7 @@ public class ContactEditorFragment extends Fragment implements
            final String accountType = state.getValues().getAsString(RawContacts.ACCOUNT_TYPE);
            final String dataSet = state.getValues().getAsString(RawContacts.DATA_SET);
            final AccountType type = accountTypes.getAccountType(accountType, dataSet);
            if (!type.readOnly) {
            if (type.areContactsWritable()) {
                // Apply extras to the first writable raw contact only
                EntityModifier.parseExtras(mContext, type, state, extras);
                break;
@@ -698,7 +698,7 @@ public class ContactEditorFragment extends Fragment implements
            editor.setState(entity, type, mViewIdGenerator, isEditingUserProfile());

            editor.getPhotoEditor().setEditorListener(
                    new PhotoEditorListener(editor, type.readOnly));
                    new PhotoEditorListener(editor, type.areContactsWritable()));
            if (editor instanceof RawContactEditorView) {
                final RawContactEditorView rawContactEditor = (RawContactEditorView) editor;
                EditorListener listener = new EditorListener() {
@@ -1154,7 +1154,7 @@ public class ContactEditorFragment extends Fragment implements
            final String accountType = values.getAsString(RawContacts.ACCOUNT_TYPE);
            final String dataSet = values.getAsString(RawContacts.DATA_SET);
            final AccountType type = accountTypes.getAccountType(accountType, dataSet);
            if (!type.readOnly) {
            if (type.areContactsWritable()) {
                return true;
            }
        }
@@ -1234,9 +1234,9 @@ public class ContactEditorFragment extends Fragment implements
            final AccountType type2 = accountTypes.getAccountType(accountType2, dataSet2);

            // Check read-only
            if (type1.readOnly && !type2.readOnly) {
            if (!type1.areContactsWritable() && type2.areContactsWritable()) {
                return 1;
            } else if (!type1.readOnly && type2.readOnly) {
            } else if (type1.areContactsWritable() && !type2.areContactsWritable()) {
                return -1;
            }

@@ -1693,11 +1693,11 @@ public class ContactEditorFragment extends Fragment implements
    private final class PhotoEditorListener
            implements EditorListener, PhotoActionPopup.Listener {
        private final BaseRawContactEditorView mEditor;
        private final boolean mAccountReadOnly;
        private final boolean mAccountWritable;

        private PhotoEditorListener(BaseRawContactEditorView editor, boolean accountReadOnly) {
        private PhotoEditorListener(BaseRawContactEditorView editor, boolean accountWritable) {
            mEditor = editor;
            mAccountReadOnly = accountReadOnly;
            mAccountWritable = accountWritable;
        }

        @Override
@@ -1707,14 +1707,7 @@ public class ContactEditorFragment extends Fragment implements
            if (request == EditorListener.REQUEST_PICK_PHOTO) {
                // Determine mode
                final int mode;
                if (mAccountReadOnly) {
                    if (mEditor.hasSetPhoto() && hasMoreThanOnePhoto()) {
                        mode = PhotoActionPopup.MODE_READ_ONLY_ALLOW_PRIMARY;
                    } else {
                        // Read-only and either no photo or the only photo ==> no options
                        return;
                    }
                } else {
                if (mAccountWritable) {
                    if (mEditor.hasSetPhoto()) {
                        if (hasMoreThanOnePhoto()) {
                            mode = PhotoActionPopup.MODE_PHOTO_ALLOW_PRIMARY;
@@ -1724,6 +1717,13 @@ public class ContactEditorFragment extends Fragment implements
                    } else {
                        mode = PhotoActionPopup.MODE_NO_PHOTO;
                    }
                } else {
                    if (mEditor.hasSetPhoto() && hasMoreThanOnePhoto()) {
                        mode = PhotoActionPopup.MODE_READ_ONLY_ALLOW_PRIMARY;
                    } else {
                        // Read-only and either no photo or the only photo ==> no options
                        return;
                    }
                }
                PhotoActionPopup.createPopupMenu(mContext, mEditor.getPhotoEditor(), this, mode)
                        .show();
+6 −6
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ public class ExternalRawContactEditorView extends BaseRawContactEditorView
            boolean hasPhotoEditor = type.getKindForMimetype(Photo.CONTENT_ITEM_TYPE) != null;
            setHasPhotoEditor(hasPhotoEditor);
            primary = state.getPrimaryEntry(Photo.CONTENT_ITEM_TYPE);
            getPhotoEditor().setValues(kind, primary, state, type.readOnly, vig);
            getPhotoEditor().setValues(kind, primary, state, !type.areContactsWritable(), vig);
            if (!hasPhotoEditor || !getPhotoEditor().hasSetPhoto()) {
                mPhotoStub.setVisibility(View.GONE);
            } else {
@@ -187,7 +187,11 @@ public class ExternalRawContactEditorView extends BaseRawContactEditorView
        mName.setText(primary != null ? primary.getAsString(StructuredName.DISPLAY_NAME) :
                mContext.getString(R.string.missing_name));

        if (type.readOnly) {
        if (type.areContactsWritable()) {
            mAccountContainer.setBackgroundDrawable(null);
            mAccountContainer.setEnabled(false);
            mEditExternallyButton.setVisibility(View.VISIBLE);
        } else {
            mAccountContainer.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
@@ -196,10 +200,6 @@ public class ExternalRawContactEditorView extends BaseRawContactEditorView
                }
            });
            mEditExternallyButton.setVisibility(View.GONE);
        } else {
            mAccountContainer.setBackgroundDrawable(null);
            mAccountContainer.setEnabled(false);
            mEditExternallyButton.setVisibility(View.VISIBLE);
        }

        final Resources res = mContext.getResources();
+4 −4
Original line number Diff line number Diff line
@@ -240,11 +240,11 @@ public class ContactDeletionInteraction extends Fragment
            contactId = cursor.getLong(COLUMN_INDEX_CONTACT_ID);
            lookupKey = cursor.getString(COLUMN_INDEX_LOOKUP_KEY);
            AccountType type = accountTypes.getAccountType(accountType, dataSet);
            boolean readonly = type != null && type.readOnly;
            if (readonly) {
                readOnlyRawContacts.add(rawContactId);
            } else {
            boolean writable = type == null || type.areContactsWritable();
            if (writable) {
                writableRawContacts.add(rawContactId);
            } else {
                readOnlyRawContacts.add(rawContactId);
            }
        }

Loading