From 17caa213eeef57d83b9792c03bc8bf889437afd5 Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Fri, 23 Aug 2024 12:33:56 +1000 Subject: [PATCH] Fixing animations Also fixing compose copy that wasn't set up properly... --- .../conversation/v2/ConversationActivityV2.kt | 5 +++- .../securesms/preferences/SettingsActivity.kt | 24 ++++++++++++------- .../securesms/ui/theme/SessionTypography.kt | 4 ++-- .../securesms/util/ActivityUtilities.kt | 4 ++-- app/src/main/res/anim/fade_scale_in.xml | 21 ++++++++++++++++ app/src/main/res/anim/slide_to_bottom.xml | 11 +++++++++ 6 files changed, 56 insertions(+), 13 deletions(-) create mode 100644 app/src/main/res/anim/fade_scale_in.xml create mode 100644 app/src/main/res/anim/slide_to_bottom.xml diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index d3192abc05..69844e33b6 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -2085,7 +2085,10 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe override fun showMessageDetail(messages: Set) { Intent(this, MessageDetailActivity::class.java) .apply { putExtra(MESSAGE_TIMESTAMP, messages.first().timestamp) } - .let { handleMessageDetail.launch(it) } + .let { + handleMessageDetail.launch(it) + overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left) + } endActionMode() } diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt index 527cb6ae73..77f5938d53 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt @@ -162,6 +162,9 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() { super.onCreate(savedInstanceState, isReady) binding = ActivitySettingsBinding.inflate(layoutInflater) setContentView(binding.root) + + // set the toolbar icon to a close icon + supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_baseline_close_24) } override fun onStart() { @@ -182,6 +185,11 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() { } } + override fun finish() { + super.finish() + overridePendingTransition(R.anim.fade_scale_in, R.anim.slide_to_bottom) + } + private fun getDisplayName(): String = TextSecurePreferences.getProfileName(this) ?: truncateIdForDisplay(hexEncodedPublicKey) @@ -501,26 +509,26 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() { Cell { Column { Crossfade(if (hasPaths) R.drawable.ic_status else R.drawable.ic_path_yellow, label = "path") { - LargeItemButtonWithDrawable(R.string.activity_path_title, it) { show() } + LargeItemButtonWithDrawable(R.string.activity_path_title, it) { push() } } Divider() - LargeItemButton(R.string.activity_settings_privacy_button_title, R.drawable.ic_privacy_icon) { show() } + LargeItemButton(R.string.activity_settings_privacy_button_title, R.drawable.ic_privacy_icon) { push() } Divider() - LargeItemButton(R.string.activity_settings_notifications_button_title, R.drawable.ic_speaker, Modifier.contentDescription(R.string.AccessibilityId_notifications)) { show() } + LargeItemButton(R.string.activity_settings_notifications_button_title, R.drawable.ic_speaker, Modifier.contentDescription(R.string.AccessibilityId_notifications)) { push() } Divider() - LargeItemButton(R.string.activity_settings_conversations_button_title, R.drawable.ic_conversations, Modifier.contentDescription(R.string.AccessibilityId_conversations)) { show() } + LargeItemButton(R.string.activity_settings_conversations_button_title, R.drawable.ic_conversations, Modifier.contentDescription(R.string.AccessibilityId_conversations)) { push() } Divider() - LargeItemButton(R.string.activity_settings_message_requests_button_title, R.drawable.ic_message_requests, Modifier.contentDescription(R.string.AccessibilityId_message_requests)) { show() } + LargeItemButton(R.string.activity_settings_message_requests_button_title, R.drawable.ic_message_requests, Modifier.contentDescription(R.string.AccessibilityId_message_requests)) { push() } Divider() - LargeItemButton(R.string.activity_settings_message_appearance_button_title, R.drawable.ic_appearance, Modifier.contentDescription(R.string.AccessibilityId_appearance)) { show() } + LargeItemButton(R.string.activity_settings_message_appearance_button_title, R.drawable.ic_appearance, Modifier.contentDescription(R.string.AccessibilityId_appearance)) { push() } Divider() LargeItemButton(R.string.activity_settings_invite_button_title, R.drawable.ic_invite_friend, Modifier.contentDescription(R.string.AccessibilityId_invite_friend)) { sendInvitationToUseSession() } Divider() if (!prefs.getHidePassword()) { - LargeItemButton(R.string.sessionRecoveryPassword, R.drawable.ic_shield_outline, Modifier.contentDescription(R.string.AccessibilityId_recovery_password_menu_item)) { show() } + LargeItemButton(R.string.sessionRecoveryPassword, R.drawable.ic_shield_outline, Modifier.contentDescription(R.string.AccessibilityId_recovery_password_menu_item)) { push() } Divider() } - LargeItemButton(R.string.activity_settings_help_button, R.drawable.ic_help, Modifier.contentDescription(R.string.AccessibilityId_help)) { show() } + LargeItemButton(R.string.activity_settings_help_button, R.drawable.ic_help, Modifier.contentDescription(R.string.AccessibilityId_help)) { push() } Divider() LargeItemButton(R.string.activity_settings_clear_all_data_button_title, R.drawable.ic_delete, Modifier.contentDescription(R.string.AccessibilityId_clear_data), dangerButtonColors()) { ClearAllDataDialog().show(supportFragmentManager, "Clear All Data Dialog") } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/theme/SessionTypography.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/theme/SessionTypography.kt index 602affa6af..50c3957cbd 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/theme/SessionTypography.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/theme/SessionTypography.kt @@ -8,11 +8,11 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.sp -fun TextStyle.bold() = TextStyle.Default.copy( +fun TextStyle.bold() = copy( fontWeight = FontWeight.Bold ) -fun TextStyle.monospace() = TextStyle.Default.copy( +fun TextStyle.monospace() = copy( fontFamily = FontFamily.Monospace ) diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/ActivityUtilities.kt b/app/src/main/java/org/thoughtcrime/securesms/util/ActivityUtilities.kt index c3b7eaca96..f50ac33e28 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/ActivityUtilities.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/util/ActivityUtilities.kt @@ -53,7 +53,7 @@ fun AppCompatActivity.push(intent: Intent, isForResult: Boolean = false) { } else { startActivity(intent) } - overridePendingTransition(R.anim.slide_from_right, R.anim.fade_scale_out) + overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left) } fun AppCompatActivity.show(intent: Intent, isForResult: Boolean = false) { @@ -108,5 +108,5 @@ data class ThemeState ( ) inline fun Activity.show() = Intent(this, T::class.java).also(::startActivity).let { overridePendingTransition(R.anim.slide_from_bottom, R.anim.fade_scale_out) } -inline fun Activity.push(modify: Intent.() -> Unit = {}) = Intent(this, T::class.java).also(modify).also(::startActivity).let { overridePendingTransition(R.anim.slide_from_right, R.anim.fade_scale_out) } +inline fun Activity.push(modify: Intent.() -> Unit = {}) = Intent(this, T::class.java).also(modify).also(::startActivity).let { overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left) } inline fun Context.start(modify: Intent.() -> Unit = {}) = Intent(this, T::class.java).also(modify).apply { addFlags(FLAG_ACTIVITY_SINGLE_TOP) }.let(::startActivity) diff --git a/app/src/main/res/anim/fade_scale_in.xml b/app/src/main/res/anim/fade_scale_in.xml new file mode 100644 index 0000000000..3e004af2c2 --- /dev/null +++ b/app/src/main/res/anim/fade_scale_in.xml @@ -0,0 +1,21 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_to_bottom.xml b/app/src/main/res/anim/slide_to_bottom.xml new file mode 100644 index 0000000000..0f62dfa487 --- /dev/null +++ b/app/src/main/res/anim/slide_to_bottom.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file