android: clean up build warnings (#443)

#cleanup

Removed a host of noisy deprecation and unchecked
cast warnings.

Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
pull/444/head
Jonathan Nobels 4 months ago committed by GitHub
parent 66fa3c41a6
commit 26b4635c11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -326,7 +326,7 @@ class App : UninitializedApp(), libtailscale.AppContext {
@Throws(
IOException::class, GeneralSecurityException::class, MDMSettings.NoSuchKeyException::class)
override fun getSyspolicyStringArrayJSONValue(key: String): String {
val list = MDMSettings.allSettingsByKey[key]?.flow?.value as? List<String>
val list = MDMSettings.allSettingsByKey[key]?.flow?.value as? List<*>
try {
return Json.encodeToString(list)
} catch (e: Exception) {

@ -28,8 +28,8 @@ class ShareActivity : ComponentActivity() {
private val requestedTransfers: StateFlow<List<Ipn.OutgoingFile>> = MutableStateFlow(emptyList())
override fun onCreate(state: Bundle?) {
super.onCreate(state)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
AppTheme {
Surface(color = MaterialTheme.colorScheme.inverseSurface) { // Background for the letterbox
@ -62,14 +62,14 @@ class ShareActivity : ComponentActivity() {
}
val act = intent.action
val uris: List<Uri?>?
uris =
val uris: List<Uri?>? =
when (act) {
Intent.ACTION_SEND -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
listOf(intent.getParcelableExtra(Intent.EXTRA_STREAM, Uri::class.java))
} else {
@Suppress("DEPRECATION")
listOf(intent.getParcelableExtra(Intent.EXTRA_STREAM) as? Uri)
}
}
@ -77,7 +77,7 @@ class ShareActivity : ComponentActivity() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent.getParcelableArrayListExtra<Uri?>(Intent.EXTRA_STREAM, Uri::class.java)
} else {
intent.getParcelableArrayListExtra<Uri?>(Intent.EXTRA_STREAM)
@Suppress("DEPRECATION") intent.getParcelableArrayListExtra<Uri?>(Intent.EXTRA_STREAM)
}
}
else -> {

@ -320,6 +320,8 @@ class Request<T>(
// TODO: use the streaming body for performance
// An empty body is a perfectly valid response and indicates success
val respData = resp.bodyBytes() ?: ByteArray(0)
@Suppress("UNCHECKED_CAST")
val response: Result<T> =
when (responseType) {
typeOf<String>() -> Result.success(respData.decodeToString() as T)

@ -25,13 +25,14 @@ import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
class DNSSettingsViewModelFactory() : ViewModelProvider.Factory {
class DNSSettingsViewModelFactory : ViewModelProvider.Factory {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return DNSSettingsViewModel() as T
}
}
class DNSSettingsViewModel() : IpnViewModel() {
class DNSSettingsViewModel : IpnViewModel() {
val enablementState: StateFlow<DNSEnablementState> =
MutableStateFlow(DNSEnablementState.NOT_RUNNING)
val dnsConfig: StateFlow<Tailcfg.DNSConfig?> = MutableStateFlow(null)

@ -30,6 +30,7 @@ data class ExitNodePickerNav(
class ExitNodePickerViewModelFactory(private val nav: ExitNodePickerNav) :
ViewModelProvider.Factory {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return ExitNodePickerViewModel(nav) as T
}

@ -23,6 +23,7 @@ class PeerDetailsViewModelFactory(
private val filesDir: File,
private val pingViewModel: PingViewModel
) : ViewModelProvider.Factory {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return PeerDetailsViewModel(nodeId, filesDir, pingViewModel) as T
}

@ -20,6 +20,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
class PingViewModelFactory(private val peer: Tailcfg.Node) : ViewModelProvider.Factory {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return PingViewModel() as T
}

@ -36,13 +36,14 @@ class TaildropViewModelFactory(
private val requestedTransfers: StateFlow<List<Ipn.OutgoingFile>>,
private val applicationScope: CoroutineScope
) : ViewModelProvider.Factory {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return TaildropViewModel(requestedTransfers, applicationScope) as T
}
}
class TaildropViewModel(
val requestedTransfers: StateFlow<List<Ipn.OutgoingFile>>,
private val requestedTransfers: StateFlow<List<Ipn.OutgoingFile>>,
private val applicationScope: CoroutineScope
) : IpnViewModel() {

@ -16,7 +16,8 @@ import com.tailscale.ipn.ui.util.set
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
class TailnetLockSetupViewModelFactory() : ViewModelProvider.Factory {
class TailnetLockSetupViewModelFactory : ViewModelProvider.Factory {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return TailnetLockSetupViewModel() as T
}
@ -24,7 +25,7 @@ class TailnetLockSetupViewModelFactory() : ViewModelProvider.Factory {
data class StatusItem(@StringRes val title: Int, @DrawableRes val icon: Int)
class TailnetLockSetupViewModel() : IpnViewModel() {
class TailnetLockSetupViewModel : IpnViewModel() {
val statusItems: StateFlow<List<StatusItem>> = MutableStateFlow(emptyList())
val nodeKey: StateFlow<String> = MutableStateFlow("unknown")

Loading…
Cancel
Save