Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(android): remove query img usage #907

Merged
merged 2 commits into from
Oct 28, 2024

Conversation

breautek
Copy link
Contributor

@breautek breautek commented Oct 25, 2024

Will rebase after #906 & #902 is merged.

Platforms affected

Android

Motivation and Context

fixes #891
closes #725
closes #660

This code existed since the beginning of time and it does not appear to be relevant anymore.
Duplicates does not occur, even with using DATA_URL or creating modifications via scaling.

Additionally querying the media store on API 28 and lower requires broad READ_EXTERNAL_STORAGE permission. If we can remove numpics and the usage of queryImgDb then we can make READ/WRITE_EXTERNAL_STORAGE optional.

With this change, on API 29+ no permissions are necessary to use the plugin, except for CAMERA if it's declared (that workaround is still necessary).

On API 28 and lower, WRITE_EXTERNAL_PERMISSION is optional, but will be required if saveToPhotoAlbum option is enabled, which is a change I plan to make in another PR soon.

Additionally, the way it was detecting and attempting to remove duplicate images is dangerous, as media store objects can be inserted at any time by other applications. There is no guarantee that the image selected as the duplicate was actually the duplicate, or if there was a duplicate to begin with.

Description

Removed numpics and all code related to managing numpics

Testing

Manual test on API 24
Paramedic test passes

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@breautek breautek added this to the 8.0.0 milestone Oct 25, 2024
@breautek breautek force-pushed the refactor/remove-query-img-usage branch 2 times, most recently from c181067 to 1ad86f6 Compare October 28, 2024 15:44
@breautek breautek force-pushed the refactor/remove-query-img-usage branch from 1ad86f6 to 3617e39 Compare October 28, 2024 15:47
@breautek breautek requested a review from erisu October 28, 2024 16:16
@breautek breautek marked this pull request as ready for review October 28, 2024 16:16
Copy link
Member

@erisu erisu left a comment

Choose a reason for hiding this comment

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

LGTM

  • Tested Mobile Spec
  • Tested getPicture with
    • sourceType=CAMERA, destinationType=DATA_URL
    • sourceType=CAMERA, destinationType=DATA_URL, saveToPhotoAlbum=true

@breautek breautek merged commit c208754 into apache:master Oct 28, 2024
14 of 15 checks passed
@breautek breautek deleted the refactor/remove-query-img-usage branch October 28, 2024 16:32
KarinBerg added a commit to MobisysGmbH/mobisys-cordova-plugin-camera that referenced this pull request Feb 4, 2025
* chore: bump plugin version 7.0.0-dev (apache#845)
* dep(dev)!: bump @cordova/eslint-config@5.0.0 (apache#846)
* dep(dev)!: bump @cordova/eslint-config@5.0.0
* chore: apply automatic lint fix
* feat(android)!: Android 13 support (apache#844)
* feat(android)!: Android 13 support
* refactor(android): simplify getPermissions logic
* feat(android)!: bump cordova-android requirement to >=12.0.0
* feat(android): update saveAlbumPermission to include Android 9 and below use case

---------

Co-authored-by: ochakov <evgeny@ochakov.com>

* chore: Update SUPPORT_QUESTION.md template (apache#849)

* fix!: remove deprecated platforms (apache#848)

* chore: remove windows/osx from plugin.xml (apache#850)

* ci(gh-action): sync with paramedic configs (apache#851)

* release(camera-v7.0.0): updated version and RELEASENOTES.md

* chore: bump version 7.0.1-dev

* ci(android): Update Android CI to be compatible with cordova-android@13 (apache#890)

* chore: Added npmrc

* ci: sync workflow with paramedic (apache#895)

* chore: Update eslint config to 5.1.0 (apache#898)

* chore: Update package to 8.0.0-dev (apache#899)

* Remove media permissions to make complaint with Android 14 requirements (apache#889)

Co-authored-by: Ravi Yakasiri <ravi.yakasiri@planonsoftware.com>

* fix(android): Isolate provider access to a subdirectory (apache#901)

* fix(android): Use VERSION_CODES instead of hard-coded API literals (apache#904)

* fix(android): improper cache path construction during image manipulation (apache#905)

* fix(android): Improper serialization of image uri in save instance state (apache#903)

* fix(android): Return data uris as an URI (apache#910)

* fix: return content uris when possible when selecting from gallery (apache#902)

* fix(browser): Make data uri be returned as actual URI strings (apache#912)

* fix(ios): Sync camera API return to match Android changes (apache#911)

* refactor(android): replace image path usage with image uris (apache#906)

* refactor(android): clean up image file path usages

* removed references of image paths in log messages

* refactor(android): remove query img usage (apache#907)

* refactor: remove unnecessary duplicate image checks and queryImgDb usage

* remove unused imageType parameter, because it's a private API anyway

* docs: Revisions for v8 public API changes with the return string formats of getPicture (apache#913)

* refactor(android): Make WRITE_EXTERNAL_STORAGE optional (apache#909)

* refactor(android): Rework permission management to make WRITE_EXTERNAL_STORAGE optional

* removed unused getPermissions API

* Proper error if WRITE_EXTERNAL_STORAGE is required but missing the declaration

* removed obsolete hasPermissions API

* fix: Remove WRITE_EXTERNAL_PERMISSION (apache#915)

* deprecation: allowEdit (apache#914)

* deprecation: allowEdit

* applied suggestions to verbiage

* chore: version 8.0.0

* chore: 8.0.1-dev

* chore: remove trailing whitespace (apache#921)

* Change "allowedPublishingBranches" from "refs/heads/master" to "refs/heads/release"

* ci: Publish only the file "mobisys-internal-cordova-plugin-camera-*.tgz" to AzureDevOps

* ci: Use "release/v8" of "devops-templates"

* Add new section "Branches" to the README.md

---------

Co-authored-by: エリス <erisu@users.noreply.github.com>
Co-authored-by: ochakov <evgeny@ochakov.com>
Co-authored-by: jcesarmobile <jcesarmobile@gmail.com>
Co-authored-by: Erisu <erisu@apache.org>
Co-authored-by: Norman Breau <norman@breautek.com>
Co-authored-by: ravi-yk <107058879+ravi-yk@users.noreply.github.com>
Co-authored-by: Ravi Yakasiri <ravi.yakasiri@planonsoftware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants