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

Commit c4f3f498 authored by Alina Zaidi's avatar Alina Zaidi
Browse files

Fix bugs for Widgets picker Search UI.

- On orientation change, clear search bar.
- Change text and search bar color to make similar to mocks/ all apps search bar.
- Fix search recycler view visual bugs.
- If back is pressed in search mode, exit search mode instead of exiting widget picker.

Test: Manually seen widget picker on phone.
Bug: 183103133
Bug: 183103936
Bug: 183115050
Bug: 157286785
Change-Id: I056f089eada84d00133038f4a3d7b18bc51be564
parent cb76e7d1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -14,6 +14,6 @@
     limitations under the License.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <solid android:color="#FFFFF7" />
    <solid android:color="?android:attr/textColorPrimaryInverse" />
    <corners android:radius="24dp" />
</shape>
 No newline at end of file
+4 −1
Original line number Diff line number Diff line
@@ -19,12 +19,15 @@
        android:hint="@string/widgets_full_sheet_search_bar_hint"
        android:maxLines="1"
        android:layout_weight="1"
        android:inputType="text"/>
        android:inputType="text"
        android:textColor="?android:attr/textColorSecondary"
        android:textColorHint="?android:attr/textColorTertiary"/>

    <ImageButton
        android:id="@+id/widgets_search_cancel_button"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:padding="8dp"
        android:src="@drawable/ic_gm_close_24"
        android:background="?android:selectableItemBackground"
        android:layout_gravity="center"
+21 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.PropertyValuesHolder;
import android.content.Context;
import android.content.pm.LauncherApps;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.Process;
import android.os.UserHandle;
@@ -232,6 +233,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet
        mInsets.set(insets);

        setBottomPadding(mAdapters.get(AdapterHolder.PRIMARY).mWidgetsRecyclerView, insets.bottom);
        setBottomPadding(mAdapters.get(AdapterHolder.SEARCH).mWidgetsRecyclerView, insets.bottom);
        if (mHasWorkProfile) {
            setBottomPadding(mAdapters.get(AdapterHolder.WORK).mWidgetsRecyclerView, insets.bottom);
        }
@@ -276,6 +278,8 @@ public class WidgetsFullSheet extends BaseWidgetSheet
        int maxSpansPerRow = getMeasuredWidth() / (deviceProfile.cellWidthPx + paddingPx);
        mAdapters.get(AdapterHolder.PRIMARY).mWidgetsListAdapter.setMaxHorizontalSpansPerRow(
                maxSpansPerRow);
        mAdapters.get(AdapterHolder.SEARCH).mWidgetsListAdapter.setMaxHorizontalSpansPerRow(
                maxSpansPerRow);
        if (mHasWorkProfile) {
            mAdapters.get(AdapterHolder.WORK).mWidgetsListAdapter.setMaxHorizontalSpansPerRow(
                    maxSpansPerRow);
@@ -471,6 +475,23 @@ public class WidgetsFullSheet extends BaseWidgetSheet
                + marginLayoutParams.topMargin;
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        if (mIsInSearchMode) {
            mSearchAndRecommendationViewHolder.mSearchBar.reset();
        }
    }

    @Override
    public boolean onBackPressed() {
        if (mIsInSearchMode) {
            mSearchAndRecommendationViewHolder.mSearchBar.reset();
            return true;
        }
        return super.onBackPressed();
    }

    /** A holder class for holding adapters & their corresponding recycler view. */
    private final class AdapterHolder {
        static final int PRIMARY = 0;
+5 −0
Original line number Diff line number Diff line
@@ -62,6 +62,11 @@ public class LauncherWidgetsSearchBar extends LinearLayout implements WidgetsSea
                algo, mEditText, mCancelButton, searchModeListener);
    }

    @Override
    public void reset() {
        mController.clearSearchResult();
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
+5 −0
Original line number Diff line number Diff line
@@ -29,6 +29,11 @@ public interface WidgetsSearchBar {
     */
    void initialize(List<WidgetsListBaseEntry> allWidgets, SearchModeListener searchModeListener);

    /**
     * Clears search bar.
     */
    void reset();

    /**
     * Sets the vertical location, in pixels, of this search bar relative to its top position.
     */