Skip to content

Commit 6838457

Browse files
committed
remember the zoom level used at the file editor
1 parent 23c786d commit 6838457

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/helpers/Config.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,8 @@ class Config(context: Context) : BaseConfig(context) {
8989
var enableRootAccess: Boolean
9090
get() = prefs.getBoolean(ENABLE_ROOT_ACCESS, false)
9191
set(enableRootAccess) = prefs.edit().putBoolean(ENABLE_ROOT_ACCESS, enableRootAccess).apply()
92+
93+
var editorTextZoom: Float
94+
get() = prefs.getFloat(EDITOR_TEXT_ZOOM, 0f)
95+
set(editorTextZoom) = prefs.edit().putFloat(EDITOR_TEXT_ZOOM, editorTextZoom).apply()
9296
}

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/helpers/Constants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const val SORT_FOLDER_PREFIX = "sort_folder_"
1010
const val TEMPORARILY_SHOW_HIDDEN = "temporarily_show_hidden"
1111
const val IS_ROOT_AVAILABLE = "is_root_available"
1212
const val ENABLE_ROOT_ACCESS = "enable_root_access"
13+
const val EDITOR_TEXT_ZOOM = "editor_text_zoom"
1314

1415
// open as
1516
const val OPEN_AS_DEFAULT = 0

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/views/GestureTextView.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.alexvasilkov.gestures.GestureController
99
import com.alexvasilkov.gestures.State
1010
import com.alexvasilkov.gestures.views.interfaces.GestureView
1111
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
12+
import com.simplemobiletools.commons.extensions.onGlobalLayout
1213
import com.simplemobiletools.filemanager.pro.extensions.config
1314

1415
// taken from
@@ -34,6 +35,14 @@ class GestureTextView @JvmOverloads constructor(context: Context, attrs: Attribu
3435
origSize = textSize
3536
setTextColor(context.config.textColor)
3637
setLinkTextColor(context.getAdjustedPrimaryColor())
38+
39+
val storedTextZoom = context.config.editorTextZoom
40+
if (storedTextZoom != 0f) {
41+
onGlobalLayout {
42+
controller.state.zoomTo(storedTextZoom, width / 2f, height / 2f)
43+
controller.updateState()
44+
}
45+
}
3746
}
3847

3948
override fun getController() = controller
@@ -67,6 +76,7 @@ class GestureTextView @JvmOverloads constructor(context: Context, attrs: Attribu
6776
if (!State.equals(this.size, size)) {
6877
this.size = size
6978
super.setTextSize(TypedValue.COMPLEX_UNIT_PX, size)
79+
context.config.editorTextZoom = state.zoom
7080
}
7181
}
7282
}

0 commit comments

Comments
 (0)