Release 1.13.0

This commit is contained in:
Thomas 2021-01-16 18:25:59 +01:00
parent a7f9256947
commit d5a5fdf52e
9 changed files with 114 additions and 82 deletions

View File

@ -11,8 +11,8 @@ android {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 30 targetSdkVersion 30
versionCode 37 versionCode 38
versionName "1.12.1" versionName "1.13.0"
multiDexEnabled true multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }

View File

@ -11,6 +11,12 @@
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".PeertubeActivity" /> android:value=".PeertubeActivity" />
</activity> </activity>
<activity
android:name=".expandedcontrols.ExpandedControlsActivity"
android:theme="@style/AppThemeNoActionBar"
/>
<meta-data <meta-data
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME" android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
android:value="app.fedilab.fedilabtube.provider.CastOptionsProvider" /> android:value="app.fedilab.fedilabtube.provider.CastOptionsProvider" />

View File

@ -99,7 +99,7 @@ public class BasePeertubeActivity extends AppCompatActivity {
@Override @Override
public void onSessionStarted(CastSession castSession, String s) { public void onSessionStarted(CastSession castSession, String s) {
onApplicationConnected(castSession); onApplicationConnected(castSession, true);
} }
@Override @Override
@ -123,7 +123,7 @@ public class BasePeertubeActivity extends AppCompatActivity {
@Override @Override
public void onSessionResumed(CastSession castSession, boolean b) { public void onSessionResumed(CastSession castSession, boolean b) {
onApplicationConnected(castSession); onApplicationConnected(castSession, false);
} }
@Override @Override
@ -136,16 +136,20 @@ public class BasePeertubeActivity extends AppCompatActivity {
onApplicationDisconnected(); onApplicationDisconnected();
} }
private void onApplicationConnected(CastSession castSession) { private void onApplicationConnected(CastSession castSession, boolean hide) {
mCastSession = castSession; mCastSession = castSession;
supportInvalidateOptionsMenu(); supportInvalidateOptionsMenu();
player.setPlayWhenReady(false); player.setPlayWhenReady(false);
binding.doubleTapPlayerView.setVisibility(View.INVISIBLE); if (hide) {
binding.doubleTapPlayerView.setVisibility(View.INVISIBLE);
}
binding.minController.castMiniController.setVisibility(View.VISIBLE);
loadCast(); loadCast();
} }
private void onApplicationDisconnected() { private void onApplicationDisconnected() {
binding.doubleTapPlayerView.setVisibility(View.VISIBLE); binding.doubleTapPlayerView.setVisibility(View.VISIBLE);
binding.minController.castMiniController.setVisibility(View.GONE);
supportInvalidateOptionsMenu(); supportInvalidateOptionsMenu();
} }
}; };

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/castMiniController"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
android:visibility="gone">
<fragment
class="com.google.android.gms.cast.framework.media.widget.MiniControllerFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1425,7 +1425,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
@Override @Override
public void onConfigurationChanged(@NotNull Configuration newConfig) { public void onConfigurationChanged(@NotNull Configuration newConfig) {
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
if (binding.castController.getVisibility() == View.VISIBLE) { if (binding.minController.castMiniController.getVisibility() == View.VISIBLE) {
return; return;
} }
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
@ -1478,7 +1478,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
onStopCalled = false; onStopCalled = false;
if (player != null && !player.isPlaying()) { if (player != null && !player.isPlaying() && binding.minController.castMiniController.getVisibility() != View.VISIBLE) {
player.setPlayWhenReady(autoPlay); player.setPlayWhenReady(autoPlay);
if (autoPlay) { if (autoPlay) {
binding.doubleTapPlayerView.hideController(); binding.doubleTapPlayerView.hideController();
@ -1494,7 +1494,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
} }
if (player != null && (!isPlayInMinimized || !playInMinimized)) { if (player != null && (!isPlayInMinimized || !playInMinimized)) {
player.setPlayWhenReady(false); player.setPlayWhenReady(false);
} else if (playInMinimized && binding.castController.getVisibility() != View.VISIBLE) { } else if (playInMinimized && binding.minController.castMiniController.getVisibility() != View.VISIBLE) {
enterVideoMode(); enterVideoMode();
} }
} }

View File

@ -259,11 +259,9 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
if (binding.swipeContainer != null) { binding.swipeContainer.setEnabled(false);
binding.swipeContainer.setEnabled(false); binding.swipeContainer.setRefreshing(false);
binding.swipeContainer.setRefreshing(false); binding.swipeContainer.clearAnimation();
binding.swipeContainer.clearAnimation();
}
if (getActivity() != null) { if (getActivity() != null) {
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null && getView() != null) { if (imm != null && getView() != null) {
@ -431,7 +429,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
} }
public void manageVIewRelationship(APIResponse apiResponse) { public void manageVIewRelationship(APIResponse apiResponse) {
if (apiResponse.getError() != null) { if (apiResponse.getError() != null || apiResponse.getRelationships() == null) {
return; return;
} }
if (relationship == null) { if (relationship == null) {

View File

@ -75,58 +75,9 @@
android:scaleType="fitCenter" android:scaleType="fitCenter"
android:visibility="gone" /> android:visibility="gone" />
<androidx.constraintlayout.widget.ConstraintLayout <include
android:id="@+id/cast_controller" android:id="@+id/min_controller"
android:layout_width="match_parent" layout="@layout/min_controller" />
android:layout_height="match_parent"
android:background="@android:color/black"
android:visibility="gone">
<ImageView
android:id="@+id/cast_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/play"
android:src="@drawable/ic_baseline_play_arrow_32"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cast_loader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<TextView
android:id="@+id/cast_loader_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/please_wait"
android:textColor="?colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/cast_loader_small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.github.ybq.android.spinkit.SpinKitView
android:id="@+id/cast_loader_small"
style="@style/progressBottom"
android:layout_width="wrap_content"
android:layout_height="18dp"
android:layout_gravity="center"
android:layout_marginStart="5dp"
app:SpinKit_Color="?colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/cast_loader_text"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<app.fedilab.fedilabtube.webview.CustomWebview <app.fedilab.fedilabtube.webview.CustomWebview
android:id="@+id/webview_video" android:id="@+id/webview_video"

View File

@ -47,7 +47,6 @@ import static app.fedilab.fedilabtube.helper.Helper.CAST_ID;
public class BasePeertubeActivity extends AppCompatActivity { public class BasePeertubeActivity extends AppCompatActivity {
protected ActivityPeertubeBinding binding; protected ActivityPeertubeBinding binding;
private String chromeCastVideoURL;
protected VideoData.Video peertube; protected VideoData.Video peertube;
protected SimpleExoPlayer player; protected SimpleExoPlayer player;
protected String videoURL; protected String videoURL;
@ -60,8 +59,8 @@ public class BasePeertubeActivity extends AppCompatActivity {
binding = ActivityPeertubeBinding.inflate(getLayoutInflater()); binding = ActivityPeertubeBinding.inflate(getLayoutInflater());
View view = binding.getRoot(); View view = binding.getRoot();
setContentView(view); setContentView(view);
binding.castPlay.setOnClickListener(v -> { binding.minController.castPlay.setOnClickListener(v -> {
binding.castLoader.setVisibility(View.VISIBLE); binding.minController.castLoader.setVisibility(View.VISIBLE);
if (BaseMainActivity.chromeCast != null) { if (BaseMainActivity.chromeCast != null) {
new Thread(() -> { new Thread(() -> {
try { try {
@ -76,11 +75,11 @@ public class BasePeertubeActivity extends AppCompatActivity {
if (icon != -1) { if (icon != -1) {
Handler mainHandler = new Handler(Looper.getMainLooper()); Handler mainHandler = new Handler(Looper.getMainLooper());
int finalIcon = icon; int finalIcon = icon;
Runnable myRunnable = () -> binding.castPlay.setImageResource(finalIcon); Runnable myRunnable = () -> binding.minController.castPlay.setImageResource(finalIcon);
mainHandler.post(myRunnable); mainHandler.post(myRunnable);
} }
Handler mainHandler = new Handler(Looper.getMainLooper()); Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> binding.castLoader.setVisibility(View.GONE); Runnable myRunnable = () -> binding.minController.castLoader.setVisibility(View.GONE);
mainHandler.post(myRunnable); mainHandler.post(myRunnable);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
@ -123,7 +122,7 @@ public class BasePeertubeActivity extends AppCompatActivity {
Handler mainHandler = new Handler(Looper.getMainLooper()); Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> { Runnable myRunnable = () -> {
binding.doubleTapPlayerView.setVisibility(View.VISIBLE); binding.doubleTapPlayerView.setVisibility(View.VISIBLE);
binding.castController.setVisibility(View.GONE); binding.minController.castMiniController.setVisibility(View.GONE);
}; };
mainHandler.post(myRunnable); mainHandler.post(myRunnable);
@ -136,14 +135,14 @@ public class BasePeertubeActivity extends AppCompatActivity {
Handler mainHandler = new Handler(Looper.getMainLooper()); Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> { Runnable myRunnable = () -> {
invalidateOptionsMenu(); invalidateOptionsMenu();
binding.castLoader.setVisibility(View.VISIBLE); binding.minController.castLoader.setVisibility(View.VISIBLE);
player.setPlayWhenReady(false); player.setPlayWhenReady(false);
binding.doubleTapPlayerView.setVisibility(View.GONE); binding.doubleTapPlayerView.setVisibility(View.GONE);
binding.castController.setVisibility(View.VISIBLE); binding.minController.castMiniController.setVisibility(View.VISIBLE);
dialog.dismiss(); dialog.dismiss();
if (chromeCastVideoURL != null) { if (videoURL != null) {
if (player != null && player.getCurrentPosition() > 0) { if (player != null && player.getCurrentPosition() > 0) {
chromeCastVideoURL += "?start=" + (player.getCurrentPosition() / 1000); videoURL += "?start=" + (player.getCurrentPosition() / 1000);
} }
} }
}; };
@ -157,14 +156,14 @@ public class BasePeertubeActivity extends AppCompatActivity {
if (BaseMainActivity.chromeCast.isAppAvailable(CAST_ID) && !status.isAppRunning(CAST_ID)) { if (BaseMainActivity.chromeCast.isAppAvailable(CAST_ID) && !status.isAppRunning(CAST_ID)) {
BaseMainActivity.chromeCast.launchApp(CAST_ID); BaseMainActivity.chromeCast.launchApp(CAST_ID);
} }
if (chromeCastVideoURL != null) { if (videoURL != null) {
String mime = MimeTypeMap.getFileExtensionFromUrl(chromeCastVideoURL); String mime = MimeTypeMap.getFileExtensionFromUrl(videoURL);
BaseMainActivity.chromeCast.setRequestTimeout(60000); BaseMainActivity.chromeCast.setRequestTimeout(60000);
BaseMainActivity.chromeCast.load(peertube.getTitle(), null, chromeCastVideoURL, mime); BaseMainActivity.chromeCast.load(peertube.getTitle(), null, videoURL, mime);
BaseMainActivity.chromeCast.play(); BaseMainActivity.chromeCast.play();
binding.castPlay.setImageResource(R.drawable.ic_baseline_pause_32); binding.minController.castPlay.setImageResource(R.drawable.ic_baseline_pause_32);
} }
myRunnable = () -> binding.castLoader.setVisibility(View.GONE); myRunnable = () -> binding.minController.castLoader.setVisibility(View.GONE);
mainHandler.post(myRunnable); mainHandler.post(myRunnable);
} catch (IOException | GeneralSecurityException e) { } catch (IOException | GeneralSecurityException e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/castMiniController"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
android:visibility="gone">
<ImageView
android:id="@+id/cast_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/play"
android:src="@drawable/ic_baseline_play_arrow_32"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cast_loader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<TextView
android:id="@+id/cast_loader_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/please_wait"
android:textColor="?colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/cast_loader_small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.github.ybq.android.spinkit.SpinKitView
android:id="@+id/cast_loader_small"
style="@style/progressBottom"
android:layout_width="wrap_content"
android:layout_height="18dp"
android:layout_gravity="center"
android:layout_marginStart="5dp"
app:SpinKit_Color="?colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/cast_loader_text"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>