remember the zoom level used at the file editor

This commit is contained in:
tibbi 2019-01-27 17:34:06 +01:00
parent 23c786d3b9
commit 683845788a
3 changed files with 15 additions and 0 deletions

View File

@ -89,4 +89,8 @@ class Config(context: Context) : BaseConfig(context) {
var enableRootAccess: Boolean
get() = prefs.getBoolean(ENABLE_ROOT_ACCESS, false)
set(enableRootAccess) = prefs.edit().putBoolean(ENABLE_ROOT_ACCESS, enableRootAccess).apply()
var editorTextZoom: Float
get() = prefs.getFloat(EDITOR_TEXT_ZOOM, 0f)
set(editorTextZoom) = prefs.edit().putFloat(EDITOR_TEXT_ZOOM, editorTextZoom).apply()
}

View File

@ -10,6 +10,7 @@ const val SORT_FOLDER_PREFIX = "sort_folder_"
const val TEMPORARILY_SHOW_HIDDEN = "temporarily_show_hidden"
const val IS_ROOT_AVAILABLE = "is_root_available"
const val ENABLE_ROOT_ACCESS = "enable_root_access"
const val EDITOR_TEXT_ZOOM = "editor_text_zoom"
// open as
const val OPEN_AS_DEFAULT = 0

View File

@ -9,6 +9,7 @@ import com.alexvasilkov.gestures.GestureController
import com.alexvasilkov.gestures.State
import com.alexvasilkov.gestures.views.interfaces.GestureView
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.onGlobalLayout
import com.simplemobiletools.filemanager.pro.extensions.config
// taken from
@ -34,6 +35,14 @@ class GestureTextView @JvmOverloads constructor(context: Context, attrs: Attribu
origSize = textSize
setTextColor(context.config.textColor)
setLinkTextColor(context.getAdjustedPrimaryColor())
val storedTextZoom = context.config.editorTextZoom
if (storedTextZoom != 0f) {
onGlobalLayout {
controller.state.zoomTo(storedTextZoom, width / 2f, height / 2f)
controller.updateState()
}
}
}
override fun getController() = controller
@ -67,6 +76,7 @@ class GestureTextView @JvmOverloads constructor(context: Context, attrs: Attribu
if (!State.equals(this.size, size)) {
this.size = size
super.setTextSize(TypedValue.COMPLEX_UNIT_PX, size)
context.config.editorTextZoom = state.zoom
}
}
}