From 7bfac416d898e669dbc4620f0aa9140e15f706bc Mon Sep 17 00:00:00 2001 From: Erik Eelde Date: Thu, 4 Jan 2018 00:19:56 +0100 Subject: [PATCH] Fix incompatibility with old prefs-libraries --- .../wrench/provider/WrenchProvider.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/wrench-app/src/main/java/com/izettle/wrench/provider/WrenchProvider.java b/wrench-app/src/main/java/com/izettle/wrench/provider/WrenchProvider.java index 88c1958..0600e5d 100644 --- a/wrench-app/src/main/java/com/izettle/wrench/provider/WrenchProvider.java +++ b/wrench-app/src/main/java/com/izettle/wrench/provider/WrenchProvider.java @@ -255,6 +255,8 @@ public Uri insert(@NonNull Uri uri, ContentValues values) { case CURRENT_CONFIGURATIONS: { Bolt bolt = Bolt.fromContentValues(values); + bolt = fixRCTypes(bolt); + WrenchConfiguration wrenchConfiguration = configurationDao.getWrenchConfiguration(callingApplication.id(), bolt.getKey()); if (wrenchConfiguration == null) { @@ -290,6 +292,23 @@ public Uri insert(@NonNull Uri uri, ContentValues values) { return ContentUris.withAppendedId(uri, insertId); } + private Bolt fixRCTypes(Bolt bolt) { + switch (bolt.getType()) { + case "java.lang.String": + return bolt.copy(bolt.getId(), Bolt.TYPE.STRING, bolt.getKey(), bolt.getValue()); + case "java.lang.Integer": + return bolt.copy(bolt.getId(), Bolt.TYPE.INTEGER, bolt.getKey(), bolt.getValue()); + case "java.lang.Enum": + return bolt.copy(bolt.getId(), Bolt.TYPE.ENUM, bolt.getKey(), bolt.getValue()); + case "java.lang.Boolean": + return bolt.copy(bolt.getId(), Bolt.TYPE.BOOLEAN, bolt.getKey(), bolt.getValue()); + default: { + return bolt; + } + + } + } + @Override public int bulkInsert(@NonNull Uri uri, @NonNull ContentValues[] values) { WrenchApplication callingApplication = getCallingApplication(getContext(), applicationDao);