Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40fa7dc3 authored by Stefan Niedermann's avatar Stefan Niedermann Committed by Niedermann IT-Dienstleistungen
Browse files

Add focus workaround for old android devices

parent 0c676a65
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -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);
                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);
+9 −0
Original line number Diff line number Diff line
@@ -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"