Skip to content

Commit

Permalink
update snackbar style
Browse files Browse the repository at this point in the history
  • Loading branch information
sdex committed Feb 7, 2024
1 parent dfc2d43 commit 30ea5e2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
33 changes: 24 additions & 9 deletions app/src/main/java/com/sdex/activityrunner/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatDelegate
import androidx.appcompat.widget.SearchView
import androidx.appcompat.widget.SearchView.OnQueryTextListener
import androidx.core.content.ContextCompat
import androidx.core.view.MenuProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.behavior.SwipeDismissBehavior
Expand Down Expand Up @@ -60,6 +61,7 @@ class MainActivity : BaseActivity() {
)
true
}

R.id.action_launch_intent -> {
IntentBuilderActivity.start(this@MainActivity, null)
true
Expand Down Expand Up @@ -113,15 +115,8 @@ class MainActivity : BaseActivity() {

binding.progress.show()

if (appPreferences.appOpenCounter % 10 == 0) {
val behavior = BaseTransientBottomBar.Behavior().apply {
setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_ANY)
}
Snackbar.make(binding.coordinator, R.string.about_donation, Snackbar.LENGTH_INDEFINITE)
.setBehavior(behavior)
.setAction(R.string.donate_action_text) {
AppUtils.openLink(this, getString(R.string.donate_link))
}.show()
if (appPreferences.appOpenCounter % 20 == 0) {
showDonateSnackbar()
}
}

Expand Down Expand Up @@ -174,6 +169,26 @@ class MainActivity : BaseActivity() {
})
}

private fun showDonateSnackbar() {
val behavior = BaseTransientBottomBar.Behavior().apply {
setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_ANY)
}
Snackbar.make(binding.coordinator, R.string.donate_message, Snackbar.LENGTH_LONG)
.setBehavior(behavior)
.setBackgroundTint(
ContextCompat.getColor(this, R.color.snackbar_background_tint)
)
.setActionTextColor(
ContextCompat.getColor(this, R.color.snackbar_action_text_color)
)
.setTextColor(
ContextCompat.getColor(this, R.color.snackbar_text_color)
)
.setAction(getString(R.string.donate_action_text).uppercase()) {
AppUtils.openLink(this, getString(R.string.donate_link))
}.show()
}

companion object {

init {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<color name="scrollbar_background">#28000000</color>
<color name="scrollbar_inactive_thumb">#79000000</color>

<color name="snackbar_background_tint">#526070</color>
<color name="snackbar_action_text_color">#b8e9ff</color>
<color name="snackbar_text_color">#FFFFFF</color>

<color name="fip_inactive_color">#BDBDBD</color>
<color name="fip_active_color">#000000</color>
<color name="fip_active_selected">#000000</color>
Expand Down

0 comments on commit 30ea5e2

Please sign in to comment.