mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 10:35:19 +00:00
parent
060bed8559
commit
1c47812877
@ -35,26 +35,26 @@ final class DataMigrator {
|
|||||||
builder.putString(entry.getKey(), (String) value);
|
builder.putString(entry.getKey(), (String) value);
|
||||||
} else if (type == String[].class) {
|
} else if (type == String[].class) {
|
||||||
builder.putStringArray(entry.getKey(), (String[]) value);
|
builder.putStringArray(entry.getKey(), (String[]) value);
|
||||||
} else if (type == Integer.class) {
|
} else if (type == Integer.class || type == int.class) {
|
||||||
builder.putInt(entry.getKey(), (int) value);
|
builder.putInt(entry.getKey(), (int) value);
|
||||||
} else if (type == int[].class) {
|
} else if (type == Integer[].class || type == int[].class) {
|
||||||
builder.putIntArray(entry.getKey(), (int[]) value);
|
builder.putIntArray(entry.getKey(), convertToIntArray(value, type));
|
||||||
} else if (type == Long.class) {
|
} else if (type == Long.class || type == long.class) {
|
||||||
builder.putLong(entry.getKey(), (long) value);
|
builder.putLong(entry.getKey(), (long) value);
|
||||||
} else if (type == long[].class) {
|
} else if (type == Long[].class || type == long[].class) {
|
||||||
builder.putLongArray(entry.getKey(), (long[]) value);
|
builder.putLongArray(entry.getKey(), convertToLongArray(value, type));
|
||||||
} else if (type == Float.class) {
|
} else if (type == Float.class || type == float.class) {
|
||||||
builder.putFloat(entry.getKey(), (float) value);
|
builder.putFloat(entry.getKey(), (float) value);
|
||||||
} else if (type == float[].class) {
|
} else if (type == Float[].class || type == float[].class) {
|
||||||
builder.putFloatArray(entry.getKey(), (float[]) value);
|
builder.putFloatArray(entry.getKey(), convertToFloatArray(value, type));
|
||||||
} else if (type == Double.class) {
|
} else if (type == Double.class || type == double.class) {
|
||||||
builder.putDouble(entry.getKey(), (double) value);
|
builder.putDouble(entry.getKey(), (double) value);
|
||||||
} else if (type == double[].class) {
|
} else if (type == Double[].class || type == double[].class) {
|
||||||
builder.putDoubleArray(entry.getKey(), (double[]) value);
|
builder.putDoubleArray(entry.getKey(), convertToDoubleArray(value, type));
|
||||||
} else if (type == Boolean.class) {
|
} else if (type == Boolean.class || type == boolean.class) {
|
||||||
builder.putBoolean(entry.getKey(), (boolean) value);
|
builder.putBoolean(entry.getKey(), (boolean) value);
|
||||||
} else if (type == boolean[].class) {
|
} else if (type == Boolean[].class || type == boolean[].class) {
|
||||||
builder.putBooleanArray(entry.getKey(), (boolean[]) value);
|
builder.putBooleanArray(entry.getKey(), convertToBooleanArray(value, type));
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "Encountered unexpected type '" + type + "'. Skipping.");
|
Log.w(TAG, "Encountered unexpected type '" + type + "'. Skipping.");
|
||||||
}
|
}
|
||||||
@ -90,5 +90,80 @@ final class DataMigrator {
|
|||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int[] convertToIntArray(Object value, Class type) {
|
||||||
|
if (type == int[].class) {
|
||||||
|
return (int[]) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer[] casted = (Integer[]) value;
|
||||||
|
int[] output = new int[casted.length];
|
||||||
|
|
||||||
|
for (int i = 0; i < casted.length; i++) {
|
||||||
|
output[i] = casted[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static long[] convertToLongArray(Object value, Class type) {
|
||||||
|
if (type == long[].class) {
|
||||||
|
return (long[]) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
Long[] casted = (Long[]) value;
|
||||||
|
long[] output = new long[casted.length];
|
||||||
|
|
||||||
|
for (int i = 0; i < casted.length; i++) {
|
||||||
|
output[i] = casted[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static float[] convertToFloatArray(Object value, Class type) {
|
||||||
|
if (type == float[].class) {
|
||||||
|
return (float[]) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
Float[] casted = (Float[]) value;
|
||||||
|
float[] output = new float[casted.length];
|
||||||
|
|
||||||
|
for (int i = 0; i < casted.length; i++) {
|
||||||
|
output[i] = casted[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double[] convertToDoubleArray(Object value, Class type) {
|
||||||
|
if (type == double[].class) {
|
||||||
|
return (double[]) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
Double[] casted = (Double[]) value;
|
||||||
|
double[] output = new double[casted.length];
|
||||||
|
|
||||||
|
for (int i = 0; i < casted.length; i++) {
|
||||||
|
output[i] = casted[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean[] convertToBooleanArray(Object value, Class type) {
|
||||||
|
if (type == boolean[].class) {
|
||||||
|
return (boolean[]) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
Boolean[] casted = (Boolean[]) value;
|
||||||
|
boolean[] output = new boolean[casted.length];
|
||||||
|
|
||||||
|
for (int i = 0; i < casted.length; i++) {
|
||||||
|
output[i] = casted[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public class SendReadReceiptJob extends BaseJob implements InjectableType {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRun() throws IOException, UntrustedIdentityException {
|
public void onRun() throws IOException, UntrustedIdentityException {
|
||||||
if (!TextSecurePreferences.isReadReceiptsEnabled(context)) return;
|
if (!TextSecurePreferences.isReadReceiptsEnabled(context) || messageIds.isEmpty()) return;
|
||||||
|
|
||||||
SignalServiceAddress remoteAddress = new SignalServiceAddress(address);
|
SignalServiceAddress remoteAddress = new SignalServiceAddress(address);
|
||||||
SignalServiceReceiptMessage receiptMessage = new SignalServiceReceiptMessage(SignalServiceReceiptMessage.Type.READ, messageIds, timestamp);
|
SignalServiceReceiptMessage receiptMessage = new SignalServiceReceiptMessage(SignalServiceReceiptMessage.Type.READ, messageIds, timestamp);
|
||||||
@ -110,7 +110,7 @@ public class SendReadReceiptJob extends BaseJob implements InjectableType {
|
|||||||
public @NonNull SendReadReceiptJob create(@NonNull Parameters parameters, @NonNull Data data) {
|
public @NonNull SendReadReceiptJob create(@NonNull Parameters parameters, @NonNull Data data) {
|
||||||
Address address = Address.fromSerialized(data.getString(KEY_ADDRESS));
|
Address address = Address.fromSerialized(data.getString(KEY_ADDRESS));
|
||||||
long timestamp = data.getLong(KEY_TIMESTAMP);
|
long timestamp = data.getLong(KEY_TIMESTAMP);
|
||||||
long[] ids = data.getLongArray(KEY_MESSAGE_IDS);
|
long[] ids = data.hasLongArray(KEY_MESSAGE_IDS) ? data.getLongArray(KEY_MESSAGE_IDS) : new long[0];
|
||||||
List<Long> messageIds = new ArrayList<>(ids.length);
|
List<Long> messageIds = new ArrayList<>(ids.length);
|
||||||
|
|
||||||
for (long id : ids) {
|
for (long id : ids) {
|
||||||
|
Loading…
Reference in New Issue
Block a user