diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index cd4c449f9e..a1277018ed 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -89,6 +89,7 @@ jobs: path: "app/build/outputs/apk/google/alpha/app-google-alpha.apk" - name: Upload APK to Discord and Telegram + if: ${{ github.repository == 'rebelonion/Dantotsu' }} shell: bash run: | #Discord diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 12e7eccc0f..5883981b0b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -16,7 +16,6 @@ - diff --git a/app/src/main/java/ani/dantotsu/Functions.kt b/app/src/main/java/ani/dantotsu/Functions.kt index 67af749c09..cdc8ffdd6a 100644 --- a/app/src/main/java/ani/dantotsu/Functions.kt +++ b/app/src/main/java/ani/dantotsu/Functions.kt @@ -904,16 +904,16 @@ fun toast(string: String?) { } } -fun snackString(s: String?, activity: Activity? = null, clipboard: String? = null) { +fun snackString(s: String?, activity: Activity? = null, clipboard: String? = null) : Snackbar? { try { //I have no idea why this sometimes crashes for some people... if (s != null) { (activity ?: currActivity())?.apply { + val snackBar = Snackbar.make( + window.decorView.findViewById(android.R.id.content), + s, + Snackbar.LENGTH_SHORT + ) runOnUiThread { - val snackBar = Snackbar.make( - window.decorView.findViewById(android.R.id.content), - s, - Snackbar.LENGTH_SHORT - ) snackBar.view.apply { updateLayoutParams { gravity = (Gravity.CENTER_HORIZONTAL or Gravity.BOTTOM) @@ -933,6 +933,7 @@ fun snackString(s: String?, activity: Activity? = null, clipboard: String? = nul } snackBar.show() } + return snackBar } logger(s) } @@ -940,6 +941,7 @@ fun snackString(s: String?, activity: Activity? = null, clipboard: String? = nul logger(e.stackTraceToString()) Injekt.get().logException(e) } + return null } open class NoPaddingArrayAdapter(context: Context, layoutId: Int, items: List) : diff --git a/app/src/main/java/ani/dantotsu/MainActivity.kt b/app/src/main/java/ani/dantotsu/MainActivity.kt index a2bb5f3169..ba47d2fb1a 100644 --- a/app/src/main/java/ani/dantotsu/MainActivity.kt +++ b/app/src/main/java/ani/dantotsu/MainActivity.kt @@ -22,6 +22,9 @@ import androidx.annotation.OptIn import androidx.appcompat.app.AppCompatActivity import androidx.core.animation.doOnEnd import androidx.core.content.ContextCompat +import androidx.core.view.WindowCompat +import androidx.core.view.WindowInsetsCompat +import androidx.core.view.WindowInsetsControllerCompat import androidx.core.view.doOnAttach import androidx.core.view.updateLayoutParams import androidx.fragment.app.Fragment @@ -49,6 +52,8 @@ import ani.dantotsu.settings.saving.PrefName import ani.dantotsu.settings.saving.SharedPreferenceBooleanLiveData import ani.dantotsu.subcriptions.Subscription.Companion.startSubscription import ani.dantotsu.themes.ThemeManager +import com.google.android.material.snackbar.BaseTransientBottomBar +import com.google.android.material.snackbar.Snackbar import eu.kanade.domain.source.service.SourcePreferences import io.noties.markwon.Markwon import io.noties.markwon.SoftBreakAddsNewLinePlugin @@ -141,7 +146,20 @@ class MainActivity : AppCompatActivity() { finish() } doubleBackToExitPressedOnce = true - snackString(this@MainActivity.getString(R.string.back_to_exit)) + WindowInsetsControllerCompat(window, window.decorView) + .show(WindowInsetsCompat.Type.navigationBars()) + snackString(this@MainActivity.getString(R.string.back_to_exit)).apply { + this?.addCallback(object : BaseTransientBottomBar.BaseCallback() { + override fun onDismissed(transientBottomBar: Snackbar?, event: Int) { + super.onDismissed(transientBottomBar, event) + WindowInsetsControllerCompat(window, window.decorView).let { controller -> + controller.systemBarsBehavior = + WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE + controller.hide(WindowInsetsCompat.Type.navigationBars()) + } + } + }) + } Handler(Looper.getMainLooper()).postDelayed( { doubleBackToExitPressedOnce = false }, 2000 @@ -349,6 +367,16 @@ class MainActivity : AppCompatActivity() { } } + override fun onResume() { + super.onResume() + + WindowCompat.setDecorFitsSystemWindows(window, false) + + WindowInsetsControllerCompat(window, window.decorView).let { controller -> + controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE + controller.hide(WindowInsetsCompat.Type.navigationBars()) + } + } //ViewPager private class ViewPagerAdapter(fragmentManager: FragmentManager, lifecycle: Lifecycle) : diff --git a/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt b/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt index e1b52dbaa1..bbc2bb07ae 100644 --- a/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt +++ b/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt @@ -281,7 +281,7 @@ class AnilistQueries { } else { if (currContext()?.let { isOnline(it) } == true) { snackString(currContext()?.getString(R.string.error_getting_data)) - } + } else { } } } val mal = async { diff --git a/settings.gradle.kts b/settings.gradle.kts index f4dce55888..8174ef2b54 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,5 +5,5 @@ dependencyResolutionManagement { maven("https://jitpack.io") } } -rootProject.name = "dantotsu" +rootProject.name = "Dantotsu" include(":app")