From 4be9c0b431547fb9b31ed3ccf397d3af431619fa Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 4 Jan 2019 20:40:46 +0100 Subject: [PATCH] fix #297, allow one to one pixel ratio zooming with two double taps --- app/build.gradle | 2 +- .../pro/activities/SettingsActivity.kt | 10 ++++++++ .../gallery/pro/fragments/PhotoFragment.kt | 10 ++++---- .../gallery/pro/helpers/Config.kt | 4 ++++ .../gallery/pro/helpers/Constants.kt | 1 + app/src/main/res/layout/activity_settings.xml | 24 +++++++++++++++++++ 6 files changed, 46 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b31ee9a6c..33b03df6b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -78,7 +78,7 @@ dependencies { //implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0' //implementation 'com.github.tibbi:subsampling-scale-image-view:v3.10.1-fork' - implementation 'com.github.tibbi:subsampling-scale-image-view:4.0.2' + implementation 'com.github.tibbi:subsampling-scale-image-view:7a000e651e' // implementation 'com.github.chrisbanes:PhotoView:2.3.0' implementation 'com.github.tibbi:PhotoView:2.3.0-fork' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt index 8426bd8c4..eb292610f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt @@ -65,6 +65,7 @@ class SettingsActivity : SimpleActivity() { setupAllowZoomingImages() setupShowHighestQuality() setupOneFingerZoom() + setupAllowOneToOneZoom() setupAllowInstantChange() setupShowExtendedDetails() setupHideExtendedDetails() @@ -377,6 +378,7 @@ class SettingsActivity : SimpleActivity() { private fun updateDeepZoomToggleButtons() { settings_one_finger_zoom_holder.beVisibleIf(config.allowZoomingImages) settings_show_highest_quality_holder.beVisibleIf(config.allowZoomingImages) + settings_allow_one_to_one_zoom_holder.beVisibleIf(config.allowZoomingImages) } private fun setupShowHighestQuality() { @@ -395,6 +397,14 @@ class SettingsActivity : SimpleActivity() { } } + private fun setupAllowOneToOneZoom() { + settings_allow_one_to_one_zoom.isChecked = config.allowOneToOneZoom + settings_allow_one_to_one_zoom_holder.setOnClickListener { + settings_allow_one_to_one_zoom.toggle() + config.allowOneToOneZoom = settings_allow_one_to_one_zoom.isChecked + } + } + private fun setupAllowInstantChange() { settings_allow_instant_change.isChecked = config.allowInstantChange settings_allow_instant_change_holder.setOnClickListener { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt index 910039de2..0517bc088 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt @@ -393,15 +393,17 @@ class PhotoFragment : ViewPagerFragment() { override fun make() = PicassoRegionDecoder() } + val config = context!!.config view.subsampling_view.apply { - setMaxTileSize(if (context!!.config.showHighestQuality) Integer.MAX_VALUE else 4096) - setMinimumTileDpi(if (context!!.config.showHighestQuality) -1 else getMinTileDpi()) + setMaxTileSize(if (config.showHighestQuality) Integer.MAX_VALUE else 4096) + setMinimumTileDpi(if (config.showHighestQuality) -1 else getMinTileDpi()) background = ColorDrawable(Color.TRANSPARENT) setBitmapDecoderFactory(bitmapDecoder) setRegionDecoderFactory(regionDecoder) maxScale = 10f beVisible() - isQuickScaleEnabled = context.config.oneFingerZoom + isQuickScaleEnabled = config.oneFingerZoom + isOneToOneZoomEnabled = config.allowOneToOneZoom setResetScaleOnSizeChange(false) setImage(ImageSource.uri(path)) setOrientation(rotation) @@ -411,7 +413,7 @@ class PhotoFragment : ViewPagerFragment() { } override fun onReady() { - background = ColorDrawable(if (context.config.blackBackground) Color.BLACK else context.config.backgroundColor) + background = ColorDrawable(if (config.blackBackground) Color.BLACK else config.backgroundColor) val useWidth = if (imageOrientation == ORIENTATION_ROTATE_90 || imageOrientation == ORIENTATION_ROTATE_270) sHeight else sWidth val useHeight = if (imageOrientation == ORIENTATION_ROTATE_90 || imageOrientation == ORIENTATION_ROTATE_270) sWidth else sHeight setDoubleTapZoomScale(getDoubleTapZoomScale(useWidth, useHeight)) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt index 1b479de80..c218dc78c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt @@ -441,4 +441,8 @@ class Config(context: Context) : BaseConfig(context) { var showWidgetFolderName: Boolean get() = prefs.getBoolean(SHOW_WIDGET_FOLDER_NAME, true) set(showWidgetFolderName) = prefs.edit().putBoolean(SHOW_WIDGET_FOLDER_NAME, showWidgetFolderName).apply() + + var allowOneToOneZoom: Boolean + get() = prefs.getBoolean(ALLOW_ONE_TO_ONE_ZOOM, false) + set(allowOneToOneZoom) = prefs.edit().putBoolean(ALLOW_ONE_TO_ONE_ZOOM, allowOneToOneZoom).apply() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt index 3b234336e..9baa22b50 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt @@ -74,6 +74,7 @@ const val LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_X = "last_editor_crop_other_aspect const val LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_Y = "last_editor_crop_other_aspect_ratio_y" const val GROUP_DIRECT_SUBFOLDERS = "group_direct_subfolders" const val SHOW_WIDGET_FOLDER_NAME = "show_widget_folder_name" +const val ALLOW_ONE_TO_ONE_ZOOM = "allow_one_to_one_zoom" // slideshow const val SLIDESHOW_INTERVAL = "slideshow_interval" diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 75d86d798..72de10803 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -795,6 +795,30 @@ + + + + + +