mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-11-19 16:24:57 +00:00
Merge pull request #1092 from TeamNewPipe/icon
move download menu item into detail controls menu
This commit is contained in:
commit
0ba6f8b39f
@ -53,7 +53,6 @@ class ActionBarHandler {
|
|||||||
// those are edited directly. Typically VideoDetailFragment will implement those callbacks.
|
// those are edited directly. Typically VideoDetailFragment will implement those callbacks.
|
||||||
private OnActionListener onShareListener;
|
private OnActionListener onShareListener;
|
||||||
private OnActionListener onOpenInBrowserListener;
|
private OnActionListener onOpenInBrowserListener;
|
||||||
private OnActionListener onDownloadListener;
|
|
||||||
private OnActionListener onPlayWithKodiListener;
|
private OnActionListener onPlayWithKodiListener;
|
||||||
|
|
||||||
// Triggered when a stream related action is triggered.
|
// Triggered when a stream related action is triggered.
|
||||||
@ -117,11 +116,6 @@ class ActionBarHandler {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case R.id.menu_item_download:
|
|
||||||
if (onDownloadListener != null) {
|
|
||||||
onDownloadListener.onActionSelected(selectedVideoStream);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.action_play_with_kodi:
|
case R.id.action_play_with_kodi:
|
||||||
if (onPlayWithKodiListener != null) {
|
if (onPlayWithKodiListener != null) {
|
||||||
onPlayWithKodiListener.onActionSelected(selectedVideoStream);
|
onPlayWithKodiListener.onActionSelected(selectedVideoStream);
|
||||||
@ -145,19 +139,12 @@ class ActionBarHandler {
|
|||||||
onOpenInBrowserListener = listener;
|
onOpenInBrowserListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnDownloadListener(OnActionListener listener) {
|
|
||||||
onDownloadListener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOnPlayWithKodiListener(OnActionListener listener) {
|
public void setOnPlayWithKodiListener(OnActionListener listener) {
|
||||||
onPlayWithKodiListener = listener;
|
onPlayWithKodiListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showDownloadAction(boolean visible) {
|
|
||||||
menu.findItem(R.id.menu_item_download).setVisible(visible);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showPlayWithKodiAction(boolean visible) {
|
public void showPlayWithKodiAction(boolean visible) {
|
||||||
menu.findItem(R.id.action_play_with_kodi).setVisible(visible);
|
menu.findItem(R.id.action_play_with_kodi).setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -147,6 +147,7 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
|
|||||||
private TextView detailControlsBackground;
|
private TextView detailControlsBackground;
|
||||||
private TextView detailControlsPopup;
|
private TextView detailControlsPopup;
|
||||||
private TextView detailControlsAddToPlaylist;
|
private TextView detailControlsAddToPlaylist;
|
||||||
|
private TextView detailControlsDownload;
|
||||||
private TextView appendControlsDetail;
|
private TextView appendControlsDetail;
|
||||||
|
|
||||||
private LinearLayout videoDescriptionRootLayout;
|
private LinearLayout videoDescriptionRootLayout;
|
||||||
@ -335,6 +336,24 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
|
|||||||
.show(getFragmentManager(), TAG);
|
.show(getFragmentManager(), TAG);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case R.id.detail_controls_download:
|
||||||
|
if (!PermissionHelper.checkStoragePermissions(activity)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
DownloadDialog downloadDialog =
|
||||||
|
DownloadDialog.newInstance(currentInfo,
|
||||||
|
sortedStreamVideosList,
|
||||||
|
actionBarHandler.getSelectedVideoStream());
|
||||||
|
downloadDialog.show(activity.getSupportFragmentManager(), "downloadDialog");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Toast.makeText(activity,
|
||||||
|
R.string.could_not_setup_download_menu,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case R.id.detail_uploader_root_layout:
|
case R.id.detail_uploader_root_layout:
|
||||||
if (TextUtils.isEmpty(currentInfo.getUploaderUrl())) {
|
if (TextUtils.isEmpty(currentInfo.getUploaderUrl())) {
|
||||||
Log.w(TAG, "Can't open channel because we got no channel URL");
|
Log.w(TAG, "Can't open channel because we got no channel URL");
|
||||||
@ -438,6 +457,7 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
|
|||||||
detailControlsBackground = rootView.findViewById(R.id.detail_controls_background);
|
detailControlsBackground = rootView.findViewById(R.id.detail_controls_background);
|
||||||
detailControlsPopup = rootView.findViewById(R.id.detail_controls_popup);
|
detailControlsPopup = rootView.findViewById(R.id.detail_controls_popup);
|
||||||
detailControlsAddToPlaylist = rootView.findViewById(R.id.detail_controls_playlist_append);
|
detailControlsAddToPlaylist = rootView.findViewById(R.id.detail_controls_playlist_append);
|
||||||
|
detailControlsDownload = rootView.findViewById(R.id.detail_controls_download);
|
||||||
appendControlsDetail = rootView.findViewById(R.id.touch_append_detail);
|
appendControlsDetail = rootView.findViewById(R.id.touch_append_detail);
|
||||||
|
|
||||||
videoDescriptionRootLayout = rootView.findViewById(R.id.detail_description_root_layout);
|
videoDescriptionRootLayout = rootView.findViewById(R.id.detail_description_root_layout);
|
||||||
@ -489,6 +509,7 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
|
|||||||
detailControlsBackground.setOnClickListener(this);
|
detailControlsBackground.setOnClickListener(this);
|
||||||
detailControlsPopup.setOnClickListener(this);
|
detailControlsPopup.setOnClickListener(this);
|
||||||
detailControlsAddToPlaylist.setOnClickListener(this);
|
detailControlsAddToPlaylist.setOnClickListener(this);
|
||||||
|
detailControlsDownload.setOnClickListener(this);
|
||||||
relatedStreamExpandButton.setOnClickListener(this);
|
relatedStreamExpandButton.setOnClickListener(this);
|
||||||
|
|
||||||
detailControlsBackground.setLongClickable(true);
|
detailControlsBackground.setLongClickable(true);
|
||||||
@ -508,9 +529,7 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
|
|||||||
context.getResources().getString(R.string.enqueue_on_popup)
|
context.getResources().getString(R.string.enqueue_on_popup)
|
||||||
};
|
};
|
||||||
|
|
||||||
final DialogInterface.OnClickListener actions = new DialogInterface.OnClickListener() {
|
final DialogInterface.OnClickListener actions = (DialogInterface dialogInterface, int i) -> {
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item));
|
NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item));
|
||||||
@ -521,16 +540,14 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
new InfoItemDialog(getActivity(), item, commands, actions).show();
|
new InfoItemDialog(getActivity(), item, commands, actions).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private View.OnTouchListener getOnControlsTouchListener() {
|
private View.OnTouchListener getOnControlsTouchListener() {
|
||||||
return new View.OnTouchListener() {
|
return (View view, MotionEvent motionEvent) -> {
|
||||||
@Override
|
view.performClick();
|
||||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
|
||||||
if (!PreferenceManager.getDefaultSharedPreferences(activity).getBoolean(getString(R.string.show_hold_to_append_key), true)) return false;
|
if (!PreferenceManager.getDefaultSharedPreferences(activity).getBoolean(getString(R.string.show_hold_to_append_key), true)) return false;
|
||||||
|
|
||||||
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
|
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
@ -542,7 +559,6 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,18 +631,9 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
|
|||||||
private static void showInstallKoreDialog(final Context context) {
|
private static void showInstallKoreDialog(final Context context) {
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
builder.setMessage(R.string.kore_not_found)
|
builder.setMessage(R.string.kore_not_found)
|
||||||
.setPositiveButton(R.string.install, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.install, (DialogInterface dialog, int which) ->
|
||||||
@Override
|
NavigationHelper.installKore(context))
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
.setNegativeButton(R.string.cancel, (DialogInterface dialog, int which) -> {});
|
||||||
NavigationHelper.installKore(context);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -636,41 +643,19 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
|
|||||||
actionBarHandler.setupStreamList(sortedStreamVideosList, spinnerToolbar);
|
actionBarHandler.setupStreamList(sortedStreamVideosList, spinnerToolbar);
|
||||||
actionBarHandler.setOnShareListener(selectedStreamId -> shareUrl(info.name, info.url));
|
actionBarHandler.setOnShareListener(selectedStreamId -> shareUrl(info.name, info.url));
|
||||||
|
|
||||||
actionBarHandler.setOnOpenInBrowserListener(new ActionBarHandler.OnActionListener() {
|
actionBarHandler.setOnOpenInBrowserListener((int selectedStreamId)->
|
||||||
@Override
|
openUrlInBrowser(info.getUrl()));
|
||||||
public void onActionSelected(int selectedStreamId) {
|
|
||||||
openUrlInBrowser(info.getUrl());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
actionBarHandler.setOnPlayWithKodiListener(new ActionBarHandler.OnActionListener() {
|
actionBarHandler.setOnPlayWithKodiListener((int selectedStreamId) -> {
|
||||||
@Override
|
|
||||||
public void onActionSelected(int selectedStreamId) {
|
|
||||||
try {
|
try {
|
||||||
NavigationHelper.playWithKore(activity, Uri.parse(info.getUrl().replace("https", "http")));
|
NavigationHelper.playWithKore(activity, Uri.parse(
|
||||||
|
info.getUrl().replace("https", "http")));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if(DEBUG) Log.i(TAG, "Failed to start kore", e);
|
if(DEBUG) Log.i(TAG, "Failed to start kore", e);
|
||||||
showInstallKoreDialog(activity);
|
showInstallKoreDialog(activity);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
actionBarHandler.setOnDownloadListener(new ActionBarHandler.OnActionListener() {
|
|
||||||
@Override
|
|
||||||
public void onActionSelected(int selectedStreamId) {
|
|
||||||
if (!PermissionHelper.checkStoragePermissions(activity)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
DownloadDialog downloadDialog = DownloadDialog.newInstance(info, sortedStreamVideosList, selectedStreamId);
|
|
||||||
downloadDialog.show(activity.getSupportFragmentManager(), "downloadDialog");
|
|
||||||
} catch (Exception e) {
|
|
||||||
Toast.makeText(activity, R.string.could_not_setup_download_menu, Toast.LENGTH_LONG).show();
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
@ -777,20 +762,14 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
|
|||||||
currentWorker = ExtractorHelper.getStreamInfo(serviceId, url, forceLoad)
|
currentWorker = ExtractorHelper.getStreamInfo(serviceId, url, forceLoad)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new Consumer<StreamInfo>() {
|
.subscribe((@NonNull StreamInfo result) -> {
|
||||||
@Override
|
|
||||||
public void accept(@NonNull StreamInfo result) throws Exception {
|
|
||||||
isLoading.set(false);
|
isLoading.set(false);
|
||||||
currentInfo = result;
|
currentInfo = result;
|
||||||
showContentWithAnimation(120, 0, 0);
|
showContentWithAnimation(120, 0, 0);
|
||||||
handleResult(result);
|
handleResult(result);
|
||||||
}
|
}, (@NonNull Throwable throwable) -> {
|
||||||
}, new Consumer<Throwable>() {
|
|
||||||
@Override
|
|
||||||
public void accept(@NonNull Throwable throwable) throws Exception {
|
|
||||||
isLoading.set(false);
|
isLoading.set(false);
|
||||||
onError(throwable);
|
onError(throwable);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -884,9 +863,7 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
disposables.add(Single.just(descriptionHtml)
|
disposables.add(Single.just(descriptionHtml)
|
||||||
.map(new Function<String, Spanned>() {
|
.map((@io.reactivex.annotations.NonNull String description) -> {
|
||||||
@Override
|
|
||||||
public Spanned apply(@io.reactivex.annotations.NonNull String description) throws Exception {
|
|
||||||
Spanned parsedDescription;
|
Spanned parsedDescription;
|
||||||
if (Build.VERSION.SDK_INT >= 24) {
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
parsedDescription = Html.fromHtml(description, 0);
|
parsedDescription = Html.fromHtml(description, 0);
|
||||||
@ -895,16 +872,12 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
|
|||||||
parsedDescription = Html.fromHtml(description);
|
parsedDescription = Html.fromHtml(description);
|
||||||
}
|
}
|
||||||
return parsedDescription;
|
return parsedDescription;
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.subscribeOn(Schedulers.computation())
|
.subscribeOn(Schedulers.computation())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new Consumer<Spanned>() {
|
.subscribe((@io.reactivex.annotations.NonNull Spanned spanned) -> {
|
||||||
@Override
|
|
||||||
public void accept(@io.reactivex.annotations.NonNull Spanned spanned) throws Exception {
|
|
||||||
videoDescriptionView.setText(spanned);
|
videoDescriptionView.setText(spanned);
|
||||||
videoDescriptionView.setVisibility(View.VISIBLE);
|
videoDescriptionView.setVisibility(View.VISIBLE);
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1131,14 +1104,11 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onBlockedByGemaError() {
|
public void onBlockedByGemaError() {
|
||||||
thumbnailBackgroundButton.setOnClickListener(new View.OnClickListener() {
|
thumbnailBackgroundButton.setOnClickListener((View v) -> {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
intent.setData(Uri.parse(getString(R.string.c3s_url)));
|
intent.setData(Uri.parse(getString(R.string.c3s_url)));
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
showError(getString(R.string.blocked_by_gema), false, R.drawable.gruese_die_gema);
|
showError(getString(R.string.blocked_by_gema), false, R.drawable.gruese_die_gema);
|
||||||
|
@ -354,6 +354,24 @@
|
|||||||
android:paddingTop="6dp"
|
android:paddingTop="6dp"
|
||||||
android:text="@string/controls_popup_title"
|
android:text="@string/controls_popup_title"
|
||||||
android:textSize="12sp"/>
|
android:textSize="12sp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/detail_controls_download"
|
||||||
|
android:layout_width="80dp"
|
||||||
|
android:layout_height="55dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:contentDescription="@string/controls_download_desg"
|
||||||
|
android:drawableTop="?attr/download"
|
||||||
|
android:gravity="center"
|
||||||
|
android:paddingBottom="6dp"
|
||||||
|
android:paddingTop="6dp"
|
||||||
|
android:text="@string/download"
|
||||||
|
android:textSize="12sp"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
@ -2,12 +2,6 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_item_download"
|
|
||||||
android:icon="?attr/download"
|
|
||||||
android:title="@string/download"
|
|
||||||
app:showAsAction="always"/>
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_play_with_kodi"
|
android:id="@+id/action_play_with_kodi"
|
||||||
android:icon="?attr/cast"
|
android:icon="?attr/cast"
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
<string name="open_in_popup_mode">Open in popup mode</string>
|
<string name="open_in_popup_mode">Open in popup mode</string>
|
||||||
<string name="share">Share</string>
|
<string name="share">Share</string>
|
||||||
<string name="download">Download</string>
|
<string name="download">Download</string>
|
||||||
|
<string name="controls_download_desg">Download stream file.</string>
|
||||||
<string name="search">Search</string>
|
<string name="search">Search</string>
|
||||||
<string name="settings">Settings</string>
|
<string name="settings">Settings</string>
|
||||||
<string name="did_you_mean">Did you mean: %1$s ?</string>
|
<string name="did_you_mean">Did you mean: %1$s ?</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user