-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Implemented Drawing Activity #9394
Conversation
I think commits should split,
will this okay? |
AnkiDroid/src/main/java/com/ichi2/anki/multimediacard/fields/BasicImageFieldController.java
Outdated
Show resolved
Hide resolved
I think these are good (only changed the order)
|
218b03e
to
c94a5f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! One comment regarding the cast to AbstractFlashcardViewer
, the rest are nitpicks
Blocked by #9409
resultData.putExtra(EXTRA_RESULT_WHITEBOARD, savedWhiteboardFileName) | ||
setResult(RESULT_OK, resultData) | ||
} catch (e: FileNotFoundException) { | ||
Timber.e(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timber.e(e) | |
Timber.w(e) |
|
||
private void handleDrawingResult(Uri imageUri) { | ||
if (imageUri == null) { | ||
Timber.e("handleDrawingResult() no image path provided"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timber.e("handleDrawingResult() no image path provided"); | |
Timber.w("handleDrawingResult() no image path provided"); |
|
||
Timber.i("handleDrawingResult() Decoded image: '%s'", drewImagePath); | ||
} catch (IOException e) { | ||
Timber.e(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timber.e(""); | |
Timber.w(e); |
@@ -22,6 +22,7 @@ | |||
--> | |||
<!-- App name --> | |||
<string name="app_name" comment="The name of the app">AnkiDroid</string> | |||
<string name="drawing">Drawing</string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this to 01-core
c94a5f1
to
e270e3b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much nicer!
|
||
package com.ichi2.anki; | ||
|
||
public interface WhiteboardMethods { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could do with a better name and javadocs, but this is exactly what we need code-wise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/**
* WhiteboardMethods interface will provide abstract methods to override by abstractflascardviewer class
* for handling multi touch while whiteboard is on.
*/
public interface WhiteboardMultiTouchMethods {
see this, is this doc correct?
it would be great if you could suggest me some names...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds great!
Slight change to the documentation. You want to try to avoid referencing a concrete implementation for an interface (although it's often useful to provide an example).
/**
* Provides callbacks for multi touch handling on a whiteboard
*/
public interface WhiteboardMultiTouchMethods {
unblocked, awaiting de-conflict |
e270e3b
to
667b9a5
Compare
52c2f0d
to
c8c9da8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two very minor things, but LGTM!
|
||
package com.ichi2.anki; | ||
|
||
public interface WhiteboardMethods { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds great!
Slight change to the documentation. You want to try to avoid referencing a concrete implementation for an interface (although it's often useful to provide an example).
/**
* Provides callbacks for multi touch handling on a whiteboard
*/
public interface WhiteboardMultiTouchMethods {
@mikehardy what do you say, do we have a userbase of API 21 or below? should we rescale the image before saving it(in API 21 or below)? |
Yes, minsdkversion is still 21, won't move for a while, the whole android ecosystem just moved up to it in fact. Probably a year or more before it goes higher. Still tens of thousands of users |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed with @Akshay0701, moving the issue of the image size to #9439
Could we find out which API version this issue is resolved with, and limit the feature to API versions that are working correctly (likely via @Requires()
with a comment, and make the button gone
if it's not available).
Note that since we haven't diagnosed the issue, it may be screen size related, in which case we should get it fixed before getting this feature in.
cb61578
to
27c7043
Compare
AnkiDroid/src/main/java/com/ichi2/anki/multimediacard/fields/BasicImageFieldController.java
Show resolved
Hide resolved
David, I am sure this issue is not related to screen size, because |
Could you add a comment on the API restriction listing the issue number, then good to go! |
i think i already did comment with issue number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, was missed in the GitHub preview. LGTM!
public String getPathFromUri(Uri uri) throws IOException { | ||
String filename = ContentResolverUtil.getFileName(mActivity.getContentResolver(), uri); | ||
InputStream fd = mActivity.getContentResolver().openInputStream(uri); | ||
Map.Entry<String, String> fileNameAndExtension = FileUtil.getFileNameAndExtension(filename); | ||
filename = fileNameAndExtension.getKey(); | ||
File clipCopy = File.createTempFile(filename, fileNameAndExtension.getValue()); | ||
CompatHelper.getCompat().copyFile(fd, clipCopy.getAbsolutePath()); | ||
return clipCopy.getAbsolutePath(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This to me is return internalizeUri(uri).getAbsolutePath()
, which is defined just below this method
In fact, there is a proliferation of methods like this:
- MediaRegistration::loadImageIntoCollection does it
- FileUtil::internalizeUri does it
Why are we duplicating the process of "take a URI, copy the contents of it into our local area and give me a file" in so many places? 🤔
I may be missing something, but I would love for this logic to be in one spot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great review, Thank you for letting me know about the internalizeUri
method, I was unaware of this method,
Done now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this a lot - it appears to me that all the things required for it to actually work, are working. Which is awesome. My only concern is that I've seen this URI-->File logic in so many places and it looks like this is adding another? Can we avoid it at all?
1adb1c1
to
177fe70
Compare
177fe70
to
199df53
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! thanks for the shift to internalizeUri
Pull Request template
Fixes
Fixes #9363
Done
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration (SDK version(s), emulator or physical, etc)
Learning (optional, can help others)
Describe the research stage
Links to blog posts, patterns, libraries or addons used to solve this problem
Checklist
Please, go through these checks before submitting the PR.
if
statements)