Changeset View
Changeset View
Standalone View
Standalone View
src/org/kde/kdeconnect/Plugins/SharePlugin/SharePlugin.java
Show First 20 Lines • Show All 276 Lines • ▼ Show 20 Line(s) | 61 | public class SharePlugin extends Plugin { | |||
---|---|---|---|---|---|
277 | @Override | 277 | @Override | ||
278 | public void startPreferencesActivity(DeviceSettingsActivity parentActivity) { | 278 | public void startPreferencesActivity(DeviceSettingsActivity parentActivity) { | ||
279 | Intent intent = new Intent(parentActivity, ShareSettingsActivity.class); | 279 | Intent intent = new Intent(parentActivity, ShareSettingsActivity.class); | ||
280 | intent.putExtra("plugin_display_name", getDisplayName()); | 280 | intent.putExtra("plugin_display_name", getDisplayName()); | ||
281 | intent.putExtra("plugin_key", getPluginKey()); | 281 | intent.putExtra("plugin_key", getPluginKey()); | ||
282 | parentActivity.startActivity(intent); | 282 | parentActivity.startActivity(intent); | ||
283 | } | 283 | } | ||
284 | 284 | | |||
285 | static void queuedSendUriList(Context context, final Device device, final ArrayList<Uri> uriList) { | 285 | void queuedSendUriList(final ArrayList<Uri> uriList) { | ||
286 | 286 | | |||
287 | //Read all the data early, as we only have permissions to do it while the activity is alive | 287 | //Read all the data early, as we only have permissions to do it while the activity is alive | ||
288 | final ArrayList<NetworkPacket> toSend = new ArrayList<>(); | 288 | final ArrayList<NetworkPacket> toSend = new ArrayList<>(); | ||
289 | for (Uri uri : uriList) { | 289 | for (Uri uri : uriList) { | ||
290 | toSend.add(uriToNetworkPacket(context, uri)); | 290 | toSend.add(uriToNetworkPacket(context, uri)); | ||
291 | } | 291 | } | ||
292 | 292 | | |||
293 | //Callback that shows a progress notification | 293 | //Callback that shows a progress notification | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 317 | try { | |||
383 | return np; | 383 | return np; | ||
384 | } catch (Exception e) { | 384 | } catch (Exception e) { | ||
385 | Log.e("SendFileActivity", "Exception sending files"); | 385 | Log.e("SendFileActivity", "Exception sending files"); | ||
386 | e.printStackTrace(); | 386 | e.printStackTrace(); | ||
387 | return null; | 387 | return null; | ||
388 | } | 388 | } | ||
389 | } | 389 | } | ||
390 | 390 | | |||
391 | public static void share(Intent intent, Device device) { | 391 | public void share(Intent intent) { | ||
392 | Bundle extras = intent.getExtras(); | 392 | Bundle extras = intent.getExtras(); | ||
393 | if (extras != null) { | 393 | if (extras != null) { | ||
394 | if (extras.containsKey(Intent.EXTRA_STREAM)) { | 394 | if (extras.containsKey(Intent.EXTRA_STREAM)) { | ||
395 | 395 | | |||
396 | try { | 396 | try { | ||
397 | 397 | | |||
398 | ArrayList<Uri> uriList; | 398 | ArrayList<Uri> uriList; | ||
399 | if (!Intent.ACTION_SEND.equals(intent.getAction())) { | 399 | if (!Intent.ACTION_SEND.equals(intent.getAction())) { | ||
400 | uriList = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); | 400 | uriList = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); | ||
401 | } else { | 401 | } else { | ||
402 | Uri uri = extras.getParcelable(Intent.EXTRA_STREAM); | 402 | Uri uri = extras.getParcelable(Intent.EXTRA_STREAM); | ||
403 | uriList = new ArrayList<>(); | 403 | uriList = new ArrayList<>(); | ||
404 | uriList.add(uri); | 404 | uriList.add(uri); | ||
405 | } | 405 | } | ||
406 | 406 | | |||
407 | SharePlugin.queuedSendUriList(device.getContext(), device, uriList); | 407 | queuedSendUriList(uriList); | ||
408 | 408 | | |||
409 | } catch (Exception e) { | 409 | } catch (Exception e) { | ||
410 | Log.e("ShareActivity", "Exception"); | 410 | Log.e("ShareActivity", "Exception"); | ||
411 | e.printStackTrace(); | 411 | e.printStackTrace(); | ||
412 | } | 412 | } | ||
413 | 413 | | |||
414 | } else if (extras.containsKey(Intent.EXTRA_TEXT)) { | 414 | } else if (extras.containsKey(Intent.EXTRA_TEXT)) { | ||
415 | String text = extras.getString(Intent.EXTRA_TEXT); | 415 | String text = extras.getString(Intent.EXTRA_TEXT); | ||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |