Skip to content

Commit

Permalink
refactor: other refactors to adapt Android 14
Browse files Browse the repository at this point in the history
- Adjust export settings of the activities
- Use compat to register receivers
- Change the theme of LiquidKeyboardEditActivity
  • Loading branch information
WhiredPlanck committed Feb 26, 2024
1 parent 78fc34f commit 48801ee
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

<service
android:name=".TrimeImeService"
android:exported="false"
android:exported="true"
android:label="@string/trime_app_name"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
Expand All @@ -66,6 +66,7 @@
<!-- Settings activity -->
<activity
android:name=".ui.main.PrefMainActivity"
android:exported="true"
android:launchMode="singleTask" />

<activity
Expand All @@ -85,7 +86,7 @@
android:label="@string/edit"
android:launchMode="singleInstance"
android:taskAffinity=".ui.main.LiquidKeyboardEditActivity"
android:theme="@style/Theme.AppCompat.Dialog.MinWidth"
android:theme="@android:style/Theme.DeviceDefault.Light.Dialog"
android:windowSoftInputMode="stateAlwaysVisible|adjustPan" />

<!-- Using an activity alias to disable/enable the app icon in the launcher -->
Expand Down
24 changes: 20 additions & 4 deletions app/src/main/java/com/osfans/trime/ime/broadcast/IntentReceiver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import android.content.IntentFilter
import android.os.Build.VERSION
import android.os.Build.VERSION_CODES
import android.os.PowerManager.PARTIAL_WAKE_LOCK
import androidx.core.content.ContextCompat
import com.blankj.utilcode.util.ToastUtils
import com.osfans.trime.R
import com.osfans.trime.core.Rime
Expand Down Expand Up @@ -81,7 +82,7 @@ class IntentReceiver : BroadcastReceiver(), CoroutineScope by MainScope() {
PendingIntent.getBroadcast(
context,
0,
Intent("com.osfans.trime.timing.sync"),
Intent(COMMAND_TIMING_SYNC),
if (VERSION.SDK_INT >= VERSION_CODES.M) {
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
} else {
Expand Down Expand Up @@ -114,9 +115,24 @@ class IntentReceiver : BroadcastReceiver(), CoroutineScope by MainScope() {
}

fun registerReceiver(context: Context) {
context.registerReceiver(this, IntentFilter(COMMAND_DEPLOY))
context.registerReceiver(this, IntentFilter(COMMAND_SYNC))
context.registerReceiver(this, IntentFilter(COMMAND_TIMING_SYNC))
ContextCompat.registerReceiver(
context,
this,
IntentFilter(COMMAND_DEPLOY),
ContextCompat.RECEIVER_NOT_EXPORTED,
)
ContextCompat.registerReceiver(
context,
this,
IntentFilter(COMMAND_SYNC),
ContextCompat.RECEIVER_NOT_EXPORTED,
)
ContextCompat.registerReceiver(
context,
this,
IntentFilter(COMMAND_TIMING_SYNC),
ContextCompat.RECEIVER_NOT_EXPORTED,
)
context.registerReceiver(this, IntentFilter(Intent.ACTION_SHUTDOWN))
}

Expand Down

0 comments on commit 48801ee

Please sign in to comment.