Get the view to be used as qsb bar from the launcher directly.
This will allow more control over the qsb visuals and behaviour in GEL.
Depends on ag/339203
Future changes:
- revert ag/344333 since we won't need the normal qsb to support hotword
anymore
- Dragging icons over the Drop target bar (to remove/uninstall them or
get App info) doesn't currently work in GEL. There might be future
changes needed to fix that.
Change-Id: Ic498f0abee5ad99ef1644ff94f174b61f8e1f5f0
diff --git a/src/com/android/launcher3/DrawableStateProxyView.java b/src/com/android/launcher3/DrawableStateProxyView.java
index 196e2f2..0758de1 100644
--- a/src/com/android/launcher3/DrawableStateProxyView.java
+++ b/src/com/android/launcher3/DrawableStateProxyView.java
@@ -58,8 +58,10 @@
View parent = (View) getParent();
mView = parent.findViewById(mViewId);
}
- mView.setPressed(isPressed());
- mView.setHovered(isHovered());
+ if (mView != null) {
+ mView.setPressed(isPressed());
+ mView.setHovered(isHovered());
+ }
}
@Override
diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java
index 37cccfb..593c4de 100644
--- a/src/com/android/launcher3/DynamicGrid.java
+++ b/src/com/android/launcher3/DynamicGrid.java
@@ -321,7 +321,7 @@
searchBarSpace.setLayoutParams(lp);
// Layout the search bar
- View searchBar = searchBarSpace.findViewById(R.id.qsb_search_bar);
+ View searchBar = launcher.getQsbBar();
lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams();
lp.width = LayoutParams.MATCH_PARENT;
lp.height = LayoutParams.MATCH_PARENT;
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index d91fee8..85bcdc0 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -245,6 +245,7 @@
private AppsCustomizeTabHost mAppsCustomizeTabHost;
private AppsCustomizePagedView mAppsCustomizeContent;
private boolean mAutoAdvanceRunning = false;
+ private View mQsbBar;
private Bundle mSavedState;
// We set the state in both onCreate and then onNewIntent in some cases, which causes both
@@ -413,8 +414,8 @@
checkForLocaleChange();
setContentView(R.layout.launcher);
- grid.layout(this);
setupViews();
+ grid.layout(this);
showFirstRunWorkspaceCling();
registerContentObservers();
@@ -3247,7 +3248,14 @@
}
}
- private boolean updateGlobalSearchIcon() {
+ public View getQsbBar() {
+ if (mQsbBar == null) {
+ mQsbBar = mInflater.inflate(R.layout.qsb_bar, mSearchDropTargetBar);
+ }
+ return mQsbBar;
+ }
+
+ protected boolean updateGlobalSearchIcon() {
final View searchButtonContainer = findViewById(R.id.search_button_container);
final ImageView searchButton = (ImageView) findViewById(R.id.search_button);
final View voiceButtonContainer = findViewById(R.id.voice_button_container);
@@ -3282,14 +3290,14 @@
}
}
- private void updateGlobalSearchIcon(Drawable.ConstantState d) {
+ protected void updateGlobalSearchIcon(Drawable.ConstantState d) {
final View searchButtonContainer = findViewById(R.id.search_button_container);
final View searchButton = (ImageView) findViewById(R.id.search_button);
updateButtonWithDrawable(R.id.search_button, d);
invalidatePressedFocusedStates(searchButtonContainer, searchButton);
}
- private boolean updateVoiceSearchIcon(boolean searchVisible) {
+ protected boolean updateVoiceSearchIcon(boolean searchVisible) {
final View voiceButtonContainer = findViewById(R.id.voice_button_container);
final View voiceButton = findViewById(R.id.voice_button);
@@ -3335,7 +3343,7 @@
}
}
- private void updateVoiceSearchIcon(Drawable.ConstantState d) {
+ protected void updateVoiceSearchIcon(Drawable.ConstantState d) {
final View voiceButtonContainer = findViewById(R.id.voice_button_container);
final View voiceButton = findViewById(R.id.voice_button);
updateButtonWithDrawable(R.id.voice_button, d);
diff --git a/src/com/android/launcher3/SearchDropTargetBar.java b/src/com/android/launcher3/SearchDropTargetBar.java
index 8f1b5d2..0a0861f 100644
--- a/src/com/android/launcher3/SearchDropTargetBar.java
+++ b/src/com/android/launcher3/SearchDropTargetBar.java
@@ -23,6 +23,7 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
+import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.widget.FrameLayout;
@@ -71,6 +72,14 @@
dragController.setFlingToDeleteDropTarget(mDeleteDropTarget);
mInfoDropTarget.setLauncher(launcher);
mDeleteDropTarget.setLauncher(launcher);
+ mQSBSearchBar = launcher.getQsbBar();
+ if (mEnableDropDownDropTargets) {
+ mQSBSearchBarAnim = LauncherAnimUtils.ofFloat(mQSBSearchBar, "translationY", 0,
+ -mBarHeight);
+ } else {
+ mQSBSearchBarAnim = LauncherAnimUtils.ofFloat(mQSBSearchBar, "alpha", 1f, 0f);
+ }
+ setupAnimation(mQSBSearchBarAnim, mQSBSearchBar);
}
private void prepareStartAnimation(View v) {
@@ -95,7 +104,6 @@
super.onFinishInflate();
// Get the individual components
- mQSBSearchBar = findViewById(R.id.qsb_search_bar);
mDropTargetBar = findViewById(R.id.drag_target_bar);
mInfoDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.info_target_text);
mDeleteDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.delete_target_text);
@@ -114,15 +122,12 @@
mDropTargetBar.setTranslationY(-mBarHeight);
mDropTargetBarAnim = LauncherAnimUtils.ofFloat(mDropTargetBar, "translationY",
-mBarHeight, 0f);
- mQSBSearchBarAnim = LauncherAnimUtils.ofFloat(mQSBSearchBar, "translationY", 0,
- -mBarHeight);
+
} else {
mDropTargetBar.setAlpha(0f);
mDropTargetBarAnim = LauncherAnimUtils.ofFloat(mDropTargetBar, "alpha", 0f, 1f);
- mQSBSearchBarAnim = LauncherAnimUtils.ofFloat(mQSBSearchBar, "alpha", 1f, 0f);
}
setupAnimation(mDropTargetBarAnim, mDropTargetBar);
- setupAnimation(mQSBSearchBarAnim, mQSBSearchBar);
}
public void finishAnimations() {