Skip to content

Commit

Permalink
[feat]: update v2.0.1
Browse files Browse the repository at this point in the history
* [fix]: small Compose performance improvements

* [fix]: clearing logs with logging paused

* [fix]: proper fix of clearing logs

* [feat]: search in crashes

* [fix]: select all feature

* [feat]: sorting crashes

* [feat]: disabling separate notification channels

* [feat]: open crashes page on startup

* [fix]: logic in sorting

* [build]: added release workflow
  • Loading branch information
F0x1d authored Jul 28, 2024
1 parent 034cf37 commit dc5074e
Show file tree
Hide file tree
Showing 39 changed files with 584 additions and 124 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
on:
workflow_dispatch:

push:
branches:
- 'master'

env:
KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
ALIAS: ${{ secrets.ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}

jobs:
build:
name: Build APK
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: oracle
cache: 'gradle'

- name: Checkout keystore repository
uses: actions/checkout@v4
with:
repository: ${{ secrets.KEYSTORE_GIT_REPOSITORY }}
token: ${{ secrets.KEYSTORE_ACCESS_TOKEN }}
path: app/keystore

- name: Build APK
run: bash ./gradlew assembleRelease --stacktrace --no-daemon

- name: Upload APK
uses: actions/upload-artifact@v4
with:
name: logfox-release
compression-level: 0
path: app/build/outputs/apk/release/app-release.apk
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
defaultConfig {
applicationId = logFoxPackageName

versionCode = 60
versionName = "2.0.0"
versionCode = 61
versionName = "2.0.1"
}
}

Expand Down
40 changes: 40 additions & 0 deletions app/src/main/kotlin/com/f0x1d/logfox/ui/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.os.bundleOf
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updatePadding
import androidx.navigation.NavController
import androidx.navigation.NavDestination
import androidx.navigation.fragment.NavHostFragment
Expand Down Expand Up @@ -70,6 +73,7 @@ class MainActivity: BaseViewModelActivity<MainViewModel, ActivityMainBinding>(),
barView?.setOnItemReselectedListener {
// Just do nothing
}
setupBarInsets()

navController.addOnDestinationChangedListener(this@MainActivity)

Expand All @@ -87,6 +91,10 @@ class MainActivity: BaseViewModelActivity<MainViewModel, ActivityMainBinding>(),

viewModel.askedNotificationsPermission = true
}

if (savedInstanceState == null && viewModel.openCrashesOnStartup) {
navController.navigate(Directions.crashes)
}
}

override fun onPostCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -169,6 +177,38 @@ class MainActivity: BaseViewModelActivity<MainViewModel, ActivityMainBinding>(),
}
}

private fun ActivityMainBinding.setupBarInsets() {
barView?.let { view ->
ViewCompat.setOnApplyWindowInsetsListener(view) { _, insets ->
if (isHorizontalOrientation) {
val statusBarInsets = insets.getInsets(WindowInsetsCompat.Type.statusBars())

view.updatePadding(
left = statusBarInsets.left,
top = statusBarInsets.top,
right = statusBarInsets.right,
bottom = statusBarInsets.bottom,
)
} else {
val navigationBarsInsets = insets.getInsets(WindowInsetsCompat.Type.navigationBars())
val imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime())

// I don't want to see it above keyboard
val imeBottomInset = (imeInsets.bottom - view.height).coerceAtLeast(0)

view.updatePadding(
left = navigationBarsInsets.left,
top = navigationBarsInsets.top,
right = navigationBarsInsets.right,
bottom = navigationBarsInsets.bottom + imeBottomInset,
)
}

insets
}
}
}

override fun onDestroy() {
super.onDestroy()
navController.removeOnDestinationChangedListener(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class MainViewModel @Inject constructor(
get() = appPreferences.askedNotificationsPermission
set(value) { appPreferences.askedNotificationsPermission = value }

val openCrashesOnStartup get() = appPreferences.openCrashesOnStartup

init {
load()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
}
}
}

dependenciesInfo {
// https://gitlab.com/IzzyOnDroid/repo/-/issues/569#note_1997934495
includeInApk = false
includeInBundle = false
}
}

