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
This commit is contained in:
Sunny Goyal authored and Brandon Dayauon committed 2022-07-28 18:10:19 +00:00
1 parent 524f4c4fba
commit 42b640404a
8 files changed
+5 -81

No files matched your search

@@ -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) {