mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 08:30:44 +00:00
Add a secondary control panel to video detail fragment
It is shown when the user expands the description It contains share, open in browser and play in kodi
This commit is contained in:
parent
6277639ded
commit
78a9811fe3
@ -11,6 +11,7 @@ import android.content.pm.ActivityInfo;
|
||||
import android.database.ContentObserver;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@ -90,6 +91,7 @@ import org.schabi.newpipe.util.Constants;
|
||||
import org.schabi.newpipe.util.DeviceUtils;
|
||||
import org.schabi.newpipe.util.ExtractorHelper;
|
||||
import org.schabi.newpipe.util.ImageDisplayConstants;
|
||||
import org.schabi.newpipe.util.KoreUtil;
|
||||
import org.schabi.newpipe.util.ListHelper;
|
||||
import org.schabi.newpipe.util.Localization;
|
||||
import org.schabi.newpipe.util.NavigationHelper;
|
||||
@ -193,6 +195,7 @@ public final class VideoDetailFragment
|
||||
private TabAdapter pageAdapter;
|
||||
|
||||
private ContentObserver settingsContentObserver;
|
||||
@Nullable
|
||||
private MainPlayer playerService;
|
||||
private Player player;
|
||||
|
||||
@ -452,6 +455,30 @@ public final class VideoDetailFragment
|
||||
this.openDownloadDialog();
|
||||
}
|
||||
break;
|
||||
case R.id.detail_controls_share:
|
||||
if (currentInfo != null) {
|
||||
ShareUtils.shareText(requireContext(),
|
||||
currentInfo.getName(), currentInfo.getUrl());
|
||||
}
|
||||
break;
|
||||
case R.id.detail_controls_open_in_browser:
|
||||
if (currentInfo != null) {
|
||||
ShareUtils.openUrlInBrowser(requireContext(), currentInfo.getUrl());
|
||||
}
|
||||
break;
|
||||
case R.id.detail_controls_play_with_kodi:
|
||||
if (currentInfo != null) {
|
||||
try {
|
||||
NavigationHelper.playWithKore(
|
||||
requireContext(), Uri.parse(currentInfo.getUrl()));
|
||||
} catch (final Exception e) {
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "Failed to start kore", e);
|
||||
}
|
||||
KoreUtil.showInstallKoreDialog(requireContext());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case R.id.detail_uploader_root_layout:
|
||||
if (isEmpty(currentInfo.getSubChannelUrl())) {
|
||||
if (!isEmpty(currentInfo.getUploaderUrl())) {
|
||||
@ -549,6 +576,7 @@ public final class VideoDetailFragment
|
||||
binding.detailDescriptionView.setFocusable(false);
|
||||
binding.detailToggleDescriptionView.setImageResource(
|
||||
ThemeHelper.resolveResourceIdFromAttr(requireContext(), R.attr.ic_expand_more));
|
||||
binding.detailSecondaryControlPanel.setVisibility(View.GONE);
|
||||
} else {
|
||||
binding.detailVideoTitleView.setMaxLines(10);
|
||||
binding.detailDescriptionRootLayout.setVisibility(View.VISIBLE);
|
||||
@ -556,6 +584,7 @@ public final class VideoDetailFragment
|
||||
binding.detailDescriptionView.setMovementMethod(new LargeTextMovementMethod());
|
||||
binding.detailToggleDescriptionView.setImageResource(
|
||||
ThemeHelper.resolveResourceIdFromAttr(requireContext(), R.attr.ic_expand_less));
|
||||
binding.detailSecondaryControlPanel.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -582,6 +611,9 @@ public final class VideoDetailFragment
|
||||
binding.detailControlsBackground.setBackgroundColor(transparent);
|
||||
binding.detailControlsPopup.setBackgroundColor(transparent);
|
||||
binding.detailControlsDownload.setBackgroundColor(transparent);
|
||||
binding.detailControlsShare.setBackgroundColor(transparent);
|
||||
binding.detailControlsOpenInBrowser.setBackgroundColor(transparent);
|
||||
binding.detailControlsPlayWithKodi.setBackgroundColor(transparent);
|
||||
}
|
||||
}
|
||||
|
||||
@ -589,21 +621,22 @@ public final class VideoDetailFragment
|
||||
protected void initListeners() {
|
||||
super.initListeners();
|
||||
|
||||
binding.detailTitleRootLayout.setOnClickListener(this);
|
||||
binding.detailTitleRootLayout.setOnLongClickListener(this);
|
||||
binding.detailUploaderRootLayout.setOnClickListener(this);
|
||||
binding.detailUploaderRootLayout.setOnLongClickListener(this);
|
||||
binding.detailTitleRootLayout.setOnClickListener(this);
|
||||
binding.detailThumbnailRootLayout.setOnClickListener(this);
|
||||
binding.detailControlsBackground.setOnClickListener(this);
|
||||
binding.detailControlsBackground.setOnLongClickListener(this);
|
||||
binding.detailControlsPopup.setOnClickListener(this);
|
||||
binding.detailControlsPopup.setOnLongClickListener(this);
|
||||
binding.detailControlsPlaylistAppend.setOnClickListener(this);
|
||||
binding.detailControlsDownload.setOnClickListener(this);
|
||||
binding.detailControlsDownload.setOnLongClickListener(this);
|
||||
|
||||
binding.detailControlsBackground.setLongClickable(true);
|
||||
binding.detailControlsPopup.setLongClickable(true);
|
||||
binding.detailControlsBackground.setOnLongClickListener(this);
|
||||
binding.detailControlsPopup.setOnLongClickListener(this);
|
||||
binding.detailControlsShare.setOnClickListener(this);
|
||||
binding.detailControlsOpenInBrowser.setOnClickListener(this);
|
||||
binding.detailControlsPlayWithKodi.setOnClickListener(this);
|
||||
showHideKodiButton();
|
||||
|
||||
binding.overlayThumbnail.setOnClickListener(this);
|
||||
binding.overlayThumbnail.setOnLongClickListener(this);
|
||||
@ -672,6 +705,12 @@ public final class VideoDetailFragment
|
||||
}
|
||||
}
|
||||
|
||||
private void showHideKodiButton() {
|
||||
// show kodi button if it supports the current service and it is enabled in settings
|
||||
binding.detailControlsPlayWithKodi.setVisibility(KoreUtil.shouldShowPlayWithKodi(
|
||||
requireContext(), serviceId) ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// OwnStack
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
@ -1312,6 +1351,7 @@ public final class VideoDetailFragment
|
||||
binding.detailDescriptionRootLayout.setVisibility(View.GONE);
|
||||
binding.detailToggleDescriptionView.setVisibility(View.GONE);
|
||||
binding.detailTitleRootLayout.setClickable(false);
|
||||
binding.detailSecondaryControlPanel.setVisibility(View.GONE);
|
||||
|
||||
if (binding.relatedStreamsLayout != null) {
|
||||
if (showRelatedStreams) {
|
||||
@ -1431,6 +1471,7 @@ public final class VideoDetailFragment
|
||||
ThemeHelper.resolveResourceIdFromAttr(requireContext(), R.attr.ic_expand_more));
|
||||
binding.detailToggleDescriptionView.setVisibility(View.VISIBLE);
|
||||
binding.detailDescriptionRootLayout.setVisibility(View.GONE);
|
||||
binding.detailSecondaryControlPanel.setVisibility(View.GONE);
|
||||
|
||||
if (info.getUploadDate() != null) {
|
||||
binding.detailUploadDateView.setText(Localization
|
||||
|
@ -426,6 +426,7 @@
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<!-- CONTROLS -->
|
||||
<LinearLayout
|
||||
android:id="@+id/detail_control_panel"
|
||||
android:layout_width="match_parent"
|
||||
@ -433,13 +434,12 @@
|
||||
android:descendantFocusability="afterDescendants"
|
||||
android:focusable="true"
|
||||
android:orientation="horizontal"
|
||||
android:padding="6dp">
|
||||
android:padding="@dimen/detail_control_padding">
|
||||
|
||||
<!-- CONTROLS -->
|
||||
<TextView
|
||||
android:id="@+id/detail_controls_playlist_append"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="55dp"
|
||||
android:layout_width="@dimen/detail_control_width"
|
||||
android:layout_height="@dimen/detail_control_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
@ -447,16 +447,15 @@
|
||||
android:contentDescription="@string/append_playlist"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingVertical="@dimen/detail_control_padding"
|
||||
android:text="@string/controls_add_to_playlist_title"
|
||||
android:textSize="12sp"
|
||||
android:textSize="@dimen/detail_control_text_size"
|
||||
app:drawableTopCompat="?attr/ic_playlist_add" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/detail_controls_background"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="55dp"
|
||||
android:layout_width="@dimen/detail_control_width"
|
||||
android:layout_height="@dimen/detail_control_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
@ -464,16 +463,15 @@
|
||||
android:contentDescription="@string/play_audio"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingVertical="@dimen/detail_control_padding"
|
||||
android:text="@string/controls_background_title"
|
||||
android:textSize="12sp"
|
||||
android:textSize="@dimen/detail_control_text_size"
|
||||
app:drawableTopCompat="?attr/ic_headset" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/detail_controls_popup"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="55dp"
|
||||
android:layout_width="@dimen/detail_control_width"
|
||||
android:layout_height="@dimen/detail_control_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
@ -481,16 +479,15 @@
|
||||
android:contentDescription="@string/open_in_popup_mode"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingVertical="@dimen/detail_control_padding"
|
||||
android:text="@string/controls_popup_title"
|
||||
android:textSize="12sp"
|
||||
android:textSize="@dimen/detail_control_text_size"
|
||||
app:drawableTopCompat="?attr/ic_popup" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/detail_controls_download"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="55dp"
|
||||
android:layout_width="@dimen/detail_control_width"
|
||||
android:layout_height="@dimen/detail_control_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
@ -498,14 +495,75 @@
|
||||
android:contentDescription="@string/controls_download_desc"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingVertical="@dimen/detail_control_padding"
|
||||
android:text="@string/download"
|
||||
android:textSize="12sp"
|
||||
android:textSize="@dimen/detail_control_text_size"
|
||||
app:drawableTopCompat="?attr/ic_file_download" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- SECONDARY CONTROLS -->
|
||||
<LinearLayout
|
||||
android:id="@+id/detail_secondary_control_panel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:descendantFocusability="afterDescendants"
|
||||
android:focusable="true"
|
||||
android:orientation="horizontal"
|
||||
android:padding="@dimen/detail_control_padding"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/detail_controls_share"
|
||||
android:layout_width="@dimen/detail_control_width"
|
||||
android:layout_height="@dimen/detail_control_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/share"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:paddingVertical="@dimen/detail_control_padding"
|
||||
android:text="@string/share"
|
||||
android:textSize="@dimen/detail_control_text_size"
|
||||
app:drawableTopCompat="?attr/ic_share" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/detail_controls_open_in_browser"
|
||||
android:layout_width="@dimen/detail_control_width"
|
||||
android:layout_height="@dimen/detail_control_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/open_in_browser"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:paddingVertical="@dimen/detail_control_padding"
|
||||
android:text="@string/open_in_browser"
|
||||
android:textSize="@dimen/detail_control_text_size"
|
||||
app:drawableTopCompat="?attr/ic_language" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/detail_controls_play_with_kodi"
|
||||
android:layout_width="@dimen/detail_control_width"
|
||||
android:layout_height="@dimen/detail_control_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/play_with_kodi_title"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:paddingVertical="@dimen/detail_control_padding"
|
||||
android:text="@string/play_with_kodi_title"
|
||||
android:textSize="@dimen/detail_control_text_size"
|
||||
app:drawableTopCompat="?attr/ic_cast" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/detail_meta_info_separator"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -413,18 +413,18 @@
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<!-- CONTROLS -->
|
||||
<LinearLayout
|
||||
android:id="@+id/detail_control_panel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="6dp">
|
||||
android:padding="@dimen/detail_control_padding">
|
||||
|
||||
<!-- CONTROLS -->
|
||||
<TextView
|
||||
android:id="@+id/detail_controls_playlist_append"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="55dp"
|
||||
android:layout_width="@dimen/detail_control_width"
|
||||
android:layout_height="@dimen/detail_control_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
@ -432,16 +432,15 @@
|
||||
android:contentDescription="@string/append_playlist"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingVertical="@dimen/detail_control_padding"
|
||||
android:text="@string/controls_add_to_playlist_title"
|
||||
android:textSize="12sp"
|
||||
android:textSize="@dimen/detail_control_text_size"
|
||||
app:drawableTopCompat="?attr/ic_playlist_add" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/detail_controls_background"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="55dp"
|
||||
android:layout_width="@dimen/detail_control_width"
|
||||
android:layout_height="@dimen/detail_control_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
@ -449,16 +448,15 @@
|
||||
android:contentDescription="@string/play_audio"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingVertical="@dimen/detail_control_padding"
|
||||
android:text="@string/controls_background_title"
|
||||
android:textSize="12sp"
|
||||
android:textSize="@dimen/detail_control_text_size"
|
||||
app:drawableTopCompat="?attr/ic_headset" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/detail_controls_popup"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="55dp"
|
||||
android:layout_width="@dimen/detail_control_width"
|
||||
android:layout_height="@dimen/detail_control_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
@ -466,16 +464,15 @@
|
||||
android:contentDescription="@string/open_in_popup_mode"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingVertical="@dimen/detail_control_padding"
|
||||
android:text="@string/controls_popup_title"
|
||||
android:textSize="12sp"
|
||||
android:textSize="@dimen/detail_control_text_size"
|
||||
app:drawableTopCompat="?attr/ic_popup" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/detail_controls_download"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="55dp"
|
||||
android:layout_width="@dimen/detail_control_width"
|
||||
android:layout_height="@dimen/detail_control_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
@ -483,14 +480,73 @@
|
||||
android:contentDescription="@string/controls_download_desc"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingVertical="@dimen/detail_control_padding"
|
||||
android:text="@string/download"
|
||||
android:textSize="12sp"
|
||||
android:textSize="@dimen/detail_control_text_size"
|
||||
app:drawableTopCompat="?attr/ic_file_download" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- SECONDARY CONTROLS -->
|
||||
<LinearLayout
|
||||
android:id="@+id/detail_secondary_control_panel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="@dimen/detail_control_padding"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/detail_controls_share"
|
||||
android:layout_width="@dimen/detail_control_width"
|
||||
android:layout_height="@dimen/detail_control_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/share"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:paddingVertical="@dimen/detail_control_padding"
|
||||
android:text="@string/share"
|
||||
android:textSize="@dimen/detail_control_text_size"
|
||||
app:drawableTopCompat="?attr/ic_share" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/detail_controls_open_in_browser"
|
||||
android:layout_width="@dimen/detail_control_width"
|
||||
android:layout_height="@dimen/detail_control_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/open_in_browser"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:paddingVertical="@dimen/detail_control_padding"
|
||||
android:text="@string/open_in_browser"
|
||||
android:textSize="@dimen/detail_control_text_size"
|
||||
app:drawableTopCompat="?attr/ic_language" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/detail_controls_play_with_kodi"
|
||||
android:layout_width="@dimen/detail_control_width"
|
||||
android:layout_height="@dimen/detail_control_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/play_with_kodi_title"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:paddingVertical="@dimen/detail_control_padding"
|
||||
android:text="@string/play_with_kodi_title"
|
||||
android:textSize="@dimen/detail_control_text_size"
|
||||
app:drawableTopCompat="?attr/ic_cast" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/detail_meta_info_separator"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -84,6 +84,11 @@
|
||||
<!-- Paddings & Margins -->
|
||||
<dimen name="video_item_detail_like_margin">5dp</dimen>
|
||||
<dimen name="video_item_detail_error_panel_margin">50dp</dimen>
|
||||
<!-- Control panel -->
|
||||
<dimen name="detail_control_text_size">12sp</dimen>
|
||||
<dimen name="detail_control_width">80dp</dimen>
|
||||
<dimen name="detail_control_height">55dp</dimen>
|
||||
<dimen name="detail_control_padding">6dp</dimen>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
|
Loading…
Reference in New Issue
Block a user