Skip to content

Commit

Permalink
refactor: remove finishActivityWithFade
Browse files Browse the repository at this point in the history
  • Loading branch information
BrayanDSO committed Dec 9, 2023
1 parent 86cc40c commit cbb80b7
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 18 deletions.
7 changes: 0 additions & 7 deletions AnkiDroid/src/main/java/com/ichi2/anki/AnkiActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package com.ichi2.anki

import android.app.Activity
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.ActivityNotFoundException
Expand Down Expand Up @@ -577,12 +576,6 @@ open class AnkiActivity : AppCompatActivity, SimpleMessageDialogListener {
/** Extra key to set the finish animation of an activity */
const val FINISH_ANIMATION_EXTRA = "finishAnimation"

/** Finish Activity using FADE animation */
fun finishActivityWithFade(activity: Activity) {
activity.finish()
ActivityTransitionAnimation.slide(activity, FADE)
}

fun showDialogFragment(activity: AnkiActivity, newFragment: DialogFragment) {
showDialogFragment(activity.supportFragmentManager, newFragment)
}
Expand Down
2 changes: 1 addition & 1 deletion AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ open class CardBrowser :
deckPicker.addCategory(Intent.CATEGORY_LAUNCHER)
deckPicker.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(deckPicker)
finishActivityWithFade(this)
finish()
this.setResult(RESULT_CANCELED)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CardTemplateBrowserAppearanceEditor : AnkiActivity() {
val bundle = savedInstanceState ?: intent.extras
if (bundle == null) {
UIUtils.showThemedToast(this, getString(R.string.card_template_editor_card_browser_appearance_failed), true)
finishActivityWithFade(this)
finish()
return
}
initializeUiFromBundle(bundle)
Expand Down Expand Up @@ -157,7 +157,7 @@ class CardTemplateBrowserAppearanceEditor : AnkiActivity() {
private fun discardChangesAndClose() {
Timber.i("Closing and discarding changes")
setResult(RESULT_CANCELED)
finishActivityWithFade(this)
finish()
}

private fun saveAndExit() {
Expand All @@ -167,7 +167,7 @@ class CardTemplateBrowserAppearanceEditor : AnkiActivity() {
putExtra(INTENT_ANSWER_FORMAT, answerFormat)
}
setResult(RESULT_OK, data)
finishActivityWithFade(this)
finish()
}

private fun hasChanges(): Boolean {
Expand Down
2 changes: 1 addition & 1 deletion AnkiDroid/src/main/java/com/ichi2/anki/DrawingActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class DrawingActivity : AnkiActivity() {
} catch (e: FileNotFoundException) {
Timber.w(e)
} finally {
finishActivityWithFade(this)
finish()
}
}

Expand Down
6 changes: 3 additions & 3 deletions AnkiDroid/src/main/java/com/ichi2/anki/IntentHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class IntentHandler : Activity() {
val reviewIntent = Intent(this, Reviewer::class.java)
CollectionHelper.instance.getColUnsafe(this)!!.decks.select(deckId)
startActivity(reviewIntent)
AnkiActivity.finishActivityWithFade(this)
finish()
}

private fun handleSyncIntent(reloadIntent: Intent, action: String?) {
Expand All @@ -130,7 +130,7 @@ class IntentHandler : Activity() {
reloadIntent.action = action
reloadIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(reloadIntent)
AnkiActivity.finishActivityWithFade(this)
finish()
}

private fun handleFileImport(intent: Intent, reloadIntent: Intent, action: String?) {
Expand Down Expand Up @@ -173,7 +173,7 @@ class IntentHandler : Activity() {
reloadIntent.action = action
reloadIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(reloadIntent)
AnkiActivity.finishActivityWithFade(this)
finish()
} else {
Timber.i("File import failed")
// Don't import the file if it didn't load properly or doesn't have apkg extension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package com.ichi2.anki.workarounds
import android.app.Activity
import android.os.Bundle
import android.os.Process
import com.ichi2.anki.AnkiActivity
import com.ichi2.anki.AnkiDroidApp
import com.ichi2.anki.R
import com.ichi2.anki.UIUtils
Expand Down Expand Up @@ -62,7 +61,7 @@ object AppLoadedFromBackupWorkaround {
Themes.setTheme(this)
// Avoids a SuperNotCalledException
activitySuperOnCreate(savedInstanceState)
AnkiActivity.finishActivityWithFade(this)
finish()

// If we don't kill the process, the backup is not "done" and reopening the app show the same message.
Thread {
Expand Down
2 changes: 1 addition & 1 deletion AnkiDroid/src/main/java/com/ichi2/utils/ImportUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ object ImportUtils {
setCancelable(false)
positiveButton(R.string.dialog_ok) {
if (exitActivity) {
AnkiActivity.finishActivityWithFade(activity)
activity.finish()
}
}
}
Expand Down

0 comments on commit cbb80b7

Please sign in to comment.