dependencies { coreDependencies() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import androidx.annotation.ChecksSdkIntAtLeast
@get:ChecksSdkIntAtLeast(api = Q) val gesturesAvailable = SDK_INT >= Q
@get:ChecksSdkIntAtLeast(api = O) val contrastedNavBarAvailable = SDK_INT >= O

@get:ChecksSdkIntAtLeast(api = S) val notificationsDynamicColorAvailable = SDK_INT >= S
@get:ChecksSdkIntAtLeast(api = O) val notificationsChannelsAvailable = SDK_INT >= O
@get:ChecksSdkIntAtLeast(api = TIRAMISU) val shouldRequestNotificationsPermission = SDK_INT >= TIRAMISU
@get:ChecksSdkIntAtLeast(api = O) val startForegroundServiceAvailable = notificationsChannelsAvailable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.ViewCompositionStrategy
import com.f0x1d.logfox.arch.databinding.FragmentComposeBinding
import com.f0x1d.logfox.arch.ui.fragment.BaseFragment

Expand All @@ -18,8 +20,13 @@ abstract class BaseComposeFragment : BaseFragment<FragmentComposeBinding>() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

binding.composeView.setContent {
Content()
binding.composeView.apply {
consumeWindowInsets = false
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)

setContent {
this@BaseComposeFragment.Content()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.ViewCompositionStrategy
import com.f0x1d.logfox.arch.databinding.FragmentComposeBinding
import com.f0x1d.logfox.arch.ui.fragment.BaseViewModelFragment
import com.f0x1d.logfox.arch.ui.snackbar
Expand All @@ -25,6 +26,7 @@ abstract class BaseComposeViewModelFragment<T : BaseViewModel> : BaseViewModelFr

binding.composeView.apply {
consumeWindowInsets = false
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)

setContent {
this@BaseComposeViewModelFragment.Content()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,8 @@ class FileConverter {
@TypeConverter
fun fromFile(value: File) = value.absolutePath
}

data class AppCrashesCount(
val lastCrash: AppCrash,
val count: Int = 1,
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.f0x1d.logfox.database.entity.CrashType
import com.f0x1d.logfox.model.logline.LogLine
import com.f0x1d.logfox.model.preferences.ShowLogValues
import com.f0x1d.logfox.preferences.shared.base.BasePreferences
import com.f0x1d.logfox.preferences.shared.crashes.CrashesSort
import dagger.hilt.android.qualifiers.ApplicationContext
import java.util.Date
import javax.inject.Inject
Expand Down Expand Up @@ -50,6 +51,10 @@ class AppPreferences @Inject constructor(
set(value) { put("pref_time_format", value) }
val timeFormatFlow get() = flowSharedPreferences.getString("pref_time_format", TIME_FORMAT_DEFAULT).asFlow()

var openCrashesOnStartup
get() = get("pref_open_crashes_page_on_startup", false)
set(value) { put("pref_open_crashes_page_on_startup", value) }

var logsUpdateInterval
get() = get("pref_logs_update_interval", LOGS_UPDATE_INTERVAL_DEFAULT)
set(value) { put("pref_logs_update_interval", value) }
Expand Down Expand Up @@ -151,12 +156,30 @@ class AppPreferences @Inject constructor(
get() = get("pref_include_device_info_in_archives", true)
set(value) { put("pref_include_device_info_in_archives", value) }

var useSeparateNotificationsChannelsForCrashes
get() = get("pref_notifications_use_separate_channels", true)
set(value) { put("pref_notifications_use_separate_channels", value) }

var askedNotificationsPermission
get() = get("pref_asked_notifications_permission", false)
set(value) { put("pref_asked_notifications_permission", value) }

val showLogValues get() = cachedShowLogValues ?: updateCachedShowLogsValues()

val crashesSortType get() = flowSharedPreferences.getEnum(
key = "pref_crashes_sort_type",
defaultValue = CrashesSort.NEW,
)
val crashesSortReversedOrder get() = flowSharedPreferences.getBoolean(
key = "pref_crashes_sort_reversed_order",
defaultValue = true,
)

fun updateCrashesSortSettings(sortType: CrashesSort, sortInReversedOrder: Boolean) {
put("pref_crashes_sort_type", sortType.name)
put("pref_crashes_sort_reversed_order", sortInReversedOrder)
}

fun collectingFor(crashType: CrashType) = get(
key = "pref_collect_${crashType.readableName.lowercase()}",
defaultValue = true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.f0x1d.logfox.preferences.shared.crashes

import androidx.annotation.Keep
import androidx.annotation.StringRes
import com.f0x1d.logfox.database.entity.AppCrashesCount
import com.f0x1d.logfox.strings.Strings

@Keep
enum class CrashesSort(
@StringRes val titleRes: Int,
val sorter: (List<AppCrashesCount>) -> List<AppCrashesCount> = { it },
) {
NAME(
titleRes = Strings.sort_by_name,
sorter = { crashes ->
crashes.sortedBy { it.lastCrash.appName ?: it.lastCrash.packageName }
},
),
NEW(
titleRes = Strings.sort_by_new,
sorter = { crashes ->
crashes.sortedBy { it.lastCrash.dateAndTime }
},
),
COUNT(
titleRes = Strings.sort_by_count,
sorter = { crashes ->
crashes.sortedBy { it.count }
},
),
}
13 changes: 13 additions & 0 deletions core/core-ui/src/main/res/drawable/ic_sort.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:autoMirrored="true"
android:height="24dp"
android:tint="?colorControlNormal"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="24dp">

<path
android:fillColor="@android:color/white"
android:pathData="M3,18h6v-2L3,16v2zM3,6v2h18L21,6L3,6zM3,13h12v-2L3,11v2z" />

</vector>
Loading

0 comments on commit dc5074e

Please sign in to comment.