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

Commit 71f45a10 authored by dantmnf's avatar dantmnf
Browse files

Trebuchet: Fix sorting in zh-Hans-CN

Sorting behavior is different in the exact locale "zh-CN", but newer
setups will have "zh-Hans-CN" and miss the locale-specific behavior.

P.S. "zh-CN" locale is no longer accessible in settings UI.

Change-Id: I59afe38e1ea2ac507ff017e855d9810092604e99
parent 4ca5f8af
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2023 The LineageOS Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<resources>
    <!-- Sort sections of apps list, in case AlphabeticIndex (of current locale)
         returns duplicate labels for some reasons. -->
    <bool name="config_appsListSortSections">true</bool>
</resources>
+4 −0
Original line number Diff line number Diff line
@@ -16,4 +16,8 @@
<resources>

    <string name="pref_show_google_now_summary" translatable="false">@string/msg_minus_one_on_left</string>

    <!-- Sort sections of apps list, in case AlphabeticIndex (of current locale)
         returns duplicate labels for some reasons. -->
    <bool name="config_appsListSortSections">false</bool>
</resources>
+4 −4
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.DiffUtil;

import com.android.launcher3.R;
import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfo;
@@ -28,7 +29,6 @@ import com.android.launcher3.views.ActivityContext;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.TreeMap;
import java.util.function.Predicate;
@@ -85,6 +85,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
    private final int mNumAppsPerRowAllApps;
    private int mNumAppRowsInAdapter;
    private Predicate<ItemInfo> mItemFilter;
    private final boolean mSortSections;

    public AlphabeticalAppsList(Context context, @Nullable AllAppsStore appsStore,
            WorkProfileManager workProfileManager) {
@@ -96,6 +97,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
        if (mAllAppsStore != null) {
            mAllAppsStore.addUpdateListener(this);
        }
        mSortSections = context.getResources().getBoolean(R.bool.config_appsListSortSections);
    }

    public void updateItemFilter(Predicate<ItemInfo> itemFilter) {
@@ -201,9 +203,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement

        // As a special case for some languages (currently only Simplified Chinese), we may need to
        // coalesce sections
        Locale curLocale = mActivityContext.getResources().getConfiguration().locale;
        boolean localeRequiresSectionSorting = curLocale.equals(Locale.SIMPLIFIED_CHINESE);
        if (localeRequiresSectionSorting) {
        if (mSortSections) {
            // Compute the section headers. We use a TreeMap with the section name comparator to
            // ensure that the sections are ordered when we iterate over it later
            appSteam = appSteam.collect(Collectors.groupingBy(