Add LANraragi (#702)
* Add LANraragi * clean up build.gradle * use buildList Co-authored-by: stevenyomi <95685115+stevenyomi@users.noreply.github.com> --------- Co-authored-by: stevenyomi <95685115+stevenyomi@users.noreply.github.com>
This commit is contained in:
parent
72283a476a
commit
d70973dbf7
@ -24,7 +24,11 @@ You can visit the [LANraragi](https://github.com/Difegue/LANraragi) github page
|
||||
Make sure that your LANraragi server and extension are on the newest version.
|
||||
|
||||
### Can I add more than one LANraragi server or user?
|
||||
<<<<<<< HEAD
|
||||
No, currently there is only support for 1 instances in Tachiyomi, if you need more instances please open a feature request on [tachiyomi-extensions](https://github.com/tachiyomiorg/tachiyomi-extensions/issues/new/choose) repo.
|
||||
=======
|
||||
No, currently there is only support for 1 instances in Tachiyomi, if you need more instances please open a feature request on [extensions](https://github.com/tachiyomiorg/extensions/issues/new/choose) repo.
|
||||
>>>>>>> 4dac8de22 (Add LANraragi (#702))
|
||||
|
||||
### Can I test the LANraragi extension before setting up my own server?
|
||||
Yes, you can try it out with the DEMO server `https://lrr.tvc-16.science`.
|
||||
|
@ -1,7 +1,11 @@
|
||||
ext {
|
||||
extName = 'LANraragi'
|
||||
extClass = '.LANraragiFactory'
|
||||
<<<<<<< HEAD
|
||||
extVersionCode = 15
|
||||
=======
|
||||
extVersionCode = 16
|
||||
>>>>>>> 4dac8de22 (Add LANraragi (#702))
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
||||
|
BIN
src/all/lanraragi/res/web_hi_res_512.png
Normal file
BIN
src/all/lanraragi/res/web_hi_res_512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 134 KiB |
@ -6,6 +6,10 @@ import android.net.Uri
|
||||
import android.text.InputType
|
||||
import android.util.Base64
|
||||
import android.widget.Toast
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import androidx.preference.ListPreference
|
||||
>>>>>>> 4dac8de22 (Add LANraragi (#702))
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||
@ -272,7 +276,11 @@ open class LANraragi(private val suffix: String = "") : ConfigurableSource, Unme
|
||||
(0..7).map { bytes[it].toLong() and 0xff shl 8 * (7 - it) }.reduce(Long::or) and Long.MAX_VALUE
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
private val preferences: SharedPreferences by lazy {
|
||||
=======
|
||||
internal val preferences: SharedPreferences by lazy {
|
||||
>>>>>>> 4dac8de22 (Add LANraragi (#702))
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
|
||||
@ -282,6 +290,30 @@ open class LANraragi(private val suffix: String = "") : ConfigurableSource, Unme
|
||||
private fun getPrefCustomLabel(): String = preferences.getString(CUSTOM_LABEL_KEY, suffix)!!.ifBlank { suffix }
|
||||
|
||||
override fun setupPreferenceScreen(screen: androidx.preference.PreferenceScreen) {
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
if (suffix == "1") {
|
||||
ListPreference(screen.context).apply {
|
||||
key = EXTRA_SOURCES_COUNT_KEY
|
||||
title = "Number of extra sources"
|
||||
summary = "Number of additional sources to create. There will always be at least one LANraragi source."
|
||||
entries = EXTRA_SOURCES_ENTRIES
|
||||
entryValues = EXTRA_SOURCES_ENTRIES
|
||||
|
||||
setDefaultValue(EXTRA_SOURCES_COUNT_DEFAULT)
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
try {
|
||||
val setting = preferences.edit().putString(EXTRA_SOURCES_COUNT_KEY, newValue as String).commit()
|
||||
Toast.makeText(screen.context, "Restart Tachiyomi to apply new setting.", Toast.LENGTH_LONG).show()
|
||||
setting
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
false
|
||||
}
|
||||
}
|
||||
}.also(screen::addPreference)
|
||||
}
|
||||
>>>>>>> 4dac8de22 (Add LANraragi (#702))
|
||||
screen.addPreference(screen.editTextPreference(HOSTNAME_KEY, "Hostname", HOSTNAME_DEFAULT, baseUrl, refreshSummary = true))
|
||||
screen.addPreference(screen.editTextPreference(APIKEY_KEY, "API Key", "", "Required if No-Fun Mode is enabled.", true))
|
||||
screen.addPreference(screen.editTextPreference(CUSTOM_LABEL_KEY, "Custom Label", "", "Show the given label for the source instead of the default."))
|
||||
@ -458,6 +490,13 @@ open class LANraragi(private val suffix: String = "") : ConfigurableSource, Unme
|
||||
}
|
||||
|
||||
companion object {
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
internal const val EXTRA_SOURCES_COUNT_KEY = "extraSourcesCount"
|
||||
internal const val EXTRA_SOURCES_COUNT_DEFAULT = "2"
|
||||
private val EXTRA_SOURCES_ENTRIES = (0..10).map { it.toString() }.toTypedArray()
|
||||
|
||||
>>>>>>> 4dac8de22 (Add LANraragi (#702))
|
||||
private const val HOSTNAME_DEFAULT = "http://127.0.0.1:3000"
|
||||
private const val HOSTNAME_KEY = "hostname"
|
||||
private const val APIKEY_KEY = "apiKey"
|
||||
|
@ -4,10 +4,24 @@ import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceFactory
|
||||
|
||||
class LANraragiFactory : SourceFactory {
|
||||
<<<<<<< HEAD
|
||||
override fun createSources(): List<Source> =
|
||||
listOf(
|
||||
LANraragi("1"),
|
||||
LANraragi("2"),
|
||||
LANraragi("3"),
|
||||
)
|
||||
=======
|
||||
override fun createSources(): List<Source> {
|
||||
val firstLrr = LANraragi("1")
|
||||
val lrrCount = firstLrr.preferences.getString(LANraragi.EXTRA_SOURCES_COUNT_KEY, LANraragi.EXTRA_SOURCES_COUNT_DEFAULT)!!.toInt()
|
||||
|
||||
return buildList(lrrCount) {
|
||||
add(firstLrr)
|
||||
for (i in 2..lrrCount) {
|
||||
add(LANraragi("$i"))
|
||||
}
|
||||
}
|
||||
}
|
||||
>>>>>>> 4dac8de22 (Add LANraragi (#702))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user