Merge "[Search] Apply background to entire SearchInput view instead of just EditText" into sc-v2-dev

This commit is contained in:
TreeHugger Robot 2021-09-16 17:11:52 +00:00 committed by Android (Google) Code Review
commit 7b5aedc72d
3 changed files with 16 additions and 20 deletions

View File

@ -26,7 +26,6 @@ import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.views.ActivityContext;
@ -99,18 +98,6 @@ public class ExtendedEditText extends EditText {
}
}
/**
* Sets whether EditText background should be visible
* @param maxAlpha defines the maximum alpha the background should animates to
*/
public void setBackgroundVisibility(boolean visible, float maxAlpha) {}
/**
* Returns whether a visible background is set on EditText
*/
public boolean getBackgroundVisibility() {
return getBackground() != null;
}
public void showKeyboard() {
mShowImeAfterFirstLayout = !showSoftInput();
@ -150,9 +137,6 @@ public class ExtendedEditText extends EditText {
if (!TextUtils.isEmpty(getText())) {
setText("");
}
if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
return;
}
if (isFocused()) {
View nextFocus = focusSearch(View.FOCUS_DOWN);
if (nextFocus != null) {

View File

@ -59,7 +59,6 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.DragSource;
import com.android.launcher3.DropTarget.DragObject;
import com.android.launcher3.ExtendedEditText;
import com.android.launcher3.Insettable;
import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.R;
@ -642,6 +641,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
public void onClearSearchResult() {
mIsSearching = false;
mHeader.setCollapsed(false);
rebindAdapters();
getActiveRecyclerView().scrollToTop();
}
@ -817,14 +817,13 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
invalidateHeader();
}
if (mSearchUiManager.getEditText() != null) {
ExtendedEditText editText = mSearchUiManager.getEditText();
boolean bgVisible = editText.getBackgroundVisibility();
boolean bgVisible = mSearchUiManager.getBackgroundVisibility();
if (scrolledOffset == 0 && !mIsSearching) {
bgVisible = true;
} else if (scrolledOffset > mHeaderThreshold) {
bgVisible = false;
}
editText.setBackgroundVisibility(bgVisible, 1 - prog);
mSearchUiManager.setBackgroundVisibility(bgVisible, 1 - prog);
}
}

View File

@ -48,6 +48,19 @@ public interface SearchUiManager {
@Nullable
ExtendedEditText getEditText();
/**
* Sets whether EditText background should be visible
* @param maxAlpha defines the maximum alpha the background should animates to
*/
default void setBackgroundVisibility(boolean visible, float maxAlpha) {}
/**
* Returns whether a visible background is set on EditText
*/
default boolean getBackgroundVisibility() {
return false;
}
/**
* sets highlight result's title
*/