Some fixes for peertube
This commit is contained in:
parent
d39f0c1ec3
commit
75b6b9bb76
|
@ -74,7 +74,6 @@ import static fr.gouv.etalab.mastodon.helper.Helper.manageDownloads;
|
||||||
public class PeertubeActivity extends BaseActivity implements OnRetrievePeertubeInterface {
|
public class PeertubeActivity extends BaseActivity implements OnRetrievePeertubeInterface {
|
||||||
|
|
||||||
private String peertubeInstance, videoId;
|
private String peertubeInstance, videoId;
|
||||||
private String peertubeLinkToFetch;
|
|
||||||
private FullScreenMediaController.fullscreen fullscreen;
|
private FullScreenMediaController.fullscreen fullscreen;
|
||||||
private VideoView videoView;
|
private VideoView videoView;
|
||||||
private RelativeLayout loader;
|
private RelativeLayout loader;
|
||||||
|
@ -121,10 +120,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
||||||
if(b != null) {
|
if(b != null) {
|
||||||
peertubeInstance = b.getString("peertube_instance", null);
|
peertubeInstance = b.getString("peertube_instance", null);
|
||||||
videoId = b.getString("video_id", null);
|
videoId = b.getString("video_id", null);
|
||||||
peertubeLinkToFetch = b.getString("peertubeLinkToFetch", null);
|
|
||||||
}
|
}
|
||||||
if( peertubeLinkToFetch == null)
|
|
||||||
finish();
|
|
||||||
if( getSupportActionBar() != null)
|
if( getSupportActionBar() != null)
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
@ -172,8 +168,8 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
|
|
||||||
if(peertubeLinkToFetch != null) {
|
if(peertube != null) {
|
||||||
Results search = new API(contextReference.get()).search(peertubeLinkToFetch);
|
Results search = new API(contextReference.get()).search("https://" + peertube.getAccount().getHost() + "/videos/watch/" + peertube.getUuid());
|
||||||
if (search != null) {
|
if (search != null) {
|
||||||
remoteStatuses = search.getStatuses();
|
remoteStatuses = search.getStatuses();
|
||||||
}
|
}
|
||||||
|
@ -265,7 +261,6 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
videoView.setZOrderOnTop(true);
|
videoView.setZOrderOnTop(true);
|
||||||
videoView.setMediaController(fullScreenMediaController);
|
|
||||||
videoView.start();
|
videoView.start();
|
||||||
|
|
||||||
peertube_download.setOnClickListener(new View.OnClickListener() {
|
peertube_download.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
|
@ -616,6 +616,7 @@ public class API {
|
||||||
try {
|
try {
|
||||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||||
String response = httpsConnection.get("https://"+instance+"/api/v1/videos", 60, params, null);
|
String response = httpsConnection.get("https://"+instance+"/api/v1/videos", 60, params, null);
|
||||||
|
Helper.largeLog(response);
|
||||||
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
|
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
|
||||||
peertubes = parsePeertube(instance, jsonArray);
|
peertubes = parsePeertube(instance, jsonArray);
|
||||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||||
|
|
|
@ -21,7 +21,6 @@ import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -114,12 +113,10 @@ public class PeertubeAdapter extends RecyclerView.Adapter implements OnListActio
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
String finalUrl = "https://" + instance + peertube.getEmbedPath();
|
String finalUrl = "https://" + instance + peertube.getEmbedPath();
|
||||||
Pattern link = Pattern.compile("(https?:\\/\\/[\\da-z\\.-]+\\.[a-z\\.]{2,10})\\/videos\\/embed\\/(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})$");
|
Pattern link = Pattern.compile("(https?:\\/\\/[\\da-z\\.-]+\\.[a-z\\.]{2,10})\\/videos\\/embed\\/(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})$");
|
||||||
Log.v(Helper.TAG,"finalUrl: "+finalUrl);
|
|
||||||
Matcher matcherLink = link.matcher(finalUrl);
|
Matcher matcherLink = link.matcher(finalUrl);
|
||||||
if( matcherLink.find()) {
|
if( matcherLink.find()) {
|
||||||
String url = matcherLink.group(1) + "/videos/watch/" + matcherLink.group(2);
|
String url = matcherLink.group(1) + "/videos/watch/" + matcherLink.group(2);
|
||||||
b.putString("peertubeLinkToFetch", url);
|
b.putString("peertubeLinkToFetch", url);
|
||||||
Log.v(Helper.TAG,"peertube_instance: "+matcherLink.group(1).replace("https://","").replace("http://",""));
|
|
||||||
b.putString("peertube_instance", matcherLink.group(1).replace("https://","").replace("http://",""));
|
b.putString("peertube_instance", matcherLink.group(1).replace("https://","").replace("http://",""));
|
||||||
b.putString("video_id", matcherLink.group(2));
|
b.putString("video_id", matcherLink.group(2));
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import android.view.Gravity;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.WindowManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.MediaController;
|
import android.widget.MediaController;
|
||||||
|
@ -65,7 +66,7 @@ public class FullScreenMediaController extends MediaController {
|
||||||
super.setAnchorView(view);
|
super.setAnchorView(view);
|
||||||
|
|
||||||
//image button for full screen to be added to media controller
|
//image button for full screen to be added to media controller
|
||||||
fullScreen = new ImageButton(super.getContext());
|
fullScreen = new ImageButton(context);
|
||||||
LayoutParams params =
|
LayoutParams params =
|
||||||
new LayoutParams(LayoutParams.WRAP_CONTENT,
|
new LayoutParams(LayoutParams.WRAP_CONTENT,
|
||||||
LayoutParams.WRAP_CONTENT);
|
LayoutParams.WRAP_CONTENT);
|
||||||
|
@ -76,7 +77,7 @@ public class FullScreenMediaController extends MediaController {
|
||||||
|
|
||||||
if( resolutionVal == null)
|
if( resolutionVal == null)
|
||||||
resolutionVal = peertube.getResolution().get(0) +"p";
|
resolutionVal = peertube.getResolution().get(0) +"p";
|
||||||
resolution = new Button(super.getContext());
|
resolution = new Button(context);
|
||||||
resolution.setAllCaps(false);
|
resolution.setAllCaps(false);
|
||||||
resolution.setBackgroundColor(Color.TRANSPARENT);
|
resolution.setBackgroundColor(Color.TRANSPARENT);
|
||||||
resolution.setText(resolutionVal);
|
resolution.setText(resolutionVal);
|
||||||
|
@ -103,8 +104,12 @@ public class FullScreenMediaController extends MediaController {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
popup.show();
|
try {
|
||||||
|
popup.show();
|
||||||
|
}catch (WindowManager.BadTokenException ignored){}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(((PeertubeActivity)getContext()).getFullscreen() == fullscreen.ON){
|
if(((PeertubeActivity)getContext()).getFullscreen() == fullscreen.ON){
|
||||||
|
|
Loading…
Reference in New Issue