@@ -19,7 +19,6 @@ package com.itsaky.androidide.activities.editor
1919
2020import android.content.Intent
2121import android.content.pm.PackageInstaller.SessionCallback
22- import android.content.res.ColorStateList
2322import android.graphics.Color
2423import android.graphics.Rect
2524import android.graphics.drawable.GradientDrawable
@@ -58,9 +57,6 @@ import com.github.mikephil.charting.data.LineDataSet
5857import com.github.mikephil.charting.formatter.IAxisValueFormatter
5958import com.google.android.material.bottomsheet.BottomSheetBehavior
6059import com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
61- import com.google.android.material.shape.CornerFamily
62- import com.google.android.material.shape.MaterialShapeDrawable
63- import com.google.android.material.shape.ShapeAppearanceModel
6460import com.google.android.material.snackbar.Snackbar
6561import com.google.android.material.tabs.TabLayout
6662import com.google.android.material.tabs.TabLayout.Tab
@@ -71,6 +67,7 @@ import com.itsaky.androidide.adapters.DiagnosticsAdapter
7167import com.itsaky.androidide.adapters.SearchListAdapter
7268import com.itsaky.androidide.app.EdgeToEdgeIDEActivity
7369import com.itsaky.androidide.databinding.ActivityEditorBinding
70+ import com.itsaky.androidide.databinding.ContentEditorBinding
7471import com.itsaky.androidide.databinding.LayoutDiagnosticInfoBinding
7572import com.itsaky.androidide.events.InstallationResultEvent
7673import com.itsaky.androidide.fragments.SearchResultFragment
@@ -147,6 +144,8 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
147144 internal var _binding : ActivityEditorBinding ? = null
148145 val binding: ActivityEditorBinding
149146 get() = checkNotNull(_binding ) { " Activity has been destroyed" }
147+ val content: ContentEditorBinding
148+ get() = binding.content
150149
151150 override val subscribeToEvents: Boolean
152151 get() = true
@@ -184,19 +183,24 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
184183 }
185184 }
186185 }
187-
186+
188187 private val editorSurfaceContainerBackground by lazy {
189188 resolveAttr(R .attr.colorSurfaceDim)
190189 }
190+ private val editorLayoutCorners by lazy {
191+ resources.getDimensionPixelSize(R .dimen.editor_container_corners).toFloat()
192+ }
191193
192194 private var optionsMenuInvalidator: Runnable ? = null
193195
194196 companion object {
195197
196198 @JvmStatic
197199 protected val PROC_IDE = " IDE"
200+
198201 @JvmStatic
199202 protected val PROC_GRADLE_TOOLING = " Gradle Tooling"
203+
200204 @JvmStatic
201205 protected val PROC_GRADLE_DAEMON = " Gradle Daemon"
202206
@@ -252,7 +256,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
252256
253257 override fun bindLayout (): View {
254258 this ._binding = ActivityEditorBinding .inflate(layoutInflater)
255- this .diagnosticInfoBinding = this .binding .diagnosticInfo
259+ this .diagnosticInfoBinding = this .content .diagnosticInfo
256260 return this .binding.root
257261 }
258262
@@ -262,13 +266,15 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
262266 drawerSidebar.getFragment<EditorSidebarFragment >()
263267 .onApplyWindowInsets(insets)
264268
265- editorAppBarLayout.updatePadding(
266- top = insets.top
267- )
268- editorToolbar.updatePaddingRelative(
269- start = editorToolbar.paddingStart + insets.left,
270- end = editorToolbar.paddingEnd + insets.right
271- )
269+ content.apply {
270+ editorAppBarLayout.updatePadding(
271+ top = insets.top
272+ )
273+ editorToolbar.updatePaddingRelative(
274+ start = editorToolbar.paddingStart + insets.left,
275+ end = editorToolbar.paddingEnd + insets.right
276+ )
277+ }
272278 }
273279 }
274280
@@ -286,7 +292,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
286292 return
287293 }
288294
289- Snackbar .make(binding .realContainer, string.msg_action_open_application, Snackbar .LENGTH_LONG )
295+ Snackbar .make(content .realContainer, string.msg_action_open_application, Snackbar .LENGTH_LONG )
290296 .setAction(string.yes) { IntentUtils .launchApp(this , packageName) }.show()
291297 }
292298
@@ -305,10 +311,10 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
305311 onBackPressedDispatcher.addCallback(this , onBackPressedCallback)
306312 lifecycle.addObserver(mLifecycleObserver)
307313
308- setSupportActionBar(binding .editorToolbar)
314+ setSupportActionBar(content .editorToolbar)
309315
310316 setupDrawers()
311- binding .tabs.addOnTabSelectedListener(this )
317+ content .tabs.addOnTabSelectedListener(this )
312318
313319 setupViews()
314320
@@ -325,8 +331,9 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
325331
326332 private fun onSwipeRevealDragProgress (progress : Float ) {
327333 _binding ?.apply {
334+ contentCard.progress = progress
328335 val insetsTop = lastWindowInsets?.top ? : 0
329- editorAppBarLayout.updatePadding(
336+ content. editorAppBarLayout.updatePadding(
330337 top = (insetsTop * (1f - progress)).roundToInt()
331338 )
332339 memUsageView.chart.updateLayoutParams<ViewGroup .MarginLayoutParams > {
@@ -507,11 +514,11 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
507514 }
508515
509516 open fun setSearchResultAdapter (adapter : SearchListAdapter ) {
510- binding .bottomSheet.setSearchResultAdapter(adapter)
517+ content .bottomSheet.setSearchResultAdapter(adapter)
511518 }
512519
513520 open fun setDiagnosticsAdapter (adapter : DiagnosticsAdapter ) {
514- binding .bottomSheet.setDiagnosticsAdapter(adapter)
521+ content .bottomSheet.setDiagnosticsAdapter(adapter)
515522 }
516523
517524 open fun hideBottomSheet () {
@@ -525,20 +532,20 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
525532 editorBottomSheet?.state = BottomSheetBehavior .STATE_EXPANDED
526533 }
527534
528- val index = binding .bottomSheet.pagerAdapter.findIndexOfFragmentByClass(
535+ val index = content .bottomSheet.pagerAdapter.findIndexOfFragmentByClass(
529536 SearchResultFragment ::class .java)
530537
531- if (index >= 0 && index < binding .bottomSheet.binding.tabs.tabCount) {
532- binding .bottomSheet.binding.tabs.getTabAt(index)?.select()
538+ if (index >= 0 && index < content .bottomSheet.binding.tabs.tabCount) {
539+ content .bottomSheet.binding.tabs.getTabAt(index)?.select()
533540 }
534541 }
535542
536543 open fun handleDiagnosticsResultVisibility (errorVisible : Boolean ) {
537- binding .bottomSheet.handleDiagnosticsResultVisibility(errorVisible)
544+ content .bottomSheet.handleDiagnosticsResultVisibility(errorVisible)
538545 }
539546
540547 open fun handleSearchResultVisibility (errorVisible : Boolean ) {
541- binding .bottomSheet.handleSearchResultVisibility(errorVisible)
548+ content .bottomSheet.handleSearchResultVisibility(errorVisible)
542549 }
543550
544551 open fun showFirstBuildNotice () {
@@ -565,7 +572,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
565572 }
566573
567574 fun refreshSymbolInput (editor : CodeEditorView ) {
568- binding .bottomSheet.refreshSymbolInput(editor)
575+ content .bottomSheet.refreshSymbolInput(editor)
569576 }
570577
571578 private fun checkIsDestroying () {
@@ -595,14 +602,14 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
595602 }
596603
597604 private fun setupDrawers () {
598- val toggle = ActionBarDrawerToggle (this , binding.editorDrawerLayout, binding .editorToolbar,
605+ val toggle = ActionBarDrawerToggle (this , binding.editorDrawerLayout, content .editorToolbar,
599606 string.app_name, string.app_name)
600607
601608 binding.editorDrawerLayout.addDrawerListener(toggle)
602609 toggle.syncState()
603610 binding.apply {
604611 editorDrawerLayout.apply {
605- childId = binding .realContainer.id
612+ childId = content .realContainer.id
606613 translationBehaviorStart = ContentTranslatingDrawerLayout .TranslationBehavior .FULL
607614 translationBehaviorEnd = ContentTranslatingDrawerLayout .TranslationBehavior .FULL
608615 setScrimColor(Color .TRANSPARENT )
@@ -614,17 +621,17 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
614621 log.debug(
615622 " onBuildStatusChanged: isInitializing: ${editorViewModel.isInitializing} , isBuildInProgress: ${editorViewModel.isBuildInProgress} " )
616623 val visible = editorViewModel.isBuildInProgress || editorViewModel.isInitializing
617- binding .progressIndicator.visibility = if (visible) View .VISIBLE else View .GONE
624+ content .progressIndicator.visibility = if (visible) View .VISIBLE else View .GONE
618625 invalidateOptionsMenu()
619626 }
620627
621628 private fun setupViews () {
622629 editorViewModel._isBuildInProgress .observe(this ) { onBuildStatusChanged() }
623630 editorViewModel._isInitializing .observe(this ) { onBuildStatusChanged() }
624- editorViewModel._statusText .observe(this ) { binding .bottomSheet.setStatus(it.first, it.second) }
631+ editorViewModel._statusText .observe(this ) { content .bottomSheet.setStatus(it.first, it.second) }
625632
626633 editorViewModel.observeFiles(this ) { files ->
627- binding .apply {
634+ content .apply {
628635 if (files.isNullOrEmpty()) {
629636 tabs.visibility = View .GONE
630637 viewContainer.displayedChild = 1
@@ -650,6 +657,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
650657 }, 1500 )
651658 }
652659
660+ binding.contentCard.progress = 0f
653661 binding.swipeReveal.dragListener = object : SwipeRevealLayout .OnDragListener {
654662 override fun onDragStateChanged (swipeRevealLayout : SwipeRevealLayout , state : Int ) {}
655663 override fun onDragProgress (swipeRevealLayout : SwipeRevealLayout , progress : Float ) {
@@ -659,7 +667,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
659667 }
660668
661669 private fun setupNoEditorView () {
662- binding .noEditorSummary.movementMethod = LinkMovementMethod ()
670+ content .noEditorSummary.movementMethod = LinkMovementMethod ()
663671 val filesSpan: ClickableSpan = object : ClickableSpan () {
664672 override fun onClick (widget : View ) {
665673 binding.root.openDrawer(GravityCompat .START )
@@ -673,7 +681,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
673681 val sb = SpannableStringBuilder ()
674682 appendClickableSpan(sb, string.msg_drawer_for_files, filesSpan)
675683 appendClickableSpan(sb, string.msg_swipe_for_output, bottomSheetSpan)
676- binding .noEditorSummary.text = sb
684+ content .noEditorSummary.text = sb
677685 }
678686
679687 private fun appendClickableSpan (
@@ -696,7 +704,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
696704 }
697705
698706 private fun setupBottomSheet () {
699- editorBottomSheet = BottomSheetBehavior .from<View >(binding .bottomSheet)
707+ editorBottomSheet = BottomSheetBehavior .from<View >(content .bottomSheet)
700708 editorBottomSheet?.addBottomSheetCallback(object : BottomSheetCallback () {
701709 override fun onStateChanged (bottomSheet : View , newState : Int ) {
702710 if (newState == BottomSheetBehavior .STATE_EXPANDED ) {
@@ -706,7 +714,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
706714 }
707715
708716 override fun onSlide (bottomSheet : View , slideOffset : Float ) {
709- binding .apply {
717+ content .apply {
710718 val editorScale = 1 - slideOffset * (1 - EDITOR_CONTAINER_SCALE_FACTOR )
711719 this .bottomSheet.onSlide(slideOffset)
712720 this .viewContainer.scaleX = editorScale
@@ -717,7 +725,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
717725
718726 val observer: OnGlobalLayoutListener = object : OnGlobalLayoutListener {
719727 override fun onGlobalLayout () {
720- binding .also {
728+ content .also {
721729 it.realContainer.pivotX = it.realContainer.width.toFloat() / 2f
722730 it.realContainer.pivotY = (it.realContainer.height.toFloat() / 2f ) + (lastWindowInsets?.height()
723731 ? : 0 )
@@ -726,7 +734,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
726734 }
727735 }
728736
729- binding .apply {
737+ content .apply {
730738 viewContainer.viewTreeObserver.addOnGlobalLayoutListener(observer)
731739 bottomSheet.setOffsetAnchor(editorAppBarLayout)
732740 }
@@ -750,7 +758,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
750758 private fun onSoftInputChanged () {
751759 if (! isDestroying) {
752760 invalidateOptionsMenu()
753- binding .bottomSheet.onSoftInputChanged()
761+ content .bottomSheet.onSoftInputChanged()
754762 }
755763 }
756764
0 commit comments