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

Commit 485693c9 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Trim all whitespace from titles and labels." into ub-launcher3-burnaby

parents 62227274 82b016cb
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -29,8 +29,7 @@ class AppNameComparator {
        mAppNameComparator = new Comparator<AppInfo>() {
            public final int compare(AppInfo a, AppInfo b) {
                // Order by the title
                int result = collator.compare(a.title.toString().trim(),
                        b.title.toString().trim());
                int result = collator.compare(a.title.toString(), b.title.toString());
                if (result == 0) {
                    // If two apps have the same title, then order by the component name
                    result = a.componentName.compareTo(b.componentName);
@@ -349,7 +348,7 @@ public class AlphabeticalAppsList {
        int appIndex = 0;
        int numApps = mApps.size();
        for (AppInfo info : mApps) {
            String sectionName = mIndexer.computeSectionName(info.title.toString().trim());
            String sectionName = mIndexer.computeSectionName(info.title);

            // Check if we want to retain this app
            if (mFilter != null && !mFilter.retainApp(info, sectionName)) {
+2 −2
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ public class AppInfo extends ItemInfo {
    public AppInfo(AppInfo info) {
        super(info);
        componentName = info.componentName;
        title = info.title.toString();
        title = Utilities.trim(info.title);
        intent = new Intent(info.intent);
        flags = info.flags;
        firstInstallTime = info.firstInstallTime;
@@ -114,7 +114,7 @@ public class AppInfo extends ItemInfo {

    @Override
    public String toString() {
        return "ApplicationInfo(title=" + title.toString() + " id=" + this.id
        return "ApplicationInfo(title=" + title + " id=" + this.id
                + " type=" + this.itemType + " container=" + this.container
                + " screen=" + screenId + " cellX=" + cellX + " cellY=" + cellY
                + " spanX=" + spanX + " spanY=" + spanY + " dropPos=" + Arrays.toString(dropPos)
+11 −7
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.widget.TextView;
import com.android.launcher3.util.Thunk;

import java.util.List;
import java.util.regex.Pattern;


/**
@@ -56,6 +57,8 @@ public class AppsContainerView extends BaseContainerView implements DragSource,
    private static final int FADE_OUT_DURATION = 100;
    private static final int SEARCH_TRANSLATION_X_DP = 18;

    private static final Pattern SPLIT_PATTERN = Pattern.compile("[\\s|\\p{javaSpaceChar}]+");

    @Thunk Launcher mLauncher;
    @Thunk AlphabeticalAppsList mApps;
    private AppsGridAdapter mAdapter;
@@ -430,23 +433,24 @@ public class AppsContainerView extends BaseContainerView implements DragSource,

    @Override
    public void afterTextChanged(final Editable s) {
        if (s.toString().isEmpty()) {
        String queryText = s.toString();
        if (queryText.isEmpty()) {
            mApps.setFilter(null);
        } else {
            String formatStr = getResources().getString(R.string.apps_view_no_search_results);
            mAdapter.setEmptySearchText(String.format(formatStr, s.toString()));
            mAdapter.setEmptySearchText(String.format(formatStr, queryText));

            final String filterText = s.toString().toLowerCase().replaceAll("\\s+", "");
            final String queryTextLower = queryText.toLowerCase();
            mApps.setFilter(new AlphabeticalAppsList.Filter() {
                @Override
                public boolean retainApp(AppInfo info, String sectionName) {
                    String title = info.title.toString();
                    if (sectionName.toLowerCase().contains(filterText)) {
                    if (sectionName.toLowerCase().contains(queryTextLower)) {
                        return true;
                    }
                    String[] words = title.toLowerCase().split("\\s+");
                    String title = info.title.toString();
                    String[] words = SPLIT_PATTERN.split(title.toLowerCase());
                    for (int i = 0; i < words.length; i++) {
                        if (words[i].startsWith(filterText)) {
                        if (words[i].startsWith(queryTextLower)) {
                            return true;
                        }
                    }
+3 −2
Original line number Diff line number Diff line
@@ -309,13 +309,14 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
        mFolderName.setHint(sHintText);
        // Convert to a string here to ensure that no other state associated with the text field
        // gets saved.
        String newTitle = mFolderName.getText().toString();
        CharSequence newTitle = mFolderName.getText();
        mInfo.setTitle(newTitle);
        LauncherModel.updateItemInDatabase(mLauncher, mInfo);

        if (commit) {
            sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
                    String.format(getContext().getString(R.string.folder_renamed), newTitle));
                    String.format(getContext().getString(R.string.folder_renamed),
                            newTitle.toString()));
        }
        // In order to clear the focus from the text field, we set the focus on ourself. This
        // ensures that every time the field is clicked, focus is gained, giving reliable behavior.
+1 −1
Original line number Diff line number Diff line
@@ -710,7 +710,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
    }

    public void onTitleChanged(CharSequence title) {
        mFolderName.setText(title.toString());
        mFolderName.setText(title);
        setContentDescription(String.format(getContext().getString(R.string.folder_name_format),
                title));
    }
Loading