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(); + } + } + } } diff --git a/apidoc/Titanium/UI/Tab.yml b/apidoc/Titanium/UI/Tab.yml index 6408f1b6b02..bec905e881c 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: "9.2.0"} + platforms: [android, iphone, ipad, macos] properties: - name: active