diff --git a/flexera/res/layout/flexera_all_apps_section_header.xml b/flexera/res/layout/flexera_all_apps_section_header.xml index 4fe50bbf59..65c13e6ac4 100644 --- a/flexera/res/layout/flexera_all_apps_section_header.xml +++ b/flexera/res/layout/flexera_all_apps_section_header.xml @@ -10,6 +10,9 @@ android:paddingEnd="@dimen/flexera_drawer_row_padding_end" android:paddingBottom="@dimen/flexera_drawer_header_padding_bottom" android:textAlignment="viewStart" - android:textColor="?android:attr/textColorSecondary" + android:shadowColor="#73000000" + android:shadowDy="2" + android:shadowRadius="6" + android:textColor="@color/flexera_drawer_header_text" android:textSize="@dimen/flexera_drawer_header_text_size" android:textStyle="bold" /> diff --git a/flexera/res/values/flexera_colors.xml b/flexera/res/values/flexera_colors.xml index 657575a710..747c95f61c 100644 --- a/flexera/res/values/flexera_colors.xml +++ b/flexera/res/values/flexera_colors.xml @@ -2,4 +2,7 @@ #170A7A + + + #CCFFFFFF diff --git a/flexera/res/values/flexera_config.xml b/flexera/res/values/flexera_config.xml index 29f6bb8dfa..6567842647 100644 --- a/flexera/res/values/flexera_config.xml +++ b/flexera/res/values/flexera_config.xml @@ -17,4 +17,7 @@ false + + + false diff --git a/flexera/res/values/flexera_dimens.xml b/flexera/res/values/flexera_dimens.xml index ef0d5370aa..d2f8afc2e7 100644 --- a/flexera/res/values/flexera_dimens.xml +++ b/flexera/res/values/flexera_dimens.xml @@ -10,6 +10,29 @@ 56dp + + + 40dp + + 16dp + 12sp + + 30dp + 16dp + + 52dp + + 60dp + + 56dp + + + 72dp + + + 3dp + 1dp + 44dp 6dp 14sp diff --git a/flexera/res/values/flexera_ids.xml b/flexera/res/values/flexera_ids.xml new file mode 100644 index 0000000000..aae70bbec8 --- /dev/null +++ b/flexera/res/values/flexera_ids.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/flexera/src/app/flexera/drawer/FlexeraDrawer.kt b/flexera/src/app/flexera/drawer/FlexeraDrawer.kt index 4258cfaf13..eb25676927 100644 --- a/flexera/src/app/flexera/drawer/FlexeraDrawer.kt +++ b/flexera/src/app/flexera/drawer/FlexeraDrawer.kt @@ -1,14 +1,20 @@ package app.flexera.drawer import android.content.Context +import android.graphics.Color +import android.graphics.Rect +import android.os.Build import android.util.TypedValue import android.view.LayoutInflater +import android.view.MotionEvent import android.view.View import android.view.ViewGroup import android.widget.TextView import com.android.launcher3.BubbleTextView import com.android.launcher3.R +import com.android.launcher3.allapps.ActivityAllAppsContainerView import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem +import com.android.launcher3.views.BaseDragLayer /** * Flexera Launcher's app drawer: a single-column alphabetical list with letter headers @@ -56,8 +62,43 @@ object FlexeraDrawer { icon.layoutParams.height = res.getDimensionPixelSize(R.dimen.flexera_drawer_row_height) icon.compoundDrawablePadding = res.getDimensionPixelSize(R.dimen.flexera_drawer_row_icon_gap) icon.setTextSize(TypedValue.COMPLEX_UNIT_PX, res.getDimension(R.dimen.flexera_drawer_row_text_size)) + // The drawer has no background, so names sit directly on the dimmed wallpaper: white, + // with a soft shadow to stay readable over light areas. + icon.setTextColor(Color.WHITE) + icon.setShadowLayer( + res.getDimension(R.dimen.flexera_drawer_text_shadow_radius), + 0f, + res.getDimension(R.dimen.flexera_drawer_text_shadow_dy), + TEXT_SHADOW_COLOR, + ) } + /** Shadow behind white drawer text. */ + const val TEXT_SHADOW_COLOR = 0x73000000 + + /** + * Where the drawer panel sits for a given all-apps progress (0 = open, 1 = closed). Launcher3 + * slides the panel up from the bottom; here it stays in place and fades (see + * [applyOpenProgress]), and is parked off-screen only when fully closed. + */ + @JvmStatic + fun panelTranslation(progress: Float, shiftRange: Float): Float = + if (progress >= 1f) shiftRange else 0f + + /** + * Fades the drawer with how far open it is. It reaches full strength a little before the + * gesture or animation ends, so the list is readable while it is still arriving. + */ + @JvmStatic + fun applyOpenProgress(appsView: View, progress: Float) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) return + val open = (1f - progress).coerceIn(0f, 1f) + appsView.transitionAlpha = (open / FADE_COMPLETE_AT).coerceAtMost(1f) + } + + /** The share of the opening travel at which the drawer is fully visible. */ + private const val FADE_COMPLETE_AT = 0.6f + /** * How far a row's icon sits from the edge of the list. Launcher3 uses its grid version of * this number to line the search bar up with the first icon, so the list supplies its own. @@ -66,6 +107,76 @@ object FlexeraDrawer { fun rowStartPadding(context: Context): Int = context.resources.getDimensionPixelSize(R.dimen.flexera_drawer_row_padding_start) + /** + * Adds the wave alphabet (PRD AD-4 to AD-6) on top of the drawer's list. Called once, when the + * drawer's views have been created. + */ + @JvmStatic + fun attachWaveAlphabet(appsView: ActivityAllAppsContainerView<*>) { + if (appsView.findViewById(R.id.flexera_wave_alphabet) != null) return + // With no background panel, the panel's drag handle would float on its own. Launcher3 + // toggles the handle's visibility itself, so hide it through alpha, which it leaves alone. + appsView.findViewById(R.id.bottom_sheet_handle_area)?.alpha = 0f + appsView.findViewById(R.id.bottom_sheet_handle)?.alpha = 0f + appsView.addView( + WaveAlphabetView(appsView.context, appsView), + ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT), + ) + } + + /** The drawer's wave alphabet, or null if this drawer has none. */ + @JvmStatic + fun waveAlphabet(appsView: ActivityAllAppsContainerView<*>): WaveAlphabetView? = + appsView.findViewById(R.id.flexera_wave_alphabet) + + /** + * True when [ev], given in the drag layer's coordinates, lands on the wave alphabet's strip. + * The drawer asks this before deciding whether a touch may drag the whole drawer closed. + */ + @JvmStatic + fun isOverWaveAlphabet( + appsView: ActivityAllAppsContainerView<*>, + dragLayer: BaseDragLayer<*>, + ev: MotionEvent, + ): Boolean { + val wave = waveAlphabet(appsView) ?: return false + val bounds = Rect() + dragLayer.getDescendantRectRelativeToSelf(wave, bounds) + return wave.isOnStrip(ev.x - bounds.left, ev.y - bounds.top) + } + + /** + * How far up a swipe from the home screen must travel before a pause counts as "swipe up and + * hold" (PRD AD-17). Below this, a slow start to an ordinary swipe would trigger it by accident. + */ + @JvmStatic + fun holdMinSwipePx(context: Context): Float = + context.resources.getDimension(R.dimen.flexera_hold_min_swipe) + + /** + * Feeds one touch position of a swipe-up-and-hold gesture to the wave alphabet. The first call + * starts the scrub and later calls move it. [ev] is in the drag layer's coordinates. + */ + @JvmStatic + fun scrubFromSwipe( + appsView: ActivityAllAppsContainerView<*>, + dragLayer: BaseDragLayer<*>, + ev: MotionEvent, + ) { + val wave = waveAlphabet(appsView) ?: return + val bounds = Rect() + dragLayer.getDescendantRectRelativeToSelf(wave, bounds) + val x = ev.x - bounds.left + val y = ev.y - bounds.top + if (wave.isScrubbing) wave.moveScrub(x, y) else wave.beginScrub(x, y) + } + + /** Ends a scrub started by [scrubFromSwipe]; the drawer stays open at the chosen letter. */ + @JvmStatic + fun endScrubFromSwipe(appsView: ActivityAllAppsContainerView<*>) { + waveAlphabet(appsView)?.endScrub() + } + /** * A letter header. It carries its letter so that the adapter's diffing notices when the * header at a position changes, for example after an app is installed or removed. diff --git a/flexera/src/app/flexera/drawer/WaveAlphabetView.kt b/flexera/src/app/flexera/drawer/WaveAlphabetView.kt new file mode 100644 index 0000000000..256b10e3c4 --- /dev/null +++ b/flexera/src/app/flexera/drawer/WaveAlphabetView.kt @@ -0,0 +1,324 @@ +package app.flexera.drawer + +import android.animation.ValueAnimator +import android.annotation.SuppressLint +import android.content.Context +import android.graphics.Canvas +import android.graphics.Color +import android.graphics.Paint +import android.graphics.Rect +import android.graphics.Typeface +import android.os.Build +import android.view.HapticFeedbackConstants +import android.view.MotionEvent +import android.view.View +import android.view.ViewTreeObserver +import android.view.animation.DecelerateInterpolator +import androidx.core.graphics.ColorUtils +import androidx.recyclerview.widget.LinearLayoutManager +import com.android.launcher3.R +import com.android.launcher3.allapps.ActivityAllAppsContainerView +import kotlin.math.abs +import kotlin.math.exp +import kotlin.math.max +import kotlin.math.min +import kotlin.math.roundToInt + +/** + * The wave alphabet: a strip of letters down the end edge of the drawer (PRD AD-4 to AD-6). + * + * Only letters that have apps are shown. Touching the strip and sliding along it jumps the list + * to the letter under the finger, with a haptic tick on every change. While the finger is down, + * the letters near it bulge away from the edge in a wave, and the wave reaches further the + * further the finger moves in from the edge, so the current letter always sits beside the thumb + * instead of under it. + * + * The view covers the whole drawer so it has room to draw the wave, but it only takes touches + * that start on the strip; every other touch falls through to the list underneath. + * + * [beginScrub], [moveScrub] and [endScrub] are public so that another gesture, such as swipe up + * and hold from the home screen (PRD AD-17), can hand its touch over to the alphabet. + */ +@SuppressLint("ViewConstructor") +class WaveAlphabetView( + context: Context, + private val appsView: ActivityAllAppsContainerView<*>, +) : View(context) { + + private data class Letter(val label: String, val adapterPosition: Int) + + private val res = context.resources + private val touchWidth = res.getDimension(R.dimen.flexera_wave_touch_width) + private val edgeInset = res.getDimension(R.dimen.flexera_wave_edge_inset) + private val maxSpacing = res.getDimension(R.dimen.flexera_wave_max_spacing) + private val verticalMargin = res.getDimension(R.dimen.flexera_wave_vertical_margin) + private val fingerGap = res.getDimension(R.dimen.flexera_wave_finger_gap) + private val minReach = res.getDimension(R.dimen.flexera_wave_min_reach) + private val waveWidth = res.getDimension(R.dimen.flexera_wave_width) + private val letterSize = res.getDimension(R.dimen.flexera_wave_letter_size) + + // The drawer has no background, so the letters are white like the app names: slightly + // dimmed at rest, full white near the finger. + private val idleColor = ColorUtils.setAlphaComponent(Color.WHITE, 0xB3) + private val activeColor = Color.WHITE + + private val paint = Paint(Paint.ANTI_ALIAS_FLAG).apply { + textAlign = Paint.Align.CENTER + textSize = letterSize + setShadowLayer( + res.getDimension(R.dimen.flexera_drawer_text_shadow_radius), + 0f, + res.getDimension(R.dimen.flexera_drawer_text_shadow_dy), + FlexeraDrawer.TEXT_SHADOW_COLOR, + ) + } + private val boldTypeface = Typeface.create(Typeface.DEFAULT, Typeface.BOLD) + + private var letters: List = emptyList() + private var letterYs = FloatArray(0) + private var stripTop = 0f + private var stripBottom = 0f + private var layoutDirty = true + private var wasSearching = false + + private var scrubbing = false + private var fingerX = 0f + private var fingerY = 0f + private var selected = -1 + + /** 0 when the strip is at rest, 1 when the wave is fully out. Animated on touch down and up. */ + private var press = 0f + private var pressAnimator: ValueAnimator? = null + + private val exclusionRect = Rect() + private val location = IntArray(2) + private val otherLocation = IntArray(2) + + private val layoutListener = ViewTreeObserver.OnGlobalLayoutListener { refreshIfChanged() } + + init { + id = R.id.flexera_wave_alphabet + importantForAccessibility = IMPORTANT_FOR_ACCESSIBILITY_NO + } + + // ---- Letters and their positions --------------------------------------------------------- + + private fun readLetters(): List { + if (appsView.isSearching) return emptyList() + val sections = appsView.activeRecyclerView?.apps?.fastScrollerSections ?: return emptyList() + val result = ArrayList(sections.size) + for (section in sections) { + val label = section.sectionName?.toString().orEmpty() + // Launcher3 repeats the last section once more so its own scroller can reach the + // bottom, and Private Space uses a long badge string; neither is a letter. + if (label.isEmpty() || label.length > 2) continue + if (result.isNotEmpty() && result.last().label == label) continue + result.add(Letter(label, section.position)) + } + return result + } + + private fun refreshIfChanged() { + val searching = appsView.isSearching + val fresh = readLetters() + if (fresh != letters || searching != wasSearching) { + letters = fresh + wasSearching = searching + layoutDirty = true + invalidate() + } + } + + private fun computeLayout() { + layoutDirty = false + + // The strip runs from where the list starts down to the navigation bar. + var top = 0f + appsView.activeRecyclerView?.let { rv -> + getLocationInWindow(location) + rv.getLocationInWindow(otherLocation) + top = (otherLocation[1] - location[1]).toFloat().coerceAtLeast(0f) + } + val bottomInset = rootWindowInsets?.systemWindowInsetBottom ?: 0 + val availableTop = top + verticalMargin + val availableBottom = height - bottomInset - verticalMargin + + val count = letters.size + letterYs = FloatArray(count) + if (count == 0 || availableBottom <= availableTop) { + stripTop = 0f + stripBottom = 0f + } else { + val spacing = min(maxSpacing, (availableBottom - availableTop) / count) + val blockHeight = spacing * count + // Few letters: keep the block in the middle of the edge, where a thumb rests. + stripTop = availableTop + (availableBottom - availableTop - blockHeight) / 2f + stripBottom = stripTop + blockHeight + for (i in 0 until count) { + letterYs[i] = stripTop + spacing * (i + 0.5f) + } + } + + // The strip sits where Android's back swipe starts. A home app may reserve the whole + // edge, so the scrub never turns into Back. + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + exclusionRect.set((width - touchWidth).toInt(), stripTop.toInt(), width, stripBottom.toInt()) + systemGestureExclusionRects = listOf(exclusionRect) + } + } + + override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { + super.onSizeChanged(w, h, oldw, oldh) + layoutDirty = true + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + viewTreeObserver.addOnGlobalLayoutListener(layoutListener) + refreshIfChanged() + } + + override fun onDetachedFromWindow() { + viewTreeObserver.removeOnGlobalLayoutListener(layoutListener) + pressAnimator?.cancel() + super.onDetachedFromWindow() + } + + // ---- Drawing ----------------------------------------------------------------------------- + + override fun onDraw(canvas: Canvas) { + if (layoutDirty) computeLayout() + if (letters.isEmpty()) return + + val baseX = width - edgeInset + // The wave's peak sits a fixed gap before the finger, so it reaches further out the + // further the finger is from the edge. + val reach = (baseX - fingerX + fingerGap).coerceIn(minReach, width * 0.7f) * press + + for (i in letters.indices) { + val y = letterYs[i] + val nearness = if (press > 0f) bell((y - fingerY) / waveWidth) else 0f + val isSelected = i == selected && press > 0f + + val scale = 1f + (if (isSelected) SELECTED_GROWTH else NEAR_GROWTH) * nearness * press + paint.textSize = letterSize * scale + paint.typeface = if (isSelected) boldTypeface else Typeface.DEFAULT + paint.color = if (isSelected) { + activeColor + } else { + ColorUtils.blendARGB(idleColor, activeColor, nearness * press) + } + + val x = baseX - reach * nearness + // Centre the glyph on the letter's line. + val baseline = y - (paint.descent() + paint.ascent()) / 2f + canvas.drawText(letters[i].label, x, baseline, paint) + } + } + + private fun bell(distance: Float): Float = exp(-distance * distance) + + // ---- Touch ------------------------------------------------------------------------------- + + /** True when a touch at this point, in this view's coordinates, starts a scrub. */ + fun isOnStrip(x: Float, y: Float): Boolean { + if (layoutDirty) computeLayout() + if (letters.isEmpty() || !appsView.isInAllApps || appsView.isSearching) return false + return x >= width - touchWidth && y >= stripTop - verticalMargin && y <= stripBottom + verticalMargin + } + + @SuppressLint("ClickableViewAccessibility") + override fun onTouchEvent(event: MotionEvent): Boolean { + when (event.actionMasked) { + MotionEvent.ACTION_DOWN -> { + if (!isOnStrip(event.x, event.y)) return false + // Keep the drawer from scrolling or closing under the thumb. + parent?.requestDisallowInterceptTouchEvent(true) + beginScrub(event.x, event.y) + return true + } + MotionEvent.ACTION_MOVE -> { + if (!scrubbing) return false + moveScrub(event.x, event.y) + return true + } + MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { + if (!scrubbing) return false + endScrub() + return true + } + } + return scrubbing + } + + /** Starts a scrub with the finger at ([x], [y]) in this view's coordinates. */ + fun beginScrub(x: Float, y: Float) { + refreshIfChanged() + if (layoutDirty) computeLayout() + if (letters.isEmpty()) return + scrubbing = true + selected = -1 + animatePress(1f, PRESS_IN_MS) + moveScrub(x, y) + } + + /** Moves the finger of a scrub started with [beginScrub]. */ + fun moveScrub(x: Float, y: Float) { + if (!scrubbing || letters.isEmpty()) return + fingerX = x + fingerY = y.coerceIn(stripTop, stripBottom) + + val spacing = (stripBottom - stripTop) / letters.size + val index = ((fingerY - stripTop) / spacing).toInt().coerceIn(0, letters.size - 1) + if (index != selected) { + selected = index + performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK) + scrollListTo(letters[index].adapterPosition) + } + invalidate() + } + + /** Ends the scrub; the list stays at the last letter and the wave settles back to the edge. */ + fun endScrub() { + if (!scrubbing) return + scrubbing = false + animatePress(0f, PRESS_OUT_MS) + } + + val isScrubbing: Boolean get() = scrubbing + + private fun scrollListTo(adapterPosition: Int) { + val rv = appsView.activeRecyclerView ?: return + rv.stopScroll() + (rv.layoutManager as? LinearLayoutManager)?.scrollToPositionWithOffset(adapterPosition, 0) + } + + private fun animatePress(target: Float, durationMs: Long) { + pressAnimator?.cancel() + if (abs(press - target) < 0.001f) { + press = target + invalidate() + return + } + pressAnimator = ValueAnimator.ofFloat(press, target).apply { + duration = max(1L, (durationMs * abs(target - press)).roundToInt().toLong()) + interpolator = DecelerateInterpolator() + addUpdateListener { + press = it.animatedValue as Float + invalidate() + } + start() + } + } + + private companion object { + /** How much larger than its resting size the selected letter grows. */ + const val SELECTED_GROWTH = 1.5f + + /** How much its neighbours grow, tapering with distance from the finger. */ + const val NEAR_GROWTH = 0.5f + + const val PRESS_IN_MS = 110L + const val PRESS_OUT_MS = 220L + } +} diff --git a/lawnchair/src/app/lawnchair/preferences/PreferenceManager.kt b/lawnchair/src/app/lawnchair/preferences/PreferenceManager.kt index 5e7eda167d..291e9161cd 100644 --- a/lawnchair/src/app/lawnchair/preferences/PreferenceManager.kt +++ b/lawnchair/src/app/lawnchair/preferences/PreferenceManager.kt @@ -122,7 +122,8 @@ class PreferenceManager @Inject constructor( val workspaceIncreaseMaxGridSize = BoolPref("pref_workspace_increase_max_grid_size", false) val folderRows = IdpIntPref("pref_folderRows", { numFolderRows[INDEX_DEFAULT] }, reloadGrid) - val drawerOpacity = FloatPref("pref_drawerOpacity", .5f, recreate) + // Flexera Launcher: the drawer has no background panel by default (Lawnchair's default is .5f). + val drawerOpacity = FloatPref("pref_drawerOpacity", 0f, recreate) val coloredBackgroundLightness = FloatPref("pref_coloredBackgroundLightness", 1F) val feedProvider = StringPref("pref_feedProvider", "") val ignoreFeedWhitelist = BoolPref("pref_ignoreFeedWhitelist", false) diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java index 8d907f4183..7b2932a615 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java @@ -79,6 +79,12 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch private final float mMotionPauseMinDisplacement; private boolean mDidTouchStartInNavBar; + + // Flexera Launcher: swipe up and hold hands the same touch to the wave alphabet (PRD AD-17). + // "Started" is set when the pause is detected and the drawer begins to finish opening; + // "ready" is set once it is fully open and the alphabet can take the finger's position. + private boolean mFlexeraScrubStarted; + private boolean mFlexeraScrubReady; private boolean mStartedOverview; private boolean mReachedOverview; // The last recorded displacement before we reached overview. @@ -163,6 +169,13 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch mMotionPauseDetector.setOnMotionPauseListener(this::onMotionPauseDetected); } + // Flexera Launcher: a pause during an ordinary swipe up to the drawer starts a scrub. + mFlexeraScrubStarted = false; + mFlexeraScrubReady = false; + if (flexeraHoldToScrub()) { + mMotionPauseDetector.setOnMotionPauseListener(this::onFlexeraHoldDetected); + } + if (mFromState == NORMAL && mToState == HINT_STATE) { mNormalToHintOverviewScrimAnimator = ObjectAnimator.ofObject( mLauncher.getScrimView(), @@ -197,7 +210,14 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch controller.setShouldDelayLauncherStateAnim(false); } - if (mStartedOverview) { + if (mFlexeraScrubStarted) { + // Flexera Launcher: lifting the finger ends the scrub and leaves the drawer open at + // the chosen letter. If the drawer is still opening, its end callback finishes up. + app.flexera.drawer.FlexeraDrawer.endScrubFromSwipe(mLauncher.getAppsView()); + if (mFlexeraScrubReady) { + onSwipeInteractionCompleted(ALL_APPS); + } + } else if (mStartedOverview) { goToOverviewOrHomeOnDragEnd(velocity); } else { InteractionJankMonitorWrapper.cancel(Cuj.CUJ_LAUNCHER_APP_SWIPE_TO_RECENTS); @@ -251,6 +271,40 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch VibratorWrapper.INSTANCE.get(mLauncher).vibrate(OVERVIEW_HAPTIC); } + /** + * Flexera Launcher: true while this gesture is an ordinary swipe up from the home screen to + * the drawer, which is the one gesture where holding still should start an alphabet scrub. + * A swipe that starts on the navigation bar keeps its stock meaning (recents). + */ + private boolean flexeraHoldToScrub() { + return !mIsTrackpadSwipe && !mDidTouchStartInNavBar + && mStartState == NORMAL && mToState == ALL_APPS; + } + + /** + * Flexera Launcher: the finger paused part-way through a swipe up. Finish opening the drawer + * and, once it is open, let the same touch scrub the wave alphabet. This mirrors + * {@link #onMotionPauseDetected()}, which does the same hand-over to Overview. + */ + private void onFlexeraHoldDetected() { + if (mCurrentAnimation == null || mFlexeraScrubStarted || !flexeraHoldToScrub()) { + return; + } + mCurrentAnimation.getTarget().addListener(newSingleUseCancelListener(() -> + mLauncher.getStateManager().goToState(ALL_APPS, true, forSuccessCallback(() -> { + mFlexeraScrubReady = true; + if (!mDetector.isDraggingState()) { + // The finger lifted while the drawer was still opening. + onSwipeInteractionCompleted(ALL_APPS); + } + })))); + + mCurrentAnimation.getTarget().removeListener(mClearStateOnCancelListener); + mCurrentAnimation.dispatchOnCancel(); + mFlexeraScrubStarted = true; + VibratorWrapper.INSTANCE.get(mLauncher).vibrate(OVERVIEW_HAPTIC); + } + private void maybeSwipeInteractionToOverviewComplete() { if (mReachedOverview && !mDetector.isDraggingState()) { InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_APP_SWIPE_TO_RECENTS); @@ -266,6 +320,15 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch @Override public boolean onDrag(float yDisplacement, float xDisplacement, MotionEvent event) { + if (mFlexeraScrubStarted) { + // Flexera Launcher: the swipe has become a scrub; the finger now moves the alphabet, + // not the drawer. Until the drawer has finished opening there is nothing to move yet. + if (mFlexeraScrubReady) { + app.flexera.drawer.FlexeraDrawer.scrubFromSwipe( + mLauncher.getAppsView(), mLauncher.getDragLayer(), event); + } + return true; + } if (mStartedOverview) { if (!mReachedOverview) { mStartDisplacement.set(xDisplacement, yDisplacement); @@ -284,12 +347,22 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch } float upDisplacement = -yDisplacement; - mMotionPauseDetector.setDisallowPause(!handlingOverviewAnim() - || upDisplacement < mMotionPauseMinDisplacement); + // Flexera Launcher: a pause also matters on an ordinary swipe up to the drawer, but only + // after the swipe has travelled far enough that it is clearly not a slow start. + boolean holdToScrub = flexeraHoldToScrub(); + float minDisplacement = holdToScrub + ? app.flexera.drawer.FlexeraDrawer.holdMinSwipePx(mLauncher) + : mMotionPauseMinDisplacement; + mMotionPauseDetector.setDisallowPause(!(handlingOverviewAnim() || holdToScrub) + || upDisplacement < minDisplacement); mMotionPauseDetector.addPosition(event); // Stay in Overview. - return mStartedOverview || super.onDrag(yDisplacement, xDisplacement, event); + // Flexera Launcher: likewise, once this very event has triggered the hold hand-over (inside + // addPosition above), it must not also reach the normal drag code. That code would move + // the drawer back to the finger's position and leave it stuck there. + return mStartedOverview || mFlexeraScrubStarted + || super.onDrag(yDisplacement, xDisplacement, event); } private void goToOverviewOrHomeOnDragEnd(float velocity) { diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index 22b8008b20..3e2abd4737 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -372,6 +372,9 @@ public class ActivityAllAppsContainerView updateBackgroundVisibility(mActivityContext.getDeviceProfile()); mSearchUiManager.initializeSearch(this); + + // Flexera Launcher: the wave alphabet on the drawer's edge. + app.flexera.drawer.FlexeraDrawer.attachWaveAlphabet(this); } @Override @@ -515,6 +518,11 @@ public class ActivityAllAppsContainerView public boolean shouldContainerScroll(MotionEvent ev) { BaseDragLayer dragLayer = mActivityContext.getDragLayer(); + // Flexera Launcher: a touch on the wave alphabet scrubs the list; it must not drag the + // whole drawer closed. + if (app.flexera.drawer.FlexeraDrawer.isOverWaveAlphabet(this, dragLayer, ev)) { + return false; + } // If the MotionEvent is inside the search box, and the container keeps on receiving touch // input, container should move down. if (dragLayer.isEventOverView(mSearchContainer, ev)) { diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 9f62bd66c3..99f177dd5a 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -239,7 +239,12 @@ public class AllAppsTransitionController mLauncher.getStateManager().getCurrentStableState() == BACKGROUND_APP; // Allow apps panel to shift the full screen if coming from another app. float shiftRange = fromBackground ? mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx() : mShiftRange; - getAppsViewProgressTranslationY().setValue(mProgress * shiftRange); + // Flexera Launcher: the drawer fades in over the home screen instead of sliding up from + // the bottom. It stays in place while opening or closing and is parked off-screen only + // when fully closed, so that it takes no touches there. + getAppsViewProgressTranslationY().setValue( + app.flexera.drawer.FlexeraDrawer.panelTranslation(mProgress, shiftRange)); + app.flexera.drawer.FlexeraDrawer.applyOpenProgress(mAppsView, mProgress); mLauncher.onAllAppsTransition(1 - progress); boolean hasScrim = progress < NAV_BAR_COLOR_FORCE_UPDATE_THRESHOLD diff --git a/src/com/android/launcher3/views/RecyclerViewFastScroller.java b/src/com/android/launcher3/views/RecyclerViewFastScroller.java index 89c85d0164..9215b05a46 100644 --- a/src/com/android/launcher3/views/RecyclerViewFastScroller.java +++ b/src/com/android/launcher3/views/RecyclerViewFastScroller.java @@ -528,7 +528,9 @@ public class RecyclerViewFastScroller extends View { } public boolean isHitInParent(float x, float y, Point outOffset) { - if (mThumbOffsetY < 0) { + // Flexera Launcher: a hidden scroll bar must not take touches. Lawnchair hides it by + // making it invisible, which leaves it laid out and, without this check, still touchable. + if (mThumbOffsetY < 0 || getVisibility() != VISIBLE) { return false; } getHitRect(sTempRect);