mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-20 03:52:15 +02:00
Allow tags to be null in addNote()
This commit is contained in:
parent
eb274d7ce1
commit
71dde60d2d
@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
|
||||
|
||||
def groupId = "com.ichi2.anki"
|
||||
def artifactId = "api"
|
||||
def version = "1.1.0alpha2"
|
||||
def version = "1.1.0alpha3"
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
@ -11,7 +11,7 @@ android {
|
||||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 22
|
||||
versionCode 3
|
||||
versionCode 11013 // 4th digit: 1=alpha, 2=beta, 3=official
|
||||
versionName version
|
||||
}
|
||||
buildTypes {
|
||||
|
@ -88,7 +88,9 @@ public final class AddContentApi {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(Note.MID, modelId);
|
||||
values.put(Note.FLDS, Utils.joinFields(fields));
|
||||
if (tags != null) {
|
||||
values.put(Note.TAGS, Utils.joinTags(tags));
|
||||
}
|
||||
return addNoteForContentValues(deckId, values);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@ import android.text.TextUtils;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -40,16 +39,18 @@ class Utils {
|
||||
|
||||
|
||||
static String joinFields(String[] list) {
|
||||
// note: since list is very unlikely to be length <2, any optimizations for those lengths are irrelevant
|
||||
return TextUtils.join("\u001f", list);
|
||||
return list != null ? TextUtils.join("\u001f", list): null;
|
||||
}
|
||||
|
||||
|
||||
static String[] splitFields(String fields) {
|
||||
return fields.split("\\x1f", -1);
|
||||
return fields != null? fields.split("\\x1f", -1): null;
|
||||
}
|
||||
|
||||
static String joinTags(Set<String> tags) {
|
||||
if (tags == null || tags.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
for (String t : tags) {
|
||||
t.replaceAll(" ", "_");
|
||||
}
|
||||
@ -57,6 +58,9 @@ class Utils {
|
||||
}
|
||||
|
||||
static String[] splitTags(String tags) {
|
||||
if (tags == null) {
|
||||
return null;
|
||||
}
|
||||
return tags.trim().split("\\s+");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user