diff --git a/library-noop/flaker-android-okhttp-noop/build.gradle.kts b/library-noop/flaker-android-okhttp-noop/build.gradle.kts index 8cae0e0..a64f586 100644 --- a/library-noop/flaker-android-okhttp-noop/build.gradle.kts +++ b/library-noop/flaker-android-okhttp-noop/build.gradle.kts @@ -12,7 +12,7 @@ android { compileSdk = 33 defaultConfig { - minSdk = 24 + minSdk = 21 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") diff --git a/library-noop/flaker-okhttp-core-noop/build.gradle.kts b/library-noop/flaker-okhttp-core-noop/build.gradle.kts index 39c4417..6bd19ba 100644 --- a/library-noop/flaker-okhttp-core-noop/build.gradle.kts +++ b/library-noop/flaker-okhttp-core-noop/build.gradle.kts @@ -12,7 +12,7 @@ android { compileSdk = 33 defaultConfig { - minSdk = 24 + minSdk = 21 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") diff --git a/library/flaker-android-ktor/build.gradle.kts b/library/flaker-android-ktor/build.gradle.kts index ea92e2b..9ea696c 100644 --- a/library/flaker-android-ktor/build.gradle.kts +++ b/library/flaker-android-ktor/build.gradle.kts @@ -12,7 +12,7 @@ android { compileSdk = 33 defaultConfig { - minSdk = 24 + minSdk = 21 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") diff --git a/library/flaker-android-monitor/build.gradle.kts b/library/flaker-android-monitor/build.gradle.kts index 41b3c7d..65eeb47 100644 --- a/library/flaker-android-monitor/build.gradle.kts +++ b/library/flaker-android-monitor/build.gradle.kts @@ -23,7 +23,7 @@ android { } defaultConfig { - minSdk = 24 + minSdk = 21 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") diff --git a/library/flaker-android-okhttp/build.gradle.kts b/library/flaker-android-okhttp/build.gradle.kts index 887febf..c0b2816 100644 --- a/library/flaker-android-okhttp/build.gradle.kts +++ b/library/flaker-android-okhttp/build.gradle.kts @@ -12,7 +12,7 @@ android { compileSdk = 33 defaultConfig { - minSdk = 24 + minSdk = 21 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") diff --git a/library/flaker-android-okhttp/src/main/java/io/github/rotbolt/flakerandroidokhttp/ui/FlakerViewModel.kt b/library/flaker-android-okhttp/src/main/java/io/github/rotbolt/flakerandroidokhttp/ui/FlakerViewModel.kt index a662324..7dfe009 100644 --- a/library/flaker-android-okhttp/src/main/java/io/github/rotbolt/flakerandroidokhttp/ui/FlakerViewModel.kt +++ b/library/flaker-android-okhttp/src/main/java/io/github/rotbolt/flakerandroidokhttp/ui/FlakerViewModel.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.viewModelScope import io.github.rotbolt.flakedomain.prefs.FlakerPrefs import io.github.rotbolt.flakedomain.prefs.RetentionPolicy import io.github.rotbolt.flakerandroidmonitor.FlakerMonitor +import io.github.rotbolt.flakerandroidui.components.lists.NetworkRequestInfo import io.github.rotbolt.flakerandroidui.components.lists.NetworkRequestUi import io.github.rotbolt.flakerandroidui.screens.prefs.FlakerPrefsUiDto import io.github.rotbolt.flakerandroidui.screens.search.SearchUiDto @@ -70,11 +71,22 @@ class FlakerViewModel( networkRequestRepo.observeAll() .collectLatest { list -> val uiMapList = list - .map { NetworkRequestUi.NetworkRequestItem(it) } - .sortedByDescending { it.networkRequest.requestTime } + .map { + val sdf = SimpleDateFormat("HH:mm:ss", Locale.getDefault()) + val date = Date(it.requestTime) + val formattedTime: String = sdf.format(date) + val info = NetworkRequestInfo( + networkRequest = it, + formattedTime = formattedTime + ) + NetworkRequestUi.NetworkRequestItem(info) + } + .sortedByDescending { it.networkRequestInfo.networkRequest.requestTime } .groupBy { val dateFormatter = SimpleDateFormat("MMM dd, yyyy", Locale.ENGLISH) - val formattedString = dateFormatter.format(Date(it.networkRequest.requestTime)) + val formattedString = dateFormatter.format( + Date(it.networkRequestInfo.networkRequest.requestTime) + ) NetworkRequestUi.DateItem(formattedString) } _viewStateFlow.emit(_viewStateFlow.value.copy(networkRequests = uiMapList)) @@ -171,13 +183,13 @@ class FlakerViewModel( .networkRequests .flatMap { item -> item.value } .filter { item -> - item.networkRequest.host.contains(term, ignoreCase = true) || - item.networkRequest.path.contains(term, ignoreCase = true) + item.networkRequestInfo.networkRequest.host.contains(term, ignoreCase = true) || + item.networkRequestInfo.networkRequest.path.contains(term, ignoreCase = true) } - .sortedByDescending { it.networkRequest.requestTime } + .sortedByDescending { it.networkRequestInfo.networkRequest.requestTime } .groupBy { val dateFormatter = SimpleDateFormat("MMM dd, yyyy", Locale.ENGLISH) - val formattedString = dateFormatter.format(Date(it.networkRequest.requestTime)) + val formattedString = dateFormatter.format(Date(it.networkRequestInfo.networkRequest.requestTime)) NetworkRequestUi.DateItem(formattedString) } val searchUiDto = _viewStateFlow.value.searchData.copy(filteredContent) diff --git a/library/flaker-android-ui/build.gradle.kts b/library/flaker-android-ui/build.gradle.kts index 7b582bd..7d227f4 100644 --- a/library/flaker-android-ui/build.gradle.kts +++ b/library/flaker-android-ui/build.gradle.kts @@ -12,7 +12,7 @@ android { compileSdk = 33 defaultConfig { - minSdk = 24 + minSdk = 21 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") @@ -55,7 +55,6 @@ dependencies { implementation(libs.ui.graphics) implementation(libs.ui.tooling.preview) implementation(libs.material3) - implementation(libs.kotlinx.datetime) testImplementation(libs.junit) androidTestImplementation(libs.androidx.test.ext.junit) androidTestImplementation(libs.espresso.core) diff --git a/library/flaker-android-ui/src/main/java/io/github/rotbolt/flakerandroidui/components/lists/NetworkRequestList.kt b/library/flaker-android-ui/src/main/java/io/github/rotbolt/flakerandroidui/components/lists/NetworkRequestList.kt index ef32d98..73e5e0d 100644 --- a/library/flaker-android-ui/src/main/java/io/github/rotbolt/flakerandroidui/components/lists/NetworkRequestList.kt +++ b/library/flaker-android-ui/src/main/java/io/github/rotbolt/flakerandroidui/components/lists/NetworkRequestList.kt @@ -56,7 +56,7 @@ fun NetworkRequestList(modifier: Modifier = Modifier, contentProvider: () -> Net items(networkRequestList) { item -> NetworkRequestItem( - networkRequest = item.networkRequest, + networkRequestInfo = item.networkRequestInfo, modifier = Modifier.padding(horizontal = 16.dp) ) Spacer(modifier = Modifier.size(8.dp)) diff --git a/library/flaker-android-ui/src/main/java/io/github/rotbolt/flakerandroidui/components/lists/NetworkRequestUi.kt b/library/flaker-android-ui/src/main/java/io/github/rotbolt/flakerandroidui/components/lists/NetworkRequestUi.kt index c3af430..fd315bf 100644 --- a/library/flaker-android-ui/src/main/java/io/github/rotbolt/flakerandroidui/components/lists/NetworkRequestUi.kt +++ b/library/flaker-android-ui/src/main/java/io/github/rotbolt/flakerandroidui/components/lists/NetworkRequestUi.kt @@ -4,5 +4,10 @@ import io.github.rotbolt.flakedomain.networkrequest.NetworkRequest sealed class NetworkRequestUi { data class DateItem(val formattedString: String) : NetworkRequestUi() - data class NetworkRequestItem(val networkRequest: NetworkRequest) : NetworkRequestUi() + data class NetworkRequestItem(val networkRequestInfo: NetworkRequestInfo) : NetworkRequestUi() } + +data class NetworkRequestInfo( + val networkRequest: NetworkRequest, + val formattedTime: String +) diff --git a/library/flaker-android-ui/src/main/java/io/github/rotbolt/flakerandroidui/elements/listitem/NetworkRequestItem.kt b/library/flaker-android-ui/src/main/java/io/github/rotbolt/flakerandroidui/elements/listitem/NetworkRequestItem.kt index f87de62..2011489 100644 --- a/library/flaker-android-ui/src/main/java/io/github/rotbolt/flakerandroidui/elements/listitem/NetworkRequestItem.kt +++ b/library/flaker-android-ui/src/main/java/io/github/rotbolt/flakerandroidui/elements/listitem/NetworkRequestItem.kt @@ -23,18 +23,16 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import io.github.rotbolt.flakedomain.networkrequest.NetworkRequest +import io.github.rotbolt.flakerandroidui.components.lists.NetworkRequestInfo import io.github.rotbolt.flakerandroidui.theme.FlakerAndroidTheme import io.github.rotbolt.flakerandroidui.theme.statusCodeError import io.github.rotbolt.flakerandroidui.theme.statusCodeOther import io.github.rotbolt.flakerandroidui.theme.statusCodeSuccess -import kotlinx.datetime.Instant -import kotlinx.datetime.TimeZone -import kotlinx.datetime.toLocalDateTime @Composable fun NetworkRequestItem( modifier: Modifier = Modifier, - networkRequest: NetworkRequest + networkRequestInfo: NetworkRequestInfo ) { Card( modifier = modifier @@ -42,6 +40,8 @@ fun NetworkRequestItem( .wrapContentHeight(), shape = RoundedCornerShape(8.dp), ) { + val (networkRequest, formattedTime) = networkRequestInfo + Row(modifier = Modifier.padding(8.dp)) { Text( text = networkRequest.responseCode.toString(), @@ -87,11 +87,8 @@ fun NetworkRequestItem( .padding(vertical = 8.dp) .align(Alignment.Start) ) { - val localTime = Instant.fromEpochMilliseconds(networkRequest.requestTime) - .toLocalDateTime(TimeZone.currentSystemDefault()) - Text( - text = localTime.time.toString().substringBefore("."), + text = formattedTime, modifier = Modifier.align(Alignment.CenterVertically) ) @@ -148,7 +145,11 @@ fun NetworkRequestItemPreview() { isFailedByFlaker = it >= 2, createdAt = 1692270425000 ) - NetworkRequestItem(networkRequest = networkRequest, modifier = Modifier.padding(16.dp)) + val networkRequestInfo = NetworkRequestInfo( + networkRequest = networkRequest, + formattedTime = "11:42:40" + ) + NetworkRequestItem(networkRequestInfo = networkRequestInfo, modifier = Modifier.padding(16.dp)) } } } diff --git a/library/flaker-android/build.gradle.kts b/library/flaker-android/build.gradle.kts index 1bdfe30..c22b08c 100644 --- a/library/flaker-android/build.gradle.kts +++ b/library/flaker-android/build.gradle.kts @@ -12,7 +12,7 @@ android { compileSdk = 33 defaultConfig { - minSdk = 24 + minSdk = 21 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") diff --git a/library/flaker-data/build.gradle.kts b/library/flaker-data/build.gradle.kts index f9db696..af455e0 100644 --- a/library/flaker-data/build.gradle.kts +++ b/library/flaker-data/build.gradle.kts @@ -111,7 +111,7 @@ android { namespace = "io.github.rotbolt.flakerdata" compileSdk = 33 defaultConfig { - minSdk = 24 + minSdk = 21 targetSdk = 33 consumerProguardFiles("consumer-rules.pro") } diff --git a/library/flaker-domain/build.gradle.kts b/library/flaker-domain/build.gradle.kts index 95925db..efa7cba 100644 --- a/library/flaker-domain/build.gradle.kts +++ b/library/flaker-domain/build.gradle.kts @@ -64,7 +64,7 @@ android { namespace = "io.github.rotbolt.flakerdomain" compileSdk = 33 defaultConfig { - minSdk = 24 + minSdk = 21 targetSdk = 33 consumerProguardFiles("consumer-rules.pro") } diff --git a/library/flaker-ktor-core/build.gradle.kts b/library/flaker-ktor-core/build.gradle.kts index 81dca7d..4fcca81 100644 --- a/library/flaker-ktor-core/build.gradle.kts +++ b/library/flaker-ktor-core/build.gradle.kts @@ -95,7 +95,7 @@ android { namespace = "io.github.rotbolt.flakerktorcore" compileSdk = 33 defaultConfig { - minSdk = 24 + minSdk = 21 targetSdk = 33 consumerProguardFiles("consumer-rules.pro") } diff --git a/library/flaker-okhttp-core/build.gradle.kts b/library/flaker-okhttp-core/build.gradle.kts index 2b2f97e..a4a918b 100644 --- a/library/flaker-okhttp-core/build.gradle.kts +++ b/library/flaker-okhttp-core/build.gradle.kts @@ -12,7 +12,7 @@ android { compileSdk = 33 defaultConfig { - minSdk = 24 + minSdk = 21 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") diff --git a/sampleapp/build.gradle.kts b/sampleapp/build.gradle.kts index c137a9a..f611ed4 100644 --- a/sampleapp/build.gradle.kts +++ b/sampleapp/build.gradle.kts @@ -13,7 +13,7 @@ android { defaultConfig { applicationId = "io.github.rotbolt.flakersampleapp" - minSdk = 24 + minSdk = 21 targetSdk = 33 versionCode = 1 versionName = "1.0"