Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteEditFragment.java')
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteEditFragment.java29
1 files changed, 20 insertions, 9 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteEditFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteEditFragment.java
index ff529277..1a1ab089 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteEditFragment.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteEditFragment.java
@@ -41,9 +41,12 @@ import it.niedermann.owncloud.notes.util.format.ContextBasedRangeFormattingCallb
import static androidx.core.view.ViewCompat.isAttachedToWindow;
import static it.niedermann.owncloud.notes.util.DisplayUtils.searchAndColor;
+import static it.niedermann.owncloud.notes.util.NoteUtil.getFontSizeFromPreferences;
public class NoteEditFragment extends SearchableBaseNoteFragment {
+ private static final String TAG = NoteEditFragment.class.getSimpleName();
+
private static final String LOG_TAG_AUTOSAVE = "AutoSave";
private static final long DELAY = 2000; // Wait for this time after typing before saving
@@ -147,10 +150,12 @@ public class NoteEditFragment extends SearchableBaseNoteFragment {
requireActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
- InputMethodManager imm = (InputMethodManager)
- requireActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.showSoftInput(getView(), InputMethodManager.SHOW_IMPLICIT);
-
+ final InputMethodManager imm = (InputMethodManager) requireContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (imm != null) {
+ imm.showSoftInput(getView(), InputMethodManager.SHOW_IMPLICIT);
+ } else {
+ Log.e(TAG, InputMethodManager.class.getSimpleName() + " is null.");
+ }
}
// workaround for issue yydcdut/RxMarkdown#41
@@ -159,7 +164,7 @@ public class NoteEditFragment extends SearchableBaseNoteFragment {
binding.editContent.setText(note.getContent());
binding.editContent.setEnabled(true);
- MarkdownProcessor markdownProcessor = new MarkdownProcessor(requireContext());
+ final MarkdownProcessor markdownProcessor = new MarkdownProcessor(requireContext());
markdownProcessor.config(MarkDownUtil.getMarkDownConfiguration(binding.editContent.getContext()).build());
markdownProcessor.factory(EditFactory.create());
markdownProcessor.live(binding.editContent);
@@ -168,8 +173,8 @@ public class NoteEditFragment extends SearchableBaseNoteFragment {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
binding.editContent.setCustomInsertionActionModeCallback(new ContextBasedFormattingCallback(binding.editContent));
}
- SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(requireContext().getApplicationContext());
- binding.editContent.setTextSize(TypedValue.COMPLEX_UNIT_PX, getFontSizeFromPreferences(sp));
+ final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(requireContext().getApplicationContext());
+ binding.editContent.setTextSize(TypedValue.COMPLEX_UNIT_PX, getFontSizeFromPreferences(requireContext(), sp));
if (sp.getBoolean(getString(R.string.pref_key_font), false)) {
binding.editContent.setTypeface(Typeface.MONOSPACE);
}
@@ -239,10 +244,16 @@ public class NoteEditFragment extends SearchableBaseNoteFragment {
}
@Override
- protected void colorWithText(@NonNull String newText, @Nullable Integer current) {
+ protected void colorWithText(@NonNull String newText, @Nullable Integer current, int mainColor, int textColor) {
if (binding != null && isAttachedToWindow(binding.editContent)) {
binding.editContent.clearFocus();
- binding.editContent.setText(searchAndColor(new SpannableString(getContent()), newText, requireContext(), current), TextView.BufferType.SPANNABLE);
+ binding.editContent.setText(searchAndColor(new SpannableString(getContent()), newText, requireContext(), current, mainColor, textColor), TextView.BufferType.SPANNABLE);
}
}
+
+ @Override
+ public void applyBrand(int mainColor, int textColor) {
+ super.applyBrand(mainColor, textColor);
+ binding.editContent.setHighlightColor(getTextHighlightBackgroundColor(requireContext(), mainColor, colorPrimary, colorAccent));
+ }
}