Skip to content

Improve logging by placing logs in core functions#96

Merged
tuancoltech merged 4 commits into
mainfrom
feat/improve_logging
Jul 30, 2025
Merged

Improve logging by placing logs in core functions#96
tuancoltech merged 4 commits into
mainfrom
feat/improve_logging

Conversation

@tuancoltech

@tuancoltech tuancoltech commented Jul 16, 2025

Copy link
Copy Markdown
Contributor

Description

Improve logging by placing logs in core functions

Ticket

https://app.asana.com/1/1207783906637200/project/1207819682524134/task/1208764211704004

Summary by CodeRabbit

  • Chores
    • Added debug and error logging throughout the app to improve traceability of key actions, method calls, and error conditions.
    • Standardized log tags across multiple components for consistent log output.
    • Minor renaming of internal constants for improved code clarity.
    • No changes to app functionality or user interface.

@tuancoltech tuancoltech marked this pull request as draft July 16, 2025 15:09
@tuancoltech tuancoltech force-pushed the feat/improve_logging branch from a74b0de to 322196c Compare July 17, 2025 05:37
@tuancoltech tuancoltech marked this pull request as ready for review July 17, 2025 05:40
@tuancoltech tuancoltech force-pushed the feat/improve_logging branch from 322196c to 2bb08f0 Compare July 17, 2025 05:44
@tuancoltech tuancoltech requested review from hieuwu and shubertm July 17, 2025 05:44
@tuancoltech tuancoltech force-pushed the feat/improve_logging branch from 2bb08f0 to 49ad4cb Compare July 17, 2025 14:55
@tuancoltech

Copy link
Copy Markdown
Contributor Author

@coderabbitai Do a code review.

@coderabbitai

coderabbitai Bot commented Jul 18, 2025

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

I'll conduct a code review of PR #96 for you. Let me first gather information about the changes made in this pull request.


🏁 Script executed:

#!/bin/bash
# Get information about the PR and its changes
gh pr view 96 --json title,body,files,additions,deletions,commits

# Get the list of changed files
gh pr diff 96 --name-only

# Get the actual diff to see what changes were made
gh pr diff 96

Length of output: 29265


@tuancoltech I've reviewed PR #96 which adds logging to improve debugging capabilities across the ARK Memo application. Here's my comprehensive code review:

Positive Aspects

  1. Consistent logging pattern: Good use of class-specific TAG constants (e.g., tag = "ArkMediaPlayerImpl")
  2. Appropriate log levels: Debug logs for normal operations, error logs for exceptions
  3. Comprehensive coverage: Logging added to key functions across media, repository, and UI layers
  4. Minimal invasiveness: Changes don't affect core functionality, only add observability

🔍 Detailed Analysis

Media Layer (ArkAudioRecorderImpl.kt, ArkMediaPlayerImpl.kt)

  • ✅ Good logging of media operations (start, pause, resume, stop)
  • ✅ Exception handling with error logs
  • ✅ Consistent TAG usage

Repository Layer (NotesRepoHelper.kt, *NotesRepo.kt)

  • ✅ Logging of CRUD operations
  • ✅ Resource information included in logs
  • ✅ Error handling improvements

UI Layer (ViewModels, Fragments, Activities)

  • ✅ Side effect handling logged
  • ✅ User interaction tracking
  • ✅ State change logging

