diff --git a/app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt b/app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt index 62d77a1c85..b1471d19e7 100644 --- a/app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt +++ b/app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt @@ -465,6 +465,15 @@ abstract class BaseEditorActivity : } } + /** + * Apply system bar insets to the editor UI and propagate them to child components. + * + * Updates the stored top inset, applies it to the editor app bar layout, resets content + * inset and padding for the in-layout toolbars, and forwards the insets to the drawer + * sidebar fragment if present. + * + * @param insets System window insets (status/navigation bar); the top inset is used for app bar padding. + */ override fun onApplySystemBarInsets(insets: Insets) { super.onApplySystemBarInsets(insets) editorAppBarInsetTop = insets.top @@ -540,6 +549,11 @@ abstract class BaseEditorActivity : builder.show() } + /** + * Initializes the activity: restores project path if available, registers language servers and lifecycle observers, + * configures toolbars, drawers, tabs, views, containers, diagnostic UI, bottom sheet and result launchers, + * and starts memory watching, feedback, file-operation observation, and gesture handling required by the editor. + */ override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mLifecycleObserver = EditorActivityLifecyclerObserver() @@ -597,6 +611,12 @@ abstract class BaseEditorActivity : } + /** + * Configure the editor activity toolbar: set the project title, install and sync the drawer toggle, + * adjust toolbar and child padding, and attach a long-press tooltip to the navigation icon. + * + * The installed drawer toggle will hide the keyboard and dismiss editor windows when the drawer opens. + */ private fun setupToolbar() { // Set the project name in the title TextView content.root.findViewById(R.id.title_text)?.apply { @@ -662,6 +682,13 @@ abstract class BaseEditorActivity : } } + /** + * Updates UI layout values as the bottom sheet swipe-to-reveal gesture progresses. + * + * Adjusts the content card animation progress, interpolates the top padding of the editor app bar + * based on system top inset and gesture progress, and shifts the memory usage chart's top margin + * to follow the reveal motion. + */ private fun onSwipeRevealDragProgress(progress: Float) { _binding?.apply { contentCard.progress = progress @@ -964,6 +991,13 @@ abstract class BaseEditorActivity : } } + /** + * Processes the result from the UI Designer activity and appends the generated XML into the + * currently open editor. + * + * If the result is not OK, contains no data, or the generated XML is empty, the function + * performs no changes. If there is no currently open editor, the function performs no changes. + */ private fun handleUiDesignerResult(result: ActivityResult) { if (result.resultCode != RESULT_OK || result.data == null) { log.warn( @@ -988,6 +1022,12 @@ abstract class BaseEditorActivity : text.replace(0, 0, endLine, text.getColumnCount(endLine), generated) } + /** + * Configures the editor drawer layout's translation behavior and scrim color. + * + * Sets the content-child id for the drawer, uses full translation for both + * start and end edges, and makes the drawer scrim transparent. + */ private fun setupDrawers() { // Note: Drawer toggle is now set up in setupToolbar() on the title toolbar // This method only sets up the drawer layout behavior @@ -1326,4 +1366,4 @@ abstract class BaseEditorActivity : return null } -} +} \ No newline at end of file diff --git a/app/src/main/java/com/itsaky/androidide/ui/CompactMaterialToolbar.kt b/app/src/main/java/com/itsaky/androidide/ui/CompactMaterialToolbar.kt index 35f65d3c54..6e919ab33f 100644 --- a/app/src/main/java/com/itsaky/androidide/ui/CompactMaterialToolbar.kt +++ b/app/src/main/java/com/itsaky/androidide/ui/CompactMaterialToolbar.kt @@ -23,6 +23,14 @@ class CompactMaterialToolbar @JvmOverloads constructor( setContentInsetsRelative(0, 0) } + /** + * Measures the toolbar and, when a title TextView is present, constrains the toolbar's height to match that TextView's measured height. + * + * If no TextView child is found the measured dimensions remain as determined by the superclass. + * + * @param widthMeasureSpec horizontal space requirements as imposed by the parent. + * @param heightMeasureSpec vertical space requirements as imposed by the parent. + */ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { // First, measure children to get their desired height super.onMeasure(widthMeasureSpec, heightMeasureSpec) @@ -44,6 +52,12 @@ class CompactMaterialToolbar @JvmOverloads constructor( } } + /** + * Reapplies zero padding and content insets, and aligns the navigation icon's top edge with the toolbar title's top. + * + * If both a title TextView and the navigation ImageButton (identified by matching `navigationContentDescription`) are present, + * the navigation button is repositioned so its top equals the title's top while preserving its measured height. + */ override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) { super.onLayout(changed, l, t, r, b) // Ensure padding is still 0 after layout @@ -75,4 +89,3 @@ class CompactMaterialToolbar @JvmOverloads constructor( } } } - diff --git a/common/src/main/java/com/itsaky/androidide/ui/CustomToolbar.kt b/common/src/main/java/com/itsaky/androidide/ui/CustomToolbar.kt index 93203ddb92..6bf3849dcf 100644 --- a/common/src/main/java/com/itsaky/androidide/ui/CustomToolbar.kt +++ b/common/src/main/java/com/itsaky/androidide/ui/CustomToolbar.kt @@ -37,12 +37,31 @@ class CustomToolbar @JvmOverloads constructor( binding.horizontalScrollView.setPadding(0, 0, 0, 0) } + /** + * Preserves the legacy API for setting the toolbar title for backward compatibility. + * + * This method is a no-op; the toolbar title is managed separately (see the `title_text` TextView + * in content_editor.xml). + * + * @param title The title to set; this value is ignored. + */ @Deprecated("Title is now displayed separately. Use the title_text TextView in content_editor.xml instead.") fun setTitleText(title: String) { // Title is now handled separately in content_editor.xml // This method is kept for backward compatibility but does nothing } + /** + * Adds a circular icon button to the toolbar's menu area. + * + * The created button is added to the internal menu container and wired with the provided click and long-click handlers. + * + * @param icon The drawable to display in the button, or `null` for no image. + * @param hint The tooltip text shown for the button. + * @param onClick Action invoked when the button is clicked. + * @param onLongClick Action invoked when the button is long-clicked; the long-click event is consumed. + * @param shouldAddMargin If `true`, adds end margin to the button for spacing between menu items. + */ fun addMenuItem( icon: Drawable?, hint: String,