Skip to content

Commit

Permalink
Merge pull request #8776 from hansemannn/TIMOB-20459-6_0_X
Browse files Browse the repository at this point in the history
[TIMOB-20459] (6_0_X) Android: Fix shortcut and notification intents
  • Loading branch information
hansemannn committed Jan 23, 2017
2 parents c068ffa + f075797 commit 8bff706
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@

import android.content.Intent;
import android.os.Bundle;

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.titanium.proxy.IntentProxy;

public class TiActivity extends TiBaseActivity
{
Intent intent = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -32,6 +34,28 @@ protected void onDestroy()
@Override
protected void onResume()
{
TiRootActivity rootActivity = getTiApp().getRootActivity();
if (rootActivity != null) {
Intent rootIntent = rootActivity.getIntent();

// merge root intent extras
if (rootIntent != null) {
if (intent == null) {
intent = getIntent();
}
if (intent.getComponent().getClassName().equals(TiActivity.class.getName())) {
Intent newIntent = new Intent(intent);
newIntent.putExtras(rootIntent);
setIntent(newIntent);

// fire 'newintent'
IntentProxy intentProxy = new IntentProxy(newIntent);
KrollDict data = new KrollDict();
data.put(TiC.PROPERTY_INTENT, intentProxy);
rootActivity.getActivityProxy().fireSyncEvent(TiC.EVENT_NEW_INTENT, data);
}
}
}
super.onResume();
if (getTiApp().isRestartPending()) {
return;
Expand All @@ -43,7 +67,15 @@ protected void onPause()
{
super.onPause();

if (getTiApp().isRestartPending()) {
TiApplication tiApp = getTiApp();
TiRootActivity rootActivity = tiApp.getRootActivity();
if (rootActivity != null) {
Intent rootIntent = rootActivity.getIntent();
if (rootIntent != null) {
rootIntent.replaceExtras((Bundle) null);
}
}
if (tiApp.isRestartPending()) {
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,7 @@ protected void onResume()
KrollDict data = new KrollDict();
data.put(TiC.EVENT_PROPERTY_INTENT, new IntentProxy(intent));

if (getTiApp().isRootActivityAvailable()) {
TiBaseActivity activity = (TiBaseActivity) getTiApp().getRootOrCurrentActivity();
activity.getActivityProxy().fireEvent(TiC.EVENT_NEW_INTENT, data);
} else {
if (!getTiApp().isRootActivityAvailable()) {
activityProxy.fireEvent(TiC.PROPERTY_ON_INTENT, data);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.appcelerator.titanium.util.TiActivitySupport;
import org.appcelerator.titanium.util.TiRHelper;

import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
Expand Down Expand Up @@ -71,6 +72,14 @@ public String getUrl()
@Override
protected void onCreate(Bundle savedInstanceState)
{
TiApplication tiApp = getTiApp();
Intent intent = getIntent();
TiRootActivity rootActivity = tiApp.getRootActivity();

if (intent != null && rootActivity != null) {
rootActivity.setIntent(intent);
}

if (willFinishFalseRootActivity(savedInstanceState)) {
return;
}
Expand All @@ -80,8 +89,6 @@ protected void onCreate(Bundle savedInstanceState)
return;
}

TiApplication tiApp = getTiApp();

if (tiApp.isRestartPending() || TiBaseActivity.isUnsupportedReLaunch(this, savedInstanceState)) {
super.onCreate(savedInstanceState); // Will take care of scheduling restart and finishing.
return;
Expand Down

0 comments on commit 8bff706

Please sign in to comment.