Skip to content

Commit 0801598

Browse files
committed
- added preference for "next video" item
- display if a url is supported or nod
1 parent d9e690f commit 0801598

9 files changed

Lines changed: 181 additions & 138 deletions

File tree

app/src/main/java/org/schabi/newpipe/VideoItemDetailActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.view.Menu;
99
import android.view.MenuInflater;
1010
import android.view.MenuItem;
11+
import android.widget.Toast;
1112

1213

1314
/**
@@ -74,6 +75,10 @@ protected void onCreate(Bundle savedInstanceState) {
7475
break;
7576
}
7677
}
78+
if(extractor == null) {
79+
Toast.makeText(this, R.string.urlNotSupportedText, Toast.LENGTH_LONG)
80+
.show();
81+
}
7782
arguments.putString(VideoItemDetailFragment.VIDEO_URL,
7883
extractor.getVideoUrl(extractor.getVideoId(videoUrl)));
7984
arguments.putBoolean(VideoItemDetailFragment.AUTO_PLAY,

app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import android.widget.RelativeLayout;
2424
import android.widget.ScrollView;
2525
import android.widget.TextView;
26+
import android.content.Context;
2627

2728
import java.net.URL;
2829
import java.util.Vector;
@@ -63,6 +64,8 @@ public class VideoItemDetailFragment extends Fragment {
6364
private Thread extractorThread = null;
6465
private VideoInfo currentVideoInfo = null;
6566

67+
private boolean showNextVideoItem = false;
68+
6669
private class ExtractorRunnable implements Runnable {
6770
private Handler h = new Handler();
6871
private Class extractorClass;
@@ -88,11 +91,13 @@ public void run() {
8891
new URL(videoInfo.uploader_thumbnail_url)
8992
.openConnection()
9093
.getInputStream()), SetThumbnailRunnable.CHANNEL_THUMBNAIL));
91-
h.post(new SetThumbnailRunnable(
92-
BitmapFactory.decodeStream(
93-
new URL(videoInfo.nextVideo.thumbnail_url)
94-
.openConnection()
95-
.getInputStream()), SetThumbnailRunnable.NEXT_VIDEO_THUMBNAIL));
94+
if(showNextVideoItem) {
95+
h.post(new SetThumbnailRunnable(
96+
BitmapFactory.decodeStream(
97+
new URL(videoInfo.nextVideo.thumbnail_url)
98+
.openConnection()
99+
.getInputStream()), SetThumbnailRunnable.NEXT_VIDEO_THUMBNAIL));
100+
}
96101
}
97102
} catch (Exception e) {
98103
e.printStackTrace();
@@ -177,13 +182,18 @@ public void updateInfo(VideoInfo info) {
177182
TextView descriptionView = (TextView) a.findViewById(R.id.detailDescriptionView);
178183
ImageView thumbnailView = (ImageView) a.findViewById(R.id.detailThumbnailView);
179184
FrameLayout nextVideoFrame = (FrameLayout) a.findViewById(R.id.detailNextVideoFrame);
185+
RelativeLayout nextVideoRootFrame =
186+
(RelativeLayout) a.findViewById(R.id.detailNextVideoRootLayout);
180187
View nextVideoView = videoItemViewCreator
181188
.getViewByVideoInfoItem(null, nextVideoFrame, info.nextVideo);
182189
nextVideoFrame.addView(nextVideoView);
183190
Button nextVideoButton = (Button) a.findViewById(R.id.detailNextVideoButton);
184191

185192
contentMainView.setVisibility(View.VISIBLE);
186193
progressBar.setVisibility(View.GONE);
194+
if(!showNextVideoItem) {
195+
nextVideoRootFrame.setVisibility(View.GONE);
196+
}
187197

188198
switch (info.videoAvailableStatus) {
189199
case VideoInfo.VIDEO_AVAILABLE: {
@@ -262,6 +272,9 @@ public VideoItemDetailFragment() {
262272
@Override
263273
public void onCreate(Bundle savedInstanceState) {
264274
super.onCreate(savedInstanceState);
275+
Context context = getActivity();
276+
showNextVideoItem = PreferenceManager.getDefaultSharedPreferences(getActivity())
277+
.getBoolean(context.getString(R.string.showNextVideo), true);
265278
}
266279

267280
@Override

app/src/main/res/layout-land/fragment_videoitem_detail.xml

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -134,55 +134,60 @@
134134
android:text="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmodtempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. "
135135
/>
136136

137-
<TextView android:id="@+id/detailNextVideoTitle"
138-
android:layout_width="wrap_content"
139-
android:layout_height="wrap_content"
140-
android:layout_below="@id/detailDescriptionView"
141-
android:layout_alignParentLeft="true"
142-
android:paddingLeft="6dp"
143-
android:paddingRight="6dp"
144-
android:paddingTop="20dp"
145-
android:paddingBottom="6dp"
146-
android:textAppearance="?android:attr/textAppearanceMedium"
147-
android:textColor="@android:color/black"
148-
android:text="@string/nextVideoTitle"
149-
/>
150-
151-
<View android:id="@+id/detailNextVideoSeperationLine"
152-
android:layout_width="fill_parent"
153-
android:layout_height="1dp"
154-
android:layout_marginLeft="6dp"
155-
android:layout_marginRight="6dp"
156-
android:background="@android:color/darker_gray"
157-
android:layout_below="@id/detailNextVideoTitle"
158-
android:layout_alignParentLeft="true" />
159-
160-
<RelativeLayout android:id="@+id/detailNextVidButtonAndContantLayout"
137+
<RelativeLayout android:id="@+id/detailNextVideoRootLayout"
161138
android:layout_width="match_parent"
162139
android:layout_height="wrap_content"
163-
android:layout_below="@id/detailNextVideoSeperationLine">
164-
<FrameLayout
165-
android:id="@+id/detailNextVideoFrame"
166-
android:layout_width="match_parent"
167-
android:layout_height="wrap_content"/>
168-
<Button
169-
android:id="@+id/detailNextVideoButton"
140+
android:layout_below="@id/detailDescriptionView" >
141+
142+
<TextView android:id="@+id/detailNextVideoTitle"
143+
android:layout_width="wrap_content"
144+
android:layout_height="wrap_content"
145+
android:layout_alignParentLeft="true"
146+
android:paddingLeft="6dp"
147+
android:paddingRight="6dp"
148+
android:paddingTop="20dp"
149+
android:paddingBottom="6dp"
150+
android:textAppearance="?android:attr/textAppearanceMedium"
151+
android:textColor="@android:color/black"
152+
android:text="@string/nextVideoTitle"
153+
/>
154+
155+
<View android:id="@+id/detailNextVideoSeperationLine"
156+
android:layout_width="fill_parent"
157+
android:layout_height="1dp"
158+
android:layout_marginLeft="6dp"
159+
android:layout_marginRight="6dp"
160+
android:background="@android:color/darker_gray"
161+
android:layout_below="@id/detailNextVideoTitle"
162+
android:layout_alignParentLeft="true" />
163+
164+
<RelativeLayout android:id="@+id/detailNextVidButtonAndContantLayout"
170165
android:layout_width="match_parent"
171-
android:layout_height="match_parent"
172-
android:layout_alignTop="@id/detailNextVideoFrame"
173-
android:layout_alignBottom="@id/detailNextVideoFrame"
174-
android:background="?attr/selectableItemBackground"/>
166+
android:layout_height="wrap_content"
167+
android:layout_below="@id/detailNextVideoSeperationLine">
168+
<FrameLayout
169+
android:id="@+id/detailNextVideoFrame"
170+
android:layout_width="match_parent"
171+
android:layout_height="wrap_content"/>
172+
<Button
173+
android:id="@+id/detailNextVideoButton"
174+
android:layout_width="match_parent"
175+
android:layout_height="match_parent"
176+
android:layout_alignTop="@id/detailNextVideoFrame"
177+
android:layout_alignBottom="@id/detailNextVideoFrame"
178+
android:background="?attr/selectableItemBackground"/>
179+
</RelativeLayout>
180+
181+
<View android:id="@+id/detailNextVideoSeperationLineEnd"
182+
android:layout_width="fill_parent"
183+
android:layout_height="1dp"
184+
android:layout_marginLeft="6dp"
185+
android:layout_marginRight="6dp"
186+
android:background="@android:color/darker_gray"
187+
android:layout_below="@id/detailNextVidButtonAndContantLayout"
188+
android:layout_alignParentLeft="true" />
175189
</RelativeLayout>
176190

177-
<View android:id="@+id/detailNextVideoSeperationLineEnd"
178-
android:layout_width="fill_parent"
179-
android:layout_height="1dp"
180-
android:layout_marginLeft="6dp"
181-
android:layout_marginRight="6dp"
182-
android:background="@android:color/darker_gray"
183-
android:layout_below="@id/detailNextVidButtonAndContantLayout"
184-
android:layout_alignParentLeft="true" />
185-
186191
<View
187192
android:layout_width="match_parent"
188193
android:layout_height="100dip"

app/src/main/res/layout-sw600dp/fragment_videoitem_detail.xml

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -134,55 +134,60 @@
134134
android:text="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmodtempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. "
135135
/>
136136

137-
<TextView android:id="@+id/detailNextVideoTitle"
138-
android:layout_width="wrap_content"
139-
android:layout_height="wrap_content"
140-
android:layout_below="@id/detailDescriptionView"
141-
android:layout_alignParentLeft="true"
142-
android:paddingLeft="6dp"
143-
android:paddingRight="6dp"
144-
android:paddingTop="20dp"
145-
android:paddingBottom="6dp"
146-
android:textAppearance="?android:attr/textAppearanceMedium"
147-
android:textColor="@android:color/black"
148-
android:text="@string/nextVideoTitle"
149-
/>
150-
151-
<View android:id="@+id/detailNextVideoSeperationLine"
152-
android:layout_width="fill_parent"
153-
android:layout_height="1dp"
154-
android:layout_marginLeft="6dp"
155-
android:layout_marginRight="6dp"
156-
android:background="@android:color/darker_gray"
157-
android:layout_below="@id/detailNextVideoTitle"
158-
android:layout_alignParentLeft="true" />
159-
160-
<RelativeLayout android:id="@+id/detailNextVidButtonAndContantLayout"
137+
<RelativeLayout android:id="@+id/detailNextVideoRootLayout"
161138
android:layout_width="match_parent"
162139
android:layout_height="wrap_content"
163-
android:layout_below="@id/detailNextVideoSeperationLine">
164-
<FrameLayout
165-
android:id="@+id/detailNextVideoFrame"
166-
android:layout_width="match_parent"
167-
android:layout_height="wrap_content"/>
168-
<Button
169-
android:id="@+id/detailNextVideoButton"
140+
android:layout_below="@id/detailDescriptionView" >
141+
142+
<TextView android:id="@+id/detailNextVideoTitle"
143+
android:layout_width="wrap_content"
144+
android:layout_height="wrap_content"
145+
android:layout_alignParentLeft="true"
146+
android:paddingLeft="6dp"
147+
android:paddingRight="6dp"
148+
android:paddingTop="20dp"
149+
android:paddingBottom="6dp"
150+
android:textAppearance="?android:attr/textAppearanceMedium"
151+
android:textColor="@android:color/black"
152+
android:text="@string/nextVideoTitle"
153+
/>
154+
155+
<View android:id="@+id/detailNextVideoSeperationLine"
156+
android:layout_width="fill_parent"
157+
android:layout_height="1dp"
158+
android:layout_marginLeft="6dp"
159+
android:layout_marginRight="6dp"
160+
android:background="@android:color/darker_gray"
161+
android:layout_below="@id/detailNextVideoTitle"
162+
android:layout_alignParentLeft="true" />
163+
164+
<RelativeLayout android:id="@+id/detailNextVidButtonAndContantLayout"
170165
android:layout_width="match_parent"
171-
android:layout_height="match_parent"
172-
android:layout_alignTop="@id/detailNextVideoFrame"
173-
android:layout_alignBottom="@id/detailNextVideoFrame"
174-
android:background="?attr/selectableItemBackground"/>
166+
android:layout_height="wrap_content"
167+
android:layout_below="@id/detailNextVideoSeperationLine">
168+
<FrameLayout
169+
android:id="@+id/detailNextVideoFrame"
170+
android:layout_width="match_parent"
171+
android:layout_height="wrap_content"/>
172+
<Button
173+
android:id="@+id/detailNextVideoButton"
174+
android:layout_width="match_parent"
175+
android:layout_height="match_parent"
176+
android:layout_alignTop="@id/detailNextVideoFrame"
177+
android:layout_alignBottom="@id/detailNextVideoFrame"
178+
android:background="?attr/selectableItemBackground"/>
179+
</RelativeLayout>
180+
181+
<View android:id="@+id/detailNextVideoSeperationLineEnd"
182+
android:layout_width="fill_parent"
183+
android:layout_height="1dp"
184+
android:layout_marginLeft="6dp"
185+
android:layout_marginRight="6dp"
186+
android:background="@android:color/darker_gray"
187+
android:layout_below="@id/detailNextVidButtonAndContantLayout"
188+
android:layout_alignParentLeft="true" />
175189
</RelativeLayout>
176190

177-
<View android:id="@+id/detailNextVideoSeperationLineEnd"
178-
android:layout_width="fill_parent"
179-
android:layout_height="1dp"
180-
android:layout_marginLeft="6dp"
181-
android:layout_marginRight="6dp"
182-
android:background="@android:color/darker_gray"
183-
android:layout_below="@id/detailNextVidButtonAndContantLayout"
184-
android:layout_alignParentLeft="true" />
185-
186191
<View
187192
android:layout_width="match_parent"
188193
android:layout_height="100dip"

0 commit comments

Comments
 (0)