mirror of
https://github.com/bitfireAT/davx5-ose
synced 2024-07-21 02:23:24 +00:00
Lint cleanup
This commit is contained in:
parent
267e73723c
commit
dbd0dd0a9b
|
@ -24,6 +24,6 @@ abstract class AndroidSingleton<T> {
|
|||
return newSingleton
|
||||
}
|
||||
|
||||
abstract protected fun createInstance(context: Context): T
|
||||
protected abstract fun createInstance(context: Context): T
|
||||
|
||||
}
|
|
@ -24,8 +24,8 @@ import at.bitfire.dav4jvm.UrlUtils
|
|||
import at.bitfire.dav4jvm.exception.HttpException
|
||||
import at.bitfire.dav4jvm.property.*
|
||||
import at.bitfire.davdroid.log.Logger
|
||||
import at.bitfire.davdroid.model.*
|
||||
import at.bitfire.davdroid.model.Collection
|
||||
import at.bitfire.davdroid.model.*
|
||||
import at.bitfire.davdroid.settings.AccountSettings
|
||||
import at.bitfire.davdroid.ui.DebugInfoActivity
|
||||
import at.bitfire.davdroid.ui.NotificationUtils
|
||||
|
@ -299,7 +299,7 @@ class DavService: IntentService("DavService") {
|
|||
val itHomeSets = homeSets.iterator()
|
||||
while (itHomeSets.hasNext()) {
|
||||
val (homeSetUrl, homeSet) = itHomeSets.next()
|
||||
Logger.log.fine("Listing home set ${homeSetUrl}")
|
||||
Logger.log.fine("Listing home set $homeSetUrl")
|
||||
|
||||
try {
|
||||
DavResource(httpClient, homeSetUrl).propfind(1, *DAV_COLLECTION_PROPERTIES) { response, relation ->
|
||||
|
|
|
@ -45,7 +45,7 @@ object DavUtils {
|
|||
|
||||
fun lastSegmentOfUrl(url: HttpUrl): String {
|
||||
// the list returned by HttpUrl.pathSegments() is unmodifiable, so we have to create a copy
|
||||
val segments = LinkedList<String>(url.pathSegments)
|
||||
val segments = LinkedList(url.pathSegments)
|
||||
segments.reverse()
|
||||
|
||||
return segments.firstOrNull { it.isNotEmpty() } ?: "/"
|
||||
|
|
|
@ -27,7 +27,7 @@ class ForegroundService : Service() {
|
|||
|
||||
fun startIfEnabled(context: Context) {
|
||||
if (isEnabled(context)) {
|
||||
val serviceIntent = Intent(ForegroundService.ACTION_FOREGROUND, null, context, ForegroundService::class.java)
|
||||
val serviceIntent = Intent(ACTION_FOREGROUND, null, context, ForegroundService::class.java)
|
||||
if (Build.VERSION.SDK_INT >= 26)
|
||||
context.startForegroundService(serviceIntent)
|
||||
else
|
||||
|
|
|
@ -171,11 +171,11 @@ class HttpClient private constructor(
|
|||
}
|
||||
|
||||
fun build(): HttpClient {
|
||||
val trustManager = certManager ?: {
|
||||
val trustManager = certManager ?: run {
|
||||
val factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm())
|
||||
factory.init(null as KeyStore?)
|
||||
factory.trustManagers.first() as X509TrustManager
|
||||
}()
|
||||
}
|
||||
|
||||
val hostnameVerifier = certManager?.hostnameVerifier(OkHostnameVerifier)
|
||||
?: OkHostnameVerifier
|
||||
|
|
|
@ -63,7 +63,7 @@ object PermissionUtils {
|
|||
/**
|
||||
* Whether this app declares the given permission (regardless of whether it has been granted or not).
|
||||
*
|
||||
* @param permisssion permission to check
|
||||
* @param permission permission to check
|
||||
*
|
||||
* @return *true* if this app declares [permission] in the manifest; *false* otherwise
|
||||
*/
|
||||
|
|
|
@ -203,7 +203,7 @@ abstract class AppDatabase: RoomDatabase() {
|
|||
val cols = cursor.columnCount
|
||||
// print rows
|
||||
while (cursor.moveToNext()) {
|
||||
val values = Array<String?>(cols) { idx -> cursor.getStringOrNull(idx) }
|
||||
val values = Array(cols) { idx -> cursor.getStringOrNull(idx) }
|
||||
table.addLine(*values)
|
||||
}
|
||||
writer.append(table.toString())
|
||||
|
|
|
@ -3,7 +3,6 @@ package at.bitfire.davdroid.model
|
|||
import androidx.room.Delete
|
||||
import androidx.room.Insert
|
||||
import androidx.room.Update
|
||||
import java.util.*
|
||||
|
||||
interface SyncableDao<T: IdEntity> {
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import android.os.RemoteException
|
|||
import android.provider.ContactsContract
|
||||
import android.provider.ContactsContract.CommonDataKinds.GroupMembership
|
||||
import android.provider.ContactsContract.RawContacts.Data
|
||||
import androidx.annotation.RequiresApi
|
||||
import at.bitfire.davdroid.BuildConfig
|
||||
import at.bitfire.davdroid.log.Logger
|
||||
import at.bitfire.davdroid.model.UnknownProperties
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
package at.bitfire.davdroid.resource
|
||||
|
||||
import android.content.ContentProviderOperation
|
||||
import android.content.ContentUris
|
||||
import android.content.ContentValues
|
||||
import android.net.Uri
|
||||
|
|
|
@ -153,8 +153,7 @@ class AccountSettings(
|
|||
}
|
||||
|
||||
// repair calendar sync
|
||||
settings.getSavedCalendarsSyncInterval()?.let { strInterval ->
|
||||
val shouldBe = strInterval.toLong()
|
||||
settings.getSavedCalendarsSyncInterval()?.let { shouldBe ->
|
||||
val current = settings.getSyncInterval(CalendarContract.AUTHORITY)
|
||||
if (current != shouldBe) {
|
||||
Logger.log.warning("${account.name}: ${CalendarContract.AUTHORITY} sync interval should be $shouldBe but is $current -> setting to $current")
|
||||
|
@ -164,8 +163,7 @@ class AccountSettings(
|
|||
|
||||
if (taskAuthority != null)
|
||||
// repair calendar sync
|
||||
settings.getSavedTasksSyncInterval()?.let { strInterval ->
|
||||
val shouldBe = strInterval.toLong()
|
||||
settings.getSavedTasksSyncInterval()?.let { shouldBe ->
|
||||
val current = settings.getSyncInterval(taskAuthority)
|
||||
if (current != shouldBe) {
|
||||
Logger.log.warning("${account.name}: $taskAuthority sync interval should be $shouldBe but is $current -> setting to $current")
|
||||
|
@ -249,7 +247,7 @@ class AccountSettings(
|
|||
Logger.log.fine("Disabling automatic sync of $account/$authority")
|
||||
ContentResolver.setSyncAutomatically(account, authority, false)
|
||||
|
||||
/* return */ ContentResolver.getSyncAutomatically(account, authority) == false
|
||||
/* return */ !ContentResolver.getSyncAutomatically(account, authority)
|
||||
}
|
||||
} else {
|
||||
{
|
||||
|
@ -263,7 +261,7 @@ class AccountSettings(
|
|||
}
|
||||
|
||||
// try up to 10 times with 100 ms pause
|
||||
var success: Boolean = false
|
||||
var success = false
|
||||
for (idxTry in 0 until 10) {
|
||||
success = setInterval()
|
||||
if (success)
|
||||
|
|
|
@ -124,7 +124,7 @@ class AboutActivity: AppCompatActivity() {
|
|||
private val binding get() = _binding!!
|
||||
val model by viewModels<TextFileModel>()
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
_binding = AboutBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
@ -268,9 +268,9 @@ class AboutActivity: AppCompatActivity() {
|
|||
|
||||
// sort translations by localized language name
|
||||
val collator = Collator.getInstance()
|
||||
result.sortWith({
|
||||
o1, o2 -> collator.compare(o1.language, o2.language)
|
||||
})
|
||||
result.sortWith { o1, o2 ->
|
||||
collator.compare(o1.language, o2.language)
|
||||
}
|
||||
|
||||
postValue(result)
|
||||
}
|
||||
|
|
|
@ -240,9 +240,9 @@ class AccountListFragment: Fragment() {
|
|||
|
||||
val sortedAccounts = accountManager
|
||||
.getAccountsByType(context.getString(R.string.account_type))
|
||||
.sortedArrayWith({ a, b ->
|
||||
.sortedArrayWith { a, b ->
|
||||
collator.compare(a.name, b.name)
|
||||
})
|
||||
}
|
||||
val accountsWithInfo = sortedAccounts.map { account ->
|
||||
AccountInfo(account, DavUtils.accountSyncStatus(context, syncAuthorities, account))
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ class AccountsActivity: AppCompatActivity(), NavigationView.OnNavigationItemSele
|
|||
class Model(app: Application): AndroidViewModel(app), SyncStatusObserver {
|
||||
|
||||
private var syncStatusObserver: Any? = null
|
||||
val showSyncDisabled = MutableLiveData<Boolean>(false)
|
||||
val showSyncDisabled = MutableLiveData(false)
|
||||
|
||||
init {
|
||||
syncStatusObserver = ContentResolver.addStatusChangeListener(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS, this)
|
||||
|
|
|
@ -184,7 +184,7 @@ class DebugInfoActivity: AppCompatActivity() {
|
|||
val remoteResource = MutableLiveData<String>()
|
||||
val debugInfo = MutableLiveData<File>()
|
||||
|
||||
val zipProgress = MutableLiveData<Boolean>(false)
|
||||
val zipProgress = MutableLiveData(false)
|
||||
val zipFile = MutableLiveData<File>()
|
||||
|
||||
// private storage, not readable by others
|
||||
|
@ -232,7 +232,7 @@ class DebugInfoActivity: AppCompatActivity() {
|
|||
remoteResource.postValue(remote)
|
||||
|
||||
generateDebugInfo(
|
||||
extras?.getParcelable<Account>(EXTRA_ACCOUNT),
|
||||
extras?.getParcelable(EXTRA_ACCOUNT),
|
||||
extras?.getString(EXTRA_AUTHORITY),
|
||||
throwable,
|
||||
local,
|
||||
|
@ -241,7 +241,7 @@ class DebugInfoActivity: AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
fun generateDebugInfo(syncAccount: Account?, syncAuthority: String?, cause: Throwable?, localResource: String?, remoteResource: String?) {
|
||||
private fun generateDebugInfo(syncAccount: Account?, syncAuthority: String?, cause: Throwable?, localResource: String?, remoteResource: String?) {
|
||||
val debugInfoFile = File(debugInfoDir, FILE_DEBUG_INFO)
|
||||
debugInfoFile.writer().buffered().use { writer ->
|
||||
writer.append(ByteOrderMark.UTF_BOM)
|
||||
|
@ -356,7 +356,7 @@ class DebugInfoActivity: AppCompatActivity() {
|
|||
}
|
||||
if (properties != null) {
|
||||
writer .append(" - DNS: ")
|
||||
.append(properties.dnsServers.map { it.hostAddress }.joinToString(", "))
|
||||
.append(properties.dnsServers.joinToString(", ") { it.hostAddress })
|
||||
if (Build.VERSION.SDK_INT >= 28 && properties.isPrivateDnsActive)
|
||||
writer.append(" (private mode)")
|
||||
writer.append('\n')
|
||||
|
|
|
@ -19,8 +19,7 @@ class HomeSetAdapter(
|
|||
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||
val data = getItem(position)!!
|
||||
|
||||
val v: View
|
||||
v = convertView ?: LayoutInflater.from(context).inflate(R.layout.text_list_item, parent, false)
|
||||
val v: View = convertView ?: LayoutInflater.from(context).inflate(R.layout.text_list_item, parent, false)
|
||||
v.findViewById<TextView>(android.R.id.text1).apply {
|
||||
text = data.displayName ?: DavUtils.lastSegmentOfUrl(data.url)
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class PermissionsFragment: Fragment() {
|
|||
val model by viewModels<Model>()
|
||||
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
val binding = ActivityPermissionsBinding.inflate(inflater, container, false)
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.model = model
|
||||
|
|
|
@ -249,7 +249,7 @@ class AccountActivity: AppCompatActivity() {
|
|||
}
|
||||
|
||||
private val db = AppDatabase.getInstance(application)
|
||||
val accountManager = AccountManager.get(application)
|
||||
val accountManager = AccountManager.get(application)!!
|
||||
val accountSettings by lazy { AccountSettings(getApplication(), account) }
|
||||
|
||||
val accountExists = MutableLiveData<Boolean>()
|
||||
|
|
|
@ -15,7 +15,7 @@ class AddressBooksFragment: CollectionsFragment() {
|
|||
inflater.inflate(R.menu.carddav_actions, menu)
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu) {
|
||||
menu.findItem(R.id.create_address_book).setVisible(model.hasWriteableCollections.value ?: false)
|
||||
menu.findItem(R.id.create_address_book).isVisible = model.hasWriteableCollections.value ?: false
|
||||
super.onPrepareOptionsMenu(menu)
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class CalendarsFragment: CollectionsFragment() {
|
|||
inflater.inflate(R.menu.caldav_actions, menu)
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu) {
|
||||
menu.findItem(R.id.create_calendar).setVisible(model.hasWriteableCollections.value ?: false)
|
||||
menu.findItem(R.id.create_calendar).isVisible = model.hasWriteableCollections.value ?: false
|
||||
super.onPrepareOptionsMenu(menu)
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class CollectionInfoFragment: DialogFragment() {
|
|||
|
||||
val model by viewModels<Model>()
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
arguments?.getLong(ARGS_COLLECTION_ID)?.let { id ->
|
||||
model.initialize(id)
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ class CreateAddressBookActivity: AppCompatActivity() {
|
|||
super.onCreate(savedInstanceState)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
|
||||
binding = DataBindingUtil.setContentView<ActivityCreateAddressBookBinding>(this, R.layout.activity_create_address_book)
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.activity_create_address_book)
|
||||
binding.lifecycleOwner = this
|
||||
binding.model = model
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class CreateCalendarActivity: AppCompatActivity(), ColorPickerDialogListener {
|
|||
super.onCreate(savedInstanceState)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
|
||||
binding = DataBindingUtil.setContentView<ActivityCreateCalendarBinding>(this, R.layout.activity_create_calendar)
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.activity_create_calendar)
|
||||
binding.lifecycleOwner = this
|
||||
binding.model = model
|
||||
|
||||
|
@ -185,8 +185,7 @@ class CreateCalendarActivity: AppCompatActivity(), ColorPickerDialogListener {
|
|||
val tzId = getItem(position)!!
|
||||
val tz = ZoneId.of(tzId)
|
||||
|
||||
val v: View
|
||||
v = convertView ?: LayoutInflater.from(context).inflate(R.layout.text_list_item, parent, false)
|
||||
val v: View = convertView ?: LayoutInflater.from(context).inflate(R.layout.text_list_item, parent, false)
|
||||
v.findViewById<TextView>(android.R.id.text1).text = tz.id
|
||||
v.findViewById<TextView>(android.R.id.text2).text = tz.getDisplayName(TextStyle.FULL, Locale.getDefault())
|
||||
|
||||
|
@ -215,7 +214,7 @@ class CreateCalendarActivity: AppCompatActivity(), ColorPickerDialogListener {
|
|||
var homeSet: HomeSet? = null
|
||||
|
||||
val timezones = TimeZoneAdapter(application)
|
||||
val timezone = MutableLiveData<String>(TimeZone.getDefault().id)
|
||||
val timezone = MutableLiveData(TimeZone.getDefault().id)
|
||||
val timezoneError = MutableLiveData<String>()
|
||||
|
||||
val typeError = MutableLiveData<String>()
|
||||
|
|
|
@ -363,12 +363,12 @@ class SettingsActivity: AppCompatActivity() {
|
|||
private fun checkWifiPermissions() {
|
||||
if (model.syncWifiOnlySSIDs.value != null && !PermissionUtils.canAccessWifiSsid(requireActivity()))
|
||||
Snackbar.make(requireView(), R.string.settings_sync_wifi_only_ssids_permissions_required, UiUtils.SNACKBAR_LENGTH_VERY_LONG)
|
||||
.setAction(R.string.settings_sync_wifi_only_ssids_permissions_action, {
|
||||
.setAction(R.string.settings_sync_wifi_only_ssids_permissions_action) {
|
||||
val intent = Intent(requireActivity(), WifiPermissionsActivity::class.java)
|
||||
intent.putExtra(WifiPermissionsActivity.EXTRA_ACCOUNT, account)
|
||||
startActivity(intent)
|
||||
})
|
||||
.show()
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ class BatteryOptimizationsFragment: Fragment() {
|
|||
binding.autostartMoreInfo.setOnClickListener {
|
||||
UiUtils.launchUri(requireActivity(), App.homepageUrl(requireActivity()).buildUpon()
|
||||
.appendPath("faq").appendPath("synchronization-is-not-run-as-expected")
|
||||
.appendQueryParameter("manufacturer", Build.MANUFACTURER.toLowerCase(Locale.ROOT)).build())
|
||||
.appendQueryParameter("manufacturer", Build.MANUFACTURER.lowercase(Locale.ROOT)).build())
|
||||
}
|
||||
|
||||
binding.infoLeaveUnchecked.text = getString(R.string.intro_leave_unchecked, getString(R.string.app_settings_reset_hints))
|
||||
|
@ -115,7 +115,7 @@ class BatteryOptimizationsFragment: Fragment() {
|
|||
* @see evilManufacturers
|
||||
*/
|
||||
val manufacturerWarning =
|
||||
(evilManufacturers.contains(Build.MANUFACTURER.toLowerCase(Locale.ROOT)) || BuildConfig.DEBUG)
|
||||
(evilManufacturers.contains(Build.MANUFACTURER.lowercase(Locale.ROOT)) || BuildConfig.DEBUG)
|
||||
|
||||
fun isWhitelisted(context: Context) =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.view.ViewGroup
|
|||
import androidx.fragment.app.Fragment
|
||||
import at.bitfire.davdroid.App
|
||||
import at.bitfire.davdroid.BuildConfig
|
||||
import at.bitfire.davdroid.R
|
||||
import at.bitfire.davdroid.databinding.IntroWelcomeBinding
|
||||
import at.bitfire.davdroid.settings.SettingsManager
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ class AccountDetailsFragment : Fragment() {
|
|||
|
||||
// CalDAV-specific
|
||||
config.calDAV?.let {
|
||||
val accountNameAdapter = ArrayAdapter<String>(requireActivity(), android.R.layout.simple_list_item_1, it.emails)
|
||||
val accountNameAdapter = ArrayAdapter(requireActivity(), android.R.layout.simple_list_item_1, it.emails)
|
||||
v.accountName.setAdapter(accountNameAdapter)
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ class AccountDetailsFragment : Fragment() {
|
|||
loginModel.credentials,
|
||||
config,
|
||||
GroupMethod.valueOf(groupMethodName)
|
||||
).observe(viewLifecycleOwner, Observer<Boolean> { success ->
|
||||
).observe(viewLifecycleOwner, Observer { success ->
|
||||
if (success) {
|
||||
// close Create account activity
|
||||
requireActivity().finish()
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
open-source license: see doc/undraw-license.pdf
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="931dp"
|
||||
android:height="758.59dp"
|
||||
android:viewportWidth="931"
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
-->
|
||||
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="none"
|
||||
android:adapter="@{model.homeSets}" />
|
||||
app:adapter="@{model.homeSets}" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="none"
|
||||
android:adapter="@{model.homeSets}"/>
|
||||
app:adapter="@{model.homeSets}"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
|
@ -106,7 +106,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:inputType="none"
|
||||
android:text="@={model.timezone}"
|
||||
android:adapter="@{model.timezones}"/>
|
||||
app:adapter="@{model.timezones}"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
|
|
Loading…
Reference in a new issue