diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index fa781a2..4f85fca 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -1,3 +1,21 @@ +/* + * Copyright 2018 Stefan Schüller + * + * License: GPL-3.0+ + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.schueller.peertube.activity; import android.content.ComponentName; @@ -5,6 +23,7 @@ import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.SharedPreferences; +import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.net.Uri; import android.os.Bundle; @@ -38,6 +57,7 @@ import com.google.android.exoplayer2.decoder.DecoderCounters; import com.google.android.exoplayer2.ui.PlayerView; import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.video.VideoRendererEventListener; +import com.mikepenz.iconics.Iconics; import com.squareup.picasso.Picasso; import net.schueller.peertube.R; import net.schueller.peertube.fragment.VideoOptionsFragment; @@ -53,6 +73,7 @@ import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; +import static net.schueller.peertube.helper.Constants.BACKGROUND_PLAY_PREF_KEY; import static net.schueller.peertube.helper.Constants.DEFAULT_THEME; import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY; @@ -64,6 +85,8 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere private PlayerView simpleExoPlayerView; private Intent videoPlayerIntent; private Context context = this; + private TextView fullscreenButton; + private Boolean isFullscreen = false; boolean mBound = false; VideoPlayerService mService; @@ -111,8 +134,24 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere simpleExoPlayerView = new PlayerView(this); simpleExoPlayerView = findViewById(R.id.video_view); - videoPlayerIntent = new Intent(this, VideoPlayerService.class); - bindService(videoPlayerIntent, mConnection, Context.BIND_AUTO_CREATE); + // Full screen Icon + fullscreenButton = findViewById(R.id.exo_fullscreen); + fullscreenButton.setText(R.string.video_expand_icon); + new Iconics.IconicsBuilder().ctx(this).on(fullscreenButton).build(); + + fullscreenButton.setOnClickListener(view -> { + Log.d(TAG, "Fullscreen"); + if (!isFullscreen) { + isFullscreen = true; + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); + fullscreenButton.setText(R.string.video_compress_icon); + } else { + isFullscreen = false; + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + fullscreenButton.setText(R.string.video_expand_icon); + } + new Iconics.IconicsBuilder().ctx(this).on(fullscreenButton).build(); + }); } @@ -381,6 +420,16 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere @Override protected void onStop() { super.onStop(); + +// SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); +// +// Log.v(TAG, "" + sharedPref.getBoolean(BACKGROUND_PLAY_PREF_KEY, false)); +// +// if (!sharedPref.getBoolean(BACKGROUND_PLAY_PREF_KEY, false)) { +// Log.v(TAG, "BACKGROUND_PLAY_PREF_KEY..."); +// stopService(new Intent(this, VideoPlayerService.class)); +// } + if (mBound) { unbindService(mConnection); mBound = false; @@ -391,6 +440,11 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere @Override protected void onStart() { super.onStart(); +// +// if (!mBound) { +// videoPlayerIntent = new Intent(this, VideoPlayerService.class); +// bindService(videoPlayerIntent, mConnection, Context.BIND_AUTO_CREATE); +// } Log.v(TAG, "onStart()..."); } diff --git a/app/src/main/res/layout/exo_playback_control_view.xml b/app/src/main/res/layout/exo_playback_control_view.xml index 05296fc..8659b6f 100644 --- a/app/src/main/res/layout/exo_playback_control_view.xml +++ b/app/src/main/res/layout/exo_playback_control_view.xml @@ -1,16 +1,15 @@ - - + android:background="@null" + android:paddingTop="0dp" + android:src="@drawable/ic_action_more_vert" + android:tint="#ffffff" /> @@ -44,23 +43,28 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" - android:paddingTop="4dp" - android:orientation="horizontal"> + android:orientation="horizontal" + android:paddingTop="4dp"> - + - + - + - + - + @@ -70,7 +74,6 @@ android:layout_weight="1" /> - - + android:textColor="#FFBEBEBE" + android:textSize="14sp" /> - + android:gravity="center_vertical" + android:paddingLeft="6dp" + android:paddingRight="6dp" + android:textColor="#FFBEBEBE" + android:textSize="14sp" /> + + + @@ -116,9 +132,9 @@ + android:layout_weight="1" + app:played_color="?attr/colorPrimary" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6e367c6..d21d156 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -91,5 +91,9 @@ {faw-check} + {faw-expand} + {faw-compress} + Background Playback + If enabled, continues to play video in background. diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index 9a964c2..d287b5d 100644 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -10,6 +10,12 @@ android:singleLine="true" android:title="@string/pref_title_peertube_server" /> + + + + + +