diff --git a/app/src/main/java/io/lbry/browser/tasks/UploadImageTask.java b/app/src/main/java/io/lbry/browser/tasks/UploadImageTask.java index 85be7a0a..2dcd8d65 100644 --- a/app/src/main/java/io/lbry/browser/tasks/UploadImageTask.java +++ b/app/src/main/java/io/lbry/browser/tasks/UploadImageTask.java @@ -9,6 +9,7 @@ import org.json.JSONObject; import java.io.IOException; import java.io.File; +import java.util.concurrent.TimeUnit; import io.lbry.browser.exceptions.LbryResponseException; import io.lbry.browser.utils.Helper; @@ -50,7 +51,10 @@ public class UploadImageTask extends AsyncTask { addFormDataPart("file", fileName, RequestBody.create(file, MediaType.parse(fileType))). build(); Request request = new Request.Builder().url("https://spee.ch/api/claim/publish").post(body).build(); - OkHttpClient client = new OkHttpClient(); + OkHttpClient client = new OkHttpClient.Builder(). + writeTimeout(300, TimeUnit.SECONDS). + readTimeout(300, TimeUnit.SECONDS). + build(); Response response = client.newCall(request).execute(); JSONObject json = new JSONObject(response.body().string()); if (json.has("success") && Helper.getJSONBoolean("success", false, json)) { diff --git a/app/src/main/java/io/lbry/browser/ui/publish/PublishFormFragment.java b/app/src/main/java/io/lbry/browser/ui/publish/PublishFormFragment.java index 965cda97..25cbd63d 100644 --- a/app/src/main/java/io/lbry/browser/ui/publish/PublishFormFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/publish/PublishFormFragment.java @@ -152,6 +152,7 @@ public class PublishFormFragment extends BaseFragment implements private TextInputLayout layoutOtherLicenseDescription; private View inlineDepositBalanceContainer; private TextView inlineDepositBalanceValue; + private TextView textInlineAddressInvalid; private View linkPublishCancel; private MaterialButton buttonPublish; @@ -198,6 +199,7 @@ public class PublishFormFragment extends BaseFragment implements noTagsView = root.findViewById(R.id.form_no_added_tags); noTagResultsView = root.findViewById(R.id.form_no_tag_results); + textInlineAddressInvalid = root.findViewById(R.id.publish_form_inline_address_invalid); inlineDepositBalanceContainer = root.findViewById(R.id.publish_form_inline_balance_container); inlineDepositBalanceValue = root.findViewById(R.id.publish_form_inline_balance_value); @@ -314,6 +316,25 @@ public class PublishFormFragment extends BaseFragment implements } }); + inputAddress.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + String value = Helper.getValue(charSequence); + boolean invalid = !Helper.isNullOrEmpty(value) && !LbryUri.isNameValid(value); + Helper.setViewVisibility(textInlineAddressInvalid, invalid ? View.VISIBLE : View.INVISIBLE); + } + + @Override + public void afterTextChanged(Editable editable) { + + } + }); + inputDeposit.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { diff --git a/app/src/main/java/io/lbry/browser/utils/LbryUri.java b/app/src/main/java/io/lbry/browser/utils/LbryUri.java index 32d23612..a217632c 100644 --- a/app/src/main/java/io/lbry/browser/utils/LbryUri.java +++ b/app/src/main/java/io/lbry/browser/utils/LbryUri.java @@ -44,7 +44,7 @@ public class LbryUri { } public static boolean isNameValid(String name) { - return !name.matches(REGEX_INVALID_URI); + return !Pattern.compile(REGEX_INVALID_URI).matcher(name).find(); } public static LbryUri tryParse(String url) { diff --git a/app/src/main/res/layout/fragment_publish_form.xml b/app/src/main/res/layout/fragment_publish_form.xml index 8281c382..7d24d34f 100644 --- a/app/src/main/res/layout/fragment_publish_form.xml +++ b/app/src/main/res/layout/fragment_publish_form.xml @@ -377,6 +377,18 @@ android:textSize="14sp" /> + +