Change launcher flags for single instance of app

Closes #301
pull/321/head
Alex Baker 10 years ago
parent bb3e72a5ee
commit 31b826f93b

@ -128,7 +128,8 @@
<!-- Activity that displays task list -->
<activity
android:name="com.todoroo.astrid.activity.TaskListActivity"
android:windowSoftInputMode="stateHidden|adjustResize">
android:windowSoftInputMode="stateHidden|adjustResize"
android:launchMode="singleTask" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@ -141,8 +142,7 @@
<!-- Activity launched from shortcut -->
<activity
android:name="com.todoroo.astrid.activity.ShortcutActivity"
android:clearTaskOnLaunch="true">
android:name="com.todoroo.astrid.activity.ShortcutActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
@ -161,6 +161,7 @@
</activity>
<!-- Activity launched from ShareLink menu item -->
<!-- TODO: clearTaskOnLaunch probable cause of #275 -->
<activity
android:name="com.todoroo.astrid.activity.ShareLinkActivity"
android:clearTaskOnLaunch="true">

@ -56,20 +56,25 @@ public class ShortcutActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
launchTaskList(getIntent());
launchTaskList();
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
launchTaskList(intent);
setIntent(intent);
launchTaskList();
}
private void launchTaskList(Intent intent) {
private void launchTaskList() {
Intent intent = getIntent();
Bundle extras = intent.getExtras();
Intent taskListIntent = new Intent(this, TaskListActivity.class);
taskListIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
if(extras != null && extras.containsKey(TOKEN_CUSTOM_CLASS)) {
taskListIntent.putExtras(intent.getExtras());

@ -112,8 +112,27 @@ public class TaskListActivity extends AstridActivity implements OnPageChangeList
DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
navigationDrawer.setUp(drawerLayout);
initializeFragments();
View editFragment = findViewById(R.id.taskedit_fragment_container);
if(editFragment != null) {
fragmentLayout = LAYOUT_DOUBLE;
} else {
fragmentLayout = LAYOUT_SINGLE;
}
readIntent();
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
readIntent();
}
private void readIntent() {
Bundle extras = getIntent().getExtras();
if (extras != null) {
extras = (Bundle) extras.clone();
@ -218,16 +237,6 @@ public class TaskListActivity extends AstridActivity implements OnPageChangeList
return BuiltInFilterExposer.getMyTasksFilter(getResources());
}
protected void initializeFragments() {
View editFragment = findViewById(R.id.taskedit_fragment_container);
if(editFragment != null) {
fragmentLayout = LAYOUT_DOUBLE;
} else {
fragmentLayout = LAYOUT_SINGLE;
}
}
@Override
public boolean onFilterItemClicked(FilterListItem item) {
TaskEditFragment.removeExtrasFromIntent(getIntent());

@ -35,13 +35,14 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.inject.Singleton;
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
@Singleton
public class WidgetHelper {
public static int flags = FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK;
public static int flags = FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TOP;
private final TagDataDao tagDataDao;
private final Preferences preferences;
@ -105,7 +106,7 @@ public class WidgetHelper {
Bundle extras = AndroidUtilities.bundleFromSerializedString(serializedExtras);
listIntent.putExtras(extras);
}
listIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
listIntent.setFlags(flags);
if (filter != null) {
listIntent.putExtra(TaskListFragment.TOKEN_FILTER, filter);
listIntent.setAction("L" + widgetId + filter.getSqlQuery());

Loading…
Cancel
Save