Files
Lawnchair/src/com/android/launcher3/graphics/OverviewScrim.java
T
Tony Wickham 4fdba14cfb Two-zone model: swipe up from nav bar vs above it
When ENABLE_OVERVIEW_ACTIONS flag is enabled, swiping up from the nav
bar goes to overview if you hold, or the first home screen if you don't.

- Added NoButtonNavBarToOverviewTouchController, which extends
  FlingAndHoldTouchController but only works if you start from the nav
  bar. Otherwise it falls back to PortraitStatesTouchController to
  handle normal state transition to all apps.
- Added HintState. This is where the workspace/hotseat/qsb scale down
  when you swipe up from the nav bar, to hint that you're about to
  either go to overview or the first home screen.
  - Added getQsbScaleAndTranslation() to allow Overview and Hint states
    to treat it as part of the hotseat.
  - Since Overview needs to show above the QSB as it's animating, bring
    Overview to the front and update OverviewScrim to handle the case
    where there's no view above Overview to draw the scrim beneath.
- ENABLE_OVERVIEW_ACTIONS is always false in 2-button mode, since the
  shelf is crucial to that mode.

Bug: 143361609
Change-Id: I743481bb239dc77f7024dc98ba68a43534da2637
2020-01-28 18:31:10 -08:00

72 lines
2.4 KiB
Java

/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.graphics;
import static android.view.View.VISIBLE;
import static com.android.launcher3.LauncherState.HOTSEAT_ICONS;
import static com.android.launcher3.LauncherState.OVERVIEW;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/**
* View scrim which draws behind overview (recent apps).
*/
public class OverviewScrim extends Scrim {
private @NonNull View mStableScrimmedView;
// Might be higher up if mStableScrimmedView is invisible.
private @Nullable View mCurrentScrimmedView;
public OverviewScrim(View view) {
super(view);
mStableScrimmedView = mCurrentScrimmedView = mLauncher.getOverviewPanel();
onExtractedColorsChanged(mWallpaperColorInfo);
}
public void onInsetsChanged(Rect insets) {
mStableScrimmedView = (OVERVIEW.getVisibleElements(mLauncher) & HOTSEAT_ICONS) != 0
? mLauncher.getHotseat()
: mLauncher.getOverviewPanel();
}
public void updateCurrentScrimmedView(ViewGroup root) {
// Find the lowest view that is at or above the view we want to show the scrim behind.
mCurrentScrimmedView = mStableScrimmedView;
int currentIndex = root.indexOfChild(mCurrentScrimmedView);
final int childCount = root.getChildCount();
while (mCurrentScrimmedView != null && mCurrentScrimmedView.getVisibility() != VISIBLE
&& currentIndex < childCount) {
currentIndex++;
mCurrentScrimmedView = root.getChildAt(currentIndex);
}
}
/**
* @return The view to draw the scrim behind, or null if all visible views should be scrimmed.
*/
public @Nullable View getScrimmedView() {
return mCurrentScrimmedView;
}
}