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
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ import com.github.mikephil.charting.data.LineData
import com.github.mikephil.charting.data.LineDataSet
import com.github.mikephil.charting.formatter.IAxisValueFormatter
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_COLLAPSED
import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_HIDDEN
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayout.Tab
import com.itsaky.androidide.FeedbackButtonManager
Expand Down Expand Up @@ -234,8 +236,8 @@ abstract class BaseEditorActivity :
binding.editorDrawerLayout.closeDrawer(GravityCompat.START)
}

bottomSheetViewModel.sheetBehaviorState != BottomSheetBehavior.STATE_COLLAPSED -> {
bottomSheetViewModel.setSheetState(sheetState = BottomSheetBehavior.STATE_COLLAPSED)
bottomSheetViewModel.sheetBehaviorState != STATE_COLLAPSED -> {
bottomSheetViewModel.setSheetState(sheetState = STATE_COLLAPSED)
}

binding.swipeReveal.isOpen -> {
Expand Down Expand Up @@ -517,7 +519,7 @@ abstract class BaseEditorActivity :

applyImmersiveModeInsets(systemBars)

handleKeyboardInsets(imeInsets)
handleKeyboardInsets(imeInsets, systemBars)
}

private fun applyStandardInsets(systemBars: Insets) {
Expand All @@ -530,7 +532,7 @@ abstract class BaseEditorActivity :
_binding?.content?.applyImmersiveModeInsets(systemBars)
}

private fun handleKeyboardInsets(imeInsets: Insets) {
private fun handleKeyboardInsets(imeInsets: Insets, systemBars: Insets) {
val isImeVisible = imeInsets.bottom > 0
_binding?.content?.bottomSheet?.setImeVisible(isImeVisible)

Expand All @@ -539,7 +541,8 @@ abstract class BaseEditorActivity :
isImeVisible -> {
contentCardRealHeight?.let { baseHeight ->
updateLayoutParams<ViewGroup.LayoutParams> {
height = (baseHeight - imeInsets.bottom).coerceAtLeast(0)
val diff = (imeInsets.bottom - systemBars.bottom).coerceAtLeast(0)
height = (baseHeight - diff).coerceAtLeast(0)
}
}
}
Expand All @@ -555,6 +558,14 @@ abstract class BaseEditorActivity :

if (this.isImeVisible != isImeVisible) {
this.isImeVisible = isImeVisible

if (editorViewModel.isFullscreen) {
// Hide the bottom sheet if in fullscreen mode, but only collapse it if keyboard
// is open so the symbol input view is visible
val targetState = if (isImeVisible) STATE_COLLAPSED else STATE_HIDDEN
editorBottomSheet?.state = targetState
}

onSoftInputChanged()
}
}
Expand Down Expand Up @@ -1053,7 +1064,7 @@ abstract class BaseEditorActivity :
}

open fun hideBottomSheet() {
bottomSheetViewModel.setSheetState(sheetState = BottomSheetBehavior.STATE_COLLAPSED)
bottomSheetViewModel.setSheetState(sheetState = STATE_COLLAPSED)
}

private fun updateBottomSheetState(state: BottomSheetViewModel.SheetState = BottomSheetViewModel.SheetState.EMPTY) {
Expand Down Expand Up @@ -1332,7 +1343,7 @@ abstract class BaseEditorActivity :
) {
bottomSheetViewModel.setSheetState(BottomSheetBehavior.STATE_EXPANDED)
ThreadUtils.runOnUiThreadDelayed({
bottomSheetViewModel.setSheetState(BottomSheetBehavior.STATE_COLLAPSED)
bottomSheetViewModel.setSheetState(STATE_COLLAPSED)
app.prefManager.putBoolean(KEY_BOTTOM_SHEET_SHOWN, true)
}, 1500)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.itsaky.androidide.activities.editor

import android.app.Activity
import android.content.ContextWrapper
import android.view.View
import android.view.ViewGroup
import androidx.core.view.updateLayoutParams
import com.blankj.utilcode.util.KeyboardUtils
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.itsaky.androidide.R
Expand Down Expand Up @@ -225,8 +228,17 @@ class FullscreenManager(
appBarContent.alpha = 0f

bottomSheetBehavior.isHideable = true
if (bottomSheetBehavior.state != BottomSheetBehavior.STATE_HIDDEN) {
bottomSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN

val activity = contentBinding.root.context.let { context ->
generateSequence(context) { (it as? ContextWrapper)?.baseContext }
.filterIsInstance<Activity>()
.firstOrNull()
}
val isKeyboardOpen = activity?.let { KeyboardUtils.isSoftInputVisible(it) } ?: false
val targetState = if (isKeyboardOpen) BottomSheetBehavior.STATE_COLLAPSED else BottomSheetBehavior.STATE_HIDDEN

if (bottomSheetBehavior.state != targetState) {
bottomSheetBehavior.state = targetState
}

editorContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ constructor(
}

private fun applyPeekHeight() {
behavior.peekHeight = if (isImeVisible || isSearchModeActive) 0 else collapsedHeight.toInt()
behavior.peekHeight = if (isSearchModeActive) 0 else collapsedHeight.roundToInt()
}

fun setOffsetAnchor(view: View) {
Expand Down
Loading