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 Tab.popToRootWindow() #13976

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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 @@ -253,6 +253,12 @@ public void onPropertyChanged(String name, Object value)
}
}

@Kroll.method
public void popToRootWindow()
{
TiApplication.getInstance().popToRootWindow();
}

@Override
public String getApiName()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
}
7 changes: 3 additions & 4 deletions apidoc/Titanium/UI/Tab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading