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

RNMT-3515 Listen to 2-finger long press and open ECT #12

Merged
merged 6 commits into from
Dec 2, 2019

Conversation

EiyuuZack
Copy link
Contributor

@EiyuuZack EiyuuZack commented Nov 25, 2019

Description

Following https://github.com/OutSystems/cordova-outsystems-broadcaster/pull/17, this PR makes the App Feedback subscribe to gesture events and react when a 2-finger long press is broadcast.

This will only hold true when targeting Android 10 (API 29), otherwise the old mechanism is used.

See the commit messages for more information.

Context

References https://outsystemsrd.atlassian.net/browse/RNMT-3515

Type of changes

  • Feature (change which adds functionality)
    • BREAKING CHANGE (existing functionality will not work as expected due to new feature)
  • Fix (change which fixes an issue)
    • BREAKING CHANGE (existing functionality will not work as expected due to fix)
  • Performance (change which improves performance)
    • BREAKING CHANGE (existing functionality will not work as expected due to performance improvement)
  • Refactor (non-breaking change that is neither feature, fix nor performance)
  • Style (non-breaking change that only affects formatting and/or white-space)

Components affected

  • Android
  • iOS
  • JavaScript

Tests

Manual tests

Screenshots (if appropriate)

demo_android

Checklist

  • Code follows code style of this project
  • CHANGELOG.md file is correctly updated
  • Changes require an update to the documentation
    • Documentation has been updated accordingly

To avoid a breaking change, this feature will live side-by-side
with the old code and only run on applications which were built
on MABS 6 and above and thus only target SDK 29 and onwards,
which provides the required version of the Broadcaster plugin.

The breaking change would manifest due to the lack of proper release
segmentation on this asset. Since this plugin always injected at the
latest version of the respective O<version> branch that means it is
possible to have these changes running on an application built with
MABS < 6.

References https://outsystemsrd.atlassian.net/browse/RNMT-3515
Copy link
Contributor

@usernuno usernuno left a comment

Choose a reason for hiding this comment

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

Aren't there some preferences that allow the target SDK to change? These preferences can't change every value (hence the patches for MABS 6) but I'm not sure if they can change the target SDK.

If that is the case, we can break builds in every MABS version.

@EiyuuZack
Copy link
Contributor Author

Aren't there some preferences that allow the target SDK to change? These preferences can't change every value (hence the patches for MABS 6) but I'm not sure if they can change the target SDK.

If that is the case, we can break builds in every MABS version.

There are preferences that can change the targetSDK but I'm not sure we should support that -- it is a large reason for why there are different MABS versions.

This check just ensure that this code does not run when the targetSDK is below one that we're sure is compatible. If people try to bump up a targetSDK (e.g. for MABS 5) then there is a high probability that it will not compile on MABS in the first place.

We could try leverage the NATIVE_SHELL_VERSION preference much like Application Info does to ensure we only run this code starting from a specific NativeShell version, but alas it is still a preference. Do you have any suggestions?

@usernuno
Copy link
Contributor

Aren't there some preferences that allow the target SDK to change? These preferences can't change every value (hence the patches for MABS 6) but I'm not sure if they can change the target SDK.
If that is the case, we can break builds in every MABS version.

There are preferences that can change the targetSDK but I'm not sure we should support that -- it is a large reason for why there are different MABS versions.

This check just ensure that this code does not run when the targetSDK is below one that we're sure is compatible. If people try to bump up a targetSDK (e.g. for MABS 5) then there is a high probability that it will not compile on MABS in the first place.

We could try leverage the NATIVE_SHELL_VERSION preference much like Application Info does to ensure we only run this code starting from a specific NativeShell version, but alas it is still a preference. Do you have any suggestions?

I was just raising the flag regarding the android-targetSdkVersion preference. From what I understand the validations implemented in the supported plugins for the universal versions took this preference into consideration. I'd prefer if @Chuckytuh could chime in this thread.

Regarding alternatives I'm not seeing much. My only guess would be using reflection to see if one of the new classes exists but it's quite ugly and "depends" on knowledge of another plugin.

Copy link
Contributor

@luissilvaos luissilvaos left a comment

Choose a reason for hiding this comment

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

