Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add guard for empty string at port textfield in SftpConnectionDialog #4128

Merged
merged 2 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import android.text.Editable
import android.text.InputFilter
import android.text.TextUtils
import android.text.TextWatcher
import android.view.LayoutInflater
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
Expand All @@ -55,6 +54,7 @@ import com.amaze.filemanager.fileoperations.filesystem.OpenMode
import com.amaze.filemanager.filesystem.ftp.NetCopyClientConnectionPool
import com.amaze.filemanager.filesystem.ftp.NetCopyClientConnectionPool.FTPS_URI_PREFIX
import com.amaze.filemanager.filesystem.ftp.NetCopyClientConnectionPool.FTP_URI_PREFIX
import com.amaze.filemanager.filesystem.ftp.NetCopyClientConnectionPool.SSH_DEFAULT_PORT
import com.amaze.filemanager.filesystem.ftp.NetCopyClientConnectionPool.SSH_URI_PREFIX
import com.amaze.filemanager.filesystem.ftp.NetCopyClientUtils
import com.amaze.filemanager.filesystem.ftp.NetCopyConnectionInfo.Companion.COLON
Expand Down Expand Up @@ -82,7 +82,6 @@ import java.io.BufferedReader
import java.lang.ref.WeakReference
import java.security.KeyPair
import java.security.PublicKey
import java.util.*
import java.util.concurrent.Callable

/** SSH/SFTP connection setup dialog. */
Expand Down Expand Up @@ -132,7 +131,7 @@ class SftpConnectDialog : DialogFragment() {
@Suppress("ComplexMethod")
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
ctx = WeakReference(activity)
binding = SftpDialogBinding.inflate(LayoutInflater.from(context))
binding = SftpDialogBinding.inflate(layoutInflater)
val utilsProvider: UtilitiesProvider = AppConfig.getInstance().utilsProvider
val edit = requireArguments().getBoolean(ARG_EDIT, false)

Expand Down Expand Up @@ -790,7 +789,13 @@ class SftpConnectDialog : DialogFragment() {
prefix = getProtocolPrefixFromDropdownSelection(),
connectionName = binding.connectionET.text.toString(),
hostname = binding.ipET.text.toString(),
port = binding.portET.text.toString().toInt(),
port = binding.portET.text.toString().let {
if (it.isEmpty() || it.isBlank()) {
SSH_DEFAULT_PORT
} else {
it.toInt()
}
},
defaultPath = binding.defaultPathET.text.toString(),
username = binding.usernameET.text.toString().urlEncoded(),
password = if (true == binding.passwordET.text?.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
package com.amaze.filemanager.utils

import android.content.Context
import android.os.Build
import android.os.Build.VERSION_CODES.N
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.os.LocaleListCompat
import com.amaze.filemanager.R
Expand Down Expand Up @@ -50,6 +52,12 @@ fun Context.getLocaleListFromXml(): LocaleListCompat {
e.printStackTrace()
}

// Remove locale tags that would produce same locale on Android N or above
if (Build.VERSION.SDK_INT >= N) {
tagsList.remove("id")
tagsList.remove("he")
}

return LocaleListCompat.forLanguageTags(tagsList.joinToString(","))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ import kotlin.random.Random
* Tests for [UiPrefsFragment].
*/
@Config(
sdk = [Build.VERSION_CODES.KITKAT, Build.VERSION_CODES.P, Build.VERSION_CODES.R],
sdk = [
Build.VERSION_CODES.KITKAT,
Build.VERSION_CODES.N,
Build.VERSION_CODES.P,
Build.VERSION_CODES.R
],
shadows = [
ShadowMultiDex::class,
ShadowStorageManager::class,
Expand Down
Loading