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

Add WPMediaUtils and its few dependencies #25

Merged
merged 7 commits into from
Jul 21, 2021

Conversation

wzieba
Copy link
Contributor

@wzieba wzieba commented Jul 20, 2021

This PR focuses on bringing minimal* version of WPMediaUtils and its wrapper.

*minimal I mean without code that is not used by mediapicker package

@anitaa1990 anitaa1990 self-assigned this Jul 20, 2021
@wzieba
Copy link
Contributor Author

wzieba commented Jul 20, 2021

@anitaa1990 Just a heads up - I'll be adding a few comments in a minute for easier review

@anitaa1990
Copy link
Contributor

Thanks for the heads up @wzieba! Let me know when it's good for a review by requesting a review and I'll take a look 👍

Copy link
Contributor Author

@wzieba wzieba left a comment

Choose a reason for hiding this comment

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

@anitaa1990 I've added comments, mostly link to new issues I've created while working on this PR.

I've created a new project (Improving quality of MediaPicker codebase). I moved there issues which are nice-to-have but not completely necessary for first iteration.

I hope that this way it'll be easier to focus/pick issues that are must-have (which are in Extracting MediaPicker and make it a library project).

* [UiString] is a utility sealed class that represents a string to be used in the UI. It allows a string to be
* represented as both string resource and text.
*/
sealed class UiString {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

import java.util.ArrayList;
import java.util.List;

public class WPMediaUtils {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

try {
fileUri = FileProvider.getUriForFile(context, applicationId + ".provider", new File(mediaCapturePath));
} catch (IllegalArgumentException e) {
Log.e(TAG, "Cannot access the file planned to store the new media", e);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +134 to +136
return R.drawable.media_powerpoint;
} else if (MediaUtils.isSpreadsheet(url)) {
return R.drawable.media_spreadsheet;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +3 to +4
<string name="sdcard_title">SD Card Required</string>
<string name="sdcard_message">A mounted SD card is required to upload media</string>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

import android.content.Context
import android.net.Uri

class WPMediaUtilsWrapper(private val context: Context) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -216,6 +216,7 @@ class MediaPickerActivity : LocaleAwareActivity(), MediaPickerListener {
IMAGE_EDITOR_EDIT_IMAGE -> {
data?.let {
val intent = Intent()
// TODO: 20/07/2021 There's a whole ImageEditor module in WPAndroid. Should we import it?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anitaa1990 do you think we should also add ImageEditor to the MediaPicker? If not (or not in the first iteration) we will need to provide some interfaces to glue together MediaPicker and ImageEditor from WPAndroid.

@wzieba wzieba marked this pull request as ready for review July 20, 2021 16:42
Copy link
Contributor

@anitaa1990 anitaa1990 left a comment

Choose a reason for hiding this comment

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

This looks good! Thank you for opening a separate project and issues for us to keep track :shipit:

@@ -216,6 +216,7 @@ class MediaPickerActivity : LocaleAwareActivity(), MediaPickerListener {
IMAGE_EDITOR_EDIT_IMAGE -> {
data?.let {
val intent = Intent()
// TODO: 20/07/2021 There's a whole ImageEditor module in WPAndroid. Should we import it?
Copy link
Contributor

Choose a reason for hiding this comment

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

ImageManager is tightly coupled with the media picker feature 🤔 I'm not really thrilled to migrate that here but maybe we can do the bare minimum and import what is necessary here. Because this class seems to handle everything related to image loading.

But I am wondering what would happen when this is getting merged into the WordPress app. Because almost all of the util classes are being utilised by WordPress (not related to the media picker) so they might have two classes of everything 😬

It might be good to also rename files at some point to ensure that it is very specific to media picker. Not blocking but just something to keep in mind

@anitaa1990 anitaa1990 merged commit bc27da8 into trunk Jul 21, 2021
@anitaa1990 anitaa1990 deleted the issue/19_add_wp_media_utils branch July 21, 2021 05:02
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