1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-11-16 14:54:57 +00:00

-Added dropdown menu for background player activity.

-Added icons for shuffle and drag handle.
-Fixed exception when returning to background player activity after service shuts down.
-Fixed open detail only working for Youtube.
This commit is contained in:
John Zhen M 2017-10-11 21:16:28 -07:00 committed by John Zhen Mo
parent b5a9f042cc
commit 6a9e3ef639
23 changed files with 55 additions and 22 deletions

View File

@ -139,7 +139,10 @@ public final class BackgroundPlayer extends Service {
if (DEBUG) Log.d(TAG, "destroy() called"); if (DEBUG) Log.d(TAG, "destroy() called");
releaseWifiAndCpu(); releaseWifiAndCpu();
stopForeground(true); stopForeground(true);
if (basePlayerImpl != null) basePlayerImpl.destroy(); if (basePlayerImpl != null) basePlayerImpl.destroy();
basePlayerImpl = null;
mBinder = null;
} }
@Override @Override

View File

@ -1,12 +1,12 @@
package org.schabi.newpipe.player; package org.schabi.newpipe.player;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
import android.provider.Settings;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; 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.PlaybackParameters;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import org.schabi.newpipe.MainActivity;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.playlist.PlayQueueItem; import org.schabi.newpipe.playlist.PlayQueueItem;
import org.schabi.newpipe.playlist.PlayQueueItemBuilder; import org.schabi.newpipe.playlist.PlayQueueItemBuilder;
import org.schabi.newpipe.playlist.PlayQueueItemHolder; 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.Localization;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.ThemeHelper; import org.schabi.newpipe.util.ThemeHelper;
public class BackgroundPlayerActivity extends AppCompatActivity public class BackgroundPlayerActivity extends AppCompatActivity
@ -101,15 +98,26 @@ public class BackgroundPlayerActivity extends AppCompatActivity
bind(); bind();
} }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_play_queue, menu);
return true;
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home: case android.R.id.home:
finish(); finish();
return true; return true;
case R.id.action_history:
NavigationHelper.openHistory(this);
return true;
case R.id.action_settings: case R.id.action_settings:
Intent intent = new Intent(this, SettingsActivity.class); NavigationHelper.openSettings(this);
startActivity(intent); return true;
case R.id.action_system_audio:
startActivity(new Intent(Settings.ACTION_SOUND_SETTINGS));
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
@ -264,7 +272,7 @@ public class BackgroundPlayerActivity extends AppCompatActivity
private void buildItemPopupMenu(final PlayQueueItem item, final View view) { private void buildItemPopupMenu(final PlayQueueItem item, final View view) {
final PopupMenu menu = new PopupMenu(this, 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() { remove.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem menuItem) { 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() { detail.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem menuItem) { public boolean onMenuItemClick(MenuItem menuItem) {
onOpenDetail(BackgroundPlayerActivity.this, item.getUrl(), item.getTitle()); onOpenDetail(item.getServiceId(), item.getUrl(), item.getTitle());
return true; return true;
} }
}); });
@ -346,15 +354,8 @@ public class BackgroundPlayerActivity extends AppCompatActivity
}; };
} }
private void onOpenDetail(Context context, String videoUrl, String videoTitle) { private void onOpenDetail(int serviceId, String videoUrl, String videoTitle) {
Intent i = new Intent(context, MainActivity.class); NavigationHelper.openVideoDetail(this, serviceId, videoUrl, videoTitle);
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 scrollToSelected() { private void scrollToSelected() {

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 B

View File

@ -209,7 +209,7 @@
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@drawable/ic_palette_white_24dp" android:src="@drawable/ic_shuffle_white_24dp"
tools:ignore="ContentDescription"/> tools:ignore="ContentDescription"/>
<TextView <TextView

View File

@ -29,8 +29,10 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:scaleType="center" android:scaleType="center"
android:src="?attr/filter" android:src="?attr/reorder"
tools:ignore="ContentDescription,RtlHardcoded"/> tools:ignore="ContentDescription,RtlHardcoded"/>
<TextView <TextView

View File

@ -0,0 +1,20 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.schabi.newpipe.history.HistoryActivity">
<item android:id="@+id/action_history"
android:orderInCategory="981"
android:title="@string/action_history"
app:showAsAction="never"/>
<item android:id="@+id/action_settings"
android:orderInCategory="990"
android:title="@string/settings"
app:showAsAction="never"/>
<item android:id="@+id/action_system_audio"
android:orderInCategory="996"
android:title="@string/play_queue_audio_settings"
app:showAsAction="never"/>
</menu>

View File

@ -18,6 +18,7 @@
<attr name="palette" format="reference"/> <attr name="palette" format="reference"/>
<attr name="language" format="reference"/> <attr name="language" format="reference"/>
<attr name="history" format="reference"/> <attr name="history" format="reference"/>
<attr name="reorder" format="reference"/>
<!-- Can't refer to colors directly into drawable's xml--> <!-- Can't refer to colors directly into drawable's xml-->
<attr name="toolbar_shadow_drawable" format="reference"/> <attr name="toolbar_shadow_drawable" format="reference"/>

View File

@ -293,6 +293,10 @@
<string name="new_and_hot">New &amp; hot</string> <string name="new_and_hot">New &amp; hot</string>
<string name="service_kiosk_string" translatable="false">%1$s/%2$s</string> <string name="service_kiosk_string" translatable="false">%1$s/%2$s</string>
<!-- Player --> <!-- Play Queue -->
<string name="title_activity_background_player">Background Player</string> <string name="title_activity_background_player">Background Player</string>
<string name="play_queue_remove">Remove</string>
<string name="play_queue_stream_detail">Details</string>
<string name="play_queue_audio_settings">Audio Settings</string>
</resources> </resources>

View File

@ -25,6 +25,7 @@
<item name="palette">@drawable/ic_palette_black_24dp</item> <item name="palette">@drawable/ic_palette_black_24dp</item>
<item name="language">@drawable/ic_language_black_24dp</item> <item name="language">@drawable/ic_language_black_24dp</item>
<item name="history">@drawable/ic_history_black_24dp</item> <item name="history">@drawable/ic_history_black_24dp</item>
<item name="reorder">@drawable/ic_reorder_black_24dp</item>
<item name="selector_color">@color/light_selector</item> <item name="selector_color">@color/light_selector</item>
<item name="separator_color">@color/light_separator_color</item> <item name="separator_color">@color/light_separator_color</item>
@ -60,6 +61,7 @@
<item name="palette">@drawable/ic_palette_white_24dp</item> <item name="palette">@drawable/ic_palette_white_24dp</item>
<item name="language">@drawable/ic_language_white_24dp</item> <item name="language">@drawable/ic_language_white_24dp</item>
<item name="history">@drawable/ic_history_white_24dp</item> <item name="history">@drawable/ic_history_white_24dp</item>
<item name="reorder">@drawable/ic_reorder_white_24dp</item>
<item name="selector_color">@color/dark_selector</item> <item name="selector_color">@color/dark_selector</item>
<item name="separator_color">@color/dark_separator_color</item> <item name="separator_color">@color/dark_separator_color</item>