From 75a35d3c97ea3023b4df03be112d3605ae564784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sat, 16 Mar 2024 21:34:19 +0800 Subject: [PATCH] Make linter happy --- .../main/java/io/nekohasekai/sfa/Application.kt | 1 + .../io/nekohasekai/sfa/bg/AppChangeReceiver.kt | 4 ++-- .../java/io/nekohasekai/sfa/bg/BootReceiver.kt | 2 ++ .../main/java/io/nekohasekai/sfa/bg/BoxService.kt | 14 +++++++++----- .../nekohasekai/sfa/bg/DefaultNetworkListener.kt | 3 +++ .../nekohasekai/sfa/bg/PlatformInterfaceWrapper.kt | 1 + .../java/io/nekohasekai/sfa/bg/ProxyService.kt | 4 ++-- .../java/io/nekohasekai/sfa/bg/ServiceBinder.kt | 2 ++ .../io/nekohasekai/sfa/bg/ServiceNotification.kt | 2 ++ .../main/java/io/nekohasekai/sfa/bg/VPNService.kt | 4 ++-- .../io/nekohasekai/sfa/database/ProfileManager.kt | 2 ++ .../java/io/nekohasekai/sfa/database/Settings.kt | 2 ++ app/src/main/java/io/nekohasekai/sfa/ktx/Shares.kt | 2 +- .../java/io/nekohasekai/sfa/ui/MainActivity.kt | 2 +- .../nekohasekai/sfa/ui/dashboard/GroupsFragment.kt | 4 ++++ .../sfa/ui/dashboard/OverviewFragment.kt | 2 ++ .../io/nekohasekai/sfa/ui/debug/VPNScanActivity.kt | 1 - .../sfa/ui/main/ConfigurationFragment.kt | 8 +++++--- .../nekohasekai/sfa/ui/main/DashboardFragment.kt | 8 ++++---- .../sfa/ui/profile/EditProfileActivity.kt | 5 +---- .../sfa/ui/profile/EditProfileContentActivity.kt | 2 -- .../sfa/ui/profile/NewProfileActivity.kt | 6 +----- .../sfa/ui/profileoverride/PerAppProxyActivity.kt | 6 ++++-- 23 files changed, 53 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/io/nekohasekai/sfa/Application.kt b/app/src/main/java/io/nekohasekai/sfa/Application.kt index ac96d0c..bec7372 100644 --- a/app/src/main/java/io/nekohasekai/sfa/Application.kt +++ b/app/src/main/java/io/nekohasekai/sfa/Application.kt @@ -31,6 +31,7 @@ class Application : Application() { Seq.setContext(this) + @Suppress("OPT_IN_USAGE") GlobalScope.launch(Dispatchers.IO) { UpdateProfileWork.reconfigureUpdater() } diff --git a/app/src/main/java/io/nekohasekai/sfa/bg/AppChangeReceiver.kt b/app/src/main/java/io/nekohasekai/sfa/bg/AppChangeReceiver.kt index 3088f0a..3d251b4 100644 --- a/app/src/main/java/io/nekohasekai/sfa/bg/AppChangeReceiver.kt +++ b/app/src/main/java/io/nekohasekai/sfa/bg/AppChangeReceiver.kt @@ -15,10 +15,10 @@ class AppChangeReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { Log.d(TAG, "onReceive: ${intent.action}") - checkUpdate(context, intent) + checkUpdate(intent) } - private fun checkUpdate(context: Context, intent: Intent) { + private fun checkUpdate(intent: Intent) { if (!Settings.perAppProxyEnabled) { Log.d(TAG, "per app proxy disabled") return diff --git a/app/src/main/java/io/nekohasekai/sfa/bg/BootReceiver.kt b/app/src/main/java/io/nekohasekai/sfa/bg/BootReceiver.kt index bca64a6..f4dc8f0 100644 --- a/app/src/main/java/io/nekohasekai/sfa/bg/BootReceiver.kt +++ b/app/src/main/java/io/nekohasekai/sfa/bg/BootReceiver.kt @@ -4,6 +4,7 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import io.nekohasekai.sfa.database.Settings +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch @@ -11,6 +12,7 @@ import kotlinx.coroutines.withContext class BootReceiver : BroadcastReceiver() { + @OptIn(DelicateCoroutinesApi::class) override fun onReceive(context: Context, intent: Intent) { when (intent.action) { Intent.ACTION_BOOT_COMPLETED, Intent.ACTION_MY_PACKAGE_REPLACED -> { diff --git a/app/src/main/java/io/nekohasekai/sfa/bg/BoxService.kt b/app/src/main/java/io/nekohasekai/sfa/bg/BoxService.kt index 4cf132c..cc339cb 100644 --- a/app/src/main/java/io/nekohasekai/sfa/bg/BoxService.kt +++ b/app/src/main/java/io/nekohasekai/sfa/bg/BoxService.kt @@ -27,6 +27,7 @@ import io.nekohasekai.sfa.constant.Status import io.nekohasekai.sfa.database.ProfileManager import io.nekohasekai.sfa.database.Settings import io.nekohasekai.sfa.ktx.hasPermission +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.delay @@ -243,6 +244,7 @@ class BoxService( } } + @OptIn(DelicateCoroutinesApi::class) private fun stopService() { if (status.value != Status.Started) return status.value = Status.Stopping @@ -298,7 +300,9 @@ class BoxService( } } - fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { + @OptIn(DelicateCoroutinesApi::class) + @Suppress("SameReturnValue") + internal fun onStartCommand(): Int { if (status.value != Status.Stopped) return Service.START_NOT_STICKY status.value = Status.Starting @@ -327,19 +331,19 @@ class BoxService( return Service.START_NOT_STICKY } - fun onBind(intent: Intent): IBinder { + internal fun onBind(): IBinder { return binder } - fun onDestroy() { + internal fun onDestroy() { binder.close() } - fun onRevoke() { + internal fun onRevoke() { stopService() } - fun writeLog(message: String) { + internal fun writeLog(message: String) { binder.broadcast { it.onServiceWriteLog(message) } diff --git a/app/src/main/java/io/nekohasekai/sfa/bg/DefaultNetworkListener.kt b/app/src/main/java/io/nekohasekai/sfa/bg/DefaultNetworkListener.kt index 9fb45f6..239daae 100644 --- a/app/src/main/java/io/nekohasekai/sfa/bg/DefaultNetworkListener.kt +++ b/app/src/main/java/io/nekohasekai/sfa/bg/DefaultNetworkListener.kt @@ -30,8 +30,10 @@ import android.os.Handler import android.os.Looper import io.nekohasekai.sfa.Application import kotlinx.coroutines.CompletableDeferred +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.ObsoleteCoroutinesApi import kotlinx.coroutines.channels.actor import kotlinx.coroutines.runBlocking @@ -49,6 +51,7 @@ object DefaultNetworkListener { class Lost(val network: Network) : NetworkMessage() } + @OptIn(DelicateCoroutinesApi::class, ObsoleteCoroutinesApi::class) private val networkActor = GlobalScope.actor(Dispatchers.Unconfined) { val listeners = mutableMapOf Unit>() var network: Network? = null diff --git a/app/src/main/java/io/nekohasekai/sfa/bg/PlatformInterfaceWrapper.kt b/app/src/main/java/io/nekohasekai/sfa/bg/PlatformInterfaceWrapper.kt index fd13a46..1502646 100644 --- a/app/src/main/java/io/nekohasekai/sfa/bg/PlatformInterfaceWrapper.kt +++ b/app/src/main/java/io/nekohasekai/sfa/bg/PlatformInterfaceWrapper.kt @@ -103,6 +103,7 @@ interface PlatformInterfaceWrapper : PlatformInterface { } override fun readWIFIState(): WIFIState? { + @Suppress("DEPRECATION") val wifiInfo = Application.wifiManager.connectionInfo ?: return null var ssid = wifiInfo.ssid if (ssid.startsWith("\"") && ssid.endsWith("\"")) { diff --git a/app/src/main/java/io/nekohasekai/sfa/bg/ProxyService.kt b/app/src/main/java/io/nekohasekai/sfa/bg/ProxyService.kt index 878f0c7..a84082f 100644 --- a/app/src/main/java/io/nekohasekai/sfa/bg/ProxyService.kt +++ b/app/src/main/java/io/nekohasekai/sfa/bg/ProxyService.kt @@ -8,9 +8,9 @@ class ProxyService : Service(), PlatformInterfaceWrapper { private val service = BoxService(this, this) override fun onStartCommand(intent: Intent?, flags: Int, startId: Int) = - service.onStartCommand(intent, flags, startId) + service.onStartCommand() - override fun onBind(intent: Intent) = service.onBind(intent) + override fun onBind(intent: Intent) = service.onBind() override fun onDestroy() = service.onDestroy() override fun writeLog(message: String) = service.writeLog(message) diff --git a/app/src/main/java/io/nekohasekai/sfa/bg/ServiceBinder.kt b/app/src/main/java/io/nekohasekai/sfa/bg/ServiceBinder.kt index d0eb951..0f8a605 100644 --- a/app/src/main/java/io/nekohasekai/sfa/bg/ServiceBinder.kt +++ b/app/src/main/java/io/nekohasekai/sfa/bg/ServiceBinder.kt @@ -5,6 +5,7 @@ import androidx.lifecycle.MutableLiveData import io.nekohasekai.sfa.aidl.IService import io.nekohasekai.sfa.aidl.IServiceCallback import io.nekohasekai.sfa.constant.Status +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch @@ -23,6 +24,7 @@ class ServiceBinder(private val status: MutableLiveData) : IService.Stub } } + @OptIn(DelicateCoroutinesApi::class) fun broadcast(work: (IServiceCallback) -> Unit) { GlobalScope.launch(Dispatchers.Main) { broadcastLock.withLock { diff --git a/app/src/main/java/io/nekohasekai/sfa/bg/ServiceNotification.kt b/app/src/main/java/io/nekohasekai/sfa/bg/ServiceNotification.kt index 74b9aa4..db1a618 100644 --- a/app/src/main/java/io/nekohasekai/sfa/bg/ServiceNotification.kt +++ b/app/src/main/java/io/nekohasekai/sfa/bg/ServiceNotification.kt @@ -22,6 +22,7 @@ import io.nekohasekai.sfa.constant.Status import io.nekohasekai.sfa.database.Settings import io.nekohasekai.sfa.ui.MainActivity import io.nekohasekai.sfa.utils.CommandClient +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.withContext @@ -43,6 +44,7 @@ class ServiceNotification( } } + @OptIn(DelicateCoroutinesApi::class) private val commandClient = CommandClient(GlobalScope, CommandClient.ConnectionType.Status, this) private var receiverRegistered = false diff --git a/app/src/main/java/io/nekohasekai/sfa/bg/VPNService.kt b/app/src/main/java/io/nekohasekai/sfa/bg/VPNService.kt index 12c4fc0..44e244c 100644 --- a/app/src/main/java/io/nekohasekai/sfa/bg/VPNService.kt +++ b/app/src/main/java/io/nekohasekai/sfa/bg/VPNService.kt @@ -22,14 +22,14 @@ class VPNService : VpnService(), PlatformInterfaceWrapper { private val service = BoxService(this, this) override fun onStartCommand(intent: Intent?, flags: Int, startId: Int) = - service.onStartCommand(intent, flags, startId) + service.onStartCommand() override fun onBind(intent: Intent): IBinder { val binder = super.onBind(intent) if (binder != null) { return binder } - return service.onBind(intent) + return service.onBind() } override fun onDestroy() { diff --git a/app/src/main/java/io/nekohasekai/sfa/database/ProfileManager.kt b/app/src/main/java/io/nekohasekai/sfa/database/ProfileManager.kt index 881b6f1..61f1dc6 100644 --- a/app/src/main/java/io/nekohasekai/sfa/database/ProfileManager.kt +++ b/app/src/main/java/io/nekohasekai/sfa/database/ProfileManager.kt @@ -3,6 +3,7 @@ package io.nekohasekai.sfa.database import androidx.room.Room import io.nekohasekai.sfa.Application import io.nekohasekai.sfa.constant.Path +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch @@ -19,6 +20,7 @@ object ProfileManager { callbacks.remove(callback) } + @OptIn(DelicateCoroutinesApi::class) private val instance by lazy { Application.application.getDatabasePath(Path.PROFILES_DATABASE_PATH).parentFile?.mkdirs() Room diff --git a/app/src/main/java/io/nekohasekai/sfa/database/Settings.kt b/app/src/main/java/io/nekohasekai/sfa/database/Settings.kt index cc83056..6f5bb79 100644 --- a/app/src/main/java/io/nekohasekai/sfa/database/Settings.kt +++ b/app/src/main/java/io/nekohasekai/sfa/database/Settings.kt @@ -14,6 +14,7 @@ import io.nekohasekai.sfa.ktx.int import io.nekohasekai.sfa.ktx.long import io.nekohasekai.sfa.ktx.string import io.nekohasekai.sfa.ktx.stringSet +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import org.json.JSONObject @@ -21,6 +22,7 @@ import java.io.File object Settings { + @OptIn(DelicateCoroutinesApi::class) private val instance by lazy { Application.application.getDatabasePath(Path.SETTINGS_DATABASE_PATH).parentFile?.mkdirs() Room.databaseBuilder( diff --git a/app/src/main/java/io/nekohasekai/sfa/ktx/Shares.kt b/app/src/main/java/io/nekohasekai/sfa/ktx/Shares.kt index 71ab82a..52dc78e 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ktx/Shares.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ktx/Shares.kt @@ -52,7 +52,7 @@ suspend fun Context.shareProfile(profile: Profile) { } } -suspend fun FragmentActivity.shareProfileURL(profile: Profile) { +fun FragmentActivity.shareProfileURL(profile: Profile) { val link = Libbox.generateRemoteProfileImportLink( profile.name, profile.typed.remoteURL diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/MainActivity.kt b/app/src/main/java/io/nekohasekai/sfa/ui/MainActivity.kt index e2e2d5c..9f6c46a 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ui/MainActivity.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ui/MainActivity.kt @@ -103,12 +103,12 @@ class MainActivity : AbstractActivity(), return navController.navigateUp(appBarConfiguration) } + @Suppress("UNUSED_PARAMETER") private fun onDestinationChanged( navController: NavController, navDestination: NavDestination, bundle: Bundle? ) { - val binding = binding ?: return val destinationId = navDestination.id binding.dashboardTabContainer.isVisible = destinationId == R.id.navigation_dashboard } diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/dashboard/GroupsFragment.kt b/app/src/main/java/io/nekohasekai/sfa/ui/dashboard/GroupsFragment.kt index 07e3cab..2c53507 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ui/dashboard/GroupsFragment.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ui/dashboard/GroupsFragment.kt @@ -29,6 +29,7 @@ import io.nekohasekai.sfa.ktx.errorDialogBuilder import io.nekohasekai.sfa.ktx.text import io.nekohasekai.sfa.ui.MainActivity import io.nekohasekai.sfa.utils.CommandClient +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch @@ -152,6 +153,7 @@ class GroupsFragment : Fragment(), CommandClient.Handler { private lateinit var adapter: ItemAdapter private lateinit var textWatcher: TextWatcher + @OptIn(DelicateCoroutinesApi::class) @SuppressLint("NotifyDataSetChanged") fun bind(group: OutboundGroup) { this.group = group @@ -185,6 +187,7 @@ class GroupsFragment : Fragment(), CommandClient.Handler { updateExpand() } + @OptIn(DelicateCoroutinesApi::class) private fun updateExpand(isExpand: Boolean? = null) { val newExpandStatus = isExpand ?: group.isExpand if (isExpand != null) { @@ -280,6 +283,7 @@ class GroupsFragment : Fragment(), CommandClient.Handler { private class ItemGroupView(val binding: ViewDashboardGroupItemBinding) : RecyclerView.ViewHolder(binding.root) { + @OptIn(DelicateCoroutinesApi::class) fun bind(groupView: GroupView, group: OutboundGroup, item: OutboundGroupItem) { if (group.selectable) { binding.itemCard.setOnClickListener { diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/dashboard/OverviewFragment.kt b/app/src/main/java/io/nekohasekai/sfa/ui/dashboard/OverviewFragment.kt index 5c81bd5..f221fae 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ui/dashboard/OverviewFragment.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ui/dashboard/OverviewFragment.kt @@ -28,6 +28,7 @@ import io.nekohasekai.sfa.ktx.getAttrColor import io.nekohasekai.sfa.ui.MainActivity import io.nekohasekai.sfa.utils.CommandClient import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.delay @@ -224,6 +225,7 @@ class OverviewFragment : Fragment() { private inner class ClashModeItemView(val binding: ViewClashModeButtonBinding) : RecyclerView.ViewHolder(binding.root) { + @OptIn(DelicateCoroutinesApi::class) fun bind(item: String, selected: String) { binding.clashModeButtonText.text = item if (item != selected) { diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/debug/VPNScanActivity.kt b/app/src/main/java/io/nekohasekai/sfa/ui/debug/VPNScanActivity.kt index d0cb836..c1aab2e 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ui/debug/VPNScanActivity.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ui/debug/VPNScanActivity.kt @@ -114,7 +114,6 @@ class VPNScanActivity : AbstractActivity() { private suspend fun scanVPN() { val adapter = adapter ?: return - val binding = binding ?: return val flag = PackageManager.GET_SERVICES or if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { PackageManager.MATCH_UNINSTALLED_PACKAGES diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/main/ConfigurationFragment.kt b/app/src/main/java/io/nekohasekai/sfa/ui/main/ConfigurationFragment.kt index 13b09d4..53a903d 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ui/main/ConfigurationFragment.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ui/main/ConfigurationFragment.kt @@ -9,7 +9,6 @@ import android.view.ViewGroup import androidx.appcompat.widget.PopupMenu import androidx.core.view.isVisible import androidx.fragment.app.Fragment -import androidx.fragment.app.FragmentActivity import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.LinearLayoutManager @@ -29,10 +28,12 @@ import io.nekohasekai.sfa.ui.MainActivity import io.nekohasekai.sfa.ui.profile.EditProfileActivity import io.nekohasekai.sfa.ui.profile.NewProfileActivity import io.nekohasekai.sfa.ui.profile.QRScanActivity +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import java.text.DateFormat import java.util.Collections class ConfigurationFragment : Fragment() { @@ -126,7 +127,7 @@ class ConfigurationFragment : Fragment() { internal var items: MutableList = mutableListOf() internal val scope = lifecycleScope - internal val fragmentActivity = requireActivity() as FragmentActivity + internal val fragmentActivity = requireActivity() @SuppressLint("NotifyDataSetChanged") internal fun reload() { @@ -160,6 +161,7 @@ class ConfigurationFragment : Fragment() { return true } + @OptIn(DelicateCoroutinesApi::class) internal fun updateUserOrder() { items.forEachIndexed { index, profile -> profile.userOrder = index.toLong() @@ -199,7 +201,7 @@ class ConfigurationFragment : Fragment() { binding.profileLastUpdated.isVisible = true binding.profileLastUpdated.text = binding.root.context.getString( R.string.profile_item_last_updated, - profile.typed.lastUpdated.toLocaleString() + DateFormat.getDateTimeInstance().format(profile.typed.lastUpdated) ) } else { binding.profileLastUpdated.isVisible = false diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/main/DashboardFragment.kt b/app/src/main/java/io/nekohasekai/sfa/ui/main/DashboardFragment.kt index 8022009..221f8eb 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ui/main/DashboardFragment.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ui/main/DashboardFragment.kt @@ -100,14 +100,14 @@ class DashboardFragment : Fragment(R.layout.fragment_dashboard) { private fun enablePager() { val activity = activity ?: return val binding = binding ?: return - activity.binding?.dashboardTabLayout?.isVisible = true + activity.binding.dashboardTabLayout.isVisible = true binding.dashboardPager.isUserInputEnabled = true } private fun disablePager() { val activity = activity ?: return val binding = binding ?: return - activity.binding?.dashboardTabLayout?.isVisible = false + activity.binding.dashboardTabLayout.isVisible = false binding.dashboardPager.isUserInputEnabled = false binding.dashboardPager.setCurrentItem(0, false) } @@ -119,11 +119,11 @@ class DashboardFragment : Fragment(R.layout.fragment_dashboard) { class Adapter(parent: Fragment) : FragmentStateAdapter(parent) { override fun getItemCount(): Int { - return Page.values().size + return Page.entries.size } override fun createFragment(position: Int): Fragment { - return Page.values()[position].fragmentClass.newInstance() + return Page.entries[position].fragmentClass.getConstructor().newInstance() } } diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileActivity.kt b/app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileActivity.kt index 53de9cb..9935a1d 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileActivity.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileActivity.kt @@ -110,7 +110,6 @@ class EditProfileActivity : AbstractActivity() { } private fun updateAutoUpdate(newValue: String) { - val binding = binding ?: return val boolValue = EnabledType.valueOf(newValue).boolValue if (profile.typed.autoUpdate == boolValue) { return @@ -126,7 +125,6 @@ class EditProfileActivity : AbstractActivity() { } private fun updateAutoUpdateInterval(newValue: String) { - val binding = binding ?: return if (newValue.isBlank()) { binding.autoUpdateInterval.error = getString(R.string.profile_input_required) return @@ -148,7 +146,6 @@ class EditProfileActivity : AbstractActivity() { } private fun updateProfile() { - val binding = binding ?: return binding.progressView.isVisible = true lifecycleScope.launch(Dispatchers.IO) { delay(200L) @@ -165,8 +162,8 @@ class EditProfileActivity : AbstractActivity() { } } + @Suppress("UNUSED_PARAMETER") private fun updateProfile(view: View) { - val binding = binding ?: return binding.progressView.isVisible = true lifecycleScope.launch(Dispatchers.IO) { try { diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileContentActivity.kt b/app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileContentActivity.kt index d87758e..7beacdf 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileContentActivity.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileContentActivity.kt @@ -52,7 +52,6 @@ class EditProfileContentActivity : AbstractActivity { if (binding.editor.canUndo()) binding.editor.undo() @@ -104,7 +103,6 @@ class EditProfileContentActivity : AbstractActivity() { private val importFile = registerForActivityResult(ActivityResultContracts.GetContent()) { fileURI -> - val binding = binding ?: return@registerForActivityResult if (fileURI != null) { binding.sourceURL.editText?.setText(fileURI.toString()) } @@ -95,8 +94,7 @@ class NewProfileActivity : AbstractActivity() { binding.autoUpdateInterval.addTextChangedListener(this::updateAutoUpdateInterval) } - private fun createProfile(view: View) { - val binding = binding ?: return + private fun createProfile(@Suppress("UNUSED_PARAMETER") view: View) { if (binding.name.showErrorIfEmpty()) { return } @@ -131,7 +129,6 @@ class NewProfileActivity : AbstractActivity() { } private suspend fun createProfile0() { - val binding = binding ?: return val typedProfile = TypedProfile() val profile = Profile(name = binding.name.text, typed = typedProfile) profile.userOrder = ProfileManager.nextOrder() @@ -190,7 +187,6 @@ class NewProfileActivity : AbstractActivity() { } private fun updateAutoUpdateInterval(newValue: String) { - val binding = binding ?: return if (newValue.isBlank()) { binding.autoUpdateInterval.error = getString(R.string.profile_input_required) return diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/profileoverride/PerAppProxyActivity.kt b/app/src/main/java/io/nekohasekai/sfa/ui/profileoverride/PerAppProxyActivity.kt index b907e57..ab70515 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ui/profileoverride/PerAppProxyActivity.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ui/profileoverride/PerAppProxyActivity.kt @@ -112,7 +112,8 @@ class PerAppProxyActivity : AbstractActivity() { val packageManagerFlags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { PackageManager.GET_PERMISSIONS or PackageManager.MATCH_UNINSTALLED_PACKAGES } else { - @Suppress("DEPRECATION") PackageManager.GET_PERMISSIONS or PackageManager.GET_UNINSTALLED_PACKAGES + @Suppress("DEPRECATION") + PackageManager.GET_PERMISSIONS or PackageManager.GET_UNINSTALLED_PACKAGES } val installedPackages = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { packageManager.getInstalledPackages( @@ -669,7 +670,8 @@ class PerAppProxyActivity : AbstractActivity() { val packageManagerFlags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { PackageManager.MATCH_UNINSTALLED_PACKAGES or PackageManager.GET_ACTIVITIES or PackageManager.GET_SERVICES or PackageManager.GET_RECEIVERS or PackageManager.GET_PROVIDERS } else { - @Suppress("DEPRECATION") PackageManager.GET_UNINSTALLED_PACKAGES or PackageManager.GET_ACTIVITIES or PackageManager.GET_SERVICES or PackageManager.GET_RECEIVERS or PackageManager.GET_PROVIDERS + @Suppress("DEPRECATION") + PackageManager.GET_UNINSTALLED_PACKAGES or PackageManager.GET_ACTIVITIES or PackageManager.GET_SERVICES or PackageManager.GET_RECEIVERS or PackageManager.GET_PROVIDERS } if (packageName.matches(chinaAppRegex)) { Log.d("PerAppProxyActivity", "Match package name: $packageName")