Skip to content

Commit

Permalink
Merge branch 'flora' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ShareASmile committed Jun 23, 2024
2 parents 1bd0f84 + 049b468 commit 4b81c7c
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 20 deletions.
6 changes: 2 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ android {
archivesBaseName = 'NewPipe_' + System.getProperty('packageSuffix')
}
minifyEnabled true
shrinkResources false // disabled to fix F-Droid's reproducible build
shrinkResources true // could be disabled to fix F-Droid's reproducible build
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
archivesBaseName = 'app'
applicationIdSuffix ".Flora"
applicationIdSuffix ".flora"
resValue "string", "app_name", "NewPipe " + "Flora"
}
}
Expand Down Expand Up @@ -193,8 +193,6 @@ dependencies {
// This works thanks to JitPack: https://jitpack.io/
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
implementation 'com.github.ShareASmile:NewPipeExtractor:9f741d54b2'
//implementation 'com.github.TeamNewPipe:NewPipeExtractor:eb07d70a2ce03bee3cc74fc33b2e4173e1c21436'


/** Checkstyle **/
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ private void toggleTitleAndSecondaryControls() {
VideoPlayerUi.DEFAULT_CONTROLS_DURATION, 180);
binding.detailSecondaryControlPanel.setVisibility(View.VISIBLE);
} else {
binding.detailVideoTitleView.setMaxLines(1);
binding.detailVideoTitleView.setMaxLines(2);
animateRotation(binding.detailToggleSecondaryControlsView,
VideoPlayerUi.DEFAULT_CONTROLS_DURATION, 0);
binding.detailSecondaryControlPanel.setVisibility(View.GONE);
Expand Down Expand Up @@ -1323,9 +1323,11 @@ private void addVideoPlayerView() {
// Prevent from re-adding a view multiple times
new Handler(Looper.getMainLooper()).post(() ->
player.UIs().get(MainPlayerUi.class).ifPresent(playerUi -> {
playerUi.removeViewFromParent();
binding.playerPlaceholder.addView(playerUi.getBinding().getRoot());
playerUi.setupVideoSurfaceIfNeeded();
if (binding != null) {
playerUi.removeViewFromParent();
binding.playerPlaceholder.addView(playerUi.getBinding().getRoot());
playerUi.setupVideoSurfaceIfNeeded();
}
}));
}

Expand Down Expand Up @@ -1521,7 +1523,7 @@ public void showLoading() {
animate(binding.positionView, false, 50);

binding.detailVideoTitleView.setText(title);
binding.detailVideoTitleView.setMaxLines(1);
binding.detailVideoTitleView.setMaxLines(2);
animate(binding.detailVideoTitleView, true, 0);

binding.detailToggleSecondaryControlsView.setVisibility(View.GONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public void onComplete() {
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
if (item.getItemId() == R.id.menu_item_share_playlist) {
sharePlaylist();
createShareConfirmationDialog();
} else if (item.getItemId() == R.id.menu_item_rename_playlist) {
createRenameDialog();
} else if (item.getItemId() == R.id.menu_item_remove_watched) {
Expand All @@ -376,15 +376,33 @@ public boolean onOptionsItemSelected(final MenuItem item) {

/**
* Share the playlist as a newline-separated list of stream URLs.
* Shares the playlist as a list of stream URLs if {@code shouldSharePlaylistDetails} is
* set to {@code false}. Shares the playlist name along with a list of video titles and URLs
* if {@code shouldSharePlaylistDetails} is set to {@code true}.
*
* @param shouldSharePlaylistDetails Whether the playlist details should be included in the
* shared content.
*/
public void sharePlaylist() {
private void sharePlaylist(final boolean shouldSharePlaylistDetails) {
final Context context = requireContext();

disposables.add(playlistManager.getPlaylistStreams(playlistId)
.flatMapSingle(playlist -> Single.just(playlist.stream()
.map(PlaylistStreamEntry::getStreamEntity)
.map(StreamEntity::getUrl)
.map(streamEntity -> {
if (shouldSharePlaylistDetails) {
return context.getString(R.string.video_details_list_item,
streamEntity.getTitle(), streamEntity.getUrl());
} else {
return streamEntity.getUrl();
}
})
.collect(Collectors.joining("\n"))))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(urlsText -> ShareUtils.shareText(requireContext(), name, urlsText),
.subscribe(urlsText -> ShareUtils.shareText(
context, name, shouldSharePlaylistDetails
? context.getString(R.string.share_playlist_content_details,
name, urlsText) : urlsText),
throwable -> showUiErrorSnackbar(this, "Sharing playlist", throwable)));
}

Expand Down Expand Up @@ -825,5 +843,24 @@ private PlayQueue getPlayQueue(final int index) {
}
return new SinglePlayQueue(streamInfoItems, index);
}

/**
* Creates a dialog to confirm whether the user wants to share the playlist
* with the playlist details or just the list of stream URLs.
* After the user has made a choice, the playlist is shared.
*/
private void createShareConfirmationDialog() {
new AlertDialog.Builder(requireContext())
.setTitle(R.string.share_playlist)
.setMessage(R.string.share_playlist_with_titles_message)
.setCancelable(true)
.setPositiveButton(R.string.share_playlist_with_titles, (dialog, which) ->
sharePlaylist(/* shouldSharePlaylistDetails= */ true)
)
.setNegativeButton(R.string.share_playlist_with_list, (dialog, which) ->
sharePlaylist(/* shouldSharePlaylistDetails= */ false)
)
.show();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ protected void showOrHideButtons() {
return;
}

final boolean showQueue = playQueue.getStreams().size() > 1;
final boolean showQueue = playQueue.getStreams().isEmpty();
final boolean showSegment = !player.getCurrentStreamInfo()
.map(StreamInfo::getStreamSegments)
.map(List::isEmpty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
android:layout_height="match_parent"
android:layout_marginEnd="30dp"
android:ellipsize="end"
android:maxLines="1"
android:maxLines="2"
android:paddingTop="12dp"
android:paddingBottom="8dp"
android:textAppearance="?android:attr/textAppearanceLarge"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_video_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
android:layout_height="match_parent"
android:layout_marginEnd="30dp"
android:ellipsize="end"
android:maxLines="1"
android:maxLines="2"
android:paddingTop="12dp"
android:paddingBottom="8dp"
android:textAppearance="?android:attr/textAppearanceLarge"
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
<dimen name="video_item_detail_likes_text_size">12sp</dimen>
<dimen name="video_item_detail_uploader_text_size">12sp</dimen>
<dimen name="video_item_detail_sub_channel_text_size">14sp</dimen>
<dimen name="video_item_detail_upload_date_text_size">13sp</dimen>
<dimen name="video_item_detail_description_text_size">13sp</dimen>
<dimen name="video_item_detail_upload_date_text_size">15sp</dimen>
<dimen name="video_item_detail_description_text_size">15sp</dimen>
<dimen name="channel_subscribers_text_size">12sp</dimen>
<dimen name="channel_rss_title_size">12sp</dimen>
<!-- Elements Size -->
Expand Down Expand Up @@ -120,8 +120,8 @@
<dimen name="file_picker_items_text_size">14sp</dimen>

<!-- Text Size -->
<dimen name="comment_item_title_text_size">12sp</dimen>
<dimen name="comment_item_content_text_size">12sp</dimen>
<dimen name="comment_item_title_text_size">15sp</dimen>
<dimen name="comment_item_content_text_size">15sp</dimen>

<!-- Feed Groups dimensions-->
<dimen name="feed_group_carousel_start_end_margin">12dp</dimen>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -748,4 +748,10 @@
<string name="unknown_format">Unknown format</string>
<string name="unknown_quality">Unknown quality</string>
<string name="feed_toggle_show_future_items">Show future videos</string>
<string name="share_playlist">Share Playlist</string>
<string name="share_playlist_with_titles_message">Share playlist with details such as playlist name and video titles or as a simple list of video URLs</string>
<string name="share_playlist_with_titles">Share with Titles</string>
<string name="share_playlist_with_list">Share URL list</string>
<string name="video_details_list_item">- %s: %s</string>
<string name="share_playlist_content_details">%s\n%s</string>
</resources>

0 comments on commit 4b81c7c

Please sign in to comment.