1818package com.itsaky.androidide.activities.editor
1919
2020import android.content.Intent
21+ import android.content.res.Configuration
2122import android.os.Bundle
2223import android.text.TextUtils
2324import android.util.Log
@@ -26,6 +27,7 @@ import android.view.ViewGroup.LayoutParams
2627import androidx.collection.MutableIntObjectMap
2728import androidx.core.content.res.ResourcesCompat
2829import androidx.core.view.GravityCompat
30+ import androidx.core.view.doOnNextLayout
2931import androidx.lifecycle.lifecycleScope
3032import com.blankj.utilcode.util.ImageUtils
3133import com.google.android.material.tabs.TabLayout
@@ -79,6 +81,7 @@ import org.adfa.constants.CONTENT_KEY
7981import org.greenrobot.eventbus.Subscribe
8082import org.greenrobot.eventbus.ThreadMode
8183import java.io.File
84+ import java.util.concurrent.ConcurrentHashMap
8285import java.util.concurrent.CopyOnWriteArrayList
8386import java.util.concurrent.atomic.AtomicBoolean
8487import java.util.function.Consumer
@@ -100,7 +103,7 @@ open class EditorHandlerActivity :
100103
101104 protected val isOpenedFilesSaved = AtomicBoolean (false )
102105
103- private val fileTimestamps = mutableMapOf <String , Long >()
106+ private val fileTimestamps = ConcurrentHashMap <String , Long >()
104107
105108 private val pluginTabIndices = mutableMapOf<String , Int >()
106109 private val tabIndexToPluginId = mutableMapOf<Int , String >()
@@ -704,6 +707,16 @@ open class EditorHandlerActivity :
704707 }
705708 }
706709
710+ override fun onConfigurationChanged (newConfig : Configuration ) {
711+ super .onConfigurationChanged(newConfig)
712+
713+ getCurrentEditor()?.editor?.apply {
714+ doOnNextLayout {
715+ cursor?.let { c -> ensurePositionVisible(c.leftLine, c.leftColumn, true ) }
716+ }
717+ }
718+ }
719+
707720 private suspend fun saveResultInternal (
708721 index : Int ,
709722 result : SaveResult ,
@@ -723,6 +736,10 @@ open class EditorHandlerActivity :
723736 return false
724737 }
725738
739+ frag.file?.let { savedFile ->
740+ fileTimestamps[savedFile.absolutePath] = savedFile.lastModified()
741+ }
742+
726743 val isGradle = fileName.endsWith(" .gradle" ) || fileName.endsWith(" .gradle.kts" )
727744 val isXml: Boolean = fileName.endsWith(" .xml" )
728745 if (! result.gradleSaved) {
0 commit comments