Fix some errors
This commit is contained in:
parent
75b6b9bb76
commit
c33ddd3952
|
@ -17,6 +17,7 @@ package fr.gouv.etalab.mastodon.activities;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
@ -27,13 +28,17 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.PopupMenu;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
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.view.WindowManager;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -258,9 +263,10 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
||||||
public void onPrepared(MediaPlayer mp) {
|
public void onPrepared(MediaPlayer mp) {
|
||||||
loader.setVisibility(View.GONE);
|
loader.setVisibility(View.GONE);
|
||||||
mediaPlayer = mp;
|
mediaPlayer = mp;
|
||||||
|
mp.start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
videoView.setZOrderOnTop(true);
|
|
||||||
videoView.start();
|
videoView.start();
|
||||||
|
|
||||||
peertube_download.setOnClickListener(new View.OnClickListener() {
|
peertube_download.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -358,14 +364,35 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
||||||
videoView.start();
|
videoView.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void changeVideoResolution(Peertube peertube, String resolution){
|
|
||||||
if( mediaPlayer != null) {
|
public void displayResolution(){
|
||||||
int position = videoView.getCurrentPosition();
|
|
||||||
mediaPlayer.stop();
|
AlertDialog.Builder builderSingle = new AlertDialog.Builder(PeertubeActivity.this);
|
||||||
videoView.setVideoURI(Uri.parse(peertube.getFileUrl(resolution)));
|
builderSingle.setTitle(R.string.pickup_resolution);
|
||||||
fullScreenMediaController.setResolutionVal(resolution + "p");
|
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(PeertubeActivity.this, android.R.layout.select_dialog_item);
|
||||||
videoView.seekTo(position);
|
for(String resolution: peertube.getResolution())
|
||||||
mediaPlayer.start();
|
arrayAdapter.add(resolution+"p");
|
||||||
}
|
builderSingle.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
String res = arrayAdapter.getItem(which).substring(0, arrayAdapter.getItem(which).length() - 1);
|
||||||
|
if( mediaPlayer != null) {
|
||||||
|
int position = videoView.getCurrentPosition();
|
||||||
|
mediaPlayer.stop();
|
||||||
|
videoView.setVideoURI(Uri.parse(peertube.getFileUrl(res)));
|
||||||
|
fullScreenMediaController.setResolutionVal(res);
|
||||||
|
videoView.seekTo(position);
|
||||||
|
videoView.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builderSingle.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,8 @@ package fr.gouv.etalab.mastodon.helper;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.support.v7.widget.PopupMenu;
|
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.Menu;
|
|
||||||
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;
|
||||||
|
@ -88,30 +84,14 @@ public class FullScreenMediaController extends MediaController {
|
||||||
paramsButton.gravity = Gravity.START;
|
paramsButton.gravity = Gravity.START;
|
||||||
paramsButton.rightMargin = 80;
|
paramsButton.rightMargin = 80;
|
||||||
paramsButton.topMargin = 22;
|
paramsButton.topMargin = 22;
|
||||||
addView(resolution, paramsButton);
|
|
||||||
resolution.setOnClickListener(new OnClickListener() {
|
resolution.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
PopupMenu popup = new PopupMenu(context, resolution);
|
((PeertubeActivity)getContext()).displayResolution();
|
||||||
int i = 0;
|
|
||||||
for(String res: peertube.getResolution()){
|
|
||||||
MenuItem item = popup.getMenu().add(0, i, Menu.NONE, res);
|
|
||||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
|
||||||
((PeertubeActivity)context).changeVideoResolution(peertube, res);
|
|
||||||
resolution.setText(String.format("%sp",res));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
popup.show();
|
|
||||||
}catch (WindowManager.BadTokenException ignored){}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
addView(resolution, paramsButton);
|
||||||
|
|
||||||
if(((PeertubeActivity)getContext()).getFullscreen() == fullscreen.ON){
|
if(((PeertubeActivity)getContext()).getFullscreen() == fullscreen.ON){
|
||||||
Resources resources = getResources();
|
Resources resources = getResources();
|
||||||
fullScreen.setImageDrawable(resources.getDrawable(R.drawable.ic_fullscreen_exit));
|
fullScreen.setImageDrawable(resources.getDrawable(R.drawable.ic_fullscreen_exit));
|
||||||
|
@ -130,7 +110,7 @@ public class FullScreenMediaController extends MediaController {
|
||||||
}else{
|
}else{
|
||||||
((PeertubeActivity)getContext()).setFullscreen(fullscreen.ON);
|
((PeertubeActivity)getContext()).setFullscreen(fullscreen.ON);
|
||||||
}
|
}
|
||||||
((PeertubeActivity)getContext()).change();
|
|
||||||
changeIcon();
|
changeIcon();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -138,6 +118,8 @@ public class FullScreenMediaController extends MediaController {
|
||||||
|
|
||||||
public void setResolutionVal(String resolutionVal){
|
public void setResolutionVal(String resolutionVal){
|
||||||
this.resolutionVal = resolutionVal;
|
this.resolutionVal = resolutionVal;
|
||||||
|
if( resolution != null)
|
||||||
|
resolution.setText(String.format("%sp",resolutionVal));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeIcon(){
|
private void changeIcon(){
|
||||||
|
|
|
@ -2057,9 +2057,9 @@ public class Helper {
|
||||||
|
|
||||||
public static String secondsToString(int pTime) {
|
public static String secondsToString(int pTime) {
|
||||||
|
|
||||||
int hour = pTime/3660;
|
int hour = pTime/3600;
|
||||||
int min = pTime/60;
|
int min = (pTime -(hour*3600))/60;
|
||||||
int sec = pTime-(min*60);
|
int sec = pTime -(hour*3600)-(min*60);
|
||||||
String strHour="0", strMin="0", strSec="0";
|
String strHour="0", strMin="0", strSec="0";
|
||||||
|
|
||||||
if( hour > 0 )
|
if( hour > 0 )
|
||||||
|
|
|
@ -641,6 +641,7 @@
|
||||||
<string name="duration_video">Duration: %s</string>
|
<string name="duration_video">Duration: %s</string>
|
||||||
<string name="add_remote_instance">Add an instance</string>
|
<string name="add_remote_instance">Add an instance</string>
|
||||||
<string name="comment_no_allowed_peertube">Comments are not enabled on this video!</string>
|
<string name="comment_no_allowed_peertube">Comments are not enabled on this video!</string>
|
||||||
|
<string name="pickup_resolution">Pick up a resolution</string>
|
||||||
|
|
||||||
<string-array name="filter_expire">
|
<string-array name="filter_expire">
|
||||||
<item>Never</item>
|
<item>Never</item>
|
||||||
|
|
Loading…
Reference in New Issue