mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-28 15:56:49 +00:00
Adds ENABLE_FLOATING_SEARCH_BOX flag for All Apps.
This defines how the All Apps screen should be laid out without anchoring to the search bar at the top, as follows: - Header view aligns to the top instead of below search bar. - Same for A-Z list. - Scroller is aligned to the header view to receive the above adjustments automatically. - A-Z list is set above search bar to not peek from below. - Search bar is set to align parent bottom and translates up with the keyboard. - Button to disable work apps is raised above the search bar. Bug: 213954333 Test: Manually with flag enabled/disabled, Always show keyboard enabled/disabled, and work profile enabled/disabled. Change-Id: If90bb39a890029fa7056367fe62bad0677f0b86e
This commit is contained in:
@@ -21,6 +21,7 @@ import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@@ -176,6 +177,28 @@ public class ActivityAllAppsContainerView<T extends BaseDraggingActivity> extend
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected View replaceRVContainer(boolean showTabs) {
|
||||
View rvContainer = super.replaceRVContainer(showTabs);
|
||||
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
|
||||
alignParentTop(rvContainer);
|
||||
layoutAboveSearchContainer(rvContainer);
|
||||
} else {
|
||||
layoutBelowSearchContainer(rvContainer);
|
||||
}
|
||||
return rvContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
void setupHeader() {
|
||||
super.setupHeader();
|
||||
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
|
||||
alignParentTop(mHeader);
|
||||
} else {
|
||||
layoutBelowSearchContainer(mHeader);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateHeaderScroll(int scrolledOffset) {
|
||||
super.updateHeaderScroll(scrolledOffset);
|
||||
@@ -202,6 +225,36 @@ public class ActivityAllAppsContainerView<T extends BaseDraggingActivity> extend
|
||||
|
||||
@Override
|
||||
protected int getHeaderBottom() {
|
||||
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
|
||||
return super.getHeaderBottom();
|
||||
}
|
||||
return super.getHeaderBottom() + mSearchContainer.getBottom();
|
||||
}
|
||||
|
||||
private void layoutBelowSearchContainer(View v) {
|
||||
if (!(v.getLayoutParams() instanceof RelativeLayout.LayoutParams)) {
|
||||
return;
|
||||
}
|
||||
RelativeLayout.LayoutParams layoutParams = (LayoutParams) v.getLayoutParams();
|
||||
layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_TOP);
|
||||
layoutParams.removeRule(RelativeLayout.ABOVE);
|
||||
layoutParams.addRule(RelativeLayout.BELOW, R.id.search_container_all_apps);
|
||||
}
|
||||
|
||||
private void layoutAboveSearchContainer(View v) {
|
||||
if (!(v.getLayoutParams() instanceof RelativeLayout.LayoutParams)) {
|
||||
return;
|
||||
}
|
||||
RelativeLayout.LayoutParams layoutParams = (LayoutParams) v.getLayoutParams();
|
||||
layoutParams.addRule(RelativeLayout.ABOVE, R.id.search_container_all_apps);
|
||||
}
|
||||
|
||||
private void alignParentTop(View v) {
|
||||
if (!(v.getLayoutParams() instanceof RelativeLayout.LayoutParams)) {
|
||||
return;
|
||||
}
|
||||
RelativeLayout.LayoutParams layoutParams = (LayoutParams) v.getLayoutParams();
|
||||
layoutParams.removeRule(RelativeLayout.BELOW);
|
||||
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user