1
0
mirror of https://framagit.org/tom79/fedilab-tube synced 2025-06-05 21:09:11 +02:00

6 Commits

Author SHA1 Message Date
d5a5fdf52e Release 1.13.0 2021-01-16 18:25:59 +01:00
a7f9256947 Small fixes 2021-01-16 14:14:15 +01:00
d769729901 Merge branch 'l10n_develop' into 'develop'
New Crowdin updates

See merge request tom79/fedilab-tube!64
2021-01-16 11:34:44 +01:00
b2026c8784 New Crowdin updates 2021-01-16 11:34:44 +01:00
b29de141ef Add cast library for Google release only - Checked through Exodus 2021-01-16 11:33:59 +01:00
6d4772da75 Fix issue #170 2021-01-11 17:42:54 +01:00
37 changed files with 1065 additions and 477 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"
} }
@ -53,6 +53,9 @@ android {
buildConfigField "boolean", "sepia_search", "false" buildConfigField "boolean", "sepia_search", "false"
buildConfigField "boolean", "instance_switcher", "true" buildConfigField "boolean", "instance_switcher", "true"
buildConfigField "boolean", "allow_remote_connections", "false" buildConfigField "boolean", "allow_remote_connections", "false"
buildConfigField "boolean", "google_cast_lib", "false"
buildConfigField "int", "cast_enabled", "0"
buildConfigField "int", "default_theme", "2"
} }
google_peertube_apps_educ { google_peertube_apps_educ {
applicationId "app.fedilab.fedilabtube" applicationId "app.fedilab.fedilabtube"
@ -65,6 +68,9 @@ android {
buildConfigField "boolean", "sepia_search", "false" buildConfigField "boolean", "sepia_search", "false"
buildConfigField "boolean", "instance_switcher", "true" buildConfigField "boolean", "instance_switcher", "true"
buildConfigField "boolean", "allow_remote_connections", "false" buildConfigField "boolean", "allow_remote_connections", "false"
buildConfigField "boolean", "google_cast_lib", "false"
buildConfigField "int", "cast_enabled", "0"
buildConfigField "int", "default_theme", "2"
} }
fdroid_full { fdroid_full {
applicationId "app.fedilab.tubelab" applicationId "app.fedilab.tubelab"
@ -77,6 +83,9 @@ android {
buildConfigField "boolean", "sepia_search", "true" buildConfigField "boolean", "sepia_search", "true"
buildConfigField "boolean", "instance_switcher", "true" buildConfigField "boolean", "instance_switcher", "true"
buildConfigField "boolean", "allow_remote_connections", "true" buildConfigField "boolean", "allow_remote_connections", "true"
buildConfigField "boolean", "google_cast_lib", "false"
buildConfigField "int", "cast_enabled", "0"
buildConfigField "int", "default_theme", "2"
} }
google_full { google_full {
applicationId "app.fedilab.tubelab" applicationId "app.fedilab.tubelab"
@ -89,6 +98,9 @@ android {
buildConfigField "boolean", "sepia_search", "true" buildConfigField "boolean", "sepia_search", "true"
buildConfigField "boolean", "instance_switcher", "true" buildConfigField "boolean", "instance_switcher", "true"
buildConfigField "boolean", "allow_remote_connections", "true" buildConfigField "boolean", "allow_remote_connections", "true"
buildConfigField "boolean", "google_cast_lib", "true"
buildConfigField "int", "cast_enabled", "1"
buildConfigField "int", "default_theme", "2"
} }
queermotion { queermotion {
applicationId "org.queermotion.peertube" applicationId "org.queermotion.peertube"
@ -101,6 +113,9 @@ android {
buildConfigField "boolean", "sepia_search", "false" buildConfigField "boolean", "sepia_search", "false"
buildConfigField "boolean", "instance_switcher", "false" buildConfigField "boolean", "instance_switcher", "false"
buildConfigField "boolean", "allow_remote_connections", "false" buildConfigField "boolean", "allow_remote_connections", "false"
buildConfigField "boolean", "google_cast_lib", "false"
buildConfigField "int", "cast_enabled", "0"
buildConfigField "int", "default_theme", "2"
} }
bittube { bittube {
applicationId "app.fedilab.bittube" applicationId "app.fedilab.bittube"
@ -113,33 +128,38 @@ android {
buildConfigField "boolean", "sepia_search", "false" buildConfigField "boolean", "sepia_search", "false"
buildConfigField "boolean", "instance_switcher", "true" buildConfigField "boolean", "instance_switcher", "true"
buildConfigField "boolean", "allow_remote_connections", "false" buildConfigField "boolean", "allow_remote_connections", "false"
buildConfigField "boolean", "google_cast_lib", "true"
buildConfigField "int", "cast_enabled", "1"
buildConfigField "int", "default_theme", "1"
} }
} }
sourceSets { sourceSets {
fdroid_peertube_apps_educ { fdroid_peertube_apps_educ {
res.srcDirs = ['src/main/res', 'src/acad/res'] res.srcDirs = ['src/main/res', 'src/acad/res', 'src/no_google_cast_lib/res']
java.srcDirs = ['src/main/java', 'src/acad/java', 'src/no_google_donation/java'] java.srcDirs = ['src/main/java', 'src/acad/java', 'src/no_google_donation/java', 'src/no_google_cast_lib/java']
} }
google_peertube_apps_educ { google_peertube_apps_educ {
res.srcDirs = ['src/main/res', 'src/acad/res'] res.srcDirs = ['src/main/res', 'src/acad/res', 'src/no_google_cast_lib/res']
java.srcDirs = ['src/main/java', 'src/acad/java', 'src/no_google_donation/java'] java.srcDirs = ['src/main/java', 'src/acad/java', 'src/no_google_donation/java', 'src/no_google_cast_lib/java']
} }
fdroid_full { fdroid_full {
res.srcDirs = ['src/main/res', 'src/full/res'] res.srcDirs = ['src/main/res', 'src/full/res', 'src/no_google_cast_lib/res']
java.srcDirs = ['src/main/java', 'src/full/java', 'src/no_google_donation/java'] java.srcDirs = ['src/main/java', 'src/full/java', 'src/no_google_donation/java', 'src/no_google_cast_lib/java']
} }
google_full { google_full {
res.srcDirs = ['src/main/res', 'src/full/res', 'src/google_donation/res'] res.srcDirs = ['src/main/res', 'src/full/res', 'src/google_donation/res', 'src/google_cast_lib/res']
java.srcDirs = ['src/main/java', 'src/full/java', 'src/google_donation/java'] java.srcDirs = ['src/main/java', 'src/full/java', 'src/google_donation/java', 'src/google_cast_lib/java']
manifest.srcFile "src/google_cast_lib/AndroidManifest.xml"
} }
queermotion { queermotion {
res.srcDirs = ['src/main/res', 'src/queermotion/res'] res.srcDirs = ['src/main/res', 'src/queermotion/res', 'src/no_google_cast_lib/res']
java.srcDirs = ['src/main/java', 'src/full/java', 'src/no_google_donation/java'] java.srcDirs = ['src/main/java', 'src/full/java', 'src/no_google_donation/java', 'src/no_google_cast_lib/java']
} }
bittube { bittube {
res.srcDirs = ['src/main/res', 'src/bittube/res'] res.srcDirs = ['src/main/res', 'src/bittube/res', 'src/google_cast_lib/res']
java.srcDirs = ['src/main/java', 'src/full/java', 'src/no_google_donation/java'] java.srcDirs = ['src/main/java', 'src/full/java', 'src/no_google_donation/java', 'src/google_cast_lib/java']
manifest.srcFile "src/google_cast_lib/AndroidManifest.xml"
} }
} }
} }
@ -179,6 +199,7 @@ dependencies {
implementation "com.github.mabbas007:TagsEditText:1.0.5" implementation "com.github.mabbas007:TagsEditText:1.0.5"
implementation "com.github.bumptech.glide:glide:4.11.0" implementation "com.github.bumptech.glide:glide:4.11.0"
annotationProcessor "com.github.bumptech.glide:compiler:4.11.0" annotationProcessor "com.github.bumptech.glide:compiler:4.11.0"
implementation 'jp.wasabeef:glide-transformations:4.0.0'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation "net.gotev:uploadservice:4.5.1" implementation "net.gotev:uploadservice:4.5.1"
implementation "net.gotev:uploadservice-okhttp:4.5.1" implementation "net.gotev:uploadservice-okhttp:4.5.1"
@ -196,17 +217,34 @@ dependencies {
implementation "androidx.work:work-runtime:2.4.0" implementation "androidx.work:work-runtime:2.4.0"
implementation "androidx.work:work-runtime-ktx:2.4.0" implementation "androidx.work:work-runtime-ktx:2.4.0"
//custom cast feature
implementation 'jp.wasabeef:glide-transformations:4.0.0'
implementation 'su.litvak.chromecast:api-v2:0.11.3'
implementation 'com.fasterxml.jackson.core:jackson-core:2.12.0'
implementation 'org.slf4j:slf4j-simple:1.7.30'
//************ DONATION GOOGLE ONLY **************//
google_fullImplementation "com.android.billingclient:billing:3.0.2" google_fullImplementation "com.android.billingclient:billing:3.0.2"
//************ MATOMO --> acad instances only **************//
fdroid_peertube_apps_educImplementation 'org.matomo.sdk:tracker:4.1.2' fdroid_peertube_apps_educImplementation 'org.matomo.sdk:tracker:4.1.2'
google_peertube_apps_educImplementation 'org.matomo.sdk:tracker:4.1.2' google_peertube_apps_educImplementation 'org.matomo.sdk:tracker:4.1.2'
//************ CAST **************///
//---> Google libs (google_full + bittube)
google_fullImplementation "androidx.mediarouter:mediarouter:1.2.1"
google_fullImplementation 'com.google.android.gms:play-services-cast-framework:19.0.0'
bittubeImplementation "androidx.mediarouter:mediarouter:1.2.1"
bittubeImplementation 'com.google.android.gms:play-services-cast-framework:19.0.0'
//----> Other flavors
fdroid_peertube_apps_educImplementation 'su.litvak.chromecast:api-v2:0.11.3'
fdroid_peertube_apps_educImplementation 'com.fasterxml.jackson.core:jackson-core:2.12.0'
fdroid_peertube_apps_educImplementation 'org.slf4j:slf4j-simple:1.7.30'
google_peertube_apps_educImplementation 'su.litvak.chromecast:api-v2:0.11.3'
google_peertube_apps_educImplementation 'com.fasterxml.jackson.core:jackson-core:2.12.0'
google_peertube_apps_educImplementation 'org.slf4j:slf4j-simple:1.7.30'
fdroid_fullImplementation 'su.litvak.chromecast:api-v2:0.11.3'
fdroid_fullImplementation 'com.fasterxml.jackson.core:jackson-core:2.12.0'
fdroid_fullImplementation 'org.slf4j:slf4j-simple:1.7.30'
queermotionImplementation 'su.litvak.chromecast:api-v2:0.11.3'
queermotionImplementation 'com.fasterxml.jackson.core:jackson-core:2.12.0'
queermotionImplementation 'org.slf4j:slf4j-simple:1.7.30'
} }

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="app.fedilab.fedilabtube">
<application>
<activity
android:name=".PeertubeActivity"
tools:node="merge">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".PeertubeActivity" />
</activity>
<activity
android:name=".expandedcontrols.ExpandedControlsActivity"
android:theme="@style/AppThemeNoActionBar"
/>
<meta-data
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
android:value="app.fedilab.fedilabtube.provider.CastOptionsProvider" />
</application>
</manifest>

View File

@ -0,0 +1,41 @@
package app.fedilab.fedilabtube;
/* Copyright 2021 Thomas Schneider
*
* This file is a part of TubeLab
*
* 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.
*
* TubeLab 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 TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
import android.os.Bundle;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import app.fedilab.fedilabtube.databinding.ActivityMainBinding;
public class BaseMainActivity extends AppCompatActivity {
protected ActivityMainBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(getLayoutInflater());
View view = binding.getRoot();
setContentView(view);
}
//Method for discovering cast devices
public void discoverCast() {
}
}

View File

@ -0,0 +1,182 @@
package app.fedilab.fedilabtube;
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.appcompat.app.AppCompatActivity;
import com.google.android.exoplayer2.SimpleExoPlayer;
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.fedilabtube.client.data.VideoData;
import app.fedilab.fedilabtube.databinding.ActivityPeertubeBinding;
import app.fedilab.fedilabtube.helper.Helper;
/* Copyright 2021 Thomas Schneider
*
* This file is a part of TubeLab
*
* 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.
*
* TubeLab 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 TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
public class BasePeertubeActivity extends AppCompatActivity {
protected ActivityPeertubeBinding binding;
protected VideoData.Video peertube;
protected SimpleExoPlayer 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);
int search_cast = sharedpreferences.getInt(getString(R.string.set_cast_choice), BuildConfig.cast_enabled);
if (search_cast == 1) {
setupCastListener();
mCastContext = CastContext.getSharedInstance(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() * 1000)
.build();
if (mCastSession != null) {
RemoteMediaClient remoteMediaClient = mCastSession.getRemoteMediaClient();
remoteMediaClient.load(mediaInfo);
}
}
private void setupCastListener() {
mSessionManagerListener = new SessionManagerListener<CastSession>() {
@Override
public void onSessionStarting(CastSession castSession) {
}
@Override
public void onSessionStarted(CastSession castSession, String s) {
onApplicationConnected(castSession, true);
}
@Override
public void onSessionStartFailed(CastSession castSession, int i) {
onApplicationDisconnected();
}
@Override
public void onSessionEnding(CastSession castSession) {
onApplicationDisconnected();
}
@Override
public void onSessionEnded(CastSession castSession, int i) {
onApplicationDisconnected();
}
@Override
public void onSessionResuming(CastSession castSession, String s) {
}
@Override
public void onSessionResumed(CastSession castSession, boolean b) {
onApplicationConnected(castSession, false);
}
@Override
public void onSessionResumeFailed(CastSession castSession, int i) {
onApplicationDisconnected();
}
@Override
public void onSessionSuspended(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;
}
}

View File

@ -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.fedilabtube.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.fedilabtube.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;
}
}

View File

@ -0,0 +1,54 @@
package app.fedilab.fedilabtube.provider;
/* Copyright 2021 Thomas Schneider
*
* This file is a part of TubeLab
*
* 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.
*
* TubeLab 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 TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
import android.content.Context;
import com.google.android.gms.cast.framework.CastOptions;
import com.google.android.gms.cast.framework.OptionsProvider;
import com.google.android.gms.cast.framework.SessionProvider;
import com.google.android.gms.cast.framework.media.CastMediaOptions;
import com.google.android.gms.cast.framework.media.NotificationOptions;
import java.util.List;
import app.fedilab.fedilabtube.BuildConfig;
import app.fedilab.fedilabtube.expandedcontrols.ExpandedControlsActivity;
import app.fedilab.fedilabtube.helper.Helper;
public class CastOptionsProvider implements OptionsProvider {
@Override
public CastOptions getCastOptions(Context context) {
NotificationOptions notificationOptions = new NotificationOptions.Builder()
.setTargetActivityClassName(ExpandedControlsActivity.class.getName())
.build();
CastMediaOptions mediaOptions = new CastMediaOptions.Builder()
.setNotificationOptions(notificationOptions)
.setExpandedControllerActivityClassName(ExpandedControlsActivity.class.getName())
.build();
return new CastOptions.Builder()
.setReceiverApplicationId(BuildConfig.FLAVOR.compareTo("bittube") == 0 ? Helper.CAST_ID_BITTUBE : Helper.CAST_ID)
.setCastMediaOptions(mediaOptions)
.build();
}
@Override
public List<SessionProvider> getAdditionalSessionProviders(Context context) {
return null;
}
}

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

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/media_route_button"
android:title="@string/cast"
app:actionProviderClass="androidx.mediarouter.app.MediaRouteActionProvider"
app:showAsAction="always" />
</menu>

View File

@ -65,7 +65,7 @@ public class BaseFedilabTube extends MultiDexApplication {
MultiDex.install(BaseFedilabTube.this); MultiDex.install(BaseFedilabTube.this);
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
int themePref = sharedpreferences.getInt(Helper.SET_THEME, Helper.DEFAULT_MODE); int themePref = sharedpreferences.getInt(Helper.SET_THEME, BuildConfig.default_theme);
ThemeHelper.switchTo(themePref); ThemeHelper.switchTo(themePref);

View File

@ -16,17 +16,14 @@ package app.fedilab.fedilabtube;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Looper;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -37,14 +34,12 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.SearchView;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.appcompat.widget.TooltipCompat; import androidx.appcompat.widget.TooltipCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter; import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
@ -53,13 +48,7 @@ import com.kobakei.ratethisapp.RateThisApp;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.URL; import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -73,7 +62,6 @@ import java.util.regex.Pattern;
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI; import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
import app.fedilab.fedilabtube.client.data.AccountData.Account; import app.fedilab.fedilabtube.client.data.AccountData.Account;
import app.fedilab.fedilabtube.client.data.InstanceData; import app.fedilab.fedilabtube.client.data.InstanceData;
import app.fedilab.fedilabtube.client.data.VideoData;
import app.fedilab.fedilabtube.client.entities.Error; import app.fedilab.fedilabtube.client.entities.Error;
import app.fedilab.fedilabtube.client.entities.OauthParams; import app.fedilab.fedilabtube.client.entities.OauthParams;
import app.fedilab.fedilabtube.client.entities.PeertubeInformation; import app.fedilab.fedilabtube.client.entities.PeertubeInformation;
@ -95,17 +83,13 @@ import app.fedilab.fedilabtube.sqlite.Sqlite;
import app.fedilab.fedilabtube.sqlite.StoredInstanceDAO; import app.fedilab.fedilabtube.sqlite.StoredInstanceDAO;
import app.fedilab.fedilabtube.viewmodel.TimelineVM; import app.fedilab.fedilabtube.viewmodel.TimelineVM;
import es.dmoral.toasty.Toasty; import es.dmoral.toasty.Toasty;
import su.litvak.chromecast.api.v2.ChromeCast;
import su.litvak.chromecast.api.v2.ChromeCasts;
import su.litvak.chromecast.api.v2.ChromeCastsListener;
import su.litvak.chromecast.api.v2.MediaStatus;
import static app.fedilab.fedilabtube.MainActivity.TypeOfConnection.NORMAL; import static app.fedilab.fedilabtube.MainActivity.TypeOfConnection.NORMAL;
import static app.fedilab.fedilabtube.MainActivity.TypeOfConnection.SURFING; import static app.fedilab.fedilabtube.MainActivity.TypeOfConnection.SURFING;
import static app.fedilab.fedilabtube.helper.Helper.peertubeInformation; import static app.fedilab.fedilabtube.helper.Helper.peertubeInformation;
public class MainActivity extends AppCompatActivity implements ChromeCastsListener { public class MainActivity extends BaseMainActivity {
public static int PICK_INSTANCE = 5641; public static int PICK_INSTANCE = 5641;
@ -113,9 +97,8 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
public static UserMe userMe; public static UserMe userMe;
public static InstanceData.InstanceConfig instanceConfig; public static InstanceData.InstanceConfig instanceConfig;
public static TypeOfConnection typeOfConnection; public static TypeOfConnection typeOfConnection;
public static List<ChromeCast> chromeCasts;
public static ChromeCast chromeCast;
public static boolean chromecastActivated = false;
private DisplayVideosFragment recentFragment, locaFragment, trendingFragment, subscriptionFragment, mostLikedFragment; private DisplayVideosFragment recentFragment, locaFragment, trendingFragment, subscriptionFragment, mostLikedFragment;
private DisplayOverviewFragment overviewFragment; private DisplayOverviewFragment overviewFragment;
private ActivityMainBinding binding; private ActivityMainBinding binding;
@ -158,8 +141,7 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
} }
return true; return true;
}; };
private BroadcastReceiver manage_chromecast;
private VideoData.Video castedTube;
@SuppressLint("ApplySharedPref") @SuppressLint("ApplySharedPref")
public static void showRadioButtonDialogFullInstances(Activity activity, boolean storeInDb) { public static void showRadioButtonDialogFullInstances(Activity activity, boolean storeInDb) {
@ -234,123 +216,20 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
} }
} }
@Override
public void newChromeCastDiscovered(ChromeCast chromeCast) {
if (chromeCasts == null) {
chromeCasts = new ArrayList<>();
chromeCasts.add(chromeCast);
} else {
boolean canBeAdded = true;
for (ChromeCast cast : chromeCasts) {
if (cast.getName().compareTo(chromeCast.getName()) == 0) {
canBeAdded = false;
break;
}
}
if (canBeAdded) {
chromeCasts.add(chromeCast);
}
}
try {
if (chromeCast.isAppRunning(Helper.CAST_ID) && chromeCast.getMediaStatus() != null && chromeCast.getMediaStatus().playerState != null) {
if (binding.castInfo.getVisibility() == View.GONE) {
binding.castInfo.setVisibility(View.VISIBLE);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void chromeCastRemoved(ChromeCast chromeCast) {
}
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
binding = null; binding = null;
ChromeCasts.unregisterListener(this);
if (manage_chromecast != null) {
LocalBroadcastManager.getInstance(MainActivity.this).unregisterReceiver(manage_chromecast);
new Thread(() -> {
if (chromeCasts != null && chromeCasts.size() > 0) {
for (ChromeCast cast : chromeCasts) {
try {
cast.stopApp();
cast.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}).start();
}
if (chromeCasts != null) {
chromeCasts = null;
}
if (chromeCast != null) {
chromeCast = null;
}
} }
//Method for discovering cast devices
public void discoverCast() {
new Thread(() -> {
if (chromeCasts != null) {
for (ChromeCast cast : chromeCasts) {
try {
cast.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
chromeCasts = null;
}
chromeCasts = new ArrayList<>();
try {
List<NetworkInterface> interfaces;
interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface ni : interfaces) {
if ((!ni.isLoopback()) && ni.isUp() && (ni.getName().equals("wlan0"))) {
Enumeration<InetAddress> inetAddressEnumeration = ni.getInetAddresses();
while (inetAddressEnumeration.hasMoreElements()) {
InetAddress inetAddress = inetAddressEnumeration.nextElement();
ChromeCasts.restartDiscovery(inetAddress);
int tryFind = 0;
while (ChromeCasts.get().isEmpty() && tryFind < 5) {
try {
//noinspection BusyWait
Thread.sleep(1000);
tryFind++;
} catch (InterruptedException ignored) {
}
}
}
}
}
ChromeCasts.stopDiscovery();
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = this::invalidateOptionsMenu;
mainHandler.post(myRunnable);
} catch (IOException e) {
e.printStackTrace();
}
}).start();
}
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(getLayoutInflater()); binding = super.binding;
View view = binding.getRoot();
setContentView(view);
ChromeCastsListener chromeCastsListener = this;
ChromeCasts.registerListener(chromeCastsListener);
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
@ -462,92 +341,10 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
} }
binding.castClose.setOnClickListener(v -> {
Intent intentBC = new Intent(Helper.RECEIVE_CAST_SETTINGS);
Bundle b = new Bundle();
b.putInt("displayed", 0);
intentBC.putExtras(b);
LocalBroadcastManager.getInstance(MainActivity.this).sendBroadcast(intentBC);
});
binding.castTogglePlay.setOnClickListener(v -> {
if (chromeCast != null) {
new Thread(() -> {
try {
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> binding.castTogglePlay.setVisibility(View.GONE);
mainHandler.post(myRunnable);
int icon = -1;
if (chromeCast.getMediaStatus().playerState == MediaStatus.PlayerState.PLAYING) {
chromeCast.pause();
icon = R.drawable.ic_baseline_play_arrow_32;
} else if (chromeCast.getMediaStatus().playerState == MediaStatus.PlayerState.PAUSED) {
chromeCast.play();
icon = R.drawable.ic_baseline_pause_32;
}
if (icon != -1) {
int finalIcon = icon;
myRunnable = () -> binding.castTogglePlay.setImageResource(finalIcon);
mainHandler.post(myRunnable);
}
myRunnable = () -> binding.castTogglePlay.setVisibility(View.VISIBLE);
mainHandler.post(myRunnable);
} catch (IOException e) {
e.printStackTrace();
}
}).start();
}
});
manage_chromecast = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Bundle b = intent.getExtras();
assert b != null;
int state = b.getInt("state_asked", -1);
int displayed = b.getInt("displayed", -1);
castedTube = b.getParcelable("castedTube");
if (state == 1) {
discoverCast();
} else if (state == 0) {
new Thread(() -> {
try {
if (chromeCast != null) {
chromeCast.stopApp();
chromeCast.disconnect();
}
} catch (IOException e) {
e.printStackTrace();
}
}).start();
}
if (displayed == 1) {
chromecastActivated = true;
if (castedTube != null) {
binding.castInfo.setVisibility(View.VISIBLE);
Helper.loadGiF(MainActivity.this, castedTube.getThumbnailPath(), binding.castView);
binding.castTitle.setText(castedTube.getTitle());
binding.castDescription.setText(castedTube.getDescription());
}
} else if (displayed == 0) {
chromecastActivated = false;
binding.castInfo.setVisibility(View.GONE);
new Thread(() -> {
try {
if (chromeCast != null) {
chromeCast.stopApp();
}
} catch (IOException e) {
e.printStackTrace();
}
}).start();
}
}
};
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
LocalBroadcastManager.getInstance(MainActivity.this).registerReceiver(manage_chromecast, new IntentFilter(Helper.RECEIVE_CAST_SETTINGS));
int search_cast = sharedpreferences.getInt(getString(R.string.set_cast_choice), 0); int search_cast = sharedpreferences.getInt(getString(R.string.set_cast_choice), BuildConfig.cast_enabled);
if (search_cast == 1) { if (search_cast == 1) {
discoverCast(); discoverCast();
} }

View File

@ -44,7 +44,6 @@ import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan; import android.text.style.ClickableSpan;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
@ -52,7 +51,6 @@ import android.view.WindowManager;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.view.animation.TranslateAnimation; import android.view.animation.TranslateAnimation;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.webkit.MimeTypeMap;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
@ -63,14 +61,12 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.PopupMenu;
import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.graphics.drawable.DrawableCompat;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -111,8 +107,6 @@ import com.google.android.material.snackbar.Snackbar;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.text.DateFormat; import java.text.DateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -163,19 +157,12 @@ import app.fedilab.fedilabtube.webview.CustomWebview;
import app.fedilab.fedilabtube.webview.MastalabWebChromeClient; import app.fedilab.fedilabtube.webview.MastalabWebChromeClient;
import app.fedilab.fedilabtube.webview.MastalabWebViewClient; import app.fedilab.fedilabtube.webview.MastalabWebViewClient;
import es.dmoral.toasty.Toasty; import es.dmoral.toasty.Toasty;
import su.litvak.chromecast.api.v2.ChromeCast;
import su.litvak.chromecast.api.v2.MediaStatus;
import su.litvak.chromecast.api.v2.Status;
import static app.fedilab.fedilabtube.MainActivity.chromeCast;
import static app.fedilab.fedilabtube.MainActivity.chromeCasts;
import static app.fedilab.fedilabtube.MainActivity.chromecastActivated;
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.ADD_COMMENT; import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.ADD_COMMENT;
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.RATEVIDEO; import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.RATEVIDEO;
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPLY; import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPLY;
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT; import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT;
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPORT_VIDEO; import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPORT_VIDEO;
import static app.fedilab.fedilabtube.helper.Helper.CAST_ID;
import static app.fedilab.fedilabtube.helper.Helper.canMakeAction; import static app.fedilab.fedilabtube.helper.Helper.canMakeAction;
import static app.fedilab.fedilabtube.helper.Helper.getAttColor; import static app.fedilab.fedilabtube.helper.Helper.getAttColor;
import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn; import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn;
@ -184,15 +171,13 @@ import static app.fedilab.fedilabtube.helper.Helper.peertubeInformation;
import static com.google.android.exoplayer2.Player.MEDIA_ITEM_TRANSITION_REASON_AUTO; import static com.google.android.exoplayer2.Player.MEDIA_ITEM_TRANSITION_REASON_AUTO;
public class PeertubeActivity extends AppCompatActivity implements CommentListAdapter.AllCommentRemoved, Player.EventListener, VideoListener, TorrentListener, MenuAdapter.ItemClicked, MenuItemAdapter.ItemAction { public class PeertubeActivity extends BasePeertubeActivity implements CommentListAdapter.AllCommentRemoved, Player.EventListener, VideoListener, TorrentListener, MenuAdapter.ItemClicked, MenuItemAdapter.ItemAction {
public static String video_id; public static String video_id;
public static List<String> playedVideos = new ArrayList<>(); public static List<String> playedVideos = new ArrayList<>();
private String peertubeInstance, videoUuid; private String peertubeInstance, videoUuid;
private ImageView fullScreenIcon; private ImageView fullScreenIcon;
private SimpleExoPlayer player;
private boolean fullScreenMode; private boolean fullScreenMode;
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, autoPlay, autoFullscreen; private boolean playInMinimized, autoPlay, autoFullscreen;
@ -218,7 +203,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
private String currentCaption; private String currentCaption;
private boolean isRemote; private boolean isRemote;
private boolean willPlayFromIntent; private boolean willPlayFromIntent;
private String chromeCastVideoURL;
private app.fedilab.fedilabtube.client.mastodon.Status status; private app.fedilab.fedilabtube.client.mastodon.Status status;
Uri captionURI; Uri captionURI;
String captionLang; String captionLang;
@ -307,10 +292,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
binding = super.binding;
binding = ActivityPeertubeBinding.inflate(getLayoutInflater());
View view = binding.getRoot();
setContentView(view);
videoOrientationType = videoOrientation.LANDSCAPE; videoOrientationType = videoOrientation.LANDSCAPE;
max_id = "0"; max_id = "0";
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
@ -512,34 +494,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
} }
}); });
binding.castPlay.setOnClickListener(v -> {
binding.castLoader.setVisibility(View.VISIBLE);
if (chromeCast != null) {
new Thread(() -> {
try {
int icon = -1;
if (chromeCast.getMediaStatus().playerState == MediaStatus.PlayerState.PLAYING) {
chromeCast.pause();
icon = R.drawable.ic_baseline_play_arrow_32;
} else if (chromeCast.getMediaStatus().playerState == MediaStatus.PlayerState.PAUSED) {
chromeCast.play();
icon = R.drawable.ic_baseline_pause_32;
}
if (icon != -1) {
Handler mainHandler = new Handler(Looper.getMainLooper());
int finalIcon = icon;
Runnable myRunnable = () -> binding.castPlay.setImageResource(finalIcon);
mainHandler.post(myRunnable);
}
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> binding.castLoader.setVisibility(View.GONE);
mainHandler.post(myRunnable);
} catch (IOException e) {
e.printStackTrace();
}
}).start();
}
});
} }
@ -798,20 +753,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}).start(); }).start();
} }
@Override
public boolean onCreateOptionsMenu(@NotNull Menu menu) {
getMenuInflater().inflate(R.menu.video_menu, menu);
MenuItem castItem = menu.findItem(R.id.action_cast);
if (chromeCasts != null && chromeCasts.size() > 0) {
castItem.setVisible(true);
if (chromeCast != null && chromeCast.isConnected()) {
castItem.setIcon(R.drawable.ic_baseline_cast_connected_24);
} else {
castItem.setIcon(R.drawable.ic_baseline_cast_24);
}
}
return true;
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
@ -821,101 +762,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
} }
finish(); finish();
return true; return true;
} else if (item.getItemId() == R.id.action_cast) {
if (chromeCasts != null && chromeCasts.size() > 0) {
String[] chromecast_choice = new String[chromeCasts.size()];
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
alt_bld.setTitle(R.string.chromecast_choice);
int i = 0;
for (ChromeCast cc : chromeCasts) {
chromecast_choice[i] = cc.getTitle();
i++;
}
i = 0;
for (ChromeCast cc : chromeCasts) {
if (chromecastActivated && cc.isConnected()) {
break;
}
i++;
}
alt_bld.setSingleChoiceItems(chromecast_choice, i, (dialog, position) -> {
chromeCast = chromeCasts.get(position);
new Thread(() -> {
if (chromeCast != null) {
Intent intentBC = new Intent(Helper.RECEIVE_CAST_SETTINGS);
Bundle b = new Bundle();
if (chromecastActivated) {
b.putInt("displayed", 0);
intentBC.putExtras(b);
LocalBroadcastManager.getInstance(PeertubeActivity.this).sendBroadcast(intentBC);
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> {
binding.doubleTapPlayerView.setVisibility(View.VISIBLE);
binding.castController.setVisibility(View.GONE);
};
mainHandler.post(myRunnable);
} else {
b.putInt("displayed", 1);
b.putParcelable("castedTube", peertube);
intentBC.putExtras(b);
LocalBroadcastManager.getInstance(PeertubeActivity.this).sendBroadcast(intentBC);
try {
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> {
invalidateOptionsMenu();
binding.castLoader.setVisibility(View.VISIBLE);
player.setPlayWhenReady(false);
binding.doubleTapPlayerView.setVisibility(View.GONE);
binding.castController.setVisibility(View.VISIBLE);
dialog.dismiss();
if (chromeCastVideoURL != null) {
if (player != null && player.getCurrentPosition() > 0) {
chromeCastVideoURL += "?start=" + (player.getCurrentPosition() / 1000);
}
}
};
mainHandler.post(myRunnable);
if (!chromeCast.isConnected()) {
chromeCast.connect();
}
myRunnable = this::invalidateOptionsMenu;
mainHandler.post(myRunnable);
Status status = chromeCast.getStatus();
if (chromeCast.isAppAvailable(CAST_ID) && !status.isAppRunning(CAST_ID)) {
chromeCast.launchApp(CAST_ID);
}
if (chromeCastVideoURL != null) {
String mime = MimeTypeMap.getFileExtensionFromUrl(chromeCastVideoURL);
chromeCast.setRequestTimeout(60000);
chromeCast.load(peertube.getTitle(), null, chromeCastVideoURL, mime);
chromeCast.play();
binding.castPlay.setImageResource(R.drawable.ic_baseline_pause_32);
}
myRunnable = () -> binding.castLoader.setVisibility(View.GONE);
mainHandler.post(myRunnable);
} catch (IOException | GeneralSecurityException e) {
e.printStackTrace();
}
}
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> {
invalidateOptionsMenu();
dialog.dismiss();
};
mainHandler.post(myRunnable);
}
}).start();
});
alt_bld.setPositiveButton(R.string.close, (dialog, id) -> dialog.dismiss());
AlertDialog alert = alt_bld.create();
alert.show();
}
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -1417,6 +1263,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}); });
} }
/** /**
* Manage video to play with different factors * Manage video to play with different factors
* *
@ -1429,7 +1276,10 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
* @param lang String ("en","fr", etc.) * @param lang String ("en","fr", etc.)
*/ */
private void stream(VideoData.Video video, String localTorrentUrl, String resolution, boolean autoPlay, long position, Uri subtitles, String lang) { private void stream(VideoData.Video video, String localTorrentUrl, String resolution, boolean autoPlay, long position, Uri subtitles, String lang) {
String videoURL = localTorrentUrl == null ? video.getFileUrl(resolution, PeertubeActivity.this) : localTorrentUrl; videoURL = localTorrentUrl == null ? video.getFileUrl(resolution, PeertubeActivity.this) : localTorrentUrl;
if (subtitles != null) {
subtitlesStr = subtitles.toString();
}
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
int video_cache = sharedpreferences.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB); int video_cache = sharedpreferences.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB);
if (videoURL != null && (videoURL.endsWith(".torrent") || videoURL.startsWith("magnet"))) { if (videoURL != null && (videoURL.endsWith(".torrent") || videoURL.startsWith("magnet"))) {
@ -1503,6 +1353,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
if (autoPlay) { if (autoPlay) {
binding.doubleTapPlayerView.hideController(); binding.doubleTapPlayerView.hideController();
} }
// loadCast(video, videoURL, subtitles!=null?subtitles.toString():null);
} }
private void fetchComments() { private void fetchComments() {
@ -1544,7 +1395,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
snackbar.show(); snackbar.show();
return; return;
} }
chromeCastVideoURL = videoURL;
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
String nsfwAction = sharedpreferences.getString(getString(R.string.set_video_sensitive_choice), Helper.BLUR); String nsfwAction = sharedpreferences.getString(getString(R.string.set_video_sensitive_choice), Helper.BLUR);
if (promptNSFW && peertube != null && peertube.isNsfw() && (nsfwAction.compareTo(Helper.BLUR) == 0 || nsfwAction.compareTo(Helper.DO_NOT_LIST) == 0)) { if (promptNSFW && peertube != null && peertube.isNsfw() && (nsfwAction.compareTo(Helper.BLUR) == 0 || nsfwAction.compareTo(Helper.DO_NOT_LIST) == 0)) {
@ -1574,7 +1425,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
@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) {
@ -1627,7 +1478,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
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();
@ -1643,7 +1494,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
} }
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

@ -43,6 +43,7 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit;
import app.fedilab.fedilabtube.BuildConfig; import app.fedilab.fedilabtube.BuildConfig;
import app.fedilab.fedilabtube.MainActivity; import app.fedilab.fedilabtube.MainActivity;
@ -85,6 +86,7 @@ import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
import app.fedilab.fedilabtube.viewmodel.TimelineVM; import app.fedilab.fedilabtube.viewmodel.TimelineVM;
import okhttp3.MediaType; import okhttp3.MediaType;
import okhttp3.MultipartBody; import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
import retrofit2.Call; import retrofit2.Call;
@ -103,6 +105,13 @@ public class RetrofitPeertubeAPI {
private String token; private String token;
private Set<String> selection; private Set<String> selection;
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.build();
public RetrofitPeertubeAPI(Context context) { public RetrofitPeertubeAPI(Context context) {
_context = context; _context = context;
instance = HelperInstance.getLiveInstance(context); instance = HelperInstance.getLiveInstance(context);
@ -199,6 +208,7 @@ public class RetrofitPeertubeAPI {
Retrofit retrofit = new Retrofit.Builder() Retrofit retrofit = new Retrofit.Builder()
.baseUrl(finalUrl) .baseUrl(finalUrl)
.addConverterFactory(GsonConverterFactory.create()) .addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build(); .build();
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
if (token == null) { if (token == null) {
@ -215,6 +225,7 @@ public class RetrofitPeertubeAPI {
Retrofit retrofit = new Retrofit.Builder() Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance) .baseUrl("https://" + instance)
.addConverterFactory(GsonConverterFactory.create()) .addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build(); .build();
return retrofit.create(PeertubeService.class); return retrofit.create(PeertubeService.class);
} }

View File

@ -25,6 +25,7 @@ import android.os.Looper;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.concurrent.TimeUnit;
import app.fedilab.fedilabtube.MainActivity; import app.fedilab.fedilabtube.MainActivity;
import app.fedilab.fedilabtube.R; import app.fedilab.fedilabtube.R;
@ -36,6 +37,7 @@ import app.fedilab.fedilabtube.client.entities.Token;
import app.fedilab.fedilabtube.helper.Helper; import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.sqlite.MastodonAccountDAO; import app.fedilab.fedilabtube.sqlite.MastodonAccountDAO;
import app.fedilab.fedilabtube.sqlite.Sqlite; import app.fedilab.fedilabtube.sqlite.Sqlite;
import okhttp3.OkHttpClient;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Response; import retrofit2.Response;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -49,6 +51,12 @@ public class RetrofitMastodonAPI {
private String instance; private String instance;
private String token; private String token;
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.build();
public Status search(String url) throws Error { public Status search(String url) throws Error {
MastodonService mastodonService2 = init2(); MastodonService mastodonService2 = init2();
Call<Results> statusCall = mastodonService2.searchMessage(getToken(), url); Call<Results> statusCall = mastodonService2.searchMessage(getToken(), url);
@ -147,6 +155,7 @@ public class RetrofitMastodonAPI {
Retrofit retrofit = new Retrofit.Builder() Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + instance) .baseUrl("https://" + instance)
.addConverterFactory(GsonConverterFactory.create()) .addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build(); .build();
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
if (token == null) { if (token == null) {
@ -159,6 +168,7 @@ public class RetrofitMastodonAPI {
Retrofit retrofit = new Retrofit.Builder() Retrofit retrofit = new Retrofit.Builder()
.baseUrl(finalUrl) .baseUrl(finalUrl)
.addConverterFactory(GsonConverterFactory.create()) .addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build(); .build();
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
if (token == null) { if (token == null) {
@ -171,6 +181,7 @@ public class RetrofitMastodonAPI {
Retrofit retrofit = new Retrofit.Builder() Retrofit retrofit = new Retrofit.Builder()
.baseUrl(finalUrl2) .baseUrl(finalUrl2)
.addConverterFactory(GsonConverterFactory.create()) .addConverterFactory(GsonConverterFactory.create())
.client(okHttpClient)
.build(); .build();
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
if (token == null) { if (token == null) {

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

@ -34,6 +34,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import app.fedilab.fedilabtube.BuildConfig;
import app.fedilab.fedilabtube.MainActivity; import app.fedilab.fedilabtube.MainActivity;
import app.fedilab.fedilabtube.R; import app.fedilab.fedilabtube.R;
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI; import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
@ -315,7 +316,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
CharSequence[] entriesTheme = arrayTheme.toArray(new CharSequence[0]); CharSequence[] entriesTheme = arrayTheme.toArray(new CharSequence[0]);
CharSequence[] entryValuesTheme = new CharSequence[3]; CharSequence[] entryValuesTheme = new CharSequence[3];
final SharedPreferences sharedpref = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); final SharedPreferences sharedpref = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
int currentTheme = sharedpref.getInt(Helper.SET_THEME, Helper.DEFAULT_MODE); int currentTheme = sharedpref.getInt(Helper.SET_THEME, BuildConfig.default_theme);
entryValuesTheme[0] = String.valueOf(Helper.LIGHT_MODE); entryValuesTheme[0] = String.valueOf(Helper.LIGHT_MODE);
entryValuesTheme[1] = String.valueOf(Helper.DARK_MODE); entryValuesTheme[1] = String.valueOf(Helper.DARK_MODE);
entryValuesTheme[2] = String.valueOf(Helper.DEFAULT_MODE); entryValuesTheme[2] = String.valueOf(Helper.DEFAULT_MODE);
@ -407,7 +408,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
set_video_in_list_choice.setChecked(videosInList); set_video_in_list_choice.setChecked(videosInList);
//****** Allow Chromecast ******* //****** Allow Chromecast *******
int cast = sharedpref.getInt(getString(R.string.set_cast_choice), 0); int cast = sharedpref.getInt(getString(R.string.set_cast_choice), BuildConfig.cast_enabled);
SwitchPreference set_cast_choice = findPreference(getString(R.string.set_cast_choice)); SwitchPreference set_cast_choice = findPreference(getString(R.string.set_cast_choice));
assert set_cast_choice != null; assert set_cast_choice != null;
set_cast_choice.setChecked(cast == 1); set_cast_choice.setChecked(cast == 1);

View File

@ -135,6 +135,7 @@ public class Helper {
public static final String VIDEO_ID = "video_id_update"; public static final String VIDEO_ID = "video_id_update";
public static final String APP_PREFS = "app_prefs"; public static final String APP_PREFS = "app_prefs";
public static final String CAST_ID = "D402501A"; public static final String CAST_ID = "D402501A";
public static final String CAST_ID_BITTUBE = "CBA4A31D";
public static final int VIDEOS_PER_PAGE = 10; public static final int VIDEOS_PER_PAGE = 10;
public static final String RECEIVE_ACTION = "receive_action"; public static final String RECEIVE_ACTION = "receive_action";
public static final String SET_UNFOLLOW_VALIDATION = "set_unfollow_validation"; public static final String SET_UNFOLLOW_VALIDATION = "set_unfollow_validation";

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"
@ -689,6 +640,5 @@
android:layout_gravity="center" android:layout_gravity="center"
android:layout_margin="30dp" /> android:layout_margin="30dp" />
</RelativeLayout> </RelativeLayout>
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -377,4 +377,6 @@
<string name="subscription_cancelled">Subscription cancelled!</string> <string name="subscription_cancelled">Subscription cancelled!</string>
<string name="cancel_subscription">Cancel subscription</string> <string name="cancel_subscription">Cancel subscription</string>
<string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string> <string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string>
<string name="mark_all_notifications_as_read_confirm">Are you sure you want to mark all notifications as read?</string>
<string name="mark_all_as_read">Mark all as read</string>
</resources> </resources>

View File

@ -373,4 +373,6 @@
<string name="subscription_cancelled">Subscription cancelled!</string> <string name="subscription_cancelled">Subscription cancelled!</string>
<string name="cancel_subscription">Cancel subscription</string> <string name="cancel_subscription">Cancel subscription</string>
<string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string> <string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string>
<string name="mark_all_notifications_as_read_confirm">Are you sure you want to mark all notifications as read?</string>
<string name="mark_all_as_read">Mark all as read</string>
</resources> </resources>

View File

@ -372,4 +372,6 @@
<string name="subscription_cancelled">Subscription cancelled!</string> <string name="subscription_cancelled">Subscription cancelled!</string>
<string name="cancel_subscription">Cancel subscription</string> <string name="cancel_subscription">Cancel subscription</string>
<string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string> <string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string>
<string name="mark_all_notifications_as_read_confirm">Are you sure you want to mark all notifications as read?</string>
<string name="mark_all_as_read">Mark all as read</string>
</resources> </resources>

View File

@ -373,4 +373,6 @@
<string name="subscription_cancelled">Subscription cancelled!</string> <string name="subscription_cancelled">Subscription cancelled!</string>
<string name="cancel_subscription">Cancel subscription</string> <string name="cancel_subscription">Cancel subscription</string>
<string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string> <string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string>
<string name="mark_all_notifications_as_read_confirm">Are you sure you want to mark all notifications as read?</string>
<string name="mark_all_as_read">Mark all as read</string>
</resources> </resources>

View File

@ -372,4 +372,6 @@
<string name="subscription_cancelled">Subscription cancelled!</string> <string name="subscription_cancelled">Subscription cancelled!</string>
<string name="cancel_subscription">Cancel subscription</string> <string name="cancel_subscription">Cancel subscription</string>
<string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string> <string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string>
<string name="mark_all_notifications_as_read_confirm">Are you sure you want to mark all notifications as read?</string>
<string name="mark_all_as_read">Mark all as read</string>
</resources> </resources>

View File

@ -372,4 +372,6 @@
<string name="subscription_cancelled">Subscription cancelled!</string> <string name="subscription_cancelled">Subscription cancelled!</string>
<string name="cancel_subscription">Cancel subscription</string> <string name="cancel_subscription">Cancel subscription</string>
<string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string> <string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string>
<string name="mark_all_notifications_as_read_confirm">Are you sure you want to mark all notifications as read?</string>
<string name="mark_all_as_read">Mark all as read</string>
</resources> </resources>

View File

@ -373,4 +373,6 @@
<string name="subscription_cancelled">Subscription cancelled!</string> <string name="subscription_cancelled">Subscription cancelled!</string>
<string name="cancel_subscription">Cancel subscription</string> <string name="cancel_subscription">Cancel subscription</string>
<string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string> <string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string>
<string name="mark_all_notifications_as_read_confirm">Are you sure you want to mark all notifications as read?</string>
<string name="mark_all_as_read">Mark all as read</string>
</resources> </resources>

View File

@ -375,4 +375,6 @@
<string name="subscription_cancelled">Subscription cancelled!</string> <string name="subscription_cancelled">Subscription cancelled!</string>
<string name="cancel_subscription">Cancel subscription</string> <string name="cancel_subscription">Cancel subscription</string>
<string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string> <string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string>
<string name="mark_all_notifications_as_read_confirm">Are you sure you want to mark all notifications as read?</string>
<string name="mark_all_as_read">Mark all as read</string>
</resources> </resources>

View File

@ -373,4 +373,6 @@
<string name="subscription_cancelled">Subscription cancelled!</string> <string name="subscription_cancelled">Subscription cancelled!</string>
<string name="cancel_subscription">Cancel subscription</string> <string name="cancel_subscription">Cancel subscription</string>
<string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string> <string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string>
<string name="mark_all_notifications_as_read_confirm">Are you sure you want to mark all notifications as read?</string>
<string name="mark_all_as_read">Mark all as read</string>
</resources> </resources>

View File

@ -133,9 +133,9 @@
<string name="action_follow">Подписка</string> <string name="action_follow">Подписка</string>
<string name="action_mute">Игнорировать</string> <string name="action_mute">Игнорировать</string>
<string name="unlimited">Без ограничений</string> <string name="unlimited">Без ограничений</string>
<string name="peers">%1$d Peers</string> <string name="peers">%1$d пиров</string>
<string name="b">B</string> <string name="b">Б</string>
<string name="kb">KB</string> <string name="kb">КБ</string>
<string name="mb">МБ</string> <string name="mb">МБ</string>
<string name="gb">ГБ</string> <string name="gb">ГБ</string>
<string name="total_video_quota">Общая квота видео</string> <string name="total_video_quota">Общая квота видео</string>
@ -357,22 +357,24 @@
<string name="instance_not_availabe">Экземпляр недоступен!</string> <string name="instance_not_availabe">Экземпляр недоступен!</string>
<string name="max_tag_size">На видео не должно быть более 5 тегов!</string> <string name="max_tag_size">На видео не должно быть более 5 тегов!</string>
<string name="watermark">Водяной знак</string> <string name="watermark">Водяной знак</string>
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string> <string name="toast_code_error">Произошла ошибка! Экземпляр не вернул код авторизации!</string>
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string> <string name="remote_account_from"><b>%1$s</b> удаленная учетная запись, связанная с приложением.\n\nВы можете перейти к некоторым ограниченным действиям.</string>
<string name="donate">Donate</string> <string name="donate">Пожертвование</string>
<string name="my_donations">My donations</string> <string name="my_donations">Мои пожертвования</string>
<string name="one_time_donation_text">Here, you can make a one time donation for supporting the development of the app. This action will not bring extra features!</string> <string name="one_time_donation_text">Здесь вы можете сделать единовременное пожертвование для поддержки разработки приложения. Это действие не принесет дополнительных возможностей!</string>
<string name="recurrent_donation_text">Here, you can make a recurrent donation for supporting the development of the app. This action will not bring extra features!</string> <string name="recurrent_donation_text">Здесь вы можете сделать единовременное пожертвование для поддержки разработки приложения. Это действие не принесет дополнительных возможностей!</string>
<string name="make_a_donation">Make a donation</string> <string name="make_a_donation">Сделать пожертвование</string>
<string name="donations_description">Here you will find the list of your recurrent donations made to support the development of the app! Thank you!</string> <string name="donations_description">Здесь вы найдете список ваших периодических пожертвований, сделанных для поддержки разработки приложения! Спасибо!</string>
<string name="support_the_app">Support the app</string> <string name="support_the_app">Поддержка приложения</string>
<string name="donation_cancelled">Donation has been cancelled!</string> <string name="donation_cancelled">Пожертвование было отменено!</string>
<string name="donation_succeeded_null">Thank you for your donation!</string> <string name="donation_succeeded_null">Благодарим Вас за ваше пожертвование!</string>
<string name="donation_succeeded">Thank you for your donation of %1$s!</string> <string name="donation_succeeded">Спасибо за пожертвование в %1$s!</string>
<string name="one_time">One time</string> <string name="one_time">Один раз</string>
<string name="my_subscriptions">My subscription</string> <string name="my_subscriptions">Моя подписка</string>
<string name="month">Month</string> <string name="month">Месяц</string>
<string name="subscription_cancelled">Subscription cancelled!</string> <string name="subscription_cancelled">Подписка отменена!</string>
<string name="cancel_subscription">Cancel subscription</string> <string name="cancel_subscription">Отменить подписку</string>
<string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string> <string name="cancel_subscription_confirm">Вы уверены, что хотите отменить эту подписку?</string>
<string name="mark_all_notifications_as_read_confirm">Вы уверены, что хотите отметить все уведомления как прочитанные?</string>
<string name="mark_all_as_read">Отметить все как прочитанные</string>
</resources> </resources>

View File

@ -373,4 +373,6 @@
<string name="subscription_cancelled">Subscription cancelled!</string> <string name="subscription_cancelled">Subscription cancelled!</string>
<string name="cancel_subscription">Cancel subscription</string> <string name="cancel_subscription">Cancel subscription</string>
<string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string> <string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string>
<string name="mark_all_notifications_as_read_confirm">Are you sure you want to mark all notifications as read?</string>
<string name="mark_all_as_read">Mark all as read</string>
</resources> </resources>

View File

@ -371,4 +371,6 @@
<string name="subscription_cancelled">Subscription cancelled!</string> <string name="subscription_cancelled">Subscription cancelled!</string>
<string name="cancel_subscription">Cancel subscription</string> <string name="cancel_subscription">Cancel subscription</string>
<string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string> <string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string>
<string name="mark_all_notifications_as_read_confirm">Are you sure you want to mark all notifications as read?</string>
<string name="mark_all_as_read">Mark all as read</string>
</resources> </resources>

View File

@ -372,4 +372,6 @@
<string name="subscription_cancelled">Subscription cancelled!</string> <string name="subscription_cancelled">Subscription cancelled!</string>
<string name="cancel_subscription">Cancel subscription</string> <string name="cancel_subscription">Cancel subscription</string>
<string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string> <string name="cancel_subscription_confirm">Are you sure, you want to cancel that subscription?</string>
<string name="mark_all_notifications_as_read_confirm">Are you sure you want to mark all notifications as read?</string>
<string name="mark_all_as_read">Mark all as read</string>
</resources> </resources>

View File

@ -0,0 +1,261 @@
package app.fedilab.fedilabtube;
/* Copyright 2021 Thomas Schneider
*
* This file is a part of TubeLab
*
* 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.
*
* TubeLab 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 TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import java.io.IOException;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import app.fedilab.fedilabtube.client.data.VideoData;
import app.fedilab.fedilabtube.databinding.ActivityMainBinding;
import app.fedilab.fedilabtube.helper.Helper;
import su.litvak.chromecast.api.v2.ChromeCast;
import su.litvak.chromecast.api.v2.ChromeCasts;
import su.litvak.chromecast.api.v2.ChromeCastsListener;
import su.litvak.chromecast.api.v2.MediaStatus;
public abstract class BaseMainActivity extends AppCompatActivity implements ChromeCastsListener {
public static List<ChromeCast> chromeCasts;
public static ChromeCast chromeCast;
public static boolean chromecastActivated = false;
protected ActivityMainBinding binding;
private BroadcastReceiver manage_chromecast;
private VideoData.Video castedTube;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(getLayoutInflater());
View view = binding.getRoot();
setContentView(view);
ChromeCastsListener chromeCastsListener = this;
ChromeCasts.registerListener(chromeCastsListener);
binding.castClose.setOnClickListener(v -> {
Intent intentBC = new Intent(Helper.RECEIVE_CAST_SETTINGS);
Bundle b = new Bundle();
b.putInt("displayed", 0);
intentBC.putExtras(b);
LocalBroadcastManager.getInstance(BaseMainActivity.this).sendBroadcast(intentBC);
});
binding.castTogglePlay.setOnClickListener(v -> {
if (chromeCast != null) {
new Thread(() -> {
try {
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> binding.castTogglePlay.setVisibility(View.GONE);
mainHandler.post(myRunnable);
int icon = -1;
if (chromeCast.getMediaStatus().playerState == MediaStatus.PlayerState.PLAYING) {
chromeCast.pause();
icon = R.drawable.ic_baseline_play_arrow_32;
} else if (chromeCast.getMediaStatus().playerState == MediaStatus.PlayerState.PAUSED) {
chromeCast.play();
icon = R.drawable.ic_baseline_pause_32;
}
if (icon != -1) {
int finalIcon = icon;
myRunnable = () -> binding.castTogglePlay.setImageResource(finalIcon);
mainHandler.post(myRunnable);
}
myRunnable = () -> binding.castTogglePlay.setVisibility(View.VISIBLE);
mainHandler.post(myRunnable);
} catch (IOException e) {
e.printStackTrace();
}
}).start();
}
});
manage_chromecast = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Bundle b = intent.getExtras();
assert b != null;
int state = b.getInt("state_asked", -1);
int displayed = b.getInt("displayed", -1);
castedTube = b.getParcelable("castedTube");
if (state == 1) {
discoverCast();
} else if (state == 0) {
new Thread(() -> {
try {
if (chromeCast != null) {
chromeCast.stopApp();
chromeCast.disconnect();
}
} catch (IOException e) {
e.printStackTrace();
}
}).start();
}
if (displayed == 1) {
chromecastActivated = true;
if (castedTube != null) {
binding.castInfo.setVisibility(View.VISIBLE);
Helper.loadGiF(BaseMainActivity.this, castedTube.getThumbnailPath(), binding.castView);
binding.castTitle.setText(castedTube.getTitle());
binding.castDescription.setText(castedTube.getDescription());
}
} else if (displayed == 0) {
chromecastActivated = false;
binding.castInfo.setVisibility(View.GONE);
new Thread(() -> {
try {
if (chromeCast != null) {
chromeCast.stopApp();
}
} catch (IOException e) {
e.printStackTrace();
}
}).start();
}
}
};
LocalBroadcastManager.getInstance(BaseMainActivity.this).registerReceiver(manage_chromecast, new IntentFilter(Helper.RECEIVE_CAST_SETTINGS));
}
@Override
public void newChromeCastDiscovered(ChromeCast chromeCast) {
if (chromeCasts == null) {
chromeCasts = new ArrayList<>();
chromeCasts.add(chromeCast);
} else {
boolean canBeAdded = true;
for (ChromeCast cast : chromeCasts) {
if (cast.getName().compareTo(chromeCast.getName()) == 0) {
canBeAdded = false;
break;
}
}
if (canBeAdded) {
chromeCasts.add(chromeCast);
}
}
try {
if (chromeCast.isAppRunning(Helper.CAST_ID) && chromeCast.getMediaStatus() != null && chromeCast.getMediaStatus().playerState != null) {
if (binding.castInfo.getVisibility() == View.GONE) {
binding.castInfo.setVisibility(View.VISIBLE);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void chromeCastRemoved(ChromeCast chromeCast) {
}
@Override
public void onDestroy() {
super.onDestroy();
ChromeCasts.unregisterListener(this);
if (manage_chromecast != null) {
LocalBroadcastManager.getInstance(BaseMainActivity.this).unregisterReceiver(manage_chromecast);
new Thread(() -> {
if (chromeCasts != null && chromeCasts.size() > 0) {
for (ChromeCast cast : chromeCasts) {
try {
cast.stopApp();
cast.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}).start();
}
if (chromeCasts != null) {
chromeCasts = null;
}
if (chromeCast != null) {
chromeCast = null;
}
}
//Method for discovering cast devices
public void discoverCast() {
new Thread(() -> {
if (chromeCasts != null) {
for (ChromeCast cast : chromeCasts) {
try {
cast.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
chromeCasts = null;
}
chromeCasts = new ArrayList<>();
try {
List<NetworkInterface> interfaces;
interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface ni : interfaces) {
if ((!ni.isLoopback()) && ni.isUp() && (ni.getName().equals("wlan0"))) {
Enumeration<InetAddress> inetAddressEnumeration = ni.getInetAddresses();
while (inetAddressEnumeration.hasMoreElements()) {
InetAddress inetAddress = inetAddressEnumeration.nextElement();
ChromeCasts.restartDiscovery(inetAddress);
int tryFind = 0;
while (ChromeCasts.get().isEmpty() && tryFind < 5) {
try {
//noinspection BusyWait
Thread.sleep(1000);
tryFind++;
} catch (InterruptedException ignored) {
}
}
}
}
}
ChromeCasts.stopDiscovery();
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = this::invalidateOptionsMenu;
mainHandler.post(myRunnable);
} catch (IOException e) {
e.printStackTrace();
}
}).start();
}
}

View File

@ -0,0 +1,205 @@
package app.fedilab.fedilabtube;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.webkit.MimeTypeMap;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.google.android.exoplayer2.SimpleExoPlayer;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.security.GeneralSecurityException;
import app.fedilab.fedilabtube.client.data.VideoData;
import app.fedilab.fedilabtube.databinding.ActivityPeertubeBinding;
import app.fedilab.fedilabtube.helper.Helper;
import su.litvak.chromecast.api.v2.ChromeCast;
import su.litvak.chromecast.api.v2.MediaStatus;
import su.litvak.chromecast.api.v2.Status;
import static app.fedilab.fedilabtube.helper.Helper.CAST_ID;
/* Copyright 2021 Thomas Schneider
*
* This file is a part of TubeLab
*
* 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.
*
* TubeLab 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 TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
public class BasePeertubeActivity extends AppCompatActivity {
protected ActivityPeertubeBinding binding;
protected VideoData.Video peertube;
protected SimpleExoPlayer player;
protected String videoURL;
protected String subtitlesStr;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityPeertubeBinding.inflate(getLayoutInflater());
View view = binding.getRoot();
setContentView(view);
binding.minController.castPlay.setOnClickListener(v -> {
binding.minController.castLoader.setVisibility(View.VISIBLE);
if (BaseMainActivity.chromeCast != null) {
new Thread(() -> {
try {
int icon = -1;
if (BaseMainActivity.chromeCast.getMediaStatus().playerState == MediaStatus.PlayerState.PLAYING) {
BaseMainActivity.chromeCast.pause();
icon = R.drawable.ic_baseline_play_arrow_32;
} else if (BaseMainActivity.chromeCast.getMediaStatus().playerState == MediaStatus.PlayerState.PAUSED) {
BaseMainActivity.chromeCast.play();
icon = R.drawable.ic_baseline_pause_32;
}
if (icon != -1) {
Handler mainHandler = new Handler(Looper.getMainLooper());
int finalIcon = icon;
Runnable myRunnable = () -> binding.minController.castPlay.setImageResource(finalIcon);
mainHandler.post(myRunnable);
}
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> binding.minController.castLoader.setVisibility(View.GONE);
mainHandler.post(myRunnable);
} catch (IOException e) {
e.printStackTrace();
}
}).start();
}
});
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_cast) {
if (BaseMainActivity.chromeCasts != null && BaseMainActivity.chromeCasts.size() > 0) {
String[] chromecast_choice = new String[BaseMainActivity.chromeCasts.size()];
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
alt_bld.setTitle(R.string.chromecast_choice);
int i = 0;
for (ChromeCast cc : BaseMainActivity.chromeCasts) {
chromecast_choice[i] = cc.getTitle();
i++;
}
i = 0;
for (ChromeCast cc : BaseMainActivity.chromeCasts) {
if (BaseMainActivity.chromecastActivated && cc.isConnected()) {
break;
}
i++;
}
alt_bld.setSingleChoiceItems(chromecast_choice, i, (dialog, position) -> {
BaseMainActivity.chromeCast = BaseMainActivity.chromeCasts.get(position);
new Thread(() -> {
if (BaseMainActivity.chromeCast != null) {
Intent intentBC = new Intent(Helper.RECEIVE_CAST_SETTINGS);
Bundle b = new Bundle();
if (BaseMainActivity.chromecastActivated) {
b.putInt("displayed", 0);
intentBC.putExtras(b);
LocalBroadcastManager.getInstance(BasePeertubeActivity.this).sendBroadcast(intentBC);
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> {
binding.doubleTapPlayerView.setVisibility(View.VISIBLE);
binding.minController.castMiniController.setVisibility(View.GONE);
};
mainHandler.post(myRunnable);
} else {
b.putInt("displayed", 1);
b.putParcelable("castedTube", peertube);
intentBC.putExtras(b);
LocalBroadcastManager.getInstance(BasePeertubeActivity.this).sendBroadcast(intentBC);
try {
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> {
invalidateOptionsMenu();
binding.minController.castLoader.setVisibility(View.VISIBLE);
player.setPlayWhenReady(false);
binding.doubleTapPlayerView.setVisibility(View.GONE);
binding.minController.castMiniController.setVisibility(View.VISIBLE);
dialog.dismiss();
if (videoURL != null) {
if (player != null && player.getCurrentPosition() > 0) {
videoURL += "?start=" + (player.getCurrentPosition() / 1000);
}
}
};
mainHandler.post(myRunnable);
if (!BaseMainActivity.chromeCast.isConnected()) {
BaseMainActivity.chromeCast.connect();
}
myRunnable = this::invalidateOptionsMenu;
mainHandler.post(myRunnable);
Status status = BaseMainActivity.chromeCast.getStatus();
if (BaseMainActivity.chromeCast.isAppAvailable(CAST_ID) && !status.isAppRunning(CAST_ID)) {
BaseMainActivity.chromeCast.launchApp(CAST_ID);
}
if (videoURL != null) {
String mime = MimeTypeMap.getFileExtensionFromUrl(videoURL);
BaseMainActivity.chromeCast.setRequestTimeout(60000);
BaseMainActivity.chromeCast.load(peertube.getTitle(), null, videoURL, mime);
BaseMainActivity.chromeCast.play();
binding.minController.castPlay.setImageResource(R.drawable.ic_baseline_pause_32);
}
myRunnable = () -> binding.minController.castLoader.setVisibility(View.GONE);
mainHandler.post(myRunnable);
} catch (IOException | GeneralSecurityException e) {
e.printStackTrace();
}
}
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> {
invalidateOptionsMenu();
dialog.dismiss();
};
mainHandler.post(myRunnable);
}
}).start();
});
alt_bld.setPositiveButton(R.string.close, (dialog, id) -> dialog.dismiss());
AlertDialog alert = alt_bld.create();
alert.show();
}
}
return super.onOptionsItemSelected(item);
}
@Override
public boolean onCreateOptionsMenu(@NotNull Menu menu) {
getMenuInflater().inflate(R.menu.video_menu, menu);
MenuItem castItem = menu.findItem(R.id.action_cast);
if (BaseMainActivity.chromeCasts != null && BaseMainActivity.chromeCasts.size() > 0) {
castItem.setVisible(true);
if (BaseMainActivity.chromeCast != null && BaseMainActivity.chromeCast.isConnected()) {
castItem.setIcon(R.drawable.ic_baseline_cast_connected_24);
} else {
castItem.setIcon(R.drawable.ic_baseline_cast_24);
}
}
return true;
}
}

View File

@ -0,0 +1,18 @@
package app.fedilab.fedilabtube.provider;
/* Copyright 2021 Thomas Schneider
*
* This file is a part of TubeLab
*
* 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.
*
* TubeLab 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 TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
public class CastOptionsProvider {
}

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>