Skip to content

[image_picker] Refactor the C++ code #353

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

Merged
merged 3 commits into from
Apr 15, 2022

Conversation

swift-kim
Copy link
Member

@swift-kim swift-kim commented Apr 11, 2022

Part of the code refactoring project.

image_picker_tizen_plugin.cc

  • Create a class PermissionManager as a replacement for CheckPermissionAndPickContent.
    • The class is a wrapper of the Tizen PPM API and provides two methods: CheckPermission and RequestPermssion.
    • Note that RequestPermssion is a blocking method.
    • The code will be shared by multiple packages. The CheckPermission method is not used by this package but is for use by other packages.
    • The return types of the methods are PermissionStatus and PermissionResult respectively.
    • The methods return kAllow or kAllowForever when compiled for TV.
  • Use the GetValueFromEncodableMap template function to process method call arguments.
  • Remove SetContentMimeType and let PickContent take mime_type as an argument.
  • Minor cleanups.
    • SendResultWithSuccess/SendResultWithErrorSendResult/SendErrorResult
    • Organize error codes and error messages in a consistent manner.
    • Move the non-public implementation into an anonymous namespace.

image_resize.cc

  • Simplify the method Resize and move many of its parts to individual methods DecodeImage, TransformImage, and EncodeImage as appropriate. For example, the decode handle is created by DecodeImage but not Resize.
  • Rename local variables in a consistent manner to make the code more readable.
  • Create a private method IsValidQuality.
  • Always use an explicit type uint32_t instead of unsigned int.
  • Minor cleanups.
    • Format log messages consistently.
    • Inline the implementation of SetSize in the definition.
    • Remove a TODO regarding image_util_decode_set_colorspace.

@bbrto21
Copy link
Contributor

bbrto21 commented Apr 14, 2022

  • The code will be shared by multiple packages. The CheckPermission method is not used by this package but is for use by other packages.

How do you plan to support multiple packages?

@swift-kim
Copy link
Member Author

How do you plan to support multiple packages?

The files will be copied to each package's (camera and geolocator) directory.

@swift-kim swift-kim merged commit 32ff0b5 into flutter-tizen:master Apr 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants