From 0200e1a058e94e16624dd519167c29b06c301f29 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Mon, 29 Jan 2024 21:18:46 +0100 Subject: [PATCH 1/3] feat(android): parity for Tab.popToRootWindow() --- .../java/ti/modules/titanium/ui/TabProxy.java | 6 +++++ .../appcelerator/titanium/TiApplication.java | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/TabProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/TabProxy.java index 09ea35d055f..0f02092363e 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/TabProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/TabProxy.java @@ -253,6 +253,12 @@ public void onPropertyChanged(String name, Object value) } } + @Kroll.method + public void popToRootWindow() + { + TiApplication.getInstance().popToRootWindow(); + } + @Override public String getApiName() { diff --git a/android/titanium/src/java/org/appcelerator/titanium/TiApplication.java b/android/titanium/src/java/org/appcelerator/titanium/TiApplication.java index 37f9ec8eab0..9adc362f0b2 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/TiApplication.java +++ b/android/titanium/src/java/org/appcelerator/titanium/TiApplication.java @@ -1023,4 +1023,27 @@ public AccessibilityManager getAccessibilityManager() public void verifyCustomModules(TiRootActivity rootActivity) { } + + public void popToRootWindow() + { + /** + * emulates the iOS Tab.popToRootWindow() by closing all windows above a TabGroup. + */ + boolean isTabGroup = (activityStack.get(1).get() instanceof TiActivity) + && ((TiActivity) activityStack.get(1).get()) + .getWindowProxy().getApiName().equals("Ti.UI.TabGroup"); + + // no TabGroup - don't do anything + if (!isTabGroup) { + return; + } + + // finish all activities above our TabGroup + for (int i = activityStack.size() - 1; i > 1; --i) { + if (activityStack.get(i).get() instanceof TiActivity) { + TiActivity currentActivity = (TiActivity) activityStack.get(i).get(); + currentActivity.finish(); + } + } + } } From e24e40e074c1fc88825741d24ef6b64cc8fbdf94 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Mon, 29 Jan 2024 21:31:19 +0100 Subject: [PATCH 2/3] docs --- apidoc/Titanium/UI/Tab.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apidoc/Titanium/UI/Tab.yml b/apidoc/Titanium/UI/Tab.yml index 6408f1b6b02..88a6bb2fbe0 100644 --- a/apidoc/Titanium/UI/Tab.yml +++ b/apidoc/Titanium/UI/Tab.yml @@ -130,19 +130,18 @@ methods: notes: Set the value of the [window](Titanium.UI.Tab.window) property directly. - name: popToRootWindow - # FIXME: I don't think this exists on Android! summary: Closes all windows that are currently opened inside the tab. description: Note that only the `close` event of the most recently opened window is fired. parameters: - name: options summary: | - Options supporting a single `animated` boolean property to determine whether the windows + iOS only: Options supporting a single `animated` boolean property to determine whether the windows will be animated while being closed (default: false). type: AnimatedOptions optional: true default: "{ animated: false }" - since: "6.2.0" - platforms: [iphone, ipad, macos] + since: {android: "12.4.0", iphone: "6.2.0", ipad: "6.2.0", macos: "6.2.0"} + platforms: [android, iphone, ipad, macos] properties: - name: active From 12e646ad5b0567817108c91f8c970f1750ad8dd8 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Mon, 29 Jan 2024 21:37:42 +0100 Subject: [PATCH 3/3] fix docs linting --- apidoc/Titanium/UI/Tab.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apidoc/Titanium/UI/Tab.yml b/apidoc/Titanium/UI/Tab.yml index 88a6bb2fbe0..bec905e881c 100644 --- a/apidoc/Titanium/UI/Tab.yml +++ b/apidoc/Titanium/UI/Tab.yml @@ -140,7 +140,7 @@ methods: type: AnimatedOptions optional: true default: "{ animated: false }" - since: {android: "12.4.0", iphone: "6.2.0", ipad: "6.2.0", macos: "6.2.0"} + since: {android: "12.4.0", iphone: "6.2.0", ipad: "6.2.0", macos: "9.2.0"} platforms: [android, iphone, ipad, macos] properties: