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