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

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

am 09fe43f7: Merge "Delay loading groups until compact editors are bound...

am 09fe43f7: Merge "Delay loading groups until compact editors are bound (E14)" into ub-contactsdialer-a-dev

* commit '09fe43f7':
  Delay loading groups until compact editors are bound (E14)
parents 2bb68a7b 09fe43f7
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -365,6 +365,11 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl
        }
    }

    @Override
    public void onEditorsBound() {
        getLoaderManager().initLoader(LOADER_GROUPS, null, mGroupsLoaderListener);
    }

    private CompactRawContactsEditorView getContent() {
        return (CompactRawContactsEditorView) mContent;
    }
+18 −27
Original line number Diff line number Diff line
@@ -109,6 +109,11 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
         * Invoked when no editors could be bound for the contact.
         */
        public void onBindEditorsFailed();

        /**
         * Invoked after editors have been bound for the contact.
         */
        public void onEditorsBound();
    }

    /** Used to sort entire kind sections. */
@@ -360,8 +365,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.more_fields) {
            showMoreFields();
            updateMoreFieldsButton();
            showAllFields();
        }
    }

@@ -391,8 +395,8 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
        final SavedState savedState = (SavedState) state;
        super.onRestoreInstanceState(savedState.getSuperState());
        mIsExpanded = savedState.mIsExpanded;
        if (mIsExpanded && !mKindSectionDataMap.isEmpty()) {
            showMoreFields();
        if (mIsExpanded) {
            showAllFields();
        }
    }

