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

Ctrl+n+n for settings panel #2260

Closed
wants to merge 7 commits into from

Conversation

brunoais
Copy link
Contributor

@brunoais brunoais commented Apr 17, 2021

Show the settings panel if pressing CTRL+n and then, without releasing CTRL, press n again

Still not done/updated:
README:

  • New shortcut
  • Rename what CTRL+SHIFT+n does

Closes: #2264

@brunoais brunoais changed the base branch from master to dev April 17, 2021 16:10
@brunoais brunoais force-pushed the ctrl_n_n-forSettingsPanel branch from 7ba0fde to a4aa0e6 Compare April 17, 2021 16:12
@brunoais
Copy link
Contributor Author

If all looks good, I'll update documentation

Comment on lines -14 to +19
public static final int TYPE_COLLAPSE_NOTIFICATION_PANEL = 6;
public static final int TYPE_GET_CLIPBOARD = 7;
public static final int TYPE_SET_CLIPBOARD = 8;
public static final int TYPE_SET_SCREEN_POWER_MODE = 9;
public static final int TYPE_ROTATE_DEVICE = 10;
public static final int TYPE_EXPAND_SETTINGS_PANEL = 6;
public static final int TYPE_COLLAPSE_PANELS = 7;
public static final int TYPE_GET_CLIPBOARD = 8;
public static final int TYPE_SET_CLIPBOARD = 9;
public static final int TYPE_SET_SCREEN_POWER_MODE = 10;
public static final int TYPE_ROTATE_DEVICE = 11;
Copy link
Contributor Author

@brunoais brunoais Apr 17, 2021

Choose a reason for hiding this comment

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

Not fully sure about changing the value of the constants as I did (and related) as it will make the previous server incompatible.

  1. On one hand, as I did,
    1. breaks backwards compatibility.
    2. making this change allows cleaner code on both ends.
  2. On the other hand, by just adding at the end
    1. Keeps backwards compatibility
    2. The code is less readable and maintainable.

I ended up going with 1, but I don't mind changing to 2 if you prefer.
Maybe doing as 2 and change to 1 soon, though, later.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not fully sure about changing the value of the constants as I did (and related) as it will make the previous server incompatible.

That's totally acceptable, servers are not expected to be compatible at all with any other scrcpy client version. This would add annoying constraints for absolutely no benefit for scrcpy.

Copy link
Collaborator

@rom1v rom1v left a comment

Choose a reason for hiding this comment

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

On the principle, probably ok.

However, on my Android 6 device, I don't understand what it should open, it does nothing more than if I press Alt+n only once.

On my Android 10:

[server] ERROR: Could not invoke method
java.lang.NoSuchMethodException: com.android.internal.statusbar.IStatusBarService$Stub$Proxy.expandSettingsPanel []
	at java.lang.Class.getMethod(Class.java:2072)
	at java.lang.Class.getMethod(Class.java:1693)
	at com.genymobile.scrcpy.wrappers.StatusBarManager.getExpandSettingsPanel(StatusBarManager.java:30)
	at com.genymobile.scrcpy.wrappers.StatusBarManager.expandSettingsPanel(StatusBarManager.java:52)
	at com.genymobile.scrcpy.Device.expandSettingsPanel(Device.java:231)
	at com.genymobile.scrcpy.Controller.handleEvent(Controller.java:111)
	at com.genymobile.scrcpy.Controller.control(Controller.java:71)
	at com.genymobile.scrcpy.Server$2.run(Server.java:100)
	at java.lang.Thread.run(Thread.java:919)

Also, it doesn't build/link tests on debug mode:

