diff --git a/app/src/main/java/com/etesync/syncadapter/ui/AccountSettingsActivity.kt b/app/src/main/java/com/etesync/syncadapter/ui/AccountSettingsActivity.kt index d3604ccb..b7d1b001 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/AccountSettingsActivity.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/AccountSettingsActivity.kt @@ -134,7 +134,7 @@ class AccountSettingsActivity : BaseActivity() { val prefWifiOnly = findPreference("sync_wifi_only") as SwitchPreferenceCompat prefWifiOnly.isChecked = settings.syncWifiOnly - prefWifiOnly.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { preference, wifiOnly -> + prefWifiOnly.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, wifiOnly -> settings.setSyncWiFiOnly(wifiOnly as Boolean) loaderManager.restartLoader(0, arguments, this@AccountSettingsFragment) false diff --git a/app/src/main/java/com/etesync/syncadapter/ui/AppSettingsActivity.kt b/app/src/main/java/com/etesync/syncadapter/ui/AppSettingsActivity.kt index 5e6d1cdc..c58830b4 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/AppSettingsActivity.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/AppSettingsActivity.kt @@ -67,7 +67,7 @@ class AppSettingsActivity : BaseActivity() { prefOverrideProxy = findPreference("override_proxy") as SwitchPreferenceCompat prefOverrideProxy.isChecked = settings.getBoolean(App.OVERRIDE_PROXY, false) - prefOverrideProxy.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { preference, newValue -> + prefOverrideProxy.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue -> settings.putBoolean(App.OVERRIDE_PROXY, newValue as Boolean) true } diff --git a/app/src/main/java/com/etesync/syncadapter/ui/CollectionMembersListFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/CollectionMembersListFragment.kt index f0b647a7..b6bb702a 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/CollectionMembersListFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/CollectionMembersListFragment.kt @@ -105,8 +105,8 @@ class CollectionMembersListFragment : ListFragment(), AdapterView.OnItemClickLis internal inner class MembersListAdapter(context: Context) : ArrayAdapter(context, R.layout.collection_members_list_item) { - override fun getView(position: Int, v: View?, parent: ViewGroup): View { - var v = v + override fun getView(position: Int, _v: View?, parent: ViewGroup): View { + var v = _v if (v == null) v = LayoutInflater.from(context).inflate(R.layout.collection_members_list_item, parent, false) diff --git a/app/src/main/java/com/etesync/syncadapter/ui/CreateCollectionActivity.kt b/app/src/main/java/com/etesync/syncadapter/ui/CreateCollectionActivity.kt index 9bbc7950..b622d37b 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/CreateCollectionActivity.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/CreateCollectionActivity.kt @@ -35,7 +35,7 @@ open class CreateCollectionActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - account = intent.extras!!.getParcelable(EXTRA_ACCOUNT) + account = intent.extras!!.getParcelable(EXTRA_ACCOUNT)!! info = intent.extras!!.getSerializable(EXTRA_COLLECTION_INFO) as CollectionInfo supportActionBar!!.setDisplayHomeAsUpEnabled(true) @@ -101,27 +101,25 @@ open class CreateCollectionActivity : BaseActivity() { fun onCreateCollection(item: MenuItem) { var ok = true - if (info == null) { - info = CollectionInfo() - } + info = CollectionInfo() var edit = findViewById(R.id.display_name) as EditText - info!!.displayName = edit.text.toString() - if (TextUtils.isEmpty(info!!.displayName)) { + info.displayName = edit.text.toString() + if (TextUtils.isEmpty(info.displayName)) { edit.error = getString(R.string.create_collection_display_name_required) ok = false } edit = findViewById(R.id.description) as EditText - info!!.description = StringUtils.trimToNull(edit.text.toString()) + info.description = StringUtils.trimToNull(edit.text.toString()) if (ok) { - if (info!!.type == CollectionInfo.Type.CALENDAR) { + if (info.type == CollectionInfo.Type.CALENDAR) { val view = findViewById(R.id.color) - info!!.color = (view.background as ColorDrawable).color + info.color = (view.background as ColorDrawable).color } - info!!.selected = true + info.selected = true CreateCollectionFragment.newInstance(account, info).show(supportFragmentManager, null) } diff --git a/app/src/main/java/com/etesync/syncadapter/ui/DeleteCollectionFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/DeleteCollectionFragment.kt index e6d5e237..2c52118f 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/DeleteCollectionFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/DeleteCollectionFragment.kt @@ -50,7 +50,7 @@ class DeleteCollectionFragment : DialogFragment(), LoaderManager.LoaderCallbacks override fun onCreateLoader(id: Int, args: Bundle?): Loader { - account = args!!.getParcelable(ARG_ACCOUNT) + account = args!!.getParcelable(ARG_ACCOUNT)!! collectionInfo = args.getSerializable(ARG_COLLECTION_INFO) as CollectionInfo return DeleteCollectionLoader(context!!, account, collectionInfo) } @@ -120,12 +120,12 @@ class DeleteCollectionFragment : DialogFragment(), LoaderManager.LoaderCallbacks return AlertDialog.Builder(context!!) .setTitle(R.string.delete_collection_confirm_title) .setMessage(getString(R.string.delete_collection_confirm_warning, name)) - .setPositiveButton(android.R.string.yes) { dialog, which -> + .setPositiveButton(android.R.string.yes) { dialog, _ -> val frag = DeleteCollectionFragment() frag.arguments = arguments frag.show(fragmentManager!!, null) } - .setNegativeButton(android.R.string.no) { dialog, which -> dismiss() } + .setNegativeButton(android.R.string.no) { _, _ -> dismiss() } .create() } diff --git a/app/src/main/java/com/etesync/syncadapter/ui/EditCollectionActivity.kt b/app/src/main/java/com/etesync/syncadapter/ui/EditCollectionActivity.kt index ec9c0534..980fc9b3 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/EditCollectionActivity.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/EditCollectionActivity.kt @@ -30,16 +30,16 @@ class EditCollectionActivity : CreateCollectionActivity() { setTitle(R.string.edit_collection) - if (info!!.type == CollectionInfo.Type.CALENDAR) { + if (info.type == CollectionInfo.Type.CALENDAR) { val colorSquare = findViewById(R.id.color) colorSquare.setBackgroundColor(info.color ?: LocalCalendar.defaultColor) } val edit = findViewById(R.id.display_name) as EditText - edit.setText(info!!.displayName) + edit.setText(info.displayName) val desc = findViewById(R.id.description) as EditText - desc.setText(info!!.description) + desc.setText(info.description) } override fun onCreateOptionsMenu(menu: Menu): Boolean { @@ -57,7 +57,7 @@ class EditCollectionActivity : CreateCollectionActivity() { fun onDeleteCollection(item: MenuItem) { val data = (application as App).data - val journalCount = data.count(JournalEntity::class.java).where(JournalEntity.SERVICE_MODEL.eq(info!!.getServiceEntity(data))).get().value() + val journalCount = data.count(JournalEntity::class.java).where(JournalEntity.SERVICE_MODEL.eq(info.getServiceEntity(data))).get().value() if (journalCount < 2) { AlertDialog.Builder(this) diff --git a/app/src/main/java/com/etesync/syncadapter/ui/ExceptionInfoFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/ExceptionInfoFragment.kt index 084435ee..462c50c4 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/ExceptionInfoFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/ExceptionInfoFragment.kt @@ -35,15 +35,15 @@ class ExceptionInfoFragment : DialogFragment() { val dialog = AlertDialog.Builder(context!!) .setIcon(R.drawable.ic_error_dark) .setTitle(title) - .setMessage(exception.javaClass.canonicalName + "\n" + exception.localizedMessage) - .setNegativeButton(R.string.exception_show_details) { dialog, which -> + .setMessage("${exception.javaClass.canonicalName}\n" + exception.localizedMessage) + .setNegativeButton(R.string.exception_show_details) { _, _ -> val intent = Intent(context, DebugInfoActivity::class.java) intent.putExtra(DebugInfoActivity.KEY_THROWABLE, exception) if (account != null) intent.putExtra(Constants.KEY_ACCOUNT, account) startActivity(intent) } - .setPositiveButton(android.R.string.ok) { dialog, which -> } + .setPositiveButton(android.R.string.ok) { _, _ -> } .create() isCancelable = false return dialog diff --git a/app/src/main/java/com/etesync/syncadapter/ui/JournalItemActivity.kt b/app/src/main/java/com/etesync/syncadapter/ui/JournalItemActivity.kt index e0a7b403..dce81780 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/JournalItemActivity.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/JournalItemActivity.kt @@ -465,7 +465,7 @@ class JournalItemActivity : BaseActivity(), Refreshable { flagsTime = flagsTime or DateUtils.FORMAT_24HOUR } - var datetimeString: String? = null + val datetimeString: String if (allDay) { // For multi-day allday events or single-day all-day events that are not // today or tomorrow, use framework formatter. diff --git a/app/src/main/java/com/etesync/syncadapter/ui/RemoveMemberFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/RemoveMemberFragment.kt index 45d7c3ec..66db9456 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/RemoveMemberFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/RemoveMemberFragment.kt @@ -71,7 +71,7 @@ class RemoveMemberFragment : DialogFragment() { .setIcon(R.drawable.ic_error_dark) .setTitle(R.string.collection_members_remove_error) .setMessage(result.throwable.message) - .setPositiveButton(android.R.string.yes) { dialog, which -> }.show() + .setPositiveButton(android.R.string.yes) { _, _ -> }.show() } dismiss() } diff --git a/app/src/main/java/com/etesync/syncadapter/ui/StartupDialogFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/StartupDialogFragment.kt index 46975d45..d03dbebb 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/StartupDialogFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/StartupDialogFragment.kt @@ -39,7 +39,7 @@ class StartupDialogFragment : DialogFragment() { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { isCancelable = false - val mode = Mode.valueOf(arguments!!.getString(ARGS_MODE)) + val mode = Mode.valueOf(arguments!!.getString(ARGS_MODE)!!) when (mode) { StartupDialogFragment.Mode.BATTERY_OPTIMIZATIONS -> return AlertDialog.Builder(activity!!) .setTitle(R.string.startup_battery_optimization) @@ -87,7 +87,7 @@ class StartupDialogFragment : DialogFragment() { // battery optimization whitelisting if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !HintManager.getHintSeen(context, HINT_BATTERY_OPTIMIZATIONS)) { - val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager + val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager? if (powerManager != null && !powerManager.isIgnoringBatteryOptimizations(BuildConfig.APPLICATION_ID)) dialogs.add(StartupDialogFragment.instantiate(Mode.BATTERY_OPTIMIZATIONS)) } diff --git a/app/src/main/java/com/etesync/syncadapter/ui/ViewCollectionActivity.kt b/app/src/main/java/com/etesync/syncadapter/ui/ViewCollectionActivity.kt index c2f4115f..bdd1f408 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/ViewCollectionActivity.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/ViewCollectionActivity.kt @@ -134,7 +134,7 @@ class ViewCollectionActivity : BaseActivity(), Refreshable { .setIcon(R.drawable.ic_info_dark) .setTitle(R.string.not_allowed_title) .setMessage(getString(R.string.edit_owner_only, journalEntity!!.owner)) - .setPositiveButton(android.R.string.yes) { dialog, which -> }.create() + .setPositiveButton(android.R.string.yes) { _, _ -> }.create() dialog.show() } } @@ -157,7 +157,7 @@ class ViewCollectionActivity : BaseActivity(), Refreshable { .setIcon(R.drawable.ic_info_dark) .setTitle(R.string.not_allowed_title) .setMessage(R.string.members_old_journals_not_allowed) - .setPositiveButton(android.R.string.yes) { dialog, which -> }.create() + .setPositiveButton(android.R.string.yes) { _, _ -> }.create() dialog.show() } else if (isOwner) { startActivity(CollectionMembersActivity.newIntent(this, account, info)) @@ -166,7 +166,7 @@ class ViewCollectionActivity : BaseActivity(), Refreshable { .setIcon(R.drawable.ic_info_dark) .setTitle(R.string.not_allowed_title) .setMessage(getString(R.string.members_owner_only, journalEntity!!.owner)) - .setPositiveButton(android.R.string.yes) { dialog, which -> }.create() + .setPositiveButton(android.R.string.yes) { _, _ -> }.create() dialog.show() } } diff --git a/app/src/main/java/com/etesync/syncadapter/ui/WebViewActivity.kt b/app/src/main/java/com/etesync/syncadapter/ui/WebViewActivity.kt index 091d858c..3f5c1770 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/WebViewActivity.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/WebViewActivity.kt @@ -116,8 +116,8 @@ class WebViewActivity : BaseActivity() { mWebView!!.invalidate() } - private fun shouldOverrideUrl(uri: Uri): Boolean { - var uri = uri + private fun shouldOverrideUrl(_uri: Uri): Boolean { + var uri = _uri if (isAllowedUrl(uri)) { if (uri.getQueryParameter(QUERY_KEY_EMBEDDED) != null) { return false diff --git a/app/src/main/java/com/etesync/syncadapter/ui/importlocal/CalendarAccount.kt b/app/src/main/java/com/etesync/syncadapter/ui/importlocal/CalendarAccount.kt index 1c351c9a..0367d2f1 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/importlocal/CalendarAccount.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/importlocal/CalendarAccount.kt @@ -60,7 +60,7 @@ class CalendarAccount protected constructor(val account: Account) { var calendarAccount: CalendarAccount? = null - val contentProviderClient = resolver.acquireContentProviderClient(CalendarContract.CONTENT_URI) + val contentProviderClient = resolver.acquireContentProviderClient(CalendarContract.CONTENT_URI)!! while (cur.moveToNext()) { if (getLong(cur, Calendars.DELETED) != 0L) continue @@ -84,7 +84,7 @@ class CalendarAccount protected constructor(val account: Account) { } } - contentProviderClient!!.release() + contentProviderClient.release() cur.close() return calendarAccounts } diff --git a/app/src/main/java/com/etesync/syncadapter/ui/importlocal/ImportFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/importlocal/ImportFragment.kt index af57d3de..b8283b51 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/importlocal/ImportFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/importlocal/ImportFragment.kt @@ -47,7 +47,7 @@ class ImportFragment : DialogFragment() { isCancelable = false retainInstance = true - account = arguments!!.getParcelable(KEY_ACCOUNT) + account = arguments!!.getParcelable(KEY_ACCOUNT)!! info = arguments!!.getSerializable(KEY_COLLECTION_INFO) as CollectionInfo } @@ -118,9 +118,9 @@ class ImportFragment : DialogFragment() { intent.addCategory(Intent.CATEGORY_OPENABLE) intent.action = Intent.ACTION_GET_CONTENT - if (info!!.type == CollectionInfo.Type.CALENDAR) { + if (info.type == CollectionInfo.Type.CALENDAR) { intent.type = "text/calendar" - } else if (info!!.type == CollectionInfo.Type.ADDRESS_BOOK) { + } else if (info.type == CollectionInfo.Type.ADDRESS_BOOK) { intent.type = "text/x-vcard" } @@ -205,7 +205,7 @@ class ImportFragment : DialogFragment() { try { val importReader = FileReader(importFile!!) - if (info!!.type == CollectionInfo.Type.CALENDAR) { + if (info.type == CollectionInfo.Type.CALENDAR) { val events = Event.fromReader(importReader, null) importReader.close() @@ -219,10 +219,10 @@ class ImportFragment : DialogFragment() { finishParsingFile(events.size) - val provider = context!!.contentResolver.acquireContentProviderClient(CalendarContract.CONTENT_URI) + val provider = context!!.contentResolver.acquireContentProviderClient(CalendarContract.CONTENT_URI)!! val localCalendar: LocalCalendar? try { - localCalendar = LocalCalendar.findByName(account, provider, LocalCalendar.Factory, info!!.uid!!) + localCalendar = LocalCalendar.findByName(account, provider, LocalCalendar.Factory, info.uid!!) if (localCalendar == null) { throw FileNotFoundException("Failed to load local resource.") } @@ -247,7 +247,7 @@ class ImportFragment : DialogFragment() { entryProcessed() } - } else if (info!!.type == CollectionInfo.Type.ADDRESS_BOOK) { + } else if (info.type == CollectionInfo.Type.ADDRESS_BOOK) { // FIXME: Handle groups and download icon? val downloader = ContactsSyncManager.ResourceDownloader(context!!) val contacts = Contact.fromReader(importReader, downloader) @@ -263,7 +263,7 @@ class ImportFragment : DialogFragment() { finishParsingFile(contacts.size) val provider = context!!.contentResolver.acquireContentProviderClient(ContactsContract.RawContacts.CONTENT_URI) - val localAddressBook = LocalAddressBook.findByUid(context!!, provider!!, account, info!!.uid!!) + val localAddressBook = LocalAddressBook.findByUid(context!!, provider!!, account, info.uid!!) for (contact in contacts) { try { diff --git a/app/src/main/java/com/etesync/syncadapter/ui/importlocal/LocalCalendarImportFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/importlocal/LocalCalendarImportFragment.kt index db3b9750..2a2a9488 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/importlocal/LocalCalendarImportFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/importlocal/LocalCalendarImportFragment.kt @@ -31,7 +31,7 @@ class LocalCalendarImportFragment : ListFragment() { super.onCreate(savedInstanceState) retainInstance = true - account = arguments!!.getParcelable(KEY_ACCOUNT) + account = arguments!!.getParcelable(KEY_ACCOUNT)!! info = arguments!!.getSerializable(KEY_COLLECTION_INFO) as CollectionInfo } diff --git a/app/src/main/java/com/etesync/syncadapter/ui/importlocal/LocalContactImportFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/importlocal/LocalContactImportFragment.kt index 55d3ad51..8e2822a3 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/importlocal/LocalContactImportFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/importlocal/LocalContactImportFragment.kt @@ -132,7 +132,7 @@ class LocalContactImportFragment : Fragment() { try { val addressBook = LocalAddressBook.findByUid(context!!, context!!.contentResolver.acquireContentProviderClient(ContactsContract.RawContacts.CONTENT_URI)!!, - account, info!!.uid!!) + account, info.uid!!) val localContacts = localAddressBook.findAll() val total = localContacts.size progressDialog!!.max = total diff --git a/app/src/main/java/com/etesync/syncadapter/ui/journalviewer/ListEntriesFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/journalviewer/ListEntriesFragment.kt index 32c7c920..590c0d39 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/journalviewer/ListEntriesFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/journalviewer/ListEntriesFragment.kt @@ -94,15 +94,13 @@ class ListEntriesFragment : ListFragment(), AdapterView.OnItemClickListener { internal inner class EntriesListAdapter(context: Context) : ArrayAdapter(context, R.layout.journal_viewer_list_item) { - override fun getView(position: Int, v: View?, parent: ViewGroup): View { - var v = v + override fun getView(position: Int, _v: View?, parent: ViewGroup): View { + var v = _v if (v == null) - v = LayoutInflater.from(context).inflate(R.layout.journal_viewer_list_item, parent, false) + v = LayoutInflater.from(context).inflate(R.layout.journal_viewer_list_item, parent, false)!! val entryEntity = getItem(position) - val tv = v!!.findViewById(R.id.title) as TextView - // FIXME: hacky way to make it show sensible info val info = journalEntity!!.info setJournalEntryView(v, info, entryEntity!!.content)