From 4f57d3a20149b08b050d10bb77abf9493c775ae0 Mon Sep 17 00:00:00 2001 From: chschtsch Date: Mon, 14 Dec 2015 13:01:34 +0300 Subject: [PATCH] merging with master --- app/src/main/AndroidManifest.xml | 3 +- .../org/schabi/newpipe/PlayVideoActivity.java | 1 - .../java/org/schabi/newpipe/VideoInfo.java | 6 +- .../newpipe/VideoInfoItemViewCreator.java | 2 - .../newpipe/VideoItemDetailFragment.java | 48 ++- .../org/schabi/newpipe/VideoListAdapter.java | 2 - .../schabi/newpipe/services/SearchEngine.java | 1 + .../schabi/newpipe/services/ServiceList.java | 2 + .../newpipe/services/VideoExtractor.java | 2 + .../drawable-nodpi/dummy_thumbnail_dark.png | Bin 0 -> 188 bytes .../layout-land/fragment_videoitem_detail.xml | 207 ----------- .../fragment_videoitem_detail.xml | 207 ----------- .../layout-v21/fragment_videoitem_detail.xml | 213 +++++++++++ .../res/layout/fragment_videoitem_detail.xml | 347 +++++++++--------- app/src/main/res/values-v21/styles.xml | 1 + app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/styles.xml | 1 + 17 files changed, 438 insertions(+), 606 deletions(-) create mode 100644 app/src/main/res/drawable-nodpi/dummy_thumbnail_dark.png delete mode 100644 app/src/main/res/layout-land/fragment_videoitem_detail.xml delete mode 100644 app/src/main/res/layout-sw600dp/fragment_videoitem_detail.xml create mode 100644 app/src/main/res/layout-v21/fragment_videoitem_detail.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f7bb5a6fa..715680f4f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -24,7 +24,8 @@ + android:label="@string/title_videoitem_detail" + android:theme="@style/AppTheme"> diff --git a/app/src/main/java/org/schabi/newpipe/PlayVideoActivity.java b/app/src/main/java/org/schabi/newpipe/PlayVideoActivity.java index 825f69949..d5fea8c3e 100644 --- a/app/src/main/java/org/schabi/newpipe/PlayVideoActivity.java +++ b/app/src/main/java/org/schabi/newpipe/PlayVideoActivity.java @@ -56,7 +56,6 @@ public class PlayVideoActivity extends AppCompatActivity { public static final String START_POSITION = "start_position"; private static final long HIDING_DELAY = 3000; - private static final long TAB_HIDING_DELAY = 100; private String videoUrl = ""; diff --git a/app/src/main/java/org/schabi/newpipe/VideoInfo.java b/app/src/main/java/org/schabi/newpipe/VideoInfo.java index c7c051945..89e576aae 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoInfo.java +++ b/app/src/main/java/org/schabi/newpipe/VideoInfo.java @@ -1,7 +1,5 @@ package org.schabi.newpipe; -import android.graphics.Bitmap; - import org.schabi.newpipe.services.AbstractVideoInfo; import java.util.List; @@ -27,11 +25,10 @@ import java.util.List; */ /**Info object for opened videos, ie the video ready to play.*/ +@SuppressWarnings("ALL") public class VideoInfo extends AbstractVideoInfo { - private static final String TAG = VideoInfo.class.toString(); public String uploader_thumbnail_url = ""; - public Bitmap uploader_thumbnail = null; public String description = ""; public VideoStream[] videoStreams = null; public AudioStream[] audioStreams = null; @@ -89,6 +86,7 @@ public class VideoInfo extends AbstractVideoInfo { } } + @SuppressWarnings("unused") public static class AudioStream { public String url = ""; public int format = -1; diff --git a/app/src/main/java/org/schabi/newpipe/VideoInfoItemViewCreator.java b/app/src/main/java/org/schabi/newpipe/VideoInfoItemViewCreator.java index efd752788..c925a40d3 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoInfoItemViewCreator.java +++ b/app/src/main/java/org/schabi/newpipe/VideoInfoItemViewCreator.java @@ -27,8 +27,6 @@ import android.widget.TextView; */ class VideoInfoItemViewCreator { - private static final String TAG = VideoInfoItemViewCreator.class.toString(); - private final LayoutInflater inflater; public VideoInfoItemViewCreator(LayoutInflater inflater) { diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java b/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java index 84009069a..1a0e75901 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java @@ -7,6 +7,7 @@ import android.content.SharedPreferences; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.graphics.Point; import android.os.Bundle; import android.os.Handler; import android.preference.PreferenceManager; @@ -27,7 +28,6 @@ import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.RelativeLayout; -import android.widget.ScrollView; import android.widget.TextView; import android.view.MenuItem; @@ -84,6 +84,10 @@ public class VideoItemDetailFragment extends Fragment { private VideoInfo currentVideoInfo = null; private boolean showNextVideoItem = false; + private View thumbnailWindowLayout; + private FloatingActionButton playVideoButton; + private final Point initialThumbnailPos = new Point(0, 0); + public interface OnInvokeCreateOptionsMenuListener { void createOptionsMenu(); } @@ -202,7 +206,7 @@ public class VideoItemDetailFragment extends Fragment { VideoInfoItemViewCreator videoItemViewCreator = new VideoInfoItemViewCreator(LayoutInflater.from(getActivity())); - ScrollView contentMainView = (ScrollView) activity.findViewById(R.id.detailMainContent); + RelativeLayout textContentLayout = (RelativeLayout) activity.findViewById(R.id.detailTextContentLayout); ProgressBar progressBar = (ProgressBar) activity.findViewById(R.id.detailProgressBar); TextView videoTitleView = (TextView) activity.findViewById(R.id.detailVideoTitleView); TextView uploaderView = (TextView) activity.findViewById(R.id.detailUploaderView); @@ -221,7 +225,8 @@ public class VideoItemDetailFragment extends Fragment { Button nextVideoButton = (Button) activity.findViewById(R.id.detailNextVideoButton); Button similarVideosButton = (Button) activity.findViewById(R.id.detailShowSimilarButton); - contentMainView.setVisibility(View.VISIBLE); + textContentLayout.setVisibility(View.VISIBLE); + playVideoButton.setVisibility(View.VISIBLE); progressBar.setVisibility(View.GONE); if(!showNextVideoItem) { nextVideoRootFrame.setVisibility(View.GONE); @@ -239,9 +244,6 @@ public class VideoItemDetailFragment extends Fragment { viewCountView.setText( String.format( res.getString(R.string.viewCountText), localisedViewCount)); - /*viewCountView.setText(localisedViewCount - + " " + activity.getString(R.string.viewSufix)); */ - thumbsUpView.setText(nf.format(info.like_count)); thumbsDownView.setText(nf.format(info.dislike_count)); @@ -354,8 +356,11 @@ public class VideoItemDetailFragment extends Fragment { @Override public void onActivityCreated(Bundle savedInstanceBundle) { super.onActivityCreated(savedInstanceBundle); - FloatingActionButton playVideoButton = - (FloatingActionButton) getActivity().findViewById(R.id.playVideoButton); + Activity a = getActivity(); + playVideoButton = (FloatingActionButton) a.findViewById(R.id.playVideoButton); + thumbnailWindowLayout = a.findViewById(R.id.detailVideoThumbnailWindowLayout); + Button backgroundButton = (Button) + a.findViewById(R.id.detailVideoThumbnailWindowBackgroundButton); // Sometimes when this fragment is not visible it still gets initiated // then we must not try to access objects of this fragment. @@ -394,6 +399,13 @@ public class VideoItemDetailFragment extends Fragment { } }); + backgroundButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + actionBarHandler.playVideo(); + } + }); + Button similarVideosButton = (Button) activity.findViewById(R.id.detailShowSimilarButton); similarVideosButton.setOnClickListener(new View.OnClickListener() { @Override @@ -408,9 +420,26 @@ public class VideoItemDetailFragment extends Fragment { activity.startActivity(intent); } }); + + ImageView thumbnailView = (ImageView) activity.findViewById(R.id.detailThumbnailView); + thumbnailView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { + // This is used to synchronize the thumbnailWindowButton and the playVideoButton + // inside the ScrollView with the actual size of the thumbnail. + @Override + public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { + RelativeLayout.LayoutParams newWindowLayoutParams = + (RelativeLayout.LayoutParams) thumbnailWindowLayout.getLayoutParams(); + newWindowLayoutParams.height = bottom - top; + thumbnailWindowLayout.setLayoutParams(newWindowLayoutParams); + //noinspection SuspiciousNameCombination + initialThumbnailPos.set(top, left); + } + }); } } + + /**Returns the java.util.Locale object which corresponds to the locale set in NewPipe's preferences. * Currently not affected by the device's locale.*/ private Locale getPreferredLocale() { @@ -418,7 +447,8 @@ public class VideoItemDetailFragment extends Fragment { String languageKey = getContext().getString(R.string.searchLanguage); //i know the following line defaults languageCode to "en", but java is picky about uninitialised values // Schabi: well lint tels me the value is redundant. I'll suppress it for now. - @SuppressWarnings("UnusedAssignment") String languageCode = "en"; + @SuppressWarnings("UnusedAssignment") + String languageCode = "en"; languageCode = sp.getString(languageKey, "en"); if(languageCode.length() == 2) { diff --git a/app/src/main/java/org/schabi/newpipe/VideoListAdapter.java b/app/src/main/java/org/schabi/newpipe/VideoListAdapter.java index 75783f416..4e35a5a20 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoListAdapter.java +++ b/app/src/main/java/org/schabi/newpipe/VideoListAdapter.java @@ -33,8 +33,6 @@ import java.util.Vector; */ class VideoListAdapter extends BaseAdapter { - private static final String TAG = VideoListAdapter.class.toString(); - private final Context context; private final VideoInfoItemViewCreator viewCreator; private Vector videoList = new Vector<>(); diff --git a/app/src/main/java/org/schabi/newpipe/services/SearchEngine.java b/app/src/main/java/org/schabi/newpipe/services/SearchEngine.java index 42b0fed6c..98aa42ae5 100644 --- a/app/src/main/java/org/schabi/newpipe/services/SearchEngine.java +++ b/app/src/main/java/org/schabi/newpipe/services/SearchEngine.java @@ -25,6 +25,7 @@ import java.util.Vector; * along with NewPipe. If not, see . */ +@SuppressWarnings("ALL") public interface SearchEngine { diff --git a/app/src/main/java/org/schabi/newpipe/services/ServiceList.java b/app/src/main/java/org/schabi/newpipe/services/ServiceList.java index 53bba3ffb..da1b293fb 100644 --- a/app/src/main/java/org/schabi/newpipe/services/ServiceList.java +++ b/app/src/main/java/org/schabi/newpipe/services/ServiceList.java @@ -26,6 +26,8 @@ import org.schabi.newpipe.services.youtube.YoutubeService; /**Provides access to the video streaming services supported by NewPipe. * Currently only Youtube until the API becomes more stable.*/ + +@SuppressWarnings("ALL") public class ServiceList { private static final String TAG = ServiceList.class.toString(); private static final StreamingService[] services = { diff --git a/app/src/main/java/org/schabi/newpipe/services/VideoExtractor.java b/app/src/main/java/org/schabi/newpipe/services/VideoExtractor.java index 01ff361ef..dfe2e161f 100644 --- a/app/src/main/java/org/schabi/newpipe/services/VideoExtractor.java +++ b/app/src/main/java/org/schabi/newpipe/services/VideoExtractor.java @@ -23,6 +23,8 @@ package org.schabi.newpipe.services; import org.schabi.newpipe.VideoInfo; /**Scrapes information from a video streaming service (eg, YouTube).*/ + +@SuppressWarnings("ALL") public abstract class VideoExtractor { protected final String pageUrl; protected VideoInfo videoInfo; diff --git a/app/src/main/res/drawable-nodpi/dummy_thumbnail_dark.png b/app/src/main/res/drawable-nodpi/dummy_thumbnail_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..7123a6f01be7a605dc01509570eb6017caddbb32 GIT binary patch literal 188 zcmeAS@N?(olHy`uVBq!ia0vp^?m(=;!3HGP2tA(wq}Y|gW!U_%O?XxI14-? zi-9_>gD|6$#_S59AbW|YuPgg~9u8r7h2v{Jodybddb&7 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -