diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7f5d71a89..e92e54279 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -62,7 +62,7 @@ android:name=".activity.MainActivity" android:exported="true" android:label="@string/app_name" - android:launchMode="standard" + android:launchMode="singleTask" android:taskAffinity=".activity.MainActivity" android:windowSoftInputMode="stateUnchanged|adjustResize"> diff --git a/app/src/main/java/net/gsantner/markor/activity/DocumentActivity.java b/app/src/main/java/net/gsantner/markor/activity/DocumentActivity.java index 3fe3413c7..fd563564b 100644 --- a/app/src/main/java/net/gsantner/markor/activity/DocumentActivity.java +++ b/app/src/main/java/net/gsantner/markor/activity/DocumentActivity.java @@ -90,23 +90,27 @@ private static void launch( final Intent intent; if (GsFileBrowserListAdapter.isVirtualFolder(file) || file.isDirectory()) { intent = new Intent(activity, MainActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); } else { intent = new Intent(activity, DocumentActivity.class); - } - intent.putExtra(Document.EXTRA_FILE, file); + if (!(activity instanceof DocumentActivity) && + Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && + as.isMultiWindowEnabled() + ) { + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); + } - if (lineNumber != null) { - intent.putExtra(Document.EXTRA_FILE_LINE_NUMBER, lineNumber); - } + if (lineNumber != null) { + intent.putExtra(Document.EXTRA_FILE_LINE_NUMBER, lineNumber); + } - if (doPreview != null) { - intent.putExtra(Document.EXTRA_DO_PREVIEW, doPreview); + if (doPreview != null) { + intent.putExtra(Document.EXTRA_DO_PREVIEW, doPreview); + } } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && as.isMultiWindowEnabled()) { - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); - } + intent.putExtra(Document.EXTRA_FILE, file); nextLaunchTransparentBg = (activity instanceof MainActivity); GsContextUtils.instance.animateToActivity(activity, intent, false, null); diff --git a/app/thirdparty/java/other/writeily/widget/WrMarkorWidgetProvider.java b/app/thirdparty/java/other/writeily/widget/WrMarkorWidgetProvider.java index dc34e556e..8b87567f9 100644 --- a/app/thirdparty/java/other/writeily/widget/WrMarkorWidgetProvider.java +++ b/app/thirdparty/java/other/writeily/widget/WrMarkorWidgetProvider.java @@ -65,6 +65,7 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a // Open Folder final Intent goToFolder = new Intent(context, MainActivity.class) + .addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) .setAction(Intent.ACTION_VIEW) .putExtra(Document.EXTRA_FILE, directoryF); views.setOnClickPendingIntent(R.id.widget_header, PendingIntent.getActivity(context, requestCode++, goToFolder, staticFlags)); @@ -87,6 +88,7 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a // Open Notebook final Intent goHome = new Intent(context, MainActivity.class) + .addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) .setAction(Intent.ACTION_VIEW) .putExtra(Document.EXTRA_FILE, appSettings.getNotebookDirectory()); views.setOnClickPendingIntent(R.id.widget_main, PendingIntent.getActivity(context, requestCode++, goHome, staticFlags));