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

[6_0_X][TIMOB-15253] Android: Allow intent-filter to run as new task #8879

Merged
merged 4 commits into from
Mar 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void onSelectionChange(boolean selected) { }
*/
public View getContentView() {
TiWindowProxy windowProxy = getWindowProxy();
if (windowProxy == null) {
if (windowProxy == null || proxy == null) {
// If no window is provided use an empty view.
View emptyContent = new View(TiApplication.getInstance().getApplicationContext());
emptyContent.setBackgroundColor(Color.BLACK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,11 @@ public boolean runOnMainThread()
return getAppProperties().getBool("run-on-main-thread", DEFAULT_RUN_ON_MAIN_THREAD);
}

public boolean intentFilterNewTask()
{
return getAppProperties().getBool("intent-filter-new-task", false);
}

public void setFilterAnalyticsEvents(String[] events)
{
filteredAnalyticsEvents = events;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -857,12 +857,22 @@ public void onBackPressed()
onBackCallback.callAsync(activityProxy.getKrollObject(), new Object[] {});
}
if (topWindow == null || (topWindow != null && !topWindow.hasProperty(TiC.PROPERTY_ON_BACK) && !topWindow.hasListeners(TiC.EVENT_ANDROID_BACK))) {
// there are no parent activities to return to
// override back press to background the activity
// note: 2 since there should always be TiLaunchActivity and TiActivity
if (TiApplication.activityStack.size() <= 2) {
if (topWindow != null && !TiConvert.toBoolean(topWindow.getProperty(TiC.PROPERTY_EXIT_ON_CLOSE), true)) {
this.moveTaskToBack(true);
// no windows to return to
// check Ti.UI.Window.exitOnClose and either
// exit the application or send to background
if (windowStack.size() <= 1) {
if (topWindow != null) {
if (TiConvert.toBoolean(topWindow.getProperty(TiC.PROPERTY_EXIT_ON_CLOSE), true)) {
Log.d(TAG, "onBackPressed: exit");
if (Build.VERSION.SDK_INT >= 16) {
finishAffinity();
} else {
TiApplication.terminateActivityStack();
}
} else {
Log.d(TAG, "onBackPressed: suspend to background");
this.moveTaskToBack(true);
}
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,25 @@ protected void onCreate(Bundle savedInstanceState)
Intent intent = getIntent();
TiRootActivity rootActivity = tiApp.getRootActivity();

if (intent != null && rootActivity != null) {
rootActivity.setIntent(intent);
if (intent != null) {
if (rootActivity != null) {
rootActivity.setIntent(intent);
}
if (tiApp.intentFilterNewTask() &&
intent.getAction() != null && intent.getAction().equals(Intent.ACTION_VIEW) &&
intent.getDataString() != null &&
(intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != Intent.FLAG_ACTIVITY_NEW_TASK) {

if (rootActivity == null) {
intent.setAction(Intent.ACTION_MAIN);
}
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();

super.onCreate(savedInstanceState);
return;
}
}

if (willFinishFalseRootActivity(savedInstanceState)) {
Expand Down