init projects
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package ru.shadowsparky.data
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.Context
|
||||
import org.koin.core.annotation.Factory
|
||||
import ru.shadowsparky.domain.Clip
|
||||
import ru.shadowsparky.domain.ClipboardManager
|
||||
|
||||
@Factory
|
||||
class AndroidClipboardManager(private val context: Context) : ClipboardManager {
|
||||
private val service by lazy {
|
||||
context.getSystemService(Context.CLIPBOARD_SERVICE) as android.content.ClipboardManager
|
||||
}
|
||||
|
||||
override suspend fun setText(clip: Clip) {
|
||||
service.setPrimaryClip(ClipData.newPlainText(clip.title, clip.text))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package ru.shadowsparky.data
|
||||
|
||||
import org.koin.core.annotation.Single
|
||||
import ru.shadowsparky.domain.Log
|
||||
|
||||
private typealias Impl = android.util.Log
|
||||
|
||||
@Single
|
||||
class AndroidLog : Log {
|
||||
override fun d(tag: String, msg: String?, e: Throwable?) {
|
||||
Impl.d(tag, msg, e)
|
||||
}
|
||||
|
||||
override fun e(tag: String, e: Throwable?, msg: String?) {
|
||||
Impl.e(tag, msg, e)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package ru.shadowsparky.data
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import com.russhwolf.settings.Settings
|
||||
import com.russhwolf.settings.SharedPreferencesSettings
|
||||
import org.koin.core.annotation.Single
|
||||
|
||||
@Single
|
||||
class AndroidSettingsFactory(private val app: Application) : SettingsFactory {
|
||||
override fun create(name: String): Settings {
|
||||
val prefs = app.getSharedPreferences(name, Context.MODE_PRIVATE)
|
||||
return SharedPreferencesSettings(prefs)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user