Skip to content

Commit

Permalink
change: pausedContinuousTransformType, pausedContinuousTransformTypeS…
Browse files Browse the repository at this point in the history
…tate, disabledGestureType, disabledGestureTypeState renamed to pausedContinuousTransformTypes, pausedContinuousTransformTypesState, disabledGestureTypes, disabledGestureTypesState
  • Loading branch information
panpf committed Jul 23, 2024
1 parent f15488e commit e044476
Show file tree
Hide file tree
Showing 19 changed files with 118 additions and 96 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ subsampling:
destroyed. [#29](https://github.com/panpf/zoomimage/issues/29)
* improve: Tiles loaded from memory now also animate when displayed

zoom:

* change: The pausedContinuousTransformType property name of SubsamplingState is changed to
pausedContinuousTransformTypes, and the pausedContinuousTransformTypeState property name of
SubsamplingEngine is changed to pausedContinuousTransformTypesState
* change: The disabledGestureType property name of ZoomableState is changed to disabledGestureTypes,
and the disabledGestureTypeState property name of ZoomableEngine is changed to
disabledGestureTypesState

## 1.1.0-alpha02

subsampling:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ subsampling:
BitmapRegionDecoderDecodeHelper 时关闭输入流。 [#29](https://github.com/panpf/zoomimage/issues/29)
* improve: 现在从内存中加载的图块在显示时也会有动画效果

zoom:

* change: SubsamplingState 的 pausedContinuousTransformType 属性名称改为
pausedContinuousTransformTypes,SubsamplingEngine 的 pausedContinuousTransformTypeState 属性名称改为
pausedContinuousTransformTypesState
* change: ZoomableState 的 disabledGestureType 属性名称改为 disabledGestureTypes,ZoomableEngine 的
disabledGestureTypeState 属性名称改为 disabledGestureTypesState

## 1.1.0-alpha02

subsampling:
Expand Down
6 changes: 3 additions & 3 deletions docs/wiki/subsampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ loading tiles, which can improve performance
The default configuration of ZoomImage is 'SCALE', 'OFFSET', 'LOCATE' three types of continuous
transformations that pause the loading of tiles, 'GESTURE',
The 'FLING' two types load tiles in real time, which you can configure via the
`pausedContinuousTransformType` property
`pausedContinuousTransformTypes` property

example:

Expand All @@ -148,10 +148,10 @@ val zoomState: ZoomState by rememberZoomState()

LaunchEffect(Unit) {
// All continuous transform types load tiles in real time
zoomState.subsampling.pausedContinuousTransformType = ContinuousTransformType.NONE
zoomState.subsampling.pausedContinuousTransformTypes = 0

// All continuous transform types pause loading of tiles
zoomState.subsampling.pausedContinuousTransformType =
zoomState.subsampling.pausedContinuousTransformTypes =
TileManager.DefaultPausedContinuousTransformType or ContinuousTransformType.GESTURE or ContinuousTransformType.FLING
}

Expand Down
6 changes: 3 additions & 3 deletions docs/wiki/subsampling_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ ZoomImage 将连续变换行为分为 `SCALE`, `OFFSET`, `LOCATE`, `GESTURE`, `F

ZoomImage 在兼顾性能和体验的情况默认配置是 `SCALE`, `OFFSET`, `LOCATE`
三种类型的连续变换会暂停加载图块,`GESTURE`, `FLING` 两种类型会实时加载图块,
你可以通过 `pausedContinuousTransformType` 属性来配置它
你可以通过 `pausedContinuousTransformTypes` 属性来配置它

示例:

Expand All @@ -129,10 +129,10 @@ val zoomState: ZoomState by rememberZoomState()

LaunchEffect(Unit) {
// 所有连续变换类型都实时加载图块
zoomState.subsampling.pausedContinuousTransformType = ContinuousTransformType.NONE
zoomState.subsampling.pausedContinuousTransformTypes = 0

// 所有连续变换类型都暂停加载图块
zoomState.subsampling.pausedContinuousTransformType =
zoomState.subsampling.pausedContinuousTransformTypes =
TileManager.DefaultPausedContinuousTransformType or ContinuousTransformType.GESTURE or ContinuousTransformType.FLING
}

Expand Down
6 changes: 3 additions & 3 deletions docs/wiki/zoom.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ val zoomState: ZoomState by rememberZoomState()

LaunchEffect(Unit) {
// Turn off one-finger scale gesture
zoomState.zoomable.disabledGestureType = GestureType.ONE_FINGER_SCALE
zoomState.zoomable.disabledGestureTypes = GestureType.ONE_FINGER_SCALE
}

SketchZoomAsyncImage(
Expand Down Expand Up @@ -316,7 +316,7 @@ SketchZoomAsyncImage(
### Disabled gestures

ZoomImage supports gestures such as double-click zoom, two-finger zoom, one-finger zoom, drag, etc.,
which are enabled by default, and you can disable them through the `disabledGestureType` property
which are enabled by default, and you can disable them through the `disabledGestureTypes` property

example:

Expand All @@ -325,7 +325,7 @@ val zoomState: ZoomState by rememberZoomState()

LaunchEffect(Unit) {
// Turn off all scale gestures and keep only the drag gesture
zoomState.zoomable.disabledGestureType =
zoomState.zoomable.disabledGestureTypes =
GestureType.TWO_FINGER_SCALE or GestureType.ONE_FINGER_SCALE or GestureType.DOUBLE_TAP_SCALE
}

Expand Down
6 changes: 3 additions & 3 deletions docs/wiki/zoom_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ val zoomState: ZoomState by rememberZoomState()

LaunchEffect(Unit) {
// 关闭单指缩放手势
zoomState.zoomable.disabledGestureType = GestureType.ONE_FINGER_SCALE
zoomState.zoomable.disabledGestureTypes = GestureType.ONE_FINGER_SCALE
}

SketchZoomAsyncImage(
Expand Down Expand Up @@ -290,7 +290,7 @@ SketchZoomAsyncImage(
### 禁用手势

ZoomImage 支持双击缩放、双指缩放、单指缩放、拖动等手势,这些手势除单指缩放外默认都是开启的,你可以通过
`disabledGestureType` 属性来禁用它们
`disabledGestureTypes` 属性来禁用它们

示例:

Expand All @@ -299,7 +299,7 @@ val zoomState: ZoomState by rememberZoomState()

LaunchEffect(Unit) {
// 关闭所有缩放手势,只保留拖动手势
zoomState.zoomable.disabledGestureType =
zoomState.zoomable.disabledGestureTypes =
GestureType.TWO_FINGER_SCALE or GestureType.ONE_FINGER_SCALE or GestureType.DOUBLE_TAP_SCALE
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ class ZoomImageSettingsViewModel(
MultiChooseMenu(
title = "Disabled Gesture Type",
values = gestureTypes.map { GestureType.name(it) },
getCheckedList = { gestureTypes.map { it and appSettings.disabledGestureType.value != 0 } },
getCheckedList = { gestureTypes.map { it and appSettings.disabledGestureTypes.value != 0 } },
onSelected = { which, isChecked ->
val checkedList =
gestureTypes.map { it and appSettings.disabledGestureType.value != 0 }
gestureTypes.map { it and appSettings.disabledGestureTypes.value != 0 }
val newCheckedList =
checkedList.toMutableList().apply { set(which, isChecked) }
val newDisabledGestureTypeType =
Expand All @@ -174,7 +174,7 @@ class ZoomImageSettingsViewModel(
}.fold(0) { acc, gestureType ->
acc or gestureType
}
appSettings.disabledGestureType.value = newDisabledGestureTypeType
appSettings.disabledGestureTypes.value = newDisabledGestureTypeType
}
)
)
Expand Down Expand Up @@ -216,10 +216,10 @@ class ZoomImageSettingsViewModel(
MultiChooseMenu(
title = "Paused Continuous Transform Type",
values = continuousTransformTypes.map { ContinuousTransformType.name(it) },
getCheckedList = { continuousTransformTypes.map { it and appSettings.pausedContinuousTransformType.value != 0 } },
getCheckedList = { continuousTransformTypes.map { it and appSettings.pausedContinuousTransformTypes.value != 0 } },
onSelected = { which, isChecked ->
val checkedList =
continuousTransformTypes.map { it and appSettings.pausedContinuousTransformType.value != 0 }
continuousTransformTypes.map { it and appSettings.pausedContinuousTransformTypes.value != 0 }
val newCheckedList =
checkedList.toMutableList().apply { set(which, isChecked) }
val newContinuousTransformType =
Expand All @@ -228,7 +228,7 @@ class ZoomImageSettingsViewModel(
}.fold(0) { acc, continuousTransformType ->
acc or continuousTransformType
}
appSettings.pausedContinuousTransformType.value = newContinuousTransformType
appSettings.pausedContinuousTransformTypes.value = newContinuousTransformType
}
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ abstract class BaseZoomImageViewFragment<ZOOM_VIEW : ZoomImageView> :
animationSpecState.value =
ZoomAnimationSpec.Default.copy(durationMillis = durationMillis)
}
appSettings.disabledGestureType.collectWithLifecycle(viewLifecycleOwner) {
disabledGestureTypeState.value = it
appSettings.disabledGestureTypes.collectWithLifecycle(viewLifecycleOwner) {
disabledGestureTypesState.value = it
}
}
subsampling.apply {
Expand All @@ -203,8 +203,8 @@ abstract class BaseZoomImageViewFragment<ZOOM_VIEW : ZoomImageView> :
tileAnimationSpecState.value =
if (it) TileAnimationSpec.Default else TileAnimationSpec.None
}
appSettings.pausedContinuousTransformType.collectWithLifecycle(viewLifecycleOwner) {
pausedContinuousTransformTypeState.value = it
appSettings.pausedContinuousTransformTypes.collectWithLifecycle(viewLifecycleOwner) {
pausedContinuousTransformTypesState.value = it
}
appSettings.disabledBackgroundTiles.collectWithLifecycle(
viewLifecycleOwner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ class AppSettings(val context: PlatformContext) {
val scalesMultiple by lazy {
stringSettingsStateFlow(context, "scalesMultiple", ScalesCalculator.MULTIPLE.toString())
}
val disabledGestureType by lazy {
intSettingsStateFlow(context, "disabledGestureTypeInt", 0)
val disabledGestureTypes by lazy {
intSettingsStateFlow(context, "disabledGestureTypes", 0)
}

val limitOffsetWithinBaseVisibleRect by lazy {
Expand All @@ -109,9 +109,9 @@ class AppSettings(val context: PlatformContext) {
booleanSettingsStateFlow(context, "readModeAcceptedBoth", true)
}

val pausedContinuousTransformType by lazy {
val initialize = TileManager.DefaultPausedContinuousTransformType
intSettingsStateFlow(context, "pausedContinuousTransformTypeInt", initialize)
val pausedContinuousTransformTypes by lazy {
val initialize = TileManager.DefaultPausedContinuousTransformTypes
intSettingsStateFlow(context, "pausedContinuousTransformTypes", initialize)
}
val disabledBackgroundTiles by lazy {
booleanSettingsStateFlow(context, "disabledBackgroundTiles", false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ fun <T : ZoomState> BaseZoomImageSample(
val limitOffsetWithinBaseVisibleRect by settingsService.limitOffsetWithinBaseVisibleRect.collectAsState()
val scalesCalculatorName by settingsService.scalesCalculator.collectAsState()
val scalesMultipleString by settingsService.scalesMultiple.collectAsState()
val pausedContinuousTransformType by settingsService.pausedContinuousTransformType.collectAsState()
val disabledGestureType by settingsService.disabledGestureType.collectAsState()
val pausedContinuousTransformTypes by settingsService.pausedContinuousTransformTypes.collectAsState()
val disabledGestureTypes by settingsService.disabledGestureTypes.collectAsState()
val disabledBackgroundTiles by settingsService.disabledBackgroundTiles.collectAsState()
val showTileBounds by settingsService.showTileBounds.collectAsState()
val tileAnimation by settingsService.tileAnimation.collectAsState()
Expand Down Expand Up @@ -171,11 +171,11 @@ fun <T : ZoomState> BaseZoomImageSample(
LaunchedEffect(readMode) {
zoomable.readMode = readMode
}
LaunchedEffect(disabledGestureType) {
zoomable.disabledGestureType = disabledGestureType
LaunchedEffect(disabledGestureTypes) {
zoomable.disabledGestureTypes = disabledGestureTypes
}
LaunchedEffect(pausedContinuousTransformType) {
subsampling.pausedContinuousTransformType = pausedContinuousTransformType
LaunchedEffect(pausedContinuousTransformTypes) {
subsampling.pausedContinuousTransformTypes = pausedContinuousTransformTypes
}
LaunchedEffect(disabledBackgroundTiles) {
subsampling.disabledBackgroundTiles = disabledBackgroundTiles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ fun ZoomImageSettingsDialog(onDismissRequest: () -> Unit) {
val gestureTypeStrings = remember {
gestureTypes.map { GestureType.name(it) }
}
val disabledGestureType by appSettings.disabledGestureType.collectAsState()
val disabledGestureTypeCheckedList = remember(disabledGestureType) {
gestureTypes.map { it and disabledGestureType != 0 }
val disabledGestureTypes by appSettings.disabledGestureTypes.collectAsState()
val disabledGestureTypeCheckedList = remember(disabledGestureTypes) {
gestureTypes.map { it and disabledGestureTypes != 0 }
}
MultiChooseSettingItem(
title = "Disabled Gesture Type",
Expand All @@ -179,10 +179,10 @@ fun ZoomImageSettingsDialog(onDismissRequest: () -> Unit) {
val newDisabledGestureType =
newCheckedList.asSequence().mapIndexedNotNull { index, checked ->
if (checked) gestureTypes[index] else null
}.fold(0) { acc, disabledGestureType ->
acc or disabledGestureType
}.fold(0) { acc, gestureType ->
acc or gestureType
}
appSettings.disabledGestureType.value = newDisabledGestureType
appSettings.disabledGestureTypes.value = newDisabledGestureType
}
)

Expand Down Expand Up @@ -221,10 +221,10 @@ fun ZoomImageSettingsDialog(onDismissRequest: () -> Unit) {
val continuousTransformTypeStrings = remember {
continuousTransformTypes.map { ContinuousTransformType.name(it) }
}
val pausedContinuousTransformType by appSettings.pausedContinuousTransformType.collectAsState()
val pausedContinuousTransformTypes by appSettings.pausedContinuousTransformTypes.collectAsState()
val pausedContinuousTransformTypeCheckedList =
remember(pausedContinuousTransformType) {
continuousTransformTypes.map { it and pausedContinuousTransformType != 0 }
remember(pausedContinuousTransformTypes) {
continuousTransformTypes.map { it and pausedContinuousTransformTypes != 0 }
}
MultiChooseSettingItem(
title = "Paused Continuous Transform Type",
Expand All @@ -240,7 +240,8 @@ fun ZoomImageSettingsDialog(onDismissRequest: () -> Unit) {
}.fold(0) { acc, continuousTransformType ->
acc or continuousTransformType
}
appSettings.pausedContinuousTransformType.value = newContinuousTransformType
appSettings.pausedContinuousTransformTypes.value =
newContinuousTransformType
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import com.github.panpf.zoomimage.subsampling.internal.TileBitmapCacheHelper
import com.github.panpf.zoomimage.subsampling.internal.TileBitmapConvertor
import com.github.panpf.zoomimage.subsampling.internal.TileDecoder
import com.github.panpf.zoomimage.subsampling.internal.TileManager
import com.github.panpf.zoomimage.subsampling.internal.TileManager.Companion.DefaultPausedContinuousTransformType
import com.github.panpf.zoomimage.subsampling.internal.TileManager.Companion.DefaultPausedContinuousTransformTypes
import com.github.panpf.zoomimage.subsampling.internal.calculatePreferredTileSize
import com.github.panpf.zoomimage.subsampling.internal.decodeAndCreateTileDecoder
import com.github.panpf.zoomimage.subsampling.internal.toIntroString
Expand Down Expand Up @@ -144,7 +144,9 @@ class SubsamplingState constructor(
*
* @see com.github.panpf.zoomimage.zoom.ContinuousTransformType
*/
var pausedContinuousTransformType: Int by mutableIntStateOf(DefaultPausedContinuousTransformType)
var pausedContinuousTransformTypes: Int by mutableIntStateOf(
DefaultPausedContinuousTransformTypes
)

/**
* Disabling the background tile, which saves memory and improves performance, but when switching sampleSize,
Expand Down Expand Up @@ -266,8 +268,8 @@ class SubsamplingState constructor(
}
}
coroutineScope.launch(Dispatchers.Main.immediate) {
snapshotFlow { pausedContinuousTransformType }.collect {
tileManager?.pausedContinuousTransformType = it
snapshotFlow { pausedContinuousTransformTypes }.collect {
tileManager?.pausedContinuousTransformTypes = it
}
}
coroutineScope.launch(Dispatchers.Main.immediate) {
Expand Down Expand Up @@ -469,7 +471,7 @@ class SubsamplingState constructor(
imageLoadRect = it.imageLoadRect.toPlatform()
}
).apply {
pausedContinuousTransformType = this@SubsamplingState.pausedContinuousTransformType
pausedContinuousTransformTypes = this@SubsamplingState.pausedContinuousTransformTypes
disabledBackgroundTiles = this@SubsamplingState.disabledBackgroundTiles
tileAnimationSpec = this@SubsamplingState.tileAnimationSpec
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class ZoomableState(val logger: Logger) : RememberObserver {
*
* @see com.github.panpf.zoomimage.zoom.GestureType
*/
var disabledGestureType: Int by mutableIntStateOf(0)
var disabledGestureTypes: Int by mutableIntStateOf(0)


/* *********************************** Information properties ******************************* */
Expand Down Expand Up @@ -980,7 +980,7 @@ class ZoomableState(val logger: Logger) : RememberObserver {
}

internal fun checkSupportGestureType(@GestureType gestureType: Int): Boolean =
disabledGestureType.and(gestureType) == 0
disabledGestureTypes.and(gestureType) == 0

private fun limitUserScale(targetUserScale: Float): Float {
val minUserScale = minScale / baseTransform.scaleX
Expand Down
Loading

0 comments on commit e044476

Please sign in to comment.