merging with master

This commit is contained in:
chschtsch 2015-12-14 13:01:34 +03:00
parent 320ac82dea
commit 4f57d3a201
17 changed files with 438 additions and 606 deletions

View file

@ -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 = "";

View file

@ -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;

View file

@ -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) {

View file

@ -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) {

View file

@ -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<VideoPreviewInfo> videoList = new Vector<>();

View file

@ -25,6 +25,7 @@ import java.util.Vector;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/
@SuppressWarnings("ALL")
public interface SearchEngine {

View file

@ -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 = {

View file

@ -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;