2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-31 06:05:12 +00:00

Added a send to activity (untested at all)

This commit is contained in:
Albert Vaca
2013-09-18 17:31:56 +02:00
parent aabd06f5cb
commit 0d8f84037b
3 changed files with 69 additions and 0 deletions

View File

@@ -117,6 +117,18 @@
android:value="org.kde.kdeconnect.UserInterface.DeviceActivity" />
</activity>
<activity
android:theme="@style/Theme.AppCompat"
android:name="org.kde.kdeconnect.Plugins.FileTransferPlugin.ShareToReceiver"
android:label="@string/share_to"
>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
<service android:name="org.kde.kdeconnect.Plugins.NotificationsPlugin.NotificationReceiver"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>

View File

@@ -0,0 +1,55 @@
package org.kde.kdeconnect.Plugins.FileTransferPlugin;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import org.apache.mina.util.Base64;
import java.io.InputStream;
public class ShareToReceiver extends Activity {
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Intent intent = getIntent();
Bundle extras = intent.getExtras();
String action = intent.getAction();
// if this is from the share menu
if (Intent.ACTION_SEND.equals(action))
{
if (extras.containsKey(Intent.EXTRA_STREAM))
{
try
{
// Get resource path from intent callee
Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
// Query gallery for camera picture via
// Android ContentResolver interface
ContentResolver cr = getContentResolver();
InputStream inputStream = cr.openInputStream(uri);
//TODO: Send inputStream as payload
return;
} catch (Exception e)
{
Log.e(this.getClass().getName(), e.toString());
}
} else if (extras.containsKey(Intent.EXTRA_TEXT))
{
//TODO: Send text
return;
}
}
}
}

View File

@@ -52,5 +52,7 @@
<string name="mpris_previous">Previous</string>
<string name="mpris_next">Next</string>
<string name="mpris_volume">Volume</string>
<string name="share_to">Share To...</string>
</resources>