-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Navigation and highlighting improvements #2377
Merged
gsantner
merged 34 commits into
gsantner:master
from
harshad1:file_browser_improvements
Sep 16, 2024
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
a25a941
Many fixes to navigation and go back
harshad1 7de0995
Revert name change
harshad1 8ea9255
Revert revert
harshad1 4bae533
Cleanups to fragment handling
harshad1 fafd54a
Merge remote-tracking branch 'upstream/master' into file_browser_impr…
harshad1 d987437
Tweaks to showing keyboard
harshad1 c46d692
Final tweaks to activity stacks
harshad1 4f5428a
Removed unnecessary 'synchronized' calls for perf
harshad1 fdc484a
Cleanups
harshad1 c0e7b5c
Tweaks to highlighting
harshad1 587c005
Reverted some highlighting changes
harshad1 12ced96
More reverts
harshad1 287c271
Fix template cursor start
harshad1 00eae25
Improvements to display of file browser dialog / fragment
harshad1 092f22e
Initial set of changes for async
harshad1 4268201
Using canonical paths and and static members
harshad1 f731478
Merge branch 'file_browser_improvements' into highlight_in_separate_t…
harshad1 3ee43ac
Twesks to get it to work
harshad1 daeeeb0
Merge remote-tracking branch 'upstream/master' into file_browser_impr…
harshad1 3f906a1
Merge branch 'file_browser_improvements' into highlight_in_separate_t…
harshad1 d0417a8
Some small cleanups
harshad1 dd39531
Need index
harshad1 a656226
Cleaned op order of tests
harshad1 4631024
Defensive logic for indices
harshad1 1ca5698
Tweaks
harshad1 0d037ef
Batching fixup for reduced computation
harshad1 c620feb
Switching back to start end as it made no difference
harshad1 6b1bc6c
Yet more massaging spans for performance
harshad1 3a2daaa
Tweaks to reflow
harshad1 3738d2b
Tweaks and documentation
harshad1 372d7b5
Tweaks to launching; file paths -> canonical
harshad1 7cdb847
Fixed deps
harshad1 2cdef58
imports
harshad1 8c63366
Fixed wikitext link formatting
harshad1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,18 +37,24 @@ | |
import net.gsantner.opoc.util.GsFileUtils; | ||
|
||
import java.io.File; | ||
import java.util.Stack; | ||
|
||
import other.so.AndroidBug5497Workaround; | ||
|
||
public class DocumentActivity extends MarkorBaseActivity { | ||
public static final String EXTRA_DO_PREVIEW = "EXTRA_DO_PREVIEW"; | ||
|
||
private Toolbar _toolbar; | ||
|
||
private FragmentManager _fragManager; | ||
|
||
private static boolean nextLaunchTransparentBg = false; | ||
|
||
public static void launch(final Activity activity, final Intent intent) { | ||
final File file = MarkorContextUtils.getIntentFile(intent, null); | ||
final Integer lineNumber = intent.hasExtra(Document.EXTRA_FILE_LINE_NUMBER) ? intent.getIntExtra(Document.EXTRA_FILE_LINE_NUMBER, -1) : null; | ||
final Boolean doPreview = intent.hasExtra(Document.EXTRA_DO_PREVIEW) ? intent.getBooleanExtra(Document.EXTRA_DO_PREVIEW, false) : null; | ||
launch(activity, file, doPreview, lineNumber); | ||
} | ||
|
||
public static void launch( | ||
final Activity activity, | ||
final File file, | ||
|
@@ -90,18 +96,16 @@ private static void launch( | |
|
||
intent.putExtra(Document.EXTRA_FILE, file); | ||
|
||
if (lineNumber != null && lineNumber >= 0) { | ||
if (lineNumber != null) { | ||
intent.putExtra(Document.EXTRA_FILE_LINE_NUMBER, lineNumber); | ||
} | ||
|
||
if (doPreview != null) { | ||
intent.putExtra(DocumentActivity.EXTRA_DO_PREVIEW, doPreview); | ||
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); | ||
} else { | ||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); | ||
} | ||
|
||
nextLaunchTransparentBg = (activity instanceof MainActivity); | ||
|
@@ -190,7 +194,7 @@ private void handleLaunchingIntent(final Intent intent) { | |
final Document doc = new Document(file); | ||
Integer startLine = null; | ||
if (intent.hasExtra(Document.EXTRA_FILE_LINE_NUMBER)) { | ||
startLine = intent.getIntExtra(Document.EXTRA_FILE_LINE_NUMBER, -1); | ||
startLine = intent.getIntExtra(Document.EXTRA_FILE_LINE_NUMBER, Document.EXTRA_FILE_LINE_NUMBER_LAST); | ||
} else if (intentData != null) { | ||
final String line = intentData.getQueryParameter("line"); | ||
if (line != null) { | ||
|
@@ -203,7 +207,7 @@ private void handleLaunchingIntent(final Intent intent) { | |
if (startLine != null) { | ||
// If a line is requested, open in edit mode so the line is shown | ||
startInPreview = false; | ||
} else if (intent.getBooleanExtra(EXTRA_DO_PREVIEW, false) || file.getName().startsWith("index.")) { | ||
} else if (intent.getBooleanExtra(Document.EXTRA_DO_PREVIEW, false) || file.getName().startsWith("index.")) { | ||
startInPreview = true; | ||
} | ||
|
||
|
@@ -272,11 +276,11 @@ public void setDocumentTitle(final String title) { | |
} | ||
|
||
public void showTextEditor(final Document document, final Integer lineNumber, final Boolean startPreview) { | ||
final GsFragmentBase currentFragment = getCurrentVisibleFragment(); | ||
final GsFragmentBase<?, ?> currentFragment = getCurrentVisibleFragment(); | ||
|
||
final boolean sameDocumentRequested = ( | ||
currentFragment instanceof DocumentEditAndViewFragment && | ||
document.getPath().equals(((DocumentEditAndViewFragment) currentFragment).getDocument().getPath())); | ||
document.path.equals(((DocumentEditAndViewFragment) currentFragment).getDocument().path)); | ||
gsantner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (!sameDocumentRequested) { | ||
showFragment(DocumentEditAndViewFragment.newInstance(document, lineNumber, startPreview)); | ||
|
@@ -297,21 +301,15 @@ protected void onResume() { | |
@Override | ||
@SuppressWarnings("StatementWithEmptyBody") | ||
public void onBackPressed() { | ||
FragmentManager fragMgr = getSupportFragmentManager(); | ||
GsFragmentBase top = getCurrentVisibleFragment(); | ||
if (top != null) { | ||
if (!top.onBackPressed()) { | ||
if (fragMgr.getBackStackEntryCount() == 1) { | ||
// Back action was not handled by fragment, handle in activity | ||
} else if (fragMgr.getBackStackEntryCount() > 0) { | ||
// Back action was to go one fragment back | ||
fragMgr.popBackStack(); | ||
return; | ||
} | ||
} else { | ||
// Was handled by child fragment | ||
return; | ||
} | ||
final int entryCount = _fragManager.getBackStackEntryCount(); | ||
final GsFragmentBase<?, ?> top = getCurrentVisibleFragment(); | ||
|
||
// We pop the stack to go back to the previous fragment | ||
// if the top fragment does not handle the back press | ||
// Doesn't actually get called as we have 1 fragment in the stack | ||
if (top != null && !top.onBackPressed() && entryCount > 1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Back now goes to previous directory |
||
_fragManager.popBackStack(); | ||
return; | ||
} | ||
|
||
// Handle in this activity | ||
|
@@ -324,10 +322,10 @@ public void onBackPressed() { | |
|
||
@Override | ||
public boolean onKeyDown(int keyCode, KeyEvent event) { | ||
return super.onReceiveKeyPress(getCurrentVisibleFragment(), keyCode, event) ? true : super.onKeyDown(keyCode, event); | ||
return super.onReceiveKeyPress(getCurrentVisibleFragment(), keyCode, event) || super.onKeyDown(keyCode, event); | ||
} | ||
|
||
public GsFragmentBase showFragment(GsFragmentBase fragment) { | ||
public GsFragmentBase<?, ?> showFragment(GsFragmentBase<?, ?> fragment) { | ||
if (fragment != getCurrentVisibleFragment()) { | ||
_fragManager.beginTransaction() | ||
.replace(R.id.document__placeholder_fragment, fragment, fragment.getFragmentTag()) | ||
|
@@ -338,11 +336,11 @@ public GsFragmentBase showFragment(GsFragmentBase fragment) { | |
return fragment; | ||
} | ||
|
||
public synchronized GsFragmentBase getExistingFragment(final String fragmentTag) { | ||
return (GsFragmentBase) getSupportFragmentManager().findFragmentByTag(fragmentTag); | ||
public synchronized GsFragmentBase<?, ?> getExistingFragment(final String fragmentTag) { | ||
return (GsFragmentBase<?, ?>) getSupportFragmentManager().findFragmentByTag(fragmentTag); | ||
} | ||
|
||
private GsFragmentBase getCurrentVisibleFragment() { | ||
return (GsFragmentBase) getSupportFragmentManager().findFragmentById(R.id.document__placeholder_fragment); | ||
private GsFragmentBase<?, ?> getCurrentVisibleFragment() { | ||
return (GsFragmentBase<?, ?>) getSupportFragmentManager().findFragmentById(R.id.document__placeholder_fragment); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for checking the new installation options and fixing it