Permalink
Browse files

Fix for issue 618: Decks with Japanese names.

Issue 618: Ankidroid does not display deck titles with Japanese names
and fails to sync said decks.

As it turns out, the behavior of Anki on the desktop is different for
shared and personal decks.

Shared decks are limited to 40 characters and remove all but basic
characters from the file name.

Personal decks, on the other hand, are not stripped at all, to make sure
they can be synced correctly.

This makes AnkiDroid more consistent with Anki on the desktop, and
should make both shared and personal decks download work as expected.
  • Loading branch information...
1 parent a35fddd commit e65eba5ceec3b64109f8d362f55dfd1671e4aec6 @flerda flerda committed Apr 22, 2012
Showing with 3 additions and 4 deletions.
  1. +0 −3 src/com/ichi2/anki/Download.java
  2. +2 −0 src/com/ichi2/anki/SharedDeck.java
  3. +1 −1 src/com/ichi2/anki/Utils.java
@@ -54,9 +54,6 @@ public Download(String title) {
// The deck file name should match the deck title, but some characters are invalid in it,
// so they need to be replaced.
mFilename = Utils.removeInvalidDeckNameCharacters(mTitle);
- if (mFilename.length() > 40) {
- mFilename = mFilename.substring(0, 40);
- }
}
@@ -58,6 +58,8 @@ public String getTitle() {
public void setTitle(String title) {
+ title = title.replaceAll("[^][A-Za-z0-9 ()\\-]", "");
+ title = title.substring(0, 40);
mTitle = title;
put("title", mTitle);
}
@@ -1054,7 +1054,7 @@ public static String removeInvalidDeckNameCharacters(String name) {
if (name == null) { return null; }
// The only characters that we cannot absolutely allow to appear in the filename are the ones reserved in some
// file system. Currently these are \, /, and :, in order to cover Linux, OSX, and Windows.
- return name.replaceAll("[^A-Za-z0-9 ()\\-]", "");
+ return name.replaceAll("[:/\\]", "");
}
/** Returns a list of files for the installed custom fonts. */

0 comments on commit e65eba5

Please sign in to comment.