Playing queue dialog finished
- rearranged code structure
This commit is contained in:
parent
e1eaa92070
commit
9ba8a07383
16 changed files with 254 additions and 123 deletions
|
|
@ -18,8 +18,11 @@ import android.view.Menu;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.kabouzeid.materialmusic.R;
|
||||
import com.kabouzeid.materialmusic.helper.PlayingQueueDialogHelper;
|
||||
import com.kabouzeid.materialmusic.interfaces.KabSearchAbleFragment;
|
||||
import com.kabouzeid.materialmusic.interfaces.KabViewsDisableAble;
|
||||
import com.kabouzeid.materialmusic.interfaces.OnMusicRemoteEventListener;
|
||||
|
|
@ -85,7 +88,6 @@ public class MainActivity extends AbsFabActivity
|
|||
}
|
||||
|
||||
private void setUpToolBar() {
|
||||
toolbarTitle = getTitle();
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
statusBar = findViewById(R.id.statusBar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
|
@ -253,7 +255,14 @@ public class MainActivity extends AbsFabActivity
|
|||
case R.id.action_current_playing:
|
||||
openCurrentPlayingIfPossible(null);
|
||||
return true;
|
||||
|
||||
case R.id.action_playing_queue:
|
||||
final MaterialDialog materialDialog = PlayingQueueDialogHelper.getDialog(this, this);
|
||||
if (materialDialog != null) {
|
||||
materialDialog.show();
|
||||
} else {
|
||||
Toast.makeText(this, getResources().getString(R.string.nothing_playing), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import android.widget.ImageView;
|
|||
import android.widget.RelativeLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.kabouzeid.materialmusic.R;
|
||||
|
|
@ -356,10 +357,7 @@ public class MusicControllerActivity extends AbsFabActivity implements OnMusicRe
|
|||
public void onMusicRemoteEvent(MusicRemoteEvent event) {
|
||||
super.onMusicRemoteEvent(event);
|
||||
switch (event.getAction()) {
|
||||
case MusicRemoteEvent.NEXT:
|
||||
updateCurrentSong();
|
||||
break;
|
||||
case MusicRemoteEvent.PREV:
|
||||
case MusicRemoteEvent.TRACK_CHANGED:
|
||||
updateCurrentSong();
|
||||
break;
|
||||
case MusicRemoteEvent.REPEAT_MODE_CHANGED:
|
||||
|
|
@ -399,8 +397,12 @@ public class MusicControllerActivity extends AbsFabActivity implements OnMusicRe
|
|||
super.onBackPressed();
|
||||
return true;
|
||||
case R.id.action_playing_queue:
|
||||
final MaterialDialog materialDialog = PlayingQueueDialogHelper.getDialog(this);
|
||||
materialDialog.show();
|
||||
final MaterialDialog materialDialog = PlayingQueueDialogHelper.getDialog(this, this);
|
||||
if (materialDialog != null) {
|
||||
materialDialog.show();
|
||||
} else {
|
||||
Toast.makeText(this, getResources().getString(R.string.nothing_playing), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
return true;
|
||||
case R.id.action_tag_editor:
|
||||
Intent intent = new Intent(this, SongTagEditorActivity.class);
|
||||
|
|
|
|||
|
|
@ -75,40 +75,6 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text
|
|||
year.setText(getSongYear());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void save() {
|
||||
Artwork artwork = null;
|
||||
Map<FieldKey, String> fieldKeyValueMap = new EnumMap<>(FieldKey.class);
|
||||
fieldKeyValueMap.put(FieldKey.ALBUM, albumTitle.getText().toString());
|
||||
//android seems not to recognize album_artist field so we additionally write the normal artist field
|
||||
fieldKeyValueMap.put(FieldKey.ARTIST, albumArtistName.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.ALBUM_ARTIST, albumArtistName.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.GENRE, genreName.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.YEAR, year.getText().toString());
|
||||
|
||||
try {
|
||||
albumArtFile = MusicUtil.getAlbumArtFile(this, String.valueOf(getId()));
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "error while creating albumArtFile", e);
|
||||
}
|
||||
|
||||
if (albumArtBitmap != null && albumArtFile != null) {
|
||||
try {
|
||||
albumArtBitmap.compress(Bitmap.CompressFormat.PNG, 0, new FileOutputStream(albumArtFile));
|
||||
artwork = ArtworkFactory.createArtworkFromFile(albumArtFile);
|
||||
MusicUtil.insertAlbumArt(this, getId(), albumArtFile.getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "error while trying to create the artwork from file", e);
|
||||
}
|
||||
}
|
||||
writeValuesToFiles(fieldKeyValueMap, artwork, deleteAlbumArt);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentViewResId() {
|
||||
return R.layout.activity_album_tag_editor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadCurrentImage() {
|
||||
setImageBitmap(getAlbumArt());
|
||||
|
|
@ -147,6 +113,57 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text
|
|||
searchWebFor(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deleteImage() {
|
||||
setImageRes(R.drawable.default_album_art);
|
||||
deleteAlbumArt = true;
|
||||
dataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void save() {
|
||||
Artwork artwork = null;
|
||||
Map<FieldKey, String> fieldKeyValueMap = new EnumMap<>(FieldKey.class);
|
||||
fieldKeyValueMap.put(FieldKey.ALBUM, albumTitle.getText().toString());
|
||||
//android seems not to recognize album_artist field so we additionally write the normal artist field
|
||||
fieldKeyValueMap.put(FieldKey.ARTIST, albumArtistName.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.ALBUM_ARTIST, albumArtistName.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.GENRE, genreName.getText().toString());
|
||||
fieldKeyValueMap.put(FieldKey.YEAR, year.getText().toString());
|
||||
|
||||
try {
|
||||
albumArtFile = MusicUtil.getAlbumArtFile(this, String.valueOf(getId()));
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "error while creating albumArtFile", e);
|
||||
}
|
||||
|
||||
if (albumArtBitmap != null && albumArtFile != null) {
|
||||
try {
|
||||
albumArtBitmap.compress(Bitmap.CompressFormat.PNG, 0, new FileOutputStream(albumArtFile));
|
||||
artwork = ArtworkFactory.createArtworkFromFile(albumArtFile);
|
||||
MusicUtil.insertAlbumArt(this, getId(), albumArtFile.getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "error while trying to create the artwork from file", e);
|
||||
}
|
||||
}
|
||||
writeValuesToFiles(fieldKeyValueMap, artwork, deleteAlbumArt);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentViewResId() {
|
||||
return R.layout.activity_album_tag_editor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getSongPaths() {
|
||||
List<Song> songs = AlbumSongLoader.getAlbumSongList(this, getId());
|
||||
List<Integer> songIds = new ArrayList<>();
|
||||
for (Song song : songs) {
|
||||
songIds.add(song.id);
|
||||
}
|
||||
return SongFileLoader.getSongFiles(this, songIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadImageFromFile(final Uri selectedFileUri) {
|
||||
DisplayImageOptions options = new DisplayImageOptions.Builder()
|
||||
|
|
@ -167,23 +184,6 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deleteImage() {
|
||||
setImageRes(R.drawable.default_album_art);
|
||||
deleteAlbumArt = true;
|
||||
dataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getSongPaths() {
|
||||
List<Song> songs = AlbumSongLoader.getAlbumSongList(this, getId());
|
||||
List<Integer> songIds = new ArrayList<>();
|
||||
for (Song song : songs) {
|
||||
songIds.add(song.id);
|
||||
}
|
||||
return SongFileLoader.getSongFiles(this, songIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,26 @@ public class SongTagEditorActivity extends AbsTagEditorActivity implements TextW
|
|||
trackNumber.setText(getTrackNumber());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadCurrentImage() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void getImageFromLastFM() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void searchImageOnWeb() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deleteImage() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void save() {
|
||||
Map<FieldKey, String> fieldKeyValueMap = new EnumMap<>(FieldKey.class);
|
||||
|
|
@ -82,18 +102,10 @@ public class SongTagEditorActivity extends AbsTagEditorActivity implements TextW
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void loadCurrentImage() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void getImageFromLastFM() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void searchImageOnWeb() {
|
||||
|
||||
protected List<String> getSongPaths() {
|
||||
List<Integer> tempIdList = new ArrayList<>();
|
||||
tempIdList.add(getId());
|
||||
return SongFileLoader.getSongFiles(this, tempIdList);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -101,18 +113,6 @@ public class SongTagEditorActivity extends AbsTagEditorActivity implements TextW
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deleteImage() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getSongPaths() {
|
||||
List<Integer> tempIdList = new ArrayList<>();
|
||||
tempIdList.add(getId());
|
||||
return SongFileLoader.getSongFiles(this, tempIdList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue