mirror of
https://github.com/etesync/android
synced 2024-12-24 07:28:09 +00:00
Fix a lot of kotlin warnings
This commit is contained in:
parent
15309911a5
commit
e005064be6
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -105,8 +105,8 @@ class CollectionMembersListFragment : ListFragment(), AdapterView.OnItemClickLis
|
||||
|
||||
internal inner class MembersListAdapter(context: Context) : ArrayAdapter<JournalManager.Member>(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)
|
||||
|
||||
|
@ -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<View>(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<View>(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<View>(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)
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class DeleteCollectionFragment : DialogFragment(), LoaderManager.LoaderCallbacks
|
||||
|
||||
|
||||
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Exception> {
|
||||
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()
|
||||
}
|
||||
|
||||
|
@ -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<View>(R.id.color)
|
||||
colorSquare.setBackgroundColor(info.color ?: LocalCalendar.defaultColor)
|
||||
}
|
||||
|
||||
val edit = findViewById<View>(R.id.display_name) as EditText
|
||||
edit.setText(info!!.displayName)
|
||||
edit.setText(info.displayName)
|
||||
|
||||
val desc = findViewById<View>(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)
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -94,15 +94,13 @@ class ListEntriesFragment : ListFragment(), AdapterView.OnItemClickListener {
|
||||
|
||||
internal inner class EntriesListAdapter(context: Context) : ArrayAdapter<EntryEntity>(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<View>(R.id.title) as TextView
|
||||
|
||||
// FIXME: hacky way to make it show sensible info
|
||||
val info = journalEntity!!.info
|
||||
setJournalEntryView(v, info, entryEntity!!.content)
|
||||
|
Loading…
Reference in New Issue
Block a user