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

Commit d375c35c authored by Wenyi Wang's avatar Wenyi Wang
Browse files

Update content description after updating primary

Here's what went wrong: we set content description of photos in
CompactRawContactsEditorView.getPhotos() (see ag/834274) and then
we modify "primary" before entering photo picker (see ag/854600).

We need to update content description of photos after modifying
"primary" to reflect the change in which photo is checked.

Bug 27881948

Change-Id: Iad9723c9adbeaf8396fc46c578cc4a519d9ba85a
(cherry picked from commit 5a59c26c4e43fedcd449dfae97ea435f1ce885e3)
parent 8b9ef579
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -261,6 +261,25 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl
            } else {
                photo.primary = false;
            }
            updateContentDescription(photo);
        }
    }

    private void updateContentDescription(CompactPhotoSelectionFragment.Photo photo) {
        if (!TextUtils.isEmpty(photo.accountType)) {
            photo.contentDescription = getResources().getString(photo.primary ?
                            R.string.photo_view_description_checked :
                            R.string.photo_view_description_not_checked,
                    photo.accountType, photo.accountName);
            photo.contentDescriptionChecked = getResources().getString(
                    R.string.photo_view_description_checked,
                    photo.accountType, photo.accountName);
        } else {
            photo.contentDescription = getResources().getString(photo.primary ?
                    R.string.photo_view_description_checked_no_info :
                    R.string.photo_view_description_not_checked_no_info);
            photo.contentDescriptionChecked = getResources().getString(
                    R.string.photo_view_description_checked_no_info);
        }
    }

+2 −0
Original line number Diff line number Diff line
@@ -95,6 +95,8 @@ public class CompactPhotoSelectionFragment extends Fragment {

        public String contentDescription;
        public String contentDescriptionChecked; // Talkback announcement when the photo is checked
        public String accountType;
        public String accountName;

        public ValuesDelta valuesDelta;

+4 −21
Original line number Diff line number Diff line
@@ -554,27 +554,10 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
                            kindSectionData.getRawContactDelta().getRawContactId()));
                }

                // set content descriptions of the photo
                final CharSequence accountTypeText = accountType.getDisplayLabel(getContext());
                if (accountTypeText != null) {
                    final String accountNameText =
                            kindSectionData.getRawContactDelta().getAccountName();
                    photo.contentDescription = getResources().getString(photo.primary ?
                                    R.string.photo_view_description_checked :
                                    R.string.photo_view_description_not_checked,
                            accountTypeText,
                            accountNameText == null ? "" : accountNameText);
                    photo.contentDescriptionChecked = getResources().getString(
                            R.string.photo_view_description_checked,
                            accountTypeText,
                            accountNameText == null ? "" : accountNameText);
                } else {
                    photo.contentDescription = getResources().getString(photo.primary ?
                            R.string.photo_view_description_checked_no_info :
                            R.string.photo_view_description_not_checked_no_info);
                    photo.contentDescriptionChecked = getResources().getString(
                            R.string.photo_view_description_checked_no_info);
                }
                final CharSequence accountTypeLabel = accountType.getDisplayLabel(getContext());
                photo.accountType = accountTypeLabel == null ? "" : accountTypeLabel.toString();
                final String accountName = kindSectionData.getRawContactDelta().getAccountName();
                photo.accountName = accountName == null ? "" : accountName;

                photos.add(photo);
            }