0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 12:02:16 +02:00

Fix broken custom sync server url generation

This commit is contained in:
Timothy Rae 2015-12-30 19:19:31 +09:00
parent 11e20928c1
commit 8273eb8e2c
3 changed files with 8 additions and 6 deletions

View File

@ -18,7 +18,7 @@ package com.ichi2.libanki.sync;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabaseCorruptException;
import android.net.Uri;
import com.ichi2.anki.AnkiDatabaseManager;
import com.ichi2.anki.AnkiDb;
@ -65,8 +65,8 @@ public class FullSyncer extends HttpSyncer {
// Allow user to specify custom sync server
SharedPreferences userPreferences = AnkiDroidApp.getSharedPrefs(AnkiDroidApp.getInstance());
if (userPreferences!= null && userPreferences.getBoolean("useCustomSyncServer", false)) {
File syncBase = new File(userPreferences.getString("syncBaseUrl", Consts.SYNC_BASE));
return new File(syncBase, "/sync").toString() + "/";
Uri syncBase = Uri.parse(userPreferences.getString("syncBaseUrl", Consts.SYNC_BASE));
return syncBase.buildUpon().appendPath("sync").toString() + "/";
}
// Usual case
return Consts.SYNC_BASE + "sync/";

View File

@ -21,6 +21,7 @@ package com.ichi2.libanki.sync;
import android.content.SharedPreferences;
import android.net.Uri;
import com.ichi2.anki.AnkiDroidApp;
import com.ichi2.anki.exception.UnknownHttpResponseException;
@ -453,8 +454,8 @@ public class HttpSyncer {
// Allow user to specify custom sync server
SharedPreferences userPreferences = AnkiDroidApp.getSharedPrefs(AnkiDroidApp.getInstance());
if (userPreferences!= null && userPreferences.getBoolean("useCustomSyncServer", false)) {
File syncBase = new File(userPreferences.getString("syncBaseUrl", Consts.SYNC_BASE));
return new File(syncBase, "/sync").toString() + "/";
Uri syncBase = Uri.parse(userPreferences.getString("syncBaseUrl", Consts.SYNC_BASE));
return syncBase.buildUpon().appendPath("sync").toString() + "/";
}
// Usual case
return Consts.SYNC_BASE + "sync/";

View File

@ -18,6 +18,7 @@
package com.ichi2.libanki.sync;
import android.content.SharedPreferences;
import android.net.Uri;
import android.text.TextUtils;
import com.ichi2.anki.AnkiDroidApp;
@ -60,7 +61,7 @@ public class RemoteMediaServer extends HttpSyncer {
// Allow user to specify custom sync server
SharedPreferences userPreferences = AnkiDroidApp.getSharedPrefs(AnkiDroidApp.getInstance());
if (userPreferences!= null && userPreferences.getBoolean("useCustomSyncServer", false)) {
File mediaSyncBase = new File(userPreferences.getString("syncMediaUrl", Consts.SYNC_MEDIA_BASE));
Uri mediaSyncBase = Uri.parse(userPreferences.getString("syncBaseUrl", Consts.SYNC_BASE));
return mediaSyncBase.toString() + "/";
}
// Usual case