Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ class DisplayRecorder @Inject internal constructor(

do {
result = imageReaderProxy.getLastFrame()
if (result == null) delay(20.milliseconds)
if (result == null) delay(40.milliseconds)

} while (result == null && System.currentTimeMillis() < (startTimeMs + 1000))
} while (result == null && System.currentTimeMillis() < (startTimeMs + SCREEN_CAPTURE_SCREENSHOT_TIMEOUT_MS))

return result
}
Expand Down Expand Up @@ -202,7 +202,9 @@ class DisplayRecorder @Inject internal constructor(
}

/** How long to wait for the first valid frame when validating screen capture support, in milliseconds. */
private const val SCREEN_CAPTURE_VALIDATION_TIMEOUT_MS = 1000L
private const val SCREEN_CAPTURE_SCREENSHOT_TIMEOUT_MS = 2000L
/** How long to wait for the first valid frame when validating screen capture support, in milliseconds. */
private const val SCREEN_CAPTURE_VALIDATION_TIMEOUT_MS = 2000L
/** Polling interval between frame acquisition attempts during screen capture validation, in milliseconds. */
private const val SCREEN_CAPTURE_VALIDATION_RETRY_DELAY_MS = 20L

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.buzbuz.smartautoclicker.core.common.navigation

import android.content.Context
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.data.Tip
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.Tip
import dagger.hilt.EntryPoints

interface TutorialNavigator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.Window
import android.view.WindowManager

