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:
authorStefan Niedermann <info@niedermann.it>2020-06-08 14:48:16 +0300
committerNiedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com>2020-06-08 14:55:59 +0300
commit40fa7dc3d9aec09718be6f5d42658094d434bf73 (patch)
treedcbd38b5a38ff5d9196da924ec3d25c851696416 /app/src/main
parent0c676a65739e35a4ed982cce355245add60fe73f (diff)
Add focus workaround for old android devices
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteEditFragment.java16
-rw-r--r--app/src/main/res/layout/fragment_note_edit.xml9
2 files changed, 19 insertions, 6 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 4506597c..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
@@ -45,6 +45,8 @@ import static it.niedermann.owncloud.notes.util.NoteUtil.getFontSizeFromPreferen
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
@@ -148,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
@@ -160,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);
@@ -169,7 +173,7 @@ 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());
+ 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);
diff --git a/app/src/main/res/layout/fragment_note_edit.xml b/app/src/main/res/layout/fragment_note_edit.xml
index 64f83e5e..a6ea2fde 100644
--- a/app/src/main/res/layout/fragment_note_edit.xml
+++ b/app/src/main/res/layout/fragment_note_edit.xml
@@ -6,6 +6,15 @@
android:layout_height="match_parent"
tools:background="?attr/colorPrimary">
+ <!-- Dummy item to prevent editContent from receiving focus -->
+ <LinearLayout
+ android:id="@+id/focus_workaround"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:focusable="true"
+ android:focusableInTouchMode="true"
+ android:orientation="horizontal" />
+
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"