Using the new S3 dependency, region must be set when endpoint is set
This commit is contained in:
parent
318a7422f4
commit
ed3401836e
@ -39,6 +39,10 @@ class S3AddOrChangePresenter @Inject internal constructor( //
|
||||
statusMessage = getString(R.string.screen_s3_settings_msg_endpoint_and_region_not_empty)
|
||||
}
|
||||
|
||||
if (!endpoint.isNullOrEmpty() && region.isNullOrEmpty()) {
|
||||
statusMessage = getString(R.string.screen_s3_settings_msg_endpoint_set_and_region_empty)
|
||||
}
|
||||
|
||||
if (statusMessage != null) {
|
||||
Toast.makeText(context(), statusMessage, Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.cryptomator.presentation.ui.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial
|
||||
import org.cryptomator.generator.Fragment
|
||||
@ -13,8 +14,9 @@ import kotlinx.android.synthetic.main.fragment_setup_s3.accessKeyEditText
|
||||
import kotlinx.android.synthetic.main.fragment_setup_s3.bucketEditText
|
||||
import kotlinx.android.synthetic.main.fragment_setup_s3.createCloudButton
|
||||
import kotlinx.android.synthetic.main.fragment_setup_s3.displayNameEditText
|
||||
import kotlinx.android.synthetic.main.fragment_setup_s3.regionOrEndpointEditText
|
||||
import kotlinx.android.synthetic.main.fragment_setup_s3.regionOrEndpointEditTextLayout
|
||||
import kotlinx.android.synthetic.main.fragment_setup_s3.endpointEditText
|
||||
import kotlinx.android.synthetic.main.fragment_setup_s3.ll_custom_s3
|
||||
import kotlinx.android.synthetic.main.fragment_setup_s3.regionEditText
|
||||
import kotlinx.android.synthetic.main.fragment_setup_s3.secretKeyEditText
|
||||
import kotlinx.android.synthetic.main.fragment_setup_s3.toggleCustomS3
|
||||
import timber.log.Timber
|
||||
@ -42,15 +44,14 @@ class S3AddOrChangeFragment : BaseFragment() {
|
||||
showEditableCloudContent(s3CloudModel)
|
||||
|
||||
toggleCustomS3.setOnClickListener { switch ->
|
||||
regionOrEndpointEditText.text?.clear()
|
||||
toggleUseAmazonS3((switch as SwitchMaterial).isChecked)
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleUseAmazonS3(checked: Boolean) = if (checked) {
|
||||
regionOrEndpointEditTextLayout.setHint(R.string.screen_s3_settings_region_label)
|
||||
ll_custom_s3.visibility = View.GONE
|
||||
} else {
|
||||
regionOrEndpointEditTextLayout.setHint(R.string.screen_s3_settings_endpoint_label)
|
||||
ll_custom_s3.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
private fun showEditableCloudContent(s3CloudModel: S3CloudModel?) {
|
||||
@ -61,15 +62,17 @@ class S3AddOrChangeFragment : BaseFragment() {
|
||||
secretKeyEditText.setText(decrypt(s3CloudModel.secretKey()))
|
||||
bucketEditText.setText(s3CloudModel.s3Bucket())
|
||||
|
||||
regionEditText.setText(s3CloudModel.s3Region())
|
||||
|
||||
if (it.s3Endpoint().isNotEmpty()) {
|
||||
toggleCustomS3.isChecked = false
|
||||
regionOrEndpointEditText.setText(s3CloudModel.s3Endpoint())
|
||||
regionOrEndpointEditTextLayout.setHint(R.string.screen_s3_settings_endpoint_label)
|
||||
ll_custom_s3.visibility = View.VISIBLE
|
||||
endpointEditText.setText(s3CloudModel.s3Endpoint())
|
||||
} else {
|
||||
regionOrEndpointEditText.setText(s3CloudModel.s3Region())
|
||||
regionOrEndpointEditTextLayout.setHint(R.string.screen_s3_settings_region_label)
|
||||
toggleCustomS3.isChecked = false
|
||||
ll_custom_s3.visibility = View.VISIBLE
|
||||
}
|
||||
} ?: regionOrEndpointEditTextLayout.setHint(R.string.screen_s3_settings_region_label)
|
||||
}
|
||||
}
|
||||
|
||||
private fun decrypt(text: String?): String {
|
||||
@ -92,9 +95,9 @@ class S3AddOrChangeFragment : BaseFragment() {
|
||||
val displayName = displayNameEditText.text.toString().trim()
|
||||
|
||||
if (toggleCustomS3.isChecked) {
|
||||
s3AddOrChangePresenter.checkUserInput(accessKey, secretKey, bucket, null, regionOrEndpointEditText.text.toString().trim(), cloudId, displayName)
|
||||
s3AddOrChangePresenter.checkUserInput(accessKey, secretKey, bucket, null, regionEditText.text.toString().trim(), cloudId, displayName)
|
||||
} else {
|
||||
s3AddOrChangePresenter.checkUserInput(accessKey, secretKey, bucket, regionOrEndpointEditText.text.toString().trim(), null, cloudId, displayName)
|
||||
s3AddOrChangePresenter.checkUserInput(accessKey, secretKey, bucket, endpointEditText.text.toString().trim(), regionEditText.text.toString().trim(), cloudId, displayName)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,14 +79,14 @@
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/regionOrEndpointEditTextLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/regionOrEndpointEditText"
|
||||
android:id="@+id/regionEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/screen_s3_settings_region_label"
|
||||
android:imeOptions="flagNoPersonalizedLearning"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true" />
|
||||
@ -101,6 +101,31 @@
|
||||
android:checked="true"
|
||||
android:text="@string/screen_s3_settings_amazon_s3_text" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_custom_s3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/endpointEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/screen_s3_settings_endpoint_label"
|
||||
android:imeOptions="flagNoPersonalizedLearning"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/createCloudButton"
|
||||
style="?android:textAppearanceSmall"
|
||||
|
@ -194,6 +194,7 @@
|
||||
<string name="screen_s3_settings_msg_secret_key_not_empty">Secret Key can\'t be empty</string>
|
||||
<string name="screen_s3_settings_msg_bucket_not_empty">Bucket can\'t be empty</string>
|
||||
<string name="screen_s3_settings_msg_endpoint_and_region_not_empty">Endpoint and Region can\'t be empty</string>
|
||||
<string name="screen_s3_settings_msg_endpoint_set_and_region_empty">If Endpoint is set, Region must be set too</string>
|
||||
|
||||
<!-- ## screen: enter vault name -->
|
||||
<string name="screen_enter_vault_name_title" translatable="false">@string/screen_vault_list_action_create_new_vault</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user