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 vnc dimensions #657

Merged
merged 8 commits into from
Feb 27, 2019
Merged

Add vnc dimensions #657

merged 8 commits into from
Feb 27, 2019

Conversation

luongthomas
Copy link
Collaborator

Describe the pull request

This PR introduces the ability for VNC to start with the resolution that closely matches the screen resolution of the device.

This will result in a VNC session that maximizes the available screen space.

Future work will include scaling the visuals so that font is more legible.

screenshot_20190221-103800_bvnc free

Link to relevant issues

@codecov-io
Copy link

codecov-io commented Feb 21, 2019

Codecov Report

Merging #657 into master will increase coverage by 0.28%.
The diff coverage is 50%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #657      +/-   ##
============================================
+ Coverage     32.22%   32.51%   +0.28%     
  Complexity      284      284              
============================================
  Files            39       39              
  Lines          2470     2488      +18     
  Branches        443      447       +4     
============================================
+ Hits            796      809      +13     
- Misses         1599     1604       +5     
  Partials         75       75
Impacted Files Coverage Δ Complexity Δ
app/src/main/java/tech/ula/MainActivity.kt 0% <0%> (ø) 0 <0> (ø) ⬇️
app/src/main/java/tech/ula/utils/ServerUtility.kt 47.94% <100%> (+0.72%) 13 <0> (ø) ⬇️
...p/src/main/java/tech/ula/model/entities/Session.kt 100% <100%> (ø) 12 <0> (ø) ⬇️
...in/java/tech/ula/model/repositories/UlaDatabase.kt 77.77% <66.66%> (+1.03%) 1 <0> (ø) ⬇️
app/src/main/java/tech/ula/utils/AndroidUtility.kt 16.26% <88.88%> (+3.26%) 0 <0> (ø) ⬇️
...ain/java/tech/ula/model/state/SessionStartupFsm.kt 87.5% <0%> (-1.14%) 42% <0%> (ø)
...c/main/java/tech/ula/model/state/AppsStartupFsm.kt 89.41% <0%> (+3.52%) 23% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0a03599...8c20c2e. Read the comment docs.

Copy link
Collaborator

@MatthewTighe MatthewTighe left a comment

Choose a reason for hiding this comment

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

Tests for the new utility class would be nice if you've got time as well.


private fun saveDeviceDimensions(sesson: Session) {
val deviceDimensions = DeviceDimensionsUtility()
deviceDimensions.saveDeviceDimensions(applicationContext)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than injecting the applicationContext, I think it would be better to inject a WindowManager directly. That way, we can avoid passing around the Context god object.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes mocking easier as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When I added tests, I found that injecting WindowManager and DisplayMetrics made it easily testable

height = displayMetrics.heightPixels
}

fun getLongerDimension(): Int {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it makes more sense to have getLongerDimension and getShorterDimension as private functions, and expose a function like getGeometry, the return value of which can be assigned directly to a session. That way more of the logic is encapsulated in this helper class.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You could combine the theoretical getGeometry with the existing saveDeviceDimensions function to write this in a more functional way and avoid statefulness in this class.

@@ -398,6 +400,33 @@ class AcraWrapper {
}
}

class DeviceDimensionsUtility {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As an aside, I'd kind of like to avoid Utility in the name of classes as much as possible moving forward. I definitely set a precedent to do so and kind of regret it now. Something like DeviceDimensionsRetriever or even just DeviceDimensions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed this class name to just DeviceDimensions

private var width = 720
private var height = 1480

fun saveDeviceDimensions(context: Context) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this function is a bit of a misnomer, as it doesn't actually 'save' the device dimensions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed it to getDeviceDimensions

@MatthewTighe MatthewTighe merged commit 451d646 into master Feb 27, 2019
@MatthewTighe MatthewTighe deleted the add-vnc-dimensions branch February 27, 2019 18:16
MatthewTighe pushed a commit that referenced this pull request Aug 14, 2019
* Add DeviceDimensionsUtility to save and get device dimensions

* When starting VNC session, save device dimensions and set the session's `geometry` property

* Pass the session's `geometry` as an environment variable

* Add `geometry` field to Session to hold screen dimensions.  Useful when starting VNC sessions

* Lint

* Fix unit tests

* Rename saveDeviceDImensions to getDeviceDimensions and add unit test

* Add missing import
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