Skip to content

Commit

Permalink
Merge branch 'master' into auto_scroll_dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
gsantner authored Jul 27, 2024
2 parents ccb7df2 + 57aaf0f commit 2d2f46c
Show file tree
Hide file tree
Showing 47 changed files with 48 additions and 2,284 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (enable_plugin_kotlin) {
apply plugin: 'kotlin-kapt'
}

rootProject.ext.version_minSdk = 16
rootProject.ext.version_minSdk = 18

// https://github.com/vsch/flexmark-java/releases
ext.version_library_flexmark = "0.42.14"
Expand Down Expand Up @@ -142,7 +142,7 @@ dependencies {
implementation 'com.github.AppIntro:AppIntro:6.2.0'
implementation 'com.kailashdabhi:om-recorder:1.1.5'
implementation 'com.github.mertakdut:EpubParser:1.0.95'
implementation project(':app:thirdparty-lib-src:QuadFlask-colorpicker')
implementation 'com.github.martin-stone:hsv-alpha-color-picker-android:3.1.0'

// Tool libraries
//noinspection AnnotationProcessorOnCompilePath
Expand Down
45 changes: 0 additions & 45 deletions app/src/main/java/net/gsantner/markor/format/ActionButtonBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
import androidx.annotation.StringRes;
import androidx.appcompat.widget.TooltipCompat;

import com.flask.colorpicker.ColorPickerView;
import com.flask.colorpicker.Utils;
import com.flask.colorpicker.builder.ColorPickerClickListener;
import com.flask.colorpicker.builder.ColorPickerDialogBuilder;

import net.gsantner.markor.ApplicationObject;
import net.gsantner.markor.R;
import net.gsantner.markor.activity.DocumentActivity;
Expand Down Expand Up @@ -996,46 +991,6 @@ public void runSpecialKeyAction() {
});
}

public void showColorPickerDialog() {
MarkorDialogFactory.showColorSelectionModeDialog(getActivity(), new GsCallback.a1<Integer>() {
@Override
public void callback(Integer colorInsertType) {
ColorPickerDialogBuilder
.with(_hlEditor.getContext())
.setTitle(R.string.color)
.wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
.density(12)
.setPositiveButton(android.R.string.ok, new ColorPickerClickListener() {
@Override
public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) {
String hex = Utils.getHexString(selectedColor, false).toLowerCase();
int pos = _hlEditor.getSelectionStart();
switch (colorInsertType) {
case R.string.hexcode: {
_hlEditor.getText().insert(pos, hex);
break;
}
case R.string.foreground: {
_hlEditor.getText().insert(pos, "<span style='color:" + hex + ";'></span>");
_hlEditor.setSelection(_hlEditor.getSelectionStart() - 7);
break;
}
case R.string.background: {
_hlEditor.getText().insert(pos, "<span style='background-color:" + hex + ";'></span>");
_hlEditor.setSelection(_hlEditor.getSelectionStart() - 7);
break;
}
}

}
})
.setNegativeButton(R.string.cancel, null)
.build()
.show();
}
});
}

