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

Commit 6bab5112 authored by Zoey Chen's avatar Zoey Chen Committed by Android (Google) Code Review
Browse files

Merge "[Settings] Should create header again when adding it to the listview" into main

parents d3fc95aa 291e4960
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.preference.Preference;

import com.android.internal.app.LocaleHelper;
@@ -62,6 +63,7 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
    private LayoutPreference mPrefOfDescription;
    private Preference mPrefOfDisclaimer;
    private ApplicationInfo mApplicationInfo;
    @Nullable private String mParentLocale;

    /**
     * Create a instance of AppLocaleDetails.
@@ -111,6 +113,12 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
    public void onResume() {
        super.onResume();
        refreshUi();
        final Activity activity = getActivity();
        if (mParentLocale != null) {
            activity.setTitle(mParentLocale);
        } else {
            activity.setTitle(R.string.app_locale_picker_title);
        }
    }

    private void refreshUi() {
@@ -215,4 +223,8 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
            return LocaleHelper.getDisplayName(appLocale.stripExtensions(), appLocale, true);
        }
    }

    public void setParentLocale(@Nullable String localeName) {
        mParentLocale = localeName;
    }
}
+13 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.view.View;
import android.widget.FrameLayout;
import android.widget.ListView;

import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
import androidx.core.view.ViewCompat;

@@ -67,6 +68,7 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
    private View mAppLocaleDetailContainer;
    private NotificationController mNotificationController;
    private MetricsFeatureProvider mMetricsFeatureProvider;
    @Nullable private String mParentLocale;

    @Override
    public void onCreate(Bundle savedInstanceState) {
@@ -129,6 +131,11 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
        finish();
    }

    @Override
    public void onParentLocaleSelected(LocaleStore.LocaleInfo localeInfo) {
        mParentLocale = localeInfo.getFullNameNative();
    }

    @Override
    public boolean onMenuItemActionCollapse(MenuItem item) {
        mAppBarLayout.setExpanded(false /*expanded*/, false /*animate*/);
@@ -258,6 +265,12 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
                        super.onFragmentViewCreated(fm, f, v, s);
                        ListView listView = (ListView) v.findViewById(android.R.id.list);
                        if (listView != null) {
                            if (mParentLocale != null) {
                                mAppLocaleDetails = AppLocaleDetails.newInstance(mPackageName,
                                        getUserId());
                                mAppLocaleDetailContainer = launchAppLocaleDetailsPage();
                                mAppLocaleDetails.setParentLocale(mParentLocale);
                            }
                            listView.addHeaderView(mAppLocaleDetailContainer);
                        }
                    }