-
Notifications
You must be signed in to change notification settings - Fork 41
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
Fix For BlockClock Min Size #385
Conversation
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.
Remove the commented out line of code
Awesome. I realized there's one thing missing from the code I proposed. I only ensures that the block fits the horizontal screen width, but not the vertical height. So here's the logic.
@jarolrod you probably spent the most time on this, how does that logic look to you? |
69b1ec2
to
3f455ee
Compare
Done in new commit |
Thanks @GBKS and @johnny9 for looking into the math. I have update the PR with a new commit 3f455ee which replaces the line suggested by @GBKS with @johnny9's:
|
Changing the mode from |
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.
One last thing. You should include the context in your git commit message header. In this case, "qml". So the commit message can be "qml: fix the BlockClock's minimum size"
src/qml/components/BlockClock.qml
Outdated
@@ -42,7 +42,7 @@ Item { | |||
id: dial | |||
anchors.horizontalCenter: root.horizontalCenter | |||
scale: Theme.blockclocksize | |||
width: Math.min((root.parentWidth * dial.scale), (root.parentHeight * dial.scale)) | |||
width: Math.max(Math.min(200, Math.min(root.parentWidth - 30, root.parentHeight - 30)), Math.min((root.parentWidth * dial.scale), (root.parentHeight * dial.scale))) |
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.
Can we break this up into two lines? It's difficult to read.
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.
Yes on both counts... new commit with changes d6331aa
3f455ee
to
d6331aa
Compare
@GBKS regarding your question about the
Yes, would you like to explore this in this PR or should we create a new one? |
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.
ACK d6331aa
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.
tACK d6331aa
Tested on an Android Wear smart watch and experienced a significant improvement.
Light Theme | Dark Theme | |
---|---|---|
Before | ||
After |
As it can be noticed, the network indicator has almost disappeared in such devices, therefor as @GBKS pointed out perhaps the network indicator could be moved up to the top-left, but that's where the "back" button is when we navigate through the settings, maybe it can be accommodated a bit up at the bottom reducing its size?
Another observation, out of scope of this PR, the settings button it's almost at the rounded border and it has been cut a bit, but I'm not sure if we support any/ all devices.
width: {Math.max(Math.min(200, Math.min(root.parentWidth - 30, root.parentHeight - 30)), | ||
Math.min((root.parentWidth * dial.scale), (root.parentHeight * dial.scale)))} |
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.
nit: I would extract the formula to a function where I'd structure the logic as @GBKS suggested above.
How about this...
**--- a/src/qml/components/BlockClock.qml
+++ b/src/qml/components/BlockClock.qml
@@ -44,7 +44,7 @@ Item {
id: dial
anchors.horizontalCenter: root.horizontalCenter
scale: Theme.blockclocksize
- width: Math.min((root.parentWidth * dial.scale), (root.parentHeight * dial.scale))
+ width: calculateConstrainedWidth()
height: dial.width
penWidth: dial.width / 50
timeRatioList: chainModel.timeRatioList
@@ -239,6 +239,24 @@ Item {
}
]
+ function calculateConstrainedWidth() {
+ // Margin size used to create a buffer around the constrained area.
+ var marginSize = 30;
+
+ // The maximum size.
+ // This is our hardest constraint - the physical screen size.
+ var screenConstraintSize = Math.min(root.parentWidth, root.parentHeight) - marginSize;
+
+ // The minimum size (for legibility).
+ var minimumSize = 200;
+
+ // The dynamic target size based on our display mode scale.
+ // Basically just scaling up for larger non-mobile screens.
+ var scaleTargetSize = Math.min(root.parentWidth, root.parentHeight) * dial.scale;
+
+ // Mashing them all up
+ return Math.min(screenConstraintSize, Math.max(minimumSize, scaleTargetSize))
+ }
function formatProgressPercentage(progress) {
if (progress >= 1) {
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.
thanks for testing on a wearable device, maybe let’s open a new PR if this feels like a priority, what do you think @GBKS?
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.
Including the explicit logic makes it easier to read, but since I have no clue about the established code standards in this project, my opinion here should not weigh much.
We should address the separate layout at tiny scales in a different PR. I'll try to mock up all the variations, and also include them in the design docs page, probably early next week.
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 mocked things up and added them to the design docs, see here. Feedback appreciated.
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.
Also had a question about how this works on Android Wear. Is the full app running on the watch? Or does it run in some sort of stripped down way? I'd be surprised of watches are powerful enough. I also assume we can detect if the app runs on a watch and potentially adjust the layout accordingly (specifically for the rounded frame)?
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.
Is the full app running on the watch? Or does it run in some sort of stripped down way?
I haven't passed the "Connecting..." phase, even the watch is connected to the internet and everything, I'd need to debug and check deeper, but I doubt it, I was just going a bit further with the testing of this PR and since I was going thru the Android guide it seems I got a bit overexcited 😆.
I'd be surprised of watches are powerful enough.
Well, this is an old one, 2017-ish, nowadays resources on smartwatches are still limited but they are getting there.
I also assume we can detect if the app runs on a watch and potentially adjust the layout accordingly (specifically for the rounded frame)?
I'd think so, I'll check when I do something related with it.
Thanks @GBKS , @johnny9 , and @pablomartin4btc for testing and working on this PR Thanks @hebasto for merging it! |
Issue and Fix:
This fixes #382
GBKS reported an issue where the blockclock on their Galaxy A32 5G phone displayed incorrectly under the min size of 200 pixels.
They provided a fix implemented in this pull request:
Math.max(Math.min(200, root.parentWidth - 30), Math.min((root.parentWidth * dial.scale), (root.parentHeight * dial.scale)))
Verification:
I tested the fix on both a virtual device Galaxy A32 5G in Android Studio and a physical Galaxy A13 5G (armv7) device. The fix successfully resolves the pixel-related display issue on both devices.