UI: Improve toolbar animation
This commit is contained in:
@ -1,6 +1,5 @@
|
|||||||
package io.neoterm.ui.term
|
package io.neoterm.ui.term
|
||||||
|
|
||||||
import android.animation.ObjectAnimator
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
@ -16,7 +15,6 @@ import android.support.v4.view.ViewCompat
|
|||||||
import android.support.v7.app.AppCompatActivity
|
import android.support.v7.app.AppCompatActivity
|
||||||
import android.support.v7.widget.Toolbar
|
import android.support.v7.widget.Toolbar
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.view.animation.AccelerateDecelerateInterpolator
|
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.ImageButton
|
import android.widget.ImageButton
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
@ -175,13 +173,18 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
|
|||||||
override fun onSwitcherShown(tabSwitcher: TabSwitcher) {
|
override fun onSwitcherShown(tabSwitcher: TabSwitcher) {
|
||||||
toolbar.setNavigationIcon(R.drawable.ic_add_box_white_24dp)
|
toolbar.setNavigationIcon(R.drawable.ic_add_box_white_24dp)
|
||||||
toolbar.setNavigationOnClickListener(addSessionListener)
|
toolbar.setNavigationOnClickListener(addSessionListener)
|
||||||
toolbar.setBackgroundResource(android.R.color.transparent)
|
toolbar.animate().alpha(0f).setDuration(300).withEndAction {
|
||||||
|
toolbar.setBackgroundResource(android.R.color.transparent)
|
||||||
|
toolbar.alpha = 1f
|
||||||
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSwitcherHidden(tabSwitcher: TabSwitcher) {
|
override fun onSwitcherHidden(tabSwitcher: TabSwitcher) {
|
||||||
toolbar.navigationIcon = null
|
toolbar.navigationIcon = null
|
||||||
toolbar.setNavigationOnClickListener(null)
|
toolbar.setNavigationOnClickListener(null)
|
||||||
|
toolbar.alpha = 0f
|
||||||
toolbar.setBackgroundResource(R.color.colorPrimary)
|
toolbar.setBackgroundResource(R.color.colorPrimary)
|
||||||
|
toolbar.animate().alpha(1f).setDuration(300).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSelectionChanged(tabSwitcher: TabSwitcher, selectedTabIndex: Int, selectedTab: Tab?) {
|
override fun onSelectionChanged(tabSwitcher: TabSwitcher, selectedTabIndex: Int, selectedTab: Tab?) {
|
||||||
@ -540,11 +543,11 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
|
|||||||
|
|
||||||
private fun toggleSwitcher(showSwitcher: Boolean, easterEgg: Boolean) {
|
private fun toggleSwitcher(showSwitcher: Boolean, easterEgg: Boolean) {
|
||||||
if (tabSwitcher.count > 0) {
|
if (tabSwitcher.count > 0) {
|
||||||
if (showSwitcher) {
|
// if (showSwitcher) {
|
||||||
val transparentAnimator = ObjectAnimator.ofFloat(toolbar, View.ALPHA, 1.0f, 0.0f, 1.0f)
|
// val transparentAnimator = ObjectAnimator.ofFloat(toolbar, View.ALPHA, 1.0f, 0.0f, 1.0f)
|
||||||
transparentAnimator.interpolator = AccelerateDecelerateInterpolator()
|
// transparentAnimator.interpolator = AccelerateDecelerateInterpolator()
|
||||||
transparentAnimator.start()
|
// transparentAnimator.start()
|
||||||
}
|
// }
|
||||||
} else if (easterEgg) {
|
} else if (easterEgg) {
|
||||||
val happyCount = NeoPreference.loadInt(NeoPreference.KEY_HAPPY_EGG, 0) + 1
|
val happyCount = NeoPreference.loadInt(NeoPreference.KEY_HAPPY_EGG, 0) + 1
|
||||||
NeoPreference.store(NeoPreference.KEY_HAPPY_EGG, happyCount)
|
NeoPreference.store(NeoPreference.KEY_HAPPY_EGG, happyCount)
|
||||||
|
Reference in New Issue
Block a user