Changeset View
Changeset View
Standalone View
Standalone View
src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java
Show First 20 Lines • Show All 198 Lines • ▼ Show 20 Line(s) | 198 | private void receiveFile(NetworkPacket np) { | |||
---|---|---|---|---|---|
199 | if (finishReceivingRunnable != null) { | 199 | if (finishReceivingRunnable != null) { | ||
200 | Log.i("SharePlugin", "receiveFile: canceling finishReceivingRunnable"); | 200 | Log.i("SharePlugin", "receiveFile: canceling finishReceivingRunnable"); | ||
201 | handler.removeCallbacks(finishReceivingRunnable); | 201 | handler.removeCallbacks(finishReceivingRunnable); | ||
202 | finishReceivingRunnable = null; | 202 | finishReceivingRunnable = null; | ||
203 | } | 203 | } | ||
204 | 204 | | |||
205 | ShareInfo info = new ShareInfo(); | 205 | ShareInfo info = new ShareInfo(); | ||
206 | info.currentFileNumber = currentShareInfo == null ? 1 : currentShareInfo.currentFileNumber + 1; | 206 | info.currentFileNumber = currentShareInfo == null ? 1 : currentShareInfo.currentFileNumber + 1; | ||
207 | info.inputStream = np.getPayload(); | 207 | info.payload = np.getPayload(); | ||
208 | info.fileSize = np.getPayloadSize(); | 208 | info.fileSize = np.getPayloadSize(); | ||
209 | info.fileName = np.getString("filename", Long.toString(System.currentTimeMillis())); | 209 | info.fileName = np.getString("filename", Long.toString(System.currentTimeMillis())); | ||
210 | info.shouldOpen = np.getBoolean("open"); | 210 | info.shouldOpen = np.getBoolean("open"); | ||
211 | info.setNumberOfFiles(np.getInt("numberOfFiles", 1)); | 211 | info.setNumberOfFiles(np.getInt("numberOfFiles", 1)); | ||
212 | info.setTotalTransferSize(np.getLong("totalPayloadSize", 1)); | 212 | info.setTotalTransferSize(np.getLong("totalPayloadSize", 1)); | ||
213 | 213 | | |||
214 | if (currentShareInfo == null) { | 214 | if (currentShareInfo == null) { | ||
215 | currentShareInfo = info; | 215 | currentShareInfo = info; | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 266 | public void startPreferencesActivity(DeviceSettingsActivity parentActivity) { | |||
270 | parentActivity.startActivity(intent); | 270 | parentActivity.startActivity(intent); | ||
271 | } | 271 | } | ||
272 | 272 | | |||
273 | void queuedSendUriList(final ArrayList<Uri> uriList) { | 273 | void queuedSendUriList(final ArrayList<Uri> uriList) { | ||
274 | 274 | | |||
275 | //Read all the data early, as we only have permissions to do it while the activity is alive | 275 | //Read all the data early, as we only have permissions to do it while the activity is alive | ||
276 | final ArrayList<NetworkPacket> toSend = new ArrayList<>(); | 276 | final ArrayList<NetworkPacket> toSend = new ArrayList<>(); | ||
277 | for (Uri uri : uriList) { | 277 | for (Uri uri : uriList) { | ||
278 | //TODO: This can add null NetworkPackets and that makes things go boooom | ||||
278 | toSend.add(uriToNetworkPacket(context, uri)); | 279 | toSend.add(uriToNetworkPacket(context, uri)); | ||
279 | } | 280 | } | ||
280 | 281 | | |||
281 | //Callback that shows a progress notification | 282 | //Callback that shows a progress notification | ||
282 | final NotificationUpdateCallback notificationUpdateCallback = new NotificationUpdateCallback(context, device, toSend); | 283 | final NotificationUpdateCallback notificationUpdateCallback = new NotificationUpdateCallback(context, device, toSend); | ||
283 | 284 | | |||
284 | //Do the sending in background | 285 | //Do the sending in background | ||
285 | new Thread(() -> { | 286 | new Thread(() -> { | ||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | 361 | } finally { | |||
361 | try { | 362 | try { | ||
362 | cursor.close(); | 363 | cursor.close(); | ||
363 | } catch (Exception e) { | 364 | } catch (Exception e) { | ||
364 | } | 365 | } | ||
365 | } | 366 | } | ||
366 | 367 | | |||
367 | } | 368 | } | ||
368 | 369 | | |||
369 | np.setPayload(inputStream, size); | 370 | np.setPayload(new NetworkPacket.Payload(inputStream, size)); | ||
370 | 371 | | |||
371 | return np; | 372 | return np; | ||
372 | } catch (Exception e) { | 373 | } catch (Exception e) { | ||
373 | Log.e("SendFileActivity", "Exception sending files"); | 374 | Log.e("SendFileActivity", "Exception sending files"); | ||
374 | e.printStackTrace(); | 375 | e.printStackTrace(); | ||
375 | return null; | 376 | return null; | ||
376 | } | 377 | } | ||
377 | } | 378 | } | ||
▲ Show 20 Lines • Show All 158 Lines • Show Last 20 Lines |