Search in sources :

Example 1 with SleepTimerDialog

use of com.kabouzeid.gramophone.dialogs.SleepTimerDialog in project Phonograph by kabouzeid.

the class AlbumDetailActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
    int id = item.getItemId();
    final List<Song> songs = adapter.getDataSet();
    switch(id) {
        case R.id.action_sleep_timer:
            new SleepTimerDialog().show(getSupportFragmentManager(), "SET_SLEEP_TIMER");
            return true;
        case R.id.action_equalizer:
            NavigationUtil.openEqualizer(this);
            return true;
        case R.id.action_shuffle_album:
            MusicPlayerRemote.openAndShuffleQueue(songs, true);
            return true;
        case R.id.action_play_next:
            MusicPlayerRemote.playNext(songs);
            return true;
        case R.id.action_add_to_current_playing:
            MusicPlayerRemote.enqueue(songs);
            return true;
        case R.id.action_add_to_playlist:
            AddToPlaylistDialog.create(songs).show(getSupportFragmentManager(), "ADD_PLAYLIST");
            return true;
        case R.id.action_delete_from_device:
            DeleteSongsDialog.create(songs).show(getSupportFragmentManager(), "DELETE_SONGS");
            return true;
        case android.R.id.home:
            super.onBackPressed();
            return true;
        case R.id.action_tag_editor:
            Intent intent = new Intent(this, AlbumTagEditorActivity.class);
            intent.putExtra(AbsTagEditorActivity.EXTRA_ID, getAlbum().getId());
            startActivityForResult(intent, TAG_EDITOR_REQUEST);
            return true;
        case R.id.action_go_to_artist:
            NavigationUtil.goToArtist(this, getAlbum().getArtistId());
            return true;
        case R.id.action_wiki:
            if (wikiDialog == null) {
                wikiDialog = new MaterialDialog.Builder(this).title(album.getTitle()).positiveText(android.R.string.ok).build();
            }
            if (PreferenceUtil.isAllowedToDownloadMetadata(this)) {
                if (wiki != null) {
                    wikiDialog.setContent(wiki);
                    wikiDialog.show();
                } else {
                    Toast.makeText(this, getResources().getString(R.string.wiki_unavailable), Toast.LENGTH_SHORT).show();
                }
            } else {
                wikiDialog.show();
                loadWiki();
            }
            return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : Song(com.kabouzeid.gramophone.model.Song) SleepTimerDialog(com.kabouzeid.gramophone.dialogs.SleepTimerDialog) Intent(android.content.Intent)

Example 2 with SleepTimerDialog

use of com.kabouzeid.gramophone.dialogs.SleepTimerDialog in project Phonograph by kabouzeid.

the class AbsPlayerFragment method onMenuItemClick.

@Override
public boolean onMenuItemClick(MenuItem item) {
    final Song song = MusicPlayerRemote.getCurrentSong();
    switch(item.getItemId()) {
        case R.id.action_sleep_timer:
            new SleepTimerDialog().show(getFragmentManager(), "SET_SLEEP_TIMER");
            return true;
        case R.id.action_toggle_favorite:
            toggleFavorite(song);
            return true;
        case R.id.action_share:
            SongShareDialog.create(song).show(getFragmentManager(), "SHARE_SONG");
            return true;
        case R.id.action_equalizer:
            NavigationUtil.openEqualizer(getActivity());
            return true;
        case R.id.action_add_to_playlist:
            AddToPlaylistDialog.create(song).show(getFragmentManager(), "ADD_PLAYLIST");
            return true;
        case R.id.action_clear_playing_queue:
            MusicPlayerRemote.clearQueue();
            return true;
        case R.id.action_save_playing_queue:
            CreatePlaylistDialog.create(MusicPlayerRemote.getPlayingQueue()).show(getActivity().getSupportFragmentManager(), "ADD_TO_PLAYLIST");
            return true;
        case R.id.action_tag_editor:
            Intent intent = new Intent(getActivity(), SongTagEditorActivity.class);
            intent.putExtra(AbsTagEditorActivity.EXTRA_ID, song.id);
            startActivity(intent);
            return true;
        case R.id.action_details:
            SongDetailDialog.create(song).show(getFragmentManager(), "SONG_DETAIL");
            return true;
        case R.id.action_go_to_album:
            NavigationUtil.goToAlbum(getActivity(), song.albumId);
            return true;
        case R.id.action_go_to_artist:
            NavigationUtil.goToArtist(getActivity(), song.artistId);
            return true;
    }
    return false;
}
Also used : Song(com.kabouzeid.gramophone.model.Song) SleepTimerDialog(com.kabouzeid.gramophone.dialogs.SleepTimerDialog) Intent(android.content.Intent)

Example 3 with SleepTimerDialog

use of com.kabouzeid.gramophone.dialogs.SleepTimerDialog in project Phonograph by kabouzeid.

the class ArtistDetailActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
    int id = item.getItemId();
    final List<Song> songs = songAdapter.getDataSet();
    switch(id) {
        case R.id.action_sleep_timer:
            new SleepTimerDialog().show(getSupportFragmentManager(), "SET_SLEEP_TIMER");
            return true;
        case R.id.action_equalizer:
            NavigationUtil.openEqualizer(this);
            return true;
        case R.id.action_shuffle_artist:
            MusicPlayerRemote.openAndShuffleQueue(songs, true);
            return true;
        case R.id.action_play_next:
            MusicPlayerRemote.playNext(songs);
            return true;
        case R.id.action_add_to_current_playing:
            MusicPlayerRemote.enqueue(songs);
            return true;
        case R.id.action_add_to_playlist:
            AddToPlaylistDialog.create(songs).show(getSupportFragmentManager(), "ADD_PLAYLIST");
            return true;
        case android.R.id.home:
            super.onBackPressed();
            return true;
        case R.id.action_biography:
            if (biographyDialog == null) {
                biographyDialog = new MaterialDialog.Builder(this).title(artist.getName()).positiveText(android.R.string.ok).build();
            }
            if (PreferenceUtil.isAllowedToDownloadMetadata(ArtistDetailActivity.this)) {
                // wiki should've been already downloaded
                if (biography != null) {
                    biographyDialog.setContent(biography);
                    biographyDialog.show();
                } else {
                    Toast.makeText(ArtistDetailActivity.this, getResources().getString(R.string.biography_unavailable), Toast.LENGTH_SHORT).show();
                }
            } else {
                // force download
                biographyDialog.show();
                loadBiography();
            }
            return true;
        case R.id.action_set_artist_image:
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType("image/*");
            startActivityForResult(Intent.createChooser(intent, getString(R.string.pick_from_local_storage)), REQUEST_CODE_SELECT_IMAGE);
            return true;
        case R.id.action_reset_artist_image:
            Toast.makeText(ArtistDetailActivity.this, getResources().getString(R.string.updating), Toast.LENGTH_SHORT).show();
            CustomArtistImageUtil.getInstance(ArtistDetailActivity.this).resetCustomArtistImage(artist);
            return true;
        case R.id.action_colored_footers:
            item.setChecked(!item.isChecked());
            setUsePalette(item.isChecked());
            return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : Song(com.kabouzeid.gramophone.model.Song) SleepTimerDialog(com.kabouzeid.gramophone.dialogs.SleepTimerDialog) Intent(android.content.Intent)

Aggregations

Intent (android.content.Intent)3 SleepTimerDialog (com.kabouzeid.gramophone.dialogs.SleepTimerDialog)3 Song (com.kabouzeid.gramophone.model.Song)3