some fixes
This commit is contained in:
parent
fcc10f97b5
commit
5172695784
|
@ -67,6 +67,7 @@ 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;
|
||||||
|
@ -90,10 +91,10 @@ import es.dmoral.toasty.Toasty;
|
||||||
import su.litvak.chromecast.api.v2.ChromeCast;
|
import su.litvak.chromecast.api.v2.ChromeCast;
|
||||||
import su.litvak.chromecast.api.v2.ChromeCasts;
|
import su.litvak.chromecast.api.v2.ChromeCasts;
|
||||||
import su.litvak.chromecast.api.v2.ChromeCastsListener;
|
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.PeertubeActivity.chromeCasts;
|
|
||||||
import static app.fedilab.fedilabtube.helper.Helper.peertubeInformation;
|
import static app.fedilab.fedilabtube.helper.Helper.peertubeInformation;
|
||||||
import static app.fedilab.fedilabtube.helper.HelperAcadInstance.academies;
|
import static app.fedilab.fedilabtube.helper.HelperAcadInstance.academies;
|
||||||
|
|
||||||
|
@ -109,6 +110,9 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
||||||
private DisplayOverviewFragment overviewFragment;
|
private DisplayOverviewFragment overviewFragment;
|
||||||
private ActivityMainBinding binding;
|
private ActivityMainBinding binding;
|
||||||
private BroadcastReceiver manage_chromecast;
|
private BroadcastReceiver manage_chromecast;
|
||||||
|
public static List<ChromeCast> chromeCasts;
|
||||||
|
public static ChromeCast 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) {
|
||||||
|
@ -206,9 +210,17 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void newChromeCastDiscovered(ChromeCast chromeCast) {
|
public void newChromeCastDiscovered(ChromeCast 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();
|
||||||
|
}
|
||||||
if (chromeCasts == null) {
|
if (chromeCasts == null) {
|
||||||
chromeCasts = new ArrayList<>();
|
chromeCasts = new ArrayList<>();
|
||||||
chromeCasts.add(chromeCast);
|
chromeCasts.add(chromeCast);
|
||||||
|
@ -224,6 +236,7 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
||||||
chromeCasts.add(chromeCast);
|
chromeCasts.add(chromeCast);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -238,17 +251,25 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
||||||
ChromeCasts.unregisterListener(this);
|
ChromeCasts.unregisterListener(this);
|
||||||
if (manage_chromecast != null) {
|
if (manage_chromecast != null) {
|
||||||
LocalBroadcastManager.getInstance(MainActivity.this).unregisterReceiver(manage_chromecast);
|
LocalBroadcastManager.getInstance(MainActivity.this).unregisterReceiver(manage_chromecast);
|
||||||
if (chromeCasts != null && chromeCasts.size() > 0) {
|
|
||||||
for (ChromeCast cast : chromeCasts) {
|
new Thread(() -> {
|
||||||
try {
|
if (chromeCasts != null && chromeCasts.size() > 0) {
|
||||||
cast.disconnect();
|
for (ChromeCast cast : chromeCasts) {
|
||||||
} catch (IOException e) {
|
try {
|
||||||
e.printStackTrace();
|
cast.disconnect();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}).start();
|
||||||
|
}
|
||||||
|
if (chromeCasts != null) {
|
||||||
chromeCasts = null;
|
chromeCasts = null;
|
||||||
}
|
}
|
||||||
|
if (chromeCast != null) {
|
||||||
|
chromeCast = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Method for discovering cast devices
|
//Method for discovering cast devices
|
||||||
|
@ -409,35 +430,93 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
||||||
PlaylistExportHelper.manageIntentUrl(MainActivity.this, getIntent());
|
PlaylistExportHelper.manageIntentUrl(MainActivity.this, getIntent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.castClose.setOnClickListener(v -> new Thread(() -> {
|
||||||
|
try {
|
||||||
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
|
chromeCast.disconnect();
|
||||||
|
Runnable myRunnable = () -> binding.castTogglePlay.setVisibility(View.GONE);
|
||||||
|
mainHandler.post(myRunnable);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
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() {
|
manage_chromecast = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
Bundle b = intent.getExtras();
|
Bundle b = intent.getExtras();
|
||||||
assert b != null;
|
assert b != null;
|
||||||
boolean state = b.getBoolean("state_asked");
|
int state = b.getInt("state_asked", -1);
|
||||||
if (state) {
|
int displayed = b.getInt("displayed", -1);
|
||||||
|
castedTube = b.getParcelable("castedTube");
|
||||||
|
|
||||||
|
if (state == 1) {
|
||||||
discoverCast();
|
discoverCast();
|
||||||
} else {
|
} else if (state == 0) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
ChromeCasts.get();
|
try {
|
||||||
if (ChromeCasts.get().size() > 0) {
|
if (chromeCast != null) {
|
||||||
for (ChromeCast cast : ChromeCasts.get()) {
|
chromeCast.disconnect();
|
||||||
try {
|
|
||||||
cast.disconnect();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
if (displayed == 1) {
|
||||||
|
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) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
if (chromeCast != null) {
|
||||||
|
chromeCast.disconnect();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
binding.castInfo.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
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));
|
LocalBroadcastManager.getInstance(MainActivity.this).registerReceiver(manage_chromecast, new IntentFilter(Helper.RECEIVE_CAST_SETTINGS));
|
||||||
boolean search_cast = sharedpreferences.getBoolean(getString(R.string.set_cast_choice), false);
|
int search_cast = sharedpreferences.getInt(getString(R.string.set_cast_choice), 0);
|
||||||
if (search_cast) {
|
if (search_cast == 1) {
|
||||||
discoverCast();
|
discoverCast();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -657,6 +736,7 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void checkIfConnectedUsers() {
|
private void checkIfConnectedUsers() {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -70,6 +70,7 @@ 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;
|
||||||
|
|
||||||
|
@ -155,6 +156,8 @@ import su.litvak.chromecast.api.v2.ChromeCast;
|
||||||
import su.litvak.chromecast.api.v2.MediaStatus;
|
import su.litvak.chromecast.api.v2.MediaStatus;
|
||||||
import su.litvak.chromecast.api.v2.Status;
|
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.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;
|
||||||
|
@ -202,8 +205,6 @@ 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;
|
||||||
public static List<ChromeCast> chromeCasts;
|
|
||||||
private ChromeCast chromeCast;
|
|
||||||
private String chromeCastVideoURL;
|
private String chromeCastVideoURL;
|
||||||
|
|
||||||
public static void hideKeyboard(Activity activity) {
|
public static void hideKeyboard(Activity activity) {
|
||||||
|
@ -735,11 +736,24 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
chromecast_choice[i] = cc.getTitle();
|
chromecast_choice[i] = cc.getTitle();
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
i = 0;
|
||||||
|
for (ChromeCast cc : chromeCasts) {
|
||||||
|
if (cc.isConnected()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
alt_bld.setSingleChoiceItems(chromecast_choice, i, (dialog, position) -> {
|
alt_bld.setSingleChoiceItems(chromecast_choice, i, (dialog, position) -> {
|
||||||
chromeCast = chromeCasts.get(position);
|
chromeCast = chromeCasts.get(position);
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
if (chromeCast != null) {
|
if (chromeCast != null) {
|
||||||
if (chromeCast.isConnected()) {
|
if (chromeCast.isConnected()) {
|
||||||
|
Intent intentBC = new Intent(Helper.RECEIVE_CAST_SETTINGS);
|
||||||
|
Bundle b = new Bundle();
|
||||||
|
b.putInt("displayed", 0);
|
||||||
|
intentBC.putExtras(b);
|
||||||
|
LocalBroadcastManager.getInstance(PeertubeActivity.this).sendBroadcast(intentBC);
|
||||||
try {
|
try {
|
||||||
chromeCast.disconnect();
|
chromeCast.disconnect();
|
||||||
chromeCast = null;
|
chromeCast = null;
|
||||||
|
@ -754,6 +768,12 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Intent intentBC = new Intent(Helper.RECEIVE_CAST_SETTINGS);
|
||||||
|
Bundle b = new Bundle();
|
||||||
|
b.putInt("displayed", 1);
|
||||||
|
b.putParcelable("castedTube", peertube);
|
||||||
|
intentBC.putExtras(b);
|
||||||
|
LocalBroadcastManager.getInstance(PeertubeActivity.this).sendBroadcast(intentBC);
|
||||||
try {
|
try {
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable myRunnable = () -> {
|
Runnable myRunnable = () -> {
|
||||||
|
@ -934,6 +954,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apiResponse != null && apiResponse.getPeertubes() != null && apiResponse.getPeertubes().size() > 0 && apiResponse.getPeertubes().get(0).getErrorMessage() != null) {
|
if (apiResponse != null && apiResponse.getPeertubes() != null && apiResponse.getPeertubes().size() > 0 && apiResponse.getPeertubes().get(0).getErrorMessage() != null) {
|
||||||
Toasty.error(PeertubeActivity.this, apiResponse.getPeertubes().get(0).getErrorMessage(), Toast.LENGTH_LONG).show();
|
Toasty.error(PeertubeActivity.this, apiResponse.getPeertubes().get(0).getErrorMessage(), Toast.LENGTH_LONG).show();
|
||||||
binding.loader.setVisibility(View.GONE);
|
binding.loader.setVisibility(View.GONE);
|
||||||
|
@ -1611,7 +1632,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
||||||
int height = displayMetrics.heightPixels;
|
int height = displayMetrics.heightPixels;
|
||||||
binding.doubleTapPlayerView.hideController();
|
binding.doubleTapPlayerView.hideController();
|
||||||
List<MenuItemVideo> menuItemVideos = new ArrayList<>();
|
List<MenuItemVideo> menuItemVideos = new ArrayList<>();
|
||||||
if (peertube.getFiles() != null && peertube.getFiles().size() > 0) {
|
if (peertube.getAllFile(PeertubeActivity.this) != null && peertube.getAllFile(PeertubeActivity.this).size() > 0) {
|
||||||
MenuItemVideo resolutionItem = new MenuItemVideo();
|
MenuItemVideo resolutionItem = new MenuItemVideo();
|
||||||
resolutionItem.setIcon(R.drawable.ic_baseline_high_quality_24);
|
resolutionItem.setIcon(R.drawable.ic_baseline_high_quality_24);
|
||||||
resolutionItem.setTitle(getString(R.string.pickup_resolution));
|
resolutionItem.setTitle(getString(R.string.pickup_resolution));
|
||||||
|
|
|
@ -195,35 +195,63 @@ public class VideoData {
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
int mode = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL);
|
int mode = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL);
|
||||||
if (files != null && files.size() > 0) {
|
if (files != null && files.size() > 0) {
|
||||||
if (resolution != null) {
|
return getFile(context, files, resolution, mode);
|
||||||
for (File file : files) {
|
} else if (streamingPlaylists != null && streamingPlaylists.size() > 0) {
|
||||||
if (file.getResolutions().getLabel().compareTo(resolution) == 0) {
|
List<File> files = new ArrayList<>();
|
||||||
if (mode == Helper.VIDEO_MODE_MAGNET) {
|
for (StreamingPlaylists streamingPlaylists : streamingPlaylists) {
|
||||||
return file.getMagnetUri();
|
if (streamingPlaylists.getFiles().size() > 0) {
|
||||||
} else if (mode == Helper.VIDEO_MODE_TORRENT) {
|
files.addAll(streamingPlaylists.getFiles());
|
||||||
return file.getTorrentUrl();
|
} else {
|
||||||
} else {
|
return streamingPlaylists.getPlaylistUrl();
|
||||||
return file.getFileUrl();
|
}
|
||||||
}
|
}
|
||||||
|
return getFile(context, files, resolution, mode);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<File> getAllFile(Context context) {
|
||||||
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
int mode = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL);
|
||||||
|
if (files != null) {
|
||||||
|
return files;
|
||||||
|
} else if (streamingPlaylists != null) {
|
||||||
|
List<File> files = new ArrayList<>();
|
||||||
|
for (StreamingPlaylists streamingPlaylists : streamingPlaylists) {
|
||||||
|
files.addAll(streamingPlaylists.getFiles());
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getFile(Context context, List<File> files, String resolution, int mode) {
|
||||||
|
if (resolution != null) {
|
||||||
|
for (File file : files) {
|
||||||
|
if (file.getResolutions().getLabel().compareTo(resolution) == 0) {
|
||||||
|
if (mode == Helper.VIDEO_MODE_MAGNET) {
|
||||||
|
return file.getMagnetUri();
|
||||||
|
} else if (mode == Helper.VIDEO_MODE_TORRENT) {
|
||||||
|
return file.getTorrentUrl();
|
||||||
|
} else {
|
||||||
|
return file.getFileUrl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File file = Helper.defaultFile(context, files);
|
|
||||||
if (file != null) {
|
|
||||||
if (mode == Helper.VIDEO_MODE_MAGNET) {
|
|
||||||
return file.getMagnetUri();
|
|
||||||
} else if (mode == Helper.VIDEO_MODE_TORRENT) {
|
|
||||||
return file.getTorrentUrl();
|
|
||||||
} else {
|
|
||||||
return file.getFileUrl();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} else if (streamingPlaylists != null && streamingPlaylists.size() > 0) {
|
|
||||||
return streamingPlaylists.get(0).getPlaylistUrl();
|
|
||||||
}
|
}
|
||||||
return null;
|
File file = Helper.defaultFile(context, files);
|
||||||
|
if (file != null) {
|
||||||
|
if (mode == Helper.VIDEO_MODE_MAGNET) {
|
||||||
|
return file.getMagnetUri();
|
||||||
|
} else if (mode == Helper.VIDEO_MODE_TORRENT) {
|
||||||
|
return file.getTorrentUrl();
|
||||||
|
} else {
|
||||||
|
return file.getFileUrl();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTorrentUrl(String resolution, Context context) {
|
public String getTorrentUrl(String resolution, Context context) {
|
||||||
|
|
|
@ -236,10 +236,10 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
||||||
if (key.compareTo(getString(R.string.set_cast_choice)) == 0) {
|
if (key.compareTo(getString(R.string.set_cast_choice)) == 0) {
|
||||||
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;
|
||||||
editor.putBoolean(getString(R.string.set_cast_choice), set_cast_choice.isChecked());
|
editor.putInt(getString(R.string.set_cast_choice), set_cast_choice.isChecked() ? 1 : 0);
|
||||||
Intent intentBC = new Intent(Helper.RECEIVE_CAST_SETTINGS);
|
Intent intentBC = new Intent(Helper.RECEIVE_CAST_SETTINGS);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putBoolean("state_asked", set_cast_choice.isChecked());
|
b.putInt("state_asked", set_cast_choice.isChecked() ? 1 : 0);
|
||||||
intentBC.putExtras(b);
|
intentBC.putExtras(b);
|
||||||
LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(intentBC);
|
LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(intentBC);
|
||||||
}
|
}
|
||||||
|
@ -407,10 +407,10 @@ 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 *******
|
||||||
boolean cast = sharedpref.getBoolean(getString(R.string.set_cast), false);
|
int cast = sharedpref.getInt(getString(R.string.set_cast_choice), 0);
|
||||||
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);
|
set_cast_choice.setChecked(cast == 1);
|
||||||
|
|
||||||
//****** Language filter *********
|
//****** Language filter *********
|
||||||
LinkedHashMap<String, String> languages = new LinkedHashMap<>(Helper.peertubeInformation.getLanguages());
|
LinkedHashMap<String, String> languages = new LinkedHashMap<>(Helper.peertubeInformation.getLanguages());
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="#FFFFFF"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z" />
|
||||||
|
</vector>
|
|
@ -62,24 +62,102 @@
|
||||||
</androidx.appcompat.widget.Toolbar>
|
</androidx.appcompat.widget.Toolbar>
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
|
||||||
<androidx.viewpager.widget.ViewPager
|
<androidx.viewpager.widget.ViewPager
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
android:layout_marginBottom="?attr/actionBarSize"
|
||||||
android:id="@+id/viewpager"
|
android:id="@+id/viewpager"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent" />
|
||||||
android:layout_marginBottom="?attr/actionBarSize" />
|
|
||||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/nav_view"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="0dp"
|
android:layout_gravity="bottom">
|
||||||
android:layout_marginEnd="0dp"
|
|
||||||
android:background="?android:attr/windowBackground"
|
<LinearLayout
|
||||||
app:itemIconTint="@color/bottom_nav_color"
|
android:id="@+id/cast_info"
|
||||||
app:itemTextColor="@color/bottom_nav_color"
|
android:layout_width="match_parent"
|
||||||
/>
|
android:layout_height="80dp"
|
||||||
|
android:background="@android:color/black"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/nav_view"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/castView"
|
||||||
|
android:layout_width="60dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:contentDescription="@string/preview"
|
||||||
|
android:scaleType="centerCrop" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/cast_title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textColor="@color/white" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/cast_description"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/cast_toggle_play"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_margin="5dp"
|
||||||
|
android:contentDescription="@string/play"
|
||||||
|
android:src="@drawable/ic_baseline_pause_32" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/cast_close"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_margin="5dp"
|
||||||
|
android:contentDescription="@string/close"
|
||||||
|
android:src="@drawable/ic_baseline_close_white_24" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
|
android:id="@+id/nav_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="0dp"
|
||||||
|
android:layout_marginEnd="0dp"
|
||||||
|
android:background="?android:attr/windowBackground"
|
||||||
|
app:itemIconTint="@color/bottom_nav_color"
|
||||||
|
app:itemTextColor="@color/bottom_nav_color"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
||||||
</androidx.drawerlayout.widget.DrawerLayout>
|
</androidx.drawerlayout.widget.DrawerLayout>
|
Loading…
Reference in New Issue