Loading app/src/main/java/at/bitfire/davdroid/DavService.kt +4 −4 Original line number Diff line number Diff line Loading @@ -270,11 +270,11 @@ class DavService: android.app.Service() { // old URL exists in newCollections, update database if content has been changed matchingNewCollection.id = oldCollection.id matchingNewCollection.serviceId = oldCollection.serviceId if (matchingNewCollection == oldCollection) { if (matchingNewCollection != oldCollection) collectionDao.update(matchingNewCollection) // remove from "collections" (which will be added later) collections.remove(url) } } else // URL is not in newCollections, delete from database collectionDao.delete(oldCollection) Loading app/src/main/java/at/bitfire/davdroid/ui/CreateAddressBookActivity.kt +1 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ class CreateAddressBookActivity: AppCompatActivity() { var ok = true val args = Bundle() args.putString(CreateCollectionFragment.ARG_SERVICE_TYPE, Service.TYPE_CARDDAV) val parent = model.homeSets.value?.getItem(model.idxHomeSet.value!!) ?: return args.putString(CreateCollectionFragment.ARG_URL, parent.url.resolve(UUID.randomUUID().toString() + "/").toString()) Loading app/src/main/java/at/bitfire/davdroid/ui/CreateCalendarActivity.kt +1 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ class CreateCalendarActivity: AppCompatActivity(), ColorPickerDialogListener { var ok = true val args = Bundle() args.putString(CreateCollectionFragment.ARG_SERVICE_TYPE, Service.TYPE_CALDAV) val parent = model.homeSets.value?.getItem(model.idxHomeSet.value!!) ?: return args.putString(CreateCollectionFragment.ARG_URL, parent.url.resolve(UUID.randomUUID().toString() + "/").toString()) Loading app/src/main/java/at/bitfire/davdroid/ui/CreateCollectionFragment.kt +11 −8 Original line number Diff line number Diff line Loading @@ -34,8 +34,8 @@ import kotlin.concurrent.thread class CreateCollectionFragment: DialogFragment() { companion object { const val ARG_ACCOUNT = "account" const val ARG_SERVICE_TYPE = "serviceType" const val ARG_TYPE = "type" const val ARG_URL = "url" Loading @@ -57,11 +57,12 @@ class CreateCollectionFragment: DialogFragment() { val args = arguments ?: throw IllegalArgumentException() model = ViewModelProviders.of(this).get(Model::class.java) model.account = args.getParcelable(ARG_ACCOUNT) ?: throw IllegalArgumentException("Account required") model.account = args.getParcelable(ARG_ACCOUNT) ?: throw IllegalArgumentException("ARG_ACCOUNT required") model.serviceType = args.getString(ARG_SERVICE_TYPE) ?: throw java.lang.IllegalArgumentException("ARG_SERVICE_TYPE required") model.collection = Collection( type = args.getString(ARG_TYPE) ?: throw IllegalArgumentException("Type required"), url = HttpUrl.parse(args.getString(ARG_URL) ?: throw IllegalArgumentException("URL required"))!!, type = args.getString(ARG_TYPE) ?: throw IllegalArgumentException("ARG_TYPE required"), url = HttpUrl.parse(args.getString(ARG_URL) ?: throw IllegalArgumentException("ARG_URL required"))!!, displayName = args.getString(ARG_DISPLAY_NAME), description = args.getString(ARG_DESCRIPTION), Loading @@ -73,13 +74,14 @@ class CreateCollectionFragment: DialogFragment() { ) model.createCollection().observe(this, Observer { exception -> if (exception != null) { if (exception == null) requireActivity().finish() else { dismiss() requireFragmentManager().beginTransaction() .add(ExceptionInfoFragment.newInstance(exception, model.account), null) .commit() } else requireActivity().finish() } }) } Loading @@ -101,6 +103,7 @@ class CreateCollectionFragment: DialogFragment() { ): AndroidViewModel(application) { lateinit var account: Account lateinit var serviceType: String lateinit var collection: Collection val result = MutableLiveData<Exception>() Loading @@ -118,7 +121,7 @@ class CreateCollectionFragment: DialogFragment() { // no HTTP error -> create collection locally val db = AppDatabase.getInstance(getApplication()) db.serviceDao().getByAccountAndType(account.name, collection.type)?.let { service -> db.serviceDao().getByAccountAndType(account.name, serviceType)?.let { service -> collection.serviceId = service.id db.collectionDao().insert(collection) } Loading app/src/main/java/at/bitfire/davdroid/ui/account/AddressBooksFragment.kt +3 −0 Original line number Diff line number Diff line package at.bitfire.davdroid.ui.account import android.content.Intent import android.os.Bundle import android.view.* import at.bitfire.davdroid.R import at.bitfire.davdroid.model.Collection Loading @@ -9,6 +10,8 @@ import kotlinx.android.synthetic.main.account_carddav_item.view.* class AddressBooksFragment: CollectionsFragment() { override val noCollectionsStringId = R.string.account_no_address_books override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) = inflater.inflate(R.menu.carddav_actions, menu) Loading Loading
app/src/main/java/at/bitfire/davdroid/DavService.kt +4 −4 Original line number Diff line number Diff line Loading @@ -270,11 +270,11 @@ class DavService: android.app.Service() { // old URL exists in newCollections, update database if content has been changed matchingNewCollection.id = oldCollection.id matchingNewCollection.serviceId = oldCollection.serviceId if (matchingNewCollection == oldCollection) { if (matchingNewCollection != oldCollection) collectionDao.update(matchingNewCollection) // remove from "collections" (which will be added later) collections.remove(url) } } else // URL is not in newCollections, delete from database collectionDao.delete(oldCollection) Loading
app/src/main/java/at/bitfire/davdroid/ui/CreateAddressBookActivity.kt +1 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ class CreateAddressBookActivity: AppCompatActivity() { var ok = true val args = Bundle() args.putString(CreateCollectionFragment.ARG_SERVICE_TYPE, Service.TYPE_CARDDAV) val parent = model.homeSets.value?.getItem(model.idxHomeSet.value!!) ?: return args.putString(CreateCollectionFragment.ARG_URL, parent.url.resolve(UUID.randomUUID().toString() + "/").toString()) Loading
app/src/main/java/at/bitfire/davdroid/ui/CreateCalendarActivity.kt +1 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ class CreateCalendarActivity: AppCompatActivity(), ColorPickerDialogListener { var ok = true val args = Bundle() args.putString(CreateCollectionFragment.ARG_SERVICE_TYPE, Service.TYPE_CALDAV) val parent = model.homeSets.value?.getItem(model.idxHomeSet.value!!) ?: return args.putString(CreateCollectionFragment.ARG_URL, parent.url.resolve(UUID.randomUUID().toString() + "/").toString()) Loading
app/src/main/java/at/bitfire/davdroid/ui/CreateCollectionFragment.kt +11 −8 Original line number Diff line number Diff line Loading @@ -34,8 +34,8 @@ import kotlin.concurrent.thread class CreateCollectionFragment: DialogFragment() { companion object { const val ARG_ACCOUNT = "account" const val ARG_SERVICE_TYPE = "serviceType" const val ARG_TYPE = "type" const val ARG_URL = "url" Loading @@ -57,11 +57,12 @@ class CreateCollectionFragment: DialogFragment() { val args = arguments ?: throw IllegalArgumentException() model = ViewModelProviders.of(this).get(Model::class.java) model.account = args.getParcelable(ARG_ACCOUNT) ?: throw IllegalArgumentException("Account required") model.account = args.getParcelable(ARG_ACCOUNT) ?: throw IllegalArgumentException("ARG_ACCOUNT required") model.serviceType = args.getString(ARG_SERVICE_TYPE) ?: throw java.lang.IllegalArgumentException("ARG_SERVICE_TYPE required") model.collection = Collection( type = args.getString(ARG_TYPE) ?: throw IllegalArgumentException("Type required"), url = HttpUrl.parse(args.getString(ARG_URL) ?: throw IllegalArgumentException("URL required"))!!, type = args.getString(ARG_TYPE) ?: throw IllegalArgumentException("ARG_TYPE required"), url = HttpUrl.parse(args.getString(ARG_URL) ?: throw IllegalArgumentException("ARG_URL required"))!!, displayName = args.getString(ARG_DISPLAY_NAME), description = args.getString(ARG_DESCRIPTION), Loading @@ -73,13 +74,14 @@ class CreateCollectionFragment: DialogFragment() { ) model.createCollection().observe(this, Observer { exception -> if (exception != null) { if (exception == null) requireActivity().finish() else { dismiss() requireFragmentManager().beginTransaction() .add(ExceptionInfoFragment.newInstance(exception, model.account), null) .commit() } else requireActivity().finish() } }) } Loading @@ -101,6 +103,7 @@ class CreateCollectionFragment: DialogFragment() { ): AndroidViewModel(application) { lateinit var account: Account lateinit var serviceType: String lateinit var collection: Collection val result = MutableLiveData<Exception>() Loading @@ -118,7 +121,7 @@ class CreateCollectionFragment: DialogFragment() { // no HTTP error -> create collection locally val db = AppDatabase.getInstance(getApplication()) db.serviceDao().getByAccountAndType(account.name, collection.type)?.let { service -> db.serviceDao().getByAccountAndType(account.name, serviceType)?.let { service -> collection.serviceId = service.id db.collectionDao().insert(collection) } Loading
app/src/main/java/at/bitfire/davdroid/ui/account/AddressBooksFragment.kt +3 −0 Original line number Diff line number Diff line package at.bitfire.davdroid.ui.account import android.content.Intent import android.os.Bundle import android.view.* import at.bitfire.davdroid.R import at.bitfire.davdroid.model.Collection Loading @@ -9,6 +10,8 @@ import kotlinx.android.synthetic.main.account_carddav_item.view.* class AddressBooksFragment: CollectionsFragment() { override val noCollectionsStringId = R.string.account_no_address_books override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) = inflater.inflate(R.menu.carddav_actions, menu) Loading