Skip to content

Commit

Permalink
[build]: refactored app a little once again
Browse files Browse the repository at this point in the history
  • Loading branch information
F0x1d committed Nov 3, 2024
1 parent 8266e12 commit 2d98830
Show file tree
Hide file tree
Showing 244 changed files with 2,151 additions and 1,673 deletions.
18 changes: 18 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,28 @@ android {
}

dependencies {
implementation(projects.feature.appsPicker.api)
implementation(projects.feature.appsPicker.impl)

implementation(projects.feature.crashes.appsList)
implementation(projects.feature.crashes.details)
implementation(projects.feature.crashes.impl)
implementation(projects.feature.crashes.list)

implementation(projects.feature.filters.edit)
implementation(projects.feature.filters.impl)
implementation(projects.feature.filters.list)

implementation(projects.feature.logging.extendedCopy)
implementation(projects.feature.logging.impl)
implementation(projects.feature.logging.list)
implementation(projects.feature.logging.search)
implementation(projects.feature.logging.service)

implementation(projects.feature.recordings.details)
implementation(projects.feature.recordings.impl)
implementation(projects.feature.recordings.list)

implementation(projects.feature.settings)
implementation(projects.feature.setup)

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
android:enableOnBackInvokedCallback="true">

<activity
android:name=".ui.activity.MainActivity"
android:name=".presentation.ui.activity.MainActivity"
android:windowSoftInputMode="adjustResize"
android:launchMode="singleInstance"
android:exported="true">
Expand All @@ -30,7 +30,7 @@
</activity>

<activity
android:name=".ui.activity.OpenFileActivity"
android:name=".presentation.ui.activity.OpenFileActivity"
android:documentLaunchMode="always"
android:excludeFromRecents="true"
android:theme="@style/Theme.LogFox.Translucent"
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/kotlin/com/f0x1d/logfox/coil/AppIconFetcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import coil.fetch.FetchResult
import coil.fetch.Fetcher
import coil.request.Options
import com.f0x1d.logfox.arch.di.IODispatcher
import com.f0x1d.logfox.model.InstalledApp
import com.f0x1d.logfox.feature.apps.picker.InstalledApp
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.withContext
Expand All @@ -35,9 +35,9 @@ class AppIconFetcher(
class Factory @Inject constructor(
@ApplicationContext private val context: Context,
@IODispatcher private val ioDispatcher: CoroutineDispatcher,
) : Fetcher.Factory<InstalledApp> {
) : Fetcher.Factory<com.f0x1d.logfox.feature.apps.picker.InstalledApp> {
override fun create(
data: InstalledApp,
data: com.f0x1d.logfox.feature.apps.picker.InstalledApp,
options: Options,
imageLoader: ImageLoader,
): Fetcher = AppIconFetcher(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.f0x1d.logfox.di.logs
import android.app.PendingIntent
import android.content.Context
import com.f0x1d.logfox.arch.makeActivityPendingIntent
import com.f0x1d.logfox.feature.logging.impl.service.MainActivityPendingIntentProvider
import com.f0x1d.logfox.ui.activity.MainActivity
import com.f0x1d.logfox.feature.logging.service.presentation.MainActivityPendingIntentProvider
import com.f0x1d.logfox.presentation.ui.activity.MainActivity
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.f0x1d.logfox.presentation

sealed interface MainAction {
data object OpenSetup : MainAction
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.f0x1d.logfox.presentation

data object MainState
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.f0x1d.logfox.viewmodel
package com.f0x1d.logfox.presentation

import android.app.Application
import android.content.Intent
import com.f0x1d.logfox.arch.hasPermissionToReadLogs
import com.f0x1d.logfox.arch.startForegroundServiceAvailable
import com.f0x1d.logfox.arch.viewmodel.BaseViewModel
import com.f0x1d.logfox.arch.viewmodel.Event
import com.f0x1d.logfox.feature.logging.impl.service.LoggingService
import com.f0x1d.logfox.preferences.shared.AppPreferences
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
Expand All @@ -15,8 +13,10 @@ import javax.inject.Inject
class MainViewModel @Inject constructor(
private val appPreferences: AppPreferences,
application: Application,
): BaseViewModel(application) {

) : BaseViewModel<MainState, MainAction>(
initialStateProvider = { MainState },
application = application,
) {
var askedNotificationsPermission
get() = appPreferences.askedNotificationsPermission
set(value) { appPreferences.askedNotificationsPermission = value }
Expand All @@ -29,16 +29,14 @@ class MainViewModel @Inject constructor(

private fun load() {
if (ctx.hasPermissionToReadLogs) {
Intent(ctx, LoggingService::class.java).let {
Intent(ctx, com.f0x1d.logfox.feature.logging.service.presentation.LoggingService::class.java).let {
if (startForegroundServiceAvailable)
ctx.startForegroundService(it)
else
ctx.startService(it)
}
} else {
sendEvent(OpenSetup)
sendAction(MainAction.OpenSetup)
}
}
}

data object OpenSetup : Event
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.f0x1d.logfox.ui.activity
package com.f0x1d.logfox.presentation.ui.activity

import android.Manifest
import android.annotation.SuppressLint
Expand All @@ -23,22 +23,21 @@ import com.f0x1d.logfox.arch.contrastedNavBarAvailable
import com.f0x1d.logfox.arch.gesturesAvailable
import com.f0x1d.logfox.arch.hasNotificationsPermission
import com.f0x1d.logfox.arch.isHorizontalOrientation
import com.f0x1d.logfox.arch.ui.activity.BaseViewModelActivity
import com.f0x1d.logfox.arch.viewmodel.Event
import com.f0x1d.logfox.arch.presentation.ui.activity.BaseActivity
import com.f0x1d.logfox.databinding.ActivityMainBinding
import com.f0x1d.logfox.navigation.Directions
import com.f0x1d.logfox.navigation.NavGraphs
import com.f0x1d.logfox.presentation.MainAction
import com.f0x1d.logfox.presentation.MainViewModel
import com.f0x1d.logfox.strings.Strings
import com.f0x1d.logfox.ui.Icons
import com.f0x1d.logfox.viewmodel.MainViewModel
import com.f0x1d.logfox.viewmodel.OpenSetup
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class MainActivity: BaseViewModelActivity<MainViewModel, ActivityMainBinding>(), NavController.OnDestinationChangedListener {
class MainActivity: BaseActivity<ActivityMainBinding>(), NavController.OnDestinationChangedListener {

override val viewModel by viewModels<MainViewModel>()
private val viewModel by viewModels<MainViewModel>()

private val navController by lazy {
val navHostFragment = supportFragmentManager.findFragmentById(
Expand Down Expand Up @@ -94,6 +93,12 @@ class MainActivity: BaseViewModelActivity<MainViewModel, ActivityMainBinding>(),

viewModel.askedNotificationsPermission = true
}

viewModel.actions.collectWithLifecycle { action ->
when (action) {
is MainAction.OpenSetup -> navController.navigate(Directions.action_global_setupFragment)
}
}
}

private fun ActivityMainBinding.setupNavigation() {
Expand Down Expand Up @@ -139,14 +144,6 @@ class MainActivity: BaseViewModelActivity<MainViewModel, ActivityMainBinding>(),
}
}

override fun onEvent(event: Event) {
super.onEvent(event)

when (event) {
is OpenSetup -> navController.navigate(Directions.action_global_setupFragment)
}
}

override fun onDestinationChanged(controller: NavController, destination: NavDestination, arguments: Bundle?) {
val barShown = when (destination.id) {
Directions.setupFragment -> false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.f0x1d.logfox.ui.activity
package com.f0x1d.logfox.presentation.ui.activity

import android.content.Intent
import android.os.Bundle
Expand All @@ -19,4 +19,4 @@ class OpenFileActivity: AppCompatActivity() {
)
finish()
}
}
}
4 changes: 2 additions & 2 deletions app/src/main/kotlin/com/f0x1d/logfox/receiver/BootReceiver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.content.Intent
import com.f0x1d.logfox.arch.hasPermissionToReadLogs
import com.f0x1d.logfox.arch.startForegroundServiceAvailable
import com.f0x1d.logfox.arch.toast
import com.f0x1d.logfox.feature.logging.impl.service.LoggingService
import com.f0x1d.logfox.feature.logging.service.presentation.LoggingService
import com.f0x1d.logfox.preferences.shared.AppPreferences
import com.f0x1d.logfox.strings.Strings
import com.f0x1d.logfox.terminals.ShizukuTerminal
Expand All @@ -26,7 +26,7 @@ class BootReceiver: BroadcastReceiver() {
}

if (context.hasPermissionToReadLogs) {
Intent(context, LoggingService::class.java).let {
Intent(context, com.f0x1d.logfox.feature.logging.service.presentation.LoggingService::class.java).let {
if (startForegroundServiceAvailable)
context.startForegroundService(it)
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.f0x1d.logfox.arch.adapter
package com.f0x1d.logfox.arch.presentation.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import androidx.viewbinding.ViewBinding
import com.f0x1d.logfox.arch.ui.viewholder.BaseViewHolder
import com.f0x1d.logfox.arch.presentation.ui.viewholder.BaseViewHolder

abstract class BaseListAdapter<T, D : ViewBinding>(
diffUtil: DiffUtil.ItemCallback<T>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.f0x1d.logfox.arch.ui
package com.f0x1d.logfox.arch.presentation.ui

import android.view.View
import com.google.android.material.snackbar.Snackbar
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.f0x1d.logfox.arch.ui
package com.f0x1d.logfox.arch.presentation.ui

import android.content.Context
import android.graphics.Color
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.f0x1d.logfox.arch.ui.activity
package com.f0x1d.logfox.arch.presentation.ui.activity

import android.content.Context
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.viewbinding.ViewBinding
import com.f0x1d.logfox.arch.ui.base.SimpleLifecycleOwner
import com.f0x1d.logfox.arch.ui.enableEdgeToEdge
import com.f0x1d.logfox.arch.ui.snackbar
import com.f0x1d.logfox.arch.presentation.ui.base.SimpleLifecycleOwner
import com.f0x1d.logfox.arch.presentation.ui.enableEdgeToEdge
import com.f0x1d.logfox.arch.presentation.ui.snackbar
import dagger.hilt.EntryPoint
import dagger.hilt.InstallIn
import dagger.hilt.android.EntryPointAccessors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.f0x1d.logfox.arch.ui.base
package com.f0x1d.logfox.arch.presentation.ui.base

import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.f0x1d.logfox.arch.ui.dialog
package com.f0x1d.logfox.arch.presentation.ui.dialog

import android.annotation.SuppressLint
import android.app.Dialog
Expand All @@ -7,13 +7,14 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding
import com.f0x1d.logfox.arch.ui.base.SimpleFragmentLifecycleOwner
import com.f0x1d.logfox.arch.ui.enableEdgeToEdge
import com.f0x1d.logfox.arch.presentation.ui.base.SimpleFragmentLifecycleOwner
import com.f0x1d.logfox.arch.presentation.ui.enableEdgeToEdge
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment

abstract class BaseBottomSheet<T : ViewBinding>: BottomSheetDialogFragment(), SimpleFragmentLifecycleOwner {
abstract class BaseBottomSheetFragment<T : ViewBinding>: BottomSheetDialogFragment(),
SimpleFragmentLifecycleOwner {

private var mutableBinding: T? = null
protected val binding: T get() = mutableBinding!!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.f0x1d.logfox.arch.ui.fragment
package com.f0x1d.logfox.arch.presentation.ui.fragment

import android.content.res.Configuration
import android.os.Bundle
Expand All @@ -7,8 +7,8 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
import com.f0x1d.logfox.arch.ui.base.SimpleFragmentLifecycleOwner
import com.f0x1d.logfox.arch.ui.snackbar
import com.f0x1d.logfox.arch.presentation.ui.base.SimpleFragmentLifecycleOwner
import com.f0x1d.logfox.arch.presentation.ui.snackbar
import dev.chrisbanes.insetter.applyInsetter

abstract class BaseFragment<T : ViewBinding>: Fragment(), SimpleFragmentLifecycleOwner {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.f0x1d.logfox.arch.ui.fragment.compose
package com.f0x1d.logfox.arch.presentation.ui.fragment.compose

import android.os.Bundle
import android.view.LayoutInflater
Expand All @@ -9,7 +9,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy
import com.f0x1d.logfox.arch.databinding.FragmentComposeBinding
import com.f0x1d.logfox.arch.ui.fragment.BaseFragment
import com.f0x1d.logfox.arch.presentation.ui.fragment.BaseFragment

abstract class BaseComposeFragment : BaseFragment<FragmentComposeBinding>() {

Expand All @@ -25,11 +25,11 @@ abstract class BaseComposeFragment : BaseFragment<FragmentComposeBinding>() {

@Composable
abstract fun Content()
}

internal fun ComposeView.setup(content: @Composable () -> Unit) {
consumeWindowInsets = false
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
private fun ComposeView.setup(content: @Composable () -> Unit) {
consumeWindowInsets = false
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)

setContent(content)
setContent(content)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.f0x1d.logfox.arch.ui.viewholder
package com.f0x1d.logfox.arch.presentation.ui.viewholder

import androidx.recyclerview.widget.RecyclerView
import androidx.viewbinding.ViewBinding
import com.f0x1d.logfox.arch.adapter.BaseListAdapter
import com.f0x1d.logfox.arch.presentation.adapter.BaseListAdapter

abstract class BaseViewHolder<T, D : ViewBinding>(
protected val binding: D
Expand Down

This file was deleted.

Loading

0 comments on commit 2d98830

Please sign in to comment.