Skip to content

Commit

Permalink
feat(android): add Ti.UI.Window.focused property
Browse files Browse the repository at this point in the history
Fixes TIMOB-27711
  • Loading branch information
sgtcoolguy committed Jun 22, 2020
1 parent e0161ed commit 26f8dcd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public class TabGroupProxy extends TiWindowProxy implements TiActivityWindow
private WeakReference<AppCompatActivity> tabGroupActivity;
private TabProxy selectedTab;
private String tabGroupTitle = null;
private boolean isFocused;
private static int id_toolbar;

public TabGroupProxy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ void onFocusChanged(boolean focused, KrollDict eventData)
String event = focused ? TiC.EVENT_FOCUS : TiC.EVENT_BLUR;

if (window != null) {
window.fireEvent(event, null, false);
// Let window proxy handle setting state boolean and firing event
window.onWindowFocusChange(focused);
}
fireEvent(event, eventData, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public abstract class TiWindowProxy extends TiViewProxy
private TiWeakList<KrollProxy> proxiesWaitingForActivity = new TiWeakList<KrollProxy>();

protected boolean opened, opening;
protected boolean focused;
protected boolean isFocused;
protected int[] orientationModes = null;
protected TiViewProxy tabGroup;
protected TiViewProxy tab;
Expand Down Expand Up @@ -138,6 +138,12 @@ public boolean isClosed()
return !opened && !opening;
}

@Kroll.getProperty(name = "focused")
public boolean isFocused()
{
return isFocused;
}

@SuppressWarnings("unchecked")
@Kroll.method
public void close(@Kroll.argument(optional = true) Object arg)
Expand Down Expand Up @@ -274,6 +280,7 @@ public void onWindowActivityCreated()
*/
public void onWindowFocusChange(boolean focused)
{
this.isFocused = focused;
fireEvent((focused) ? TiC.EVENT_FOCUS : TiC.EVENT_BLUR, null, false);
}

Expand Down

0 comments on commit 26f8dcd

Please sign in to comment.