Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Fixed #882 #888

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified app/src/main/assets/data/common/tooling-api-all.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,6 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler {
log.info("Opening file at index:", position, "file: ", file)

val editor = CodeEditorView(this, file, selection!!)
editor.editor.subscribeEvent(ContentChangeEvent::class.java) { event, _ ->
onEditorContentChanged(event)
}
editor.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)

binding.editorContainer.addView(editor)
Expand Down Expand Up @@ -365,11 +362,9 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler {
}
}

private fun onEditorContentChanged(event: ContentChangeEvent) {
if (event.action != ContentChangeEvent.ACTION_SET_NEW_TEXT) {
viewModel.setFilesModified(true)
invalidateOptionsMenu()
}
private fun onEditorContentChanged() {
viewModel.setFilesModified(true)
invalidateOptionsMenu()
}

override fun areFilesModified(): Boolean {
Expand Down Expand Up @@ -542,6 +537,9 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler {

@Subscribe(threadMode = ThreadMode.MAIN)
fun onDocumentChange(event: DocumentChangeEvent) {
// update content modification status
onEditorContentChanged()

val index = findIndexOfEditorByFile(event.file.toFile())
if (index == -1) {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ public CodeEditorView(
final var editor = getEditor();
editor.post(() -> {
editor.setText(contents, createEditorArgs());

// editor.setText(...) sets the modified flag to true
// but in this case, file is read from disk and hence the contents are not modified at all
// so the flag must be changed to unmodified
// TODO: Find a better way to check content modification status
editor.markUnmodified();
postRead();

selection.validate();
Expand Down
15 changes: 7 additions & 8 deletions app/src/main/res/xml/ide_file_provider_paths.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
~ You should have received a copy of the GNU General Public License
~ along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
-->

<paths>
<files-path
name="files_path"
path="." />
<external-path
name="external_path"
path="."/>
</paths>
<root-path name="root" path="." />
<external-path name="external" path="." />
<external-files-path name="external_files" path="." />
<cache-path name="cache" path="." />
<external-cache-path name="external_cache" path="." />
<files-path name="files" path="." />
</paths>
10 changes: 10 additions & 0 deletions changelogs/v2.4.1-beta.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# AndroidIDE v2.4.1-beta

## Important notes

- The terminal packages have been moved to `packages.androidide.com/apt/termux-main`.

## Fixes

- Project initialization fails if the project contains a `java-library` module.
- Classes from the same package are imported when selecting a class completion item (#869).
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ open class EditorActionsMenu constructor(val editor: IDEEditor) :
private var mLastScroll: Long = 0
private var mLastPosition: Int = 0

private val contentHeight by lazy {
// approximated size is around 56dp
SizeUtils.dp2px(56f)
}

private val menu: MenuBuilder = MenuBuilder(editor.context)
protected open var location = ActionItem.Location.EDITOR_TEXT_ACTIONS

Expand Down Expand Up @@ -226,6 +231,8 @@ open class EditorActionsMenu constructor(val editor: IDEEditor) :

private fun selectTop(rect: RectF): Int {
val rowHeight = editor.rowHeight
// when the window is being shown for the first time, the height is 0
val height = if (this.height == 0) contentHeight else this.height
return if (rect.top - rowHeight * 3 / 2f > height) {
(rect.top - rowHeight * 3 / 2 - height).toInt()
} else {
Expand Down Expand Up @@ -325,7 +332,7 @@ open class EditorActionsMenu constructor(val editor: IDEEditor) :

override fun show() {

if (editor.searcher.searching) {
if (editor.searcher.isSearching) {
// Do not show if user is searching text
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import android.view.inputmethod.EditorInfo
import android.widget.FrameLayout
import android.widget.PopupMenu
import com.itsaky.androidide.editor.databinding.LayoutFindInFileBinding
import com.itsaky.androidide.resources.R
import com.itsaky.androidide.editor.ui.ReplaceAction.doReplace
import com.itsaky.androidide.resources.R
import com.itsaky.androidide.utils.SingleTextWatcher
import io.github.rosemoe.sora.widget.EditorSearcher.SearchOptions
import java.util.regex.Pattern
Expand All @@ -47,6 +47,8 @@ class EditorSearchLayout(context: Context, val editor: IDEEditor) : FrameLayout(
private val findInFileBinding: LayoutFindInFileBinding
private val optionsMenu: PopupMenu

private var isSearching = false

init {
findInFileBinding = LayoutFindInFileBinding.inflate(LayoutInflater.from(context))
findInFileBinding.prev.setOnClickListener(::onSearchActionClick)
Expand Down Expand Up @@ -113,6 +115,7 @@ class EditorSearchLayout(context: Context, val editor: IDEEditor) : FrameLayout(
findInFileBinding.searchInput.removeTextChangedListener(this.searchInputTextWatcher)
findInFileBinding.root.visibility = GONE
this.searchInputTextWatcher = null
this.editor.searcher.onClose()
}
if (!searcher.hasQuery()) {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -722,10 +722,7 @@ public void ensureWindowsDismissed() {
* @param event The content change event.
*/
private void handleContentChange(ContentChangeEvent event, Unsubscribe unsubscribe) {
if (event.getAction() != ContentChangeEvent.ACTION_SET_NEW_TEXT) {
isModified = true;
}

isModified = true;
if (getFile() == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/

@file:Suppress("DEPRECATION")

package io.github.rosemoe.sora.widget

import com.itsaky.androidide.editor.ui.IDEEditor
Expand All @@ -29,7 +27,7 @@ import com.itsaky.androidide.editor.ui.IDEEditor
*/
open class IDEEditorSearcher(editor: IDEEditor) : EditorSearcher(editor) {

var searching = false
var isSearching = false
private set

protected fun getEditor(): CodeEditor {
Expand Down Expand Up @@ -67,11 +65,15 @@ open class IDEEditorSearcher(editor: IDEEditor) : EditorSearcher(editor) {
}

override fun stopSearch() {
searching = false
isSearching = false
super.stopSearch()
}

fun onClose() {
isSearching = false
}

private fun markSearching() {
searching = true
isSearching = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class AttrValueEditorFragment : Fragment() {
val header = this.header ?: return
val view = this.viewModel.view ?: return
val attr = this.viewModel.selectedAttr ?: return

val ns = attr.namespace?.prefix?.let { "${it}:" } ?: ""
header.name.text = "${ns}${attr.name}"
header.desc.text = attr.namespace?.uri ?: ""
Expand All @@ -90,10 +90,15 @@ class AttrValueEditorFragment : Fragment() {
)
textView.dropDownVerticalOffset = -binding.root.height
textView.showDropDown()

val value = binding.attrValue.text.toString()
attr.value = value
view.applyAttribute(attr.copyAttr(value = value))
try {
view.applyAttribute(attr.copyAttr(value = value))
} catch (e: Exception) {
// When the user is editing the attribute value, it is always invalid and cannot be
// resolved. Exceptions may be thrown while parsing the value which should be ignored
}
}

textView.setText(attr.value)
Expand Down