diff --git a/app/src/main/java/com/github/libretube/extensions/GetStyledSnackBar.kt b/app/src/main/java/com/github/libretube/extensions/GetStyledSnackBar.kt
deleted file mode 100644
index 1bd6d4b58..000000000
--- a/app/src/main/java/com/github/libretube/extensions/GetStyledSnackBar.kt
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.github.libretube.extensions
-
-import android.view.View
-import android.widget.FrameLayout
-import androidx.core.content.res.ResourcesCompat
-import com.github.libretube.R
-import com.google.android.material.snackbar.Snackbar
-
-fun View.getStyledSnackBar(text: Int): Snackbar {
- val snackBar = Snackbar.make(this, text, Snackbar.LENGTH_SHORT)
- snackBar.setTextMaxLines(3)
- snackBar.animationMode = Snackbar.ANIMATION_MODE_SLIDE
-
- val params = snackBar.view.layoutParams as FrameLayout.LayoutParams
- val sideMargin = 70
-
- params.setMargins(
- sideMargin,
- params.topMargin,
- sideMargin,
- sideMargin + 50
- )
- snackBar.view.layoutParams = params
-
- snackBar.view.background = ResourcesCompat.getDrawable(resources, R.drawable.snackbar_shape, null)
- return snackBar
-}
diff --git a/app/src/main/java/com/github/libretube/ui/activities/AboutActivity.kt b/app/src/main/java/com/github/libretube/ui/activities/AboutActivity.kt
index ebd4e9198..bc4cf4b13 100644
--- a/app/src/main/java/com/github/libretube/ui/activities/AboutActivity.kt
+++ b/app/src/main/java/com/github/libretube/ui/activities/AboutActivity.kt
@@ -16,7 +16,6 @@ import com.github.libretube.constants.PIPED_GITHUB_URL
import com.github.libretube.constants.WEBLATE_URL
import com.github.libretube.constants.WEBSITE_URL
import com.github.libretube.databinding.ActivityAboutBinding
-import com.github.libretube.extensions.getStyledSnackBar
import com.github.libretube.ui.base.BaseActivity
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
@@ -103,12 +102,16 @@ class AboutActivity : BaseActivity() {
val clip = ClipData.newPlainText(getString(R.string.copied), href)
clipboard.setPrimaryClip(clip)
// show the snackBar with open action
- val snackBar = binding.root.getStyledSnackBar(R.string.copied_to_clipboard)
- snackBar.setAction(R.string.open_copied) {
- openLinkFromHref(href)
- }
- snackBar.animationMode = Snackbar.ANIMATION_MODE_FADE
- snackBar.show()
+ Snackbar.make(
+ binding.root,
+ R.string.copied_to_clipboard,
+ Snackbar.LENGTH_LONG
+ )
+ .setAction(R.string.open_copied) {
+ openLinkFromHref(href)
+ }
+ .setAnimationMode(Snackbar.ANIMATION_MODE_FADE)
+ .show()
}
private fun showLicense() {
diff --git a/app/src/main/java/com/github/libretube/ui/activities/NoInternetActivity.kt b/app/src/main/java/com/github/libretube/ui/activities/NoInternetActivity.kt
index 95233f2b6..36bf69499 100644
--- a/app/src/main/java/com/github/libretube/ui/activities/NoInternetActivity.kt
+++ b/app/src/main/java/com/github/libretube/ui/activities/NoInternetActivity.kt
@@ -5,11 +5,11 @@ import android.os.Bundle
import androidx.activity.OnBackPressedCallback
import com.github.libretube.R
import com.github.libretube.databinding.ActivityNointernetBinding
-import com.github.libretube.extensions.getStyledSnackBar
import com.github.libretube.ui.base.BaseActivity
import com.github.libretube.ui.fragments.DownloadsFragment
import com.github.libretube.util.NetworkHelper
import com.github.libretube.util.ThemeHelper
+import com.google.android.material.snackbar.Snackbar
class NoInternetActivity : BaseActivity() {
private lateinit var binding: ActivityNointernetBinding
@@ -23,7 +23,7 @@ class NoInternetActivity : BaseActivity() {
if (NetworkHelper.isNetworkAvailable(this)) {
ThemeHelper.restartMainActivity(this)
} else {
- binding.root.getStyledSnackBar(R.string.turnInternetOn).show()
+ Snackbar.make(binding.root, R.string.turnInternetOn, Snackbar.LENGTH_LONG).show()
}
}
binding.noInternetSettingsImageView.setOnClickListener {
diff --git a/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt
index b56c5e99d..f657fb860 100644
--- a/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt
+++ b/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt
@@ -16,13 +16,13 @@ import com.github.libretube.api.RetrofitInstance
import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.databinding.FragmentHomeBinding
import com.github.libretube.extensions.TAG
-import com.github.libretube.extensions.getStyledSnackBar
import com.github.libretube.ui.activities.SettingsActivity
import com.github.libretube.ui.adapters.ChannelAdapter
import com.github.libretube.ui.adapters.TrendingAdapter
import com.github.libretube.ui.base.BaseFragment
import com.github.libretube.util.LocaleHelper
import com.github.libretube.util.PreferenceHelper
+import com.google.android.material.snackbar.Snackbar
import retrofit2.HttpException
import java.io.IOException
@@ -86,8 +86,10 @@ class HomeFragment : BaseFragment() {
// show a [SnackBar] if there are no trending videos available
if (response.isEmpty()) {
- binding.root.getStyledSnackBar(
- R.string.change_region
+ Snackbar.make(
+ binding.root,
+ R.string.change_region,
+ Snackbar.LENGTH_LONG
)
.setAction(
R.string.settings
diff --git a/app/src/main/java/com/github/libretube/ui/preferences/MainSettings.kt b/app/src/main/java/com/github/libretube/ui/preferences/MainSettings.kt
index 141fc5999..e24018651 100644
--- a/app/src/main/java/com/github/libretube/ui/preferences/MainSettings.kt
+++ b/app/src/main/java/com/github/libretube/ui/preferences/MainSettings.kt
@@ -6,11 +6,11 @@ import androidx.preference.Preference
import com.github.libretube.BuildConfig
import com.github.libretube.R
import com.github.libretube.api.RetrofitInstance
-import com.github.libretube.extensions.getStyledSnackBar
import com.github.libretube.ui.activities.SettingsActivity
import com.github.libretube.ui.base.BasePreferenceFragment
import com.github.libretube.ui.dialogs.UpdateDialog
import com.github.libretube.util.NetworkHelper
+import com.google.android.material.snackbar.Snackbar
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -97,8 +97,14 @@ class MainSettings : BasePreferenceFragment() {
update?.setOnPreferenceClickListener {
CoroutineScope(Dispatchers.IO).launch {
if (!NetworkHelper.isNetworkAvailable(requireContext())) {
- (activity as? SettingsActivity)?.binding?.root?.getStyledSnackBar(R.string.unknown_error)
- ?.show()
+ (activity as? SettingsActivity)?.binding?.let {
+ Snackbar.make(
+ it.root,
+ R.string.unknown_error,
+ Snackbar.LENGTH_SHORT
+ )
+ .show()
+ }
return@launch
}
// check for update
@@ -109,8 +115,14 @@ class MainSettings : BasePreferenceFragment() {
}
if (updateInfo.name == null) {
// request failed
- (activity as? SettingsActivity)?.binding?.root?.getStyledSnackBar(R.string.unknown_error)
- ?.show()
+ (activity as? SettingsActivity)?.binding?.let {
+ Snackbar.make(
+ it.root,
+ R.string.unknown_error,
+ Snackbar.LENGTH_SHORT
+ )
+ .show()
+ }
} else if (BuildConfig.VERSION_NAME != updateInfo.name) {
// show the UpdateAvailableDialog if there's an update available
val updateAvailableDialog = UpdateDialog(updateInfo)
@@ -120,8 +132,14 @@ class MainSettings : BasePreferenceFragment() {
)
} else {
// otherwise show the no update available snackBar
- (activity as? SettingsActivity)?.binding?.root?.getStyledSnackBar(R.string.app_uptodate)
- ?.show()
+ (activity as? SettingsActivity)?.binding?.let {
+ Snackbar.make(
+ it.root,
+ R.string.unknown_error,
+ Snackbar.LENGTH_SHORT
+ )
+ .show()
+ }
}
}
true
diff --git a/app/src/main/res/drawable/snackbar_shape.xml b/app/src/main/res/drawable/snackbar_shape.xml
deleted file mode 100644
index ca4993a53..000000000
--- a/app/src/main/res/drawable/snackbar_shape.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml
index 38c6f918c..e033fea8a 100644
--- a/app/src/main/res/values-night/themes.xml
+++ b/app/src/main/res/values-night/themes.xml
@@ -11,6 +11,8 @@
@style/Preference.SwitchPreferenceCompat.Material3
+ - @style/snackBarStyle
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index 90073a60d..82bee1768 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -11,6 +11,8 @@
@style/Preference.SwitchPreferenceCompat.Material3
+ - @style/snackBarStyle
+