From 97798446201c37c02cc04056754a4c04b61a5a2e Mon Sep 17 00:00:00 2001 From: tzugen Date: Thu, 7 Apr 2022 15:29:24 +0200 Subject: [PATCH] Solve more simple... --- .../ultrasonic/api/subsonic/SubsonicAPIClient.kt | 6 ++++-- .../org/moire/ultrasonic/di/MusicServiceModule.kt | 13 +------------ .../moire/ultrasonic/fragment/EditServerFragment.kt | 3 +-- .../kotlin/org/moire/ultrasonic/util/Constants.kt | 1 - .../kotlin/org/moire/ultrasonic/util/Settings.kt | 3 --- ultrasonic/src/main/res/values/strings.xml | 2 -- ultrasonic/src/main/res/xml/settings.xml | 6 ------ 7 files changed, 6 insertions(+), 28 deletions(-) diff --git a/core/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicAPIClient.kt b/core/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicAPIClient.kt index 6f93f0df..70d09743 100644 --- a/core/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicAPIClient.kt +++ b/core/subsonic-api/src/main/kotlin/org/moire/ultrasonic/api/subsonic/SubsonicAPIClient.kt @@ -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() { diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/di/MusicServiceModule.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/di/MusicServiceModule.kt index 70262804..7751557c 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/di/MusicServiceModule.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/di/MusicServiceModule.kt @@ -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 { - val level = if (Settings.debugFullBody) { - HttpLoggingInterceptor.Level.BODY - } else { - HttpLoggingInterceptor.Level.HEADERS - } - HttpLoggingInterceptor(TimberOkHttpLogger()) - .setLevel(level) - } - + single { TimberOkHttpLogger() } single { SubsonicAPIClient(get(), get()) } single(named(ONLINE_MUSIC_SERVICE)) { diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/EditServerFragment.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/EditServerFragment.kt index c5e19cfc..84de4a97 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/EditServerFragment.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/EditServerFragment.kt @@ -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. diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Constants.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Constants.kt index c9113e35..6fb9efeb 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Constants.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Constants.kt @@ -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" diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Settings.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Settings.kt index daa24d75..58458f9e 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Settings.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Settings.kt @@ -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()) diff --git a/ultrasonic/src/main/res/values/strings.xml b/ultrasonic/src/main/res/values/strings.xml index 8e668ccd..13260419 100644 --- a/ultrasonic/src/main/res/values/strings.xml +++ b/ultrasonic/src/main/res/values/strings.xml @@ -381,8 +381,6 @@ Multiple Years Debug options Write debug log to file - Debug the body of HTTP calls - This will slow down streaming requests The log files are available at %1$s/%2$s There are %1$s log files taking up ~%2$s MB space in the %3$s directory. Do you want to keep these? Keep files diff --git a/ultrasonic/src/main/res/xml/settings.xml b/ultrasonic/src/main/res/xml/settings.xml index 2e23ed84..c03bdc62 100644 --- a/ultrasonic/src/main/res/xml/settings.xml +++ b/ultrasonic/src/main/res/xml/settings.xml @@ -341,12 +341,6 @@ a:title="@string/settings.debug.log_to_file" a:summary="" app:iconSpaceReserved="false"/> - \ No newline at end of file