fix: use MaterialCardView to clip children onSwipeRevealProgress

This commit is contained in:
Akash Yadav
2024-05-18 01:35:18 +05:30
parent 6fc4423e21
commit 8c878a0d02
14 changed files with 209 additions and 180 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
@@ -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()
}
@@ -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<EditorSidebarFragment>()
.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<ViewGroup.MarginLayoutParams> {
@@ -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<View>(binding.bottomSheet)
editorBottomSheet = BottomSheetBehavior.from<View>(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()
}
}
@@ -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
}
@@ -226,7 +226,7 @@ abstract class ProjectHandlerActivity : BaseEditorActivity() {
}
fun appendBuildOutput(str: String) {
binding.bottomSheet.appendBuildOut(str)
content.bottomSheet.appendBuildOut(str)
}
fun notifySyncNeeded() {
@@ -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)
}
}
@@ -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
@@ -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<ViewGroup.LayoutParams> {
height = ((collapsedHeight + padding) * heightScale).roundToInt()
}
@@ -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")
@@ -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) {
+14 -97
View File
@@ -14,106 +14,23 @@
android:layout_height="match_parent"
app:dragHandle="@id/editor_appBarLayout">
<include android:id="@+id/mem_usage_view" layout="@layout/layout_mem_usage" />
<include
android:id="@+id/mem_usage_view"
layout="@layout/layout_mem_usage" />
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/realContainer"
android:animateLayoutChanges="true"
android:background="?attr/colorSurface"
<com.google.android.material.card.MaterialCardView
android:id="@+id/content_card"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/editor_appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="false"
android:background="@android:color/transparent"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$Behavior">
<com.itsaky.androidide.ui.ExtendedMenuToolbar
android:id="@+id/editor_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="10dp" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/progress_indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
style="@style/AppTheme.TabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="start" />
</com.google.android.material.appbar.AppBarLayout>
<ViewFlipper
android:id="@+id/view_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="16dp"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<!--Views in this flipper are dynamically added and must be instances of CodeEditorView-->
<ViewFlipper
android:id="@+id/editor_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/editor_sheet_peek_height" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/no_editor_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textAppearance="@style/TextAppearance.Material3.TitleLarge"
android:textColor="?attr/colorOnSurface"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.4" />
<TextView
android:id="@+id/no_editor_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center"
android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
android:textColor="?attr/colorSecondaryVariant"
android:textSize="13sp"
app:layout_constraintEnd_toEndOf="@id/no_editor_title"
app:layout_constraintStart_toStartOf="@id/no_editor_title"
app:layout_constraintTop_toBottomOf="@+id/no_editor_title"
tools:text="Open right drawer for files\nSwipe from bottom for build output" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ViewFlipper>
<com.itsaky.androidide.ui.EditorBottomSheet
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:behavior_hideable="false"
app:behavior_peekHeight="@dimen/editor_sheet_peek_height"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" />
android:layout_height="match_parent"
app:cardBackgroundColor="?attr/colorSurface"
app:cardCornerRadius="@dimen/editor_container_corners"
app:cardElevation="0dp">
<include
android:id="@+id/diagnosticInfo"
layout="@layout/layout_diagnostic_info" />
android:id="@+id/content"
layout="@layout/content_editor" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</com.google.android.material.card.MaterialCardView>
</com.itsaky.androidide.ui.SwipeRevealLayout>
@@ -126,9 +43,9 @@
<androidx.fragment.app.FragmentContainerView
android:id="@+id/drawer_sidebar"
android:name="com.itsaky.androidide.fragments.sidebar.EditorSidebarFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.itsaky.androidide.fragments.sidebar.EditorSidebarFragment" />
android:layout_height="match_parent" />
</com.google.android.material.navigation.NavigationView>
+116
View File
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ This file is part of AndroidIDE.
~
~ AndroidIDE is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ AndroidIDE is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
-->
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/realContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/editor_appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:fitsSystemWindows="false"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$Behavior">
<com.itsaky.androidide.ui.ExtendedMenuToolbar
android:id="@+id/editor_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="10dp" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/progress_indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
style="@style/AppTheme.TabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="start" />
</com.google.android.material.appbar.AppBarLayout>
<ViewFlipper
android:id="@+id/view_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="16dp"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<!--Views in this flipper are dynamically added and must be instances of CodeEditorView-->
<ViewFlipper
android:id="@+id/editor_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/editor_sheet_peek_height" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/no_editor_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textAppearance="@style/TextAppearance.Material3.TitleLarge"
android:textColor="?attr/colorOnSurface"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.4" />
<TextView
android:id="@+id/no_editor_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center"
android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
android:textColor="?attr/colorSecondaryVariant"
android:textSize="13sp"
app:layout_constraintEnd_toEndOf="@id/no_editor_title"
app:layout_constraintStart_toStartOf="@id/no_editor_title"
app:layout_constraintTop_toBottomOf="@+id/no_editor_title"
tools:text="Open right drawer for files\nSwipe from bottom for build output" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ViewFlipper>
<com.itsaky.androidide.ui.EditorBottomSheet
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:behavior_hideable="false"
app:behavior_peekHeight="@dimen/editor_sheet_peek_height"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" />
<include
android:id="@+id/diagnosticInfo"
layout="@layout/layout_diagnostic_info" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
@@ -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">
<include
android:id="@+id/border"
+1
View File
@@ -17,4 +17,5 @@
<resources>
<dimen name="editor_mem_usage_view_height">200dp</dimen>
<dimen name="editor_container_corners">28dp</dimen>
</resources>