diff --git a/android/java/org/chromium/chrome/browser/settings/BraveSyncScreensPreference.java b/android/java/org/chromium/chrome/browser/settings/BraveSyncScreensPreference.java
index be15bdfe2cf7..81375293378e 100644
--- a/android/java/org/chromium/chrome/browser/settings/BraveSyncScreensPreference.java
+++ b/android/java/org/chromium/chrome/browser/settings/BraveSyncScreensPreference.java
@@ -80,8 +80,10 @@
import org.chromium.chrome.browser.sync.SyncServiceFactory;
import org.chromium.chrome.browser.sync.settings.BraveManageSyncSettings;
import org.chromium.components.browser_ui.settings.SettingsNavigation;
+import org.chromium.components.embedder_support.util.UrlConstants;
import org.chromium.components.sync.SyncService;
import org.chromium.ui.base.DeviceFormFactor;
+import org.chromium.url.GURL;
import java.io.IOException;
import java.time.LocalDateTime;
@@ -128,7 +130,7 @@ public class BraveSyncScreensPreference extends BravePreferenceFragment
private Button mDeleteAccountButton;
private Button mNewCodeWordsButton;
private Button mNewQrCodeButton;
- private TextView mBraveSyncCustomSyncUrl;
+ private TextView mBraveReadOnlySyncUrlView;
private TextView mBraveSyncTextDevicesTitle;
private TextView mBraveSyncWordCountTitle;
private TextView mBraveSyncAddDeviceCodeWords;
@@ -338,8 +340,12 @@ private void fillDevices() {
}
}
- // TODO: Check and hide if custom sync URL is empty
- mBraveSyncCustomSyncUrl.setText(getBraveSyncWorker().getSyncServiceURL());
+ LinearLayout customSyncUrlReadOnlyLayout =
+ getView().findViewById(R.id.brave_read_only_sync_url_layout);
+ if (!sCustomSyncServiceUrl.isEmpty()) {
+ mBraveReadOnlySyncUrlView.setText(sCustomSyncServiceUrl);
+ customSyncUrlReadOnlyLayout.setVisibility(View.VISIBLE);
+ }
if (index > 0) {
mBraveSyncTextDevicesTitle.setText(
@@ -450,7 +456,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
mCopyButton.setOnClickListener(this);
}
- mBraveSyncCustomSyncUrl = getView().findViewById(R.id.brave_sync_url_display);
+ mBraveReadOnlySyncUrlView = getView().findViewById(R.id.brave_read_only_sync_url_view);
mBraveSyncTextDevicesTitle = getView().findViewById(R.id.brave_sync_devices_title);
mBraveSyncWordCountTitle = getView().findViewById(R.id.brave_sync_text_word_count);
mBraveSyncWordCountTitle.setText(getString(R.string.brave_sync_word_count_text, 0));
@@ -1356,10 +1362,17 @@ private void saveCustomSyncUrlAndRelaunch() {
return;
}
- // Check if the URL starts with a valid scheme (http:// or https://)
- if (!url.matches("^[a-zA-Z][a-zA-Z0-9+.-]*://.*")) {
- // Prepend 'http://' if it doesn't
- url = "http://" + url;
+ GURL gurl = new GURL(url);
+ // Check if the URL starts with a valid scheme, if not, just prepend with https scheme.
+ if (!gurl.isValid() || gurl.getScheme().isEmpty()) {
+ url = "https://" + url;
+ gurl = new GURL(url);
+ }
+
+ // Check and show error when it is not an HTTPS Scheme.
+ if (!gurl.getScheme().equals(UrlConstants.HTTPS_SCHEME)) {
+ mCustomSyncUrlInput.setError(getString(R.string.brave_sync_url_https_error));
+ return;
}
// Validate the modified URL
diff --git a/android/java/res/layout/brave_sync_done.xml b/android/java/res/layout/brave_sync_done.xml
index 0084e9ae9396..30b22c13f628 100644
--- a/android/java/res/layout/brave_sync_done.xml
+++ b/android/java/res/layout/brave_sync_done.xml
@@ -40,29 +40,26 @@
android:textColor="@color/modern_grey_500"
android:visibility="gone" />
-
+ android:visibility="gone">
+ android:gravity="top" />
-
+ android:gravity="top" />
diff --git a/browser/ui/android/strings/android_brave_strings.grd b/browser/ui/android/strings/android_brave_strings.grd
index c04fcdccddca..1ee6ecdfb550 100644
--- a/browser/ui/android/strings/android_brave_strings.grd
+++ b/browser/ui/android/strings/android_brave_strings.grd
@@ -1190,6 +1190,9 @@ This file contains all "about" strings. It is set to NOT be translated, in tran
Reset to default
+
+ Brave Sync only supports HTTPS connections. Please enter a valid HTTPS sync URL.
+
Brave's sync protocol is open and you can provide your own server implementation. This requires that you host and configure the brave/go-sync implementation yourself. You can then provide the URL to this service and the browser will sync with your implementation instead. To confirm the change, you'll need to restart the browser and re-open sync options to continue.