Skip to content

Conversation

@KonerDev
Copy link
Member

@KonerDev KonerDev commented Oct 24, 2025

Features

  • Add sticky scroll setting
  • Add quick line deletion setting

Enhancements

  • Order settings properly
  • Improve some setting descriptions

Bug fixes

  • Fix line spacing being dependant on zoom factor (Now it's a multiplier)
  • Remove txt word wrap setting which was pointless
  • Improve migration logic by applying migration even if version was skipped

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🚨 Pull request needs attention.

Review Summary

Commits Considered (6)
  • 09c5e5d: fix(main): remove unused setting and refactor names
  • dcd8b5a: feat(main): implement MigrationManager for migrating old setting value
  • 303229c: fix(main): improve setting description and fix line spacing issues
  • 1ad69bf: feat(main): add sticky scroll and quick line deletion settings
  • ef0169a: fix(main): reorder settings
  • ee36f92: refactor(main): format SettingsEditorScreen.kt
Files Processed (8)
  • core/main/src/main/java/com/rk/App.kt (4 hunks)
  • core/main/src/main/java/com/rk/libcommons/editor/KarbonEditor.kt (5 hunks)
  • core/main/src/main/java/com/rk/settings/MigrationManager.kt (1 hunk)
  • core/main/src/main/java/com/rk/settings/Settings.kt (4 hunks)
  • core/main/src/main/java/com/rk/tabs/EditorTab.kt (1 hunk)
  • core/main/src/main/java/com/rk/xededitor/ui/screens/settings/editor/EditorFontScreen.kt (1 hunk)
  • core/main/src/main/java/com/rk/xededitor/ui/screens/settings/editor/SettingsEditorScreen.kt (10 hunks)
  • core/resources/src/main/res/values/strings.xml (3 hunks)
Actionable Comments (1)
  • core/main/src/main/java/com/rk/settings/MigrationManager.kt [18-28]

    maintainability: "Consolidate version tracking preference."

Skipped Comments (3)
  • core/main/src/main/java/com/rk/settings/MigrationManager.kt [12-12]

    maintainability: "Future migration versioning."

  • core/main/src/main/java/com/rk/xededitor/ui/screens/settings/editor/SettingsEditorScreen.kt [283-284]

    enhancement: "Review minimum line spacing value."

  • core/main/src/main/java/com/rk/xededitor/ui/screens/settings/editor/SettingsEditorScreen.kt [359-366]

    maintainability: "Consider encapsulating helper function."

Comment on lines 18 to 28
val prefs = context.getSharedPreferences("migration_prefs", Context.MODE_PRIVATE)
val lastVersion = prefs.getInt("last_version_code", 0)

if (lastVersion == CURRENT_VERSION) return

// Line spacing migration to multiplier
if (lastVersion == 0 && Settings.line_spacing == 0f) {
Settings.line_spacing = 1f
}

prefs.edit { putInt("last_version_code", CURRENT_VERSION) }

Choose a reason for hiding this comment

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

The MigrationManager uses migration_prefs and the key "last_version_code" to track the last applied migration version. However, Settings.kt also defines var lastVersionCode by CachedPreference("last_version_code", -1L). This creates two separate preferences for tracking a "last version code" with the same key name but in different preference files. This could lead to confusion or unexpected behavior if both were intended to track the same concept. Consider consolidating the version tracking into a single, clearly defined preference.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • e85ae3b: Merge branch 'main' into feat/add-settings
Files Processed (8)
  • core/main/src/main/java/com/rk/App.kt (4 hunks)
  • core/main/src/main/java/com/rk/libcommons/editor/KarbonEditor.kt (5 hunks)
  • core/main/src/main/java/com/rk/settings/MigrationManager.kt (1 hunk)
  • core/main/src/main/java/com/rk/settings/Settings.kt (4 hunks)
  • core/main/src/main/java/com/rk/tabs/EditorTab.kt (1 hunk)
  • core/main/src/main/java/com/rk/xededitor/ui/screens/settings/editor/EditorFontScreen.kt (1 hunk)
  • core/main/src/main/java/com/rk/xededitor/ui/screens/settings/editor/SettingsEditorScreen.kt (10 hunks)
  • core/resources/src/main/res/values/strings.xml (3 hunks)
Actionable Comments (1)
  • core/main/src/main/java/com/rk/settings/MigrationManager.kt [18-19]

    possible bug: "Consolidate version tracking preference."

Skipped Comments (4)
  • core/main/src/main/java/com/rk/settings/MigrationManager.kt [12-12]

    maintainability: "Clarify CURRENT_VERSION update policy."

  • core/main/src/main/java/com/rk/settings/Settings.kt [76-76]

    enhancement: "Review default line spacing value."

  • core/main/src/main/java/com/rk/xededitor/ui/screens/settings/editor/SettingsEditorScreen.kt [283-283]

    enhancement: "Improve line spacing input validation."

  • core/main/src/main/java/com/rk/xededitor/ui/screens/settings/editor/SettingsEditorScreen.kt [359-366]

    maintainability: "Consider scope of reapplyEditorSettings function."

Comment on lines 18 to 19
val prefs = context.getSharedPreferences("migration_prefs", Context.MODE_PRIVATE)
val lastVersion = prefs.getInt("last_version_code", 0)

Choose a reason for hiding this comment

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

The MigrationManager introduces its own migration_prefs and a last_version_code key. However, Settings.kt already defines lastVersionCode using a CachedPreference with the same key. This creates two distinct preference entries for tracking the application's version, which can lead to inconsistencies or make it unclear which version is the authoritative one for migration purposes. It would be more robust to consolidate version tracking into a single source, ideally leveraging the existing Settings.lastVersionCode.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh no... How could this happen to me, it seems like such a migration system was already implemented

@KonerDev KonerDev marked this pull request as draft October 24, 2025 18:39
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🚨 Pull request needs attention.

Review Summary

Commits Considered (2)
  • e52a8d8: Merge remote-tracking branch 'origin/feat/add-settings' into feat/add-settings
  • dd9df28: fix(main): use existing UpdateManager instead of duplicate implementation
Files Processed (2)
  • core/main/src/main/java/com/rk/App.kt (3 hunks)
  • core/main/src/main/java/com/rk/UpdateManager.kt (2 hunks)
Actionable Comments (1)
  • core/main/src/main/java/com/rk/UpdateManager.kt [48-48]

    possible bug: "Implement migration for line spacing setting."

Skipped Comments (2)
  • core/main/src/main/java/com/rk/App.kt [95-95]

    bug: "Correct typo in font setting name."

  • core/main/src/main/java/com/rk/UpdateManager.kt [14-15]

    best practice: "Add existence check before recursive deletion."

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • 1c25a04: fix(main): improve migration logic
Files Processed (1)
  • core/main/src/main/java/com/rk/UpdateManager.kt (1 hunk)
Actionable Comments (1)
  • core/main/src/main/java/com/rk/UpdateManager.kt [33-35]

    possible issue: "Review impact of clearing user preferences during update."

Skipped Comments (0)

@KonerDev KonerDev marked this pull request as ready for review October 24, 2025 18:54
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

LGTM!

Review Summary

Commits Considered (1)
  • b66fd17: fix(main): improve migration logic
Files Processed (1)
  • core/main/src/main/java/com/rk/UpdateManager.kt (1 hunk)
Actionable Comments (0)
Skipped Comments (1)
  • core/main/src/main/java/com/rk/UpdateManager.kt [14-16]

    readability: "Simplify file deletion logic by removing redundant existence check."

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

LGTM!

Review Summary

Commits Considered (1)
  • a03d45e: fix(main): improve migration logic
Files Processed (1)
  • core/main/src/main/java/com/rk/UpdateManager.kt (1 hunk)
Actionable Comments (0)
Skipped Comments (1)
  • core/main/src/main/java/com/rk/UpdateManager.kt [33-38]

    maintainability: "Use named constants for version codes in migration logic."

@Xed-Editor Xed-Editor deleted a comment from github-actions bot Oct 24, 2025
@github-actions
Copy link

github-actions bot commented Oct 24, 2025

PR Summary

Implemented new settings for sticky scroll and quick line deletion, enhancing the editor's functionality. This PR also includes significant improvements to the settings management, such as proper ordering of settings, refined descriptions, and robust migration logic to handle updates across different app versions. Additionally, it addresses a bug where line spacing was dependent on the zoom factor, now making it a multiplier, and removes the redundant txt word wrap setting.

Changes

File Summary
core/main/src/main/java/com/rk/App.kt Corrected a typo in the FontCache.loadFont call, changing Settings.is_selected_font_assest to Settings.is_selected_font_asset to ensure consistent font loading based on the correct setting name.
core/main/src/main/java/com/rk/UpdateManager.kt Improved the application's update migration logic by introducing specific migration steps for older versions. It now clears preferences for versions up to 40L and sets line_spacing to 1f for versions up to 66L, ensuring smoother transitions and data consistency across updates.
core/main/src/main/java/com/rk/libcommons/editor/Editor.kt Integrated new editor settings for sticky scroll and quick line deletion by updating props.stickyScroll and props.deleteEmptyLineFast. The line spacing mechanism was refactored from lineSpacingExtra to lineSpacingMultiplier, and several setting variable names were updated for consistency, including wordwrap, is_selected_font_asset, and textmate_suggestion.
core/main/src/main/java/com/rk/settings/Settings.kt Introduced new settings sticky_scroll and quick_deletion with default false values. Several existing setting names were refactored for consistency (e.g., readOnlyByDefault to read_only_default, wordwrap to word_wrap). The word_wrap_for_text setting was removed, and the default line_spacing was changed from 0f to 1f.
core/main/src/main/java/com/rk/tabs/EditorTab.kt Updated the editorState.editable assignment to use the consistently named Settings.read_only_default instead of the old Settings.readOnlyByDefault, aligning with the refactored settings.
core/main/src/main/java/com/rk/xededitor/ui/screens/settings/editor/EditorFontScreen.kt Corrected a typo in the font asset setting, changing Settings.is_selected_font_assest to Settings.is_selected_font_asset when saving the selected font, ensuring the correct preference is stored.
core/main/src/main/java/com/rk/xededitor/ui/screens/settings/editor/SettingsEditorScreen.kt Added UI toggles for 'Enable sticky scroll' and 'Enable quick line deletion'. The settings screen was reordered for better organization, and the txt_word_wrap setting UI was removed. Line spacing validation was improved, and a new reapplyEditorSettings() function was introduced to centralize editor setting updates.
core/resources/src/main/res/values/strings.xml Added new string resources for 'Enable sticky scroll' and 'Enable quick line deletion', including their descriptions. The description for 'Line spacing' was updated to line_spacing_desc, and the description for 'Tab size' was also refined for clarity.

autogenerated by presubmit.ai

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🚨 Pull request needs attention.

Review Summary

Commits Considered (13)
  • 554049e: Merge branch 'main' into feat/add-settings
  • a03d45e: fix(main): improve migration logic
  • b66fd17: fix(main): improve migration logic
  • 1c25a04: fix(main): improve migration logic
  • e52a8d8: Merge remote-tracking branch 'origin/feat/add-settings' into feat/add-settings
  • dd9df28: fix(main): use existing UpdateManager instead of duplicate implementation
  • e85ae3b: Merge branch 'main' into feat/add-settings
  • 09c5e5d: fix(main): remove unused setting and refactor names
  • dcd8b5a: feat(main): implement MigrationManager for migrating old setting value
  • 303229c: fix(main): improve setting description and fix line spacing issues
  • 1ad69bf: feat(main): add sticky scroll and quick line deletion settings
  • ef0169a: fix(main): reorder settings
  • ee36f92: refactor(main): format SettingsEditorScreen.kt
Files Processed (8)
  • core/main/src/main/java/com/rk/App.kt (1 hunk)
  • core/main/src/main/java/com/rk/UpdateManager.kt (1 hunk)
  • core/main/src/main/java/com/rk/libcommons/editor/Editor.kt (5 hunks)
  • core/main/src/main/java/com/rk/settings/Settings.kt (4 hunks)
  • core/main/src/main/java/com/rk/tabs/EditorTab.kt (1 hunk)
  • core/main/src/main/java/com/rk/xededitor/ui/screens/settings/editor/EditorFontScreen.kt (1 hunk)
  • core/main/src/main/java/com/rk/xededitor/ui/screens/settings/editor/SettingsEditorScreen.kt (10 hunks)
  • core/resources/src/main/res/values/strings.xml (3 hunks)
Actionable Comments (1)
  • core/main/src/main/java/com/rk/settings/Settings.kt [76-76]

    possible bug: "Correct default value for line spacing."

Skipped Comments (5)
  • core/main/src/main/java/com/rk/UpdateManager.kt [14-16]

    best practice: "Add defensive checks for directory existence."

  • core/main/src/main/java/com/rk/UpdateManager.kt [31-38]

    enhancement: "Improve migration logic for version updates."

  • core/main/src/main/java/com/rk/libcommons/editor/Editor.kt [294-294]

    possible bug: "Fix line spacing dependency on zoom factor."

  • core/main/src/main/java/com/rk/xededitor/ui/screens/settings/editor/SettingsEditorScreen.kt [283-284]

    enhancement: "Improve line spacing input validation."

  • core/main/src/main/java/com/rk/xededitor/ui/screens/settings/editor/SettingsEditorScreen.kt [359-366]

    maintainability: "Refactor editor settings application logic."

@RohitKushvaha01 RohitKushvaha01 merged commit d222bd1 into Xed-Editor:main Oct 24, 2025
1 check passed
@KonerDev KonerDev deleted the feat/add-settings branch October 25, 2025 06:39
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