Skip to content

Commit c62ad66

Browse files
committed
New:
- Show video title instead of stream url in vlc/MXPlayer - remember rotation Fix: - sensore controlled landscape rotation in the player
1 parent d8bdada commit c62ad66

6 files changed

Lines changed: 29 additions & 13 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ public void playAudio() {
310310
intent.setAction(Intent.ACTION_VIEW);
311311
intent.setDataAndType(Uri.parse(audioStream.url),
312312
VideoInfo.getMimeById(audioStream.format));
313+
intent.putExtra(Intent.EXTRA_TITLE, videoTitle);
314+
intent.putExtra("title", videoTitle);
313315
context.startActivity(intent); // HERE !!!
314316
} catch (Exception e) {
315317
e.printStackTrace();

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

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package org.schabi.newpipe;
22

3+
import android.content.Context;
34
import android.content.Intent;
5+
import android.content.SharedPreferences;
46
import android.content.pm.ActivityInfo;
57
import android.content.res.Configuration;
68
import android.content.res.Resources;
@@ -72,6 +74,9 @@ public class PlayVideoActivity extends AppCompatActivity {
7274
private boolean isLandscape = true;
7375
private boolean hasSoftKeys = false;
7476

77+
private SharedPreferences prefs;
78+
private static final String PREF_IS_LANDSCAPE = "is_landscape";
79+
7580
@Override
7681
protected void onCreate(Bundle savedInstanceState) {
7782
super.onCreate(savedInstanceState);
@@ -136,12 +141,16 @@ public void onSystemUiVisibilityChange(int visibility) {
136141
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
137142
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
138143
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
144+
145+
prefs = getPreferences(Context.MODE_PRIVATE);
146+
if(prefs.getBoolean(PREF_IS_LANDSCAPE, false) && !isLandscape) {
147+
toggleOrientation();
148+
}
139149
}
140150

141151
@Override
142152
protected void onPostCreate(Bundle savedInstanceState) {
143153
super.onPostCreate(savedInstanceState);
144-
145154
}
146155

147156
@Override
@@ -179,14 +188,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
179188
startActivity(Intent.createChooser(intent, getString(R.string.shareDialogTitle)));
180189
break;
181190
case R.id.menu_item_screen_rotation:
182-
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
183-
if(display.getRotation() == Surface.ROTATION_0
184-
|| display.getRotation() == Surface.ROTATION_180) {
185-
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
186-
} else if(display.getRotation() == Surface.ROTATION_90
187-
|| display.getRotation() == Surface.ROTATION_270) {
188-
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
189-
}
191+
toggleOrientation();
190192
break;
191193
default:
192194
Log.e(TAG, "Error: MenuItem not known");
@@ -319,4 +321,17 @@ public boolean checkIfLandscape() {
319321
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
320322
return displayMetrics.heightPixels < displayMetrics.widthPixels;
321323
}
324+
325+
private void toggleOrientation() {
326+
if(isLandscape) {
327+
isLandscape = false;
328+
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
329+
} else {
330+
isLandscape = true;
331+
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
332+
}
333+
SharedPreferences.Editor editor = prefs.edit();
334+
editor.putBoolean(PREF_IS_LANDSCAPE, isLandscape);
335+
editor.commit();
336+
}
322337
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ protected void onCreate(Bundle savedInstanceState) {
146146

147147
SettingsActivity.initSettings(this);
148148

149-
// TODO: If exposing deep links into your app, handle intents here.
150149
}
151150

152151
/**

app/src/main/res/values-de/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<string name="fdroidKoreUrl">https://f-droid.org/repository/browse/?fdfilter=Kore&amp;fdid=org.xbmc.kore</string>
3636
<string name="showPlayWithKodiTitle">Zeige \"Mit Kodi abspielen\" Option</string>
3737
<string name="showPlayWithKodiSummary">Zeigt eine Option an, über die man Videos mit dem Kodi Mediacenter abspielen kann.</string>
38-
<string name="leftHandLayoutTitle">Linkshänder freundliches Layout.</string>
38+
<string name="leftPlayButtonTitle">Zeige play button auf der linken seite.</string>
3939
<string name="playAudio">Audio</string>
4040
<string name="defaultAudioFormatTitle">Bevorzugtes Audio Format</string>
4141
<string name="webMAudioDescription">WebM - freies Format</string>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<string name="fdroidKoreUrl">https://f-droid.org/repository/browse/?fdfilter=Kore&amp;fdid=org.xbmc.kore</string>
3636
<string name="showPlayWithKodiTitle">Show \"Play with Kodi\" option</string>
3737
<string name="showPlayWithKodiSummary">Displays an option to play a video via Kodi media center.</string>
38-
<string name="leftHandLayoutTitle">Left hand friendly layout.</string>
38+
<string name="leftPlayButtonTitle">Show play button on the left side.</string>
3939
<string name="playAudio">Audio</string>
4040
<string name="defaultAudioFormatTitle">Default audio format</string>
4141
<string name="webMAudioDescription">WebM - free format</string>

app/src/main/res/xml/settings_screen.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
<CheckBoxPreference
3838
android:key="@string/leftHandLayout"
39-
android:title="@string/leftHandLayoutTitle"
39+
android:title="@string/leftPlayButtonTitle"
4040
android:defaultValue="false" />
4141

4242
<ListPreference

0 commit comments

Comments
 (0)