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

Play Icon When in a Command Mode #251

Merged
merged 5 commits into from
Nov 28, 2024

Conversation

Linfye
Copy link
Collaborator

@Linfye Linfye commented Nov 21, 2024

Contributor checklist


Description

This PR changes enter icon to play button when in a command mode.

Related issue

Copy link

Thank you for the pull request!

The Scribe team will do our best to address your contribution as soon as we can. The following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :)

If you're not already a member of our public Matrix community, please consider joining! We'd suggest using Element as your Matrix client, and definitely join the General and Android rooms once you're in. Also consider joining our bi-weekly Saturday dev syncs. It'd be great to have you!

Maintainer checklist

  • The linting and formatting workflows within the PR checks do not indicate new errors in the files changed

  • The CHANGELOG has been updated with a description of the changes for the upcoming release and the corresponding issue (if necessary)

@Linfye
Copy link
Collaborator Author

Linfye commented Nov 21, 2024

The creation process of the keyboard is implemented by a helper, and I haven't found a suitable way to pass the isCommandMode parameter. After modifying the isCommandMode value in SimpleKeyboardIME and recreating the keyboard, it seems that the parameter is reset, and I don't know how to solve this. Could you help me with this? Thanks! :) @andrewtavis

@andrewtavis
Copy link
Member

CC also @angrezichatterbox as I'm at work atm :) I'll take a look tonight or over the weekend, @Linfye! Thank you!

@angrezichatterbox
Copy link
Member

I am not sure we have any easy ways of passing the command boolean. However, I have another way in which we could do it. One method is to set a custom state within the keyboard. So for eg if we use the EditorInfo.IME_ACTION_UNSPECIFIED is the condition for setting the icon of the enter key to the Play Icon. Now there is the setEnterKeyColor function use it to set the mEnterKeyType as that specific type. Now create a function to set the enter key icon using this logic in MyKeyboard.kt and call this function after setting the mEnterKey type. You can use any custom type to do it.

I am happy to explain in more detail :)

@Linfye
Copy link
Collaborator Author

Linfye commented Nov 22, 2024

I am not sure we have any easy ways of passing the command boolean. However, I have another way in which we could do it. One method is to set a custom state within the keyboard. So for eg if we use the EditorInfo.IME_ACTION_UNSPECIFIED is the condition for setting the icon of the enter key to the Play Icon. Now there is the setEnterKeyColor function use it to set the mEnterKeyType as that specific type. Now create a function to set the enter key icon using this logic in MyKeyboard.kt and call this function after setting the mEnterKey type. You can use any custom type to do it.

I had considered this method initially, but I thought that modifying the built-in state might not be a common practice in Android development (I'm not quite sure about this). Since you suggested it, I can give it a try. Thank you! :)

@angrezichatterbox
Copy link
Member

I am not sure we have any easy ways of passing the command boolean. However, I have another way in which we could do it. One method is to set a custom state within the keyboard. So for eg if we use the EditorInfo.IME_ACTION_UNSPECIFIED is the condition for setting the icon of the enter key to the Play Icon. Now there is the setEnterKeyColor function use it to set the mEnterKeyType as that specific type. Now create a function to set the enter key icon using this logic in MyKeyboard.kt and call this function after setting the mEnterKey type. You can use any custom type to do it.

I had considered this method initially, but I thought that modifying the built-in state might not be a common practice in Android development (I'm not quite sure about this). Since you suggested it, I can give it a try. Thank you! :)

You could also set a companion object as a new type and set the key type as that from the setEnterKeyColor function.

@Linfye
Copy link
Collaborator Author

Linfye commented Nov 27, 2024

@angrezichatterbox Sorry for the delay, I've been busy with college matters lately. And thank you very much for your help!

Could you review the current code? 😊

@andrewtavis
Copy link
Member

Functionality wise it looks good to me, @Linfye :) Might be nice if we could have the play icon moved a bit to the right - say 10% of the button's width, as with these sorts of icons if we actually center it it doesn't "look centered" :) This could be another task if you'd like it to be though!

@Linfye
Copy link
Collaborator Author

Linfye commented Nov 27, 2024

Functionality wise it looks good to me, @Linfye :) Might be nice if we could have the play icon moved a bit to the right - say 10% of the button's width, as with these sorts of icons if we actually center it it doesn't "look centered" :) This could be another task if you'd like it to be though!

Yes, I noticed this issue before but forgot to mention it here. I can update this icon by adding a transparent margin on the left side to resolve it. What do you think? :)

@andrewtavis
Copy link
Member

That'd be perfect, @Linfye! Thank you!

Copy link
Member

@angrezichatterbox angrezichatterbox left a comment

Choose a reason for hiding this comment

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

@Linfye Everything looks nice. We could make the visual changes as suggested. We also have an edge case to deal with which comes which the approach. This could be an issue which could be created and worked on later on.

So currently when the user closes the keyboard when in any of the modes where the play icon is shown. If the user switches to an app and gets back to keyboard the play icon disappears and it would become again the icon as per the Editor Info.

A thing we could do is to switch the mode to idle when the user exits off the keyboard. Would love to hear about this specific issue.

Other than this amazing work @Linfye

@andrewtavis
Copy link
Member

Switching to idle when the user navigates away makes sense to me, @angrezichatterbox 😊

@angrezichatterbox
Copy link
Member

Switching to idle when the user navigates away makes sense to me, @angrezichatterbox 😊

Yes it makes sense. Should we create an issue for correcting this edge case after this PR is merged ?

@andrewtavis
Copy link
Member

Either or. @Linfye, if you want to include it in here, then by all means, or if not let's make the issue 😊

@angrezichatterbox
Copy link
Member

@Linfye Would u like to bring it in or should I add it to this PR :) Happy to add it to the PR :)

@Linfye
Copy link
Collaborator Author

Linfye commented Nov 28, 2024

@Linfye Would u like to bring it in or should I add it to this PR :) Happy to add it to the PR :)

Yes, I'd like to solve this.

@Linfye
Copy link
Collaborator Author

Linfye commented Nov 28, 2024

@angrezichatterbox I've tried to change the keyboard state using onFinishInput, but I'm not sure how to update the UI. There's some strange functionality disorder. Would you like to take over this?

@angrezichatterbox
Copy link
Member

@angrezichatterbox I've tried to change the keyboard state using onFinishInput, but I'm not sure how to update the UI. There's some strange functionality disorder. Would you like to take over this?

I would look into it and would get back to you.

@angrezichatterbox
Copy link
Member

So the function that was being run when the input view is closed was onFinishInputView(). I have implemented the changes. I just checked the codebase a bit more now. Thanks for replacing the deprecated setBackgroundDrawable().

It is ready for review @andrewtavis

Copy link
Member

@andrewtavis andrewtavis left a comment

Choose a reason for hiding this comment

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

Is working really well now 😊 Beautiful work, @Linfye, and thanks for following through with the fix for setting the keyboard to idle! Thanks also for the review and final touches, @angrezichatterbox!

@andrewtavis andrewtavis merged commit 45e33fe into scribe-org:main Nov 28, 2024
4 checks passed
@Linfye Linfye deleted the command-mode-play-button branch November 29, 2024 03:36
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.

3 participants