diff --git a/Android-kotlin-Code/app/src/main/java/com/github/kr328/clash/remote/Broadcasts.kt b/Android-kotlin-Code/app/src/main/java/com/github/kr328/clash/remote/Broadcasts.kt index 51d0692..75d3dcb 100644 --- a/Android-kotlin-Code/app/src/main/java/com/github/kr328/clash/remote/Broadcasts.kt +++ b/Android-kotlin-Code/app/src/main/java/com/github/kr328/clash/remote/Broadcasts.kt @@ -5,6 +5,8 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter +import android.os.Build +import androidx.core.content.ContextCompat import com.github.kr328.clash.common.constants.Intents import com.github.kr328.clash.common.log.Log import java.util.* @@ -88,7 +90,7 @@ class Broadcasts(private val context: Application) { return try { - context.registerReceiver(broadcastReceiver, IntentFilter().apply { + val filter = IntentFilter().apply { addAction(Intents.ACTION_SERVICE_RECREATED) addAction(Intents.ACTION_CLASH_STARTED) addAction(Intents.ACTION_CLASH_STOPPED) @@ -96,7 +98,15 @@ class Broadcasts(private val context: Application) { addAction(Intents.ACTION_PROFILE_UPDATE_COMPLETED) addAction(Intents.ACTION_PROFILE_UPDATE_FAILED) addAction(Intents.ACTION_PROFILE_LOADED) - }) + } + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + context.registerReceiver(broadcastReceiver, filter, Context.RECEIVER_EXPORTED) + } else { + context.registerReceiver(broadcastReceiver, filter) + } + + registered = true clashRunning = StatusClient(context).currentProfile() != null } catch (e: Exception) { @@ -110,10 +120,11 @@ class Broadcasts(private val context: Application) { try { context.unregisterReceiver(broadcastReceiver) + registered = false clashRunning = false } catch (e: Exception) { Log.w("Unregister global receiver: $e", e) } } -} \ No newline at end of file +} diff --git a/Android-kotlin-Code/design/src/main/res/layout/activity_profile.xml b/Android-kotlin-Code/design/src/main/res/layout/activity_profile.xml index c53f6f6..88ca3e6 100644 --- a/Android-kotlin-Code/design/src/main/res/layout/activity_profile.xml +++ b/Android-kotlin-Code/design/src/main/res/layout/activity_profile.xml @@ -406,7 +406,7 @@ android:layout_marginTop="16dp" android:id="@+id/view_accountinfo5" android:background="@color/white" - + android:backgroundTint="@color/white" app:cardElevation="4dp" app:cardCornerRadius="6dp" android:layout_margin="4dp" >