improve MainActivity / LoginActivity transitions (#4301)
I overlooked those in https://github.com/tuskyapp/Tusky/pull/4224
This commit is contained in:
parent
9901376d38
commit
be8b7c3a31
7 changed files with 26 additions and 22 deletions
|
@ -24,7 +24,6 @@ import android.content.res.Configuration;
|
|||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
|
@ -81,7 +80,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
|||
|
||||
if (supportsOverridingActivityTransitions() && activityTransitionWasRequested()) {
|
||||
overrideActivityTransition(OVERRIDE_TRANSITION_OPEN, R.anim.activity_open_enter, R.anim.activity_open_exit);
|
||||
overrideActivityTransition(OVERRIDE_TRANSITION_CLOSE, R.anim.actitivity_close_enter, R.anim.activity_close_exit);
|
||||
overrideActivityTransition(OVERRIDE_TRANSITION_CLOSE, R.anim.activity_close_enter, R.anim.activity_close_exit);
|
||||
}
|
||||
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
@ -195,7 +194,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
|||
super.finish();
|
||||
// if this activity was opened with slide-in, close it with slide out
|
||||
if (!supportsOverridingActivityTransitions() && activityTransitionWasRequested()) {
|
||||
overridePendingTransition(R.anim.actitivity_close_enter, R.anim.activity_close_exit);
|
||||
overridePendingTransition(R.anim.activity_close_enter, R.anim.activity_close_exit);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -216,6 +216,10 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
|||
val activeAccount = accountManager.activeAccount
|
||||
?: return // will be redirected to LoginActivity by BaseActivity
|
||||
|
||||
if (supportsOverridingActivityTransitions() && explodeAnimationWasRequested()) {
|
||||
overrideActivityTransition(OVERRIDE_TRANSITION_OPEN, R.anim.explode, R.anim.activity_open_exit)
|
||||
}
|
||||
|
||||
var showNotificationTab = false
|
||||
|
||||
// check for savedInstanceState in order to not handle intent events more than once
|
||||
|
@ -979,7 +983,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
|||
cacheUpdater.stop()
|
||||
accountManager.setActiveAccount(newSelectedId)
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
intent.putExtra(OPEN_WITH_EXPLODE_ANIMATION, true)
|
||||
if (forward != null) {
|
||||
intent.type = forward.type
|
||||
intent.action = forward.action
|
||||
|
@ -987,11 +991,9 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
|||
}
|
||||
startActivity(intent)
|
||||
finish()
|
||||
if (supportsOverridingActivityTransitions()) {
|
||||
overrideActivityTransition(OVERRIDE_TRANSITION_OPEN, R.anim.explode, R.anim.explode)
|
||||
} else {
|
||||
if (!supportsOverridingActivityTransitions()) {
|
||||
@Suppress("DEPRECATION")
|
||||
overridePendingTransition(R.anim.explode, R.anim.explode)
|
||||
overridePendingTransition(R.anim.explode, R.anim.activity_open_exit)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1209,11 +1211,17 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
|||
}
|
||||
}
|
||||
|
||||
private fun explodeAnimationWasRequested(): Boolean {
|
||||
return intent.getBooleanExtra(OPEN_WITH_EXPLODE_ANIMATION, false)
|
||||
}
|
||||
|
||||
override fun getActionButton() = binding.composeButton
|
||||
|
||||
override fun androidInjector() = androidInjector
|
||||
|
||||
companion object {
|
||||
const val OPEN_WITH_EXPLODE_ANIMATION = "explode"
|
||||
|
||||
private const val TAG = "MainActivity" // logging tag
|
||||
private const val DRAWER_ITEM_ADD_ACCOUNT: Long = -13
|
||||
private const val DRAWER_ITEM_ANNOUNCEMENTS: Long = 14
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.keylesspalace.tusky.util.getNonNullString
|
|||
import com.keylesspalace.tusky.util.openLinkInCustomTab
|
||||
import com.keylesspalace.tusky.util.rickRoll
|
||||
import com.keylesspalace.tusky.util.shouldRickRoll
|
||||
import com.keylesspalace.tusky.util.supportsOverridingActivityTransitions
|
||||
import com.keylesspalace.tusky.util.viewBinding
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -123,13 +124,6 @@ class LoginActivity : BaseActivity(), Injectable {
|
|||
return false
|
||||
}
|
||||
|
||||
override fun finish() {
|
||||
super.finish()
|
||||
if (isAdditionalLogin() || isAccountMigration()) {
|
||||
overridePendingTransition(R.anim.actitivity_close_enter, R.anim.activity_close_exit)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
menu?.add(R.string.action_browser_login)?.apply {
|
||||
setOnMenuItemClickListener {
|
||||
|
@ -320,10 +314,13 @@ class LoginActivity : BaseActivity(), Injectable {
|
|||
)
|
||||
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
intent.putExtra(MainActivity.OPEN_WITH_EXPLODE_ANIMATION, true)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
overridePendingTransition(R.anim.explode, R.anim.explode)
|
||||
finishAffinity()
|
||||
if (!supportsOverridingActivityTransitions()) {
|
||||
@Suppress("DEPRECATION")
|
||||
overridePendingTransition(R.anim.explode, R.anim.activity_open_exit)
|
||||
}
|
||||
}, { e ->
|
||||
setLoading(false)
|
||||
binding.domainTextInputLayout.error =
|
||||
|
|
|
@ -117,7 +117,7 @@ class PreferencesActivity :
|
|||
setCustomAnimations(
|
||||
R.anim.activity_open_enter,
|
||||
R.anim.activity_open_exit,
|
||||
R.anim.actitivity_close_enter,
|
||||
R.anim.activity_close_enter,
|
||||
R.anim.activity_close_exit
|
||||
)
|
||||
replace(R.id.fragment_container, fragment)
|
||||
|
|
|
@ -431,7 +431,7 @@ class ViewThreadFragment :
|
|||
setCustomAnimations(
|
||||
R.anim.activity_open_enter,
|
||||
R.anim.activity_open_exit,
|
||||
R.anim.actitivity_close_enter,
|
||||
R.anim.activity_close_enter,
|
||||
R.anim.activity_close_exit
|
||||
)
|
||||
replace(R.id.fragment_container, viewEditsFragment, "ViewEditsFragment_$id")
|
||||
|
|
|
@ -57,6 +57,7 @@ import com.keylesspalace.tusky.network.MastodonApi
|
|||
import com.keylesspalace.tusky.usecase.TimelineCases
|
||||
import com.keylesspalace.tusky.util.openLink
|
||||
import com.keylesspalace.tusky.util.parseAsMastodonHtml
|
||||
import com.keylesspalace.tusky.util.startActivityWithSlideInAnimation
|
||||
import com.keylesspalace.tusky.view.showMuteAccountDialog
|
||||
import com.keylesspalace.tusky.viewdata.AttachmentViewData
|
||||
import javax.inject.Inject
|
||||
|
@ -83,8 +84,7 @@ abstract class SFragment : Fragment(), Injectable {
|
|||
lateinit var timelineCases: TimelineCases
|
||||
|
||||
override fun startActivity(intent: Intent) {
|
||||
super.startActivity(intent)
|
||||
requireActivity().overridePendingTransition(R.anim.activity_open_enter, R.anim.activity_open_exit)
|
||||
requireActivity().startActivityWithSlideInAnimation(intent)
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
|
|
Loading…
Reference in a new issue