Refactor media-projection & screenshot handling, improve accessibility and command parsing, add app mappings and tests#61
Merged
Android-PowerUser merged 1 commit intocodex/analyze-technical-debt-and-complexity-o6bm9pfrom Mar 26, 2026
Conversation
There was a problem hiding this comment.
This PR implements code refactoring and cleanup focused on improving code organization and readability. The changes extract helper methods, improve null safety checks, and remove unnecessary comments. The refactoring maintains the existing functionality while making the code more maintainable. No blocking defects were found - the code has proper error handling, state management, and follows good practices.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
d9bd498
into
codex/analyze-technical-debt-and-complexity-o6bm9p
1 check passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
MainActivityandScreenCaptureService.Description
MainActivityto encapsulate MediaProjection initialization and result handling viainitializeMediaProjection,handleMediaProjectionResult,handleWebRtcMediaProjectionResult,handleScreenshotRequest, andhandleScreenshotResult, and to register permission/screenshot receivers viaregisterPermissionLaunchersandregisterScreenshotReceivers.TrialStateDialogs,PaymentMethodDialog, andApiKeyDialogSection, added keyboard visibility listener setup, and exposed media-projection/accessibility state flows (_isMediaProjectionPermissionGranted,_isAccessibilityServiceEnabled) with improved logging.ScreenOperatorAccessibilityServiceby centralizing root-node null checks intocurrentRootNodeOrHandleMissing, avoiding NPEs and ensuring command queue processing is scheduled safely.PhotoReasoningScreenandPhotoReasoningViewModelto avoid duplicate initialization, added helper functions (appendUserAndPendingModelMessages,appendErrorMessage,clearStaleErrorState,routeProviderSpecificReasoning,reasonInLiveMode,reasonInRegularMode,buildPromptWithScreenInfo), improved offline/live reasoning checks, safer image loading, and more robust error handling and logging.AppNamePackageMapperto use a new internalAppMappingsobject for variations/manual mappings and added normalization/query helpers to improve accuracy and caching.CommandParserbuffer handling with synchronized methods, better logging vialogCommandDetails, and added a unit test fileCommandParserTest.ktto validate parsing and buffer semantics.data_extraction_rules.xmlto include/exclude common backup domains and small cleanups/organizing imports across changed files.Testing
./gradlew testand the newCommandParserTestsuite passed successfully../gradlew assembleDebugand reported successful build artifacts creation.Codex Task