Skip to content

Commit

Permalink
feat(settings): Smooth theme transitions (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sadwhy authored Nov 8, 2024
1 parent b703337 commit 95b5581
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/ani/dantotsu/Functions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ fun Activity.reloadActivity() {
Refresh.all()
finish()
startActivity(Intent(this, this::class.java))
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
initActivity(this)
}

Expand Down
11 changes: 7 additions & 4 deletions app/src/main/java/ani/dantotsu/settings/SettingsThemeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import android.content.ComponentName
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
Expand All @@ -16,7 +18,6 @@ import ani.dantotsu.databinding.ActivitySettingsThemeBinding
import ani.dantotsu.initActivity
import ani.dantotsu.navBarHeight
import ani.dantotsu.reloadActivity
import ani.dantotsu.restartApp
import ani.dantotsu.settings.saving.PrefManager
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.statusBarHeight
Expand Down Expand Up @@ -73,7 +74,7 @@ class SettingsThemeActivity : AppCompatActivity(), SimpleDialog.OnDialogResultLi
previous = current
current.alpha = 1f
PrefManager.setVal(PrefName.DarkMode, mode)
reloadActivity()
reload()
}

settingsUiAuto.setOnClickListener {
Expand Down Expand Up @@ -210,7 +211,9 @@ class SettingsThemeActivity : AppCompatActivity(), SimpleDialog.OnDialogResultLi

fun reload() {
PrefManager.setCustomVal("reload", true)
restartApp()
Handler(Looper.getMainLooper()).postDelayed({
reloadActivity()
finishAndRemoveTask()
}, 100)
}

}

0 comments on commit 95b5581

Please sign in to comment.