Skip to content
Merged
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
Original file line numberDiff line numberDiff line change
Expand Up@@ -157,6 +157,7 @@ class EditorActivity : BaseActivity() {
)
)
project = projectManager.openedProject!!
invalidateOptionsMenu()
androidToDesignConversion(
Uri.fromFile(File(projectManager.openedProject?.mainLayout?.path ?: "")),
)
Expand DownExpand Up@@ -414,10 +415,31 @@ class EditorActivity : BaseActivity() {
binding.listView.adapter = adapter
}

private fun isProjectReady(): Boolean {
if (!::project.isInitialized) {
ToastUtils.showShort(getString(R.string.loading_project))
return false
}
return true
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
val id = item.itemId
undoRedo!!.updateButtons()
if (actionBarDrawerToggle!!.onOptionsItemSelected(item)) return true

when (id) {
R.id.resources_manager,
R.id.preview,
R.id.export_xml,
R.id.export_as_image,
R.id.save_xml,
R.id.exit_editor,
R.id.edit_xml -> {
if (!isProjectReady()) return false
}
}

when (id) {
android.R.id.home -> {
drawerLayout.openDrawer(GravityCompat.START)
Expand DownExpand Up@@ -567,6 +589,18 @@ class EditorActivity : BaseActivity() {
}
}

override fun onPrepareOptionsMenu(menu: Menu): Boolean {
val isReady = ::project.isInitialized
menu.findItem(R.id.resources_manager)?.isEnabled = isReady
menu.findItem(R.id.preview)?.isEnabled = isReady
menu.findItem(R.id.export_xml)?.isEnabled = isReady
menu.findItem(R.id.export_as_image)?.isEnabled = isReady
menu.findItem(R.id.save_xml)?.isEnabled = isReady
menu.findItem(R.id.edit_xml)?.isEnabled = isReady
menu.findItem(R.id.exit_editor)?.isEnabled = isReady
return super.onPrepareOptionsMenu(menu)
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

override fun onConfigurationChanged(config: Configuration) {
super.onConfigurationChanged(config)
actionBarDrawerToggle!!.onConfigurationChanged(config)
Expand Down