-
-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow users to trigger rime action via adb shell
- Loading branch information
1 parent
7e59896
commit 6a95f6c
Showing
7 changed files
with
96 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 0 additions & 138 deletions
138
app/src/main/java/com/osfans/trime/ime/broadcast/IntentReceiver.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
app/src/main/java/com/osfans/trime/receiver/RimeIntentReceiver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2015 - 2025 Rime community | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
|
||
package com.osfans.trime.receiver | ||
|
||
import android.content.BroadcastReceiver | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.content.IntentFilter | ||
import com.osfans.trime.BuildConfig | ||
import com.osfans.trime.daemon.RimeDaemon | ||
import timber.log.Timber | ||
|
||
class RimeIntentReceiver : BroadcastReceiver() { | ||
override fun onReceive( | ||
context: Context, | ||
intent: Intent, | ||
) { | ||
val rime = RimeDaemon.getFirstSessionOrNull() ?: return Timber.w("No active rime session, skipping") | ||
Timber.i("Received broadcast ${intent.action}") | ||
when (intent.action) { | ||
ACTION_DEPLOY -> { | ||
Timber.i("try to start maintenance ...") | ||
RimeDaemon.restartRime(true) | ||
} | ||
ACTION_SYNC_USER_DATA -> { | ||
Timber.i("try to sync rime user data ...") | ||
rime.run { syncUserData() } | ||
} | ||
else -> {} | ||
} | ||
} | ||
|
||
companion object { | ||
private const val ACTION_DEPLOY = "${BuildConfig.APPLICATION_ID}.action.DEPLOY" | ||
private const val ACTION_SYNC_USER_DATA = "${BuildConfig.APPLICATION_ID}.action.SYNC_USER_DATA" | ||
|
||
val intentFilter = | ||
IntentFilter().apply { | ||
addAction(ACTION_DEPLOY) | ||
addAction(ACTION_SYNC_USER_DATA) | ||
} | ||
} | ||
} |