diff --git a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java index d4e2b0dbe..e39035013 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java @@ -139,7 +139,10 @@ public final class BackgroundPlayer extends Service { if (DEBUG) Log.d(TAG, "destroy() called"); releaseWifiAndCpu(); stopForeground(true); + if (basePlayerImpl != null) basePlayerImpl.destroy(); + basePlayerImpl = null; + mBinder = null; } @Override diff --git a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayerActivity.java index 2087f943d..ffa1e68bd 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayerActivity.java @@ -1,12 +1,12 @@ package org.schabi.newpipe.player; import android.content.ComponentName; -import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.Build; import android.os.Bundle; import android.os.IBinder; +import android.provider.Settings; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; @@ -24,16 +24,13 @@ import android.widget.TextView; import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.Player; -import org.schabi.newpipe.MainActivity; import org.schabi.newpipe.R; -import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.playlist.PlayQueueItem; import org.schabi.newpipe.playlist.PlayQueueItemBuilder; import org.schabi.newpipe.playlist.PlayQueueItemHolder; -import org.schabi.newpipe.settings.SettingsActivity; -import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.Localization; +import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.ThemeHelper; public class BackgroundPlayerActivity extends AppCompatActivity @@ -101,15 +98,26 @@ public class BackgroundPlayerActivity extends AppCompatActivity bind(); } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_play_queue, menu); + return true; + } + @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish(); return true; + case R.id.action_history: + NavigationHelper.openHistory(this); + return true; case R.id.action_settings: - Intent intent = new Intent(this, SettingsActivity.class); - startActivity(intent); + NavigationHelper.openSettings(this); + return true; + case R.id.action_system_audio: + startActivity(new Intent(Settings.ACTION_SOUND_SETTINGS)); return true; } return super.onOptionsItemSelected(item); @@ -264,7 +272,7 @@ public class BackgroundPlayerActivity extends AppCompatActivity private void buildItemPopupMenu(final PlayQueueItem item, final View view) { final PopupMenu menu = new PopupMenu(this, view); - final MenuItem remove = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 0, Menu.NONE, "Remove"); + final MenuItem remove = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 0, Menu.NONE, R.string.play_queue_remove); remove.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { @@ -274,11 +282,11 @@ public class BackgroundPlayerActivity extends AppCompatActivity } }); - final MenuItem detail = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 1, Menu.NONE, "Detail"); + final MenuItem detail = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 1, Menu.NONE, R.string.play_queue_stream_detail); detail.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { - onOpenDetail(BackgroundPlayerActivity.this, item.getUrl(), item.getTitle()); + onOpenDetail(item.getServiceId(), item.getUrl(), item.getTitle()); return true; } }); @@ -346,15 +354,8 @@ public class BackgroundPlayerActivity extends AppCompatActivity }; } - private void onOpenDetail(Context context, String videoUrl, String videoTitle) { - Intent i = new Intent(context, MainActivity.class); - i.putExtra(Constants.KEY_SERVICE_ID, 0); - i.putExtra(Constants.KEY_URL, videoUrl); - i.putExtra(Constants.KEY_TITLE, videoTitle); - i.putExtra(Constants.KEY_LINK_TYPE, StreamingService.LinkType.STREAM); - i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - context.startActivity(i); - context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); + private void onOpenDetail(int serviceId, String videoUrl, String videoTitle) { + NavigationHelper.openVideoDetail(this, serviceId, videoUrl, videoTitle); } private void scrollToSelected() { diff --git a/app/src/main/res/drawable-hdpi/ic_reorder_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_reorder_black_24dp.png new file mode 100644 index 000000000..142d71505 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_reorder_black_24dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_reorder_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_reorder_white_24dp.png new file mode 100644 index 000000000..bacaaef28 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_reorder_white_24dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_shuffle_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_shuffle_white_24dp.png new file mode 100644 index 000000000..ab55a83f4 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_shuffle_white_24dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_reorder_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_reorder_black_24dp.png new file mode 100644 index 000000000..d18997cd4 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_reorder_black_24dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_reorder_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_reorder_white_24dp.png new file mode 100644 index 000000000..a82363318 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_reorder_white_24dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_shuffle_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_shuffle_white_24dp.png new file mode 100644 index 000000000..d13a258a3 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_shuffle_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_reorder_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_reorder_black_24dp.png new file mode 100644 index 000000000..0b080a187 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_reorder_black_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_reorder_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_reorder_white_24dp.png new file mode 100644 index 000000000..6b4c52861 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_reorder_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_shuffle_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_shuffle_white_24dp.png new file mode 100644 index 000000000..66c15ce62 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_shuffle_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_reorder_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_reorder_black_24dp.png new file mode 100644 index 000000000..0a66529bf Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_reorder_black_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_reorder_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_reorder_white_24dp.png new file mode 100644 index 000000000..a0d2543f2 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_reorder_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_shuffle_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_shuffle_white_24dp.png new file mode 100644 index 000000000..dc8e5341b Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_shuffle_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_reorder_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_reorder_black_24dp.png new file mode 100644 index 000000000..56a5bc8ba Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_reorder_black_24dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_reorder_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_reorder_white_24dp.png new file mode 100644 index 000000000..bc4fde512 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_reorder_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_shuffle_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_shuffle_white_24dp.png new file mode 100644 index 000000000..e24dfa3b0 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_shuffle_white_24dp.png differ diff --git a/app/src/main/res/layout/activity_background_player.xml b/app/src/main/res/layout/activity_background_player.xml index 3a4a4454d..f2efd7411 100644 --- a/app/src/main/res/layout/activity_background_player.xml +++ b/app/src/main/res/layout/activity_background_player.xml @@ -209,7 +209,7 @@ android:clickable="true" android:focusable="true" android:scaleType="fitXY" - android:src="@drawable/ic_palette_white_24dp" + android:src="@drawable/ic_shuffle_white_24dp" tools:ignore="ContentDescription"/> + + + + + + + diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 047038e50..216cc1605 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -18,6 +18,7 @@ + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7609a7730..9054397a6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -293,6 +293,10 @@ New & hot %1$s/%2$s - + Background Player + Remove + Details + Audio Settings + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index c556cce50..0ec8093bc 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -25,6 +25,7 @@ @drawable/ic_palette_black_24dp @drawable/ic_language_black_24dp @drawable/ic_history_black_24dp + @drawable/ic_reorder_black_24dp @color/light_selector @color/light_separator_color @@ -60,6 +61,7 @@ @drawable/ic_palette_white_24dp @drawable/ic_language_white_24dp @drawable/ic_history_white_24dp + @drawable/ic_reorder_white_24dp @color/dark_selector @color/dark_separator_color