Further reduce Java usages - #40
Conversation
…n logics out of database scope
|
/opencode /review This PR tend to reduce Java usages to minimum. Notice that some of the Java usage is acceptable, for example ArcaeaPackageHelper is only available for Android, so using Java / Apache Commons ZipFile is OK; and for date time formatting, |
|
Now I have a thorough understanding of the PR. Here's my review: PR Review: Further reduce Java usagesBug found:
|
| Input | DOWN (old) |
ROUND_HALF_TOWARDS_ZERO (new) |
|---|---|---|
| 12.054 | "12.05" | "12.05" |
| 12.055 | "12.05" | "12.05" |
| 12.056 | "12.05" | "12.06" |
The existing tests at ArcaeaFormattersTest.kt:21-22 only cover 12.054 and 12.055, which happen to produce the same result under both modes, so the bug is not caught. The correct bignum equivalent of Java's RoundingMode.DOWN is RoundingMode.ROUND_TOWARD_ZERO.
Minor observation: Java IO still in DatabaseManageViewModel.kt
app/src/main/java/xyz/sevive/arcaeaoffline/ui/screens/database/manage/DatabaseManageViewModel.kt:43-47 still imports:
import java.io.FileInputStream
import java.io.InputStream
import java.io.OutputStream
import java.nio.charset.Charset
import java.nio.charset.StandardCharsetsFileInputStreamis needed to bridgeandroid.os.FileDescriptor→SeekableByteChannelfor Apache Commons CompressZipFile— acceptable.InputStream/OutputStreamcome from Android content resolver and Apache Commons Compress APIs — acceptable.Charset/StandardCharsetscould be replaced withkotlin.text.Charsets.UTF_8for a bit more Java removal, but it's low priority.
Acceptable remaining Java (as noted in PR description)
ArcaeaPackageHelper.kt:23-24—java.util.zip.ZipFileandZipEntry. Android-only, explicitly scoped as acceptable.DateTimeEditDialog.kt:61-62—java.time.format.DateTimeFormatter/FormatStyle. Nokotlinx.datetimelocale support yet, acceptable.DeviceOcrOnnxHelper.kt:16—java.nio.ByteBuffer. Required by ONNX Runtime library API. The PR already removed theByteOrderimport, which is good.
All other changes look clean
java.util.UUID→kotlin.uuid.Uuidmigration is thorough across entities, converters, daos, repos, serializers, and migrations.java.text.DecimalFormat/java.math.RoundingMode→bignuminArcaeaFormatters(aside from the bug above).java.util.regex.Pattern/Matcher→ KotlinRegexinPack.kt— clean.java.io→ Okio in DataStore serializers — clean.java.nio.ByteBuffer/ByteOrderbit-twiddling inDeviceOcrOnnxHelper.modelVersion()replaced with bitwise ops — correctly implemented.Exception/warningsremoved from Room entity (OcrQueueTask) — validation moved to ViewModel, avoiding Java serialization in DB. Good architectural improvement.FileInputStream→ Apache Commons CompressZipFilewithSeekableByteChannelfor APK importing — eliminatesZipInputStreamstreaming issues.- The self-import
import xyz.sevive.arcaeaoffline.ui.helpers.ArcaeaFormatters.constantToRatingClassTextinsideArcaeaFormatters.kt:14is redundant but harmless (needed for tests inArcaeaFormattersTest.kt, but the import landed in the wrong file). Could be cleaned up.
Summary
One real bug (rounding mode mismatch), otherwise the PR is well-scoped and correctly identifies which Java APIs cannot be replaced. Fix the rounding mode and add a test case covering truncation behavior (e.g., potentialToText(12.056) should equal "12.05") and this is good to merge.

No description provided.