I think we have a breaking change here 😞 check my comments below, please.

}
if ((System.currentTimeMillis() - mSecondFingerTimeDown) >= INTERVAL_TO_SHOW_MENU) {
mSecondFingerTimeDown = 0;
if(cordovaActivity.getApplicationInfo().targetSdkVersion >= 29) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Houston, I think we have a breaking change here.
Although this is protected with the targetSdkVersion for the runtime, I'm not sure if this will build with previous MABS Versions 😞

Copy link
Contributor Author

@EiyuuZack EiyuuZack Nov 27, 2019

Choose a reason for hiding this comment

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

After looking better I believe you are correct. There is a breaking change on the Constants import from the Broadcaster. The constants used here (e.g. Constants.GESTURE_EVENT) do not exist in older MABS versions (more specifically older Broadcaster versions) and will cause a compile-time error when using this App Feedback commit/version.

A way to avoid this breaking change is to drop the Constants import and replace the constants used here with their string literals, although if the respective values change on the Broadcaster Constants class this code can suddenly stop working without visibility.

Regarding the Event import from the Broadcaster there is no breaking change because all MABS versions dating back from 3.3 include the Broadcaster with this Event interface and the getData() method. Any MABS version using this App Feedback commit/version will compile. However this is creating a dependency that may break if the Event interface is changed...

What are your thoughts on this?

Copy link
Contributor

Choose a reason for hiding this comment

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

The price to pay for not having versioning on this plugin 😞
Go ahead with that changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should aim to have the plugins backwards compatibility with other MABS versions, in this case, it's more justified because we don't have versioning for this plugin. That being said, I agree with @luissilvaos to implement those changes.

@Chuckytuh
Copy link
Contributor

@EiyuuZack what are we trying to achieve here? Is the new mechanism (with Broadcast Receiver) just to be used when running on Android 10 or when we compile the application with targetSdkVersion to 29?

If we're just trying to understand whether the application is running on Android 10 than we should be using https://developer.android.com/reference/android/os/Build.VERSION.html#SDK_INT .

@usernuno
Copy link
Contributor

@EiyuuZack what are we trying to achieve here? Is the new mechanism (with Broadcast Receiver) just to be used when running on Android 10 or when we compile the application with targetSdkVersion to 29?

If we're just trying to understand whether the application is running on Android 10 than we should be using https://developer.android.com/reference/android/os/Build.VERSION.html#SDK_INT .

@Chuckytuh this should run in all MABS 6 builds. It should not run in MABS 5- builds. The code that supports this is in the broadcaster plugin, but only in MABS 6. Therefore older builds should use the currently existing touch handler while newer builds should use this new code.

@EiyuuZack
Copy link
Contributor Author

@EiyuuZack what are we trying to achieve here? Is the new mechanism (with Broadcast Receiver) just to be used when running on Android 10 or when we compile the application with targetSdkVersion to 29?

If we're just trying to understand whether the application is running on Android 10 than we should be using https://developer.android.com/reference/android/os/Build.VERSION.html#SDK_INT .

We do not want this to run just because an app is running on Android 10. We want to run this new code when the app has been built targeting Android 10 (API 29).

This would cause a breaking change due to the way this plugin is
(not) versioned. Bear in mind that these constants still mirror
the ones in the Broadcaster plugin and should any of these be
modified there such changes must be reflected here, lest this
code start failing suddenly.

References https://outsystemsrd.atlassian.net/browse/RNMT-3515
usernuno
usernuno previously approved these changes Nov 28, 2019
luissilvaos
luissilvaos previously approved these changes Nov 28, 2019
pmaroco
pmaroco previously approved these changes Nov 29, 2019
This fix is twofold:

1) Unregisters the receiver which was not being done at all
2) Moves the register/unregister calls to the onStart and onStop
lifecycle callbacks as per Android best practices

References https://outsystemsrd.atlassian.net/browse/RNMT-3515
@EiyuuZack EiyuuZack dismissed stale reviews from pmaroco, luissilvaos, and usernuno via 20ef2ca November 29, 2019 14:33
@EiyuuZack EiyuuZack merged commit 9c69bd6 into master Dec 2, 2019
@EiyuuZack EiyuuZack deleted the feat/RNMT-3515/longpress-activation-android branch December 2, 2019 11:11
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.

6 participants