Skip to content

[PAINTROID - 776] Second instance of app is opened when catrobat image is opened from files#146

Open
this-is-varunxyz wants to merge 1 commit intoCatrobat:developfrom
this-is-varunxyz:fix/PAINTROID-776-open-with-feature
Open

[PAINTROID - 776] Second instance of app is opened when catrobat image is opened from files#146
this-is-varunxyz wants to merge 1 commit intoCatrobat:developfrom
this-is-varunxyz:fix/PAINTROID-776-open-with-feature

Conversation

@this-is-varunxyz
Copy link

@this-is-varunxyz this-is-varunxyz commented Feb 6, 2026

Jira Ticket: PAINTROID-776
Refactorings and Bug Fixes
Summary of Changes

This PR resolves the issue where opening an image from an external file manager (via "Open with") would launch a duplicate instance of the app. It also implements the necessary native bridge to read and load the image data from secure Android URIs.
Technical Details

AndroidManifest.xml: Changed launchMode to singleTask. This ensures that if the app is already running, a new intent brings the existing task to the front instead of spawning a new window.

MainActivity.kt:

    Overrode onNewIntent to capture file intents when the app is resumed from the background.

    Extended the file_handler MethodChannel with a getFileBytes method. This uses ContentResolver to read secure content:// URIs, which standard Dart file I/O cannot access.

Flutter Implementation:

    main.dart: Now checks for an initial file URI immediately at startup and passes it to the App widget.

    landing_page.dart: Added a lifecycle listener. When the app resumes, it checks for a new file URI, fetches the image bytes via the native bridge, decodes the image, and loads it directly onto the canvas.

Checklist
Your checklist for this pull request

[x] Include the name of the Jira ticket in the PR’s title

[x] Add the link to the ticket in Jira in the description of the PR

[x] Include a summary of the changes plus the relevant context

[x] Choose the proper base branch (develop)

[x] Confirm that the changes follow the project’s coding guidelines (Wiki)

[x] Verify that the changes generate no compiler or linter warnings

[x] Perform a self-review of the changes

[x] Verify to commit no other files than the intentionally changed ones

[x] Include reasonable and readable tests verifying the added or changed behavior (Verified manually via "Open with" scenarios on Android)

[x] Confirm that new and existing tests pass locally

[x] Check that the commits’ message style matches the [project’s guideline](https://github.com/Catrobat/Catroid/wiki/Commit-Message-Guidelines)

[x] Verify that your changes do not have any conflicts with the base branch

[ ] After the PR, verify that all CI checks have passed

[ ] Add new information to the [Wiki](https://github.com/Catrobat/Paintroid-Flutter/wiki) (N/A for this bug fix)

@this-is-varunxyz this-is-varunxyz force-pushed the fix/PAINTROID-776-open-with-feature branch from 1ac939a to 2610a60 Compare February 6, 2026 10:34
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.

1 participant