forked from melod1n/fast-messenger
return of debug token for auth; ability to disable haptic and set logging level; etc
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package dev.meloda.fast.common.model
|
||||
|
||||
enum class LogLevel(val value: Int) {
|
||||
NONE(0),
|
||||
BASIC(1),
|
||||
HEADERS(2),
|
||||
BODY(3);
|
||||
|
||||
companion object {
|
||||
fun parse(value: Int): LogLevel = entries.firstOrNull { it.value == value }
|
||||
?: throw IllegalArgumentException("Unknown log level with value: $value")
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package dev.meloda.fast.datastore
|
||||
import android.content.SharedPreferences
|
||||
import androidx.core.content.edit
|
||||
import dev.meloda.fast.common.model.DarkMode
|
||||
import dev.meloda.fast.common.model.LogLevel
|
||||
import kotlin.properties.Delegates
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@@ -187,6 +188,20 @@ object AppSettings {
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_APPEARANCE_SHOW_TIME_IN_ACTION_MESSAGES, value)
|
||||
|
||||
var enableHaptic: Boolean
|
||||
get() = get(
|
||||
SettingsKeys.KEY_DEBUG_ENABLE_HAPTIC,
|
||||
true
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_DEBUG_ENABLE_HAPTIC, value)
|
||||
|
||||
var networkLogLevel: LogLevel
|
||||
get() = get(
|
||||
SettingsKeys.KEY_DEBUG_NETWORK_LOG_LEVEL,
|
||||
SettingsKeys.DEFAULT_NETWORK_LOG_LEVEL
|
||||
).let(LogLevel::parse)
|
||||
set(level) = put(SettingsKeys.KEY_DEBUG_NETWORK_LOG_LEVEL, level.value)
|
||||
|
||||
var showDebugCategory: Boolean
|
||||
get() = get(
|
||||
SettingsKeys.KEY_SHOW_DEBUG_CATEGORY,
|
||||
|
||||
@@ -45,6 +45,9 @@ object SettingsKeys {
|
||||
const val KEY_DEBUG_SHOW_CRASH_ALERT = "debug_show_crash_alert"
|
||||
const val KEY_DEBUG_HIDE_DEBUG_LIST = "debug_hide_debug_list"
|
||||
const val KEY_ENABLE_ANIMATIONS_IN_MESSAGES = "debug_enable_animations_in_messages"
|
||||
const val KEY_DEBUG_ENABLE_HAPTIC = "debug_enable_haptic"
|
||||
const val KEY_DEBUG_NETWORK_LOG_LEVEL = "debug_network_log_level"
|
||||
const val DEFAULT_NETWORK_LOG_LEVEL = 0
|
||||
|
||||
const val KEY_SHOW_DEBUG_CATEGORY = "show_debug_category"
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ android {
|
||||
dependencies {
|
||||
api(projects.core.common)
|
||||
api(projects.core.model)
|
||||
api(projects.core.datastore)
|
||||
|
||||
implementation(libs.moshi.kotlin)
|
||||
implementation(libs.koin.android)
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.slack.eithernet.ApiResultCallAdapterFactory
|
||||
import com.slack.eithernet.ApiResultConverterFactory
|
||||
import com.squareup.moshi.Moshi
|
||||
import dev.meloda.fast.common.AppConstants
|
||||
import dev.meloda.fast.common.model.LogLevel
|
||||
import dev.meloda.fast.datastore.AppSettings
|
||||
import dev.meloda.fast.network.JsonConverter
|
||||
import dev.meloda.fast.network.MoshiConverter
|
||||
import dev.meloda.fast.network.OAuthResultCallFactory
|
||||
@@ -55,7 +57,12 @@ val networkModule = module {
|
||||
.followSslRedirects(true)
|
||||
.addInterceptor(
|
||||
HttpLoggingInterceptor().apply {
|
||||
level = HttpLoggingInterceptor.Level.BODY
|
||||
level = when (AppSettings.Debug.networkLogLevel) {
|
||||
LogLevel.NONE -> HttpLoggingInterceptor.Level.NONE
|
||||
LogLevel.BASIC -> HttpLoggingInterceptor.Level.BASIC
|
||||
LogLevel.HEADERS -> HttpLoggingInterceptor.Level.HEADERS
|
||||
LogLevel.BODY -> HttpLoggingInterceptor.Level.BODY
|
||||
}
|
||||
}
|
||||
)
|
||||
.build()
|
||||
|
||||
@@ -47,6 +47,8 @@ class ImmutableList<T>(val values: List<T>) : Iterable<T> {
|
||||
return single
|
||||
}
|
||||
|
||||
val size: Int get() = values.size
|
||||
|
||||
companion object {
|
||||
fun <T> copyOf(collection: Collection<T>): ImmutableList<T> =
|
||||
ImmutableList(collection.toList())
|
||||
|
||||
Reference in New Issue
Block a user