From 6a87dac0c99d517e539b0da2484bcabde49c5ea6 Mon Sep 17 00:00:00 2001 From: Sergei Gureev Date: Sun, 1 Sep 2019 16:12:15 +0300 Subject: [PATCH] #38 WebDAV sync support DataBindingUtil is used Small formatting fixes --- .../com/orgzly/android/repos/WebdavRepo.kt | 2 +- .../android/ui/repo/WebdavRepoActivity.kt | 20 ++-- .../main/res/layout/activity_repo_webdav.xml | 92 ++++++++++--------- gradle.properties | 2 +- 4 files changed, 60 insertions(+), 56 deletions(-) diff --git a/app/src/main/java/com/orgzly/android/repos/WebdavRepo.kt b/app/src/main/java/com/orgzly/android/repos/WebdavRepo.kt index 9667bd369..92f871dcc 100644 --- a/app/src/main/java/com/orgzly/android/repos/WebdavRepo.kt +++ b/app/src/main/java/com/orgzly/android/repos/WebdavRepo.kt @@ -100,4 +100,4 @@ class WebdavRepo(private val uri: Uri, username: String?, password: String?) : S } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/orgzly/android/ui/repo/WebdavRepoActivity.kt b/app/src/main/java/com/orgzly/android/ui/repo/WebdavRepoActivity.kt index 287de6917..43d373fd9 100644 --- a/app/src/main/java/com/orgzly/android/ui/repo/WebdavRepoActivity.kt +++ b/app/src/main/java/com/orgzly/android/ui/repo/WebdavRepoActivity.kt @@ -7,16 +7,18 @@ import android.os.Bundle import android.text.TextUtils import android.view.Menu import android.view.MenuItem +import androidx.databinding.DataBindingUtil import com.orgzly.R import com.orgzly.android.prefs.RepoPreferences import com.orgzly.android.repos.RepoFactory import com.orgzly.android.repos.WebdavRepo.Companion.PASSWORD_PREF_KEY import com.orgzly.android.repos.WebdavRepo.Companion.USERNAME_PREF_KEY import com.orgzly.android.ui.CommonActivity -import kotlinx.android.synthetic.main.activity_repo_webdav.* +import com.orgzly.databinding.ActivityRepoWebdavBinding import javax.inject.Inject class WebdavRepoActivity : CommonActivity() { + private lateinit var binding: ActivityRepoWebdavBinding @Inject lateinit var repoFactory: RepoFactory @@ -28,7 +30,7 @@ class WebdavRepoActivity : CommonActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_repo_webdav) + binding = DataBindingUtil.setContentView(this, R.layout.activity_repo_webdav) setupActionBar(R.string.webdav) @@ -36,11 +38,11 @@ class WebdavRepoActivity : CommonActivity() { if (repoId != 0L) { val prefs = RepoPreferences.fromId(this, repoId, dataRepository) - activity_repo_webdav_url.setText(prefs.repoUri.toString()) + binding.activityRepoWebdavUrl.setText(prefs.repoUri.toString()) val username = prefs.getStringValue(USERNAME_PREF_KEY, "") - activity_repo_webdav_username.setText(username) + binding.activityRepoWebdavUsername.setText(username) val password = prefs.getStringValue(PASSWORD_PREF_KEY, "") - activity_repo_webdav_password.setText(password) + binding.activityRepoWebdavPassword.setText(password) } } @@ -70,17 +72,17 @@ class WebdavRepoActivity : CommonActivity() { } private fun saveAndFinish() { - val uriString = activity_repo_webdav_url.text.toString().trim { it <= ' ' }.let { + val uriString = binding.activityRepoWebdavUrl.text.toString().trim { it <= ' ' }.let { if (it.startsWith("http")) { it.replaceFirst("http", "webdav") } it } - val username = activity_repo_webdav_username.text.toString().trim { it <= ' ' } - val password = activity_repo_webdav_password.text.toString().trim { it <= ' ' } + val username = binding.activityRepoWebdavUsername.text.toString().trim { it <= ' ' } + val password = binding.activityRepoWebdavPassword.text.toString().trim { it <= ' ' } val urlError = getWebdavUrlError(uriString) - activity_repo_webdav_url_layout.error = urlError + binding.activityRepoWebdavUrlLayout.error = urlError if (urlError != null) { return } diff --git a/app/src/main/res/layout/activity_repo_webdav.xml b/app/src/main/res/layout/activity_repo_webdav.xml index f5e61a508..7ec432b2b 100644 --- a/app/src/main/res/layout/activity_repo_webdav.xml +++ b/app/src/main/res/layout/activity_repo_webdav.xml @@ -1,74 +1,76 @@ - + xmlns:tools="http://schemas.android.com/tools"> - - + android:layout_height="match_parent" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - + android:orientation="vertical" + android:padding="@dimen/screen_edge" + tools:context=".android.ui.main.MainActivity"> - + app:errorEnabled="true"> - + - + - + app:errorEnabled="true"> - + - + - + app:errorEnabled="true"> + + - + - + - + - + - \ No newline at end of file + + diff --git a/gradle.properties b/gradle.properties index ca24023e6..20c210625 100644 --- a/gradle.properties +++ b/gradle.properties @@ -73,4 +73,4 @@ glide_version = 4.9.0 jgit_version = 4.4.1.201607150455-r -sardine_version = 0.4 \ No newline at end of file +sardine_version = 0.4