Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
44fd932
Improve text editor UX for HTML code inject dialog
guanglinn Mar 12, 2026
f27058e
Tweaks
guanglinn Mar 12, 2026
8f0c9c1
Add built assets
guanglinn Mar 12, 2026
24d396d
Tweak width
guanglinn Mar 12, 2026
60c6746
Prettify default injection code
guanglinn Mar 12, 2026
5ba9121
Tweak
guanglinn Mar 12, 2026
a221ce1
Add reset button
guanglinn Mar 12, 2026
d4dc554
Add support for dark mode
guanglinn Mar 12, 2026
b2550d1
Tweak font size
guanglinn Mar 12, 2026
419d4c7
Minor improvements
guanglinn Mar 12, 2026
6303585
Tweaks
guanglinn Mar 12, 2026
c65dbd2
Fix focus issue
guanglinn Mar 13, 2026
c0cba19
Fix theme issue
guanglinn Mar 13, 2026
b85876e
Minor improvements
guanglinn Mar 13, 2026
0968b9a
Tweak
guanglinn Mar 13, 2026
3c8b3fc
Add favorite first to FolderSortDialog
guanglinn Mar 13, 2026
cc31fac
Refresh the file item view if favorite state is changed from FileInfo…
guanglinn Mar 13, 2026
bdb8ca6
Improve RenameDialog
guanglinn Mar 13, 2026
d8f9c89
Improve dialog size
guanglinn Mar 13, 2026
7e492ba
Minor improvements
guanglinn Mar 14, 2026
4d5b639
Add reset method to set text and reset history state
guanglinn Mar 15, 2026
18c74f6
Change CodeMirror source code directory and build output directory
guanglinn Mar 15, 2026
e166741
Tweak
guanglinn Mar 15, 2026
001f1a9
Minor improvements
guanglinn Mar 15, 2026
3d3b360
Fix focus
guanglinn Mar 16, 2026
0fbacdf
Should be Link text color
guanglinn Mar 16, 2026
391e441
Minor improvements
guanglinn Mar 16, 2026
0594460
Add 'loadText' method for loading large text files
guanglinn Mar 18, 2026
7989370
Add copy_build_information to strings.xml
guanglinn Mar 18, 2026
9d7876a
Update Javadoc for CodeMirrorEditor
guanglinn Mar 18, 2026
7aaf732
Merge branch 'master' into code_mirror
guanglinn Mar 20, 2026
4971693
Merge branch 'master' into code_mirror
guanglinn Apr 8, 2026
1da0175
docs: improve cm-editor/README.md
guanglinn Apr 8, 2026
255d2e2
minor improvements
guanglinn Apr 8, 2026
54d20d6
prettify indentation
guanglinn Apr 9, 2026
cd0882a
Merge branch 'master' into code_mirror
guanglinn Apr 12, 2026
e0f304c
update .gitignore
guanglinn Apr 16, 2026
96b9e57
.
guanglinn Apr 16, 2026
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ app/src/main/res/raw/readme.*
app/src/main/res/raw/contributors.*
app/flavor*

cm-editor/node_modules/

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

Expand Down
5 changes: 4 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ dependencies {
implementation "com.vladsch.flexmark:flexmark-ext-typographic:${version_library_flexmark}"
implementation "com.vladsch.flexmark:flexmark-ext-admonition:${version_library_flexmark}"

// csv support
// Source: https://mvnrepository.com/artifact/org.apache.commons/commons-text
implementation 'org.apache.commons:commons-text:1.15.0'

// CSV support
// https://opencsv.sourceforge.net/licenses.html License: Apache2
// opencsv 3.10 was the last java-6 version
// opencsv 5.7.1' for java-8 may have dependencies that are not backward compatibility with android-4.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ public void onFsViewerConfig(GsFileBrowserOptions.Options dopt) {
}
case R.id.action_info: {
if (saveDocument(false)) { // In order to have the correct info displayed
FileInfoDialog.show(_document.file, getParentFragmentManager());
FileInfoDialog.show(_document.file, getParentFragmentManager(), null);
}
return true;
}
Expand Down
15 changes: 14 additions & 1 deletion app/src/main/java/net/gsantner/markor/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

