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

Commit b2b614e1 authored by Sunny Goyal's avatar Sunny Goyal Committed by Android Build Coastguard Worker
Browse files

Removing tabWidth calculation and using DeviceProfile directly

This removes some dependency on FloatingHeaderView, making it
easier to replace

Bug: 234008165
Test: Verified that the UI does not change
Change-Id: I363c98c23f84fe570ea9cb1a40128359f5b67c9f
Merged-In: I363c98c23f84fe570ea9cb1a40128359f5b67c9f
(cherry picked from commit 42b64040)
Merged-In: I363c98c23f84fe570ea9cb1a40128359f5b67c9f
parent 86a6cb06
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.os.Build;
import android.text.Layout;
@@ -33,7 +32,6 @@ import android.view.View;
import androidx.annotation.ColorInt;
import androidx.core.content.ContextCompat;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.allapps.FloatingHeaderRow;
import com.android.launcher3.allapps.FloatingHeaderView;
@@ -238,12 +236,6 @@ public class AppsDividerView extends View implements FloatingHeaderRow {
                getPaddingBottom() + getPaddingTop());
    }

    @Override
    public void setInsets(Rect insets, DeviceProfile grid) {
        int leftRightPadding = grid.allAppsLeftRightPadding;
        setPadding(leftRightPadding, getPaddingTop(), leftRightPadding, getPaddingBottom());
    }

    @Override
    public void setVerticalScroll(int scroll, boolean isScrolledOut) {
        setTranslationY(scroll);
+0 −7
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.launcher3.appprediction;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Build;
import android.util.AttributeSet;
import android.view.LayoutInflater;
@@ -251,12 +250,6 @@ public class PredictionRowView<T extends Context & ActivityContext & DeviceProfi
        }
    }

    @Override
    public void setInsets(Rect insets, DeviceProfile grid) {
        int leftRightPadding = grid.allAppsLeftRightPadding;
        setPadding(leftRightPadding, getPaddingTop(), leftRightPadding, getPaddingBottom());
    }

    @Override
    public Class<PredictionRowView> getTypeClass() {
        return PredictionRowView.class;
+0 −5
Original line number Diff line number Diff line
@@ -15,11 +15,8 @@
 */
package com.android.launcher3.allapps;

import android.graphics.Rect;
import android.view.View;

import com.android.launcher3.DeviceProfile;

/**
 * A abstract representation of a row in all-apps view
 */
@@ -29,8 +26,6 @@ public interface FloatingHeaderRow {

    void setup(FloatingHeaderView parent, FloatingHeaderRow[] allRows, boolean tabsHidden);

    void setInsets(Rect insets, DeviceProfile grid);

    int getExpectedHeight();

    /**
+3 −30
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
import com.android.launcher3.R;
import com.android.launcher3.allapps.BaseAllAppsContainerView.AdapterHolder;
@@ -158,22 +157,6 @@ public class FloatingHeaderView extends LinearLayout implements
        PluginManagerWrapper.INSTANCE.get(getContext()).removePluginListener(this);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        mTabLayout.getLayoutParams().width = getTabWidth();
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

    /**
     * Returns distance between left and right app icons
     */
    public int getTabWidth() {
        DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile();
        int totalWidth = getMeasuredWidth() - getPaddingLeft() - getPaddingRight();
        int iconPadding = totalWidth / grid.numShownAllAppsColumns - grid.allAppsIconSizePx;
        return totalWidth - iconPadding - grid.allAppsIconDrawablePaddingPx;
    }

    private void recreateAllRowsArray() {
        int pluginCount = mPluginRows.size();
        if (pluginCount == 0) {
@@ -423,15 +406,6 @@ public class FloatingHeaderView extends LinearLayout implements
        p.y = getTop() - mCurrentRV.getTop() - ((ViewGroup) mCurrentRV.getParent()).getTop();
    }

    public boolean hasVisibleContent() {
        for (FloatingHeaderRow row : mAllRows) {
            if (row.hasVisibleContent()) {
                return true;
            }
        }
        return false;
    }

    public boolean isHeaderProtectionSupported() {
        return mHeaderProtectionSupported;
    }
@@ -443,10 +417,9 @@ public class FloatingHeaderView extends LinearLayout implements

    @Override
    public void setInsets(Rect insets) {
        DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile();
        for (FloatingHeaderRow row : mAllRows) {
            row.setInsets(insets, grid);
        }
        int leftRightPadding = ActivityContext.lookupContext(getContext())
                .getDeviceProfile().allAppsLeftRightPadding;
        setPadding(leftRightPadding, getPaddingTop(), leftRightPadding, getPaddingBottom());
    }

    public <T extends FloatingHeaderRow> T findFixedRowByType(Class<T> type) {
+0 −5
Original line number Diff line number Diff line
@@ -18,10 +18,8 @@ package com.android.launcher3.allapps;
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;

import android.graphics.Rect;
import android.view.View;

import com.android.launcher3.DeviceProfile;
import com.android.systemui.plugins.AllAppsRow;

/**
@@ -42,9 +40,6 @@ public class PluginHeaderRow implements FloatingHeaderRow {
    public void setup(FloatingHeaderView parent, FloatingHeaderRow[] allRows,
            boolean tabsHidden) { }

    @Override
    public void setInsets(Rect insets, DeviceProfile grid) { }

    @Override
    public int getExpectedHeight() {
        return mPlugin.getExpectedHeight();
Loading