Skip to content

Commit d6c7d6e

Browse files
committed
fix: NPE on key commands that to start activity with intent
1 parent 3d0a48f commit d6c7d6e

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

app/src/main/java/com/osfans/trime/ime/keyboard/CommonKeyboardActionListener.kt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -208,19 +208,20 @@ class CommonKeyboardActionListener(
208208
}
209209
"commit" -> service.commitText(arg)
210210
"date" -> service.commitText(customFormatDateTime(arg))
211-
"run" ->
212-
service.startActivity(
213-
buildIntentFromArgument(arg)?.apply {
214-
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_HISTORY
215-
},
216-
)
211+
"run" -> {
212+
val intent = buildIntentFromArgument(arg)
213+
if (intent != null) {
214+
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_HISTORY
215+
service.startActivity(intent)
216+
}
217+
}
217218
"share_text" -> service.shareText()
218219
else -> {
219-
service.startActivity(
220-
buildIntentFromAction(action.command, arg)?.apply {
221-
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_HISTORY
222-
},
223-
)
220+
val intent = buildIntentFromAction(action.command, arg)
221+
if (intent != null) {
222+
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_HISTORY
223+
service.startActivity(intent)
224+
}
224225
}
225226
}
226227
}

0 commit comments

Comments
 (0)