From 8c878a0d020b20d32771e00aaf0fa0535ab9d75d Mon Sep 17 00:00:00 2001 From: Akash Yadav Date: Sat, 18 May 2024 01:35:18 +0530 Subject: [PATCH] fix: use MaterialCardView to clip children onSwipeRevealProgress --- .idea/codeStyles/codeStyleConfig.xml | 2 +- .../actions/file/CloseFileAction.kt | 2 +- .../activities/editor/BaseEditorActivity.kt | 82 +++++++------ .../editor/EditorHandlerActivity.kt | 28 ++--- .../editor/ProjectHandlerActivity.kt | 2 +- .../handlers/EditorBuildEventListener.kt | 4 +- .../androidide/lsp/IDELanguageClientImpl.java | 2 +- .../itsaky/androidide/ui/EditorBottomSheet.kt | 6 + .../itsaky/androidide/ui/SwipeRevealLayout.kt | 24 +--- .../utils/ApkInstallationSessionCallback.kt | 6 +- app/src/main/res/layout/activity_editor.xml | 111 +++-------------- app/src/main/res/layout/content_editor.xml | 116 ++++++++++++++++++ .../res/layout/layout_editor_bottom_sheet.xml | 3 +- app/src/main/res/values/dimens.xml | 1 + 14 files changed, 209 insertions(+), 180 deletions(-) create mode 100644 app/src/main/res/layout/content_editor.xml diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml index 307554b77..df5f35dcc 100644 --- a/.idea/codeStyles/codeStyleConfig.xml +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -1,5 +1,5 @@ - \ No newline at end of file diff --git a/app/src/main/java/com/itsaky/androidide/actions/file/CloseFileAction.kt b/app/src/main/java/com/itsaky/androidide/actions/file/CloseFileAction.kt index af142fecb..70aa7bd85 100644 --- a/app/src/main/java/com/itsaky/androidide/actions/file/CloseFileAction.kt +++ b/app/src/main/java/com/itsaky/androidide/actions/file/CloseFileAction.kt @@ -38,7 +38,7 @@ class CloseFileAction(context: Context, override val order: Int) : FileTabAction } override fun EditorHandlerActivity.doAction(data: ActionData): Boolean { - binding.tabs.selectedTabPosition.let { index -> + content.tabs.selectedTabPosition.let { index -> closeFile(index) { invalidateOptionsMenu() } 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 658f8aa7a..c1005b441 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 @@ -19,7 +19,6 @@ package com.itsaky.androidide.activities.editor import android.content.Intent import android.content.pm.PackageInstaller.SessionCallback -import android.content.res.ColorStateList import android.graphics.Color import android.graphics.Rect import android.graphics.drawable.GradientDrawable @@ -58,9 +57,6 @@ 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.BottomSheetCallback -import com.google.android.material.shape.CornerFamily -import com.google.android.material.shape.MaterialShapeDrawable -import com.google.android.material.shape.ShapeAppearanceModel import com.google.android.material.snackbar.Snackbar import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout.Tab @@ -71,6 +67,7 @@ import com.itsaky.androidide.adapters.DiagnosticsAdapter import com.itsaky.androidide.adapters.SearchListAdapter import com.itsaky.androidide.app.EdgeToEdgeIDEActivity import com.itsaky.androidide.databinding.ActivityEditorBinding +import com.itsaky.androidide.databinding.ContentEditorBinding import com.itsaky.androidide.databinding.LayoutDiagnosticInfoBinding import com.itsaky.androidide.events.InstallationResultEvent import com.itsaky.androidide.fragments.SearchResultFragment @@ -147,6 +144,8 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele internal var _binding: ActivityEditorBinding? = null val binding: ActivityEditorBinding get() = checkNotNull(_binding) { "Activity has been destroyed" } + val content: ContentEditorBinding + get() = binding.content override val subscribeToEvents: Boolean get() = true @@ -184,10 +183,13 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele } } } - + private val editorSurfaceContainerBackground by lazy { resolveAttr(R.attr.colorSurfaceDim) } + private val editorLayoutCorners by lazy { + resources.getDimensionPixelSize(R.dimen.editor_container_corners).toFloat() + } private var optionsMenuInvalidator: Runnable? = null @@ -195,8 +197,10 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele @JvmStatic protected val PROC_IDE = "IDE" + @JvmStatic protected val PROC_GRADLE_TOOLING = "Gradle Tooling" + @JvmStatic protected val PROC_GRADLE_DAEMON = "Gradle Daemon" @@ -252,7 +256,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele override fun bindLayout(): View { this._binding = ActivityEditorBinding.inflate(layoutInflater) - this.diagnosticInfoBinding = this.binding.diagnosticInfo + this.diagnosticInfoBinding = this.content.diagnosticInfo return this.binding.root } @@ -262,13 +266,15 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele drawerSidebar.getFragment() .onApplyWindowInsets(insets) - editorAppBarLayout.updatePadding( - top = insets.top - ) - editorToolbar.updatePaddingRelative( - start = editorToolbar.paddingStart + insets.left, - end = editorToolbar.paddingEnd + insets.right - ) + content.apply { + editorAppBarLayout.updatePadding( + top = insets.top + ) + editorToolbar.updatePaddingRelative( + start = editorToolbar.paddingStart + insets.left, + end = editorToolbar.paddingEnd + insets.right + ) + } } } @@ -286,7 +292,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele return } - Snackbar.make(binding.realContainer, string.msg_action_open_application, Snackbar.LENGTH_LONG) + Snackbar.make(content.realContainer, string.msg_action_open_application, Snackbar.LENGTH_LONG) .setAction(string.yes) { IntentUtils.launchApp(this, packageName) }.show() } @@ -305,10 +311,10 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele onBackPressedDispatcher.addCallback(this, onBackPressedCallback) lifecycle.addObserver(mLifecycleObserver) - setSupportActionBar(binding.editorToolbar) + setSupportActionBar(content.editorToolbar) setupDrawers() - binding.tabs.addOnTabSelectedListener(this) + content.tabs.addOnTabSelectedListener(this) setupViews() @@ -325,8 +331,9 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele private fun onSwipeRevealDragProgress(progress: Float) { _binding?.apply { + contentCard.progress = progress val insetsTop = lastWindowInsets?.top ?: 0 - editorAppBarLayout.updatePadding( + content.editorAppBarLayout.updatePadding( top = (insetsTop * (1f - progress)).roundToInt() ) memUsageView.chart.updateLayoutParams { @@ -507,11 +514,11 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele } open fun setSearchResultAdapter(adapter: SearchListAdapter) { - binding.bottomSheet.setSearchResultAdapter(adapter) + content.bottomSheet.setSearchResultAdapter(adapter) } open fun setDiagnosticsAdapter(adapter: DiagnosticsAdapter) { - binding.bottomSheet.setDiagnosticsAdapter(adapter) + content.bottomSheet.setDiagnosticsAdapter(adapter) } open fun hideBottomSheet() { @@ -525,20 +532,20 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele editorBottomSheet?.state = BottomSheetBehavior.STATE_EXPANDED } - val index = binding.bottomSheet.pagerAdapter.findIndexOfFragmentByClass( + val index = content.bottomSheet.pagerAdapter.findIndexOfFragmentByClass( SearchResultFragment::class.java) - if (index >= 0 && index < binding.bottomSheet.binding.tabs.tabCount) { - binding.bottomSheet.binding.tabs.getTabAt(index)?.select() + if (index >= 0 && index < content.bottomSheet.binding.tabs.tabCount) { + content.bottomSheet.binding.tabs.getTabAt(index)?.select() } } open fun handleDiagnosticsResultVisibility(errorVisible: Boolean) { - binding.bottomSheet.handleDiagnosticsResultVisibility(errorVisible) + content.bottomSheet.handleDiagnosticsResultVisibility(errorVisible) } open fun handleSearchResultVisibility(errorVisible: Boolean) { - binding.bottomSheet.handleSearchResultVisibility(errorVisible) + content.bottomSheet.handleSearchResultVisibility(errorVisible) } open fun showFirstBuildNotice() { @@ -565,7 +572,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele } fun refreshSymbolInput(editor: CodeEditorView) { - binding.bottomSheet.refreshSymbolInput(editor) + content.bottomSheet.refreshSymbolInput(editor) } private fun checkIsDestroying() { @@ -595,14 +602,14 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele } private fun setupDrawers() { - val toggle = ActionBarDrawerToggle(this, binding.editorDrawerLayout, binding.editorToolbar, + val toggle = ActionBarDrawerToggle(this, binding.editorDrawerLayout, content.editorToolbar, string.app_name, string.app_name) binding.editorDrawerLayout.addDrawerListener(toggle) toggle.syncState() binding.apply { editorDrawerLayout.apply { - childId = binding.realContainer.id + childId = content.realContainer.id translationBehaviorStart = ContentTranslatingDrawerLayout.TranslationBehavior.FULL translationBehaviorEnd = ContentTranslatingDrawerLayout.TranslationBehavior.FULL setScrimColor(Color.TRANSPARENT) @@ -614,17 +621,17 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele log.debug( "onBuildStatusChanged: isInitializing: ${editorViewModel.isInitializing}, isBuildInProgress: ${editorViewModel.isBuildInProgress}") val visible = editorViewModel.isBuildInProgress || editorViewModel.isInitializing - binding.progressIndicator.visibility = if (visible) View.VISIBLE else View.GONE + content.progressIndicator.visibility = if (visible) View.VISIBLE else View.GONE invalidateOptionsMenu() } private fun setupViews() { editorViewModel._isBuildInProgress.observe(this) { onBuildStatusChanged() } editorViewModel._isInitializing.observe(this) { onBuildStatusChanged() } - editorViewModel._statusText.observe(this) { binding.bottomSheet.setStatus(it.first, it.second) } + editorViewModel._statusText.observe(this) { content.bottomSheet.setStatus(it.first, it.second) } editorViewModel.observeFiles(this) { files -> - binding.apply { + content.apply { if (files.isNullOrEmpty()) { tabs.visibility = View.GONE viewContainer.displayedChild = 1 @@ -650,6 +657,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele }, 1500) } + binding.contentCard.progress = 0f binding.swipeReveal.dragListener = object : SwipeRevealLayout.OnDragListener { override fun onDragStateChanged(swipeRevealLayout: SwipeRevealLayout, state: Int) {} override fun onDragProgress(swipeRevealLayout: SwipeRevealLayout, progress: Float) { @@ -659,7 +667,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele } private fun setupNoEditorView() { - binding.noEditorSummary.movementMethod = LinkMovementMethod() + content.noEditorSummary.movementMethod = LinkMovementMethod() val filesSpan: ClickableSpan = object : ClickableSpan() { override fun onClick(widget: View) { binding.root.openDrawer(GravityCompat.START) @@ -673,7 +681,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele val sb = SpannableStringBuilder() appendClickableSpan(sb, string.msg_drawer_for_files, filesSpan) appendClickableSpan(sb, string.msg_swipe_for_output, bottomSheetSpan) - binding.noEditorSummary.text = sb + content.noEditorSummary.text = sb } private fun appendClickableSpan( @@ -696,7 +704,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele } private fun setupBottomSheet() { - editorBottomSheet = BottomSheetBehavior.from(binding.bottomSheet) + editorBottomSheet = BottomSheetBehavior.from(content.bottomSheet) editorBottomSheet?.addBottomSheetCallback(object : BottomSheetCallback() { override fun onStateChanged(bottomSheet: View, newState: Int) { if (newState == BottomSheetBehavior.STATE_EXPANDED) { @@ -706,7 +714,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele } override fun onSlide(bottomSheet: View, slideOffset: Float) { - binding.apply { + content.apply { val editorScale = 1 - slideOffset * (1 - EDITOR_CONTAINER_SCALE_FACTOR) this.bottomSheet.onSlide(slideOffset) this.viewContainer.scaleX = editorScale @@ -717,7 +725,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele val observer: OnGlobalLayoutListener = object : OnGlobalLayoutListener { override fun onGlobalLayout() { - binding.also { + content.also { it.realContainer.pivotX = it.realContainer.width.toFloat() / 2f it.realContainer.pivotY = (it.realContainer.height.toFloat() / 2f) + (lastWindowInsets?.height() ?: 0) @@ -726,7 +734,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele } } - binding.apply { + content.apply { viewContainer.viewTreeObserver.addOnGlobalLayoutListener(observer) bottomSheet.setOffsetAnchor(editorAppBarLayout) } @@ -750,7 +758,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele private fun onSoftInputChanged() { if (!isDestroying) { invalidateOptionsMenu() - binding.bottomSheet.onSoftInputChanged() + content.bottomSheet.onSoftInputChanged() } } diff --git a/app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt b/app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt index 51e7d0989..4b21c8714 100644 --- a/app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt +++ b/app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt @@ -103,7 +103,7 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler { super.onCreate(savedInstanceState) editorViewModel._displayedFile.observe( - this) { this.binding.editorContainer.displayedChild = it } + this) { this.content.editorContainer.displayedChild = it } editorViewModel._startDrawerOpened.observe(this) { opened -> this.binding.editorDrawerLayout.apply { if (opened) openDrawer(GravityCompat.START) else closeDrawer(GravityCompat.START) @@ -245,7 +245,7 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler { action.createActionView(data)?.let { item.actionView = it } } } - binding.editorToolbar.updateMenuDisplay() + content.editorToolbar.updateMenuDisplay() } private fun createToolbarActionData(): ActionData { @@ -269,7 +269,7 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler { } override fun getEditorAtIndex(index: Int): CodeEditorView? { - return _binding?.editorContainer?.getChildAt(index) as CodeEditorView? + return _binding?.content?.editorContainer?.getChildAt(index) as CodeEditorView? } override fun openFileAndSelect(file: File, selection: Range?) { @@ -296,7 +296,7 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler { } val index = openFileAndGetIndex(file, range) - val tab = binding.tabs.getTabAt(index) + val tab = content.tabs.getTabAt(index) if (tab != null && index >= 0 && !tab.isSelected) { tab.select() } @@ -329,8 +329,8 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler { val editor = CodeEditorView(this, file, selection!!) editor.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT) - binding.editorContainer.addView(editor) - binding.tabs.addTab(binding.tabs.newTab()) + content.editorContainer.addView(editor) + content.tabs.addTab(content.tabs.newTab()) editorViewModel.addFile(file) editorViewModel.setCurrentFile(position, file) @@ -342,7 +342,7 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler { override fun getEditorForFile(file: File): CodeEditorView? { for (i in 0 until editorViewModel.getOpenedFileCount()) { - val editor = binding.editorContainer.getChildAt(i) as? CodeEditorView + val editor = content.editorContainer.getChildAt(i) as? CodeEditorView if (file == editor?.file) return editor } return null @@ -460,7 +460,7 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler { editorViewModel.areFilesModified = hasUnsaved // set tab as unmodified - val tab = binding.tabs.getTabAt(index) ?: return@withContext + val tab = content.tabs.getTabAt(index) ?: return@withContext if (tab.text!!.startsWith('*')) { tab.text = tab.text!!.substring(startIndex = 1) } @@ -519,7 +519,7 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler { } editorViewModel.removeFile(index) - binding.apply { + content.apply { tabs.removeTabAt(index) editorContainer.removeViewAt(index) } @@ -587,7 +587,7 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler { } editorViewModel.removeAllFiles() - binding.apply { + content.apply { tabs.removeAllTabs() tabs.requestLayout() editorContainer.removeAllViews() @@ -637,7 +637,7 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler { @Subscribe(threadMode = ThreadMode.MAIN) fun onFileRenamed(event: FileRenameEvent) { val index = findIndexOfEditorByFile(event.file) - if (index < 0 || index >= binding.tabs.tabCount) { + if (index < 0 || index >= content.tabs.tabCount) { return } @@ -658,7 +658,7 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler { return } - val tab = binding.tabs.getTabAt(index)!! + val tab = content.tabs.getTabAt(index)!! if (tab.text?.startsWith('*') == true) { return } @@ -680,7 +680,7 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler { nameBuilder.addPath(it, it.path) } - for (index in 0 until binding.tabs.tabCount) { + for (index in 0 until content.tabs.tabCount) { val file = files.getOrNull(index) ?: continue val count = dupliCount[file.name] ?: 0 @@ -695,7 +695,7 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler { withContext(Dispatchers.Main) { names.forEach { index, (name, iconId) -> - val tab = binding.tabs.getTabAt(index) ?: return@forEach + val tab = content.tabs.getTabAt(index) ?: return@forEach tab.icon = ResourcesCompat.getDrawable(resources, iconId, theme) tab.text = name } diff --git a/app/src/main/java/com/itsaky/androidide/activities/editor/ProjectHandlerActivity.kt b/app/src/main/java/com/itsaky/androidide/activities/editor/ProjectHandlerActivity.kt index 25afb19c8..fec8eea10 100644 --- a/app/src/main/java/com/itsaky/androidide/activities/editor/ProjectHandlerActivity.kt +++ b/app/src/main/java/com/itsaky/androidide/activities/editor/ProjectHandlerActivity.kt @@ -226,7 +226,7 @@ abstract class ProjectHandlerActivity : BaseEditorActivity() { } fun appendBuildOutput(str: String) { - binding.bottomSheet.appendBuildOut(str) + content.bottomSheet.appendBuildOut(str) } fun notifySyncNeeded() { diff --git a/app/src/main/java/com/itsaky/androidide/handlers/EditorBuildEventListener.kt b/app/src/main/java/com/itsaky/androidide/handlers/EditorBuildEventListener.kt index f0522138c..de1b5dd46 100644 --- a/app/src/main/java/com/itsaky/androidide/handlers/EditorBuildEventListener.kt +++ b/app/src/main/java/com/itsaky/androidide/handlers/EditorBuildEventListener.kt @@ -74,10 +74,10 @@ class EditorBuildEventListener : GradleBuildService.EventListener { } activity.editorViewModel.isBuildInProgress = true - activity.binding.bottomSheet.clearBuildOutput() + activity.content.bottomSheet.clearBuildOutput() if (buildInfo.tasks.isNotEmpty()) { - activity.binding.bottomSheet.appendBuildOut( + activity.content.bottomSheet.appendBuildOut( activity.getString(R.string.title_run_tasks) + " : " + buildInfo.tasks) } } diff --git a/app/src/main/java/com/itsaky/androidide/lsp/IDELanguageClientImpl.java b/app/src/main/java/com/itsaky/androidide/lsp/IDELanguageClientImpl.java index 9539fca5f..22d569e17 100755 --- a/app/src/main/java/com/itsaky/androidide/lsp/IDELanguageClientImpl.java +++ b/app/src/main/java/com/itsaky/androidide/lsp/IDELanguageClientImpl.java @@ -279,7 +279,7 @@ public class IDELanguageClientImpl implements ILanguageClient { if (file.exists() && file.isFile() && FileUtils.isUtf8(file)) { final var range = params.getSelection(); var frag = - activity.getEditorAtIndex(activity.getBinding().tabs.getSelectedTabPosition()); + activity.getEditorAtIndex(activity.getContent().tabs.getSelectedTabPosition()); if (frag != null && frag.getFile() != null && frag.getEditor() != null diff --git a/app/src/main/java/com/itsaky/androidide/ui/EditorBottomSheet.kt b/app/src/main/java/com/itsaky/androidide/ui/EditorBottomSheet.kt index e248754c3..f6c726547 100644 --- a/app/src/main/java/com/itsaky/androidide/ui/EditorBottomSheet.kt +++ b/app/src/main/java/com/itsaky/androidide/ui/EditorBottomSheet.kt @@ -19,6 +19,7 @@ package com.itsaky.androidide.ui import android.app.Activity import android.content.Context +import android.graphics.Color import android.text.TextUtils import android.util.AttributeSet import android.view.LayoutInflater @@ -59,6 +60,7 @@ import com.itsaky.androidide.tasks.TaskExecutor.executeAsyncProvideError import com.itsaky.androidide.utils.IntentUtils.shareFile import com.itsaky.androidide.utils.Symbols.forFile import com.itsaky.androidide.utils.flashError +import com.itsaky.androidide.utils.resolveAttr import org.slf4j.LoggerFactory import java.io.File import java.io.IOException @@ -236,6 +238,10 @@ constructor( val insetBottom = windowInsets?.bottom ?: 0 val padding = insetBottom * paddingScale binding.headerContainer.apply { + var color = Color.valueOf(context.resolveAttr(R.attr.colorSurface)) + color = Color.valueOf(color.red(), color.green(), color.blue(), (1f - paddingScale)) + setBackgroundColor(color.toArgb()) + updateLayoutParams { height = ((collapsedHeight + padding) * heightScale).roundToInt() } diff --git a/app/src/main/java/com/itsaky/androidide/ui/SwipeRevealLayout.kt b/app/src/main/java/com/itsaky/androidide/ui/SwipeRevealLayout.kt index 59d5a7ace..48ac5ed51 100644 --- a/app/src/main/java/com/itsaky/androidide/ui/SwipeRevealLayout.kt +++ b/app/src/main/java/com/itsaky/androidide/ui/SwipeRevealLayout.kt @@ -19,7 +19,6 @@ package com.itsaky.androidide.ui import android.annotation.SuppressLint import android.content.Context -import android.content.res.ColorStateList import android.util.AttributeSet import android.view.MotionEvent import android.view.View @@ -28,13 +27,8 @@ import androidx.annotation.CallSuper import androidx.annotation.FloatRange import androidx.annotation.IdRes import androidx.customview.widget.ViewDragHelper -import com.blankj.utilcode.util.SizeUtils -import com.google.android.material.shape.CornerFamily import com.google.android.material.shape.MaterialShapeDrawable -import com.google.android.material.shape.ShapeAppearanceModel import com.itsaky.androidide.R -import com.itsaky.androidide.utils.resolveAttr -import org.slf4j.LoggerFactory import kotlin.math.max import kotlin.math.min @@ -178,16 +172,10 @@ open class SwipeRevealLayout @JvmOverloads constructor( var isOpen = false protected set - /** - * The corner radius of the overlapping content. - */ - var overlappingContentCorners = SizeUtils.dp2px(28f).toFloat() - companion object { private const val HIDDEN_CONTENT_INDEX = 0 private const val OVERLAPPING_CONTENT_INDEX = 1 - private val log = LoggerFactory.getLogger(SwipeRevealLayout::class.java) @Suppress("UNUSED") const val STATE_IDLE = ViewDragHelper.STATE_IDLE @@ -219,15 +207,6 @@ open class SwipeRevealLayout @JvmOverloads constructor( check(childCount == 2) { "SwipeRevealLayout must have exactly two children; the hidden content and the overlapping content" } - - val shapeAppearanceModel = ShapeAppearanceModel.Builder().apply { - setAllCorners(CornerFamily.ROUNDED, overlappingContentCorners) - }.build() - - val realBg = MaterialShapeDrawable(shapeAppearanceModel) - realBg.fillColor = ColorStateList.valueOf(context.resolveAttr(R.attr.colorSurface)) - realBg.interpolation = 0f - overlappingContent.background = realBg } override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { @@ -248,7 +227,8 @@ open class SwipeRevealLayout @JvmOverloads constructor( } override fun onInterceptTouchEvent(ev: MotionEvent): Boolean { - return isViewHit(dragHandleView!!, ev.x.toInt(), ev.y.toInt()) && dragHelper.shouldInterceptTouchEvent(ev) + return isViewHit(dragHandleView!!, ev.x.toInt(), + ev.y.toInt()) && dragHelper.shouldInterceptTouchEvent(ev) } @SuppressLint("ClickableViewAccessibility") diff --git a/app/src/main/java/com/itsaky/androidide/utils/ApkInstallationSessionCallback.kt b/app/src/main/java/com/itsaky/androidide/utils/ApkInstallationSessionCallback.kt index 04affe6f3..c2a5054f7 100644 --- a/app/src/main/java/com/itsaky/androidide/utils/ApkInstallationSessionCallback.kt +++ b/app/src/main/java/com/itsaky/androidide/utils/ApkInstallationSessionCallback.kt @@ -35,7 +35,7 @@ class ApkInstallationSessionCallback(private var activity: BaseEditorActivity?) override fun onCreated(sessionId: Int) { this.sessionId = sessionId log.debug("Created package installation session: {}", sessionId) - activity?._binding?.apply { + activity?._binding?.content?.apply { bottomSheet.setActionText(activity!!.getString(string.msg_installing_apk)) bottomSheet.setActionProgress(0) bottomSheet.showChild(EditorBottomSheet.CHILD_ACTION) @@ -43,11 +43,11 @@ class ApkInstallationSessionCallback(private var activity: BaseEditorActivity?) } override fun onProgressChanged(sessionId: Int, progress: Float) { - activity?._binding?.bottomSheet?.setActionProgress((progress * 100f).toInt()) + activity?._binding?.content?.bottomSheet?.setActionProgress((progress * 100f).toInt()) } override fun onFinished(sessionId: Int, success: Boolean) { - activity?._binding?.apply { + activity?._binding?.content?.apply { bottomSheet.showChild(EditorBottomSheet.CHILD_HEADER) bottomSheet.setActionProgress(0) if (!success) { diff --git a/app/src/main/res/layout/activity_editor.xml b/app/src/main/res/layout/activity_editor.xml index b78a589af..a0f7954ca 100755 --- a/app/src/main/res/layout/activity_editor.xml +++ b/app/src/main/res/layout/activity_editor.xml @@ -14,106 +14,23 @@ android:layout_height="match_parent" app:dragHandle="@id/editor_appBarLayout"> - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:layout_height="match_parent" + app:cardBackgroundColor="?attr/colorSurface" + app:cardCornerRadius="@dimen/editor_container_corners" + app:cardElevation="0dp"> + android:id="@+id/content" + layout="@layout/content_editor" /> - + @@ -126,9 +43,9 @@ + android:layout_height="match_parent" /> diff --git a/app/src/main/res/layout/content_editor.xml b/app/src/main/res/layout/content_editor.xml new file mode 100644 index 000000000..92753db22 --- /dev/null +++ b/app/src/main/res/layout/content_editor.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_editor_bottom_sheet.xml b/app/src/main/res/layout/layout_editor_bottom_sheet.xml index 7833e2f1f..4dd0c6ade 100644 --- a/app/src/main/res/layout/layout_editor_bottom_sheet.xml +++ b/app/src/main/res/layout/layout_editor_bottom_sheet.xml @@ -21,7 +21,8 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:background="?attr/colorSurface"> 200dp + 28dp \ No newline at end of file