summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas <tschneider.ac@gmail.com>2023-01-26 18:05:41 +0100
committerThomas <tschneider.ac@gmail.com>2023-01-26 18:05:41 +0100
commita97448438aab5c71dcfd66f91a9997ecf730d2a7 (patch)
tree6d461318513a1eb8401d83d14fd6444d842d9e9f
parent557e973fca4eedc7ea25a8bc6e15784a7d421034 (diff)
playstore flavor
-rw-r--r--app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java5
-rw-r--r--app/src/fdroid/java/app/fedilab/android/activities/PeertubeBaseMainActivity.java5
-rw-r--r--app/src/playstore/AndroidManifest.xml6
-rw-r--r--app/src/playstore/java/app/fedilab/android/activities/BasePeertubeActivity.java183
-rw-r--r--app/src/playstore/java/app/fedilab/android/activities/PeertubeBaseMainActivity.java42
-rw-r--r--app/src/playstore/java/app/fedilab/android/expandedcontrols/ExpandedControlsActivity.java36
6 files changed, 270 insertions, 7 deletions
diff --git a/app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java b/app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java
index a5c29d7ab..58d82d4bf 100644
--- a/app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java
+++ b/app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java
@@ -1,7 +1,7 @@
package app.fedilab.android.activities;
-/* Copyright 2021 Thomas Schneider
+/* Copyright 2023 Thomas Schneider
*
- * This file is a part of TubeLab
+ * This file is a part of Fedilab
*
* 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
@@ -15,6 +15,7 @@ package app.fedilab.android.activities;
* see <http://www.gnu.org/licenses>. */
+
import static app.fedilab.android.peertube.helper.Helper.CAST_ID;
import android.content.Intent;
diff --git a/app/src/fdroid/java/app/fedilab/android/activities/PeertubeBaseMainActivity.java b/app/src/fdroid/java/app/fedilab/android/activities/PeertubeBaseMainActivity.java
index 77ca77bd3..9c7924710 100644
--- a/app/src/fdroid/java/app/fedilab/android/activities/PeertubeBaseMainActivity.java
+++ b/app/src/fdroid/java/app/fedilab/android/activities/PeertubeBaseMainActivity.java
@@ -1,7 +1,7 @@
package app.fedilab.android.activities;
-/* Copyright 2021 Thomas Schneider
+/* Copyright 2023 Thomas Schneider
*
- * This file is a part of TubeLab
+ * This file is a part of Fedilab
*
* 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
@@ -14,6 +14,7 @@ package app.fedilab.android.activities;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
+
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
diff --git a/app/src/playstore/AndroidManifest.xml b/app/src/playstore/AndroidManifest.xml
index ae4044257..106c5963a 100644
--- a/app/src/playstore/AndroidManifest.xml
+++ b/app/src/playstore/AndroidManifest.xml
@@ -6,7 +6,7 @@
<application android:name=".MainApplication">
<receiver
- android:name=".mastodon.services.EmbeddedDistrib"
+ android:name=".services.EmbeddedDistrib"
android:enabled="true"
android:exported="false">
<intent-filter>
@@ -18,8 +18,8 @@
<activity
- android:name=".peertube.expandedcontrols.ExpandedControlsActivity"
- android:theme="@style/AppThemeNoActionBar"
+ android:name=".expandedcontrols.ExpandedControlsActivity"
+ android:theme="@style/AppTheme"
/>
diff --git a/app/src/playstore/java/app/fedilab/android/activities/BasePeertubeActivity.java b/app/src/playstore/java/app/fedilab/android/activities/BasePeertubeActivity.java
new file mode 100644
index 000000000..7b3b01faf
--- /dev/null
+++ b/app/src/playstore/java/app/fedilab/android/activities/BasePeertubeActivity.java
@@ -0,0 +1,183 @@
+package app.fedilab.android.activities;
+/* Copyright 2023 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * 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.
+ *
+ * Fedilab 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 Fedilab; if not,
+ * see <http://www.gnu.org/licenses>. */
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.net.Uri;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+
+import com.google.android.exoplayer2.ExoPlayer;
+import com.google.android.gms.cast.MediaInfo;
+import com.google.android.gms.cast.MediaMetadata;
+import com.google.android.gms.cast.framework.CastButtonFactory;
+import com.google.android.gms.cast.framework.CastContext;
+import com.google.android.gms.cast.framework.CastSession;
+import com.google.android.gms.cast.framework.SessionManagerListener;
+import com.google.android.gms.cast.framework.media.RemoteMediaClient;
+import com.google.android.gms.common.images.WebImage;
+
+import app.fedilab.android.R;
+import app.fedilab.android.databinding.ActivityPeertubeBinding;
+import app.fedilab.android.mastodon.activities.BaseBarActivity;
+import app.fedilab.android.peertube.client.data.VideoData;
+import app.fedilab.android.peertube.helper.Helper;
+
+
+public class BasePeertubeActivity extends BaseBarActivity {
+
+ protected ActivityPeertubeBinding binding;
+ protected VideoData.Video peertube;
+ protected ExoPlayer player;
+ protected String videoURL;
+ protected String subtitlesStr;
+
+ private CastContext mCastContext;
+ private CastSession mCastSession;
+ private SessionManagerListener<CastSession> mSessionManagerListener;
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ binding = ActivityPeertubeBinding.inflate(getLayoutInflater());
+ View view = binding.getRoot();
+ setContentView(view);
+ final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
+ boolean search_cast = sharedpreferences.getBoolean(getString(R.string.set_cast_choice), false);
+ if (search_cast) {
+ setupCastListener();
+ mCastContext = CastContext.getSharedInstance(BasePeertubeActivity.this);
+ mCastSession = mCastContext.getSessionManager().getCurrentCastSession();
+
+ }
+
+ }
+
+
+ protected void loadCast() {
+ MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);
+
+ movieMetadata.putString(MediaMetadata.KEY_TITLE, peertube.getTitle());
+ movieMetadata.putString(MediaMetadata.KEY_ARTIST, peertube.getAccount().getDisplayName());
+ if (subtitlesStr != null) {
+ movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, subtitlesStr);
+ }
+ movieMetadata.addImage(new WebImage(Uri.parse("https://" + peertube.getChannel().getHost() + peertube.getPreviewPath())));
+ MediaInfo mediaInfo = new MediaInfo.Builder(videoURL)
+ .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
+ .setMetadata(movieMetadata)
+ .setStreamDuration(peertube.getDuration() * 1000L)
+ .build();
+ if (mCastSession != null) {
+ RemoteMediaClient remoteMediaClient = mCastSession.getRemoteMediaClient();
+ remoteMediaClient.load(mediaInfo);
+ }
+ }
+
+
+ private void setupCastListener() {
+ mSessionManagerListener = new SessionManagerListener<CastSession>() {
+ @Override
+ public void onSessionStarting(@NonNull CastSession castSession) {
+ }
+
+ @Override
+ public void onSessionStarted(@NonNull CastSession castSession, String s) {
+ onApplicationConnected(castSession, true);
+ }
+
+ @Override
+ public void onSessionStartFailed(@NonNull CastSession castSession, int i) {
+ onApplicationDisconnected();
+ }
+
+ @Override
+ public void onSessionEnding(@NonNull CastSession castSession) {
+ onApplicationDisconnected();
+ }
+
+ @Override
+ public void onSessionEnded(@NonNull CastSession castSession, int i) {
+ onApplicationDisconnected();
+ }
+
+ @Override
+ public void onSessionResuming(@NonNull CastSession castSession, String s) {
+ }
+
+ @Override
+ public void onSessionResumed(@NonNull CastSession castSession, boolean b) {
+ onApplicationConnected(castSession, false);
+ }
+
+ @Override
+ public void onSessionResumeFailed(@NonNull CastSession castSession, int i) {
+ onApplicationDisconnected();
+ }
+
+ @Override
+ public void onSessionSuspended(@NonNull CastSession castSession, int i) {
+ onApplicationDisconnected();
+ }
+
+ private void onApplicationConnected(CastSession castSession, boolean hide) {
+ mCastSession = castSession;
+ supportInvalidateOptionsMenu();
+ player.setPlayWhenReady(false);
+ if (hide) {
+ binding.doubleTapPlayerView.setVisibility(View.INVISIBLE);
+ }
+ binding.minController.castMiniController.setVisibility(View.VISIBLE);
+ loadCast();
+ }
+
+ private void onApplicationDisconnected() {
+ binding.doubleTapPlayerView.setVisibility(View.VISIBLE);
+ binding.minController.castMiniController.setVisibility(View.GONE);
+ supportInvalidateOptionsMenu();
+ }
+ };
+ }
+
+ @Override
+ protected void onResume() {
+ mCastContext.getSessionManager().addSessionManagerListener(
+ mSessionManagerListener, CastSession.class);
+ super.onResume();
+ }
+
+ @Override
+ protected void onPause() {
+ mCastContext.getSessionManager().removeSessionManagerListener(
+ mSessionManagerListener, CastSession.class);
+ super.onPause();
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ super.onCreateOptionsMenu(menu);
+ getMenuInflater().inflate(R.menu.video_menu, menu);
+ CastButtonFactory.setUpMediaRouteButton(getApplicationContext(),
+ menu,
+ R.id.media_route_button);
+ return true;
+ }
+}
diff --git a/app/src/playstore/java/app/fedilab/android/activities/PeertubeBaseMainActivity.java b/app/src/playstore/java/app/fedilab/android/activities/PeertubeBaseMainActivity.java
new file mode 100644
index 000000000..204acd6d2
--- /dev/null
+++ b/app/src/playstore/java/app/fedilab/android/activities/PeertubeBaseMainActivity.java
@@ -0,0 +1,42 @@
+package app.fedilab.android.activities;
+/* Copyright 2023 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * 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.
+ *
+ * Fedilab 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 Fedilab; if not,
+ * see <http://www.gnu.org/licenses>. */
+
+
+import android.os.Bundle;
+import android.view.View;
+
+import app.fedilab.android.databinding.ActivityMainPeertubeBinding;
+import app.fedilab.android.mastodon.activities.BaseActivity;
+
+
+public class PeertubeBaseMainActivity extends BaseActivity {
+
+ protected ActivityMainPeertubeBinding binding;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ binding = ActivityMainPeertubeBinding.inflate(getLayoutInflater());
+ View view = binding.getRoot();
+ setContentView(view);
+ }
+
+ //Method for discovering cast devices
+ public void discoverCast() {
+ }
+
+}
diff --git a/app/src/playstore/java/app/fedilab/android/expandedcontrols/ExpandedControlsActivity.java b/app/src/playstore/java/app/fedilab/android/expandedcontrols/ExpandedControlsActivity.java
new file mode 100644
index 000000000..4cd0e5707
--- /dev/null
+++ b/app/src/playstore/java/app/fedilab/android/expandedcontrols/ExpandedControlsActivity.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 Google LLC. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package app.fedilab.android.expandedcontrols;
+
+import android.view.Menu;
+
+import com.google.android.gms.cast.framework.CastButtonFactory;
+import com.google.android.gms.cast.framework.media.widget.ExpandedControllerActivity;
+
+import app.fedilab.android.R;
+
+
+public class ExpandedControlsActivity extends ExpandedControllerActivity {
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ super.onCreateOptionsMenu(menu);
+ getMenuInflater().inflate(R.menu.video_menu, menu);
+ CastButtonFactory.setUpMediaRouteButton(this, menu, R.id.media_route_button);
+ return true;
+ }
+} \ No newline at end of file