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

Commit b681ebe3 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Fixing Search box placement in Launcher3

Bug: 152372445
Change-Id: Ifabcc73f33f18de48b737d3e325b14fba75d0d96
parent 33f98496
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -34,5 +34,4 @@
    android:singleLine="true"
    android:textColor="?android:attr/textColorSecondary"
    android:textColorHint="@drawable/all_apps_search_hint"
    android:textSize="16sp"
    android:translationY="24dp" />
 No newline at end of file
    android:textSize="16sp" />
 No newline at end of file
+9 −11
Original line number Diff line number Diff line
@@ -62,9 +62,8 @@ public class AppsSearchContainerLayout extends ExtendedEditText
    private AlphabeticalAppsList mApps;
    private AllAppsContainerView mAppsView;

    // This value was used to position the QSB. We store it here for translationY animations.
    private final float mFixedTranslationY;
    private final float mMarginTopAdjusting;
    // The amount of pixels to shift down and overlap with the rest of the content.
    private final int mContentOverlap;

    public AppsSearchContainerLayout(Context context) {
        this(context, null);
@@ -82,11 +81,10 @@ public class AppsSearchContainerLayout extends ExtendedEditText

        mSearchQueryBuilder = new SpannableStringBuilder();
        Selection.setSelection(mSearchQueryBuilder, 0);

        mFixedTranslationY = getTranslationY();
        mMarginTopAdjusting = mFixedTranslationY - getPaddingTop();

        setHint(prefixTextWithIcon(getContext(), R.drawable.ic_allapps_search, getHint()));

        mContentOverlap =
                getResources().getDimensionPixelSize(R.dimen.all_apps_search_bar_field_height) / 2;
    }

    @Override
@@ -128,6 +126,8 @@ public class AppsSearchContainerLayout extends ExtendedEditText
        int expectedLeft = parent.getPaddingLeft() + (availableWidth - myWidth) / 2;
        int shift = expectedLeft - left;
        setTranslationX(shift);

        offsetTopAndBottom(mContentOverlap);
    }

    @Override
@@ -196,7 +196,7 @@ public class AppsSearchContainerLayout extends ExtendedEditText
    @Override
    public void setInsets(Rect insets) {
        MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams();
        mlp.topMargin = Math.round(Math.max(-mFixedTranslationY, insets.top - mMarginTopAdjusting));
        mlp.topMargin = insets.top;
        requestLayout();
    }

@@ -205,9 +205,7 @@ public class AppsSearchContainerLayout extends ExtendedEditText
        if (mLauncher.getDeviceProfile().isVerticalBarLayout()) {
            return 0;
        } else {
            int topMargin = Math.round(Math.max(
                    -mFixedTranslationY, insets.top - mMarginTopAdjusting));
           return insets.bottom + topMargin + mFixedTranslationY;
            return insets.bottom + insets.top;
        }
    }

+8 −4
Original line number Diff line number Diff line
@@ -15,10 +15,12 @@
 */
package com.android.launcher3.states;

import static android.Manifest.permission.WRITE_SECURE_SETTINGS;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LOCKED;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.util.DisplayMetrics.DENSITY_DEVICE_STABLE;

import static com.android.launcher3.config.FeatureFlags.FLAG_ENABLE_FIXED_ROTATION_TRANSFORM;
@@ -37,7 +39,6 @@ import android.view.Surface;
import android.view.WindowManager;

import com.android.launcher3.Launcher;
import com.android.launcher3.PagedView;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
@@ -142,9 +143,12 @@ public class RotationHelper implements OnSharedPreferenceChangeListener {
        if (setValueFromPrefs) {
            mForcedRotation = isForcedRotation;
        }
        UI_HELPER_EXECUTOR.execute(
                () -> Settings.Global.putInt(mContentResolver, FIXED_ROTATION_TRANSFORM_SETTING_NAME,
                        mForcedRotation ? 1 : 0));
        UI_HELPER_EXECUTOR.execute(() -> {
            if (mLauncher.checkSelfPermission(WRITE_SECURE_SETTINGS) == PERMISSION_GRANTED) {
                Settings.Global.putInt(mContentResolver, FIXED_ROTATION_TRANSFORM_SETTING_NAME,
                            mForcedRotation ? 1 : 0);
            }
        });
        for (ForcedRotationChangedListener listener : mForcedRotationChangedListeners) {
            listener.onForcedRotationChanged(mForcedRotation);
        }