Skip to content
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

[enhancement] Fix Lint warnings #410

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
root = true


# noinspection EditorConfigKeyCorrectness
[*]

indent_style = space
Expand Down
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//file:noinspection GroovyConstructorNamedArguments
import org.apache.tools.ant.taskdefs.condition.Os

plugins {
Expand All @@ -11,7 +12,7 @@ apply plugin: 'kotlin-parcelize'
apply plugin: "de.mannodermaus.android-junit5"

android {
compileSdkVersion 33
compileSdk 33

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
Expand Down Expand Up @@ -187,7 +188,7 @@ dependencies {
implementation 'com.airbnb.android:lottie:6.1.0'
}

task installGitHook(type: Copy) {
tasks.register('installGitHook', Copy) {
def suffix = "linux"
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
suffix = "windows"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ import javax.inject.Singleton

@Singleton
class PermissionsHelper @Inject constructor(private val appContext: Context) {
val permissionResultFlow = MutableSharedFlow<Boolean>()
private val permissionResultFlow = MutableSharedFlow<Boolean>()
private var writePermLauncher: ActivityResultLauncher<String>? = null
private var writePermUsingSettingsLauncher: ActivityResultLauncher<String>? =
null
private var writePermLauncher_R: ActivityResultLauncher<String>? = null
private var writePermLauncherR: ActivityResultLauncher<String>? = null

fun registerActivity(activity: AppCompatActivity) {
writePermLauncher = buildWritePermLauncher(activity)
writePermUsingSettingsLauncher =
buildWritePermsUsingSettingsLauncher(activity)
writePermLauncher_R = buildWritePermLauncher_R(activity)
writePermLauncherR = buildWritePermLauncherR(activity)
}

fun isWritePermissionGranted(): Boolean {
Expand All @@ -56,7 +56,7 @@ class PermissionsHelper @Inject constructor(private val appContext: Context) {
) {
val packageUri = "package:" + BuildConfig.APPLICATION_ID
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
writePermLauncher_R!!.launch(packageUri)
writePermLauncherR!!.launch(packageUri)
} else {
val rationale =
fragment?.shouldShowRequestPermissionRationale(
Expand Down Expand Up @@ -120,7 +120,7 @@ class PermissionsHelper @Inject constructor(private val appContext: Context) {
}
}

private fun buildWritePermLauncher_R(
private fun buildWritePermLauncherR(
activity: AppCompatActivity
) =
activity.registerForActivityResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import kotlinx.coroutines.withContext
import dev.arkbuilders.arklib.data.stats.StatsEvent
import dev.arkbuilders.arklib.user.tags.Tag

class AggregatedStatsStorage(val shards: List<StatsStorage>) : StatsStorage {
class AggregatedStatsStorage(private val shards: List<StatsStorage>) : StatsStorage {

override suspend fun init() = withContext(Dispatchers.IO) {
shards.map { launch { it.init() } }.joinAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class PlainStatsStorage(
private val index: RootIndex,
private val preferences: Preferences,
private val tagStorage: RootTagsStorage,
private val statsFlow: SharedFlow<StatsEvent>
statsFlow: SharedFlow<StatsEvent>
kirillt marked this conversation as resolved.
Show resolved Hide resolved
) : StatsStorage {

private val root = index.path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class StatsStorageRepo(
}
}

suspend fun provide(
private suspend fun provide(
root: RootIndex,
tagsStorage: RootTagsStorage
): PlainStatsStorage =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private const val FLUSH_INTERVAL = 10_000L

abstract class StatsCategoryStorage<out T>(
val root: Path,
val scope: CoroutineScope
private val scope: CoroutineScope
) {
abstract val fileName: String
private val flushFlow = MutableSharedFlow<Unit>().also { flow ->
Expand All @@ -36,7 +36,7 @@ abstract class StatsCategoryStorage<out T>(
abstract fun provideData(): T
protected abstract fun flush()

fun locateStorage() = root.arkFolder().arkStats().resolve(fileName)
fun locateStorage(): Path? = root.arkFolder().arkStats().resolve(fileName)

protected fun requestFlush() = scope.launch {
flushFlow.emit(Unit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import kotlin.io.path.writeText

class TagLabeledNStorage(
val index: ResourceIndex,
val tagsStorage: TagStorage,
private val tagsStorage: TagStorage,
root: Path,
scope: CoroutineScope
) : StatsCategoryStorage<Map<Tag, Int>>(root, scope) {
Expand All @@ -26,7 +26,7 @@ class TagLabeledNStorage(

override suspend fun init() {
val storage = locateStorage()
if (storage.exists()) {
if (storage?.exists() == true) {
val json = Json.decodeFromStream<JsonTagLabeledN>(storage.inputStream())
tagLabeledAmount.putAll(json.data)
} else {
Expand Down Expand Up @@ -64,7 +64,7 @@ class TagLabeledNStorage(

override fun flush() {
val data = Json.encodeToString(JsonTagLabeledN(tagLabeledAmount))
locateStorage().writeText(data)
locateStorage()?.writeText(data)
Timber.i("flushed with $tagLabeledAmount")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TagLabeledTSStorage(

override fun flush() {
val data = Json.encodeToString(JsonTagLabeledTS(tagLabeledTS))
locateStorage().writeText(data)
locateStorage()?.writeText(data)
Timber.i("flushed with $tagLabeledTS")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TagQueriedNStorage(

override fun flush() {
val data = Json.encodeToString(JsonTagQueriedN(tagQueriedN))
locateStorage().writeText(data)
locateStorage()?.writeText(data)
Timber.i("flushed with $tagQueriedN")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ class TagQueriedTSStorage(

override suspend fun init() {
val storage = locateStorage()
if (storage.notExists()) return
val json = Json.decodeFromStream<JsonTagQueriedTS>(storage.inputStream())
tagQueriedTS.putAll(json.data)
if (storage?.notExists() == true) return
val json = storage?.let {
Json.decodeFromStream<JsonTagQueriedTS>(it.inputStream())
}
json?.let { tagQueriedTS.putAll(it.data) }
Timber.i("initialized with $tagQueriedTS")
}

Expand All @@ -43,7 +45,7 @@ class TagQueriedTSStorage(

override fun flush() {
val data = Json.encodeToString(JsonTagQueriedTS(tagQueriedTS))
locateStorage().writeText(data)
locateStorage()?.writeText(data)
Timber.i("flushed with $tagQueriedTS")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class RootPickerDialogFragment : ArkFilePickerFragment() {
@Inject
lateinit var foldersRepo: FoldersRepo

var rootNotFavorite = false
private var rootNotFavorite = false

override fun onAttach(context: Context) {
App.instance.appComponent.inject(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sealed class TagsSortSideEffect {
}

class TagsSortViewModel(
private val selectorNotEdit: Boolean,
selectorNotEdit: Boolean,
private val preferences: Preferences
) : ViewModel(), ContainerHost<TagsSortState, TagsSortSideEffect> {
override val container: Container<TagsSortState, TagsSortSideEffect> =
Expand Down
Loading