Skip to content

Commit

Permalink
[feat]: update v2.0.5
Browse files Browse the repository at this point in the history
* [fix]: not working exit button if logging is stuck

* [fix]: filters loglevel crash

* [fix]: monet setting not being applied to compose screens
  • Loading branch information
F0x1d authored Nov 15, 2024
1 parent 8a88c6f commit b20b073
Show file tree
Hide file tree
Showing 24 changed files with 148 additions and 109 deletions.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies {
implementation(projects.feature.setup)

implementation(libs.timber)
implementation(libs.gson)
implementation(libs.viewpump)
implementation(libs.coil)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.f0x1d.logfox.arch.di
package com.f0x1d.logfox.di

import com.f0x1d.logfox.arch.annotations.GsonSkip
import com.f0x1d.logfox.database.annotations.GsonSkip
import com.google.gson.ExclusionStrategy
import com.google.gson.FieldAttributes
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import dagger.Module
import dagger.Provides
Expand All @@ -16,7 +17,7 @@ object GsonModule {

@Provides
@Singleton
fun provideGson() = GsonBuilder()
fun provideGson(): Gson = GsonBuilder()
.addSerializationExclusionStrategy(
object : ExclusionStrategy {
override fun shouldSkipField(f: FieldAttributes) = f.getAnnotation(GsonSkip::class.java) != null
Expand Down
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 @@ -14,7 +14,7 @@ import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class BootReceiver: BroadcastReceiver() {
class BootReceiver : BroadcastReceiver() {

@Inject
lateinit var appPreferences: AppPreferences
Expand All @@ -26,7 +26,7 @@ class BootReceiver: BroadcastReceiver() {
}

if (context.hasPermissionToReadLogs) {
Intent(context, com.f0x1d.logfox.feature.logging.service.presentation.LoggingService::class.java).let {
Intent(context, LoggingService::class.java).let {
if (startForegroundServiceAvailable)
context.startForegroundService(it)
else
Expand Down
5 changes: 4 additions & 1 deletion core/arch/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ plugins {
android.namespace = "com.f0x1d.logfox.arch"

dependencies {
implementation(projects.core.ui)
implementation(projects.core.uiCompose)
implementation(projects.core.preferences)

implementation(libs.insetter)
implementation(libs.viewpump)
implementation(libs.gson)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import javax.inject.Qualifier

@Module
@InstallIn(SingletonComponent::class)
object DispatchersModule {
internal object DispatchersModule {

@MainDispatcher
@Provides
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.f0x1d.logfox.arch.di

import com.f0x1d.logfox.arch.presentation.ui.fragment.compose.DynamicColorAvailabilityProvider
import com.f0x1d.logfox.preferences.shared.AppPreferences
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
internal object DynamicColorAvailabilityProviderModule {

@Provides
@Singleton
fun provideDynamicColorAvailabilityProvider(
appPreferences: AppPreferences,
): DynamicColorAvailabilityProvider = object : DynamicColorAvailabilityProvider {
override fun isDynamicColorAvailable(): Boolean = appPreferences.monetEnabled
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import javax.inject.Qualifier

@Module
@InstallIn(SingletonComponent::class)
object UtilsModule {
internal object UtilsModule {

@NullString
@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,9 @@ abstract class BaseActivity<T : ViewBinding>: AppCompatActivity(), SimpleLifecyc
}

override fun attachBaseContext(newBase: Context) {
val entryPoint = EntryPointAccessors.fromApplication(
context = newBase,
entryPoint = ViewPumpEntryPoint::class.java,
)
val entryPoint = EntryPointAccessors.fromApplication<ViewPumpEntryPoint>(newBase)

super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase, entryPoint.viewPump()))
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase, entryPoint.viewPump))
}

protected fun snackbar(text: String) = binding.root.snackbar(text).apply {
Expand All @@ -65,6 +62,6 @@ abstract class BaseActivity<T : ViewBinding>: AppCompatActivity(), SimpleLifecyc
@EntryPoint
@InstallIn(SingletonComponent::class)
internal interface ViewPumpEntryPoint {
fun viewPump(): ViewPump
val viewPump: ViewPump
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,34 @@ import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy
import com.f0x1d.logfox.arch.databinding.FragmentComposeBinding
import com.f0x1d.logfox.arch.presentation.ui.fragment.BaseFragment
import com.f0x1d.logfox.ui.compose.theme.LogFoxTheme
import dagger.hilt.EntryPoint
import dagger.hilt.InstallIn
import dagger.hilt.android.EntryPointAccessors
import dagger.hilt.components.SingletonComponent

abstract class BaseComposeFragment : BaseFragment<FragmentComposeBinding>() {

private val dynamicColorAvailabilityProvider: DynamicColorAvailabilityProvider by lazy {
EntryPointAccessors
.fromApplication<BaseComposeFragmentEntryPoint>(requireContext())
.dynamicColorAvailabilityProvider
}

override fun inflateBinding(
inflater: LayoutInflater,
container: ViewGroup?,
) = FragmentComposeBinding.inflate(inflater, container, false)

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.composeView.setup { Content() }
binding.composeView.setup {
LogFoxTheme(
dynamicColor = dynamicColorAvailabilityProvider.isDynamicColorAvailable(),
) {
Content()
}
}
}

@Composable
Expand All @@ -32,4 +49,10 @@ abstract class BaseComposeFragment : BaseFragment<FragmentComposeBinding>() {

setContent(content)
}

@EntryPoint
@InstallIn(SingletonComponent::class)
internal interface BaseComposeFragmentEntryPoint {
val dynamicColorAvailabilityProvider: DynamicColorAvailabilityProvider
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.f0x1d.logfox.arch.presentation.ui.fragment.compose

interface DynamicColorAvailabilityProvider {
fun isDynamicColorAvailable(): Boolean
}
2 changes: 0 additions & 2 deletions core/database/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ android {
}

dependencies {
implementation(projects.core.arch)

compileOnly(libs.androidx.compose.runtime)

implementation(libs.androidx.room)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.f0x1d.logfox.arch.annotations
package com.f0x1d.logfox.database.annotations

@Target(AnnotationTarget.FIELD)
annotation class GsonSkip
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import androidx.room.PrimaryKey
import androidx.room.Query
import androidx.room.TypeConverter
import androidx.room.Update
import com.f0x1d.logfox.arch.annotations.GsonSkip
import com.f0x1d.logfox.database.annotations.GsonSkip
import com.f0x1d.logfox.model.Identifiable
import com.f0x1d.logfox.model.logline.LogLevel
import kotlinx.coroutines.flow.Flow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import dagger.hilt.InstallIn
import dagger.hilt.android.EntryPointAccessors
import dagger.hilt.components.SingletonComponent

val Context.dateTimeFormatter get() = EntryPointAccessors.fromApplication(
context = this,
entryPoint = DateTimeFormatterEntryPoint::class.java,
).dateTimeFormatter()
val Context.dateTimeFormatter get() = EntryPointAccessors
.fromApplication<DateTimeFormatterEntryPoint>(this)
.dateTimeFormatter

@EntryPoint
@InstallIn(SingletonComponent::class)
private interface DateTimeFormatterEntryPoint {
fun dateTimeFormatter(): DateTimeFormatter
val dateTimeFormatter: DateTimeFormatter
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import dagger.hilt.InstallIn
import dagger.hilt.android.EntryPointAccessors
import dagger.hilt.components.SingletonComponent

val Context.appPreferences get() = EntryPointAccessors.fromApplication(
context = this,
entryPoint = AppPreferencesEntryPoint::class.java,
).appPreferences()
val Context.appPreferences get() = EntryPointAccessors
.fromApplication<AppPreferencesEntryPoint>(this)
.appPreferences

@EntryPoint
@InstallIn(SingletonComponent::class)
private interface AppPreferencesEntryPoint {
fun appPreferences(): AppPreferences
val appPreferences: AppPreferences
}
1 change: 0 additions & 1 deletion core/ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {
android.namespace = "com.f0x1d.logfox.ui"

dependencies {
implementation(projects.core.arch)
implementation(projects.core.preferences)

implementation(libs.insetter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.f0x1d.logfox.ui.view

import android.view.LayoutInflater
import android.view.inputmethod.InputMethodManager
import androidx.core.content.getSystemService
import androidx.preference.Preference
import com.f0x1d.logfox.arch.inputMethodManager
import com.f0x1d.logfox.strings.Strings
import com.f0x1d.logfox.ui.databinding.DialogTextBinding
import com.google.android.material.dialog.MaterialAlertDialogBuilder
Expand Down Expand Up @@ -35,7 +35,7 @@ fun Preference.setupAsEditTextPreference(
setSelection(text?.length ?: 0)

postDelayed({
context.inputMethodManager.showSoftInput(
context.getSystemService<InputMethodManager>()?.showSoftInput(
this,
InputMethodManager.SHOW_IMPLICIT
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import com.f0x1d.logfox.feature.apps.picker.AppsPickerResultHandler
import com.f0x1d.logfox.feature.apps.picker.presentation.AppsPickerState
import com.f0x1d.logfox.feature.apps.picker.presentation.AppsPickerViewModel
import com.f0x1d.logfox.feature.apps.picker.presentation.ui.compose.AppsPickerScreenContent
import com.f0x1d.logfox.ui.compose.theme.LogFoxTheme
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.collections.immutable.toImmutableSet
import kotlinx.coroutines.flow.Flow
Expand Down Expand Up @@ -57,14 +56,12 @@ class AppsPickerFragment : BaseComposeFragment() {

@Composable
override fun Content() {
LogFoxTheme {
val state by uiState.collectAsState(initial = viewModel.currentState)
val state by uiState.collectAsState(initial = viewModel.currentState)

AppsPickerScreenContent(
state = state,
listener = listener,
)
}
AppsPickerScreenContent(
state = state,
listener = listener,
)
}

@SuppressLint("RestrictedApi")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.f0x1d.logfox.feature.filters.edit.presentation

import com.f0x1d.logfox.database.entity.UserFilter
import com.f0x1d.logfox.model.logline.LogLevel

data class EditFilterState(
val filter: UserFilter? = null,
val including: Boolean = true,
val enabledLogLevels: List<Boolean> = emptyList(),
val enabledLogLevels: List<Boolean> = List(LogLevel.entries.size) { false },
)
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class EditFilterViewModel @Inject constructor(
.collect { filter ->
if (filter == null) return@collect

val enabledLogLevels = List(7) { false }.toMutableList()
val enabledLogLevels = List(LogLevel.entries.size) { false }.toMutableList()
val allowedLevels = filter.allowedLevels.map { it.ordinal }
for (i in 0 until enabledLogLevels.size) {
enabledLogLevels[i] = allowedLevels.contains(i)
Expand Down
Loading

0 comments on commit b20b073

Please sign in to comment.