Skip to content

Commit

Permalink
Horked out unnecessary change too
Browse files Browse the repository at this point in the history
  • Loading branch information
harshad1 committed Oct 14, 2024
1 parent b282167 commit d26d51d
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.ActionMode;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,7 @@ public GsFileBrowserOptions.Options getFilesystemFragmentOptions(GsFileBrowserOp
public void onFsViewerConfig(GsFileBrowserOptions.Options dopt) {
dopt.descModtimeInsteadOfParent = true;
dopt.rootFolder = _appSettings.getNotebookDirectory();
final File fallback = _appSettings.getFolderToLoadByMenuId(_appSettings.getAppStartupFolderMenuId());
final File file = MarkorContextUtils.getValidIntentFile(getIntent(), fallback);
final File file = MarkorContextUtils.getValidIntentFile(getIntent(), dopt.rootFolder);
if (!GsFileBrowserListAdapter.isVirtualFolder(file) && file.isFile()) {
dopt.startFolder = file.getParentFile();
toShow = file;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
import android.text.Layout;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityEvent;
Expand All @@ -28,6 +31,7 @@
import androidx.appcompat.widget.AppCompatEditText;

import net.gsantner.markor.ApplicationObject;
import net.gsantner.markor.R;
import net.gsantner.markor.activity.MainActivity;
import net.gsantner.markor.model.AppSettings;
import net.gsantner.opoc.format.GsTextUtils;
Expand Down Expand Up @@ -111,6 +115,9 @@ public void afterTextChanged(final Editable s) {

// Fix for Android 12 perf issues - https://github.com/gsantner/markor/discussions/1794
setEmojiCompatEnabled(false);

// Custom options
setupCustomOptions();
}

@Override
Expand Down Expand Up @@ -503,6 +510,11 @@ public void withAutoFormatDisabled(final GsCallback.a0 callback) {
// Utility functions for interaction
// ---------------------------------------------------------------------------------------------

public void selectLines() {
final int[] sel = TextViewUtils.getLineSelection(this);
setSelection(sel[0], sel[1]);
}

public void simulateKeyPress(int keyEvent_KEYCODE_SOMETHING) {
dispatchKeyEvent(new KeyEvent(0, 0, KeyEvent.ACTION_DOWN, keyEvent_KEYCODE_SOMETHING, 0));
dispatchKeyEvent(new KeyEvent(0, 0, KeyEvent.ACTION_UP, keyEvent_KEYCODE_SOMETHING, 0));
Expand Down Expand Up @@ -718,4 +730,37 @@ public void reset() {
_maxNumberDigits = 0;
}
}

private void setupCustomOptions() {
setCustomSelectionActionModeCallback(new ActionMode.Callback() {
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
// Add custom items programmatically
menu.add(0, R.string.option_select_lines, 0, R.string.select_lines);
return true;
}

@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
// Modify menu items here if necessary
return true;
}

@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
switch (item.getItemId()) {
case R.string.option_select_lines:
HighlightingEditor.this.selectLines();
return true;
default:
return false;
}
}

@Override
public void onDestroyActionMode(ActionMode mode) {
// Cleanup if needed
}
});
}
}
51 changes: 0 additions & 51 deletions app/src/main/java/net/gsantner/markor/model/AppSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -746,57 +746,6 @@ public String getNavigationBarColor() {
return getString(R.string.pref_key__navigationbar_color, "#000000");
}

public String getAppStartupFolderMenuId() {
return getString(R.string.pref_key__app_start_folder, "notebook");
}

public File getFolderToLoadByMenuId(String itemId) {
List<Pair<File, String>> appDataPublicDirs = _cu.getAppDataPublicDirs(_context, false, true, false);
switch (itemId) {
case "storage": {
return new File("/storage");
}
case "notebook": {
return getNotebookDirectory();
}
case "popular_documents": {
return GsFileBrowserListAdapter.VIRTUAL_STORAGE_POPULAR;
}
case "recently_viewed_documents": {
return GsFileBrowserListAdapter.VIRTUAL_STORAGE_RECENTS;
}
case "favourites": {
return GsFileBrowserListAdapter.VIRTUAL_STORAGE_FAVOURITE;
}
case "appdata_private": {
return _cu.getAppDataPrivateDir(_context);
}
case "internal_storage": {
return Environment.getExternalStorageDirectory();
}
case "appdata_sdcard_1": {
if (appDataPublicDirs.size() > 0) {
return appDataPublicDirs.get(0).first;
}
return Environment.getExternalStorageDirectory();
}
case "appdata_sdcard_2": {
if (appDataPublicDirs.size() > 1) {
return appDataPublicDirs.get(1).first;
}
return Environment.getExternalStorageDirectory();
}
case "appdata_public": {
appDataPublicDirs = _cu.getAppDataPublicDirs(_context, true, false, false);
if (appDataPublicDirs.size() > 0) {
return appDataPublicDirs.get(0).first;
}
return _cu.getAppDataPrivateDir(_context);
}
}
return getNotebookDirectory();
}

public int getTabWidth() {
return getInt(R.string.pref_key__tab_width_v2, 1);
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/string-not_translatable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -426,4 +426,5 @@ work. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
<string name="squarebrackets" translatable="false">Square Brackets</string>
<string name="csv" translatable="false">CSV</string>
<string name="orgmode" translatable="false">OrgMode</string>
<string name="option_select_lines" translatable="false">option_select_lines</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ work. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
<string name="select_this_folder">Select this folder</string>
<string name="select">Select</string>
<string name="select_all">Select all</string>
<string name="select_lines">Select lines</string>
<string name="create">Create</string>
<string name="select_entries">Select entries</string>
<string name="one_item_selected">One item selected</string>
Expand Down

0 comments on commit d26d51d

Please sign in to comment.