Skip to content

Commit

Permalink
Fix how multiple windows are launched (PR gsantner#2419)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshad1 authored Sep 19, 2024
1 parent d4183ef commit 169664f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand Down

0 comments on commit 169664f

Please sign in to comment.