chore: cleanup pt 3
This commit is contained in:
parent
390ce9a022
commit
fdb7f45a3d
10 changed files with 257 additions and 93 deletions
|
@ -4,7 +4,6 @@ import android.app.AlertDialog
|
|||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -17,6 +16,8 @@ import ani.dantotsu.connections.anilist.Anilist
|
|||
import ani.dantotsu.databinding.BottomSheetSettingsBinding
|
||||
import ani.dantotsu.download.anime.OfflineAnimeFragment
|
||||
import ani.dantotsu.download.manga.OfflineMangaFragment
|
||||
import ani.dantotsu.getAppString
|
||||
import ani.dantotsu.getThemeColor
|
||||
import ani.dantotsu.home.AnimeFragment
|
||||
import ani.dantotsu.home.HomeFragment
|
||||
import ani.dantotsu.home.LoginFragment
|
||||
|
@ -32,6 +33,7 @@ import ani.dantotsu.setSafeOnClickListener
|
|||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.startMainActivity
|
||||
import ani.dantotsu.util.customAlertDialog
|
||||
import eu.kanade.tachiyomi.util.system.getSerializableCompat
|
||||
import java.util.Timer
|
||||
import kotlin.concurrent.schedule
|
||||
|
@ -59,10 +61,7 @@ class SettingsDialogFragment : BottomSheetDialogFragment() {
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
val window = dialog?.window
|
||||
window?.statusBarColor = Color.CYAN
|
||||
val typedValue = TypedValue()
|
||||
val theme = requireContext().theme
|
||||
theme.resolveAttribute(com.google.android.material.R.attr.colorSurface, typedValue, true)
|
||||
window?.navigationBarColor = typedValue.data
|
||||
window?.navigationBarColor = requireContext().getThemeColor(com.google.android.material.R.attr.colorSurface)
|
||||
val notificationIcon = if (Anilist.unreadNotificationCount > 0) {
|
||||
R.drawable.ic_round_notifications_active_24
|
||||
} else {
|
||||
|
@ -73,18 +72,16 @@ class SettingsDialogFragment : BottomSheetDialogFragment() {
|
|||
if (Anilist.token != null) {
|
||||
binding.settingsLogin.setText(R.string.logout)
|
||||
binding.settingsLogin.setOnClickListener {
|
||||
val alertDialog = AlertDialog.Builder(requireContext(), R.style.MyPopup)
|
||||
.setTitle("Logout")
|
||||
.setMessage("Are you sure you want to logout?")
|
||||
.setPositiveButton("Yes") { _, _ ->
|
||||
requireContext().customAlertDialog().apply{
|
||||
setTitle(R.string.logout)
|
||||
setMessage(R.string.logout_confirm)
|
||||
setPosButton(R.string.yes) {
|
||||
Anilist.removeSavedToken()
|
||||
dismiss()
|
||||
startMainActivity(requireActivity())
|
||||
}
|
||||
.setNegativeButton("No") { _, _ -> }
|
||||
.create()
|
||||
alertDialog.window?.setDimAmount(0.8f)
|
||||
alertDialog.show()
|
||||
setNegButton(R.string.no)
|
||||
show()
|
||||
}
|
||||
}
|
||||
binding.settingsUsername.text = Anilist.username
|
||||
binding.settingsUserAvatar.loadImage(Anilist.avatar)
|
||||
|
|
|
@ -24,6 +24,7 @@ import ani.dantotsu.settings.saving.PrefManager
|
|||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.statusBarHeight
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.util.customAlertDialog
|
||||
import eu.kanade.domain.base.BasePreferences
|
||||
import eu.kanade.tachiyomi.extension.anime.AnimeExtensionManager
|
||||
import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager
|
||||
|
@ -169,27 +170,27 @@ class SettingsExtensionsActivity : AppCompatActivity() {
|
|||
val editText = dialogView.userAgentTextBox.apply {
|
||||
hint = getString(R.string.anime_add_repository)
|
||||
}
|
||||
val alertDialog = AlertDialog.Builder(context, R.style.MyPopup)
|
||||
.setTitle(R.string.anime_add_repository).setView(dialogView.root)
|
||||
.setPositiveButton(getString(R.string.ok)) { dialog, _ ->
|
||||
context.customAlertDialog().apply {
|
||||
setTitle(R.string.anime_add_repository)
|
||||
setCustomView(dialogView.root)
|
||||
setPosButton(getString(R.string.ok)) {
|
||||
if (!editText.text.isNullOrBlank()) processUserInput(
|
||||
editText.text.toString(),
|
||||
MediaType.ANIME,
|
||||
it.attachView
|
||||
)
|
||||
dialog.dismiss()
|
||||
}.setNegativeButton(getString(R.string.cancel)) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}.create()
|
||||
|
||||
processEditorAction(
|
||||
alertDialog,
|
||||
editText,
|
||||
MediaType.ANIME,
|
||||
it.attachView
|
||||
)
|
||||
alertDialog.show()
|
||||
alertDialog.window?.setDimAmount(0.8f)
|
||||
}
|
||||
setNegButton(getString(R.string.cancel))
|
||||
attach { dialog ->
|
||||
processEditorAction(
|
||||
dialog,
|
||||
editText,
|
||||
MediaType.ANIME,
|
||||
it.attachView
|
||||
)
|
||||
}
|
||||
show()
|
||||
}
|
||||
},
|
||||
attach = {
|
||||
setExtensionOutput(it.attachView, MediaType.ANIME)
|
||||
|
|
|
@ -19,6 +19,7 @@ import ani.dantotsu.settings.saving.PrefManager
|
|||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.statusBarHeight
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.util.customAlertDialog
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
|
@ -80,23 +81,16 @@ class SettingsMangaActivity : AppCompatActivity() {
|
|||
desc = getString(R.string.purge_manga_downloads_desc),
|
||||
icon = R.drawable.ic_round_delete_24,
|
||||
onClick = {
|
||||
val dialog = AlertDialog.Builder(context, R.style.MyPopup)
|
||||
.setTitle(R.string.purge_manga_downloads)
|
||||
.setMessage(
|
||||
getString(
|
||||
R.string.purge_confirm,
|
||||
getString(R.string.manga)
|
||||
)
|
||||
)
|
||||
.setPositiveButton(R.string.yes) { dialog, _ ->
|
||||
context.customAlertDialog().apply {
|
||||
setTitle(R.string.purge_manga_downloads)
|
||||
setMessage(R.string.purge_confirm, getString(R.string.manga))
|
||||
setPosButton(R.string.yes, onClick = {
|
||||
val downloadsManager = Injekt.get<DownloadsManager>()
|
||||
downloadsManager.purgeDownloads(MediaType.MANGA)
|
||||
dialog.dismiss()
|
||||
}.setNegativeButton(R.string.no) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}.create()
|
||||
dialog.window?.setDimAmount(0.8f)
|
||||
dialog.show()
|
||||
})
|
||||
setNegButton(R.string.no)
|
||||
show()
|
||||
}
|
||||
}
|
||||
|
||||
),
|
||||
|
@ -106,23 +100,16 @@ class SettingsMangaActivity : AppCompatActivity() {
|
|||
desc = getString(R.string.purge_novel_downloads_desc),
|
||||
icon = R.drawable.ic_round_delete_24,
|
||||
onClick = {
|
||||
val dialog = AlertDialog.Builder(context, R.style.MyPopup)
|
||||
.setTitle(R.string.purge_novel_downloads)
|
||||
.setMessage(
|
||||
getString(
|
||||
R.string.purge_confirm,
|
||||
getString(R.string.novels)
|
||||
)
|
||||
)
|
||||
.setPositiveButton(R.string.yes) { dialog, _ ->
|
||||
context.customAlertDialog().apply {
|
||||
setTitle(R.string.purge_novel_downloads)
|
||||
setMessage(R.string.purge_confirm, getString(R.string.novels))
|
||||
setPosButton(R.string.yes) {
|
||||
val downloadsManager = Injekt.get<DownloadsManager>()
|
||||
downloadsManager.purgeDownloads(MediaType.NOVEL)
|
||||
dialog.dismiss()
|
||||
}.setNegativeButton(R.string.no) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}.create()
|
||||
dialog.window?.setDimAmount(0.8f)
|
||||
dialog.show()
|
||||
}
|
||||
setNegButton(R.string.no)
|
||||
show()
|
||||
}
|
||||
}
|
||||
),
|
||||
Settings(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue