Skip to content

Commit

Permalink
Fixes for search bar animation
Browse files Browse the repository at this point in the history
* Fix visible search bar after returning to the launcher.
* Simplify isResuming logic.
* Remove dead check for savedInstanceState.
  • Loading branch information
F4uzan committed Apr 8, 2019
1 parent 335699a commit efc5065
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions app/src/main/java/mono/hg/LauncherActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,6 @@ public class LauncherActivity extends AppCompatActivity {

pinnedAppsAdapter.setLongPressDragEnabled(true);

// Restore search bar visibility when panel is pulled down.
if (savedInstanceState != null && ViewUtils.isPanelVisible(slidingHome)) {
searchContainer.setVisibility(View.VISIBLE);
}

// Get icons from icon pack.
if (!"default".equals(PreferenceHelper.getIconPackName()) &&
LauncherIconHelper.loadIconPack(manager) == 0) {
Expand Down Expand Up @@ -334,6 +329,10 @@ public class LauncherActivity extends AppCompatActivity {
// Show the app list when needed.
if (PreferenceHelper.keepAppList()) {
doThis("show_panel");
} else if (Utils.sdkIsBelow(21)) {
// HACK: For some reason, KitKat and below is always late setting visibility.
// Manually set it here to make sure it's invisible.
searchContainer.setVisibility(View.INVISIBLE);
}

isResuming = true;
Expand Down Expand Up @@ -955,22 +954,18 @@ private void addPanelListener() {
}

// Animate search container entering the view.
if (previousState == SlidingUpPanelLayout.PanelState.DRAGGING) {
searchContainer.animate().alpha(1f).setDuration(animateDuration)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
searchContainer.setVisibility(View.VISIBLE);
}

@Override
public void onAnimationEnd(Animator animation) {
searchContainer.clearAnimation();
}
});
} else {
searchContainer.setVisibility(View.VISIBLE);
}
searchContainer.animate().alpha(1f).setDuration(animateDuration)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
searchContainer.setVisibility(View.VISIBLE);
}

@Override
public void onAnimationEnd(Animator animation) {
searchContainer.clearAnimation();
}
});
} else if (newState == SlidingUpPanelLayout.PanelState.EXPANDED) {
appsLayoutManager.setVerticalScrollEnabled(false);

Expand All @@ -982,12 +977,11 @@ public void onAnimationEnd(Animator animation) {

searchContainer.setVisibility(View.INVISIBLE);

// Also animate the container only when we are not resuming.
// Animate the container.
if (!isResuming) {
searchContainer.animate().alpha(0f).setDuration(animateDuration);
} else {
isResuming = false;
} else if (ActivityServiceUtils.isPowerSaving(LauncherActivity.this)) {
searchContainer.animate().alpha(0).setDuration(animateDuration);
}
} else if (newState == SlidingUpPanelLayout.PanelState.ANCHORED) {
doThis("show_panel");
Expand Down

0 comments on commit efc5065

Please sign in to comment.