Commit 2de63f63 by Jose Antonio

Merge remote-tracking branch 'origin/develop' into develop

parents f05be3a3 78c5a9dd
......@@ -16,6 +16,7 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
......@@ -51,6 +52,7 @@ import com.yottacode.tools.GUITools;
import org.json.JSONException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
......@@ -119,7 +121,7 @@ public class EditPictoActivity extends Activity {
private String dirAudioPath = null;
private MediaRecorder mRecorder = null;
private MediaPlayer mPlayer;
private MediaPlayer mPlayer = null;
BotonCircular botonGrabar;
BotonCircular botonReproducir;
......@@ -175,17 +177,15 @@ public class EditPictoActivity extends Activity {
protected void onCancelled(){
stopRecording();
botonReproducir.setEnabled(tiempoGrabado > 1 ? true : false);
botonReproducir.setEnabled(tiempoGrabado > 1);
layoutPreview.setVisibility(tiempoGrabado > 1 ? View.VISIBLE : View.GONE);
layoutGrabacion.setVisibility(tiempoGrabado > 1 ? View.GONE : View.VISIBLE);
textoTTotal.setText(tiempoGrabado == 10 ? "00:00 | 00:" + tiempoGrabado : "00:00 | 00:0" + tiempoGrabado );
tiempoTotal = tiempoGrabado-1;
barraReproducir.setMax(tiempoTotal);
botonGrabar.PhidePressedRing();
if(tiempoGrabado>1) hayGrabacion = true ;
else hayGrabacion = false;
reiniciarGrabacion();
hayGrabacion = (tiempoGrabado>=1 ? true : false); //Si lo grabado es al menos 1s => hay grabacion
if(hayGrabacion)
assignFileToPlayer(new File(previewAudioPath));
reiniciarGrabacion();
}
}
......@@ -217,7 +217,7 @@ public class EditPictoActivity extends Activity {
protected void onCancelled(){
stopPlaying();
assignFileToPlayer(editar ? (p.getUriSound() != null ? p.get_audioPath() : previewAudioPath) : null);
assignFileToPlayer(editar ? ((!borrado && p.get_audioFile()!=null) ? p.get_audioFile() : new File(previewAudioPath)) : null);
reiniciarReproducción();
}
}
......@@ -347,22 +347,15 @@ public class EditPictoActivity extends Activity {
legend.setText(p.get_translation());
supAsociado.setText(p.get_user_avatar()==null ? NO_SUP_TEXT : p.get_user_avatar());
//Si el picto viene con sonido
if(p.getUriSound() != null){
if(p.get_audioFile() != null){
borrado = false;
Log.i(DEBUG_MESSAGE,"Ruta: "+p.getUriSound() +"---Ruta2: "+p.get_audioPath());
Log.i(DEBUG_MESSAGE,"Picto CON sonido asociado");
layoutPreview.setVisibility(View.VISIBLE);
File file = new File(p.get_audioPath());
assignFileToPlayer(file.getPath());
tiempoTotal = mPlayer.getDuration();
hayGrabacion = true;
//tiempoTotal = mPlayer.getDuration();
layoutGrabacion.setVisibility(View.GONE);
layoutPreview.setVisibility(View.VISIBLE);
botonReproducir.setEnabled(true);
assignFileToPlayer(p.get_audioFile());
}else{
Log.i(DEBUG_MESSAGE,"Picto SIN sonido asociado");
layoutPreview.setVisibility(View.INVISIBLE);
layoutGrabacion.setVisibility(View.VISIBLE);
hayGrabacion = false;
......@@ -403,7 +396,6 @@ public class EditPictoActivity extends Activity {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String[] assocciated_person = mDrawerList.getAdapter().getItem(position).toString().split("\n");
supAsociado.setText(assocciated_person[1]);
Log.i("TAG_PRUEBS","Sup elegido: "+supAsociado.getText());
mDrawerLayout.closeDrawer(Gravity.RIGHT);
}
});
......@@ -460,12 +452,10 @@ public class EditPictoActivity extends Activity {
}
}
Intent intent = getIntent(); //Mandar a pictogram activity el path y el texto de la imagen
intent.putExtra(PictoMenu.IS_EDIT, editar); //Para saber despues si estas editando o añadiendo nuevo y coger los datos de intent o de data en OnActivityResult
intent.putExtra(PictoMenu.PATH, filepath); //Mandar Path imagen
intent.putExtra(PictoMenu.PATH_SOUND,borrado ? audioPath : p.get_audioPath()); //Mandar el path del audio
Log.e(LOG_TAG, "PATH SOUND:"+audioPath);
intent.putExtra(PictoMenu.PATH_SOUND,editar ? ((!borrado && p.getUriSound()!= null) ? p.get_audioPath() : audioPath) : audioPath); //Mandar el path del audio
intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, legend.getText().toString()); //Mandar expresion nueva
intent.putExtra(Picto.JSON_ATTTRS.CATEGORY, getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1));
intent.putExtra(Picto.JSON_ATTTRS.USER_AVATAR, supAsociado.getText());
......@@ -495,26 +485,23 @@ public class EditPictoActivity extends Activity {
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
recordSoundOn.play(MediaActionSound.SHUTTER_CLICK);
tareaGrabacion = (RecordTask) new RecordTask().execute(tiempoGrabado);
gifRecord.setBackgroundResource(R.drawable.record_animation);
try { //Para que no capture el sonido del sistema
sleep(600);
} catch (InterruptedException e) {
e.printStackTrace();
}
startRecording();
Log.i(DEBUG_MESSAGE,"Grabando..");
recordSoundOn.play(MediaActionSound.START_VIDEO_RECORDING);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
gifRecord.setBackgroundResource(R.drawable.record_animation);
tareaGrabacion = (RecordTask) new RecordTask().execute(tiempoGrabado);
startRecording();
}
}, 500); // 0.5s delay
return true;
case MotionEvent.ACTION_UP:
gifRecord.setBackgroundResource(R.color.white);
tareaGrabacion.cancel(true);
//mPlayer.setDataSource(previewAudioPath);
assignFileToPlayer(/*mPlayer,*/previewAudioPath);
gifRecord.setBackgroundResource(R.color.white);
recordSoundOff.play(MediaActionSound.FOCUS_COMPLETE);
return true;
}
return false;
......@@ -527,13 +514,11 @@ public class EditPictoActivity extends Activity {
if(reproduciendo){
tareaReproduccion.cancel(true);
reproduciendo = false;
Log.i(DEBUG_MESSAGE,"Parar");
botonReproducir.setImageResource(android.R.drawable.ic_media_play);
}else{
reproduciendo = true;
tareaReproduccion = (PlayTask) new PlayTask().execute(tiempoTotal);
startPlaying();
Log.i(DEBUG_MESSAGE,"Reproducir");
tareaReproduccion = (PlayTask) new PlayTask().execute(tiempoReproducir);
botonReproducir.setImageResource(android.R.drawable.ic_media_pause);
}
}
......@@ -544,18 +529,16 @@ public class EditPictoActivity extends Activity {
public void onClick(View v) {
borrado = true;
if(hayGrabacion){
mPlayer.release();
if(editar){
if(p.getUriSound() != null) {
Log.i(DEBUG_MESSAGE,"Eliminado->"+p.getUriSound());
p.setUriSound(null);
}
}
Log.i(DEBUG_MESSAGE,"Eliminado->"+previewAudioPath);
//stopPlaying();
layoutGrabacion.setVisibility(View.VISIBLE);
layoutPreview.setVisibility(View.GONE);
hayGrabacion = false;
}
File file = new File(previewAudioPath);
if(file.exists()){
file.delete();
}
/*previewAudioPath = null;*/
}
});
......@@ -613,39 +596,37 @@ public class EditPictoActivity extends Activity {
}
private void assignFileToPlayer(String pathReproducir){
private void assignFileToPlayer(File audio){
Log.i(DEBUG_MESSAGE,"Asignado: "+audio.getPath().toString());
mPlayer = new MediaPlayer();
try {
mPlayer.setDataSource(pathReproducir);
} catch (IOException e) {
e.printStackTrace();
}
}
private void startPlaying(/*MediaPlayer m*/) {
//m = new MediaPlayer();
try {
//mPlayer.setDataSource(pathReproducir);
mPlayer.setDataSource(new FileInputStream(audio).getFD());
mPlayer.prepare();
mPlayer.start();
tiempoTotal = Math.round(mPlayer.getDuration()/1000);
textoTTotal.setText("00:00 | 00:"+(tiempoTotal == 10 ? tiempoTotal : "0" + tiempoTotal));
barraReproducir.setMax(tiempoTotal);
Log.i(DEBUG_MESSAGE,"Assign.."+tiempoTotal);
} catch (IOException e) {
Log.e(DEBUG_MESSAGE, "prepare() failed");
e.printStackTrace();
} catch (IllegalStateException e){
Log.e(DEBUG_MESSAGE, "Illegal state exception on prepare()");
}
}
private void pausePlay(MediaPlayer m){
if(m.isPlaying()){
m.pause();
}else{
m.start();
private void startPlaying() {
Log.i(DEBUG_MESSAGE,"reproduciendo..."+previewAudioPath);
try {
mPlayer.start();
}catch (IllegalStateException e){
Log.e(DEBUG_MESSAGE, "Illegal state exception on start()");
}
}
private void stopPlaying(/*MediaPlayer m*/) {
private void stopPlaying() {
mPlayer.stop();
mPlayer.reset();
//mPlayer = null;
mPlayer.release();
mPlayer = null;
}
private void startRecording() {
......@@ -680,7 +661,6 @@ public class EditPictoActivity extends Activity {
private void reiniciarGrabacion(){
tiempoGrabado = 0;
textoTGrabacion.setText("00:00 | 00:10");
//hayGrabacion = false;
}
private void reiniciarReproducción(){
......@@ -689,23 +669,10 @@ public class EditPictoActivity extends Activity {
reproduciendo = false;
botonReproducir.setImageResource(android.R.drawable.ic_media_play);
textoTTotal.setText("00:00 | 00:"+(tiempoTotal == 10 ? tiempoTotal : "0" + tiempoTotal));
Log.i(DEBUG_MESSAGE,"Reinic.."+tiempoTotal);
barraReproducir.setMax(tiempoTotal);
}
/*@Override
public void onStop() {
super.onStop();
if (mRecorder != null) {
mRecorder.release();
mRecorder = null;
}
if (mPlayer!= null) {
mPlayer.release();
mPlayer = null;
}
}*/
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
......
/* global angular */
angular.module('dashboardConfig', []).constant('config', {
backend: 'https://' + window.location.host,
backend: 'http://' + window.location.host,
});
......@@ -14,11 +14,14 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
surname: '',
address: '',
country: '',
postalCode: '',
email: '',
phone: '',
gender: 'F',
lang: 'es',
office: ''
office: '',
password: '',
password_confirm: ''
};
// List of supervisors
......@@ -53,11 +56,14 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
surname: '',
address: '',
country: '',
postalCode: '',
email: '',
phone: '',
gender: 'F',
lang: 'es',
office: ''
office: '',
password: '',
password_confirm: ''
};
// Hide the form
......@@ -78,11 +84,14 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
name: supervisor.name,
surname: supervisor.surname,
address: supervisor.address,
postalCode: supervisor.address,
country: supervisor.country,
email: supervisor.email,
actualEmail: supervisor.email,
phone: supervisor.phone,
gender: supervisor.gender,
password: supervisor.password,
password_confirm: supervisor.password_confirm,
lang: supervisor.lang,
office: supervisor.office
};
......@@ -94,7 +103,7 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
// Checking new email
// If no change, it is deleted from supervisor object
if(supervisor.email == supervisor.actualEmail){
if (supervisor.email == supervisor.actualEmail){
delete supervisor.email;
delete supervisor.actualEmail;
}
......@@ -103,6 +112,14 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
var supid = supervisor.id;
delete supervisor.id;
if (supervisor.password != supervisor.password_confirm)
return;
if (supervisor.password.length == 0) {
delete supervisor.password;
delete supervisor.password_confirm;
}
$http
.put(config.backend + '/sup/' + supid, supervisor)
.success(function(data, status, headers, config) {
......@@ -122,6 +139,9 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
$scope.supervisors[i].gender = data.gender;
$scope.supervisors[i].lang = data.lang;
$scope.supervisors[i].office = data.office;
$scope.supervisors[i].postalCode = data.postalCode;
$scope.supervisors[i].password = '';
$scope.supervisors[i].password_confirm = '';
}
}
......@@ -142,7 +162,13 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
var supervisor = $scope.formdatasupervisor;
// Add password
supervisor.password = supervisor.name + supervisor.email;
if (supervisor.password != supervisor.password_confirm)
return;
if (supervisor.password.length == 0) {
delete supervisor.password;
delete supervisor.password_confirm;
}
$http
.post(config.backend+'/sup', supervisor)
......
......@@ -14,7 +14,11 @@
<input type="text" class="form-control" id="supervisor_address" placeholder="{{ 'address' | translate }}" ng-model="formdatasupervisor.address" />
</div>
<div class="form-group">
<div class="form-group">
<input type="text" class="form-control" id="supervisor_postal_code" placeholder="{{ 'postal_code' | translate }}" required ng-model="formdata.postal_code" ng-change="formdata.postal_code = formdata.postal_code.toUpperCase()"/>
</div>
<div class="form-group">
<label translate>country</label>
<select class="form-control" name="supervisor_country" id="supervisor_country" ng-model="formdatasupervisor.country" required>
<option value="ES" selected>España</option>
......@@ -39,7 +43,7 @@
</div>
<fieldset>
<legend translate>office</legend>
<label translate>office</label>
<div class="form-group">
<select class="form-control" name="supervisor_office" id="supervisor_office" ng-model="formdatasupervisor.office" required>
<option ng-repeat="of in offices | orderBy: 'name'" value="{{ of.id }}">
......@@ -50,7 +54,7 @@
</fieldset>
<fieldset>
<legend translate>language</legend>
<label translate>language</label>
<div class="form-group">
<select class="form-control" name="supervisor_language" id="supervisor_language" ng-model="formdatasupervisor.lang">
<option value="es" selected>Español</option>
......@@ -59,6 +63,17 @@
</div>
</fieldset>
<fieldset>
<label translate>password</label>
<span class="color_red text_sm pull-right" ng-show="formdata.password != formdata.password_confirm" translate>password_match</span>
<div class="form-group">
<input type="password" class="form-control" id="supervisor_password1" placeholder="{{ 'password_type' | translate }}" required ng-model="formdatasupervisor.password" />
</div>
<div class="form-group">
<input type="password" class="form-control" id="supervisor_password2" placeholder="{{ 'password_confirm' | translate }}" required ng-model="formdatasupervisor.password_confirm" />
</div>
</fieldset>
<div class="form-group">
<button type="button" class="btn btn-default" ng-click="resetForm()">{{'cancel'|translate}}</button>
<button type="submit" class="btn btn-primary" translate>add</button>
......
<h3 translate>update_supervisor</h3>
<form name="UpdateSupervisorForm" role="form" ng-submit="save_supervisor()">
<fieldset>
<div class="form-group">
......@@ -14,7 +14,11 @@
<input type="text" class="form-control" id="supervisor_address" placeholder="{{ 'address' | translate }}" ng-model="formdatasupervisor.address" />
</div>
<div class="form-group">
<div class="form-group">
<input type="text" class="form-control" id="supervisor_postal_code" placeholder="{{ 'postal_code' | translate }}" required ng-model="formdata.postalCode" ng-change="formdata.postalCode = formdata.postalCode.toUpperCase()"/>
</div>
<div class="form-group">
<input type="text" class="form-control" id="supervisor_country" placeholder="{{ 'country' | translate }}" ng-model="formdatasupervisor.country" />
</div>
......@@ -34,7 +38,7 @@
</div>
<fieldset>
<legend translate>office</legend>
<label translate>office</label>
<div class="form-group">
<select class="form-control" name="supervisor_office" id="supervisor_office" ng-model="formdatasupervisor.office">
<option ng-repeat="of in offices | orderBy: 'name'" value="{{ of.id }}">
......@@ -45,7 +49,7 @@
</fieldset>
<fieldset>
<legend translate>language</legend>
<label translate>language</label>
<div class="form-group">
<select class="form-control" name="supervisor_language" id="supervisor_language" ng-model="formdatasupervisor.lang">
<option value="es">Español</option>
......@@ -54,9 +58,20 @@
</div>
</fieldset>
<fieldset>
<label translate>password</label>
<span class="color_red text_sm pull-right" ng-show="formdata.password != formdata.password_confirm" translate>password_match</span>
<div class="form-group">
<input type="password" class="form-control" id="supervisor_password1" placeholder="{{ 'password_type' | translate }}" ng-model="formdatasupervisor.password" />
</div>
<div class="form-group">
<input type="password" class="form-control" id="supervisor_password2" placeholder="{{ 'password_confirm' | translate }}" ng-model="formdatasupervisor.password_confirm" />
</div>
</fieldset>
<div class="form-group">
<button type="button" class="btn btn-default" ng-click="resetForm()">{{'cancel'|translate}}</button>
<button type="submit" class="btn btn-primary" translate>save</button>
</div>
</fieldset>
</form>
\ No newline at end of file
</form>
......@@ -106,7 +106,7 @@
</div>
</div>
</div>
<fieldset>
</fieldset>
<fieldset>
<div class="form-group">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment