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

Bug fix 20250215 #1590

Merged
merged 5 commits into from
Feb 16, 2025
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
7 changes: 5 additions & 2 deletions app/src/main/java/com/osfans/trime/ime/bar/QuickBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.osfans.trime.ime.candidates.popup.PopupCandidatesMode
import com.osfans.trime.ime.candidates.unrolled.window.FlexboxUnrolledCandidateWindow
import com.osfans.trime.ime.core.TrimeInputMethodService
import com.osfans.trime.ime.dependency.InputScope
import com.osfans.trime.ime.keyboard.InputFeedbackManager
import com.osfans.trime.ime.keyboard.KeyboardWindow
import com.osfans.trime.ime.window.BoardWindow
import com.osfans.trime.ime.window.BoardWindowManager
Expand Down Expand Up @@ -139,7 +140,8 @@ class QuickBar(
}

private fun setUnrollButtonToAttach() {
candidateUi.unrollButton.setOnClickListener {
candidateUi.unrollButton.setOnClickListener { view ->
InputFeedbackManager.keyPressVibrate(view)
windowManager.attachWindow(
FlexboxUnrolledCandidateWindow(context, service, rime, theme, this, windowManager, candidate.compactCandidateModule),
)
Expand All @@ -148,7 +150,8 @@ class QuickBar(
}

private fun setUnrollButtonToDetach() {
candidateUi.unrollButton.setOnClickListener {
candidateUi.unrollButton.setOnClickListener { view ->
InputFeedbackManager.keyPressVibrate(view)
windowManager.attachWindow(KeyboardWindow)
}
candidateUi.unrollButton.setIcon(R.drawable.ic_baseline_expand_less_24)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.view.ViewGroup
import com.chad.library.adapter4.util.setOnDebouncedItemClick
import com.osfans.trime.data.schema.Schema
import com.osfans.trime.data.theme.Theme
import com.osfans.trime.ime.keyboard.InputFeedbackManager
import com.osfans.trime.ime.symbol.SpacesItemDecoration
import splitties.dimensions.dp
import splitties.views.dsl.core.Ui
Expand Down Expand Up @@ -42,7 +43,8 @@ class SwitchesUi(
listener: (Schema.Switch) -> Unit,
debounceTime: Long = 300L,
) {
switchesAdapter.setOnDebouncedItemClick(debounceTime) { adapter, _, position ->
switchesAdapter.setOnDebouncedItemClick(debounceTime) { adapter, view, position ->
InputFeedbackManager.keyPressVibrate(view)
(adapter as? SwitchesAdapter)?.items?.getOrNull(position)?.let(listener)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ class CompactCandidateModule(

val adapter by lazy {
CompactCandidateViewAdapter(theme).apply {
setOnItemClickListener { _, _, position ->
rime.launchOnReady { it.selectCandidate(previous + position) }
setOnItemClickListener { _, view, position ->
rime.launchOnReady {
InputFeedbackManager.keyPressVibrate(view)
it.selectCandidate(previous + position)
}
}
setOnItemLongClickListener { _, view, position ->
showCandidateAction(previous + position, items[position].text, view)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.osfans.trime.ime.candidates.unrolled.CandidatesPagingSource
import com.osfans.trime.ime.candidates.unrolled.PagingCandidateViewAdapter
import com.osfans.trime.ime.candidates.unrolled.UnrolledCandidateLayout
import com.osfans.trime.ime.core.TrimeInputMethodService
import com.osfans.trime.ime.keyboard.InputFeedbackManager
import com.osfans.trime.ime.keyboard.KeyboardWindow
import com.osfans.trime.ime.window.BoardWindow
import com.osfans.trime.ime.window.BoardWindowManager
Expand Down Expand Up @@ -107,8 +108,11 @@ abstract class BaseUnrolledCandidateWindow(

fun bindCandidateUiViewHolder(holder: CandidateViewHolder) {
holder.itemView.run {
setOnClickListener {
rime.launchOnReady { it.selectCandidate(holder.idx) }
setOnClickListener { view ->
rime.launchOnReady {
InputFeedbackManager.keyPressVibrate(view)
it.selectCandidate(holder.idx)
}
}
setOnLongClickListener { view ->
compactCandidate.showCandidateAction(holder.idx, holder.text, view)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,24 +248,20 @@ class CommonKeyboardActionListener(
KeyEvent.KEYCODE_MENU -> showEnabledSchemaPicker()
else -> {
if (action.modifier == 0 && KeyboardSwitcher.currentKeyboard.isOnlyShiftOn) {
if (action.code == KeyEvent.KEYCODE_SPACE && prefs.keyboard.hookShiftSpace) {
val shouldHookSpace =
prefs.keyboard.hookShiftSpace && action.code == KeyEvent.KEYCODE_SPACE
val shouldHookNumber =
prefs.keyboard.hookShiftNum && action.code in KeyEvent.KEYCODE_0..KeyEvent.KEYCODE_9
val shouldHookSymbol =
(prefs.keyboard.hookShiftSymbol || !Rime.isAsciiMode) &&
(
action.code in KeyEvent.KEYCODE_GRAVE..KeyEvent.KEYCODE_SLASH ||
action.code == KeyEvent.KEYCODE_COMMA ||
action.code == KeyEvent.KEYCODE_PERIOD
)
if (shouldHookSpace || shouldHookNumber || shouldHookSymbol) {
onKey(action.code, 0)
return
} else if (action.code >= KeyEvent.KEYCODE_0 &&
action.code <= KeyEvent.KEYCODE_9 &&
prefs.keyboard.hookShiftNum
) {
onKey(action.code, 0)
return
} else if (prefs.keyboard.hookShiftSymbol) {
if (action.code >= KeyEvent.KEYCODE_GRAVE &&
action.code <= KeyEvent.KEYCODE_SLASH ||
action.code == KeyEvent.KEYCODE_COMMA ||
action.code == KeyEvent.KEYCODE_PERIOD
) {
onKey(action.code, 0)
return
}
}
}
val modifier =
Expand All @@ -274,10 +270,8 @@ class CommonKeyboardActionListener(
(action.modifier and KeyEvent.META_CTRL_ON) != 0 -> {
when (action.code) {
in KeyEvent.KEYCODE_DPAD_UP..KeyEvent.KEYCODE_DPAD_RIGHT,
KeyEvent.KEYCODE_MOVE_HOME,
KeyEvent.KEYCODE_MOVE_END,
KeyEvent.KEYCODE_MOVE_HOME, KeyEvent.KEYCODE_MOVE_END,
-> action.modifier or KeyboardSwitcher.currentKeyboard.modifier

else -> action.modifier
}
}
Expand Down
Loading
Loading