Skip to content

Commit

Permalink
updated dependencies
Browse files Browse the repository at this point in the history
formatted code
  • Loading branch information
stefanosiano committed Sep 11, 2024
1 parent 4b07db3 commit f0e09b1
Show file tree
Hide file tree
Showing 17 changed files with 125 additions and 63 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ allprojects {

detekt {
toolVersion = Deps.detektPluginVersion
config = files("config/detekt/detekt.yml")
config.from("config/detekt/detekt.yml")
buildUponDefaultConfig = true
}

Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ repositories {
}

dependencies {
implementation("com.android.tools.build:gradle:7.3.1")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0")
implementation("com.android.tools.build:gradle:8.4.2")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.0")
}
8 changes: 4 additions & 4 deletions buildSrc/src/main/java/Deps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ object Deps {
const val kotlinCoroutinesAndroid = "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"

// Android
const val appCompat = "androidx.appcompat:appcompat:1.7.0"
const val appCompat = "androidx.appcompat:appcompat:1.5.1"
const val fragmentKtx = "androidx.fragment:fragment-ktx:1.5.5"
const val roomRuntime = "androidx.room:room-runtime:$roomVersion"
const val roomCommon = "androidx.room:room-common:$roomVersion"
const val roomCompiler = "androidx.room:room-compiler:$roomVersion"
const val roomKtx = "androidx.room:room-ktx:$roomVersion"
const val activityKtx = "androidx.activity:activity-ktx:1.9.0"
const val activityKtx = "androidx.activity:activity-ktx:1.6.1"
const val recyclerView = "androidx.recyclerview:recyclerview:1.3.2"
const val material = "com.google.android.material:material:1.12.0"
const val material = "com.google.android.material:material:1.7.0"
const val lifecycleExtensions = "androidx.lifecycle:lifecycle-extensions:2.2.0"
const val documentFile = "androidx.documentfile:documentfile:1.0.1"
const val pagingRuntimeKtx = "androidx.paging:paging-runtime-ktx:3.3.0"
const val pagingRuntimeKtx = "androidx.paging:paging-runtime-ktx:3.1.1"

// Tests
const val androidJUnitRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
6 changes: 6 additions & 0 deletions config/detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,10 @@ formatting:
NoUnusedImports:
active: true
autoCorrect: true
Wrapping:
active: true
autoCorrect: true
PackageName:
active: false


6 changes: 5 additions & 1 deletion powerfulsama/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ android {
}
}

kotlin {
jvmToolchain(17)
}

dependencies {
implementation(Deps.appCompat)
implementation(Deps.kotlinStdLib)
Expand Down Expand Up @@ -67,7 +71,7 @@ apply("${rootProject.projectDir}/sonatype-publish.gradle")

detekt {
toolVersion = Deps.detektPluginVersion
config = files("$rootDir/config/detekt/detekt.yml")
config.from("$rootDir/config/detekt/detekt.yml")
// allRules = true
buildUponDefaultConfig = true
autoCorrect = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ suspend inline fun delayUntil(millis: Long = 100, timeout: Long = 6000, crossinl
}
var passed = 0L
while (!f() && (timeout < 0 || passed < timeout)) {
delay(millis); passed += millis
delay(millis)
passed += millis
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@ open class SamaRecyclerView : RecyclerView {
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) :
super(context, attrs, defStyle) {

val attrSet = context.theme
.obtainStyledAttributes(attrs, R.styleable.SamaRecyclerView, defStyle, 0)
columns = attrSet.getInt(R.styleable.SamaRecyclerView_srvColumns, columns)
horizontal = attrSet.getBoolean(R.styleable.SamaRecyclerView_srvHorizontal, horizontal)
autoDetach = attrSet.getBoolean(R.styleable.SamaRecyclerView_srvAutoDetach, autoDetach)
inconsistencyWorkaround = attrSet.getBoolean(
R.styleable.SamaRecyclerView_srvInconsistencyWorkaround,
inconsistencyWorkaround
)
disableAdapterAutoStop = attrSet.getBoolean(
R.styleable.SamaRecyclerView_srvDisableAdapterAutoStop,
disableAdapterAutoStop
)
disablePredictiveAnimation = attrSet.getBoolean(
R.styleable.SamaRecyclerView_srvDisablePredictiveAnimation,
disablePredictiveAnimation
)
attrSet.recycle()
resetLayoutManager()
}
val attrSet = context.theme
.obtainStyledAttributes(attrs, R.styleable.SamaRecyclerView, defStyle, 0)
columns = attrSet.getInt(R.styleable.SamaRecyclerView_srvColumns, columns)
horizontal = attrSet.getBoolean(R.styleable.SamaRecyclerView_srvHorizontal, horizontal)
autoDetach = attrSet.getBoolean(R.styleable.SamaRecyclerView_srvAutoDetach, autoDetach)
inconsistencyWorkaround = attrSet.getBoolean(
R.styleable.SamaRecyclerView_srvInconsistencyWorkaround,
inconsistencyWorkaround
)
disableAdapterAutoStop = attrSet.getBoolean(
R.styleable.SamaRecyclerView_srvDisableAdapterAutoStop,
disableAdapterAutoStop
)
disablePredictiveAnimation = attrSet.getBoolean(
R.styleable.SamaRecyclerView_srvDisablePredictiveAnimation,
disablePredictiveAnimation
)
attrSet.recycle()
resetLayoutManager()
}

override fun onAttachedToWindow() {
super.onAttachedToWindow()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ open class SamaSearchView : SearchView, CoroutineScope {

constructor(context: Context) : this(context, null)
constructor(context: Context, attrs: AttributeSet?) :
this(context, attrs, R.attr.searchViewStyle)
this(context, attrs, androidx.appcompat.R.attr.searchViewStyle)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) :
super(context, attrs, defStyleAttr) {
val attrSet = context.theme
.obtainStyledAttributes(attrs, R.styleable.SamaSearchView, defStyleAttr, 0)
clearFocusOnSubmit = attrSet
.getBoolean(R.styleable.SamaSearchView_ssvClearFocusOnSubmit, clearFocusOnSubmit)
millis = attrSet.getInt(R.styleable.SamaSearchView_ssvMillis, 0).toLong()
mSuggestionLayout = attrSet.getInt(R.styleable.SamaSearchView_ssvSuggestionLayout, -1)
val query = attrSet.getString(R.styleable.SamaSearchView_ssvQuery) ?: ""
attrSet.recycle()
setQuery(query, true)
}
val attrSet = context.theme
.obtainStyledAttributes(attrs, R.styleable.SamaSearchView, defStyleAttr, 0)
clearFocusOnSubmit = attrSet
.getBoolean(R.styleable.SamaSearchView_ssvClearFocusOnSubmit, clearFocusOnSubmit)
millis = attrSet.getInt(R.styleable.SamaSearchView_ssvMillis, 0).toLong()
mSuggestionLayout = attrSet.getInt(R.styleable.SamaSearchView_ssvSuggestionLayout, -1)
val query = attrSet.getString(R.styleable.SamaSearchView_ssvQuery) ?: ""
attrSet.recycle()
setQuery(query, true)
}

/** Call the [addOnQueryTextListener]. */
override fun setOnQueryTextListener(listener: OnQueryTextListener?) =
Expand Down Expand Up @@ -133,10 +133,13 @@ open class SamaSearchView : SearchView, CoroutineScope {
mSuggestionsAdapter = mSuggestionsAdapter ?: ArrayAdapter(context, mSuggestionLayout)
mSuggestionsAdapter?.clear()
suggestions?.let { mSuggestionsAdapter?.addAll(it) }
val searchAutoComplete = findViewById<AutoCompleteTextView>(R.id.search_src_text)
val searchAutoComplete = findViewById<AutoCompleteTextView>(androidx.appcompat.R.id.search_src_text)

searchAutoComplete.setOnItemClickListener { _, _, position, _ ->
mSuggestionsAdapter?.getItem(position)?.let { logVerbose("Clicked on $it"); f(it) }
mSuggestionsAdapter?.getItem(position)?.let {
logVerbose("Clicked on $it")
f(it)
}
}
post { searchAutoComplete.setAdapter(mSuggestionsAdapter) }
}
Expand All @@ -152,7 +155,7 @@ open class SamaSearchView : SearchView, CoroutineScope {
.map { mSuggestionsAdapter?.getItem(it) }
mSuggestionsAdapter = ArrayAdapter(context, mSuggestionLayout)
mSuggestionsAdapter?.addAll(oldItems)
val searchAutoComplete = findViewById<AutoCompleteTextView>(R.id.search_src_text)
val searchAutoComplete = findViewById<AutoCompleteTextView>(androidx.appcompat.R.id.search_src_text)
post { searchAutoComplete.setAdapter(mSuggestionsAdapter) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ open class SamaSpinner : AppCompatSpinner {
fun init(spinnerLayoutId: Int) {
val temp = ArrayList<String>()
val old = getSpnKey()
(0 until (arrayAdapter?.count ?: 0)).forEach { i ->
for (i in 0 until (arrayAdapter?.count ?: 0)) {
arrayAdapter?.getItem(i)?.let { temp.add(it) }
}
post {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,15 @@ class SamaObserverImpl : SamaObserver {
}
)
// sets the function to call when using an observable and runs it now
observables.add(SamaInnerObservable(o, o.onPropertyChanged { helper.onStart = f; f() }))
observables.add(
SamaInnerObservable(
o,
o.onPropertyChanged {
helper.onStart = f
f()
}
)
)
}
helper.onStart = f
f()
Expand All @@ -438,7 +446,10 @@ class SamaObserverImpl : SamaObserver {
if (obs.isNotEmpty()) delay(50L)
if (isPaused) return@launch
if (!isActive) return@launch
o.toList().let { logVerbose(it.toString()); helper.f?.invoke(it) }
o.toList().let {
logVerbose(it.toString())
helper.f?.invoke(it)
}
helper.onStart = null
}
}
Expand All @@ -448,12 +459,18 @@ class SamaObserverImpl : SamaObserver {
obs.map {
SamaInnerObservable(
it,
it.onPropertyChanged { helper.onStart = f; f() }
it.onPropertyChanged {
helper.onStart = f
f()
}
)
}
)

val c = o.onAnyChange { helper.onStart = f; f() }
val c = o.onAnyChange {
helper.onStart = f
f()
}
listObservables.add(
SamaInnerListObservable(
o as ObservableList<Any>,
Expand Down Expand Up @@ -577,7 +594,10 @@ class SamaObserverImpl : SamaObserver {
}
)
}
val observer: Observer<Any?> = Observer { helper.onStart = f; f() }
val observer: Observer<Any?> = Observer {
helper.onStart = f
f()
}
synchronized(customObservedLiveData) {
customObservedLiveData.add(
Pair(liveData as LiveData<Any?>, observer)
Expand Down Expand Up @@ -696,7 +716,14 @@ class SamaObserverImpl : SamaObserver {
}
}

private inner class SamaObservableHelper(val id: Int, var onStart: (() -> Unit)?, var job: Job?, var f: ((data: Any?) -> Unit)?)
private inner class SamaObservableHelper(
val id: Int,
var onStart: (() -> Unit)?,
var job: Job?,
var f: (
(data: Any?) -> Unit
)?
)

private inner class SamaFlowHelper(
val id: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,25 @@ class SamaIntent : Intent {

internal val uid: Long

constructor() : super() { this.uid = uids.incrementAndGet(); putExtra(extra, uid) }
constructor() : super() {
this.uid = uids.incrementAndGet()
putExtra(extra, uid)
}
constructor(o: Intent?) : super(o) { this.uid = getLongExtra(extra, 0) }
constructor(action: String?) : super(action) { this.uid = uids.incrementAndGet(); putExtra(extra, uid) }
constructor(action: String?) : super(action) {
this.uid = uids.incrementAndGet()
putExtra(extra, uid)
}
constructor(action: String?, uri: Uri?) : super(action, uri) {
this.uid = uids.incrementAndGet(); putExtra(
this.uid = uids.incrementAndGet()
putExtra(
extra,
uid
)
}
constructor(packageContext: Context?, cls: Class<*>) : super(packageContext, cls) {
this.uid = uids.incrementAndGet(); putExtra(
this.uid = uids.incrementAndGet()
putExtra(
extra,
uid
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,16 @@ open class SamaRvAdapter(
}

/** Function run when adapter loads items, when [bindItems] or [bindPagingItems] is called. */
fun onLoadStarted(f: () -> Unit): SamaRvAdapter { this.onLoadStarted = f; return this }
fun onLoadStarted(f: () -> Unit): SamaRvAdapter {
this.onLoadStarted = f
return this
}

/** Function run after adapter loads items, when [bindItems] or [bindPagingItems] finished. */
fun onLoadFinished(f: () -> Unit): SamaRvAdapter { this.onLoadFinished = f; return this }
fun onLoadFinished(f: () -> Unit): SamaRvAdapter {
this.onLoadFinished = f
return this
}

private fun getItemStableId(listItem: SamaListItem?): Long {
return if (listItem?.getStableId() != RecyclerView.NO_ID) {
Expand Down Expand Up @@ -629,7 +635,7 @@ open class SamaRvAdapter(
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean =
!hasStableId ||
getItemStableId(oldList[oldItemPosition]) ==
getItemStableId(newList[newItemPosition])
getItemStableId(newList[newItemPosition])
override fun getOldListSize(): Int = oldList.size
override fun getNewListSize(): Int = newList.size
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean =
Expand Down
2 changes: 1 addition & 1 deletion powerfulsama_annotations/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ apply("${rootProject.projectDir}/sonatype-publish.gradle")

detekt {
toolVersion = Deps.detektPluginVersion
config = files("$rootDir/config/detekt/detekt.yml")
config.from("$rootDir/config/detekt/detekt.yml")
// allRules = true
buildUponDefaultConfig = true
autoCorrect = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal class SamaExtensionsAnnotationProcessor : BaseAnnotationProcessor() {
setOf(SamaExtensions::class.java.name, JvmField::class.java.name)

override fun process(set: Set<TypeElement>, roundEnv: RoundEnvironment): Boolean {
val annotation = roundEnv.getElementsAnnotatedWith(SamaExtensions::class.java)
roundEnv.getElementsAnnotatedWith(SamaExtensions::class.java)
.filter { it.kind == ElementKind.CLASS }
.map { it.getAnnotation(SamaExtensions::class.java) }
.firstOrNull()
Expand Down
8 changes: 7 additions & 1 deletion sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ android {

defaultConfig {
applicationId = "com.stefanosiano.powerful_libraries.sama_sample"
namespace = "com.stefanosiano.powerful_libraries.sama_sample"
minSdk = Deps.sdkMin
targetSdk = Deps.sdkTarget
versionCode = 1
Expand All @@ -29,6 +30,7 @@ android {
}

buildFeatures {
buildConfig = true
dataBinding = true
viewBinding = true
// Enables Jetpack Compose for this module: compose = true
Expand All @@ -48,6 +50,10 @@ android {
}
}

kotlin {
jvmToolchain(17)
}

dependencies {
implementation(project(path = ":powerfulsama"))
compileOnly(project(path = ":powerfulsama_annotations"))
Expand Down Expand Up @@ -85,7 +91,7 @@ dependencies {

detekt {
toolVersion = Deps.detektPluginVersion
config = files("$rootDir/config/detekt/detekt.yml")
config.from("$rootDir/config/detekt/detekt.yml")
// allRules = true
buildUponDefaultConfig = true
autoCorrect = false
Expand Down
4 changes: 2 additions & 2 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.stefanosiano.powerful_libraries.sama_sample">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application
android:name=".SampleApplication"
Expand Down
Loading

0 comments on commit f0e09b1

Please sign in to comment.