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

feat(android): parity for keyboardframechanged and keyboardVisible #13726

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.ITiAppInfo;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiBaseActivity;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.util.TiSensorHelper;
Expand Down Expand Up @@ -155,6 +156,16 @@ public boolean getAccessibilityEnabled()
return TiApplication.getInstance().getAccessibilityManager().isEnabled();
}

@Kroll.getProperty
public boolean getKeyboardVisible()
{
TiBaseActivity activity = (TiBaseActivity) TiApplication.getAppCurrentActivity();
if (activity == null) {
return false;
}
return TiConvert.toBoolean(activity.keyboardVisible, false);
}

@Kroll.method(name = "_restart")
public void restart()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public abstract class TiBaseActivity extends AppCompatActivity implements TiActi
private TiActionBarStyleHandler actionBarStyleHandler;
private TiActivitySafeAreaMonitor safeAreaMonitor;
private Context baseContext;
private boolean oldKeyboardValue = false;
public boolean keyboardVisible = false;
/**
* Callback to be invoked when the TiBaseActivity.onRequestPermissionsResult() has been called,
* providing the results of a requestPermissions() call. Instances of this interface are to
Expand Down Expand Up @@ -763,17 +763,18 @@ public void onChanged(TiActivitySafeAreaMonitor monitor)
}

@Override
public void onKeyboardChanged(boolean keyboardVisible)
public void onKeyboardChanged(boolean isVisible)
{
if (keyboardVisible != oldKeyboardValue) {
KrollDict kd = new KrollDict();
kd.put("keyboardVisible", keyboardVisible);
if (isVisible != keyboardVisible) {
TiWindowProxy windowProxy = TiBaseActivity.this.window;
if (windowProxy != null) {
windowProxy.fireSafeAreaChangedEvent();
}
windowProxy.fireEvent("keyboardChanged", kd);
oldKeyboardValue = keyboardVisible;
KrollDict kd = new KrollDict();
kd.put("keyboardFrame", null);
m1ga marked this conversation as resolved.
Show resolved Hide resolved
kd.put("animationDuration", 0);
tiApp.fireAppEvent("keyboardframechanged", kd);
keyboardVisible = isVisible;
}
}
});
Expand Down
9 changes: 5 additions & 4 deletions apidoc/Titanium/App/App.yml
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ events:
summary: Fired when the soft keyboard is presented, on and off the screen.
description: |
This event fires when the application presents the soft keyboard on/off the screen . The
event returns the dictionary `keyboardFrame` containing `x`, `y`, `height` and `width` keys,
event on iOS returns the dictionary `keyboardFrame` containing `x`, `y`, `height` and `width` keys,
corresponding to the frame of the keyboard with respect to the screen coordinates.

On Titanium SDK 4.0.0 and later the event also contains a second parameter `animationDuration` representing
Expand All @@ -394,8 +394,8 @@ events:
- name: animationDuration
summary: The duration of the keyboard animation. This parameter is only available on Titanium SDK 4.0.0 and later.
type: Number
platforms: [iphone, ipad, macos]
since: {iphone: "3.0.0", ipad: "3.0.0", macos: "9.2.0"}
platforms: [android, iphone, ipad, macos]
since: {android: "12.1.0", iphone: "3.0.0", ipad: "3.0.0", macos: "9.2.0"}
m1ga marked this conversation as resolved.
Show resolved Hide resolved

- name: significanttimechange
summary: Fired when there is a significant change in the time.
Expand Down Expand Up @@ -611,7 +611,8 @@ properties:
summary: Indicates whether or not the soft keyboard is visible.
type: Boolean
permission: read-only
platforms: [iphone, ipad, macos]
since: {android: "12.1.0", iphone: "7.5.0", ipad: "7.5.0", macos: "9.2.0"}
m1ga marked this conversation as resolved.
Show resolved Hide resolved
platforms: [android, iphone, ipad, macos]

- name: trackUserInteraction
summary: Indicates whether or not the user interaction shoud be tracked.
Expand Down
8 changes: 0 additions & 8 deletions apidoc/Titanium/UI/Window.yml
Original file line number Diff line number Diff line change
Expand Up @@ -739,14 +739,6 @@ events:
The listener for this event must be defined before this window
is opened.

- name: keyboardChanged
summary: Fired when the soft keyboard is shown or hidden.
description: |
Will fire on Android 11 and up if the keyboard is shown or hidden. Check
`keyboardVisible` in the event for the status.
platforms: [android]
since: '12.1.0'

properties:
- name: activity
summary: |
Expand Down