⚠️ Areas for Improvement

  1. Potential Data Exposure in Logs:

    // In TextNotesRepo.kt
    Log.d(TEXT_REPO, "write note: $note")

    This could log sensitive note content. Consider logging only metadata:

    Log.d(TEXT_REPO, "write note with id: ${note.resource?.id}")
  2. Performance Consideration:

    // In ArkMediaPlayerViewModel.kt
    private fun computeFftMagnitude(fft: ByteArray?): Float {
        Log.d(tag, "computeFftMagnitude") // Called frequently during audio processing

    This function is called frequently during audio processing. Consider removing or using a more efficient logging approach.

  3. Missing Import Statement:

    // In ArkMediaPlayerImpl.kt - missing import
    import android.util.Log

    Some files may be missing the Log import (though compilation would catch this).

  4. Inconsistent TAG Definition:
    Some files use string literals while others use constants. Consider standardizing:

    companion object {
        private const val TAG = "ArkMediaPlayerImpl"
    }

🚀 Recommendations

  1. Security: Review logged data to ensure no sensitive information (note content, user data) is exposed in production logs.

  2. Performance: Consider using conditional logging for high-frequency operations:

    if (BuildConfig.DEBUG) {
        Log.d(tag, "computeFftMagnitude")
    }
  3. Log Message Quality: Some log messages could be more descriptive:

    // Instead of just "init"
    Log.d(tag, "Initializing media player with path: $path")
  4. ProGuard Configuration: Ensure release builds strip debug logs by adding to proguard-rules.pro:

    -assumenosideeffects class android.util.Log {
        public static int d(...);
        public static int v(...);
    }
    

📊 Overall Assessment

This is a solid logging improvement that will significantly help with debugging and monitoring. The implementation is consistent and follows Android logging best practices. The main concerns are around potential data exposure and performance in high-frequency operations.

Recommendation: ✅ Approve with minor suggestions - The logging additions are valuable for debugging and the implementation is well-done. Consider addressing the data exposure and performance concerns mentioned above.

🐰
(◕‿◕)
Thoughtful rabbit appreciating the systematic approach to improving observability!

Comment thread app/src/main/java/dev/arkbuilders/arkmemo/media/ArkMediaPlayerImpl.kt Outdated
Comment thread app/src/main/java/dev/arkbuilders/arkmemo/repo/NotesRepoHelper.kt Outdated
@@ -202,6 +206,7 @@ class MainActivity : AppCompatActivity(R.layout.activity_main) {

companion object {
private const val CURRENT_FRAGMENT_TAG = "current fragment tag"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private const val CURRENT_FRAGMENT_TAG = "current fragment tag"
private const val CURRENT_FRAGMENT_TAG = "CurrentFragment"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shubertm This change wasn't made on this PR, and unrelated.
However, I still updated the value to remove whitespaces.

Comment thread app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/ArkRecorderViewModel.kt Outdated
Comment thread app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/NotesViewModel.kt Outdated
note: Note,
parentResId: ResourceId? = null,
) {
Log.d(tag, "add note: $note")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to print note resource data e.g; id or name

Comment thread app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/QRViewModel.kt Outdated
Comment thread app/src/main/java/dev/arkbuilders/arkmemo/ui/views/WaveView.kt Outdated
@coderabbitai

coderabbitai Bot commented Jul 22, 2025

Copy link
Copy Markdown

Walkthrough

This update introduces debug and error logging statements throughout various classes in the project, primarily for tracing method invocations, key events, and error occurrences. Logging tags are standardized using constants or companion objects. No changes are made to the core logic, control flow, or error handling of the affected classes.

Changes

File(s) Change Summary
Media classes
app/src/main/java/dev/arkbuilders/arkmemo/media/ArkAudioRecorderImpl.kt, app/src/main/java/dev/arkbuilders/arkmemo/media/ArkMediaPlayerImpl.kt
Added debug logs to lifecycle and control methods; standardized log tags with companion object constants; added error logging on exceptions; no logic changes.
Repository helpers and repos
app/src/main/java/dev/arkbuilders/arkmemo/repo/NotesRepoHelper.kt, app/src/main/java/dev/arkbuilders/arkmemo/repo/graphics/GraphicNotesRepo.kt, app/src/main/java/dev/arkbuilders/arkmemo/repo/text/TextNotesRepo.kt, app/src/main/java/dev/arkbuilders/arkmemo/repo/voices/VoiceNotesRepo.kt
Inserted debug logs at start of key functions (write, readStorage, persist, delete); added warning/error logs for null or exception cases; introduced TAG constants for log standardization.
UI activities and fragments
app/src/main/java/dev/arkbuilders/arkmemo/ui/activities/MainActivity.kt, app/src/main/java/dev/arkbuilders/arkmemo/ui/fragments/ArkMediaPlayerFragment.kt, app/src/main/java/dev/arkbuilders/arkmemo/ui/fragments/ArkRecorderFragment.kt, app/src/main/java/dev/arkbuilders/arkmemo/ui/fragments/NotesFragment.kt
Added debug logs tracing permission results, path selection, side effect handling, and notes loading; introduced or updated TAG constants; renamed one constant for naming consistency.
UI viewmodels
app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/ArkMediaPlayerViewModel.kt, app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/ArkRecorderViewModel.kt, app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/GraphicNotesViewModel.kt, app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/NotesViewModel.kt, app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/QRViewModel.kt
Added debug logs at start of key methods for tracing execution; introduced companion objects with TAG constants for logging; no logic changes.
UI views
app/src/main/java/dev/arkbuilders/arkmemo/ui/views/WaveView.kt
Added debug log to computeWave method; introduced TAG constant for logging.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~8 minutes

Poem

In the warren of code where the log bunnies dwell,
Debug prints now echo, their stories to tell.
With tags all aligned and errors in sight,
The burrow is brighter, each hop brings delight.
So let the logs chatter, as rabbits approve—
For clarity’s a gift in every dev move!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1120802 and 2342409.

📒 Files selected for processing (1)
  • app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/NotesViewModel.kt (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/NotesViewModel.kt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/improve_logging

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@tuancoltech tuancoltech requested a review from shubertm July 22, 2025 15:36

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🔭 Outside diff range comments (4)
app/src/main/java/dev/arkbuilders/arkmemo/repo/text/TextNotesRepo.kt (1)

63-70: Logging full note contents exposes PII

note.text can contain sensitive user data. Avoid dumping the entire object.

-Log.d(TEXT_REPO, "write note: $note")
+Log.d(TEXT_REPO, "write note title='${note.title}' size=${note.text.length}")

Do the same wherever note bodies are logged.

app/src/main/java/dev/arkbuilders/arkmemo/media/ArkMediaPlayerImpl.kt (1)

57-78: High-frequency methods should avoid unconditional logging
play(), pause(), and particularly seekTo() may fire dozens of times per second while a user scrubs. Repeated Log.d calls can produce noticeable GC pressure on low-end devices. Either:

  1. wrap with if (BuildConfig.DEBUG) or
  2. throttle logging (e.g. only once every N ms).
app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/NotesViewModel.kt (1)

174-181: Potential PII leakage in logs
Logging note titles and resource IDs (add note with title: …) may inadvertently expose user data in release builds. Suggest downgrading to verbose level guarded by BuildConfig.DEBUG or logging only the ID.

app/src/main/java/dev/arkbuilders/arkmemo/repo/NotesRepoHelper.kt (1)

61-77: Persist-properties log may expose note titles
Same privacy concern as in NotesViewModel. Title could contain sensitive data; consider obfuscating or removing in release.

♻️ Duplicate comments (1)
app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/GraphicNotesViewModel.kt (1)

26-27: Align TAG declaration with project-wide pattern

Other view-models now use a companion-object TAG. Adopt the same to avoid divergent style.

-        private val tag = "GraphicNotesViewModel"
+        companion object {
+            private const val TAG = "GraphicNotesViewModel"
+        }
🧹 Nitpick comments (16)
app/src/main/java/dev/arkbuilders/arkmemo/ui/views/WaveView.kt (1)

51-51: Guard high-frequency debug log behind a verbosity check

computeWave is invoked for every visual frame; unconditional Log.d will allocate the interpolated string each call, impacting UI thread performance.
Wrap the call in Log.isLoggable(TAG, Log.DEBUG) (or if (BuildConfig.DEBUG)) to avoid work when debug logs are disabled.

-        Log.d(TAG, "computeWave amplitude: $amplitude height: $height")
+        if (Log.isLoggable(TAG, Log.DEBUG)) {
+            Log.d(TAG, "computeWave amplitude: $amplitude height: $height")
+        }
app/src/main/java/dev/arkbuilders/arkmemo/repo/voices/VoiceNotesRepo.kt (1)

61-62: Wrap low-value debug logs with BuildConfig.DEBUG and enrich the message
Both write and readStorage are on critical I/O paths and may be invoked many times; in release builds the extra string allocations still happen even if the Logcat is disabled by policy. Guarding them avoids that overhead and lets you keep the noise out of production logs. While touching the lines, include some context (note id / list size) to make the entry actually useful during debugging.

-import android.util.Log
+import android.util.Log
+import dev.arkbuilders.arkmemo.BuildConfig-            Log.d(VOICES_REPO, "write")
+            if (BuildConfig.DEBUG) {
+                Log.d(VOICES_REPO, "write title=${note.title} size=$size")
+            }-                Log.d(VOICES_REPO, "readStorage")
+                if (BuildConfig.DEBUG) {
+                    Log.d(VOICES_REPO, "readStorage count=${root.listFiles(VOICE_EXT).size}")
+                }

Also applies to: 104-105

app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/QRViewModel.kt (2)

31-33: TAG definition is good – add @JvmField for proguard friendliness
Marking the constant @JvmField removes the synthetic getter, slightly reducing method count and preventing pro-guard from stripping usages.

-        companion object {
-            private const val TAG = "QRViewModel"
-        }
+        companion object {
+            @JvmField
+            internal const val TAG = "QRViewModel"
+        }

39-40: Guard debug logs & supply context
Same rationale as in the repo layer: avoid work in production and make the message self-describing.

-            Log.d(TAG, "generateQRCode")
+            if (BuildConfig.DEBUG) Log.d(TAG, "generateQRCode text.length=${text.length}")-            Log.d(TAG, "saveQRCodeImage")
+            if (BuildConfig.DEBUG) Log.d(TAG, "saveQRCodeImage text.length=${text.length}")

Also applies to: 56-57

app/src/main/java/dev/arkbuilders/arkmemo/ui/fragments/NotesFragment.kt (1)

318-320: Release-safe logging & better signal
onNotesLoaded runs on every screen open and after every CRUD; unguarded debug logging will appear in Play-store builds unless pro-guard strips it. At minimum:

-import android.util.Log
+import android.util.Log
+import dev.arkbuilders.arkmemo.BuildConfig-        Log.d(TAG, "onNotesLoaded notes.size: ${notes.size}")
+        if (BuildConfig.DEBUG) Log.d(TAG, "onNotesLoaded size=${notes.size}")
app/src/main/java/dev/arkbuilders/arkmemo/ui/fragments/ArkMediaPlayerFragment.kt (1)

103-104: TAG length exceeds 23 chars & log should be debug-guarded
Pre-API-26 devices truncate tags longer than 23 chars. Consider shortening to ArkMediaFragment. Also guard the call:

-        Log.d(TAG, "handleSideEffect: $effect")
+        if (BuildConfig.DEBUG) Log.d(TAG, "sideEffect=$effect")
app/src/main/java/dev/arkbuilders/arkmemo/ui/fragments/ArkRecorderFragment.kt (1)

318-320: Same logging concerns as other files
Guard the log and keep the tag short & consistent.

-        Log.d(TAG, "handlePlaySideEffect: $effect")
+        if (BuildConfig.DEBUG) Log.d(TAG, "playSideEffect=$effect")
app/src/main/java/dev/arkbuilders/arkmemo/media/ArkAudioRecorderImpl.kt (2)

17-18: Prefer a companion-object TAG constant for consistency

Most other classes in this PR switched to

companion object { private const val TAG = "..." }```  
Using a `val tag` instance property breaks that convention and creates an extra field per object.  

```diff
-    private val tag = "ArkAudioRecorderImpl"
+    companion object {
+        private const val TAG = "ArkAudioRecorderImpl"
+    }

39-55: Guard debug logs with isLoggable / BuildConfig.DEBUG

start(), pause(), resume() and reset() are user-driven, but maxAmplitude() may be polled many times per second.
Unconditionally emitting Log.d() can spam logcat in production builds.

-Log.d(TAG, "start")
+if (Log.isLoggable(TAG, Log.DEBUG)) Log.d(TAG, "start")

Apply the same pattern to the other debug logs in this class.

Also applies to: 75-76, 84-85

app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/ArkRecorderViewModel.kt (1)

3-4: Minor consistency nit

Follow the same companion-object TAG format suggested elsewhere to keep the codebase uniform.

-companion object {
-    private const val TAG = "ArkRecorderViewModel"
-}
+companion object {
+    private const val TAG = "ArkRecorderViewModel"
+}

Also applies to: 42-45

app/src/main/java/dev/arkbuilders/arkmemo/media/ArkMediaPlayerImpl.kt (1)

27-33: Consider guarding verbose logs with BuildConfig.DEBUG
init() can be called repeatedly during screen rotation or playlist changes, so these debug lines will end up in release builds and potentially pollute logcat.

-Log.d(TAG, "init")
+if (BuildConfig.DEBUG) Log.d(TAG, "init")

Apply the same guard to every other debug call in this class.

Also applies to: 50-52

app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/NotesViewModel.kt (2)

52-68: Release-build spam risk
init and readAllNotes are executed on every app launch; consider wrapping these Log.d calls with BuildConfig.DEBUG to keep production logs clean.


117-118: Log message uses enum name; prefer full object for clarity
result.name collapses both success branches (SUCCESS_NEW, SUCCESS_UPDATED) to very similar strings. Using the enum itself or a descriptive sentence improves greppability.

app/src/main/java/dev/arkbuilders/arkmemo/repo/graphics/GraphicNotesRepo.kt (2)

83-89: Path names in logs can leak user directories
initial resource name is ${tempPath.name} is fine, but elsewhere full paths (path) are logged. Consider trimming to fileName only or guarding with BuildConfig.DEBUG.


118-126: Guard repository read spam
readStorage() is invoked every refresh; the Log.d call will fire for every action. Recommend if (BuildConfig.DEBUG) to avoid noisy release logs.

app/src/main/java/dev/arkbuilders/arkmemo/repo/NotesRepoHelper.kt (1)

50-53: Consider moving Log.d(TAG, "init") behind debug flag
Minor, but aligns with other suggestions across modules.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 132d4f0 and a39de21.

📒 Files selected for processing (16)
  • app/src/main/java/dev/arkbuilders/arkmemo/media/ArkAudioRecorderImpl.kt (3 hunks)
  • app/src/main/java/dev/arkbuilders/arkmemo/media/ArkMediaPlayerImpl.kt (3 hunks)
  • app/src/main/java/dev/arkbuilders/arkmemo/repo/NotesRepoHelper.kt (6 hunks)
  • app/src/main/java/dev/arkbuilders/arkmemo/repo/graphics/GraphicNotesRepo.kt (4 hunks)
  • app/src/main/java/dev/arkbuilders/arkmemo/repo/text/TextNotesRepo.kt (3 hunks)
  • app/src/main/java/dev/arkbuilders/arkmemo/repo/voices/VoiceNotesRepo.kt (2 hunks)
  • app/src/main/java/dev/arkbuilders/arkmemo/ui/activities/MainActivity.kt (5 hunks)
  • app/src/main/java/dev/arkbuilders/arkmemo/ui/fragments/ArkMediaPlayerFragment.kt (2 hunks)
  • app/src/main/java/dev/arkbuilders/arkmemo/ui/fragments/ArkRecorderFragment.kt (2 hunks)
  • app/src/main/java/dev/arkbuilders/arkmemo/ui/fragments/NotesFragment.kt (2 hunks)
  • app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/ArkMediaPlayerViewModel.kt (5 hunks)
  • app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/ArkRecorderViewModel.kt (7 hunks)
  • app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/GraphicNotesViewModel.kt (3 hunks)
  • app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/NotesViewModel.kt (6 hunks)
  • app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/QRViewModel.kt (3 hunks)
  • app/src/main/java/dev/arkbuilders/arkmemo/ui/views/WaveView.kt (3 hunks)
🧠 Learnings (12)
app/src/main/java/dev/arkbuilders/arkmemo/ui/fragments/ArkMediaPlayerFragment.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

app/src/main/java/dev/arkbuilders/arkmemo/ui/fragments/NotesFragment.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

app/src/main/java/dev/arkbuilders/arkmemo/repo/text/TextNotesRepo.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

app/src/main/java/dev/arkbuilders/arkmemo/repo/voices/VoiceNotesRepo.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/ArkMediaPlayerViewModel.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/QRViewModel.kt (1)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/GraphicNotesViewModel.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/NotesViewModel.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

app/src/main/java/dev/arkbuilders/arkmemo/repo/graphics/GraphicNotesRepo.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

app/src/main/java/dev/arkbuilders/arkmemo/ui/activities/MainActivity.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

app/src/main/java/dev/arkbuilders/arkmemo/repo/NotesRepoHelper.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/ArkRecorderViewModel.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

🧰 Additional context used
🧠 Learnings (12)
app/src/main/java/dev/arkbuilders/arkmemo/ui/fragments/ArkMediaPlayerFragment.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

app/src/main/java/dev/arkbuilders/arkmemo/ui/fragments/NotesFragment.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

app/src/main/java/dev/arkbuilders/arkmemo/repo/text/TextNotesRepo.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

app/src/main/java/dev/arkbuilders/arkmemo/repo/voices/VoiceNotesRepo.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/ArkMediaPlayerViewModel.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/QRViewModel.kt (1)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/GraphicNotesViewModel.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/NotesViewModel.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

app/src/main/java/dev/arkbuilders/arkmemo/repo/graphics/GraphicNotesRepo.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

app/src/main/java/dev/arkbuilders/arkmemo/ui/activities/MainActivity.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

app/src/main/java/dev/arkbuilders/arkmemo/repo/NotesRepoHelper.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/ArkRecorderViewModel.kt (2)

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

🔇 Additional comments (11)
app/src/main/java/dev/arkbuilders/arkmemo/ui/views/WaveView.kt (1)

71-71: TAG constant extracted – looks good

Introducing a TAG constant satisfies the prior feedback and keeps logging consistent with the rest of the codebase. 👍

app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/ArkMediaPlayerViewModel.kt (1)

79-80: Optional: remove one-shot debug traces after validation

setupVisualizer() and startProgressMonitor() are invoked once per playback session; leaving these logs is probably fine. Just ensure they are compiled out of release builds via ProGuard/R8 rules (-assumenosideeffects class android.util.Log { *; }).

Also applies to: 175-176

app/src/main/java/dev/arkbuilders/arkmemo/repo/text/TextNotesRepo.kt (1)

100-101: Good: added tracing & error log

The lightweight readStorage entry trace and detailed exception log improve debuggability without exposing user data.

Also applies to: 128-129

app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/ArkRecorderViewModel.kt (1)

59-79: Event logs look good

The added logs fire only on explicit UI actions, so the volume is negligible and safe for production.

Also applies to: 111-113, 137-139

app/src/main/java/dev/arkbuilders/arkmemo/media/ArkMediaPlayerImpl.kt (1)

18-21: TAG constant nicely centralised
Using a companion-object constant removes the earlier string‐literal repetition – good catch.

app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/NotesViewModel.kt (1)

47-50: TAG constant added – 👍
Consistent with the rest of the codebase.

app/src/main/java/dev/arkbuilders/arkmemo/repo/graphics/GraphicNotesRepo.kt (1)

152-197: Null-log correctly handled – LGTM
Warning on missing SVG or paths is helpful and already at Log.w; no action needed.

app/src/main/java/dev/arkbuilders/arkmemo/repo/NotesRepoHelper.kt (2)

37-40: TAG constant addition – good consistency


122-138: Deletion path logged – acceptable
File names are already on disk; debug line is reasonable.

app/src/main/java/dev/arkbuilders/arkmemo/ui/activities/MainActivity.kt (2)

45-57: Permission-callbacks logging is fine
Lightweight, fires once.


208-210: Constant rename improves clarity
LGTM.

Comment on lines 73 to 77
supportFragmentManager.onArkPathPicked(this) {
Log.d(ACTIVITY_TAG, "onArkPathPicked path: $it")
memoPreferences.storePath(it.toString())
showFragment(savedInstanceState)
}

@coderabbitai coderabbitai Bot Jul 22, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Full storage path logged – possible privacy issue
onArkPathPicked path: $it prints the absolute directory chosen by the user. On shared devices this leaks personal folder structure. Limit to last path segment or guard with BuildConfig.DEBUG.

🤖 Prompt for AI Agents
In app/src/main/java/dev/arkbuilders/arkmemo/ui/activities/MainActivity.kt
around lines 73 to 77, the log statement prints the full absolute path chosen by
the user, which can expose sensitive directory information. Modify the log to
either only print the last segment of the path or wrap the logging statement
inside a check for BuildConfig.DEBUG to ensure it only logs in debug builds,
preventing privacy leaks on shared devices.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tuancoltech I think @coderabbitai is right here, let's consider this improvement

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shubertm Thank you for supporting this privacy improvement! Here are two concrete approaches @tuancoltech could implement:

Option 1: Log only the directory name

Log.d(ACTIVITY_TAG, "onArkPathPicked path: ${File(it.toString()).name}")

Option 2: Debug-only logging

if (BuildConfig.DEBUG) {
    Log.d(ACTIVITY_TAG, "onArkPathPicked path: $it")
}

Option 3: Both (recommended)

if (BuildConfig.DEBUG) {
    Log.d(ACTIVITY_TAG, "onArkPathPicked path: ${File(it.toString()).name}")
}

Option 3 provides the best privacy protection by only logging in debug builds and limiting the exposed information to just the folder name rather than the full path structure.

🐰💭
(\ /)
( ..)
o
(")(")


🧠 Learnings used
Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:40:19.332Z
Learning: In the ARK-Memo Android app, the notesViewModel.init {} callback properly handles threading by dispatching operations to worker threads, preventing main thread blocking during view restoration.

Learnt from: tuancoltech
PR: ARK-Builders/ARK-Memo#0
File: :0-0
Timestamp: 2025-07-18T05:33:52.353Z
Learning: In the ARK-Memo Android app, TextNotesRepo.findNote() intentionally returns null because text notes don't need special handling during view restoration. This is a design decision to ignore text notes when restoring view state, as users can easily continue editing text notes without complex state recovery mechanisms.

Comment on lines +121 to 123
Log.d(TAG, "computeFftMagnitude")
if (fft == null) return 0f

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

High-frequency log in computeFftMagnitude() may hurt performance

computeFftMagnitude() runs on every Visualizer callback (typically ~20-30 Hz).
Even at DEBUG level this can flood logcat and trigger string allocations.

Wrap the call:

if (Log.isLoggable(TAG, Log.DEBUG)) Log.d(TAG, "computeFftMagnitude")

or guard by BuildConfig.DEBUG.

🤖 Prompt for AI Agents
In
app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/ArkMediaPlayerViewModel.kt
around lines 121 to 123, the Log.d call inside computeFftMagnitude() runs very
frequently and can degrade performance due to excessive logging and string
allocations. To fix this, wrap the Log.d call with a conditional check using
Log.isLoggable(TAG, Log.DEBUG) or guard it with BuildConfig.DEBUG to ensure the
log executes only when debug logging is enabled.

@tuancoltech

Copy link
Copy Markdown
Contributor Author

@shubertm Please re-revew.

private var lastPaintColor = paintColor
private var strokeWidth = Size.TINY.value

private val tag = "GraphicNotesViewModel"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can also be a constant


companion object {
private const val CURRENT_FRAGMENT_TAG = "current fragment tag"
private const val CURRENT_FRAGMENT_TAG = "current_fragment_tag"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to remove "tag" at the end

note: Note,
parentResId: ResourceId? = null,
) {
Log.d(TAG, "add note with title: ${note.title} resId: ${note.resource?.id}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use resource.name for note.title. That should be the actual metadata not the note content

Comment thread app/src/main/java/dev/arkbuilders/arkmemo/ui/viewmodels/NotesViewModel.kt Outdated
@tuancoltech

Copy link
Copy Markdown
Contributor Author

@shubertm Is it ok to merge this now?

@tuancoltech tuancoltech merged commit e353a22 into main Jul 30, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants