Convert :source-api and :source-local to android library module (#3636)
- There's really no plan to support other platforms on this code base - The "KMP" modules only had android target which is rather pointless - `i18n` involves more work but given it has no actual code keeping it as is
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package eu.kanade.tachiyomi.source
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import androidx.preference.PreferenceScreen
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
interface ConfigurableSource : Source {
|
||||
|
||||
/**
|
||||
* Gets instance of [SharedPreferences] scoped to the specific source.
|
||||
*
|
||||
* @since extensions-lib 1.5
|
||||
*/
|
||||
fun getSourcePreferences(): SharedPreferences =
|
||||
Injekt.get<Application>().getSharedPreferences(preferenceKey(), Context.MODE_PRIVATE)
|
||||
|
||||
fun setupPreferenceScreen(screen: PreferenceScreen)
|
||||
}
|
||||
|
||||
fun ConfigurableSource.preferenceKey(): String = "source_$id"
|
||||
|
||||
// TODO: use getSourcePreferences once all extensions are on ext-lib 1.5
|
||||
fun ConfigurableSource.sourcePreferences(): SharedPreferences =
|
||||
Injekt.get<Application>().getSharedPreferences(preferenceKey(), Context.MODE_PRIVATE)
|
||||
|
||||
fun sourcePreferences(key: String): SharedPreferences =
|
||||
Injekt.get<Application>().getSharedPreferences(key, Context.MODE_PRIVATE)
|
||||
Reference in New Issue
Block a user