Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,12 @@ gradle-plugin/bin/
logger/bin/
lookup/bin/
shared/bin/
llama-api/bin/
subprojects/**/bin/
testing/**/bin/

# checksum files
.checksum/

# assets files
assets/
assets/
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,6 @@ abstract class BaseEditorActivity :
editorAppBarLayout.updatePadding(
top = insets.top,
)
customToolbar.setContentInsetsRelative(0, 0)
}
}
}
Expand Down Expand Up @@ -595,13 +594,17 @@ abstract class BaseEditorActivity :
}

private fun setupToolbar() {
content.customToolbar.apply {
setTitleText(editorViewModel.getProjectName())

// Set the project name in the title TextView
content.root.findViewById<android.widget.TextView>(R.id.title_text)?.apply {
text = editorViewModel.getProjectName()
}

// Set up the drawer toggle on the title toolbar (where the hamburger menu should be)
content.titleToolbar.apply {
val toggle = object : ActionBarDrawerToggle(
this@BaseEditorActivity,
binding.editorDrawerLayout,
content.customToolbar,
this,
string.app_name,
string.app_name
) {
Expand All @@ -617,11 +620,27 @@ abstract class BaseEditorActivity :
drawerToggle = toggle
binding.editorDrawerLayout.addDrawerListener(toggle)
toggle.syncState()
setOnNavIconLongClickListener {
showTooltip(tag = TooltipTag.EDITOR_TOOLBAR_NAV_ICON)

// Set up long click listener for tooltip on the navigation icon
post {
var navButton: android.widget.ImageButton? = null
for (i in 0 until childCount) {
val child = getChildAt(i)
if (child is android.widget.ImageButton && child.contentDescription == navigationContentDescription) {
navButton = child
break
}
}
navButton?.apply {
// Remove top padding to align with TextView
setPadding(paddingLeft, 0, paddingRight, paddingBottom)
setOnLongClickListener {
showTooltip(tag = TooltipTag.EDITOR_TOOLBAR_NAV_ICON)
true
}
}
}
}

}

private fun onSwipeRevealDragProgress(progress: Float) {
Expand Down Expand Up @@ -951,25 +970,8 @@ abstract class BaseEditorActivity :
}

private fun setupDrawers() {
val toggle = object : ActionBarDrawerToggle(
this,
binding.editorDrawerLayout,
content.customToolbar,
string.app_name,
string.app_name
) {
override fun onDrawerOpened(drawerView: View) {
super.onDrawerOpened(drawerView)
// Hide the keyboard when the drawer opens.
closeKeyboard()
// Dismiss autocomplete and other editor windows
provideCurrentEditor()?.editor?.ensureWindowsDismissed()
}
}


binding.editorDrawerLayout.addDrawerListener(toggle)
toggle.syncState()
// Note: Drawer toggle is now set up in setupToolbar() on the title toolbar
// This method only sets up the drawer layout behavior
binding.apply {
editorDrawerLayout.apply {
childId = contentCard.id
Expand Down Expand Up @@ -1278,7 +1280,7 @@ abstract class BaseEditorActivity :
private fun showTooltip(tag: String) {
TooltipManager.showIdeCategoryTooltip(
context = this,
anchorView = content.customToolbar,
anchorView = content.projectActionsToolbar,
tag = tag,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ open class EditorHandlerActivity :
fun prepareOptionsMenu() {
val registry = getInstance() as DefaultActionsRegistry
val data = createToolbarActionData()
content.customToolbar.clearMenu()
content.projectActionsToolbar.clearMenu()

val actions = getInstance().getActions(EDITOR_TOOLBAR)
actions.onEachIndexed { index, entry ->
Expand All @@ -338,14 +338,14 @@ open class EditorHandlerActivity :
alpha = if (action.enabled) 255 else 76
}

content.customToolbar.addMenuItem(
content.projectActionsToolbar.addMenuItem(
icon = action.icon,
hint = action.label,
onClick = { if (action.enabled) registry.executeAction(action, data) },
onLongClick = {
TooltipManager.showIdeCategoryTooltip(
context = this,
anchorView = content.customToolbar,
anchorView = content.projectActionsToolbar,
tag = action.retrieveTooltipTag(false),
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ abstract class ProjectHandlerActivity : BaseEditorActivity() {
val registry = getInstance() as DefaultActionsRegistry

return FindActionDialog(
anchor = content.customToolbar.findViewById(R.id.menu_container),
anchor = content.projectActionsToolbar.findViewById(R.id.menu_container),
context = this,
actionData = actionData,
shouldShowFindInFileAction = shouldHideFindInFileAction,
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_editor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
android:id="@+id/swipe_reveal"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:dragHandle="@id/custom_toolbar">
app:dragHandle="@id/project_actions_toolbar">

<include
android:id="@+id/mem_usage_view"
Expand Down
37 changes: 34 additions & 3 deletions app/src/main/res/layout/content_editor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,40 @@
android:fitsSystemWindows="false"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$Behavior">

<com.itsaky.androidide.ui.CustomToolbar
android:id="@+id/custom_toolbar"
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/title_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:minHeight="0dp"
android:padding="0dp"
app:contentInsetStartWithNavigation="0dp"
app:contentInsetStart="0dp"
app:contentInsetEnd="0dp">

<TextView
android:id="@+id/title_text"
style="@style/TextAppearance.Material3.TitleMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:paddingTop="0dp"
android:paddingBottom="0dp"
android:gravity="start|center_vertical"
android:maxLines="1"
android:ellipsize="end" />

</com.google.android.material.appbar.MaterialToolbar>

<com.itsaky.androidide.ui.ProjectActionsToolbar
android:id="@+id/project_actions_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="0dp"
android:minHeight="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp" />

<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/progress_indicator"
Expand All @@ -47,6 +77,7 @@
style="@style/AppTheme.TabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="8dp"
app:tabGravity="start" />

</com.google.android.material.appbar.AppBarLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,26 @@ import android.widget.ImageButton
import android.widget.LinearLayout
import com.google.android.material.appbar.MaterialToolbar
import com.itsaky.androidide.common.R
import com.itsaky.androidide.common.databinding.CustomToolbarBinding
import com.itsaky.androidide.common.databinding.ProjectActionsToolbarBinding

class CustomToolbar @JvmOverloads constructor(
class ProjectActionsToolbar @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
var onNavIconLongClick: (() -> Unit)? = null
) : MaterialToolbar(context, attrs) {

init {
this.post {
var navButton: ImageButton? = null
for (i in 0 until this.childCount) {
val child = this.getChildAt(i)
if (child is ImageButton && child.contentDescription == this.navigationContentDescription) {
navButton = child
break
}
}

navButton?.setOnLongClickListener {
onNavIconLongClick?.invoke()
true
}

}
// Navigation icon is no longer used in ProjectActionsToolbar
// It's now handled by the title toolbar
// Remove any navigation icon that might be set
navigationIcon = null
}

private val binding: CustomToolbarBinding =
CustomToolbarBinding.inflate(LayoutInflater.from(context), this, true)
private val binding: ProjectActionsToolbarBinding =
ProjectActionsToolbarBinding.inflate(LayoutInflater.from(context), this, true)

fun setTitleText(title: String) {
binding.titleText.apply {
text = title
}
}
@Deprecated("Title is now displayed separately. Use the title_text TextView in content_editor.xml instead.")
fun setTitleText(title: String) = Unit

fun addMenuItem(
icon: Drawable?,
Expand All @@ -62,16 +47,29 @@ class CustomToolbar @JvmOverloads constructor(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT
).apply {
// Add margin to the right for spacing between items except for last item
if (shouldAddMargin) {
marginEnd = resources.getDimensionPixelSize(R.dimen.toolbar_item_spacing)
}
// Apply uniform spacing to all buttons for consistent appearance
// Use a smaller spacing value for tighter button layout
marginEnd = resources.getDimensionPixelSize(R.dimen.toolbar_item_spacing) / 2
}
setOnClickListener { onClick() }
setOnLongClickListener {
onLongClick()
true
}
// Prevent DrawerLayout from intercepting touch events on this button
setOnTouchListener { view, event ->
when (event.action) {
android.view.MotionEvent.ACTION_DOWN -> {
// Request that parent views (like DrawerLayout) don't intercept touch events
parent?.requestDisallowInterceptTouchEvent(true)
}
android.view.MotionEvent.ACTION_UP, android.view.MotionEvent.ACTION_CANCEL -> {
// Allow parent to intercept again after the touch is done
parent?.requestDisallowInterceptTouchEvent(false)
}
}
false // Don't consume the event, let the click/long-click listeners handle it
}
}
binding.menuContainer.addView(item)
}
Expand All @@ -92,4 +90,5 @@ class CustomToolbar @JvmOverloads constructor(
fun setOnNavIconLongClickListener(listener: (() -> Unit)?) {
this.onNavIconLongClick = listener
}
}
}

71 changes: 0 additions & 71 deletions common/src/main/res/layout/custom_toolbar.xml

This file was deleted.

Loading