fix #297, allow one to one pixel ratio zooming with two double taps

This commit is contained in:
tibbi 2019-01-04 20:40:46 +01:00
parent 61e51058da
commit 4be9c0b431
6 changed files with 46 additions and 5 deletions

View file

@ -78,7 +78,7 @@ dependencies {
//implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0' //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: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.chrisbanes:PhotoView:2.3.0'
implementation 'com.github.tibbi:PhotoView:2.3.0-fork' implementation 'com.github.tibbi:PhotoView:2.3.0-fork'

View file

@ -65,6 +65,7 @@ class SettingsActivity : SimpleActivity() {
setupAllowZoomingImages() setupAllowZoomingImages()
setupShowHighestQuality() setupShowHighestQuality()
setupOneFingerZoom() setupOneFingerZoom()
setupAllowOneToOneZoom()
setupAllowInstantChange() setupAllowInstantChange()
setupShowExtendedDetails() setupShowExtendedDetails()
setupHideExtendedDetails() setupHideExtendedDetails()
@ -377,6 +378,7 @@ class SettingsActivity : SimpleActivity() {
private fun updateDeepZoomToggleButtons() { private fun updateDeepZoomToggleButtons() {
settings_one_finger_zoom_holder.beVisibleIf(config.allowZoomingImages) settings_one_finger_zoom_holder.beVisibleIf(config.allowZoomingImages)
settings_show_highest_quality_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() { 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() { private fun setupAllowInstantChange() {
settings_allow_instant_change.isChecked = config.allowInstantChange settings_allow_instant_change.isChecked = config.allowInstantChange
settings_allow_instant_change_holder.setOnClickListener { settings_allow_instant_change_holder.setOnClickListener {

View file

@ -393,15 +393,17 @@ class PhotoFragment : ViewPagerFragment() {
override fun make() = PicassoRegionDecoder() override fun make() = PicassoRegionDecoder()
} }
val config = context!!.config
view.subsampling_view.apply { view.subsampling_view.apply {
setMaxTileSize(if (context!!.config.showHighestQuality) Integer.MAX_VALUE else 4096) setMaxTileSize(if (config.showHighestQuality) Integer.MAX_VALUE else 4096)
setMinimumTileDpi(if (context!!.config.showHighestQuality) -1 else getMinTileDpi()) setMinimumTileDpi(if (config.showHighestQuality) -1 else getMinTileDpi())
background = ColorDrawable(Color.TRANSPARENT) background = ColorDrawable(Color.TRANSPARENT)
setBitmapDecoderFactory(bitmapDecoder) setBitmapDecoderFactory(bitmapDecoder)
setRegionDecoderFactory(regionDecoder) setRegionDecoderFactory(regionDecoder)
maxScale = 10f maxScale = 10f
beVisible() beVisible()
isQuickScaleEnabled = context.config.oneFingerZoom isQuickScaleEnabled = config.oneFingerZoom
isOneToOneZoomEnabled = config.allowOneToOneZoom
setResetScaleOnSizeChange(false) setResetScaleOnSizeChange(false)
setImage(ImageSource.uri(path)) setImage(ImageSource.uri(path))
setOrientation(rotation) setOrientation(rotation)
@ -411,7 +413,7 @@ class PhotoFragment : ViewPagerFragment() {
} }
override fun onReady() { 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 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 val useHeight = if (imageOrientation == ORIENTATION_ROTATE_90 || imageOrientation == ORIENTATION_ROTATE_270) sWidth else sHeight
setDoubleTapZoomScale(getDoubleTapZoomScale(useWidth, useHeight)) setDoubleTapZoomScale(getDoubleTapZoomScale(useWidth, useHeight))

View file

@ -441,4 +441,8 @@ class Config(context: Context) : BaseConfig(context) {
var showWidgetFolderName: Boolean var showWidgetFolderName: Boolean
get() = prefs.getBoolean(SHOW_WIDGET_FOLDER_NAME, true) get() = prefs.getBoolean(SHOW_WIDGET_FOLDER_NAME, true)
set(showWidgetFolderName) = prefs.edit().putBoolean(SHOW_WIDGET_FOLDER_NAME, showWidgetFolderName).apply() 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()
} }

View file

@ -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 LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_Y = "last_editor_crop_other_aspect_ratio_y"
const val GROUP_DIRECT_SUBFOLDERS = "group_direct_subfolders" const val GROUP_DIRECT_SUBFOLDERS = "group_direct_subfolders"
const val SHOW_WIDGET_FOLDER_NAME = "show_widget_folder_name" const val SHOW_WIDGET_FOLDER_NAME = "show_widget_folder_name"
const val ALLOW_ONE_TO_ONE_ZOOM = "allow_one_to_one_zoom"
// slideshow // slideshow
const val SLIDESHOW_INTERVAL = "slideshow_interval" const val SLIDESHOW_INTERVAL = "slideshow_interval"

View file

@ -795,6 +795,30 @@
</RelativeLayout> </RelativeLayout>
<RelativeLayout
android:id="@+id/settings_allow_one_to_one_zoom_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingRight="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/settings_allow_one_to_one_zoom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:paddingStart="@dimen/medium_margin"
android:paddingLeft="@dimen/medium_margin"
android:text="@string/allow_one_to_one_zoom"
app:switchPadding="@dimen/medium_margin"/>
</RelativeLayout>
<View <View
android:id="@+id/extended_details_divider" android:id="@+id/extended_details_divider"
android:layout_width="match_parent" android:layout_width="match_parent"