Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash in flashcard viewer when socket permission is denied #17989

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ import com.drakeet.drawer.FullDraggableContainer
import com.google.android.material.snackbar.Snackbar
import com.ichi2.anim.ActivityTransitionAnimation
import com.ichi2.anki.AbstractFlashcardViewer.Signal.Companion.toSignal
import com.ichi2.anki.CollectionHelper.getMediaDirectory
import com.ichi2.anki.CollectionManager.TR
import com.ichi2.anki.CollectionManager.withCol
import com.ichi2.anki.android.back.exitViaDoubleTapBackCallback
Expand Down Expand Up @@ -274,8 +275,6 @@ abstract class AbstractFlashcardViewer :
/** Handle joysticks/pedals */
protected lateinit var motionEventHandler: MotionEventHandler

val server = AnkiServer(this).also { it.start() }

Comment on lines -277 to -278
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this breaks the i18nresources POST request used by image occlusion cards

@get:VisibleForTesting
var cardContent: String? = null
private set
Expand Down Expand Up @@ -1549,7 +1548,7 @@ abstract class AbstractFlashcardViewer :
if (card != null) {
card.settings.mediaPlaybackRequiresUserGesture = !cardMediaPlayer.config.autoplay
card.loadDataWithBaseURL(
server.baseUrl(),
getMediaBaseUrl(getMediaDirectory(AnkiDroidApp.instance).path),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this breaks javascript imports from other files

content,
"text/html",
null,
Expand Down
5 changes: 0 additions & 5 deletions AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,6 @@ open class Reviewer :
}
}

override fun onDestroy() {
super.onDestroy()
server.stop()
}

protected val flagToDisplay: Flag
get() {
return FlagToDisplay(
Expand Down
Loading