summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdnan <adnan@cyngn.com>2014-11-10 18:35:01 (GMT)
committerAdnan <adnan@cyngn.com>2014-11-19 23:53:58 (GMT)
commit9b0b6292444f70bbe04aadffda9fb11296cc6b6d (patch)
tree686e94515bc296d81678adb8bcf3dde72089eb73
parent9ac45b642bea5e15164da3373b973828a3e8a1d8 (diff)
downloadandroid_packages_apps_Trebuchet-9b0b6292444f70bbe04aadffda9fb11296cc6b6d.zip
android_packages_apps_Trebuchet-9b0b6292444f70bbe04aadffda9fb11296cc6b6d.tar.gz
android_packages_apps_Trebuchet-9b0b6292444f70bbe04aadffda9fb11296cc6b6d.tar.bz2
Trebuchet: Implement search bar hide.
Change-Id: I410452452d5567f75070f85b974749645d9672aa
-rw-r--r--src/com/android/launcher3/DeviceProfile.java38
-rw-r--r--src/com/android/launcher3/Launcher.java4
-rw-r--r--src/com/android/launcher3/Workspace.java11
3 files changed, 44 insertions, 9 deletions
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index b6a8d82..cf298f9 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -163,6 +163,8 @@ public class DeviceProfile {
int pageIndicatorHeightPx;
int allAppsButtonVisualSize;
+ boolean searchBarVisible;
+
float dragViewScale;
int allAppsShortEdgeCount = -1;
@@ -312,6 +314,11 @@ public class DeviceProfile {
updateFromConfiguration(context, res, wPx, hPx, awPx, ahPx);
updateAvailableDimensions(context);
computeAllAppsButtonSize(context);
+ // Search Bar
+ searchBarVisible = SettingsProvider.getBoolean(context, SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH,
+ R.bool.preferences_interface_homescreen_search_default);
+ searchBarSpaceWidthPx = Math.min(searchBarSpaceMaxWidthPx, widthPx);
+ searchBarSpaceHeightPx = 2 * edgeMarginPx + (searchBarVisible ? searchBarHeightPx : 3 * edgeMarginPx);
}
/**
@@ -579,9 +586,9 @@ public class DeviceProfile {
/** Returns the search bar top offset */
int getSearchBarTopOffset() {
if (isTablet() && !isVerticalBarLayout()) {
- return 4 * edgeMarginPx;
+ return searchBarVisible ? 4 * edgeMarginPx : 0;
} else {
- return 2 * edgeMarginPx;
+ return searchBarVisible ? 2 * edgeMarginPx : 0;
}
}
@@ -614,12 +621,12 @@ public class DeviceProfile {
(numColumns * cellWidthPx)) / (2 * (numColumns + 1)));
bounds.set(edgeMarginPx + gap, getSearchBarTopOffset(),
availableWidthPx - (edgeMarginPx + gap),
- searchBarSpaceHeightPx);
+ searchBarVisible ? searchBarSpaceHeightPx : edgeMarginPx);
} else {
bounds.set(desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.left,
getSearchBarTopOffset(),
availableWidthPx - (desiredWorkspaceLeftRightMarginPx -
- defaultWidgetPadding.right), searchBarSpaceHeightPx);
+ defaultWidgetPadding.right), searchBarVisible ? searchBarSpaceHeightPx : edgeMarginPx);
}
}
return bounds;
@@ -772,14 +779,22 @@ public class DeviceProfile {
}
public void layout(Launcher launcher) {
+ // Update search bar for live settings
+ searchBarVisible = SettingsProvider.getBoolean(launcher, SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH,
+ R.bool.preferences_interface_homescreen_search_default);
+ searchBarSpaceHeightPx = 2 * edgeMarginPx + (searchBarVisible ? searchBarHeightPx : 3 * edgeMarginPx);
FrameLayout.LayoutParams lp;
Resources res = launcher.getResources();
boolean hasVerticalBarLayout = isVerticalBarLayout();
// Layout the search bar space
View searchBar = launcher.getSearchBar();
+ LinearLayout dropTargetBar = (LinearLayout) launcher.getSearchBar().getDropTargetBar();
lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams();
if (hasVerticalBarLayout) {
+ // If search bar is invisible add some extra padding for the drop targets
+ searchBarSpaceHeightPx = searchBarVisible ? searchBarSpaceHeightPx
+ : searchBarSpaceHeightPx + 5 * edgeMarginPx;
// Vertical search bar space
lp.gravity = Gravity.TOP | Gravity.LEFT;
lp.width = searchBarSpaceHeightPx;
@@ -802,6 +817,21 @@ public class DeviceProfile {
}
searchBar.setLayoutParams(lp);
+ // Layout the drop target icons
+ if (hasVerticalBarLayout) {
+ dropTargetBar.setOrientation(LinearLayout.VERTICAL);
+ } else {
+ dropTargetBar.setOrientation(LinearLayout.HORIZONTAL);
+ }
+
+ // Layout the search bar
+ View qsbBar = launcher.getQsbBar();
+ qsbBar.setVisibility(searchBarVisible ? View.VISIBLE : View.GONE);
+ LayoutParams vglp = qsbBar.getLayoutParams();
+ vglp.width = LayoutParams.MATCH_PARENT;
+ vglp.height = LayoutParams.MATCH_PARENT;
+ qsbBar.setLayoutParams(vglp);
+
// Layout the voice proxy
View voiceButtonProxy = launcher.findViewById(R.id.voice_button_proxy);
if (voiceButtonProxy != null) {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 27ae670..99fe26e 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1203,7 +1203,9 @@ public class Launcher extends Activity
public void resetQSBScroll() {
mSearchDropTargetBar.animate().translationY(0).start();
- getQsbBar().animate().translationY(0).start();
+ if (isSearchBarEnabled()) {
+ getQsbBar().animate().translationY(0).start();
+ }
}
public interface CustomContentCallbacks {
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 53e8040..8cf1ec5 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -2445,7 +2445,7 @@ public class Workspace extends SmoothPagedView
Animator searchBarAlpha = new LauncherViewPropertyAnimator(searchBar)
.alpha(finalSearchBarAlpha).withLayer();
- searchBarAlpha.addListener(new AlphaUpdateListener(searchBar));
+ if (mShowSearchBar) searchBarAlpha.addListener(new AlphaUpdateListener(searchBar));
Animator overviewPanelAlpha = new LauncherViewPropertyAnimator(overviewPanel)
.alpha(finalOverviewPanelAlpha).withLayer();
@@ -2523,7 +2523,7 @@ public class Workspace extends SmoothPagedView
// Animation animation = AnimationUtils.loadAnimation(mLauncher, R.anim.drop_down);
// overviewPanel.startAnimation(animation);
anim.play(hotseatAlpha);
- anim.play(searchBarAlpha);
+ if (mShowSearchBar) anim.play(searchBarAlpha);
anim.play(pageIndicatorAlpha);
anim.setStartDelay(delay);
} else {
@@ -2535,8 +2535,11 @@ public class Workspace extends SmoothPagedView
pageIndicator.setAlpha(finalHotseatAndPageIndicatorAlpha);
AlphaUpdateListener.updateVisibility(pageIndicator);
}
- searchBar.setAlpha(finalSearchBarAlpha);
- AlphaUpdateListener.updateVisibility(searchBar);
+
+ if (mShowSearchBar) {
+ searchBar.setAlpha(finalSearchBarAlpha);
+ AlphaUpdateListener.updateVisibility(searchBar);
+ }
updateCustomContentVisibility();
setScaleX(mNewScale);
setScaleY(mNewScale);