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
1 change: 1 addition & 0 deletions panel-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dependencies {

implementation(stack.kotlinx.coroutines.android)
implementation(stack.timber)
implementation(stack.material)

api(androidx.lifecycle.viewmodel)
}
4 changes: 2 additions & 2 deletions panel-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
android:theme="@style/DebugPanelTheme" />

<activity
android:name=".ui.debugpanel.DebugBottomSheetActivity"
android:name=".ui.debugpanel.DebugPanelActivity"
android:exported="false"
android:launchMode="singleTop"
android:theme="@style/DebugBottomSheetTheme"
android:theme="@style/DebugPanelTheme"
android:windowSoftInputMode="adjustResize" />

<activity-alias
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.Observer
import com.redmadrobot.debug.core.annotation.DebugPanelInternal
import com.redmadrobot.debug.core.plugin.Plugin
import com.redmadrobot.debug.core.ui.debugpanel.DebugBottomSheetActivity
import com.redmadrobot.debug.core.ui.debugpanel.DebugPanelActivity
import com.redmadrobot.debug.core.util.ApplicationLifecycleHandler
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.emptyFlow
Expand Down Expand Up @@ -37,12 +37,12 @@ public object DebugPanel {

public fun showPanel(activity: Activity) {
if (isInitialized) {
openDebugBottomSheet(activity)
openDebugPanel(activity)
}
}

private fun openDebugBottomSheet(activity: Activity) {
val intent = Intent(activity, DebugBottomSheetActivity::class.java)
private fun openDebugPanel(activity: Activity) {
val intent = Intent(activity, DebugPanelActivity::class.java)
activity.startActivity(intent)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,73 +4,59 @@ package com.redmadrobot.debug.core.inapp.compose

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.PagerState
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Divider
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.ModalBottomSheetLayout
import androidx.compose.material.ModalBottomSheetValue
import androidx.compose.material.Scaffold
import androidx.compose.material.ScrollableTabRow
import androidx.compose.material.Tab
import androidx.compose.material.TabRowDefaults
import androidx.compose.material.TabRowDefaults.tabIndicatorOffset
import androidx.compose.material.Text
import androidx.compose.material.rememberModalBottomSheetState
import androidx.compose.material.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.redmadrobot.debug.core.R
import com.redmadrobot.debug.core.extension.getAllPlugins
import com.redmadrobot.debug.core.plugin.Plugin
import kotlinx.coroutines.launch

@Composable
public fun DebugBottomSheet(onClose: () -> Unit) {
val state = rememberModalBottomSheetState(
initialValue = ModalBottomSheetValue.Expanded,
confirmValueChange = { sheetState ->
if (sheetState == ModalBottomSheetValue.Hidden) onClose()
true
},
skipHalfExpanded = false
)

ModalBottomSheetLayout(
modifier = Modifier.statusBarsPadding(),
sheetContent = { BottomSheetContent() },
sheetState = state,
scrimColor = Color.Transparent,
sheetShape = RoundedCornerShape(size = 16.dp),
content = {},
)
}

@Composable
private fun BottomSheetContent() {
public fun DebugPanelScreen(onClose: () -> Unit) {
val plugins = remember { getAllPlugins() }
val pluginsName = remember { plugins.map { it.getName() } }
val pagerState = rememberPagerState(initialPage = 0, pageCount = { plugins.size })

Column(modifier = Modifier.fillMaxSize()) {
Divider(
modifier = Modifier
.width(width = 50.dp)
.padding(vertical = 8.dp)
.align(alignment = Alignment.CenterHorizontally),
color = Color.Gray,
thickness = 4.dp
)
PluginsTabLayout(pluginsName = pluginsName, pagerState = pagerState)
PluginsPager(plugins = plugins, pagerState = pagerState)
Scaffold(
topBar = {
TopAppBar(
title = { Text(text = stringResource(R.string.debug_panel)) },
navigationIcon = {
IconButton(onClick = onClose) {
Icon(
painter = painterResource(id = R.drawable.ic_arrow_back),
contentDescription = null,
)
}
},
backgroundColor = MaterialTheme.colors.background,
elevation = 0.dp,
)
},
) { paddingValues ->
Column(modifier = Modifier.padding(paddingValues)) {
PluginsTabLayout(pluginsName = pluginsName, pagerState = pagerState)
PluginsPager(plugins = plugins, pagerState = pagerState)
}
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.redmadrobot.debug.core.ui.debugpanel

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material.MaterialTheme
import com.redmadrobot.debug.core.inapp.compose.DebugPanelScreen

internal class DebugPanelActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MaterialTheme {
DebugPanelScreen(onClose = { finish() })
}
}
}
}
10 changes: 10 additions & 0 deletions panel-core/src/main/res/drawable/ic_arrow_back.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:autoMirrored="true">
<path
android:fillColor="@android:color/black"
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z" />
</vector>
5 changes: 4 additions & 1 deletion panel-core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<resources>
<!-- region Common -->
<string name="debug_panel">DebugPanel</string>
<!-- endregion -->

<!--Notification-->
<!-- region Notification -->
<string name="debug_panel_notification_title">Open DebugPanel</string>
<string name="debug_panel_notification_settings">Open Settings</string>
<!-- endregion -->
</resources>
19 changes: 1 addition & 18 deletions panel-core/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="DebugPanelTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorSecondary">@color/colorSecondary</item>
<item name="colorOnSecondary">@color/colorOnSecondary</item>
<item name="colorSurface">@color/colorSurface</item>
<item name="colorOnSurface">@color/colorOnSurface</item>
</style>

<style name="DebugBottomSheetTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="DebugPanelTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar" />
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package com.redmadrobot.debug.plugin.aboutapp

import androidx.compose.runtime.Composable
import com.redmadrobot.debug.core.internal.CommonContainer
import com.redmadrobot.debug.core.internal.EditablePlugin
import com.redmadrobot.debug.core.internal.PluginDependencyContainer
import com.redmadrobot.debug.core.plugin.Plugin
import com.redmadrobot.debug.plugin.aboutapp.model.AboutAppInfo
import com.redmadrobot.debug.plugin.aboutapp.ui.AboutAppScreen

public class AboutAppPlugin(
private val appInfoList: List<AboutAppInfo>
) : Plugin(), EditablePlugin {
) : Plugin() {
init {
appInfoList.firstOrNull()
?: error("AboutAppPlugin can't be initialized. At least one information block must be set.")
Expand Down
Loading