From 35c8c10b7e006c85f4fa20b1870fadb36107bade Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Wed, 22 Mar 2023 21:17:50 +0530 Subject: ui: address Parcelable API deprecations Signed-off-by: Harsh Shandilya --- .../java/com/wireguard/android/fragment/TunnelEditorFragment.kt | 8 +++++++- ui/src/main/java/com/wireguard/android/viewmodel/ConfigProxy.kt | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'ui/src/main/java') diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt index 872d0eab..315a6b86 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt @@ -5,6 +5,7 @@ package com.wireguard.android.fragment import android.content.Context +import android.os.Build import android.os.Bundle import android.text.InputType import android.util.Log @@ -265,7 +266,12 @@ class TunnelEditorFragment : BaseFragment() { onSelectedTunnelChanged(null, selectedTunnel) } else { tunnel = selectedTunnel - val config: ConfigProxy = savedInstanceState.getParcelable(KEY_LOCAL_CONFIG)!! + val config: ConfigProxy = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + savedInstanceState.getParcelable(KEY_LOCAL_CONFIG, ConfigProxy::class.java)!! + } else { + @Suppress("DEPRECATION") + savedInstanceState.getParcelable(KEY_LOCAL_CONFIG)!! + } val originalName = savedInstanceState.getString(KEY_ORIGINAL_NAME) if (tunnel != null && tunnel!!.name != originalName) onSelectedTunnelChanged(null, tunnel) else binding!!.config = config } diff --git a/ui/src/main/java/com/wireguard/android/viewmodel/ConfigProxy.kt b/ui/src/main/java/com/wireguard/android/viewmodel/ConfigProxy.kt index 0e3c9aa1..e29de2dd 100644 --- a/ui/src/main/java/com/wireguard/android/viewmodel/ConfigProxy.kt +++ b/ui/src/main/java/com/wireguard/android/viewmodel/ConfigProxy.kt @@ -18,7 +18,7 @@ class ConfigProxy : Parcelable { val peers: ObservableList = ObservableArrayList() private constructor(parcel: Parcel) { - `interface` = parcel.readParcelable(InterfaceProxy::class.java.classLoader)!! + `interface` = InterfaceProxy.CREATOR.createFromParcel(parcel) parcel.readTypedList(peers, PeerProxy.CREATOR) peers.forEach { it.bind(this) } } -- cgit v1.2.3