Allow to publish files via Send To feature #967

Merged
kekkyojin merged 1 commit from sendto-feat into master 2020-07-29 16:20:59 +02:00
2 changed files with 28 additions and 0 deletions

View file

@ -50,6 +50,13 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="video/*" />
<data android:mimeType="image/*" />
<data android:mimeType="text/*" />
</intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />

View file

@ -8,6 +8,7 @@ import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.PictureInPictureParams; import android.app.PictureInPictureParams;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.ClipData;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -579,6 +580,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
protected void onNewIntent(Intent intent) { protected void onNewIntent(Intent intent) {
super.onNewIntent(intent); super.onNewIntent(intent);
checkSendToIntent(intent);
checkUrlIntent(intent); checkUrlIntent(intent);
checkNotificationOpenIntent(intent); checkNotificationOpenIntent(intent);
} }
@ -833,6 +835,12 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
openFragment(FileViewFragment.class, true, NavMenuItem.ID_ITEM_FOLLOWING, params); openFragment(FileViewFragment.class, true, NavMenuItem.ID_ITEM_FOLLOWING, params);
} }
public void openSendTo(String path) {
Map<String, Object> params = new HashMap<>();
params.put("directFilePath", path);
openFragment(PublishFormFragment.class, true, NavMenuItem.ID_ITEM_NEW_PUBLISH, params);
}
public void openFileClaim(Claim claim) { public void openFileClaim(Claim claim) {
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("claimId", claim.getClaimId()); params.put("claimId", claim.getClaimId());
@ -2644,6 +2652,19 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
LbryAnalytics.logEvent(LbryAnalytics.EVENT_LBRY_NOTIFICATION_OPEN, bundle); LbryAnalytics.logEvent(LbryAnalytics.EVENT_LBRY_NOTIFICATION_OPEN, bundle);
} }
private void checkSendToIntent(Intent intent) {
String intentAction = intent.getAction();
if (intentAction != null && intentAction.equals("android.intent.action.SEND")) {
ClipData clipData = intent.getClipData();
if (clipData != null) {
Uri uri = clipData.getItemAt(0).getUri();
String path = Helper.getRealPathFromURI_API19(this, uri);
openSendTo(path);
}
}
}
private void registerServiceActionsReceiver() { private void registerServiceActionsReceiver() {
IntentFilter intentFilter = new IntentFilter(); IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(DownloadManager.ACTION_DOWNLOAD_EVENT); intentFilter.addAction(DownloadManager.ACTION_DOWNLOAD_EVENT);