Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smoother animation, notification on layout change and a bug fix #218

Merged
merged 3 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package com.dessalines.thumbkey

import android.annotation.SuppressLint
import android.content.Context
import android.widget.Toast
import androidx.compose.runtime.Composable
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.platform.AbstractComposeView
import androidx.lifecycle.lifecycleScope
import com.dessalines.thumbkey.db.AppSettingsRepository
import com.dessalines.thumbkey.ui.components.keyboard.KeyboardScreen
import com.dessalines.thumbkey.ui.theme.ThumbkeyTheme
import com.dessalines.thumbkey.utils.KeyboardLayout
import com.dessalines.thumbkey.utils.keyboardLayoutsSetFromString
import kotlinx.coroutines.launch

Expand Down Expand Up @@ -43,6 +45,9 @@ class ComposeKeyboardView(
nextLayout?.let { layout ->
val s2 = s.copy(keyboardLayout = layout)
settingsRepo.update(s2)
// Display the new layout's name on the screen
val layoutName = KeyboardLayout.values().find { it.index == nextLayout }?.title
Toast.makeText(context, "$layoutName", Toast.LENGTH_SHORT).show()
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package com.dessalines.thumbkey.ui.components.keyboard
import android.content.Context
import android.media.AudioManager
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
Expand All @@ -29,6 +31,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalContext
Expand Down Expand Up @@ -291,14 +294,31 @@ fun KeyboardKey(
KeyText(it, keySizeDp, hideLetters, capsLock)
}
}
// The popup overlay

// The animated box that fades out.
AnimatedVisibility(
modifier = Modifier
.fillMaxSize()
.background(color = Color(0, 0, 0, 0)),
visible = releasedKey.value != null,
enter = EnterTransition.None,
exit = fadeOut( tween(animationSpeed) )
) {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxSize()
.background(color = MaterialTheme.colorScheme.tertiaryContainer)
) {}
}

// The animated key letter that falls downwards and then fades out.
AnimatedVisibility(
modifier = Modifier
.fillMaxSize()
.background(color = MaterialTheme.colorScheme.tertiaryContainer),
.background(color = Color(0, 0, 0, 0)),
visible = releasedKey.value != null,
enter = slideInVertically(tween(animationSpeed)),
exit = ExitTransition.None
enter = slideInVertically( tween(animationSpeed) ),
exit = fadeOut( tween(animationSpeed) )
) {
Box(
contentAlignment = Alignment.Center,
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/dessalines/thumbkey/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ fun performKeyAction(
Log.d(TAG, "committing key text: $text")
ime.currentInputConnection.commitText(
text,
text.length
1
)

if (autoCapitalize) {
Expand Down