public void runJumpBottomTopAction(ActionItem.DisplayMode displayMode) {
if (displayMode == ActionItem.DisplayMode.EDIT) {
int pos = _hlEditor.getSelectionStart();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,18 +454,12 @@ private String replaceTokens(final String markup, final Map<String, List<String>
// Extension to add line numbers to headings
// ---------------------------------------------------------------------------------------------

public static String getIdForLineNumber(final int num) {
return "line-" + num;
}

private static class LineNumberIdProvider implements AttributeProvider {
@Override
public void setAttributes(Node node, AttributablePart part, Attributes attributes) {
if (node instanceof com.vladsch.flexmark.ast.Heading) {
final Document document = node.getDocument();
final int lineNumber = document.getLineNumber(node.getStartOffset());
attributes.addValue("id", getIdForLineNumber(lineNumber));
}
final Document document = node.getDocument();
final int lineNumber = document.getLineNumber(node.getStartOffset());
attributes.addValue("line", "" + lineNumber);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -844,9 +844,12 @@ public static void showHeadlineDialog(
final int line = headings.get(index).line;

TextViewUtils.selectLines(edit, line);

final String id = MarkdownTextConverter.getIdForLineNumber(line);
webView.loadUrl(String.format("javascript:document.getElementById('%s').scrollIntoView();", id));
final String jumpJs = "document.querySelector('[line=\"" + line + "\"]').scrollIntoView();";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
webView.evaluateJavascript(jumpJs, null);
} else {
webView.loadUrl("javascript:" + jumpJs);
}
};

dopt.neutralButtonText = R.string.filter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,15 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
final MarkorContextUtils cu = new MarkorContextUtils(getContext());
dialogBuilder.setNegativeButton(R.string.cancel, (dialogInterface, i) -> dialogInterface.dismiss());
dialogBuilder.setPositiveButton(getString(android.R.string.ok), (dialogInterface, i) -> {
final FormatRegistry.Format fmt = formats.get(typeSpinner.getSelectedItemPosition());

final String title = getTitle.callback();
final String ext = extEdit.getText().toString().trim();
final String fileName = GsFileUtils.getFilteredFilenameWithoutDisallowedChars(title + ext);
String fileName = GsFileUtils.getFilteredFilenameWithoutDisallowedChars(title + ext);

if (fmt.format == FormatRegistry.FORMAT_WIKITEXT) {
fileName = fileName.replace(" ", "_");
}

// Get template string
// -------------------------------------------------------------------------------------
Expand All @@ -286,7 +291,6 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
// These are done even if the file isn't created
final String titleFormat = formatEdit.getText().toString().trim();
appSettings.setTemplateTitleFormat(templateAdapter.getItem(ti), titleFormat);
final FormatRegistry.Format fmt = formats.get(typeSpinner.getSelectedItemPosition());
appSettings.setTypeTemplate(fmt.format, (String) templateSpinner.getSelectedItem());
appSettings.setNewFileDialogLastUsedType(fmt.format);
appSettings.setNewFileDialogLastUsedExtension(extEdit.getText().toString().trim());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public File getDefaultTodoFile() {

public File getSnippetsDirectory() {
final File _default = new File(getNotebookDirectory(), ".app/snippets");
final File snf = new File(getString(R.string.pref_key__quicknote_filepath, _default.getAbsolutePath()));
final File snf = new File(getString(R.string.pref_key__snippet_directory_path, _default.getAbsolutePath()));
return snf.isDirectory() && snf.canRead() ? snf : _default;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
import androidx.preference.PreferenceScreen;
import androidx.recyclerview.widget.RecyclerView;

import com.rarepebble.colorpicker.ColorPreference;

import net.gsantner.opoc.model.GsSharedPreferencesPropertyBackend;
import net.gsantner.opoc.util.GsContextUtils;
import net.gsantner.opoc.wrapper.GsCallback;
Expand Down Expand Up @@ -154,7 +156,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {

if (activity != null && activity.getTheme() != null) {
TypedArray array = activity.getTheme().obtainStyledAttributes(new int[]{android.R.attr.colorBackground});
int bgcolor = array.getColor(0, 0xFFFFFFFF);
int bgcolor = array.getColor(0, 0xFFFFFF);
_defaultIconTintColor = _cu.shouldColorOnTopBeLight(bgcolor) ? Color.WHITE : Color.BLACK;
}

Expand Down Expand Up @@ -295,6 +297,14 @@ protected void onPreferenceChanged(SharedPreferences prefs, String key) {
}
}

public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof ColorPreference) {
((ColorPreference) preference).showDialog(this, 0);
} else {
super.onDisplayPreferenceDialog(preference);
}
}

@Override
@Deprecated
public boolean onPreferenceTreeClick(Preference preference) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,15 +644,18 @@ private void loadFolder(final File folder, final @Nullable File toShow) {
virtualMapping.put(VIRTUAL_STORAGE_APP_DATA_PRIVATE, appDataFolder);
newData.add(VIRTUAL_STORAGE_APP_DATA_PRIVATE);
}
} else if (folder.isDirectory()) {
GsCollectionUtils.addAll(newData, folder.listFiles(GsFileBrowserListAdapter.this));
} else if (folder.equals(VIRTUAL_STORAGE_RECENTS)) {
newData.addAll(_dopt.recentFiles);
} else if (folder.equals(VIRTUAL_STORAGE_POPULAR)) {
newData.addAll(_dopt.popularFiles);
} else if (folder.equals(VIRTUAL_STORAGE_FAVOURITE)) {
newData.addAll(_dopt.favouriteFiles);
} else if (folder.getAbsolutePath().equals("/storage/emulated")) {
} else if (folder.isDirectory()) {
GsCollectionUtils.addAll(newData, folder.listFiles(GsFileBrowserListAdapter.this));
}

// Some special folders get special children
if (folder.getAbsolutePath().equals("/storage/emulated")) {
newData.add(new File(folder, "0"));
} else if (folder.getAbsolutePath().equals("/")) {
newData.add(new File(folder, "storage"));
Expand All @@ -663,15 +666,16 @@ private void loadFolder(final File folder, final @Nullable File toShow) {
}

for (final File externalFileDir : ContextCompat.getExternalFilesDirs(_context, null)) {
for (int i = 0; i < newData.size(); i++) {
final File file = newData.get(i);
if (!canWrite(file) && !file.getAbsolutePath().equals("/") && externalFileDir != null && externalFileDir.getAbsolutePath().startsWith(file.getAbsolutePath())) {
final int depth = GsTextUtils.countChars(file.getAbsolutePath(), '/')[0];
for (final File file : newData) {
final String absPath = file.getAbsolutePath();
final String absExt = externalFileDir.getAbsolutePath() ;
if (!canWrite(file) && !absPath.equals("/") && absExt.startsWith(absPath)) {
final int depth = GsTextUtils.countChars(absPath, '/')[0];
if (depth < 3) {
final File parent = file.getParentFile();
if (parent != null) {
final File remap = new File(parent.getAbsolutePath(), "appdata-public (" + file.getName() + ")");
virtualMapping.put(remap, new File(externalFileDir.getAbsolutePath()));
virtualMapping.put(remap, new File(absExt));
newData.add(remap);
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ work. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
<string name="name">名稱</string>
<string name="url_or_path">網址 / 路徑</string>
<string name="insert_link">插入連結</string>
<string name="format_link">格式化連結</string>
<string name="insert_image">插入圖像</string>
<string name="contributors">貢獻人</string>
<string name="save_location">保存位置</string>
Expand Down
11 changes: 5 additions & 6 deletions app/src/main/res/xml/preferences_master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,26 +200,25 @@
android:summary="@string/background_foreground_color_in_editor_works_dark_light"
android:title="@string/basic_color_scheme">

<other.com.flask.colorpicker.ColorPickerPreference
<com.rarepebble.colorpicker.ColorPreference
android:defaultValue="@color/background"
android:icon="@drawable/ic_border_outer_black_24dp"
android:key="@string/pref_key__basic_color_scheme__bg_light"
android:title="BG Light" />

<other.com.flask.colorpicker.ColorPickerPreference
<com.rarepebble.colorpicker.ColorPreference
android:defaultValue="@color/dark_grey"
android:icon="@drawable/ic_text_fields_black_24dp"
android:key="@string/pref_key__basic_color_scheme__fg_light"
android:title="FG Light" />

<other.com.flask.colorpicker.ColorPickerPreference
<com.rarepebble.colorpicker.ColorPreference
android:defaultValue="@color/dark_grey"
android:icon="@drawable/ic_border_outer_black_24dp"
android:key="@string/pref_key__basic_color_scheme__bg_dark"
android:title="BG Dark" />


<other.com.flask.colorpicker.ColorPickerPreference
<com.rarepebble.colorpicker.ColorPreference
android:defaultValue="@color/white"
android:icon="@drawable/ic_text_fields_black_24dp"
android:key="@string/pref_key__basic_color_scheme__fg_dark"
Expand Down Expand Up @@ -420,7 +419,7 @@
</PreferenceCategory>

<PreferenceCategory android:title="@string/text">
<other.com.flask.colorpicker.ColorPickerPreference
<com.rarepebble.colorpicker.ColorPreference
android:defaultValue="@color/default_link_color"
android:icon="@drawable/ic_format_underlined_black_24dp"
android:key="@string/pref_key__view_mode_link_color"
Expand Down
1 change: 0 additions & 1 deletion app/thirdparty-lib-src/QuadFlask-colorpicker/.gitignore

This file was deleted.

13 changes: 0 additions & 13 deletions app/thirdparty-lib-src/QuadFlask-colorpicker/LICENSE-QuadFlask.md

This file was deleted.

Loading

0 comments on commit 2d2f46c

Please sign in to comment.