@@ -445,20 +449,17 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
                GroupMembership.CONTENT_ITEM_TYPE);
        for (CompactKindSectionView kindSectionView : kindSectionViews) {
            kindSectionView.setGroupMetaData(groupMetaData);
        }

        // Groups metadata may be set after we restore expansion state so just do it again
            if (mIsExpanded) {
            showMoreFields();
                kindSectionView.setHideWhenEmpty(false);
                kindSectionView.updateEmptyEditors(/* shouldAnimate =*/ true);
            }
        }
        updateMoreFieldsButton();
    }

    public void setState(RawContactDeltaList rawContactDeltas,
            MaterialColorMapUtils.MaterialPalette materialPalette, ViewIdGenerator viewIdGenerator,
            long photoId, boolean hasNewContact, boolean isUserProfile,
            AccountWithDataSet primaryAccount) {
        // Clear previous state and reset views
        mKindSectionDataMap.clear();
        mKindSectionViews.removeAllViews();
        mMoreFields.setVisibility(View.VISIBLE);
@@ -488,13 +489,15 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
        }

        // Setup the view
        setId(mViewIdGenerator.getId(rawContactDeltas.get(0), /* dataKind =*/ null,
                /* valuesDelta =*/ null, ViewIdGenerator.NO_VIEW_INDEX));
        addAccountInfo();
        addPhotoView();
        addKindSectionViews();

        updateMoreFieldsButton();
        if (mIsExpanded) {
            showAllFields();
        }

        if (mListener != null) mListener.onEditorsBound();
    }

    private void parseRawContactDeltas(RawContactDeltaList rawContactDeltas,
@@ -836,7 +839,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
        return kindSectionView;
    }

    private void showMoreFields() {
    private void showAllFields() {
        // Stop hiding empty editors and allow the user to enter values for all kinds now
        for (int i = 0; i < mKindSectionViews.getChildCount(); i++) {
            final CompactKindSectionView kindSectionView =
@@ -845,19 +848,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
            kindSectionView.updateEmptyEditors(/* shouldAnimate =*/ true);
        }
        mIsExpanded = true;
    }

    private void updateMoreFieldsButton() {
        // If any kind section views are hidden then show the link
        for (int i = 0; i < mKindSectionViews.getChildCount(); i++) {
            final CompactKindSectionView kindSectionView =
                    (CompactKindSectionView) mKindSectionViews.getChildAt(i);
            if (kindSectionView.getVisibility() == View.GONE) {
                // Show the more fields button
                mMoreFields.setVisibility(View.VISIBLE);
                return;
            }
        }
        // Hide the more fields button
        mMoreFields.setVisibility(View.GONE);
    }
+10 −16
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ abstract public class ContactEditorBaseFragment extends Fragment implements

    static final String TAG = "ContactEditor";

    protected static final int LOADER_DATA = 1;
    protected static final int LOADER_CONTACT = 1;
    protected static final int LOADER_GROUPS = 2;

    private static final List<String> VALID_INTENT_ACTIONS = new ArrayList<String>() {{
@@ -366,7 +366,7 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
    /**
     * The contact data loader listener.
     */
    protected final LoaderManager.LoaderCallbacks<Contact> mDataLoaderListener =
    protected final LoaderManager.LoaderCallbacks<Contact> mContactLoaderListener =
            new LoaderManager.LoaderCallbacks<Contact>() {

                protected long mLoaderStartTime;
@@ -405,9 +405,9 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
            };

    /**
     * The group meta data loader listener.
     * The groups meta data loader listener.
     */
    protected final LoaderManager.LoaderCallbacks<Cursor> mGroupLoaderListener =
    protected final LoaderManager.LoaderCallbacks<Cursor> mGroupsLoaderListener =
            new LoaderManager.LoaderCallbacks<Cursor>() {

                @Override
@@ -507,11 +507,11 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
            // database.
            if (Intent.ACTION_EDIT.equals(mAction) ||
                    ContactEditorBaseActivity.ACTION_EDIT.equals(mAction)) {
                // Either...
                // Either
                // 1) orientation change but load never finished.
                // or
                // 2) not an orientation change.  data needs to be loaded for first time.
                getLoaderManager().initLoader(LOADER_DATA, null, mDataLoaderListener);
                // 2) not an orientation change so data needs to be loaded for first time.
                getLoaderManager().initLoader(LOADER_CONTACT, null, mContactLoaderListener);
                getLoaderManager().initLoader(LOADER_GROUPS, null, mGroupsLoaderListener);
            }
        } else {
            // Orientation change, we already have mState, it was loaded by onCreate
@@ -559,12 +559,6 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
                "Unknown action " + action + "; Supported actions: " + VALID_INTENT_ACTIONS);
    }

    @Override
    public void onStart() {
        getLoaderManager().initLoader(LOADER_GROUPS, null, mGroupLoaderListener);
        super.onStart();
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        outState.putString(KEY_ACTION, mAction);
@@ -898,7 +892,7 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
        // If we are about to close the editor - there is no need to refresh the data
        if (saveMode == SaveMode.CLOSE || saveMode == SaveMode.COMPACT
                || saveMode == SaveMode.SPLIT) {
            getLoaderManager().destroyLoader(LOADER_DATA);
            getLoaderManager().destroyLoader(LOADER_CONTACT);
        }

        mStatus = Status.SAVING;
@@ -1360,7 +1354,7 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
                    mState = new RawContactDeltaList();
                    load(Intent.ACTION_EDIT, contactLookupUri, null);
                    mStatus = Status.LOADING;
                    getLoaderManager().restartLoader(LOADER_DATA, null, mDataLoaderListener);
                    getLoaderManager().restartLoader(LOADER_CONTACT, null, mContactLoaderListener);
                }
                break;

+6 −0
Original line number Diff line number Diff line
@@ -114,6 +114,12 @@ public class ContactEditorFragment extends ContactEditorBaseFragment implements
        }
    }

    @Override
    public void onStart() {
        getLoaderManager().initLoader(LOADER_GROUPS, null, mGroupsLoaderListener);
        super.onStart();
    }

    @Override
    public void onExternalEditorRequest(AccountWithDataSet account, Uri uri) {
        if (mListener != null) {