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

Commit 8318a4ce authored by paphonb's avatar paphonb Committed by Bruno Martins
Browse files

Launcher3: Fix launcher preview rendering



Signed-off-by: default avatarHarsh Shandilya <msfjarvis@gmail.com>
Change-Id: I8c6fc263a3021f3ff929bc75b2730962b29d3758
Signed-off-by: default avatarDennySPB <dennyspb@gmail.com>
parent 83fa69f5
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import com.android.launcher3.allapps.SearchUiManager;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.graphics.TintedDrawableSpan;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.views.ActivityContext;

import java.util.ArrayList;

@@ -61,6 +62,7 @@ public class AppsSearchContainerLayout extends ExtendedEditText


    private final Launcher mLauncher;
    private final ActivityContext mActivity;
    private final AllAppsSearchBarController mSearchBarController;
    private final SpannableStringBuilder mSearchQueryBuilder;

@@ -82,7 +84,8 @@ public class AppsSearchContainerLayout extends ExtendedEditText
    public AppsSearchContainerLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        mLauncher = Launcher.getLauncher(context);
        mActivity = ActivityContext.lookupContext(context);
        mLauncher = tryGetLauncher(context);
        mSearchBarController = new AllAppsSearchBarController();

        mSearchQueryBuilder = new SpannableStringBuilder();
@@ -94,6 +97,14 @@ public class AppsSearchContainerLayout extends ExtendedEditText
        setHint(prefixTextWithIcon(getContext(), R.drawable.ic_allapps_search, getHint()));
    }

    private Launcher tryGetLauncher(Context context) {
        try {
            return Launcher.getLauncher(context);
        } catch (IllegalArgumentException e) {
            return null;
        }
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
@@ -109,7 +120,7 @@ public class AppsSearchContainerLayout extends ExtendedEditText
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        // Update the width to match the grid padding
        DeviceProfile dp = mLauncher.getDeviceProfile();
        DeviceProfile dp = mActivity.getDeviceProfile();
        int myRequestedWidth = getSize(widthMeasureSpec);
        int rowWidth = myRequestedWidth - mAppsView.getActiveRecyclerView().getPaddingLeft()
                - mAppsView.getActiveRecyclerView().getPaddingRight();
@@ -207,7 +218,7 @@ public class AppsSearchContainerLayout extends ExtendedEditText

    @Override
    public float getScrollRangeDelta(Rect insets) {
        if (mLauncher.getDeviceProfile().isVerticalBarLayout()) {
        if (mActivity.getDeviceProfile().isVerticalBarLayout()) {
            return 0;
        } else {
            int topMargin = Math.round(Math.max(