Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Global Playing Queue Button #363

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ public void run() {
case R.id.action_search:
NavigationUtils.navigateToSearch(this);
return true;
case R.id.action_open_queue:
NavigationUtils.goToQueue(this);
return true;
case R.id.action_equalizer:
NavigationUtils.navigateToEqualizer(this);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ public void run() {
}
};

private Runnable navigateQueueAnywhere = new Runnable(){
public void run(){
Fragment fragment = new QueueFragment();
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.fragment_container,fragment).commit();
}
};

private Runnable navigateArtist = new Runnable() {
public void run() {
long artistID = getIntent().getExtras().getLong(Constants.ARTIST_ID);
Expand Down Expand Up @@ -194,6 +203,7 @@ public void onCreate(Bundle savedInstanceState) {
navigationMap.put(Constants.NAVIGATE_ALBUM, navigateAlbum);
navigationMap.put(Constants.NAVIGATE_ARTIST, navigateArtist);
navigationMap.put(Constants.NAVIGATE_LYRICS, navigateLyrics);
navigationMap.put(Constants.NAVIGATE_QUEUE_ANYWHERE, navigateQueueAnywhere);

mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
panelLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);
Expand Down Expand Up @@ -298,7 +308,15 @@ public void onClick(View view) {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);

Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
if(currentFragment instanceof QueueFragment){
MenuItem item = menu.findItem(R.id.action_open_queue);
item.setVisible(false);
}
else{
MenuItem item = menu.findItem(R.id.action_open_queue);
item.setVisible(true);
}
return true;
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/naman14/timber/utils/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class Constants {
public static final String NAVIGATE_LIBRARY = "navigate_library";
public static final String NAVIGATE_PLAYLIST = "navigate_playlist";
public static final String NAVIGATE_QUEUE = "navigate_queue";
public static final String NAVIGATE_QUEUE_ANYWHERE = "navigate_queue_anywhere";
public static final String NAVIGATE_ALBUM = "navigate_album";
public static final String NAVIGATE_ARTIST = "navigate_artist";
public static final String NAVIGATE_NOWPLAYING = "navigate_nowplaying";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ public static void goToAlbum(Context context, long albumId) {
context.startActivity(intent);
}

public static void goToQueue(Context context){
Intent intent = new Intent(context, MainActivity.class);
intent.setAction(Constants.NAVIGATE_QUEUE_ANYWHERE);
context.startActivity(intent);
}

public static void goToLyrics(Context context) {
Intent intent = new Intent(context, MainActivity.class);
intent.setAction(Constants.NAVIGATE_LYRICS);
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_queue_music_black_24px.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:pathData="M15,6L3,6v2h12L15,6zM15,10L3,10v2h12v-2zM3,16h8v-2L3,14v2zM17,6v8.18c-0.31,-0.11 -0.65,-0.18 -1,-0.18 -1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3L19,8h3L22,6h-5z"
android:fillColor="#FFFFFF"/>
</vector>
9 changes: 8 additions & 1 deletion app/src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@

<item
android:id="@+id/action_search"
android:orderInCategory="1"
android:orderInCategory="2"
android:icon="@drawable/ic_action_search"
app:showAsAction="always"
android:title="@string/search"/>

<item
android:id="@+id/action_open_queue"
android:orderInCategory="1"
android:icon="@drawable/ic_queue_music_black_24px"
app:showAsAction="always"
android:title="@string/playing_queue"/>

</menu>