forked from upstream-mirrors/quik
Create custom ChangeHandler for controller animations
This commit is contained in:
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||||
|
*
|
||||||
|
* This file is part of QKSMS.
|
||||||
|
*
|
||||||
|
* QKSMS is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* QKSMS is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.moez.QKSMS.common
|
||||||
|
|
||||||
|
import android.animation.Animator
|
||||||
|
import android.animation.AnimatorSet
|
||||||
|
import android.animation.ObjectAnimator
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.animation.DecelerateInterpolator
|
||||||
|
import androidx.annotation.NonNull
|
||||||
|
import androidx.annotation.Nullable
|
||||||
|
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||||
|
import com.bluelinelabs.conductor.changehandler.AnimatorChangeHandler
|
||||||
|
import com.moez.QKSMS.common.util.extensions.dpToPx
|
||||||
|
|
||||||
|
class QkChangeHandler(removesFromViewOnPush: Boolean = true) : AnimatorChangeHandler(250, removesFromViewOnPush) {
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
override fun getAnimator(@NonNull container: ViewGroup, @Nullable from: View?, @Nullable to: View?, isPush: Boolean, toAddedToContainer: Boolean): Animator {
|
||||||
|
val animatorSet = AnimatorSet()
|
||||||
|
animatorSet.interpolator = DecelerateInterpolator()
|
||||||
|
|
||||||
|
if (isPush) {
|
||||||
|
if (from != null) {
|
||||||
|
animatorSet.play(ObjectAnimator.ofFloat(from, View.TRANSLATION_X, -from.width.toFloat() / 4))
|
||||||
|
}
|
||||||
|
if (to != null) {
|
||||||
|
to.translationZ = 8.dpToPx(to.context).toFloat()
|
||||||
|
animatorSet.play(ObjectAnimator.ofFloat(to, View.TRANSLATION_X, to.width.toFloat(), 0f))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (from != null) {
|
||||||
|
from.translationZ = 8.dpToPx(from.context).toFloat()
|
||||||
|
animatorSet.play(ObjectAnimator.ofFloat(from, View.TRANSLATION_X, from.width.toFloat()))
|
||||||
|
}
|
||||||
|
if (to != null) {
|
||||||
|
// Allow this to have a nice transition when coming off an aborted push animation
|
||||||
|
val fromLeft = from?.translationX ?: 0f
|
||||||
|
animatorSet.play(ObjectAnimator.ofFloat(to, View.TRANSLATION_X, fromLeft - to.width / 4, 0f))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return animatorSet
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun resetFromView(@NonNull from: View) {
|
||||||
|
from.translationX = 0f
|
||||||
|
from.translationZ = 0f
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
override fun copy(): ControllerChangeHandler {
|
||||||
|
return QkChangeHandler(removesFromViewOnPush())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+3
-3
@@ -22,10 +22,10 @@ import android.text.InputFilter
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.bluelinelabs.conductor.RouterTransaction
|
import com.bluelinelabs.conductor.RouterTransaction
|
||||||
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
|
|
||||||
import com.jakewharton.rxbinding2.view.clicks
|
import com.jakewharton.rxbinding2.view.clicks
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.Navigator
|
import com.moez.QKSMS.common.Navigator
|
||||||
|
import com.moez.QKSMS.common.QkChangeHandler
|
||||||
import com.moez.QKSMS.common.base.QkController
|
import com.moez.QKSMS.common.base.QkController
|
||||||
import com.moez.QKSMS.common.util.extensions.animateLayoutChanges
|
import com.moez.QKSMS.common.util.extensions.animateLayoutChanges
|
||||||
import com.moez.QKSMS.common.util.extensions.dpToPx
|
import com.moez.QKSMS.common.util.extensions.dpToPx
|
||||||
@@ -157,8 +157,8 @@ class ConversationInfoController(val threadId: Long = 0) : QkController<Conversa
|
|||||||
|
|
||||||
override fun showThemePicker(threadId: Long) {
|
override fun showThemePicker(threadId: Long) {
|
||||||
router.pushController(RouterTransaction.with(ThemePickerController(threadId))
|
router.pushController(RouterTransaction.with(ThemePickerController(threadId))
|
||||||
.pushChangeHandler(FadeChangeHandler(150))
|
.pushChangeHandler(QkChangeHandler())
|
||||||
.popChangeHandler(FadeChangeHandler(150)))
|
.popChangeHandler(QkChangeHandler()))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showDeleteDialog() {
|
override fun showDeleteDialog() {
|
||||||
|
|||||||
@@ -7,10 +7,13 @@ import android.text.format.DateFormat
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import com.bluelinelabs.conductor.RouterTransaction
|
import com.bluelinelabs.conductor.RouterTransaction
|
||||||
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
|
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
|
||||||
|
import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler
|
||||||
|
import com.bluelinelabs.conductor.changehandler.VerticalChangeHandler
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import com.jakewharton.rxbinding2.view.clicks
|
import com.jakewharton.rxbinding2.view.clicks
|
||||||
import com.moez.QKSMS.BuildConfig
|
import com.moez.QKSMS.BuildConfig
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
|
import com.moez.QKSMS.common.QkChangeHandler
|
||||||
import com.moez.QKSMS.common.QkDialog
|
import com.moez.QKSMS.common.QkDialog
|
||||||
import com.moez.QKSMS.common.base.QkController
|
import com.moez.QKSMS.common.base.QkController
|
||||||
import com.moez.QKSMS.common.util.Colors
|
import com.moez.QKSMS.common.util.Colors
|
||||||
@@ -169,20 +172,20 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
|
|||||||
|
|
||||||
override fun showSwipeActions() {
|
override fun showSwipeActions() {
|
||||||
router.pushController(RouterTransaction.with(SwipeActionsController())
|
router.pushController(RouterTransaction.with(SwipeActionsController())
|
||||||
.pushChangeHandler(FadeChangeHandler(150))
|
.pushChangeHandler(QkChangeHandler())
|
||||||
.popChangeHandler(FadeChangeHandler(150)))
|
.popChangeHandler(QkChangeHandler()))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showThemePicker() {
|
override fun showThemePicker() {
|
||||||
router.pushController(RouterTransaction.with(ThemePickerController())
|
router.pushController(RouterTransaction.with(ThemePickerController())
|
||||||
.pushChangeHandler(FadeChangeHandler(150))
|
.pushChangeHandler(QkChangeHandler())
|
||||||
.popChangeHandler(FadeChangeHandler(150)))
|
.popChangeHandler(QkChangeHandler()))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showAbout() {
|
override fun showAbout() {
|
||||||
router.pushController(RouterTransaction.with(AboutController())
|
router.pushController(RouterTransaction.with(AboutController())
|
||||||
.pushChangeHandler(FadeChangeHandler(150))
|
.pushChangeHandler(QkChangeHandler())
|
||||||
.popChangeHandler(FadeChangeHandler(150)))
|
.popChangeHandler(QkChangeHandler()))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+14
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.moez.QKSMS.feature.themepicker
|
package com.moez.QKSMS.feature.themepicker
|
||||||
|
|
||||||
|
import android.animation.ObjectAnimator
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
@@ -25,6 +26,7 @@ import com.jakewharton.rxbinding2.view.clicks
|
|||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkController
|
import com.moez.QKSMS.common.base.QkController
|
||||||
import com.moez.QKSMS.common.util.Colors
|
import com.moez.QKSMS.common.util.Colors
|
||||||
|
import com.moez.QKSMS.common.util.extensions.dpToPx
|
||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import com.moez.QKSMS.feature.themepicker.injection.ThemePickerModule
|
import com.moez.QKSMS.feature.themepicker.injection.ThemePickerModule
|
||||||
@@ -72,6 +74,18 @@ class ThemePickerController(val threadId: Long = 0L) : QkController<ThemePickerV
|
|||||||
presenter.bindIntents(this)
|
presenter.bindIntents(this)
|
||||||
setTitle(R.string.title_theme)
|
setTitle(R.string.title_theme)
|
||||||
showBackButton(true)
|
showBackButton(true)
|
||||||
|
|
||||||
|
themedActivity?.supportActionBar?.let { toolbar ->
|
||||||
|
ObjectAnimator.ofFloat(toolbar, "elevation", toolbar.elevation, 0f).start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDetach(view: View) {
|
||||||
|
super.onDetach(view)
|
||||||
|
|
||||||
|
themedActivity?.supportActionBar?.let { toolbar ->
|
||||||
|
ObjectAnimator.ofFloat(toolbar, "elevation", toolbar.elevation, 8.dpToPx(toolbar.themedContext).toFloat()).start()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showQksmsPlusSnackbar() {
|
override fun showQksmsPlusSnackbar() {
|
||||||
|
|||||||
@@ -20,7 +20,8 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:background="?android:attr/windowBackground">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/preferences"
|
android:id="@+id/preferences"
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
<com.bluelinelabs.conductor.ChangeHandlerFrameLayout
|
<com.bluelinelabs.conductor.ChangeHandlerFrameLayout
|
||||||
android:id="@+id/container"
|
android:id="@+id/container"
|
||||||
android:elevation="8dp"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|||||||
@@ -22,7 +22,8 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:background="?android:attr/windowBackground">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/preferences"
|
android:id="@+id/preferences"
|
||||||
|
|||||||
@@ -23,7 +23,8 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:background="?android:attr/windowBackground">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:animateLayoutChanges="true"
|
android:animateLayoutChanges="true"
|
||||||
|
android:background="?android:attr/windowBackground"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.PagerTitleView
|
<com.moez.QKSMS.common.widget.PagerTitleView
|
||||||
|
|||||||
Reference in New Issue
Block a user