From 7717974b9e1ce36626323dd0494d5d7c2283a5dd Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Sat, 25 May 2024 08:37:16 -0500 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20what=20does=20the=20fix=20say=3F=20?= =?UTF-8?q?=F0=9F=A6=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dantotsu/home/status/StatusActivity.kt | 19 +- .../dantotsu/media/MediaDetailsActivity.kt | 3 +- .../dantotsu/settings/ExtensionsActivity.kt | 8 +- .../ani/dantotsu/settings/InstallerSteps.kt | 2 + .../main/res/layout-land/activity_calc.xml | 390 ++++++++++++++++++ app/src/main/res/layout/activity_calc.xml | 16 +- .../res/layout/activity_markdown_creator.xml | 9 +- app/src/main/res/layout/fragment_status.xml | 4 +- 8 files changed, 436 insertions(+), 15 deletions(-) create mode 100644 app/src/main/res/layout-land/activity_calc.xml diff --git a/app/src/main/java/ani/dantotsu/home/status/StatusActivity.kt b/app/src/main/java/ani/dantotsu/home/status/StatusActivity.kt index 43b2cb5537..e37c68a552 100644 --- a/app/src/main/java/ani/dantotsu/home/status/StatusActivity.kt +++ b/app/src/main/java/ani/dantotsu/home/status/StatusActivity.kt @@ -16,6 +16,8 @@ import ani.dantotsu.navBarHeight import ani.dantotsu.profile.User import ani.dantotsu.settings.saving.PrefManager import ani.dantotsu.statusBarHeight +import ani.dantotsu.toast +import ani.dantotsu.util.Logger class StatusActivity : AppCompatActivity(), StoriesCallback { private lateinit var activity: ArrayList @@ -44,10 +46,14 @@ class StatusActivity : AppCompatActivity(), StoriesCallback { val key = "activities" val watchedActivity = PrefManager.getCustomVal>(key, setOf()) - val startFrom = findFirstNonMatch(watchedActivity, activity[position].activity ) - val startIndex = if ( startFrom > 0) startFrom else 0 - binding.stories.setStoriesList(activity[position].activity, this, startIndex + 1) - + if (activity.getOrNull(position) != null) { + val startFrom = findFirstNonMatch(watchedActivity, activity[position].activity ) + val startIndex = if ( startFrom > 0) startFrom else 0 + binding.stories.setStoriesList(activity[position].activity, this, startIndex + 1) + } else { + Logger.log("index out of bounds for position $position of size ${activity.size}") + finish() + } } private fun findFirstNonMatch(watchedActivity: Set, activity: List): Int { @@ -58,13 +64,16 @@ class StatusActivity : AppCompatActivity(), StoriesCallback { } return -1 } + override fun onPause() { super.onPause() binding.stories.pause() } + override fun onResume() { super.onResume() - binding.stories.resume() + if (hasWindowFocus()) + binding.stories.resume() } override fun onWindowFocusChanged(hasFocus: Boolean) { diff --git a/app/src/main/java/ani/dantotsu/media/MediaDetailsActivity.kt b/app/src/main/java/ani/dantotsu/media/MediaDetailsActivity.kt index 44b044577f..048ba39848 100644 --- a/app/src/main/java/ani/dantotsu/media/MediaDetailsActivity.kt +++ b/app/src/main/java/ani/dantotsu/media/MediaDetailsActivity.kt @@ -424,7 +424,8 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi } override fun onResume() { - navBar.selectTabAt(selected) + if (::navBar.isInitialized) + navBar.selectTabAt(selected) super.onResume() } diff --git a/app/src/main/java/ani/dantotsu/settings/ExtensionsActivity.kt b/app/src/main/java/ani/dantotsu/settings/ExtensionsActivity.kt index 0fa6561258..748e476e5f 100644 --- a/app/src/main/java/ani/dantotsu/settings/ExtensionsActivity.kt +++ b/app/src/main/java/ani/dantotsu/settings/ExtensionsActivity.kt @@ -43,6 +43,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import uy.kohesive.injekt.injectLazy +import java.util.Locale class ExtensionsActivity : AppCompatActivity() { lateinit var binding: ActivityExtensionsBinding @@ -173,8 +174,11 @@ class ExtensionsActivity : AppCompatActivity() { initActivity(this) binding.languageselect.setOnClickListener { val languageOptions = - LanguageMapper.Companion.Language.entries.map { it.name }.toTypedArray() - val builder = AlertDialog.Builder(currContext(), R.style.MyPopup) + LanguageMapper.Companion.Language.entries.map { entry -> + entry.name.lowercase().replace("_", " ") + .replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.ROOT) else it.toString() } + }.toTypedArray() + val builder = AlertDialog.Builder(this, R.style.MyPopup) val listOrder: String = PrefManager.getVal(PrefName.LangSort) val index = LanguageMapper.Companion.Language.entries.toTypedArray() .indexOfFirst { it.code == listOrder } diff --git a/app/src/main/java/ani/dantotsu/settings/InstallerSteps.kt b/app/src/main/java/ani/dantotsu/settings/InstallerSteps.kt index 39b91b3eb1..e66d39c4d3 100644 --- a/app/src/main/java/ani/dantotsu/settings/InstallerSteps.kt +++ b/app/src/main/java/ani/dantotsu/settings/InstallerSteps.kt @@ -6,6 +6,7 @@ import androidx.core.app.NotificationCompat import ani.dantotsu.R import ani.dantotsu.connections.crashlytics.CrashlyticsInterface import ani.dantotsu.snackString +import ani.dantotsu.util.Logger import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.extension.InstallStep import uy.kohesive.injekt.Injekt @@ -30,6 +31,7 @@ class InstallerSteps( fun onError(error: Throwable, extra: () -> Unit) { Injekt.get().logException(error) + Logger.log(error) val builder = NotificationCompat.Builder( context, Notifications.CHANNEL_DOWNLOADER_ERROR diff --git a/app/src/main/res/layout-land/activity_calc.xml b/app/src/main/res/layout-land/activity_calc.xml new file mode 100644 index 0000000000..de7d9d5fdb --- /dev/null +++ b/app/src/main/res/layout-land/activity_calc.xml @@ -0,0 +1,390 @@ + + + + + + + + + + + + + + + + + + +