From 0ba25696981a4c4d5aef01e4a1d683c8adf7522a Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Wed, 16 Sep 2015 22:57:49 +0200 Subject: add charset to OpenPgpMetadata parcel --- .../org/openintents/openpgp/OpenPgpMetadata.java | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/openpgp-api/src/main/java/org/openintents/openpgp/OpenPgpMetadata.java b/openpgp-api/src/main/java/org/openintents/openpgp/OpenPgpMetadata.java index 8b3a3bb..0d766c7 100644 --- a/openpgp-api/src/main/java/org/openintents/openpgp/OpenPgpMetadata.java +++ b/openpgp-api/src/main/java/org/openintents/openpgp/OpenPgpMetadata.java @@ -25,10 +25,11 @@ public class OpenPgpMetadata implements Parcelable { * old versions of the protocol (and thus old versions of this class), we need a versioning * system for the parcels sent between the clients and the providers. */ - public static final int PARCELABLE_VERSION = 1; + public static final int PARCELABLE_VERSION = 2; String filename; String mimeType; + String charset; long modificationTime; long originalSize; @@ -48,9 +49,22 @@ public class OpenPgpMetadata implements Parcelable { return originalSize; } + public String getCharset() { + return charset; + } + public OpenPgpMetadata() { } + public OpenPgpMetadata(String filename, String mimeType, long modificationTime, + long originalSize, String charset) { + this.filename = filename; + this.mimeType = mimeType; + this.modificationTime = modificationTime; + this.originalSize = originalSize; + this.charset = charset; + } + public OpenPgpMetadata(String filename, String mimeType, long modificationTime, long originalSize) { this.filename = filename; @@ -86,6 +100,8 @@ public class OpenPgpMetadata implements Parcelable { dest.writeString(mimeType); dest.writeLong(modificationTime); dest.writeLong(originalSize); + // version 2 + dest.writeString(charset); // Go back and write the size int parcelableSize = dest.dataPosition() - startPosition; dest.setDataPosition(sizePosition); @@ -95,7 +111,7 @@ public class OpenPgpMetadata implements Parcelable { public static final Creator CREATOR = new Creator() { public OpenPgpMetadata createFromParcel(final Parcel source) { - source.readInt(); // parcelableVersion + int version = source.readInt(); // parcelableVersion int parcelableSize = source.readInt(); int startPosition = source.dataPosition(); @@ -104,6 +120,9 @@ public class OpenPgpMetadata implements Parcelable { vr.mimeType = source.readString(); vr.modificationTime = source.readLong(); vr.originalSize = source.readLong(); + if (version >= 2) { + vr.charset = source.readString(); + } // skip over all fields added in future versions of this parcel source.setDataPosition(startPosition + parcelableSize); @@ -122,6 +141,7 @@ public class OpenPgpMetadata implements Parcelable { out += "\nmimeType: " + mimeType; out += "\nmodificationTime: " + modificationTime; out += "\noriginalSize: " + originalSize; + out += "\ncharset: " + charset; return out; } -- cgit v1.2.3