Skip to content

Commit

Permalink
Improvement to launching activities
Browse files Browse the repository at this point in the history
  • Loading branch information
harshad1 committed Jun 3, 2024
1 parent 5c7b194 commit 0188154
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,35 @@ public class DocumentActivity extends MarkorBaseActivity {

public static void launch(final Activity activity, File path, final Boolean doPreview, Intent intent, final Integer lineNumber) {
final AppSettings as = ApplicationObject.settings();

if (intent == null) {
intent = new Intent(activity, DocumentActivity.class);
}

if (path != null) {
intent.putExtra(Document.EXTRA_FILE, path);
} else {
path = intent.hasExtra(Document.EXTRA_FILE) ? ((File) intent.getSerializableExtra(Document.EXTRA_FILE)) : null;
}

if (lineNumber != null && lineNumber >= 0) {
intent.putExtra(Document.EXTRA_FILE_LINE_NUMBER, lineNumber);
}

if (doPreview != null) {
intent.putExtra(DocumentActivity.EXTRA_DO_PREVIEW, doPreview);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && ApplicationObject.settings().isMultiWindowEnabled()) {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && as.isMultiWindowEnabled()) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
} else {
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
}

if (path != null && path.isDirectory()) {
intent = new Intent(activity, MainActivity.class).putExtra(Document.EXTRA_FILE, path);
}
if (path != null && path.isFile() && as.isPreferViewMode()) {
as.setDocumentPreviewState(path.getAbsolutePath(), true);
}

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 @@ -64,6 +64,8 @@ public class DocumentShareIntoFragment extends MarkorBaseFragment {
public static final String EXTRA_SHARED_TEXT = "EXTRA_SHARED_TEXT";
public static final String TEXT_TOKEN = "{{text}}";

private static final String CHECKBOX_TAG = "insert_link_checkbox";

public static DocumentShareIntoFragment newInstance(final Intent intent) {
final DocumentShareIntoFragment f = new DocumentShareIntoFragment();
final Bundle args = new Bundle();
Expand Down Expand Up @@ -123,7 +125,6 @@ public void onViewCreated(final @NonNull View view, final Bundle savedInstanceSt
}

private CheckBox addCheckBoxToToolbar() {
final String CHECKBOX_TAG = "insert_link_checkbox";

final Activity activity = getActivity();
if (activity == null) {
Expand Down Expand Up @@ -163,6 +164,23 @@ private CheckBox addCheckBoxToToolbar() {
return checkBox;
}

private void removeCheckbox() {
final Activity activity = getActivity();
if (activity == null) {
return;
}

final Toolbar toolbar = activity.findViewById(R.id.toolbar);
if (toolbar == null) {
return;
}

final CheckBox checkBox = toolbar.findViewWithTag(CHECKBOX_TAG);
if (checkBox != null) {
toolbar.removeView(checkBox);
}
}

@Override
public String getFragmentTag() {
return FRAGMENT_TAG;
Expand Down

0 comments on commit 0188154

Please sign in to comment.