mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-03 23:55:08 +00:00
Payload sizes are now longs instead of ints
This commit is contained in:
@@ -66,7 +66,7 @@ public class NetworkPackage {
|
|||||||
private JSONObject mBody;
|
private JSONObject mBody;
|
||||||
private InputStream mPayload;
|
private InputStream mPayload;
|
||||||
private JSONObject mPayloadTransferInfo;
|
private JSONObject mPayloadTransferInfo;
|
||||||
private int mPayloadSize;
|
private long mPayloadSize;
|
||||||
|
|
||||||
private NetworkPackage() {
|
private NetworkPackage() {
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ public class NetworkPackage {
|
|||||||
np.mBody = jo.getJSONObject("body");
|
np.mBody = jo.getJSONObject("body");
|
||||||
if (jo.has("payloadSize")) {
|
if (jo.has("payloadSize")) {
|
||||||
np.mPayloadTransferInfo = jo.getJSONObject("payloadTransferInfo");
|
np.mPayloadTransferInfo = jo.getJSONObject("payloadTransferInfo");
|
||||||
np.mPayloadSize = jo.getInt("payloadSize");
|
np.mPayloadSize = jo.getLong("payloadSize");
|
||||||
} else {
|
} else {
|
||||||
np.mPayloadTransferInfo = new JSONObject();
|
np.mPayloadTransferInfo = new JSONObject();
|
||||||
np.mPayloadSize = 0;
|
np.mPayloadSize = 0;
|
||||||
@@ -277,7 +277,7 @@ public class NetworkPackage {
|
|||||||
setPayload(new ByteArrayInputStream(data), data.length);
|
setPayload(new ByteArrayInputStream(data), data.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPayload(InputStream stream, int size) {
|
public void setPayload(InputStream stream, long size) {
|
||||||
mPayload = stream;
|
mPayload = stream;
|
||||||
mPayloadSize = size;
|
mPayloadSize = size;
|
||||||
}
|
}
|
||||||
@@ -290,7 +290,7 @@ public class NetworkPackage {
|
|||||||
return mPayload;
|
return mPayload;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPayloadSize() {
|
public long getPayloadSize() {
|
||||||
return mPayloadSize;
|
return mPayloadSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -106,7 +106,7 @@ public class SharePlugin extends Plugin {
|
|||||||
Log.e("SharePlugin", "hasPayload");
|
Log.e("SharePlugin", "hasPayload");
|
||||||
|
|
||||||
final InputStream input = np.getPayload();
|
final InputStream input = np.getPayload();
|
||||||
final int fileLength = np.getPayloadSize();
|
final long fileLength = np.getPayloadSize();
|
||||||
final String filename = np.getString("filename", new Long(System.currentTimeMillis()).toString());
|
final String filename = np.getString("filename", new Long(System.currentTimeMillis()).toString());
|
||||||
|
|
||||||
String deviceDir = FilesHelper.toFileSystemSafeName(device.getName());
|
String deviceDir = FilesHelper.toFileSystemSafeName(device.getName());
|
||||||
|
@@ -211,7 +211,7 @@ public class ShareToReceiver extends ActionBarActivity {
|
|||||||
InputStream inputStream = cr.openInputStream(uri);
|
InputStream inputStream = cr.openInputStream(uri);
|
||||||
|
|
||||||
NetworkPackage np = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_SHARE);
|
NetworkPackage np = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_SHARE);
|
||||||
int size = -1;
|
long size = -1;
|
||||||
|
|
||||||
final NotificationManager notificationManager = (NotificationManager)getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
final NotificationManager notificationManager = (NotificationManager)getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
final int notificationId = (int)System.currentTimeMillis();
|
final int notificationId = (int)System.currentTimeMillis();
|
||||||
@@ -234,7 +234,7 @@ public class ShareToReceiver extends ActionBarActivity {
|
|||||||
np.set("filename", uri.getLastPathSegment());
|
np.set("filename", uri.getLastPathSegment());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
size = (int)new File(uri.getPath()).length();
|
size = new File(uri.getPath()).length();
|
||||||
np.setPayload(inputStream, size);
|
np.setPayload(inputStream, size);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -252,7 +252,7 @@ public class ShareToReceiver extends ActionBarActivity {
|
|||||||
cursor.moveToFirst();
|
cursor.moveToFirst();
|
||||||
String path = cursor.getString(column_index);
|
String path = cursor.getString(column_index);
|
||||||
np.set("filename", Uri.parse(path).getLastPathSegment());
|
np.set("filename", Uri.parse(path).getLastPathSegment());
|
||||||
size = (int)new File(path).length();
|
size = new File(path).length();
|
||||||
} catch(Exception unused) {
|
} catch(Exception unused) {
|
||||||
|
|
||||||
Log.e("ShareToReceiver", "Could not resolve media to a file, trying to get info as media");
|
Log.e("ShareToReceiver", "Could not resolve media to a file, trying to get info as media");
|
||||||
@@ -284,7 +284,7 @@ public class ShareToReceiver extends ActionBarActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final long filesize = size;
|
final long fileSize = size;
|
||||||
final String filename = np.getString("filename");
|
final String filename = np.getString("filename");
|
||||||
|
|
||||||
builder.setContentText(res.getString(R.string.outgoing_file_text,filename));
|
builder.setContentText(res.getString(R.string.outgoing_file_text,filename));
|
||||||
|
Reference in New Issue
Block a user