Fix #13 - #14 - #15 Settings for auto fullscreen/ disable auto playblack / pause videos in fullscreen with key back
This commit is contained in:
parent
f31b6e9ac8
commit
1194209c82
|
@ -6,7 +6,16 @@
|
||||||
<string name="set_video_language_choice" translatable="false">set_video_language_choice</string>
|
<string name="set_video_language_choice" translatable="false">set_video_language_choice</string>
|
||||||
<string name="set_video_quality_choice" translatable="false">set_video_quality_choice</string>
|
<string name="set_video_quality_choice" translatable="false">set_video_quality_choice</string>
|
||||||
<string name="set_video_cache_choice" translatable="false">set_video_cache_choice</string>
|
<string name="set_video_cache_choice" translatable="false">set_video_cache_choice</string>
|
||||||
|
<string name="set_autoplay_choice" translatable="false">set_autoplay_choice</string>
|
||||||
<string name="set_theme_choice" translatable="false">set_theme_choice</string>
|
<string name="set_theme_choice" translatable="false">set_theme_choice</string>
|
||||||
|
<string name="set_fullscreen_choice" translatable="false">set_fullscreen_choice</string>
|
||||||
|
|
||||||
|
|
||||||
|
<string name="set_autoplay">Lecture automatique</string>
|
||||||
|
<string name="set_autoplay_description">Si activé, les vidéos seront lues automatiquement</string>
|
||||||
|
|
||||||
|
<string name="set_fullscreen">Plein écran</string>
|
||||||
|
<string name="set_fullscreen_description">Ouvre automatiquement les vidéos en plein écran</string>
|
||||||
|
|
||||||
<string name="delete_account_comment">Supprimer tous les commentaires</string>
|
<string name="delete_account_comment">Supprimer tous les commentaires</string>
|
||||||
<string name="delete_account_comment_confirm">Etes-vous sûr de vouloir supprimer tous les commentaires de ce compte pour vos vidéos ?</string>
|
<string name="delete_account_comment_confirm">Etes-vous sûr de vouloir supprimer tous les commentaires de ce compte pour vos vidéos ?</string>
|
||||||
|
|
|
@ -5,10 +5,20 @@
|
||||||
<string name="set_video_language_choice" translatable="false">set_video_language_choice</string>
|
<string name="set_video_language_choice" translatable="false">set_video_language_choice</string>
|
||||||
<string name="set_video_quality_choice" translatable="false">set_video_quality_choice</string>
|
<string name="set_video_quality_choice" translatable="false">set_video_quality_choice</string>
|
||||||
<string name="set_video_cache_choice" translatable="false">set_video_cache_choice</string>
|
<string name="set_video_cache_choice" translatable="false">set_video_cache_choice</string>
|
||||||
|
<string name="set_autoplay_choice" translatable="false">set_autoplay_choice</string>
|
||||||
<string name="set_theme_choice" translatable="false">set_theme_choice</string>
|
<string name="set_theme_choice" translatable="false">set_theme_choice</string>
|
||||||
|
<string name="set_fullscreen_choice" translatable="false">set_fullscreen_choice</string>
|
||||||
|
|
||||||
|
|
||||||
|
<string name="set_autoplay">Automatic playback</string>
|
||||||
|
<string name="set_autoplay_description">If enabled, videos will be played automatically</string>
|
||||||
|
|
||||||
|
<string name="set_fullscreen">Fullscreen</string>
|
||||||
|
<string name="set_fullscreen_description">Automatically open videos in fullscreen</string>
|
||||||
|
|
||||||
<string name="add_public_reply">Add a public reply</string>
|
<string name="add_public_reply">Add a public reply</string>
|
||||||
|
|
||||||
|
|
||||||
<plurals name="number_of_replies">
|
<plurals name="number_of_replies">
|
||||||
<item quantity="one">%d reply</item>
|
<item quantity="one">%d reply</item>
|
||||||
<item quantity="other">%d replies</item>
|
<item quantity="other">%d replies</item>
|
||||||
|
|
|
@ -146,7 +146,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
private VideoData.Video peertube;
|
private VideoData.Video peertube;
|
||||||
private int mode;
|
private int mode;
|
||||||
private Map<String, List<PlaylistExist>> playlists;
|
private Map<String, List<PlaylistExist>> playlists;
|
||||||
private boolean playInMinimized;
|
private boolean playInMinimized, autoPlay, autoFullscreen;
|
||||||
private boolean onStopCalled;
|
private boolean onStopCalled;
|
||||||
private List<Caption> captions;
|
private List<Caption> captions;
|
||||||
private String max_id;
|
private String max_id;
|
||||||
|
@ -221,6 +221,8 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
binding.writeCommentContainer.setVisibility(View.GONE);
|
binding.writeCommentContainer.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
playInMinimized = sharedpreferences.getBoolean(getString(R.string.set_video_minimize_choice), true);
|
playInMinimized = sharedpreferences.getBoolean(getString(R.string.set_video_minimize_choice), true);
|
||||||
|
autoPlay = sharedpreferences.getBoolean(getString(R.string.set_autoplay_choice), true);
|
||||||
|
autoFullscreen = sharedpreferences.getBoolean(getString(R.string.set_fullscreen_choice), false);
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O
|
||||||
|| !getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)) {
|
|| !getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)) {
|
||||||
playInMinimized = false;
|
playInMinimized = false;
|
||||||
|
@ -305,6 +307,10 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
playVideo();
|
playVideo();
|
||||||
}
|
}
|
||||||
registBroadcastReceiver();
|
registBroadcastReceiver();
|
||||||
|
if( autoFullscreen) {
|
||||||
|
openFullscreenDialog();
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -394,17 +400,24 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
|
|
||||||
private void playVideo() {
|
private void playVideo() {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.setPlayWhenReady(false);
|
|
||||||
player.release();
|
player.release();
|
||||||
player = ExoPlayerFactory.newSimpleInstance(PeertubeActivity.this);
|
player = ExoPlayerFactory.newSimpleInstance(PeertubeActivity.this);
|
||||||
binding.mediaVideo.setPlayer(player);
|
binding.mediaVideo.setPlayer(player);
|
||||||
binding.loader.setVisibility(View.GONE);
|
binding.loader.setVisibility(View.GONE);
|
||||||
player.setPlayWhenReady(true);
|
player.setPlayWhenReady(autoPlay);
|
||||||
captions = null;
|
captions = null;
|
||||||
}
|
}
|
||||||
|
if( autoFullscreen) {
|
||||||
|
fullscreen = FullScreenMediaController.fullscreen.ON;
|
||||||
|
setFullscreen(FullScreenMediaController.fullscreen.ON);
|
||||||
|
fullScreenMode = true;
|
||||||
|
openFullscreenDialog();
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||||
|
} else {
|
||||||
fullscreen = FullScreenMediaController.fullscreen.OFF;
|
fullscreen = FullScreenMediaController.fullscreen.OFF;
|
||||||
setFullscreen(FullScreenMediaController.fullscreen.OFF);
|
setFullscreen(FullScreenMediaController.fullscreen.OFF);
|
||||||
fullScreenMode = false;
|
fullScreenMode = false;
|
||||||
|
}
|
||||||
|
|
||||||
binding.peertubePlaylist.setVisibility(View.VISIBLE);
|
binding.peertubePlaylist.setVisibility(View.VISIBLE);
|
||||||
binding.peertubeBookmark.setVisibility(View.GONE);
|
binding.peertubeBookmark.setVisibility(View.GONE);
|
||||||
|
@ -655,7 +668,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
.createMediaSource(Uri.parse(apiResponse.getPeertubes().get(0).getStreamingPlaylists().get(0).getPlaylistUrl()));
|
.createMediaSource(Uri.parse(apiResponse.getPeertubes().get(0).getStreamingPlaylists().get(0).getPlaylistUrl()));
|
||||||
player.prepare(hlsMediaSource);
|
player.prepare(hlsMediaSource);
|
||||||
}
|
}
|
||||||
player.setPlayWhenReady(true);
|
player.setPlayWhenReady(autoPlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -853,7 +866,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
binding = null;
|
binding = null;
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.setPlayWhenReady(false);
|
|
||||||
player.release();
|
player.release();
|
||||||
}
|
}
|
||||||
unregisterReceiver();
|
unregisterReceiver();
|
||||||
|
@ -965,7 +977,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
super.onResume();
|
super.onResume();
|
||||||
onStopCalled = false;
|
onStopCalled = false;
|
||||||
if (player != null && !player.isPlaying()) {
|
if (player != null && !player.isPlaying()) {
|
||||||
player.setPlayWhenReady(true);
|
player.setPlayWhenReady(autoPlay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1025,8 +1037,15 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
|
|
||||||
fullScreenDialog = new Dialog(this, android.R.style.Theme_Black_NoTitleBar_Fullscreen) {
|
fullScreenDialog = new Dialog(this, android.R.style.Theme_Black_NoTitleBar_Fullscreen) {
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if (fullScreenMode) {
|
if( player != null && player.isPlaying() && fullScreenMode) {
|
||||||
|
player.setPlayWhenReady(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if( fullScreenMode) {
|
||||||
closeFullscreenDialog();
|
closeFullscreenDialog();
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||||
|
Handler handler = new Handler();
|
||||||
|
handler.postDelayed(() -> setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR), 2000);
|
||||||
}
|
}
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,6 +137,16 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
||||||
assert set_video_minimize_choice != null;
|
assert set_video_minimize_choice != null;
|
||||||
editor.putBoolean(getString(R.string.set_video_minimize_choice), set_video_minimize_choice.isChecked());
|
editor.putBoolean(getString(R.string.set_video_minimize_choice), set_video_minimize_choice.isChecked());
|
||||||
}
|
}
|
||||||
|
if (key.compareTo(getString(R.string.set_autoplay_choice)) == 0) {
|
||||||
|
SwitchPreference set_autoplay_choice = findPreference(getString(R.string.set_autoplay_choice));
|
||||||
|
assert set_autoplay_choice != null;
|
||||||
|
editor.putBoolean(getString(R.string.set_autoplay_choice), set_autoplay_choice.isChecked());
|
||||||
|
}
|
||||||
|
if (key.compareTo(getString(R.string.set_fullscreen_choice)) == 0) {
|
||||||
|
SwitchPreference set_fullscreen_choice = findPreference(getString(R.string.set_fullscreen_choice));
|
||||||
|
assert set_fullscreen_choice != null;
|
||||||
|
editor.putBoolean(getString(R.string.set_fullscreen_choice), set_fullscreen_choice.isChecked());
|
||||||
|
}
|
||||||
if (key.compareTo(getString(R.string.set_video_language_choice)) == 0) {
|
if (key.compareTo(getString(R.string.set_video_language_choice)) == 0) {
|
||||||
MultiSelectListPreference set_video_language_choice = findPreference(getString(R.string.set_video_language_choice));
|
MultiSelectListPreference set_video_language_choice = findPreference(getString(R.string.set_video_language_choice));
|
||||||
assert set_video_language_choice != null;
|
assert set_video_language_choice != null;
|
||||||
|
@ -208,12 +218,27 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
||||||
assert set_video_cache_choice != null;
|
assert set_video_cache_choice != null;
|
||||||
set_video_cache_choice.setValue(video_cache / 10);
|
set_video_cache_choice.setValue(video_cache / 10);
|
||||||
|
|
||||||
|
//****** Minimized videos *******
|
||||||
boolean minimized = sharedpref.getBoolean(getString(R.string.set_video_minimize_choice), true);
|
boolean minimized = sharedpref.getBoolean(getString(R.string.set_video_minimize_choice), true);
|
||||||
SwitchPreference set_video_minimize_choice = findPreference(getString(R.string.set_video_minimize_choice));
|
SwitchPreference set_video_minimize_choice = findPreference(getString(R.string.set_video_minimize_choice));
|
||||||
assert set_video_minimize_choice != null;
|
assert set_video_minimize_choice != null;
|
||||||
set_video_minimize_choice.setChecked(minimized);
|
set_video_minimize_choice.setChecked(minimized);
|
||||||
|
|
||||||
|
|
||||||
|
//****** Autoplay videos *******
|
||||||
|
boolean autoplay = sharedpref.getBoolean(getString(R.string.set_autoplay_choice), true);
|
||||||
|
SwitchPreference set_autoplay_choice = findPreference(getString(R.string.set_autoplay_choice));
|
||||||
|
assert set_autoplay_choice != null;
|
||||||
|
set_autoplay_choice.setChecked(autoplay);
|
||||||
|
|
||||||
|
|
||||||
|
//****** Fullscreen videos *******
|
||||||
|
boolean fullscreen = sharedpref.getBoolean(getString(R.string.set_fullscreen_choice), false);
|
||||||
|
SwitchPreference set_fullscreen_choice = findPreference(getString(R.string.set_fullscreen_choice));
|
||||||
|
assert set_fullscreen_choice != null;
|
||||||
|
set_fullscreen_choice.setChecked(fullscreen);
|
||||||
|
|
||||||
|
//****** Language filter *********
|
||||||
LinkedHashMap<String, String> languages = new LinkedHashMap<>(peertubeInformation.getLanguages());
|
LinkedHashMap<String, String> languages = new LinkedHashMap<>(peertubeInformation.getLanguages());
|
||||||
List<CharSequence> entriesLanguages = new ArrayList<>();
|
List<CharSequence> entriesLanguages = new ArrayList<>();
|
||||||
List<CharSequence> valuesLanguages = new ArrayList<>();
|
List<CharSequence> valuesLanguages = new ArrayList<>();
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M21,11l0,-8l-8,0l3.29,3.29l-10,10l-3.29,-3.29l0,8l8,0l-3.29,-3.29l10,-10z"/>
|
||||||
|
</vector>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M8,5v14l11,-7z"/>
|
||||||
|
</vector>
|
|
@ -21,6 +21,18 @@
|
||||||
android:summary="@string/set_video_quality_description"
|
android:summary="@string/set_video_quality_description"
|
||||||
android:title="@string/set_quality_mode" />
|
android:title="@string/set_quality_mode" />
|
||||||
|
|
||||||
|
<androidx.preference.SwitchPreference
|
||||||
|
android:icon="@drawable/ic_baseline_play_arrow_24"
|
||||||
|
android:key="@string/set_autoplay_choice"
|
||||||
|
android:summary="@string/set_autoplay_description"
|
||||||
|
android:title="@string/set_autoplay" />
|
||||||
|
|
||||||
|
<androidx.preference.SwitchPreference
|
||||||
|
android:icon="@drawable/ic_baseline_open_in_full_24"
|
||||||
|
android:key="@string/set_fullscreen_choice"
|
||||||
|
android:summary="@string/set_fullscreen_description"
|
||||||
|
android:title="@string/set_fullscreen" />
|
||||||
|
|
||||||
<androidx.preference.SeekBarPreference
|
<androidx.preference.SeekBarPreference
|
||||||
android:icon="@drawable/ic_baseline_storage_24"
|
android:icon="@drawable/ic_baseline_storage_24"
|
||||||
android:defaultValue="10"
|
android:defaultValue="10"
|
||||||
|
|
Loading…
Reference in New Issue