error
[2/10] Compiling C object app/test_control_msg_serialize.p/tests_test_control_msg_serialize.c.o
../app/tests/test_control_msg_serialize.c: In function ‘main’:
../app/tests/test_control_msg_serialize.c:292:5: warning: implicit declaration of function ‘test_serialize_collapse_notification_panel’; did you mean ‘test_serialize_expand_notification_panel’? [-Wimplicit-function-declaration]
  292 |     test_serialize_collapse_notification_panel();
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |     test_serialize_expand_notification_panel
At top level:
../app/tests/test_control_msg_serialize.c:195:13: warning: ‘test_serialize_collapse_panels’ defined but not used [-Wunused-function]
  195 | static void test_serialize_collapse_panels(void) {
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../app/tests/test_control_msg_serialize.c:180:13: warning: ‘test_serialize_expand_settings_panel’ defined but not used [-Wunused-function]
  180 | static void test_serialize_expand_settings_panel(void) {
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[7/10] Linking target app/test_control_msg_serialize
FAILED: app/test_control_msg_serialize 
cc  -o app/test_control_msg_serialize app/test_control_msg_serialize.p/tests_test_control_msg_serialize.c.o app/test_control_msg_serialize.p/src_control_msg.c.o app/test_control_msg_serialize.p/src_util_str_util.c.o -fsanitize=address,undefined -Wl,--as-needed -Wl,--no-undefined -Wl,--start-group /usr/lib/x86_64-linux-gnu/libavformat.so /usr/lib/x86_64-linux-gnu/libavcodec.so /usr/lib/x86_64-linux-gnu/libavutil.so /usr/lib/x86_64-linux-gnu/libSDL2.so -Wl,--end-group
/usr/bin/ld: app/test_control_msg_serialize.p/tests_test_control_msg_serialize.c.o: in function `main':
../app/tests/test_control_msg_serialize.c:292: undefined reference to `test_serialize_collapse_notification_panel'
collect2: error: ld returned 1 exit status
[8/10] Compiling C object app/scrcpy.p/src_input_manager.c.o
ninja: build stopped: subcommand failed.

collapse_notification_panel(controller);
} else {
collapse_panels(controller);
} else if(repeatCount == 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It could also probably be done on double-click on mouse button 5 now 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly! That PR is nearly ready ^^

app/src/input_manager.c Outdated Show resolved Hide resolved
@brunoais
Copy link
Contributor Author

I'll see those settings problems. I only own an android 6 phone. I will try to see why that exception happens with an emulator.

@brunoais brunoais force-pushed the ctrl_n_n-forSettingsPanel branch from 89ad79d to 7b4679b Compare April 17, 2021 16:52
@brunoais
Copy link
Contributor Author

@rom1v Please confirm if it works now on your Android 10.

@brunoais
Copy link
Contributor Author

brunoais commented Apr 17, 2021

However, on my Android 6 device, I don't understand what it should open

It's the same as scrolling the panel down a 2nd time. You get the buttons to turn on/off wifi, autorotate, etc...

Edit:
I tried with a friend's phone now (OnePlus 3 with Android 9). With the panel he has, if I take more than 1.5s to press the 2nd time, the settings panel doesn't show. However, if you touch the screen, it suddenly shows (I think it's a bugfeature)

@brunoais brunoais force-pushed the ctrl_n_n-forSettingsPanel branch from a070911 to 764975e Compare April 17, 2021 18:08
@rom1v
Copy link
Collaborator

rom1v commented Apr 18, 2021

Please confirm if it works now on your Android 10.

Yes, it works 👍

Could you please rebase your commits (with git rebase -i) to get a clean history. Each commit should be "correct" the first time (for example, fix the previous commits directly instead of a separate comit to "fix syntax to follow the rules"). In general, I do it, but if you have several PR, that will help 😉 Thank you.

@brunoais
Copy link
Contributor Author

@rom1v Fine to me.
I'll do that when all looks correct to you. Does all look correct now?

@brunoais brunoais force-pushed the ctrl_n_n-forSettingsPanel branch 3 times, most recently from 02efbf9 to aa60476 Compare April 18, 2021 18:14
@brunoais brunoais force-pushed the ctrl_n_n-forSettingsPanel branch from aa60476 to cd533a9 Compare April 19, 2021 18:55
@rom1v
Copy link
Collaborator

rom1v commented Apr 20, 2021

Thank you, this shortcut is very practical. 👍

I rebased/changed some minor things:

  • I moved the static local variables to track the key repeat count to input_manager fields
  • I fixed some build and unused tests issues (you should build in debug mode and test using ninja -Cx test)
  • I added a commit to expand using MOD+n+n (it was left unused in your latest version, so the shortcut didn't work)
  • I refactored the way the legacy expandSettingsPanel() method is handled (mainly for consistency with the other implementations, like in wrappers/ActivityManager.java)
  • I merged the commit for newer Android versions with the main implementation
  • I modified commit messages, to rephrase and/or to respect the Git 50/72 rule

Here is a branch: settings_panel.
It includes #2264 too.

Please test/review if it's ok for you.

rom1v pushed a commit that referenced this pull request Apr 20, 2021
The collapsing action collapses any panels.

By the way, the Android method is named collapsePanels().

PR #2260 <#2260>

Signed-off-by: Romain Vimont <[email protected]>
rom1v pushed a commit that referenced this pull request Apr 20, 2021
This will allow shortcuts such as MOD+n+n to open the settings panel.

PR #2260 <#2260>

Signed-off-by: Romain Vimont <[email protected]>
rom1v pushed a commit that referenced this pull request Apr 20, 2021
rom1v pushed a commit that referenced this pull request Apr 20, 2021
@brunoais
Copy link
Contributor Author

brunoais commented Apr 20, 2021

Thank you, this shortcut is very practical. +1

I rebased/changed some minor things:

...

OK. I'll work on taking these into account for next times.

Here is a branch: settings_panel.
It includes #2264 too.

Please test/review if it's ok for you.

Overall looks good. I only have nitpicks:

StatusBarManager.java: expandSettingsPanelMethodLegacy, I would make it a boolean for the new version instead of a boolean for the legacy version (expandSettingsPanelMethodNewVersion) and default it to true. This is also for the bottom "if" to not have the negation. For readability purposes.

Is it OK if I rebase this branch on the one you did and make the changes to the README?

rom1v and others added 5 commits April 20, 2021 20:59
The collapsing action collapses any panels.

By the way, the Android method is named collapsePanels().

PR Genymobile#2260 <Genymobile#2260>

Signed-off-by: Romain Vimont <[email protected]>
This will allow shortcuts such as MOD+n+n to open the settings panel.

PR Genymobile#2260 <Genymobile#2260>

Signed-off-by: Romain Vimont <[email protected]>
Double-click on extra mouse button to open the settings panel (a
single-click opens the notification panel).

This is consistent with the keyboard shortcut MOD+n+n.

PR Genymobile#2264 <Genymobile#2264>

Signed-off-by: Romain Vimont <[email protected]>
@rom1v
Copy link
Collaborator

rom1v commented Apr 20, 2021

I would make it a boolean for the new version instead of a boolean for the legacy version

OK, I first made the change for the existing code: ba47b33
Then I changed in this patchet.

New branch: settings_panel.2.

Is it OK if I rebase this branch on the one you did and make the changes to the README?

Yes, just push force settings_panel.2 to your ctrl_n_n-forSettingsPanel, this will update the PR, then you could add a commit for the README.

@brunoais brunoais force-pushed the ctrl_n_n-forSettingsPanel branch from cd533a9 to 01f424e Compare April 22, 2021 20:57
@brunoais
Copy link
Contributor Author

What do you think of the README like that?

@brunoais brunoais requested a review from rom1v April 22, 2021 21:01
rom1v pushed a commit that referenced this pull request Apr 25, 2021
rom1v added a commit that referenced this pull request Apr 25, 2021
rom1v pushed a commit that referenced this pull request Apr 25, 2021
The collapsing action collapses any panels.

By the way, the Android method is named collapsePanels().

PR #2260 <#2260>

Signed-off-by: Romain Vimont <[email protected]>
rom1v pushed a commit that referenced this pull request Apr 25, 2021
This will allow shortcuts such as MOD+n+n to open the settings panel.

PR #2260 <#2260>

Signed-off-by: Romain Vimont <[email protected]>
rom1v pushed a commit that referenced this pull request Apr 25, 2021
rom1v pushed a commit that referenced this pull request Apr 25, 2021
rom1v pushed a commit that referenced this pull request Apr 25, 2021
@rom1v
Copy link
Collaborator

rom1v commented Apr 25, 2021

👌 (I just changed left-double-click to double-left-click, and the same for double-5th-click).

Merged into dev.

@rom1v rom1v closed this Apr 25, 2021
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