public class MainActivity extends MarkorBaseActivity implements GsFileBrowserFragment.FilesystemFragmentOptionsListener {

public static final int REQUEST_CODE_SETTINGS = 124;
public static boolean IS_DEBUG_ENABLED = false;

private BottomNavigationView _bottomNav;
Expand Down Expand Up @@ -259,7 +260,7 @@ private void optShowRate() {
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
super.onOptionsItemSelected(item);
if (item.getItemId() == R.id.action_settings) {
_cu.animateToActivity(this, SettingsActivity.class, false, null);
_cu.animateToActivity(this, SettingsActivity.class, false, REQUEST_CODE_SETTINGS);
return true;
}
return false;
Expand Down Expand Up @@ -372,6 +373,10 @@ private void newItemCallback(final File file) {

@Override
public void onBackPressed() {
if (getNotebook().clearSelection()) {
return;
}

// Check if fragment handled back press
final GsFragmentBase<?, ?> frag = getPosFragment(getCurrentPos());
if (frag == null || !frag.onBackPressed()) {
Expand Down Expand Up @@ -585,6 +590,14 @@ protected void onStop() {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
_cu.extractResultFromActivityResult(this, requestCode, resultCode, data);

if (requestCode == REQUEST_CODE_SETTINGS) {
if (resultCode == SettingsActivity.RESULT.CHANGED) {
if (data != null && data.hasExtra(SettingsActivity.INTENT_NAME_THEME_CHANGED)) {
recreate();
}
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.Toast;

import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;
Expand Down Expand Up @@ -54,7 +55,7 @@ public boolean isDividerVisible() {
}

@Override
@SuppressWarnings({"ConstantConditions", "ConstantIfStatement", "StatementWithEmptyBody"})
@SuppressWarnings({"ConstantConditions", "ConstantIfStatement"})
public Boolean onPreferenceClicked(Preference preference, String key, int keyResId) {
Activity activity = getActivity();
if (isAdded() && preference.hasKey()) {
Expand All @@ -64,7 +65,7 @@ public Boolean onPreferenceClicked(Preference preference, String key, int keyRes
return true;
}
case R.string.pref_key__more_info__settings: {
_cu.animateToActivity(activity, SettingsActivity.class, false, 124);
_cu.animateToActivity(activity, SettingsActivity.class, false, MainActivity.REQUEST_CODE_SETTINGS);
return true;
}
case R.string.pref_key__more_info__rate_app: {
Expand Down Expand Up @@ -119,12 +120,12 @@ public Boolean onPreferenceClicked(Preference preference, String key, int keyRes
}
case R.string.pref_key__more_info__copy_build_information: {
_cu.setClipboard(getContext(), preference.getSummary());
Toast.makeText(activity, R.string.copied, Toast.LENGTH_SHORT).show();
GsSimpleMarkdownParser smp = new GsSimpleMarkdownParser();
try {
String html = smp.parse(getResources().openRawResource(R.raw.changelog), "", GsSimpleMarkdownParser.FILTER_ANDROID_TEXTVIEW).getHtml();
_cu.showDialogWithHtmlTextView(getActivity(), R.string.changelog, html);
} catch (Exception ex) {

} catch (Exception ignored) {
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Toast;

import androidx.annotation.StringRes;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.res.ResourcesCompat;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.preference.Preference;
Expand All @@ -29,6 +30,7 @@
import com.rarepebble.colorpicker.ColorPreference;

import net.gsantner.markor.R;
import net.gsantner.markor.frontend.AdvancedEditTextPreference;
import net.gsantner.markor.frontend.MarkorDialogFactory;
import net.gsantner.markor.frontend.filebrowser.MarkorFileBrowserFactory;
import net.gsantner.markor.model.AppSettings;
Expand All @@ -51,13 +53,16 @@ public class SettingsActivity extends MarkorBaseActivity {

@SuppressWarnings("WeakerAccess")
public static class RESULT {
public static final int NOCHANGE = -1;
public static final int NO_CHANGE = -1;
public static final int CHANGED = 1;
public static final int RESTART_REQ = 2;
}

public static int activityRetVal = RESULT.NOCHANGE;
private static int iconColor = Color.WHITE;
public static int activityRetVal = RESULT.NO_CHANGE;

// To fix cannot go back previous screen when theme is changed
private boolean themeChanged = false;
public static final String INTENT_NAME_THEME_CHANGED = "theme_changed";

protected Toolbar toolbar;

Expand All @@ -72,10 +77,9 @@ public void onCreate(Bundle b) {

// Custom code
GsFontPreferenceCompat.additionalyCheckedFolder = new File(_appSettings.getNotebookDirectory(), ".app/fonts");
iconColor = _cu.rcolor(this, R.color.primary_text);
toolbar.setTitle(R.string.settings);
setSupportActionBar(findViewById(R.id.toolbar));
toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp));
toolbar.setNavigationIcon(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_arrow_back_white_24dp, getTheme()));
toolbar.setNavigationOnClickListener(view -> SettingsActivity.this.onBackPressed());
showFragment(SettingsFragmentMaster.TAG, false);
}
Expand Down Expand Up @@ -119,7 +123,6 @@ protected void onPreferenceChanged(SharedPreferences prefs, String key) {
}

@Override
@SuppressWarnings("rawtypes")
protected void onPreferenceScreenChanged(PreferenceFragmentCompat preferenceFragmentCompat, PreferenceScreen preferenceScreen) {
super.onPreferenceScreenChanged(preferenceFragmentCompat, preferenceScreen);
final CharSequence title = preferenceScreen.getTitle();
Expand All @@ -137,12 +140,30 @@ public void onBackPressed() {
prefFrag.goBack();
return;
}
super.onBackPressed();

if (themeChanged) {
Intent resultIntent = new Intent();
resultIntent.putExtra(INTENT_NAME_THEME_CHANGED, true);
setResult(RESULT.CHANGED, resultIntent);
finish();
} else {
super.onBackPressed();
}
}

public static class SettingsFragmentMaster extends MarkorSettingsFragment {
public static final String TAG = "SettingsFragmentMaster";

@Override
public void onDisplayPreferenceDialog(Preference preference) {
FragmentActivity activity = getActivity();
if (preference instanceof AdvancedEditTextPreference && activity != null) {
((AdvancedEditTextPreference) preference).createDialog(activity).show();
} else {
super.onDisplayPreferenceDialog(preference);
}
}

@Override
public int getPreferenceResourceForInflation() {
return R.xml.preferences_master;
Expand Down Expand Up @@ -174,7 +195,7 @@ public void doUpdatePreferences() {
updateSummary(R.string.pref_key__snippet_directory_path, _appSettings.getSnippetsDirectory().getAbsolutePath());

final String fileDescFormat = _appSettings.getString(R.string.pref_key__file_description_format, "");
if (fileDescFormat.equals("")) {
if (fileDescFormat.isEmpty()) {
updateSummary(R.string.pref_key__file_description_format, getString(R.string.default_));
} else {
updateSummary(R.string.pref_key__file_description_format, fileDescFormat);
Expand Down Expand Up @@ -216,9 +237,8 @@ protected void onPreferenceChanged(final SharedPreferences prefs, final String k
_appSettings.setRecreateMainRequired(true);
} else if (eq(key, R.string.pref_key__app_theme)) {
_appSettings.applyAppTheme();
_appSettings.setRecreateMainRequired(true);
if (getActivity() != null) {
getActivity().recreate();
if (getActivity() instanceof SettingsActivity) {
((SettingsActivity) getActivity()).themeChanged = true;
}
} else if (eq(key, R.string.pref_key__theming_hide_system_statusbar)) {
activityRetVal = RESULT.RESTART_REQ;
Expand Down Expand Up @@ -246,7 +266,7 @@ protected void onPreferenceChanged(final SharedPreferences prefs, final String k
}

@Override
@SuppressWarnings({"ConstantConditions", "ConstantIfStatement", "StatementWithEmptyBody"})
@SuppressWarnings({"ConstantConditions", "ConstantIfStatement"})
public Boolean onPreferenceClicked(Preference preference, String key, int keyResId) {
final FragmentManager fragManager = getActivity().getSupportFragmentManager();
switch (keyResId) {
Expand Down Expand Up @@ -376,11 +396,11 @@ public void onFsViewerConfig(GsFileBrowserOptions.Options dopt) {
break;
}
case R.string.pref_key__backup_settings: {
BackupUtils.showBackupWriteToDialog(getContext(), getFragmentManager());
BackupUtils.showBackupWriteToDialog(getContext(), getParentFragmentManager());
break;
}
case R.string.pref_key__restore_settings: {
BackupUtils.showBackupSelectFromDialog(getContext(), getFragmentManager());
BackupUtils.showBackupSelectFromDialog(getContext(), getParentFragmentManager());
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package net.gsantner.markor.frontend;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Point;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
import androidx.preference.DialogPreference;

import net.gsantner.markor.R;
import net.gsantner.markor.frontend.textview.CodeMirrorEditor;
import net.gsantner.opoc.util.GsContextUtils;

public class AdvancedEditTextPreference extends DialogPreference {

private String defaultValue;
private CodeMirrorEditor editText;
private boolean initialized;

public AdvancedEditTextPreference(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init();
}

public AdvancedEditTextPreference(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}

public AdvancedEditTextPreference(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init();
}

public AdvancedEditTextPreference(@NonNull Context context) {
super(context);
init();
}

private void init() {
if (!initialized) {
setDialogLayoutResource(R.layout.edit_text_preference);
initialized = true;
}
}

@Nullable
@Override
protected Object onGetDefaultValue(@NonNull TypedArray a, int index) {
defaultValue = a.getString(index);
if (defaultValue == null) {
defaultValue = "";
} else {
// Prettify indentation with 2 spaces
defaultValue = defaultValue.replaceAll("\n ", "\n ").replaceAll("\t", " ");
}
return defaultValue;
}

public AlertDialog createDialog(FragmentActivity activity) {
View view = activity.getLayoutInflater().inflate(R.layout.edit_text_preference, null);
DisplayMetrics displayMetrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
Point size = GsContextUtils.calculateDialogSize(displayMetrics, 0.95f, 1040, 0.52f, 1900);
view.setMinimumWidth(size.x);
view.setMinimumHeight(size.y);

editText = view.findViewById(R.id.editor);
editText.setOnPreparedListener(() -> {
editText.resetText(getPersistedString(defaultValue));
editText.requestFocusFromTouch();
editText.focus();
});

TextView textView = view.findViewById(R.id.title);
textView.setText(getTitle());
view.findViewById(R.id.undo).setOnClickListener(v -> editText.undo());
view.findViewById(R.id.redo).setOnClickListener(v -> editText.redo());
view.findViewById(R.id.reset).setOnClickListener(v -> editText.setText(defaultValue));

AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setView(view);
builder.setPositiveButton(activity.getString(R.string.save),
(dialog, which) -> editText.getText(this::persistString));
builder.setNegativeButton(activity.getString(R.string.cancel), null);

return builder.create();
}
}
Loading
Loading