Skip to content

Commit f95706f

Browse files
committed
Rename NoteEditor to NoteEditorFragment
1 parent d4bd162 commit f95706f

25 files changed

+3578
-3157
lines changed

AnkiDroid/src/androidTest/java/com/ichi2/anki/NoteEditorIntentTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import androidx.core.os.bundleOf
2020
import androidx.lifecycle.Lifecycle
2121
import androidx.test.ext.junit.rules.ActivityScenarioRule
2222
import androidx.test.ext.junit.runners.AndroidJUnit4
23-
import com.ichi2.anki.NoteEditor.Companion.intentLaunchedWithImage
23+
import com.ichi2.anki.NoteEditorFragment.Companion.intentLaunchedWithImage
2424
import com.ichi2.anki.noteeditor.NoteEditorLauncher
2525
import com.ichi2.anki.tests.InstrumentedTest
2626
import com.ichi2.anki.testutil.GrantStoragePermission

AnkiDroid/src/androidTest/java/com/ichi2/anki/NoteEditorTabOrderTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class NoteEditorTabOrderTest : NoteEditorTest() {
6464
}
6565

6666
private fun sendKeyDownUp(
67-
editor: NoteEditor,
67+
editor: NoteEditorFragment,
6868
keyCode: Int,
6969
) {
7070
val focusedView = editor.requireActivity().currentFocus ?: return

AnkiDroid/src/androidTest/java/com/ichi2/anki/testutil/NoteEditor.kt renamed to AnkiDroid/src/androidTest/java/com/ichi2/anki/testutil/NoteEditorFragment.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.ichi2.anki.testutil
1818

1919
import androidx.test.core.app.ActivityScenario
20-
import com.ichi2.anki.NoteEditor
20+
import com.ichi2.anki.NoteEditorFragment
2121
import com.ichi2.anki.R
2222
import com.ichi2.anki.SingleFragmentActivity
2323
import java.util.concurrent.atomic.AtomicReference
@@ -28,7 +28,7 @@ import java.util.concurrent.atomic.AtomicReference
2828
* @throws Throwable if any exception is thrown during the execution of the block.
2929
*/
3030
@Throws(Throwable::class)
31-
fun ActivityScenario<SingleFragmentActivity>.onNoteEditor(block: (NoteEditor) -> Unit) {
31+
fun ActivityScenario<SingleFragmentActivity>.onNoteEditor(block: (NoteEditorFragment) -> Unit) {
3232
val wrapped = AtomicReference<Throwable?>(null)
3333
this.onActivity { activity: SingleFragmentActivity ->
3434
try {
@@ -50,4 +50,5 @@ fun ActivityScenario<SingleFragmentActivity>.onNoteEditor(block: (NoteEditor) ->
5050
/**
5151
* Extension function for SingleFragmentActivity to find the NoteEditor fragment
5252
*/
53-
fun SingleFragmentActivity.getEditor(): NoteEditor = supportFragmentManager.findFragmentById(R.id.fragment_container) as NoteEditor
53+
fun SingleFragmentActivity.getEditor(): NoteEditorFragment =
54+
supportFragmentManager.findFragmentById(R.id.fragment_container) as NoteEditorFragment

AnkiDroid/src/main/AndroidManifest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,12 @@
452452
android:exported="false"
453453
android:configChanges="orientation|screenSize"
454454
/>
455+
<activity
456+
android:name="com.ichi2.anki.NoteEditor"
457+
android:exported="false"
458+
android:configChanges="keyboardHidden|orientation|screenSize"
459+
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
460+
/>
455461
<activity
456462
android:name="com.ichi2.anki.previewer.CardViewerActivity"
457463
android:exported="false"

AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ abstract class AbstractFlashcardViewer :
355355
The card could have been rescheduled, the deck could have changed, or a change of
356356
note type could have lead to the card being deleted */
357357
val reloadRequired =
358-
result.data?.getBooleanExtra(NoteEditor.RELOAD_REQUIRED_EXTRA_KEY, false) == true
358+
result.data?.getBooleanExtra(NoteEditorFragment.RELOAD_REQUIRED_EXTRA_KEY, false) == true
359359
if (reloadRequired) {
360360
performReload()
361361
}

AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ open class CardBrowser :
211211
// in use by reviewer?
212212
result.data?.let {
213213
if (
214-
it.getBooleanExtra(NoteEditor.RELOAD_REQUIRED_EXTRA_KEY, false) ||
215-
it.getBooleanExtra(NoteEditor.NOTE_CHANGED_EXTRA_KEY, false)
214+
it.getBooleanExtra(NoteEditorFragment.RELOAD_REQUIRED_EXTRA_KEY, false) ||
215+
it.getBooleanExtra(NoteEditorFragment.NOTE_CHANGED_EXTRA_KEY, false)
216216
) {
217217
if (reviewerCardId == currentCardId) {
218218
reloadRequired = true
@@ -248,8 +248,8 @@ open class CardBrowser :
248248
val data = result.data
249249
if (data != null &&
250250
(
251-
data.getBooleanExtra(NoteEditor.RELOAD_REQUIRED_EXTRA_KEY, false) ||
252-
data.getBooleanExtra(NoteEditor.NOTE_CHANGED_EXTRA_KEY, false)
251+
data.getBooleanExtra(NoteEditorFragment.RELOAD_REQUIRED_EXTRA_KEY, false) ||
252+
data.getBooleanExtra(NoteEditorFragment.NOTE_CHANGED_EXTRA_KEY, false)
253253
)
254254
) {
255255
forceRefreshSearch()
@@ -370,7 +370,7 @@ open class CardBrowser :
370370
RESULT_OK,
371371
Intent().apply {
372372
// Add reload flag to result intent so that schedule reset when returning to note editor
373-
putExtra(NoteEditor.RELOAD_REQUIRED_EXTRA_KEY, reloadRequired)
373+
putExtra(NoteEditorFragment.RELOAD_REQUIRED_EXTRA_KEY, reloadRequired)
374374
},
375375
)
376376

@@ -493,9 +493,9 @@ open class CardBrowser :
493493
}
494494

495495
private fun loadNoteEditorFragment(launcher: NoteEditorLauncher) {
496-
val noteEditor = NoteEditor.newInstance(launcher)
496+
val noteEditorFragment = NoteEditorFragment.newInstance(launcher)
497497
supportFragmentManager.commit {
498-
replace(R.id.note_editor_frame, noteEditor)
498+
replace(R.id.note_editor_frame, noteEditorFragment)
499499
}
500500
// Invalidate options menu so that note editor menu will show
501501
invalidateOptionsMenu()
@@ -504,8 +504,8 @@ open class CardBrowser :
504504
/**
505505
* Retrieves the `NoteEditor` fragment if it is present in the fragment container
506506
*/
507-
val fragment: NoteEditor?
508-
get() = supportFragmentManager.findFragmentById(R.id.note_editor_frame) as? NoteEditor
507+
val fragment: NoteEditorFragment?
508+
get() = supportFragmentManager.findFragmentById(R.id.note_editor_frame) as? NoteEditorFragment
509509

510510
/**
511511
* Loads the NoteEditor fragment in container if the view is x-large.

AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ import kotlin.runCatching as runCatchingKotlin
211211
*
212212
* On a tablet, this is a fragmented view, with [StudyOptionsFragment] to the right: [loadStudyOptionsFragment]
213213
*
214-
* Often used as navigation to: [Reviewer], [NoteEditor] (adding notes), [StudyOptionsFragment] [SharedDecksDownloadFragment]
214+
* Often used as navigation to: [Reviewer], [NoteEditorFragment] (adding notes), [StudyOptionsFragment] [SharedDecksDownloadFragment]
215215
*
216216
* Responsibilities:
217217
* * Setup/upgrades of the application: [handleStartup]

AnkiDroid/src/main/java/com/ichi2/anki/DeckPickerFloatingActionMenu.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ class DeckPickerFloatingActionMenu(
421421
}
422422

423423
/**
424-
* Closes the FAB menu and opens the [NoteEditor]
424+
* Closes the FAB menu and opens the [NoteEditorFragment]
425425
* @see DeckPicker.addNote
426426
*/
427427
private fun addNote() {

AnkiDroid/src/main/java/com/ichi2/anki/ImageOcclusionIntentBuilder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import android.net.Uri
2222
import com.ichi2.anki.noteeditor.NoteEditorLauncher
2323

2424
/**
25-
* Builder class for creating intents related to image occlusion in the [NoteEditor].
25+
* Builder class for creating intents related to image occlusion in the [NoteEditorFragment].
2626
*/
2727
class ImageOcclusionIntentBuilder(
2828
private val context: Context,

AnkiDroid/src/main/java/com/ichi2/anki/IntentHandler2.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.ichi2.anki
1818

1919
import android.os.Bundle
20-
import com.ichi2.anki.NoteEditor.Companion.NoteEditorCaller
20+
import com.ichi2.anki.NoteEditorFragment.Companion.NoteEditorCaller
2121
import com.ichi2.anki.noteeditor.NoteEditorLauncher
2222
import timber.log.Timber
2323

@@ -32,9 +32,9 @@ class IntentHandler2 : AbstractIntentHandler() {
3232
override fun onCreate(savedInstanceState: Bundle?) {
3333
super.onCreate(savedInstanceState)
3434
Timber.v(intent.toString())
35-
if (NoteEditor.intentLaunchedWithImage(intent)) {
35+
if (NoteEditorFragment.intentLaunchedWithImage(intent)) {
3636
Timber.i("Intent contained an image")
37-
intent.putExtra(NoteEditor.EXTRA_CALLER, NoteEditorCaller.ADD_IMAGE.value)
37+
intent.putExtra(NoteEditorFragment.EXTRA_CALLER, NoteEditorCaller.ADD_IMAGE.value)
3838
}
3939
if (intent.extras == null) {
4040
Timber.w("Intent unexpectedly has no extras. Notifying user, defaulting to add note.")

0 commit comments

Comments
 (0)