Skip to content

Commit

Permalink
[feat]: update v2.0.2
Browse files Browse the repository at this point in the history
* [feat]: disabling word wrap for log in details

* [feat]: search in crash logs + small refactor

* [feat]: moved apps chooser to another module and refactored to compose

* [feat]: crashes blacklist

* [build]: renamed modules

* [fix]: opening crashes by default

* [feat]: blacklisting in crash details

* [feat]: search text in crash log

* [feat]: disabling monet
  • Loading branch information
F0x1d authored Aug 19, 2024
1 parent dc5074e commit 9fa3549
Show file tree
Hide file tree
Showing 397 changed files with 2,038 additions and 1,085 deletions.
31 changes: 9 additions & 22 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,21 @@ android {
defaultConfig {
applicationId = logFoxPackageName

versionCode = 61
versionName = "2.0.1"
versionCode = 62
versionName = "2.0.2"
}
}

dependencies {
implementation(project(":feature:feature-crashes"))
implementation(project(":feature:feature-crashes-core"))
implementation(project(":feature:feature-filters"))
implementation(project(":feature:feature-filters-core"))
implementation(project(":feature:feature-logging"))
implementation(project(":feature:feature-logging-core"))
implementation(project(":feature:feature-recordings"))
implementation(project(":feature:feature-recordings-core"))
implementation(project(":feature:feature-settings"))
implementation(project(":feature:feature-setup"))
implementation(projects.feature.crashes)
implementation(projects.feature.filters)
implementation(projects.feature.logging)
implementation(projects.feature.recordings)
implementation(projects.feature.settings)
implementation(projects.feature.setup)

implementation(libs.insetter)
implementation(libs.bundles.shizuku)
implementation(libs.viewpump)
implementation(libs.gson)

implementation(libs.glide)
ksp(libs.glide.compiler)

implementation(libs.androidx.room)
implementation(libs.androidx.room.runtime)
ksp(libs.androidx.room.compiler)
implementation(libs.coil)

implementation(libs.bundles.androidx)
implementation(libs.material)
Expand Down
23 changes: 18 additions & 5 deletions app/src/main/kotlin/com/f0x1d/logfox/LogFoxApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,36 @@ import android.app.Application
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.app.NotificationChannelCompat
import androidx.core.app.NotificationManagerCompat
import com.f0x1d.logfox.context.LOGGING_STATUS_CHANNEL_ID
import com.f0x1d.logfox.context.RECORDING_STATUS_CHANNEL_ID
import com.f0x1d.logfox.context.notificationManagerCompat
import coil.ImageLoader
import coil.ImageLoaderFactory
import com.f0x1d.logfox.arch.LOGGING_STATUS_CHANNEL_ID
import com.f0x1d.logfox.arch.RECORDING_STATUS_CHANNEL_ID
import com.f0x1d.logfox.arch.notificationManagerCompat
import com.f0x1d.logfox.preferences.shared.AppPreferences
import com.f0x1d.logfox.strings.Strings
import com.google.android.material.color.DynamicColors
import com.google.android.material.color.DynamicColorsOptions
import dagger.hilt.android.HiltAndroidApp
import javax.inject.Inject

@HiltAndroidApp
class LogFoxApp: Application() {
class LogFoxApp: Application(), ImageLoaderFactory {

@Inject
lateinit var appPreferences: AppPreferences

@Inject
lateinit var imageLoader: ImageLoader

override fun onCreate() {
super.onCreate()
AppCompatDelegate.setDefaultNightMode(appPreferences.nightTheme)
DynamicColors.applyToActivitiesIfAvailable(this)
DynamicColors.applyToActivitiesIfAvailable(
this,
DynamicColorsOptions.Builder()
.setPrecondition { _, _ -> appPreferences.monetEnabled }
.build()
)

notificationManagerCompat.apply {
val loggingStatusChannel = NotificationChannelCompat.Builder(
Expand Down Expand Up @@ -51,4 +62,6 @@ class LogFoxApp: Application() {
)
}
}

override fun newImageLoader(): ImageLoader = imageLoader
}
49 changes: 49 additions & 0 deletions app/src/main/kotlin/com/f0x1d/logfox/coil/AppIconFetcher.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.f0x1d.logfox.coil

import android.content.Context
import coil.ImageLoader
import coil.decode.DataSource
import coil.fetch.DrawableResult
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 dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.withContext
import javax.inject.Inject
import javax.inject.Singleton

class AppIconFetcher(
private val context: Context,
private val app: InstalledApp,
private val ioDispatcher: CoroutineDispatcher,
) : Fetcher {

override suspend fun fetch(): FetchResult = withContext(ioDispatcher) {
val appDrawable = context.packageManager.getApplicationIcon(app.packageName)

DrawableResult(
drawable = appDrawable,
isSampled = true,
dataSource = DataSource.DISK,
)
}

@Singleton
class Factory @Inject constructor(
@ApplicationContext private val context: Context,
@IODispatcher private val ioDispatcher: CoroutineDispatcher,
) : Fetcher.Factory<InstalledApp> {
override fun create(
data: InstalledApp,
options: Options,
imageLoader: ImageLoader,
): Fetcher = AppIconFetcher(
context = context,
app = data,
ioDispatcher = ioDispatcher,
)
}
}
27 changes: 27 additions & 0 deletions app/src/main/kotlin/com/f0x1d/logfox/di/CoilModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.f0x1d.logfox.di

import android.content.Context
import coil.ImageLoader
import com.f0x1d.logfox.coil.AppIconFetcher
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object CoilModule {

@Provides
@Singleton
fun provideImageLoader(
@ApplicationContext context: Context,
appIconFetcherFactory: AppIconFetcher.Factory,
): ImageLoader = ImageLoader.Builder(context)
.components {
add(appIconFetcherFactory)
}
.build()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.f0x1d.logfox.di.logs
import android.app.PendingIntent
import android.content.Context
import com.f0x1d.feature.logging.service.MainActivityPendingIntentProvider
import com.f0x1d.logfox.intents.makeActivityPendingIntent
import com.f0x1d.logfox.arch.makeActivityPendingIntent
import com.f0x1d.logfox.ui.activity.MainActivity
import dagger.Binds
import dagger.Module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.f0x1d.logfox.di.settings

import android.content.Context
import com.f0x1d.feature.logging.service.LoggingService
import com.f0x1d.logfox.context.sendService
import com.f0x1d.logfox.arch.sendService
import com.f0x1d.logfox.feature.settings.LoggingServiceDelegate
import dagger.Binds
import dagger.Module
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 @@ -4,9 +4,9 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.f0x1d.feature.logging.service.LoggingService
import com.f0x1d.logfox.arch.hasPermissionToReadLogs
import com.f0x1d.logfox.arch.startForegroundServiceAvailable
import com.f0x1d.logfox.context.hasPermissionToReadLogs
import com.f0x1d.logfox.context.toast
import com.f0x1d.logfox.arch.toast
import com.f0x1d.logfox.preferences.shared.AppPreferences
import com.f0x1d.logfox.strings.Strings
import com.f0x1d.logfox.terminals.ShizukuTerminal
Expand Down
49 changes: 33 additions & 16 deletions app/src/main/kotlin/com/f0x1d/logfox/ui/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,32 @@ import androidx.transition.TransitionManager
import com.f0x1d.logfox.R
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.context.hasNotificationsPermission
import com.f0x1d.logfox.context.isHorizontalOrientation
import com.f0x1d.logfox.arch.viewmodel.Event
import com.f0x1d.logfox.databinding.ActivityMainBinding
import com.f0x1d.logfox.model.event.Event
import com.f0x1d.logfox.navigation.Directions
import com.f0x1d.logfox.navigation.NavGraphs
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 {

override val viewModel by viewModels<MainViewModel>()
private lateinit var navController: NavController

private val navController by lazy {
val navHostFragment = supportFragmentManager.findFragmentById(
R.id.nav_host_fragment_content_main,
) as NavHostFragment

navHostFragment.navController
}

private val requestNotificationPermissionLauncher = registerForActivityResult(
ActivityResultContracts.RequestPermission(),
Expand All @@ -64,19 +73,13 @@ class MainActivity: BaseViewModelActivity<MainViewModel, ActivityMainBinding>(),

@SuppressLint("InlinedApi")
override fun ActivityMainBinding.onCreate(savedInstanceState: Bundle?) {
val navHostFragment = supportFragmentManager.findFragmentById(
R.id.nav_host_fragment_content_main,
) as NavHostFragment
navController = navHostFragment.navController
setupNavigation()

barView?.setupWithNavController(navController)
barView?.setOnItemReselectedListener {
// Just do nothing
}
setupBarInsets()

navController.addOnDestinationChangedListener(this@MainActivity)

if (!hasNotificationsPermission() && !viewModel.askedNotificationsPermission) {
MaterialAlertDialogBuilder(this@MainActivity)
.setIcon(Icons.ic_dialog_notification_important)
Expand All @@ -91,10 +94,22 @@ class MainActivity: BaseViewModelActivity<MainViewModel, ActivityMainBinding>(),

viewModel.askedNotificationsPermission = true
}
}

if (savedInstanceState == null && viewModel.openCrashesOnStartup) {
navController.navigate(Directions.crashes)
private fun ActivityMainBinding.setupNavigation() {
navController.graph = navController.navInflater.inflate(NavGraphs.nav_graph).apply {
setStartDestination(
startDestId = if (viewModel.openCrashesOnStartup) {
Directions.crashes
} else {
Directions.logs
},
)
}

barView?.setupWithNavController(navController)

navController.addOnDestinationChangedListener(this@MainActivity)
}

override fun onPostCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -125,8 +140,10 @@ class MainActivity: BaseViewModelActivity<MainViewModel, ActivityMainBinding>(),
}

override fun onEvent(event: Event) {
when (event.type) {
MainViewModel.EVENT_TYPE_SETUP -> navController.navigate(Directions.action_global_setupFragment)
super.onEvent(event)

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

Expand All @@ -136,7 +153,7 @@ class MainActivity: BaseViewModelActivity<MainViewModel, ActivityMainBinding>(),
Directions.logsExtendedCopyFragment -> false
Directions.filtersFragment -> false
Directions.editFilterFragment -> false
Directions.chooseAppFragment -> false
Directions.appsPickerFragment -> false
Directions.appCrashesFragment -> false
Directions.crashDetailsFragment -> false

Expand Down
11 changes: 5 additions & 6 deletions app/src/main/kotlin/com/f0x1d/logfox/viewmodel/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package com.f0x1d.logfox.viewmodel
import android.app.Application
import android.content.Intent
import com.f0x1d.feature.logging.service.LoggingService
import com.f0x1d.logfox.arch.hasPermissionToReadLogs
import com.f0x1d.logfox.arch.startForegroundServiceAvailable
import com.f0x1d.logfox.arch.viewmodel.BaseViewModel
import com.f0x1d.logfox.context.hasPermissionToReadLogs
import com.f0x1d.logfox.arch.viewmodel.Event
import com.f0x1d.logfox.preferences.shared.AppPreferences
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
Expand All @@ -16,10 +17,6 @@ class MainViewModel @Inject constructor(
application: Application,
): BaseViewModel(application) {

companion object {
const val EVENT_TYPE_SETUP = "setup"
}

var askedNotificationsPermission
get() = appPreferences.askedNotificationsPermission
set(value) { appPreferences.askedNotificationsPermission = value }
Expand All @@ -39,7 +36,9 @@ class MainViewModel @Inject constructor(
ctx.startService(it)
}
} else {
sendEvent(EVENT_TYPE_SETUP)
sendEvent(OpenSetup)
}
}
}

data object OpenSetup : Event
1 change: 0 additions & 1 deletion app/src/main/res/layout-land/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/navigation_rail"
app:layout_constraintBottom_toBottomOf="parent"
app:navGraph="@navigation/nav_graph"
tools:layout="@layout/fragment_logs" />

<com.f0x1d.logfox.ui.view.CustomApplyInsetsNavigationRailView
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout-land/activity_main_no_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/navigation_rail"
app:layout_constraintBottom_toBottomOf="parent"
app:navGraph="@navigation/nav_graph"
tools:layout="@layout/fragment_logs" />

<com.f0x1d.logfox.ui.view.CustomApplyInsetsNavigationRailView
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@id/bottom_navigation"
app:navGraph="@navigation/nav_graph"
tools:layout="@layout/fragment_logs" />

<com.google.android.material.bottomnavigation.BottomNavigationView
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_main_no_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@id/bottom_navigation"
app:navGraph="@navigation/nav_graph"
tools:layout="@layout/fragment_logs" />

<com.google.android.material.bottomnavigation.BottomNavigationView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.android.build.api.dsl.CommonExtension
import com.android.build.api.dsl.LibraryExtension
import extensions.bundle
import extensions.implementation
import extensions.library
import extensions.pluginId
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand All @@ -24,6 +25,7 @@ class AndroidComposeConventionPlugin : Plugin<Project> {
}

dependencies {
implementation(library("kotlinx-immutable-collections"))
implementation(bundle("androidx-compose"))
}
}
Expand Down
Loading

0 comments on commit 9fa3549

Please sign in to comment.