Skip to content
Closed
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
4 changes: 4 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/anki/AnkiDroidApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ public static SharedPreferences getSharedPrefs(Context context) {
return context.getSharedPreferences(SHARED_PREFS_NAME, Context.MODE_PRIVATE);
}

public static SharedPreferences getApplicationPrefs() {
return getSharedPrefs(sInstance.getApplicationContext());
}


public static AnkiDroidApp getInstance() {
return sInstance;
Expand Down
2 changes: 1 addition & 1 deletion AnkiDroid/src/main/java/com/ichi2/anki/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public class Preferences extends PreferenceActivity implements OnSharedPreferenc
private static String[] sShowValueInSummSeek = { "relativeDisplayFontSize", "relativeCardBrowserFontSize",
"relativeImageSize", "answerButtonSize", "whiteBoardStrokeWidth", "swipeSensitivity",
"timeoutAnswerSeconds", "timeoutQuestionSeconds", "backupMax", "dayOffset" };
private static String[] sShowValueInSummEditText = { "simpleInterfaceExcludeTags", "deckPath" };
private static String[] sShowValueInSummEditText = { "simpleInterfaceExcludeTags", "deckPath", "syncBaseUrl" };
private static String[] sShowValueInSummNumRange = { "timeLimit", "learnCutoff" };
private TreeMap<String, String> mListsToUpdate = new TreeMap<String, String>();
private StyledProgressDialog mProgressDialog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.ichi2.anki.exception.UnknownHttpResponseException;
import com.ichi2.async.Connection;
import com.ichi2.libanki.Collection;
import com.ichi2.libanki.Consts;
import com.ichi2.libanki.Utils;

import org.apache.http.HttpResponse;
Expand Down Expand Up @@ -60,7 +59,7 @@ public FullSyncer(Collection col, String hkey, Connection con) {

@Override
public String syncURL() {
return Consts.SYNC_BASE + "sync/";
return syncBase() + "sync/";
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public HttpResponse req(String method, InputStream fobj, int comp, JSONObject re
bos.flush();
bos.close();
// connection headers
String url = Consts.SYNC_BASE;
String url = syncBase();
if (method.equals("register")) {
url = url + "account/signup" + "?username=" + registerData.getString("u") + "&password="
+ registerData.getString("p");
Expand Down Expand Up @@ -447,9 +447,12 @@ public HttpResponse register(String user, String pw) throws UnknownHttpResponseE
return null;
}

public String syncBase() {
return AnkiDroidApp.getApplicationPrefs().getString("syncBaseUrl", Consts.SYNC_BASE);
}

public String syncURL() {
return Consts.SYNC_BASE + "sync/";
return syncBase() + "sync/";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.ichi2.anki.exception.UnknownHttpResponseException;
import com.ichi2.async.Connection;
import com.ichi2.libanki.Collection;
import com.ichi2.libanki.Consts;
import com.ichi2.libanki.Utils;

import org.apache.http.HttpResponse;
Expand Down Expand Up @@ -55,7 +54,7 @@ public RemoteMediaServer(Collection col, String hkey, Connection con) {

@Override
public String syncURL() {
return Consts.SYNC_BASE + "msync/";
return syncBase() + "msync/";
}


Expand Down
2 changes: 2 additions & 0 deletions AnkiDroid/src/main/res/values/10-preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
<string name="tts_summ">Reads out question and answer if no sound file is included</string>
<string name="sync_fetch_missing_media">Fetch media on sync</string>
<string name="sync_fetch_missing_media_summ">Automatically fetch missing media when syncing.</string>
<string name="sync_base_url">Anki Server URL</string>
<string name="sync_base_url_summ">XXX</string>
<string name="sync_account">AnkiWeb account</string>
<string name="sync_account_summ_logged_out">Not logged in</string>
<string name="sync_account_summ_logged_in">%s</string>
Expand Down
5 changes: 5 additions & 0 deletions AnkiDroid/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@
<!-- Advanced Preferences -->
<PreferenceScreen android:title="@string/pref_cat_advanced"
android:summary="@string/pref_cat_advanced_summ" >
<EditTextPreference
android:defaultValue="https://ankiweb.net/"
android:key="syncBaseUrl"
android:summary="@string/sync_base_url_summ"
android:title="@string/sync_base_url" />
<Preference
android:key="force_full_sync"
android:title="@string/force_full_sync_title"
Expand Down