Merge pull request #4721 from tonytamsf/share-by-timecode

share by timecode
This commit is contained in:
ByteHamster 2020-11-30 20:00:18 +01:00 committed by GitHub
commit d20557c1b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 68 additions and 65 deletions

View File

@ -21,7 +21,8 @@ import de.danoeh.antennapod.core.feed.FeedMedia;
public class ShareUtils { public class ShareUtils {
private static final String TAG = "ShareUtils"; private static final String TAG = "ShareUtils";
private ShareUtils() {} private ShareUtils() {
}
public static void shareLink(Context context, String text) { public static void shareLink(Context context, String text) {
Intent i = new Intent(Intent.ACTION_SEND); Intent i = new Intent(Intent.ACTION_SEND);
@ -67,6 +68,7 @@ public class ShareUtils {
String text = getItemShareText(item) + " " + item.getMedia().getDownload_url(); String text = getItemShareText(item) + " " + item.getMedia().getDownload_url();
if (withPosition) { if (withPosition) {
int pos = item.getMedia().getPosition(); int pos = item.getMedia().getPosition();
text += "#t=" + pos / 1000;
text += " [" + Converter.getDurationStringLong(pos) + "]"; text += " [" + Converter.getDurationStringLong(pos) + "]";
} }
shareLink(context, text); shareLink(context, text);
@ -80,7 +82,8 @@ public class ShareUtils {
i.putExtra(Intent.EXTRA_STREAM, fileUri); i.putExtra(Intent.EXTRA_STREAM, fileUri);
i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
List<ResolveInfo> resInfoList = context.getPackageManager().queryIntentActivities(i, PackageManager.MATCH_DEFAULT_ONLY); List<ResolveInfo> resInfoList = context.getPackageManager()
.queryIntentActivities(i, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo resolveInfo : resInfoList) { for (ResolveInfo resolveInfo : resInfoList) {
String packageName = resolveInfo.activityInfo.packageName; String packageName = resolveInfo.activityInfo.packageName;
context.grantUriPermission(packageName, fileUri, Intent.FLAG_GRANT_READ_URI_PERMISSION); context.grantUriPermission(packageName, fileUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);