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

Commit df1ccbdc authored by Mihai Nita's avatar Mihai Nita
Browse files

Update the title when going back from region selection

Since the title in the region selector should be the language name,
the standard Preference logic is bypassed. So the normal Preference
implementation cannot update the title automatically.
This makes sure we set the title at the right time.

Bug: 26715311
Change-Id: Ifa3d70b8504b093ae17baba8c179ebf55e3c7be2
parent 8e9316cd
Loading
Loading
Loading
Loading
+15 −14
Original line number Diff line number Diff line
@@ -138,22 +138,12 @@ public class LocalePickerWithRegion extends ListFragment implements SearchView.O
        super.onCreate(savedInstanceState);
        setHasOptionsMenu(true);

        Locale sortingLocale;
        if (mCountryMode) {
            if (mParentLocale == null) {
                sortingLocale = Locale.getDefault();
                this.getActivity().setTitle(R.string.country_selection_title);
            } else {
                sortingLocale = mParentLocale.getLocale();
                this.getActivity().setTitle(mParentLocale.getFullNameNative());
            }
        } else {
            sortingLocale = Locale.getDefault();
            this.getActivity().setTitle(R.string.language_selection_title);
        }
        final Locale sortingLocale = (mCountryMode && mParentLocale != null)
                ? mParentLocale.getLocale()
                : Locale.getDefault();

        mAdapter = new SuggestedLocaleAdapter(mLocaleList, mCountryMode);
        LocaleHelper.LocaleInfoComparator comp =
        final LocaleHelper.LocaleInfoComparator comp =
                new LocaleHelper.LocaleInfoComparator(sortingLocale);
        mAdapter.sort(comp);
        setListAdapter(mAdapter);
@@ -173,6 +163,17 @@ public class LocalePickerWithRegion extends ListFragment implements SearchView.O
    @Override
    public void onResume() {
        super.onResume();

        if (mCountryMode) {
            if (mParentLocale == null) {
                this.getActivity().setTitle(R.string.country_selection_title);
            } else {
                this.getActivity().setTitle(mParentLocale.getFullNameNative());
            }
        } else {
            this.getActivity().setTitle(R.string.language_selection_title);
        }

        getListView().requestFocus();
    }