Skip to content
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
merged 34 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
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 Jul 29, 2024
7de0995
Revert name change
harshad1 Jul 29, 2024
8ea9255
Revert revert
harshad1 Jul 29, 2024
4bae533
Cleanups to fragment handling
harshad1 Aug 8, 2024
fafd54a
Merge remote-tracking branch 'upstream/master' into file_browser_impr…
harshad1 Aug 8, 2024
d987437
Tweaks to showing keyboard
harshad1 Aug 14, 2024
c46d692
Final tweaks to activity stacks
harshad1 Aug 15, 2024
4f5428a
Removed unnecessary 'synchronized' calls for perf
harshad1 Aug 16, 2024
fdc484a
Cleanups
harshad1 Aug 16, 2024
c0e7b5c
Tweaks to highlighting
harshad1 Aug 17, 2024
587c005
Reverted some highlighting changes
harshad1 Aug 17, 2024
12ced96
More reverts
harshad1 Aug 17, 2024
287c271
Fix template cursor start
harshad1 Aug 17, 2024
00eae25
Improvements to display of file browser dialog / fragment
harshad1 Aug 17, 2024
092f22e
Initial set of changes for async
harshad1 Aug 18, 2024
4268201
Using canonical paths and and static members
harshad1 Aug 18, 2024
f731478
Merge branch 'file_browser_improvements' into highlight_in_separate_t…
harshad1 Aug 18, 2024
3ee43ac
Twesks to get it to work
harshad1 Aug 18, 2024
daeeeb0
Merge remote-tracking branch 'upstream/master' into file_browser_impr…
harshad1 Aug 18, 2024
3f906a1
Merge branch 'file_browser_improvements' into highlight_in_separate_t…
harshad1 Aug 19, 2024
d0417a8
Some small cleanups
harshad1 Aug 19, 2024
dd39531
Need index
harshad1 Aug 19, 2024
a656226
Cleaned op order of tests
harshad1 Aug 20, 2024
4631024
Defensive logic for indices
harshad1 Aug 23, 2024
1ca5698
Tweaks
harshad1 Aug 25, 2024
0d037ef
Batching fixup for reduced computation
harshad1 Aug 27, 2024
c620feb
Switching back to start end as it made no difference
harshad1 Aug 27, 2024
6b1bc6c
Yet more massaging spans for performance
harshad1 Aug 27, 2024
3a2daaa
Tweaks to reflow
harshad1 Aug 27, 2024
3738d2b
Tweaks and documentation
harshad1 Aug 28, 2024
372d7b5
Tweaks to launching; file paths -> canonical
harshad1 Sep 4, 2024
7cdb847
Fixed deps
harshad1 Sep 4, 2024
2cdef58
imports
harshad1 Sep 4, 2024
8c63366
Fixed wikitext link formatting
harshad1 Sep 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ dependencies {


// UI libs
implementation 'com.pixplicity.generate:library:1.1.8'
implementation 'com.github.Pixplicity:gene-rate:v1.1.8'
implementation 'com.github.AppIntro:AppIntro:6.2.0'
implementation 'com.kailashdabhi:om-recorder:1.1.5'
implementation 'com.github.kailash09dabhi:OmRecorder:1.1.5'
implementation 'com.github.mertakdut:EpubParser:1.0.95'
implementation 'com.github.martin-stone:hsv-alpha-color-picker-android:3.1.0'
Copy link
Owner

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


Expand Down
4 changes: 2 additions & 2 deletions 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="singleInstance"
android:launchMode="standard"
android:taskAffinity=".activity.MainActivity"
android:windowSoftInputMode="stateUnchanged|adjustResize">
<intent-filter>
Expand Down Expand Up @@ -167,7 +167,7 @@
</activity>
<activity
android:name=".activity.openeditor.OpenFromShortcutOrWidgetActivity"
android:launchMode="singleTop"
android:launchMode="standard"
android:theme="@android:style/Theme.NoDisplay" />
<activity
android:name=".activity.DocumentActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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));
Expand All @@ -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) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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
Expand All @@ -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())
Expand All @@ -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);
}
}
Loading
Loading