Solve more simple...

This commit is contained in:
tzugen 2022-04-07 15:29:24 +02:00
parent f936ad690c
commit 9779844620
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
7 changed files with 6 additions and 28 deletions

View File

@ -34,7 +34,7 @@ private const val READ_TIMEOUT = 60_000L
*/
class SubsonicAPIClient(
config: SubsonicClientConfiguration,
private val okLogger: HttpLoggingInterceptor,
private val okLogger: HttpLoggingInterceptor.Logger = HttpLoggingInterceptor.Logger.DEFAULT,
baseOkClient: OkHttpClient = OkHttpClient.Builder().build()
) {
private val versionInterceptor = VersionInterceptor(config.minimalProtocolVersion)
@ -108,7 +108,9 @@ class SubsonicAPIClient(
val api: SubsonicAPIDefinition get() = wrappedApi
private fun OkHttpClient.Builder.addLogging() {
this.addInterceptor(okLogger)
val loggingInterceptor = HttpLoggingInterceptor(okLogger)
loggingInterceptor.level = HttpLoggingInterceptor.Level.HEADERS
this.addInterceptor(loggingInterceptor)
}
private fun OkHttpClient.Builder.allowSelfSignedCertificates() {

View File

@ -1,5 +1,4 @@
@file:JvmName("MusicServiceModule")
package org.moire.ultrasonic.di
import kotlin.math.abs
@ -23,7 +22,6 @@ import org.moire.ultrasonic.subsonic.ImageLoaderProvider
import org.moire.ultrasonic.subsonic.NetworkAndStorageChecker
import org.moire.ultrasonic.subsonic.ShareHandler
import org.moire.ultrasonic.util.Constants
import org.moire.ultrasonic.util.Settings
/**
* This Koin module contains the registration of classes related to the Music Services
@ -62,16 +60,7 @@ val musicServiceModule = module {
)
}
single<HttpLoggingInterceptor> {
val level = if (Settings.debugFullBody) {
HttpLoggingInterceptor.Level.BODY
} else {
HttpLoggingInterceptor.Level.HEADERS
}
HttpLoggingInterceptor(TimberOkHttpLogger())
.setLevel(level)
}
single<HttpLoggingInterceptor.Logger> { TimberOkHttpLogger() }
single { SubsonicAPIClient(get(), get()) }
single<MusicService>(named(ONLINE_MUSIC_SERVICE)) {

View File

@ -19,7 +19,6 @@ import java.io.IOException
import java.net.MalformedURLException
import java.net.URL
import java.util.Locale
import org.koin.android.ext.android.get
import org.koin.android.ext.android.inject
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.moire.ultrasonic.BuildConfig
@ -409,7 +408,7 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
currentServerSetting!!.ldapSupport,
BuildConfig.DEBUG
)
val subsonicApiClient = SubsonicAPIClient(configuration, get())
val subsonicApiClient = SubsonicAPIClient(configuration)
// Execute a ping to retrieve the API version.
// This is accepted to fail if the authentication is incorrect yet.

View File

@ -108,7 +108,6 @@ object Constants {
const val PREFERENCES_KEY_CATEGORY_NOTIFICATIONS = "notificationsCategory"
const val PREFERENCES_KEY_FIRST_RUN_EXECUTED = "firstRunExecuted"
const val PREFERENCES_KEY_DEBUG_LOG_TO_FILE = "debugLogToFile"
const val PREFERENCES_KEY_DEBUG_LOG_BODY = "debugLogBody"
const val PREFERENCES_KEY_OVERRIDE_LANGUAGE = "overrideLanguage"
const val FILENAME_PLAYLIST_SER = "downloadstate.ser"
const val ALBUM_ART_FILE = "folder.jpeg"

View File

@ -234,9 +234,6 @@ object Settings {
@JvmStatic
var debugLogToFile by BooleanSetting(Constants.PREFERENCES_KEY_DEBUG_LOG_TO_FILE, false)
@JvmStatic
var debugFullBody by BooleanSetting(Constants.PREFERENCES_KEY_DEBUG_LOG_BODY, false)
@JvmStatic
val preferences: SharedPreferences
get() = PreferenceManager.getDefaultSharedPreferences(Util.appContext())

View File

@ -381,8 +381,6 @@
<string name="common_multiple_years">Multiple Years</string>
<string name="settings.debug.title">Debug options</string>
<string name="settings.debug.log_to_file">Write debug log to file</string>
<string name="settings.debug.log_body">Debug the body of HTTP calls</string>
<string name="settings.debug.log_body_summary">This will slow down streaming requests</string>
<string name="settings.debug.log_path">The log files are available at %1$s/%2$s</string>
<string name="settings.debug.log_summary">There are %1$s log files taking up ~%2$s MB space in the %3$s directory. Do you want to keep these?</string>
<string name="settings.debug.log_keep">Keep files</string>

View File

@ -341,12 +341,6 @@
a:title="@string/settings.debug.log_to_file"
a:summary=""
app:iconSpaceReserved="false"/>
<CheckBoxPreference
a:defaultValue="false"
a:key="debugLogBody"
a:title="@string/settings.debug.log_body"
a:summary="@string/settings.debug.log_body_summary"
app:iconSpaceReserved="false"/>
</PreferenceCategory>
</PreferenceScreen>