Skip to content

Commit

Permalink
Merge branch 'master' into scroll_sync
Browse files Browse the repository at this point in the history
  • Loading branch information
guanglinn authored Sep 17, 2024
2 parents 54bd600 + ea066b6 commit e6c4ed2
Show file tree
Hide file tree
Showing 43 changed files with 1,043 additions and 833 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-android-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ jobs:

- name: "Artifacts: All"
if: always()
uses: actions/upload-artifact@v2.2.1
uses: actions/upload-artifact@v4
with:
name: "all"
path: dist
retention-days: 5

- name: "Artifacts: Android APK"
uses: actions/upload-artifact@v2.2.1
uses: actions/upload-artifact@v4
with:
name: "android-apk"
path: |
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ Todo.txt is a simple text format for todo. Each line of text is a task. The idea
| [User Documentation](https://github.com/todotxt/todo.txt-cli/wiki/User-Documentation) | User documentation |


![todotxt](doc/assets/todotxt-format.png)
![todotxt](doc/assets/todotxt-format-dark.png#gh-dark-mode-only)
![todotxt](doc/assets/todotxt-format.png#gh-light-mode-only)

#### How to mark a task done?
Done tasks are marked by a `x ` in begining of the line and can optionally be moved to a done/archive file.
Expand Down
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'

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));

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) {
_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

0 comments on commit e6c4ed2

Please sign in to comment.