Skip to content

Added ability to display an image on the "Screen" activity - #72

Closed
Minabsapi wants to merge 4 commits into
timer-machine:developfrom
Minabsapi:feature/30-image_for_training
Closed

Minabsapi wants to merge 4 commits into
timer-machine:developfrom
Minabsapi:feature/30-image_for_training

Conversation

@Minabsapi

Copy link
Copy Markdown

Description

Per #30, being able to have an image displayed as a guide when using this app for exercising looked very handy
So I decided to display such picture in the only place where it seemed to make sense, "Screen" activities that is. In order to pick the still / animated picture to be displayed, a new option "Pick Step Image" option has been added for "Screen" items
"Solves" also #63, since I had to make room for the guide image, so removed the large bell animation that in my opinion served little purpose

Bugs

No bugs were found upon testing. However, I am unsure about the onPickImageClick implementation added in "UpdateStepDialog.kt". Maintainers might want to check additions there in particular

Feature notes

Once an image has been picked, the only way to reset to default is by removing the corresponding "Screen" item. I haven't thought of a better way to handle it

General notes

I might have made a mess in "activity_screen.xml" layouts, since I have very little experience with layouting in native Android projects. Feel free to correct directly - what mattered to me was to have something that works (which apparently is the case) therefore I do not intend to edit my PR further and leave eventual corrections to maintainers. Same applies for the Kotlin code, as I'm definitely not familiar with this language either

Glide will be used to display animated pictures
Those layouts have been reorganized to accomodate the new space dedicated for the eventual picture
This string will be used for the new "Pick Step Image" option for "Screen" items
Images and GIFs can be picked to be displayed on the "Screen" activity
@Minabsapi Minabsapi mentioned this pull request Jan 9, 2024
@DeweyReed

Copy link
Copy Markdown
Member

Thank you very much for your contribution! However, I cannot merge this pull request because of the complexity of the feature, but I'll reference it when implementing the feature.

There are a lot of considerations while implementing the feature, such as separating the image from the full-screen reminder, saving the image to internal storage, showing the image at multiple locations, etc.

I've also added some suggestions to the PR, although you can safely ignore them if the feature works for you.

The support for images will be a part of the next release(7.5.0.)

Thank you again for making me realize that the feature can be more straightforward than I expected. :D

@DeweyReed DeweyReed closed this Jan 11, 2024
context = context,
action = current.toScreenAction(),
onPickImageClick = {
registerForActivityResult(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Registering a launcher after onCreate will crash the app. If I remember correctly, you must create the launcher before or in onCreate.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I indeed noticed that with "EditActivity.kt", which has this fixed. I leaved it that way here because I didn't know how to accommodate the difference between this file and the other. Beside, I still don't know when this file intervenes in the app

// binding.image.setImageURI(Uri.parse(imagePath))
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Glide can take care of everything for you, like this:
Glide.with(this).load(imagePath.toUri()).into(binding.image)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good to know. Thanks!

kapt libs.hilt.compiler

implementation libs.glide
annotationProcessor libs.compiler

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The compiler is redundant here because we only use Glide to load images.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

My bad. I admit this one was a blind copy-pasting of some tutorial

android:layout_marginEnd="8dp"
android:layout_width="191dp"
android:layout_height="113dp"
android:layout_marginTop="16dp"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Designing layouts with the layout inspector makes the layout inconsistent on different devices, which is why many developers prefer XML.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ah, I didn't know using the layout designer was known to be a problem. Will remember this next time I work on native Android project

@Minabsapi

Copy link
Copy Markdown
Author

I understand. Thanks for taking the time to review it anyway, and I'm glad it still helped even a bit!

@DeweyReed

Copy link
Copy Markdown
Member

Due to the sheer complexity of the feature that involves backup, sharing, and some refactoring, the image support won't be able to arrive in the next release. Although I don't have much free time, I'll try to finish it as soon as possible.

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