Bug fixes, code cleanup

This commit is contained in:
Stefan Schueller 2021-01-24 00:31:51 +01:00
parent 51a8a6d838
commit 3730804c8f
18 changed files with 87 additions and 51 deletions

View File

@ -1,3 +1,12 @@
### Version 1.0.53 Tag: v1.0.53 (2021-01-24)
- Making X in pip mode stop background audio properly (@dhk2)
- Adding clear search history option to settings menu (@dhk2)
- Fix no language selected defaults to all video languages
- Updated icon library
- Added buffering indicator to video playback
- Fixed blank video issues on servers offering 0p video.
- Updated translations
### Version 1.0.52 Tag: v1.0.52 (2021-01-17)
- Implemented edit server in server book (@kosharskiy)
- Updated translations

View File

@ -109,11 +109,11 @@ dependencies {
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation "androidx.fragment:fragment-ktx:$fragment_version"
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'de.hdodenhof:circleimageview:3.1.0'
// font awesome
implementation "com.mikepenz:iconics-core:3.1.0"
implementation 'com.mikepenz:fontawesome-typeface:5.3.1.1@aar'
implementation 'com.mikepenz:iconics-core:5.2.4'
implementation 'com.mikepenz:fontawesome-typeface:5.9.0.2-kotlin@aar'
// http client / REST
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
@ -141,10 +141,10 @@ dependencies {
implementation "com.google.android.exoplayer:extension-okhttp:$exoplayer"
// date formatter
implementation 'org.ocpsoft.prettytime:prettytime:4.0.4.Final'
implementation 'org.ocpsoft.prettytime:prettytime:5.0.0.Final'
// Version comparison
implementation 'org.apache.maven:maven-artifact:3.5.0'
implementation 'org.apache.maven:maven-artifact:3.6.3'
// database lib
implementation "androidx.room:room-runtime:$room_version"
@ -162,7 +162,7 @@ dependencies {
implementation 'androidx.preference:preference-ktx:1.1.1'
// testing
testImplementation 'junit:junit:4.13'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation "androidx.room:room-testing:$room_version"

View File

@ -67,6 +67,13 @@
android:exported="false" />
<service android:name=".service.VideoPlayerService" />
<receiver android:name="androidx.media.session.MediaButtonReceiver" >
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@ -24,12 +24,11 @@ import android.view.Menu;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.bottomnavigation.LabelVisibilityMode;
import com.mikepenz.fontawesome_typeface_library.FontAwesome;
import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.iconics.typeface.library.fontawesome.FontAwesome;
import com.squareup.picasso.Picasso;
import net.schueller.peertube.R;

View File

@ -50,11 +50,10 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.mikepenz.fontawesome_typeface_library.FontAwesome;
import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.iconics.typeface.library.fontawesome.FontAwesome;
import net.schueller.peertube.R;
import net.schueller.peertube.adapter.VideoAdapter;
import net.schueller.peertube.helper.APIUrlHelper;
@ -130,15 +129,15 @@ public class VideoListActivity extends CommonActivity {
// Set an icon in the ActionBar
menu.findItem(R.id.action_account).setIcon(
new IconicsDrawable(this, FontAwesome.Icon.faw_user_circle).actionBar());
new IconicsDrawable(this, FontAwesome.Icon.faw_user_circle));
menu.findItem(R.id.action_server_address_book).setIcon(
new IconicsDrawable(this, FontAwesome.Icon.faw_server).actionBar());
new IconicsDrawable(this, FontAwesome.Icon.faw_server));
MenuItem searchMenuItem = menu.findItem(R.id.action_search);
searchMenuItem.setIcon(
new IconicsDrawable(this, FontAwesome.Icon.faw_search).actionBar());
new IconicsDrawable(this, FontAwesome.Icon.faw_search));
// Get the SearchView and set the searchable configuration
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
@ -324,13 +323,16 @@ public class VideoListActivity extends CommonActivity {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
String nsfw = sharedPref.getBoolean(getString(R.string.pref_show_nsfw_key), false) ? "both" : "false";
Locale locale = getResources().getConfiguration().locale;
String country = locale.getLanguage();
//
// Locale locale = getResources().getConfiguration().locale;
// String country = locale.getLanguage();
//
// HashSet<String> countries = new HashSet<>(1);
// countries.add(country);
HashSet<String> countries = new HashSet<>(1);
countries.add(country);
// We set this to default to null so that on initial start there are videos listed.
Set<String> languages = sharedPref.getStringSet(getString(R.string.pref_video_language_key), null);
Set<String> languages = sharedPref.getStringSet(getString(R.string.pref_video_language_key), countries);
String apiBaseURL = APIUrlHelper.getUrlWithVersion(this);
GetVideoDataService service = RetrofitInstance.getRetrofitInstance(apiBaseURL, APIUrlHelper.useInsecureConnection(this)).create(GetVideoDataService.class);

View File

@ -115,7 +115,7 @@ public class ChannelAdapter extends RecyclerView.Adapter<ChannelAdapter.AccountV
});
holder.moreButton.setText(R.string.video_more_icon);
new Iconics.IconicsBuilder().ctx(context).on(holder.moreButton).build();
new Iconics.Builder().on(holder.moreButton).build();
holder.moreButton.setOnClickListener(v -> {

View File

@ -119,7 +119,7 @@ public class ServerSearchAdapter extends RecyclerView.Adapter<ServerSearchAdapte
//
//
// holder.moreButton.setText(R.string.video_more_icon);
// new Iconics.IconicsBuilder().ctx(context).on(holder.moreButton).build();
// new Iconics.Builder().on(holder.moreButton).build();
//
// holder.moreButton.setOnClickListener(v -> {
//

View File

@ -131,7 +131,7 @@ public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHol
});
holder.moreButton.setText(R.string.video_more_icon);
new Iconics.IconicsBuilder().ctx(context).on(holder.moreButton).build();
new Iconics.Builder().on(holder.moreButton).build();
holder.moreButton.setOnClickListener(v -> {

View File

@ -52,9 +52,9 @@ public class VideoMenuQualityFragment extends BottomSheetDialogFragment {
if (autoQualityFile == null) {
autoQualityFile = new File();
Resolution autoQualityResolution = new Resolution();
autoQualityResolution.setId(0);
autoQualityResolution.setId(999999);
autoQualityResolution.setLabel(context.getString(R.string.menu_video_options_quality_automated));
autoQualityFile.setId(0);
autoQualityFile.setId(999999);
autoQualityFile.setResolution(autoQualityResolution);
}
if (!mFiles.contains(autoQualityFile)) {
@ -74,7 +74,7 @@ public class VideoMenuQualityFragment extends BottomSheetDialogFragment {
false);
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
Integer videoQuality = sharedPref.getInt(getString(R.string.pref_quality_key), 0);
Integer videoQuality = sharedPref.getInt(getString(R.string.pref_quality_key), 999999);
for (File file : mFiles) {
@ -95,11 +95,13 @@ public class VideoMenuQualityFragment extends BottomSheetDialogFragment {
for (File fileV : mFiles) {
TextView iconViewV = view.findViewById(fileV.getResolution().getId());
if (iconViewV != null) {
iconViewV.setText("");
}
}
iconView.setText(R.string.video_quality_active_icon);
new Iconics.IconicsBuilder().ctx(getContext()).on(iconView).build();
new Iconics.Builder().on(iconView).build();
//TODO: set new video quality on running video
@ -112,7 +114,7 @@ public class VideoMenuQualityFragment extends BottomSheetDialogFragment {
// Set current
if (videoQuality.equals(file.getResolution().getId())) {
iconView.setText(R.string.video_quality_active_icon);
new Iconics.IconicsBuilder().ctx(getContext()).on(iconView).build();
new Iconics.Builder().on(iconView).build();
}
}

View File

@ -100,7 +100,7 @@ public class VideoMenuSpeedFragment extends BottomSheetDialogFragment {
videoPlayerService.setPlayBackSpeed(speed);
icon.setText(R.string.video_speed_active_icon);
new Iconics.IconicsBuilder().ctx(getContext()).on(icon).build();
new Iconics.Builder().on(icon).build();
}
}

View File

@ -105,7 +105,7 @@ public class VideoMetaDataFragment extends Fragment {
Button thumbsUpButton = activity.findViewById(R.id.video_thumbs_up);
defaultTextColor = thumbsUpButton.getTextColors();
thumbsUpButton.setText(R.string.video_thumbs_up_icon);
new Iconics.IconicsBuilder().ctx(context).on(thumbsUpButton).build();
new Iconics.Builder().on(thumbsUpButton).build();
thumbsUpButton.setOnClickListener(v -> {
rateVideo(true, video);
});
@ -113,7 +113,7 @@ public class VideoMetaDataFragment extends Fragment {
// Thumbs Down
Button thumbsDownButton = activity.findViewById(R.id.video_thumbs_down);
thumbsDownButton.setText(R.string.video_thumbs_down_icon);
new Iconics.IconicsBuilder().ctx(context).on(thumbsDownButton).build();
new Iconics.Builder().on(thumbsDownButton).build();
thumbsDownButton.setOnClickListener(v -> {
rateVideo(false, video);
});
@ -145,7 +145,7 @@ public class VideoMetaDataFragment extends Fragment {
// Share
Button videoShareButton = activity.findViewById(R.id.video_share);
videoShareButton.setText(R.string.video_share_icon);
new Iconics.IconicsBuilder().ctx(context).on(videoShareButton).build();
new Iconics.Builder().on(videoShareButton).build();
videoShareButton.setOnClickListener(v ->
{
leaveAppExpected = true;
@ -155,7 +155,7 @@ public class VideoMetaDataFragment extends Fragment {
// Download
Button videoDownloadButton = activity.findViewById(R.id.video_download);
videoDownloadButton.setText(R.string.video_download_icon);
new Iconics.IconicsBuilder().ctx(context).on(videoDownloadButton).build();
new Iconics.Builder().on(videoDownloadButton).build();
videoDownloadButton.setOnClickListener(v -> {
// get permission to store file
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
@ -235,7 +235,7 @@ public class VideoMetaDataFragment extends Fragment {
// more button
TextView moreButton = activity.findViewById(R.id.moreButton);
moreButton.setText(R.string.video_more_icon);
new Iconics.IconicsBuilder().ctx(context).on(moreButton).build();
new Iconics.Builder().on(moreButton).build();
moreButton.setOnClickListener(v -> {
PopupMenu popup = new PopupMenu(context, v);
@ -260,7 +260,7 @@ public class VideoMetaDataFragment extends Fragment {
// video player options
TextView videoOptions = activity.findViewById(R.id.exo_more);
videoOptions.setText(R.string.video_more_icon);
new Iconics.IconicsBuilder().ctx(context).on(videoOptions).build();
new Iconics.Builder().on(videoOptions).build();
videoOptions.setOnClickListener(v -> {
VideoOptionsFragment videoOptionsFragment =

View File

@ -77,7 +77,7 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment {
iconView.setText(R.string.video_option_speed_icon);
new Iconics.IconicsBuilder().ctx(getContext()).on(iconView).build();
new Iconics.Builder().on(iconView).build();
textView.setOnClickListener(view1 -> {
VideoMenuSpeedFragment videoMenuSpeedFragment =
VideoMenuSpeedFragment.newInstance(videoPlayerService);
@ -92,7 +92,7 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment {
TextView textView2 = menuRow2.findViewById(R.id.video_quality_text);
textView2.setText(String.format(getString(R.string.menu_video_options_quality), getCurrentVideoQuality(files)));
iconView2.setText(R.string.video_option_quality_icon);
new Iconics.IconicsBuilder().ctx(getContext()).on(iconView2).build();
new Iconics.Builder().on(iconView2).build();
textView2.setOnClickListener(view1 -> {
VideoMenuQualityFragment videoMenuQualityFragment =
VideoMenuQualityFragment.newInstance(getContext(), files);
@ -107,7 +107,7 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment {
private String getCurrentVideoQuality(ArrayList<File> files) {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
Integer videoQuality = sharedPref.getInt(getString(R.string.pref_quality_key), 0);
Integer videoQuality = sharedPref.getInt(getString(R.string.pref_quality_key), 999999);
for (File file : files) {
if (videoQuality.equals(file.getResolution().getId())) {

View File

@ -162,7 +162,7 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL
FrameLayout fullscreenButton = activity.findViewById(R.id.exo_fullscreen_button);
fullscreenText.setText(R.string.video_expand_icon);
new Iconics.IconicsBuilder().ctx(context).on(fullscreenText).build();
new Iconics.Builder().on(fullscreenText).build();
fullscreenButton.setOnClickListener(view -> {
Log.d(TAG, "Fullscreen");
@ -239,12 +239,12 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL
torrentStream.startStream(stream);
} else {
Integer videoQuality = sharedPref.getInt(getString(R.string.pref_quality_key), 0);
Integer videoQuality = sharedPref.getInt(getString(R.string.pref_quality_key), 999999);
// get video qualities
/// #
// TODO: if auto is set all versions except 0p should be added to a track and have exoplayer auto select optimal bitrate
if (video.getFiles().size() > 0) {
String urlToPlay = video.getFiles().get( 0 ).getFileUrl();
String urlToPlay = video.getFiles().get( 0 ).getFileUrl(); // default, take first found, usually highest res
for ( File file : video.getFiles() ) {
// Set quality if it matches
if ( file.getResolution().getId().equals( videoQuality ) ) {
@ -321,7 +321,7 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL
} else {
fullscreenButton.setText(R.string.video_expand_icon);
}
new Iconics.IconicsBuilder().ctx(getContext()).on(fullscreenButton).build();
new Iconics.Builder().on(fullscreenButton).build();
}
public Boolean getIsFullscreen() {

View File

@ -44,6 +44,7 @@ import android.widget.Toast;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
@ -53,6 +54,8 @@ import com.google.android.exoplayer2.ext.mediasession.TimelineQueueNavigator;
import com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource;
import com.google.android.exoplayer2.ext.okhttp.OkHttpDataSourceFactory;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.ui.PlayerNotificationManager;
import com.google.android.exoplayer2.upstream.DataSource;
@ -102,7 +105,9 @@ public class VideoPlayerService extends Service {
super.onCreate();
player = ExoPlayerFactory.newSimpleInstance(getApplicationContext(), new DefaultTrackSelector());
player = new SimpleExoPlayer.Builder(getApplicationContext())
.setTrackSelector(new DefaultTrackSelector(getApplicationContext()))
.build();
// Stop player if audio device changes, e.g. headphones unplugged
player.addListener(new Player.EventListener() {
@ -224,14 +229,18 @@ public class VideoPlayerService extends Service {
okhttpClientBuilder = getUnsafeOkHttpClientBuilder();
}
// Create a data source factory.
DataSource.Factory dataSourceFactory = new OkHttpDataSourceFactory(okhttpClientBuilder.build(), Util.getUserAgent(getApplicationContext(), "PeerTube"));
// This is the MediaSource representing the media to be played.
ExtractorMediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(currentStreamUrl));
// Create a progressive media source pointing to a stream uri.
MediaSource mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(MediaItem.fromUri(Uri.parse(currentStreamUrl)));
// Prepare the player with the source.
player.prepare(videoSource);
// Set the media source to be played.
player.setMediaSource(mediaSource);
// Prepare the player.
player.prepare();
// Auto play
player.setPlayWhenReady(true);

View File

@ -13,7 +13,7 @@
android:background="@color/videoBackgroundColor"
app:controller_layout_id="@layout/video_playback_controls"
app:resize_mode="fixed_width"
app:show_buffering="always"
/>

View File

@ -39,6 +39,7 @@
app:iconSpaceReserved="false"/>
<MultiSelectListPreference
app:defaultValue="@array/empty_array"
app:entries="@array/languageArray"
app:entryValues="@array/languageValues"
app:key="@string/pref_video_language_key"

View File

@ -9,7 +9,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

View File

@ -0,0 +1,7 @@
- Making X in pip mode stop background audio properly (@dhk2)
- Adding clear search history option to settings menu (@dhk2)
- Fix no language selected defaults to all video languages
- Updated icon library
- Added buffering indicator to video playback
- Fixed blank video issues on servers offering 0p video.
- Updated translations