Skip to content

Commit

Permalink
Merge branch 'master' into androidsdk-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
gsantner authored Dec 24, 2021
2 parents b481eae + acb073a commit 2fb8f66
Show file tree
Hide file tree
Showing 42 changed files with 389 additions and 239 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,7 @@ protected void onCreate(Bundle savedInstanceState) {
}

setSupportActionBar(_toolbar);
ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.setDisplayHomeAsUpEnabled(true);
ab.setDisplayShowTitleEnabled(false);
}

_toolbar.setOnClickListener(this::onToolbarTitleClicked);

_fragManager = getSupportFragmentManager();
Expand Down Expand Up @@ -283,7 +279,7 @@ public void showTextEditor(@Nullable Document document, @Nullable File file, boo
boolean sameDocumentRequested = false;
if (currentFragment instanceof DocumentEditFragment) {
String reqPath = (reqFile != null) ? reqFile.getPath() : "";
sameDocumentRequested = reqPath.equals(((DocumentEditFragment) currentFragment).getPath());
sameDocumentRequested = reqPath.equals(((DocumentEditFragment) currentFragment).getDocument().getPath());
}

if (!sameDocumentRequested) {
Expand Down Expand Up @@ -369,7 +365,7 @@ private GsFragmentBase getCurrentVisibleFragment() {

public void setDocument(Document document) {
_document = document;
_toolbarTitleText.setText(_document.getTitle());
setDocumentTitle(_document.getTitle());
}

private void onToolbarTitleClicked(View v) {
Expand Down
227 changes: 115 additions & 112 deletions app/src/main/java/net/gsantner/markor/activity/DocumentEditFragment.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private void showInDocumentActivity(Document document) {
if (getActivity() instanceof DocumentActivity) {
DocumentActivity a = (DocumentActivity) getActivity();
a.setDocument(document);
a.showTextEditor(document, null, false, _appSettings.getDocumentPreviewState(Document.getPath(document)), null);
a.showTextEditor(document, null, false, _appSettings.getDocumentPreviewState(document.getPath()), null);
}
}

Expand Down
102 changes: 44 additions & 58 deletions app/src/main/java/net/gsantner/markor/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public class MainActivity extends MarkorBaseActivity implements FilesystemViewer
private SectionsPagerAdapter _viewPagerAdapter;

private boolean _doubleBackToExitPressedOnce;
private MenuItem _lastBottomMenuItem;

private AppSettings _appSettings;
private ActivityUtils _contextUtils;
Expand Down Expand Up @@ -136,11 +135,7 @@ protected void onCreate(Bundle savedInstanceState) {

(new ActivityUtils(this)).applySpecialLaunchersVisibility(_appSettings.isSpecialFileLaunchersEnabled());

_bottomNav.postDelayed(() -> {
if (_appSettings.getAppStartupTab() != R.id.nav_notebook) {
_bottomNav.setSelectedItemId(_appSettings.getAppStartupTab());
}
}, 1);
_bottomNav.postDelayed(() -> _bottomNav.setSelectedItemId(_appSettings.getAppStartupTab()), 10);
}

private void optShowRate() {
Expand All @@ -165,20 +160,11 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
@Override
public boolean onOptionsItemSelected(MenuItem item) {
super.onOptionsItemSelected(item);
AppSettings as = new AppSettings(this);
switch (item.getItemId()) {
case R.id.action_preview: {
File f = _bottomNav.getSelectedItemId() == R.id.nav_quicknote ? as.getQuickNoteFile() : as.getTodoFile();
DocumentActivity.launch(MainActivity.this, f, false, true, null, null);
return true;
}
case R.id.action_settings: {
new ActivityUtils(this).animateToActivity(SettingsActivity.class, false, null);
return true;
}
if (item.getItemId() == R.id.action_settings) {
new ActivityUtils(this).animateToActivity(SettingsActivity.class, false, null);
return true;
}
return false;

}

@Override
Expand Down Expand Up @@ -331,38 +317,12 @@ public void onBackPressed() {

@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
updateFabVisibility(item.getItemId() == R.id.nav_notebook);
PermissionChecker permc = new PermissionChecker(this);

switch (item.getItemId()) {
case R.id.nav_notebook: {
_viewPager.setCurrentItem(0);
_toolbar.setTitle(getFileBrowserTitle());
return true;
}
_viewPager.setCurrentItem(tabIdToPos(item.getItemId()));
return true;
}

case R.id.nav_todo: {
permc.doIfExtStoragePermissionGranted(); // cannot prevent bottom tab selection
restoreDefaultToolbar();
_viewPager.setCurrentItem(1);
_toolbar.setTitle(R.string.todo);
return true;
}
case R.id.nav_quicknote: {
permc.doIfExtStoragePermissionGranted(); // cannot prevent bottom tab selection
restoreDefaultToolbar();
_viewPager.setCurrentItem(2);
_toolbar.setTitle(R.string.quicknote);
return true;
}
case R.id.nav_more: {
restoreDefaultToolbar();
_viewPager.setCurrentItem(3);
_toolbar.setTitle(R.string.more);
return true;
}
}
return false;
public void setMainTitle(final String title) {
_toolbar.setTitle(title);
}

public void updateFabVisibility(boolean visible) {
Expand All @@ -382,17 +342,41 @@ public String getFileBrowserTitle() {
return title;
}

public int tabIdToPos(final int id) {
if (id == R.id.nav_notebook) return 0;
if (id == R.id.nav_todo) return 1;
if (id == R.id.nav_quicknote) return 2;
if (id == R.id.nav_more) return 3;
return 0;
}

public int getCurrentPos() {
return _viewPager.getCurrentItem();
}

public String getPosTitle(final int pos) {
if (pos == 0) return getFileBrowserTitle();
if (pos == 1) return getString(R.string.todo);
if (pos == 2) return getString(R.string.quicknote);
if (pos == 3) return getString(R.string.more);
return "";
}

@OnPageChange(value = R.id.main__view_pager_container, callback = OnPageChange.Callback.PAGE_SELECTED)
public void onViewPagerPageSelected(int pos) {
Menu menu = _bottomNav.getMenu();
PermissionChecker permc = new PermissionChecker(this);
(_lastBottomMenuItem != null ? _lastBottomMenuItem : menu.getItem(0)).setChecked(false);
_lastBottomMenuItem = menu.getItem(pos).setChecked(true);
updateFabVisibility(pos == 0);
_toolbar.setTitle(new String[]{getFileBrowserTitle(), getString(R.string.todo), getString(R.string.quicknote), getString(R.string.more)}[pos]);
_bottomNav.getMenu().getItem(pos).setChecked(true);

updateFabVisibility(pos == tabIdToPos(R.id.nav_notebook));

setMainTitle(getPosTitle(pos));

if (pos > 0 && pos < 3) {
permc.doIfExtStoragePermissionGranted(); // cannot prevent bottom tab selection
if (pos != tabIdToPos(R.id.nav_notebook)) {
restoreDefaultToolbar();
}

if (pos == tabIdToPos(R.id.nav_quicknote) || pos == tabIdToPos(R.id.nav_todo)) {
// cannot prevent bottom tab selection
new PermissionChecker(this).doIfExtStoragePermissionGranted();
}
}

Expand Down Expand Up @@ -422,7 +406,9 @@ public void onFsViewerConfig(FilesystemViewerData.Options dopt) {
public void onFsViewerDoUiUpdate(FilesystemViewerAdapter adapter) {
if (adapter != null && adapter.getCurrentFolder() != null && !TextUtils.isEmpty(adapter.getCurrentFolder().getName())) {
_appSettings.setFileBrowserLastBrowsedFolder(adapter.getCurrentFolder());
_toolbar.setTitle(adapter.areItemsSelected() ? "" : getFileBrowserTitle());
if (getCurrentPos() == tabIdToPos(R.id.nav_notebook)) {
_toolbar.setTitle(adapter.areItemsSelected() ? "" : getFileBrowserTitle());
}
invalidateOptionsMenu();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public String convertMarkupShowInWebView(Document document, String content, WebV
}

String baseFolder = new AppSettings(context).getNotebookDirectoryAsStr();
if (document.getFile() != null && document.getFile().getParentFile() != null) {
if (document.getFile().getParentFile() != null) {
baseFolder = document.getFile().getParent();
}
baseFolder = "file://" + baseFolder + "/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public boolean onLongClick(View view) {
case R.string.tmaid_common_indent: {
SearchOrCustomTextDialogCreator.showIndentSizeDialog(_activity, _indent, (size) -> {
_indent = Integer.parseInt(size);
_appSettings.setDocumentIndentSize(getPath(), _indent);
_appSettings.setDocumentIndentSize(_document.getPath(), _indent);
});
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class MarkdownTextConverter extends TextConverter {
public static final String CSS_BLOCKQUOTE_VERTICAL_LINE = CSS_S + "blockquote{padding:0px 14px;border-" + TOKEN_TEXT_DIRECTION + ":3.5px solid #dddddd;margin:4px 0}" + CSS_E;
public static final String CSS_LIST_TASK_NO_BULLET = CSS_S + ".task-list-item { list-style-type:none; text-indent: -1.4em; }" + CSS_E;
public static final String CSS_GITLAB_VIDEO_CAPTION = CSS_S + ".video-container > p { margin: 0; }" + CSS_E;
public static final String CSS_LINK_SOFT_WRAP_AUTOBREAK_LINES = CSS_S + "p > a { word-break:break-all; }" + CSS_E;

public static final String CSS_TOC_STYLE = CSS_S + ".markor-table-of-contents { border: 1px solid " + TOKEN_BW_INVERSE_OF_THEME + "; border-radius: 2px; } .markor-table-of-contents > h1 { padding-left: 14px; margin-bottom: -8px; border-bottom: 1px solid " + TOKEN_BW_INVERSE_OF_THEME + "; } .markor-table-of-contents-list li { margin-left: -12px; } .markor-table-of-contents-list a { text-decoration: none; }" + CSS_E;
public static final String CSS_PRESENTATION_BEAMER = "<!-- " + TOKEN_TEXT_CONVERTER_MAX_ZOOM_OUT_BY_DEFAULT + " -->" + CSS_S + "img { max-width: 100%; } a:visited, a:link, a:hover, a:focus, a:active { color:inherit; } table { border-collapse: collapse; width: 100%; } table, th, td { padding: 5px; } body { font-family: Helvetica, Arial, Freesans, clean, sans-serif; padding:0 0 0 0; margin:auto; max-width:42em; } h1, h2, h3, h4, h5, h6 { font-weight: bold; } h1 { font-size: 28px; border-bottom: 2px solid; border-bottom-color: inherit; } h2 { font-size: 24px; border-bottom: 2px solid; border-bottom-color: inherit; } h3 { font-size: 18px; } h4 { font-size: 16px; } h5 { font-size: 14px; } h6 { font-size: 14px; } p, blockquote, ul, ol, dl, li, table, pre { margin: 15px 0; } code { margin: 0 2px; padding: 0 5px; } pre { line-height: 1.25em; overflow: auto; padding: 6px 10px; } pre > code { border: 0; margin: 0; padding: 0; } code { font-family: monospace; } img { max-width: 100%; } .slide { display: flex; width: 297mm; height: 166mm; margin: 0 auto 20px auto; padding: 0; align-items: center; border: 1px solid " + TOKEN_BW_INVERSE_OF_THEME + "; } .slide_body { display: block; width: 260mm; height: 155mm; margin: auto; overflow: hidden; } .slide_body:empty { display: none; } .slide:empty{ display: none; } @media print { body { margin: 0; padding: 0; } .slide { page-break-after: always; margin: 0; padding: 0; width: 297mm; min-height: 200mm; height: 200mm; max-height: 200mm; border: none; overflow: hidden; border: 0; } } *:not(span){ unicode-bidi: plaintext; } .slide_title > *{ text-align: center; border-bottom: 0px; font-size: 450%; } .slide_title > h1 { font-size: 550%; } .slide_body:not(.slide_title) > * { font-size: 200%; } .slide_body:not(.slide_title) > h1 { font-size: 350%; } .slide_body:not(.slide_title) > h2 { font-size: 310%; } img[alt*='imghcenter'] { display:block; margin-left: auto; margin-right: auto; } img[alt*='imgbig'] { object-fit: cover; min-height: 100%; min-width: 70%; } .slide_body:not(.slide_title) > h3 { font-size: 280%; }" + CSS_E;
Expand Down Expand Up @@ -157,7 +158,7 @@ public String convertMarkup(String markup, Context context, boolean isExportInLi
.set(AnchorLinkExtension.ANCHORLINKS_ANCHOR_CLASS, "header_no_underline");

// Prepare head and javascript calls
head += CSS_HEADER_UNDERLINE + CSS_H1_H2_UNDERLINE + CSS_BLOCKQUOTE_VERTICAL_LINE + CSS_GITLAB_VIDEO_CAPTION + CSS_LIST_TASK_NO_BULLET;
head += CSS_HEADER_UNDERLINE + CSS_H1_H2_UNDERLINE + CSS_BLOCKQUOTE_VERTICAL_LINE + CSS_GITLAB_VIDEO_CAPTION + CSS_LIST_TASK_NO_BULLET + CSS_LINK_SOFT_WRAP_AUTOBREAK_LINES;

// Presentations
final boolean enablePresentationBeamer = markup.contains("\nclass:beamer") || markup.contains("\nclass: beamer");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public boolean onLongClick(View v) {
case R.string.tmaid_common_indent: {
SearchOrCustomTextDialogCreator.showIndentSizeDialog(_activity, _indent, (size) -> {
_indent = Integer.parseInt(size);
_appSettings.setDocumentIndentSize(getPath(), _indent);
_appSettings.setDocumentIndentSize(_document.getPath(), _indent);
});
return true;
}
Expand Down
Loading

0 comments on commit 2fb8f66

Please sign in to comment.