From e8e0cc791ffa92a9487d4bf2e1831f9ce34ee687 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 19 Sep 2020 17:28:08 +0530 Subject: Add check for potential issues with SSH URL Signed-off-by: Harsh Shandilya --- .../com/zeapo/pwdstore/git/GitServerConfigActivity.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'app/src/main/java/com') diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt b/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt index 92381384..0d4246b0 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt @@ -25,6 +25,7 @@ import com.zeapo.pwdstore.databinding.ActivityGitCloneBinding import com.zeapo.pwdstore.git.config.AuthMode import com.zeapo.pwdstore.git.config.GitSettings import com.zeapo.pwdstore.git.config.Protocol +import com.zeapo.pwdstore.ui.dialogs.BasicBottomSheet import com.zeapo.pwdstore.utils.PasswordRepository import com.zeapo.pwdstore.utils.snackbar import com.zeapo.pwdstore.utils.viewBinding @@ -87,6 +88,22 @@ class GitServerConfigActivity : BaseGitActivity() { } binding.saveButton.setOnClickListener { + val newUrl = binding.serverUrl.text.toString().trim() + // If url is of type john_doe@example.org:12435/path/to/repo, then not adding `ssh://` + // in the beginning will cause the port to be seen as part of the path. Let users know + // about it and offer a quickfix. + if (newUrl.contains(":[0-9]{1,5}/".toRegex()) && !newUrl.startsWith("ssh://")) { + BasicBottomSheet.Builder(this) + .setTitleRes(R.string.ssh_scheme_needed_title) + .setMessageRes(R.string.ssh_scheme_needed_message) + .setPositiveButtonClickListener { + @Suppress("SetTextI18n") + binding.serverUrl.setText("ssh://$newUrl") + } + .build() + .show(supportFragmentManager, "SSH_SCHEME_WARNING") + return@setOnClickListener + } when (val updateResult = GitSettings.updateConnectionSettingsIfValid( newAuthMode = newAuthMode, newUrl = binding.serverUrl.text.toString().trim(), -- cgit v1.2.3