diff --git a/res/values-ru/translatable.xml b/res/values-ru/translatable.xml index 053ece1a..dcd257f5 100644 --- a/res/values-ru/translatable.xml +++ b/res/values-ru/translatable.xml @@ -255,6 +255,9 @@ %d лучших Vanilla Music необходимо разрешение на чтение, чтобы отобразить Вашу музыку в фонотеке в обратном порядке + Поделиться… + Отправить… + Нет подходящих приложений для отправки! Запуск сканирования в Vanilla Music приведёт к перестройке всей базы медиаданных. Начать сканирование diff --git a/res/values/translatable.xml b/res/values/translatable.xml index a8db2288..8b8442a9 100644 --- a/res/values/translatable.xml +++ b/res/values/translatable.xml @@ -171,7 +171,7 @@ THE SOFTWARE. Songs without ReplayGain tag Decrease volume by Note - Android does not allow Vanilla Music to raise the volume to >100%. Setting the Pre-amp to a high value may cause issues if you are listening to \'quiet\' music. \n\nRecommended values are:\n-> -3dB for silent/classical music\n-> +3dB for post-2000 recordings + Android does not allow Vanilla Music to raise the volume to >100%. Setting the Pre-amp to a high value may cause issues if you are listening to \'quiet\' music. \n\nRecommended values are:\n-> -3dB for silent/classical music\n-> +3dB for post-2000 recordings Enable readahead Readahead the currently playing song. This option may solve \'audio dropout\' issues. (caused by a slow SD card) @@ -298,6 +298,10 @@ THE SOFTWARE. Vanilla Music needs read permission to display your music library Reverse sort + Share… + Send to… + No receiving apps found for this media type! + Starting a rescan causes Vanilla Music to trigger a full rebuild of the media database. Start Rescan diff --git a/src/ch/blinkenlights/android/vanilla/FullPlaybackActivity.java b/src/ch/blinkenlights/android/vanilla/FullPlaybackActivity.java index 57c02e69..07b8a888 100644 --- a/src/ch/blinkenlights/android/vanilla/FullPlaybackActivity.java +++ b/src/ch/blinkenlights/android/vanilla/FullPlaybackActivity.java @@ -307,6 +307,7 @@ public class FullPlaybackActivity extends SlidingPlaybackActivity menu.add(0, MENU_ENQUEUE_ARTIST, 30, R.string.enqueue_current_artist); menu.add(0, MENU_ENQUEUE_GENRE, 30, R.string.enqueue_current_genre); menu.add(0, MENU_ADD_TO_PLAYLIST, 30, R.string.add_to_playlist); + menu.add(0, MENU_SHARE, 30, R.string.share); mFavorites = menu.add(0, MENU_SONG_FAVORITE, 0, R.string.add_to_favorites).setIcon(R.drawable.btn_rating_star_off_mtrl_alpha).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM); // ensure that mFavorites is updated @@ -352,6 +353,9 @@ public class FullPlaybackActivity extends SlidingPlaybackActivity dialog.show(getFragmentManager(), "PlaylistDialog"); } break; + case MENU_SHARE: + MediaUtils.shareMedia(FullPlaybackActivity.this, MediaUtils.TYPE_SONG, song.id); + break; case MENU_DELETE: final PlaybackService playbackService = PlaybackService.get(this); final PlaybackActivity activity = this; diff --git a/src/ch/blinkenlights/android/vanilla/MediaUtils.java b/src/ch/blinkenlights/android/vanilla/MediaUtils.java index c1fa48bf..eb95598d 100644 --- a/src/ch/blinkenlights/android/vanilla/MediaUtils.java +++ b/src/ch/blinkenlights/android/vanilla/MediaUtils.java @@ -33,7 +33,11 @@ import java.util.Vector; import java.util.zip.CRC32; import junit.framework.Assert; + +import android.content.ActivityNotFoundException; import android.content.ContentResolver; +import android.content.Context; +import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Environment; @@ -42,6 +46,7 @@ import android.text.TextUtils; import android.database.MatrixCursor; import android.media.MediaMetadataRetriever; import android.util.Log; +import android.widget.Toast; /** @@ -504,6 +509,40 @@ public class MediaUtils { sAllSongs = null; } + /** + * Creates and sends share intent across the system. Includes all eligible songs found + * within this type and id (e.g. all songs in album, all songs for this artist etc.) + * @param ctx context to execute resolving on + * @param type media type to look for e.g. {@link MediaUtils#TYPE_SONG} + * @param id id of item to send + */ + public static void shareMedia(Context ctx, int type, long id) { + if (type == TYPE_INVALID || id <= 0) { // invalid + return; + } + + ContentResolver resolver = ctx.getContentResolver(); + String[] projection = new String [] { MediaStore.Audio.Media._ID, MediaStore.Audio.Media.DATA }; + Cursor cursor = buildQuery(type, id, projection, null).runQuery(resolver); + if(cursor == null) { + return; + } + + try { + while (cursor.moveToNext()) { // for all songs resolved... + File songFile = new File(cursor.getString(1)); + Intent share = new Intent(Intent.ACTION_SEND); + share.setType("audio/*"); + share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(songFile)); + ctx.startActivity(Intent.createChooser(share, ctx.getResources().getString(R.string.sendto))); + } + } catch (ActivityNotFoundException ex) { + Toast.makeText(ctx, R.string.no_receiving_apps, Toast.LENGTH_SHORT).show(); + } finally { + cursor.close(); + } + } + /** * Returns the first matching song (or NULL) of given type + id combination * diff --git a/src/ch/blinkenlights/android/vanilla/PlaybackActivity.java b/src/ch/blinkenlights/android/vanilla/PlaybackActivity.java index 0f543481..a669664d 100644 --- a/src/ch/blinkenlights/android/vanilla/PlaybackActivity.java +++ b/src/ch/blinkenlights/android/vanilla/PlaybackActivity.java @@ -375,6 +375,7 @@ public abstract class PlaybackActivity extends Activity static final int MENU_DELETE = 16; static final int MENU_EMPTY_QUEUE = 17; static final int MENU_ADD_TO_PLAYLIST = 18; + static final int MENU_SHARE = 19; @Override public boolean onCreateOptionsMenu(Menu menu)