Skip to content

Migration to Jetpack Compose #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
903e011
Dependencies: Add Jetpack Compose support
Sep 30, 2022
2ae9fe1
Dependencies: fix themeadapter dependency path
EmogurovAnton Jul 18, 2024
79a9e32
Base:Fix Broadcast receiver action name
Dec 6, 2022
9dba5b5
Deps:Update `common` module dependencies
Dec 8, 2022
4176edc
Core:Add 'content' and `settingsContent` composable functions for Plu…
Dec 8, 2022
e8a3d9c
Base: Migrate to view binding from 'synthetics'
Sep 24, 2023
e27f4eb
AppSettings: Add the ability to open `appsettings` plugin from Jetpac…
Dec 8, 2022
73acd38
Flipper:Add the ability to open `flipper` plugin from JetpackCompose
Dec 8, 2022
6154a48
Servers: Add the ability to open `servers` plugin from JetpackCompose
Dec 8, 2022
68a8498
Account:Migrate account plugin to Jetpack Compose
Oct 3, 2022
cfceedb
Account: fix function params
EmogurovAnton Jul 18, 2024
f179ffa
Accounts: Add the ability to open `accounts` plugin from JetpackCompose
Dec 8, 2022
83788a2
Variable:Add the ability to open `variable` plugin from JetpackCompose
Dec 8, 2022
765f9e6
Servers: Add the ability to add a stage with multiple hosts
Jan 12, 2023
e810f08
No-op: update no-op module
Jan 12, 2023
edd8e41
Servers: Migrate to Jetpack Compose UI
Jan 16, 2023
57dabbd
Sample: Update sample project
Jan 16, 2023
9435e32
Servers: Add methods to get the selected stage and the default stage
Jan 16, 2023
3c45a47
AppSettings: Migrate App-settings plugin to the Jetpack Compose
Jan 21, 2023
f45b6aa
Flipper: Migrate Flipper plugin to the Jetpack Compose
Mar 1, 2023
8d11f4d
Core: Add ability to open panel without fragment manager
EmogurovAnton Jul 18, 2024
6d2d038
Core: fix DebugBottomSheet deprecated expand state
EmogurovAnton Jul 18, 2024
dfee5ad
rebase: rebase fixes
EmogurovAnton Jul 22, 2024
6f49672
build: fix lint & compileTask
EmogurovAnton Jul 23, 2024
4cad8cc
ui: fix inflater error & debug bottom sheet state
EmogurovAnton Jul 23, 2024
ce2b6ff
review: review improves
EmogurovAnton Jul 25, 2024
722d8fa
Servers: Refactoring servers screen
Jul 26, 2024
725a1fa
Review: Fix review commits
Jul 26, 2024
9c86d83
refactoring: move bottom sheet to separate activity
EmogurovAnton Jul 26, 2024
c23629e
Accounts: Add settings content
Jul 26, 2024
0f28095
Core: Delete old DebugBottomSheet
Jul 26, 2024
a3d733b
Core: Delete getFragment from Plugin
Jul 26, 2024
f984f49
Accounts: Delete old fragment
Jul 26, 2024
9b1778a
Servers: Delete old fragment
Jul 26, 2024
af8821e
fix: Delete unused view binding
Jul 26, 2024
d9d4e79
review: minor fixes
EmogurovAnton Jul 29, 2024
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
36 changes: 25 additions & 11 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,37 @@ android {
}

dependencies {
api(kotlin("stdlib"))
api(androidx.activity.compose)
api(androidx.compose.animation)
api(androidx.compose.foundation)
api(androidx.compose.material)
api(androidx.compose.runtime.livedata)
api(androidx.compose.ui)
api(androidx.compose.ui.tooling)
api(androidx.compose.ui.tooling.preview)
api(androidx.compose.ui.viewbinding)
api(androidx.constraintlayout.compose)
api(androidx.core)
api(androidx.fragment)
api(androidx.lifecycle.viewmodel.compose)
api(androidx.room)
api(androidx.room.runtime)
api(rmr.flipper)
api(rmr.itemsadapter.viewbinding)
api(stack.accompanist.themeadapter.core)
api(stack.accompanist.themeadapter.material)
api(stack.kotlinx.coroutines.android)
api(stack.okhttp)
api(stack.timber)
kapt(androidx.room.compiler)
// legacy
api(androidx.appcompat)
api(stack.material)
api(androidx.constraintlayout)
api(stack.kotlinx.coroutines.android)
api(androidx.lifecycle.runtime)
api(androidx.lifecycle.livedata)
api(androidx.lifecycle.livedata.core)
api(androidx.lifecycle.runtime)
api(androidx.lifecycle.viewmodel)
api(androidx.room.runtime)
api(androidx.room)
api(androidx.core)
api(rmr.itemsadapter.viewbinding)
api(rmr.flipper)
api(stack.timber)
kapt(androidx.room.compiler)
api(stack.material)
}