import androidx.annotation.CallSuper
import androidx.annotation.StyleRes
Expand All @@ -49,8 +47,6 @@ abstract class NavBarDialog(@StyleRes theme: Int) : OverlayDialog(theme) {
lateinit var floatingActionButtons: IncludeFloatingActionButtonsBinding
lateinit var topBarBinding: IncludeDialogNavigationTopBarBinding

private var imeLiftController: NavBarDialogImeLiftController? = null

abstract fun inflateMenu(navBarView: NavigationBarView)

abstract fun onCreateContent(navItemId: Int): NavBarDialogContent
Expand All @@ -59,17 +55,6 @@ abstract class NavBarDialog(@StyleRes theme: Int) : OverlayDialog(theme) {

open fun onContentViewChanged(navItemId: Int) = Unit

/**
* Keep window size unchanged while the IME is shown.
* Portrait bottom bar sits on the dialog [CoordinatorLayout]; [SOFT_INPUT_ADJUST_RESIZE] parks the sheet mid-screen.
*/
override fun applySoftInputMode(window: Window) {
window.setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING or
WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN,
)
}

override fun onCreateView(): ViewGroup {
baseViewBinding = DialogBaseNavBarBinding.inflate(LayoutInflater.from(context)).apply {
layoutTopBar.apply {
Expand Down Expand Up @@ -114,15 +99,6 @@ abstract class NavBarDialog(@StyleRes theme: Int) : OverlayDialog(theme) {
setupPortraitViews()
}

val coordinator = dialogCoordinatorLayout
val decor = dialog.window?.decorView
if (coordinator != null && decor != null) {
imeLiftController = NavBarDialogImeLiftController(
liftTarget = coordinator,
insetHost = decor,
).also { it.start() }
}

updateContentView(
itemId = navBarView.selectedItemId,
forceUpdate = true,
Expand All @@ -140,8 +116,6 @@ abstract class NavBarDialog(@StyleRes theme: Int) : OverlayDialog(theme) {
}

override fun onDestroy() {
imeLiftController?.stop()
imeLiftController = null
contentMap.values.forEach { content ->
content.destroy()
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,30 @@ abstract class OverlayMenu(
*/
protected fun setMenuItemVisibility(view: View, visible: Boolean) {
Log.d(TAG, "setMenuItemVisibility for ${hashCode()}, $view to $visible")

if (view.isVisible == visible) return
view.isVisible = visible

if (!resizeController.isAnimating) forceWindowResize()
if (canResizeWindow()) forceWindowResize()
}

/**
* Set the visibility of several menu items.
* When changing multiple items visibility, use this method to recompute the window size only once.
*
* @param viewState map of the item views to their new visibility
*/
protected fun setMenuItemsVisibility(viewState: Map<View, Boolean>) {
Log.d(TAG, "setMenuItemVisibility for ${hashCode()}, $viewState")

var haveChanged = false
viewState.forEach { (view, isVisible) ->
haveChanged = haveChanged || view.isVisible != isVisible
view.isVisible = isVisible
}

if (!haveChanged) return
if (canResizeWindow()) forceWindowResize()
}

/**
Expand All @@ -477,6 +498,10 @@ abstract class OverlayMenu(
resizeController.animateLayoutChanges(layoutChanges)
}

private fun canResizeWindow(): Boolean =
!resizeController.isAnimating && !animations.showAnimationIsRunning
&& !animations.hideAnimationIsRunning && menuBackground.width > 0

private fun forceWindowResize() {
Log.d(TAG, "Force window resize")
onNewWindowSize(resizeController.measureMenuSize())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ internal class OverlayMenuAnimations : Dumpable {
showAnimationIsRunning = false
showOverlayMenuAnimation.cancel()
showOverlayViewAnimation.cancel()

view.alpha = 1f
if (overlayView is ViewGroup && overlayView.childCount == 1) overlayView.children.first().alpha = 1f

onAnimationEnded()
}
view.postDelayed(timeoutCallback, 1_000)
Expand Down Expand Up @@ -107,6 +111,10 @@ internal class OverlayMenuAnimations : Dumpable {
hideAnimationIsRunning = false
hideOverlayMenuAnimation.cancel()
hideOverlayViewAnimation.cancel()

view.alpha = 0f
if (overlayView is ViewGroup && overlayView.childCount == 1) overlayView.children.first().alpha = 0f

onAnimationEnded()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,15 @@ internal class OverlayMenuResizeController(
}

fun measureMenuSize(): Size {
resizedContainer.measure(MeasureSpec.EXACTLY, MeasureSpec.EXACTLY)
resizedContainer.measure(
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
)

// Get the height of all children + the padding
// Get the height of all children + the padding.
// Use measuredHeight as fallback for views that are now visible but not yet laid out (height == 0).
val height = resizedContainer.children.fold(0) { acc, child ->
acc + (if (child.isGone) 0 else child.height)
acc + (if (child.isGone) 0 else maxOf(child.height, child.measuredHeight))
} + resizedContainer.paddingTop + resizedContainer.paddingBottom

val firstChild = (backgroundViewGroup.getChildAt(0) as? ViewGroup)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
package com.buzbuz.smartautoclicker.core.common.tutorial.domain

import android.content.Intent
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.data.Tutorial
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.data.TutorialInfo
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.data.Tip
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.tutorial.Tutorial
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.Tip
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.state.TutorialState

import kotlinx.coroutines.flow.Flow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
package com.buzbuz.smartautoclicker.core.common.tutorial.domain

import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.data.subject.TutorialSubject
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.data.subject.quickclickgame.QuickClickGameTargetType
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.tutorial.subject.TutorialSubject
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.tutorial.subject.quickclickgame.QuickClickGameTargetType
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.state.TutorialSubjectState
import kotlinx.coroutines.flow.StateFlow

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2026 Kevin Buzeau
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -14,8 +14,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.data
package com.buzbuz.smartautoclicker.core.common.tutorial.domain.model

enum class Tip {
IMAGE_CAPTURE,
IMAGE_DETECTION_AREA,
NUMBER_DETECTION_AREA,
TEXT_DETECTION_AREA,
STOP_WITH_VOLUME_DOWN,
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
package com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.state

import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.data.Tutorial
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.data.step.TutorialStep
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.tutorial.Tutorial
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.tutorial.step.TutorialStep

/**
* Lifecycle state of the tutorial engine, emitted on [TutorialRepository.tutorialState].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
*/
package com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.state

import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.data.subject.TutorialSubject
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.data.subject.quickclickgame.QuickClickGameTargetState
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.data.subject.quickclickgame.QuickClickGameTargetType
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.tutorial.subject.TutorialSubject
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.tutorial.subject.quickclickgame.QuickClickGameTargetState
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.tutorial.subject.quickclickgame.QuickClickGameTargetType

/**
* Live state of the active tutorial subject, emitted on [TutorialSubjectController.Game.state].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.data
package com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.tutorial

import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.data.step.TutorialStep
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.data.subject.TutorialSubject
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.tutorial.step.TutorialStep
import com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.tutorial.subject.TutorialSubject

/**
* Root definition of a single tutorial.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.data
package com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.tutorial

import androidx.annotation.StringRes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.data.step
package com.buzbuz.smartautoclicker.core.common.tutorial.domain.model.tutorial.step

import androidx.annotation.StringRes

Expand Down
Loading
Loading