tasks.register("prepareKotlinBuildScriptModel") {}

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions common/src/main/res/layout/item_section_header.xml

This file was deleted.

4 changes: 0 additions & 4 deletions common/src/main/res/values/dimens.xml

This file was deleted.

13 changes: 0 additions & 13 deletions common/src/main/res/values/styles.xml

This file was deleted.

5 changes: 5 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ android {

buildFeatures {
viewBinding = true
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion = androidx.versions.compose.compiler.get()
}
namespace = "com.redmadrobot.debug.core"
}
Expand Down
7 changes: 7 additions & 0 deletions core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
android:taskAffinity="com.redmadrobot.debug_panel.DebugActivity"
android:theme="@style/DebugPanelTheme" />

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

<activity-alias
android:name="com.redmadrobot.debug_panel.DebugLauncherActivity"
android:enabled="true"
Expand Down
14 changes: 10 additions & 4 deletions core/src/main/kotlin/com/redmadrobot/debug/core/DebugPanel.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.redmadrobot.debug.core

import android.app.Activity
import android.app.Application
import androidx.fragment.app.FragmentManager
import android.content.Intent
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.Observer
import com.redmadrobot.debug.core.annotation.DebugPanelInternal
import com.redmadrobot.debug.core.inapp.DebugBottomSheet
import com.redmadrobot.debug.core.plugin.Plugin
import com.redmadrobot.debug.core.ui.debugpanel.DebugBottomSheetActivity
import com.redmadrobot.debug.core.util.ApplicationLifecycleHandler
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.emptyFlow
Expand Down Expand Up @@ -35,12 +36,17 @@ public object DebugPanel {
return instance?.getEventFlow() ?: emptyFlow()
}

public fun showPanel(fragmentManager: FragmentManager) {
public fun showPanel(activity: Activity) {
if (isInitialized) {
DebugBottomSheet.show(fragmentManager)
openDebugBottomSheet(activity)
}
}

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

private fun createDebugPanelInstance(application: Application, plugins: List<Plugin>) {
instance = DebugPanelInstance(application, plugins)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.redmadrobot.debug.core.extension

import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewmodel.compose.viewModel
import com.redmadrobot.debug.core.annotation.DebugPanelInternal

@DebugPanelInternal
@Composable
public inline fun <reified T : ViewModel> provideViewModel(crossinline block: () -> T): T {
return viewModel(
factory = object : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
@Suppress("UNCHECKED_CAST")
return block() as T
}
}
)
}


@DebugPanelInternal
@Composable
public fun OnLifecycleEvent(onEvent: (event: Lifecycle.Event) -> Unit) {
val eventHandler by rememberUpdatedState(onEvent)
val lifecycleOwner by rememberUpdatedState(LocalLifecycleOwner.current)

DisposableEffect(lifecycleOwner) {
val lifecycle = lifecycleOwner.lifecycle
val observer = LifecycleEventObserver { _, event ->
eventHandler(event)
}

lifecycle.addObserver(observer)
onDispose {
lifecycle.removeObserver(observer)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.redmadrobot.debug.common.extension
package com.redmadrobot.debug.core.extension

import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.redmadrobot.debug.common.extension
package com.redmadrobot.debug.core.extension

import androidx.annotation.MainThread
import androidx.fragment.app.Fragment
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.redmadrobot.debug.core.extension

import androidx.fragment.app.Fragment
import com.redmadrobot.debug.core.DebugPanelInstance
import com.redmadrobot.debug.core.annotation.DebugPanelInternal
import com.redmadrobot.debug.core.plugin.Plugin
import com.redmadrobot.debug.core.ui.debugpanel.DebugActivity

@PublishedApi
internal fun getPlugin(pluginName: String): Plugin {
Expand All @@ -20,3 +22,7 @@ public inline fun <reified T : Plugin> getPlugin(): T {
return plugin as T
}

@DebugPanelInternal
public fun Fragment.isSettingMode(): Boolean {
return activity?.javaClass == DebugActivity::class.java
}

This file was deleted.

This file was deleted.

Loading
Loading