Commit a1506b4d by Arturo Montejo Ráez

fixed conflict

parents 09eaef18 8e42e6cd
...@@ -215,7 +215,6 @@ public class RestapiWrapper { ...@@ -215,7 +215,6 @@ public class RestapiWrapper {
} }
} }
Log.e(this.getClass().getCanonicalName(),"POST-->"+surl+" "+request_method+" j"+json_params+" param"+sparams);
//Send request //Send request
DataOutputStream wr = new DataOutputStream ( DataOutputStream wr = new DataOutputStream (
urlConnection.getOutputStream ()); urlConnection.getOutputStream ());
......
...@@ -2,9 +2,8 @@ package com.yottacode.pictogram.action; ...@@ -2,9 +2,8 @@ package com.yottacode.pictogram.action;
import android.util.Log; import android.util.Log;
import com.yottacode.pictogram.net.websockets.Room;
import com.yottacode.pictogram.dao.Picto; import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.net.websockets.Room;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -50,9 +49,7 @@ public abstract class PictoAction extends Action { ...@@ -50,9 +49,7 @@ public abstract class PictoAction extends Action {
public JSONObject get_json_picto() throws JSONException { public JSONObject get_json_picto() throws JSONException {
final String param_id_json="id"; final String param_id_json="id";
final String param_picto="picto"; final String param_picto="picto";
final String param_expression="expression";
final String param_expr_lang="lang";
final String param_expr_text="text";
final String param_attrs="attributes"; final String param_attrs="attributes";
final String param_picto_id="id"; final String param_picto_id="id";
final String param_picto_uri="uri"; final String param_picto_uri="uri";
...@@ -61,11 +58,8 @@ public abstract class PictoAction extends Action { ...@@ -61,11 +58,8 @@ public abstract class PictoAction extends Action {
.put(param_picto_uri, picto.get_url()) .put(param_picto_uri, picto.get_url())
.put(param_picto_cat, picto.get_category()); .put(param_picto_cat, picto.get_category());
JSONObject attributes = new JSONObject(picto.get_json_attrs()); JSONObject attributes = new JSONObject(picto.get_json_attrs());
JSONObject expression = new JSONObject().put(param_expr_lang,PCBcontext.getPcbdb().getCurrentUser().get_lang_stu())
.put(param_expr_text,picto.get_translation());
JSONObject subPicto = new JSONObject().put(param_id_json, 1470) JSONObject subPicto = new JSONObject().put(param_id_json, 1470)
.put(param_picto, subsubPicto) .put(param_picto, subsubPicto)
.put(param_expression,expression)
.put(param_attrs, attributes); .put(param_attrs, attributes);
return subPicto; return subPicto;
} }
......
...@@ -227,7 +227,6 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -227,7 +227,6 @@ public class PCBDBHelper extends SQLiteOpenHelper {
* @see com.yottacode.pictogram.dao.Picto * @see com.yottacode.pictogram.dao.Picto
*/ */
public void deletePicto(int picto_id) { public void deletePicto(int picto_id) {
int id_stu = this.getCurrentUser().get_id_stu();
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
db.delete("collection","id_stu=? AND id_picto=?", db.delete("collection","id_stu=? AND id_picto=?",
......
...@@ -70,8 +70,7 @@ public class Picto extends Img { ...@@ -70,8 +70,7 @@ public class Picto extends Img {
private JSONObject attributes; private JSONObject attributes;
private String translation; private boolean is_mirror=false;
private boolean is_mirror=false;
private boolean highlight_background=false; private boolean highlight_background=false;
public boolean is_mirror() {return is_mirror;} public boolean is_mirror() {return is_mirror;}
...@@ -88,10 +87,9 @@ public class Picto extends Img { ...@@ -88,10 +87,9 @@ public class Picto extends Img {
} catch (JSONException e) { } catch (JSONException e) {
Log.e(LOG_TAG,e.getMessage()); Log.e(LOG_TAG,e.getMessage());
} }
translation=new String(p.get_translation());
} }
public Picto(int id, String url, String translation, int cat, int row, int column, int freeRow, int freeColumn, int stupicto_id) throws JSONException { public Picto(int id, String url, String translation, int cat, int row, int column, int freeRow, int freeColumn, int stupicto_id) throws JSONException {
this(id, url, translation, new JSONObject() this(id, url, new JSONObject()
.put(JSON_ATTTRS.CATEGORY, cat) .put(JSON_ATTTRS.CATEGORY, cat)
.put(JSON_ATTTRS.COLUMN, column) .put(JSON_ATTTRS.COLUMN, column)
.put(JSON_ATTTRS.ROW, row) .put(JSON_ATTTRS.ROW, row)
...@@ -99,16 +97,16 @@ public class Picto extends Img { ...@@ -99,16 +97,16 @@ public class Picto extends Img {
.put(JSON_ATTTRS.FREE_COLUMN, freeColumn) .put(JSON_ATTTRS.FREE_COLUMN, freeColumn)
.put(JSON_ATTTRS.STATUS, JSON_ATTTR_STATUS_VALUES.ENABLED) .put(JSON_ATTTRS.STATUS, JSON_ATTTR_STATUS_VALUES.ENABLED)
.put(JSON_ATTTRS.LEGEND,JSON_ATTTR_LEGEND_VALUES.NONE) .put(JSON_ATTTRS.LEGEND,JSON_ATTTR_LEGEND_VALUES.NONE)
.put(JSON_ATTTRS.STUPICTO_ID,stupicto_id)); .put(JSON_ATTTRS.STUPICTO_ID,stupicto_id)
.put(JSON_ATTTRS.EXPRESSION,translation));
} }
public Picto(int id, String url,String translation, String attributes) throws JSONException { public Picto(int id, String url,String translation, String attributes) throws JSONException {
this(id, url, translation, new JSONObject(attributes)); this(id, url, new JSONObject(attributes).put(JSON_ATTTRS.EXPRESSION,translation));
} }
public Picto(int id, String url,String translation, JSONObject attributes) { public Picto(int id, String url, JSONObject attributes) {
super(id,url,Img.VOCABULARY); super(id,url,Img.VOCABULARY);;
this.translation=translation;
this.attributes = attributes; this.attributes = attributes;
try { try {
if (this.attributes.get(JSON_ATTTRS.CATEGORY)==null) if (this.attributes.get(JSON_ATTTRS.CATEGORY)==null)
...@@ -131,18 +129,6 @@ public class Picto extends Img { ...@@ -131,18 +129,6 @@ public class Picto extends Img {
*/ */
public String get_url() {return this.url;} public String get_url() {return this.url;}
/**
*
* @param newTranslation
*/
public void set_translation(String newTranslation){
this.translation = newTranslation;
try {
this.attributes.put(JSON_ATTTRS.EXPRESSION,newTranslation);
} catch (JSONException e) {
e.printStackTrace();
}
}
/** /**
* *
...@@ -154,10 +140,10 @@ public class Picto extends Img { ...@@ -154,10 +140,10 @@ public class Picto extends Img {
translation=this.attributes.has(JSON_ATTTRS.EXPRESSION) && translation=this.attributes.has(JSON_ATTTRS.EXPRESSION) &&
this.attributes.getString(JSON_ATTTRS.EXPRESSION)!=null && !this.attributes.getString(JSON_ATTTRS.EXPRESSION).equals("null") this.attributes.getString(JSON_ATTTRS.EXPRESSION)!=null && !this.attributes.getString(JSON_ATTTRS.EXPRESSION).equals("null")
? this.attributes.getString(JSON_ATTTRS.EXPRESSION) ? this.attributes.getString(JSON_ATTTRS.EXPRESSION)
: this.translation; : "";
} catch (JSONException e) { } catch (JSONException e) {
translation=this.translation; translation="";
} }
return translation; return translation;
} }
......
...@@ -91,8 +91,14 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -91,8 +91,14 @@ public class Vocabulary implements Iterable<Picto> {
String uri=args.getJSONObject("picto").getString("uri"); String uri=args.getJSONObject("picto").getString("uri");
JSONObject attrs_picto = args.getJSONObject("attributes"); JSONObject attrs_picto = args.getJSONObject("attributes");
attrs_picto.put(Picto.JSON_ATTTRS.STUPICTO_ID,args.getInt("id")); attrs_picto.put(Picto.JSON_ATTTRS.STUPICTO_ID,args.getInt("id"));
String text= attrs_picto.getString("expression"); Picto newPicto=new Picto(picto_id, uri, attrs_picto);
addPicto(new Picto(picto_id, uri, text, attrs_picto),ImgDownloader.tsource.remote); Picto prev_picto=find_picto(newPicto.get_category(), newPicto.get_row(),newPicto.get_column());
if (prev_picto!=null) {
Log.i(LOG_TAG, "Pictogram "+prev_picto.get_translation()+":"+prev_picto.get_id()+" to be replaced by "+newPicto.get_translation()+":"+newPicto.get_id());
removePicto(prev_picto.get_category(), prev_picto.get_id());
}
if (find_picto_index(newPicto.get_category(),newPicto.get_id())==-1) addPicto(newPicto,ImgDownloader.tsource.remote);
} catch (JSONException e) { } catch (JSONException e) {
Log.e(this.getClass().getCanonicalName(), e.getClass().getCanonicalName() + "--" + e); Log.e(this.getClass().getCanonicalName(), e.getClass().getCanonicalName() + "--" + e);
...@@ -171,12 +177,10 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -171,12 +177,10 @@ public class Vocabulary implements Iterable<Picto> {
final String jid = "id"; final String jid = "id";
final String juri = "uri"; final String juri = "uri";
final String jattributes = "attributes"; final String jattributes = "attributes";
final String jexpression = "expression";
Picto[] pictos = new Picto[result.length()]; Picto[] pictos = new Picto[result.length()];
JSONObject picto, attributes ; JSONObject picto, attributes ;
String expression;
JSONObject stupicto=null; JSONObject stupicto=null;
try { try {
for (int i=0; i < result.length(); i++) { for (int i=0; i < result.length(); i++) {
...@@ -184,10 +188,8 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -184,10 +188,8 @@ public class Vocabulary implements Iterable<Picto> {
picto = stupicto.getJSONObject(jpicto); picto = stupicto.getJSONObject(jpicto);
attributes = stupicto.getJSONObject(jattributes); attributes = stupicto.getJSONObject(jattributes);
attributes.put(Picto.JSON_ATTTRS.STUPICTO_ID,stupicto.get(jid)); attributes.put(Picto.JSON_ATTTRS.STUPICTO_ID,stupicto.get(jid));
expression = attributes.getString(jexpression);
pictos[i] = new Picto(picto.getInt(jid), pictos[i] = new Picto(picto.getInt(jid),
picto.getString(juri), picto.getString(juri),
expression,
attributes); attributes);
} }
synchronizeImgs(pictos); synchronizeImgs(pictos);
......
...@@ -317,11 +317,11 @@ public class PictoUploader { ...@@ -317,11 +317,11 @@ public class PictoUploader {
GUITools.show_alert(PCBcontext.getActivityContext(), errmsg, PictoUploader.this.picto.get_translation()); GUITools.show_alert(PCBcontext.getActivityContext(), errmsg, PictoUploader.this.picto.get_translation());
} }
if (elements_uploaded == elements_to_be_uploaded) { if (elements_uploaded == elements_to_be_uploaded) {
PCBcontext.getPcbdb().deletePicto(local_img_id); PCBcontext.getVocabulary().removePicto(picto.get_category(), local_img_id);
PictoUploader.this.picto.delete_bitmap(PCBcontext.getContext()); PictoUploader.this.picto.delete_bitmap(PCBcontext.getContext());
PCBcontext.getVocabulary().addPicto(picto); PCBcontext.getVocabulary().addPicto(picto);
PCBcontext.getRoom().emit(new VocabularyAction(VocabularyAction.ADD, PictoUploader.this.picto)); PCBcontext.getRoom().emit(new VocabularyAction(VocabularyAction.ADD, PictoUploader.this.picto));
GUITools.show_alert(PCBcontext.getContext(), R.string.upload_ok,PictoUploader.this.picto.get_translation()); GUITools.show_alert(PCBcontext.getActivityContext(), R.string.upload_ok,PictoUploader.this.picto.get_translation());
} }
} }
}; };
......
...@@ -69,6 +69,7 @@ import java.io.ByteArrayOutputStream; ...@@ -69,6 +69,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
...@@ -505,8 +506,9 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -505,8 +506,9 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
// This is to show the pictos ordered in the 2D Array that represents the panel // This is to show the pictos ordered in the 2D Array that represents the panel
Picto[][] mp = new Picto[maxRows][maxColumns]; Picto[][] mp = new Picto[maxRows][maxColumns];
Iterator<Picto> pictos=list.iterator();
for (Picto p : list) { while (pictos.hasNext()) {
Picto p= pictos.next();
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) { if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) {
if (p.get_column() != -1 && p.get_row() != -1 if (p.get_column() != -1 && p.get_row() != -1
&& p.get_column() < maxRows && p.get_row() < maxColumns) { && p.get_column() < maxRows && p.get_row() < maxColumns) {
......
...@@ -4,7 +4,7 @@ var dashboardDirectives = angular.module('dashboardDirectives', ['dashboardConfi ...@@ -4,7 +4,7 @@ var dashboardDirectives = angular.module('dashboardDirectives', ['dashboardConfi
/*------------------------------------------------------------------------------- /*-------------------------------------------------------------------------------
Pictogram follows a Hierarchical MVC pattern (the old PAC pattern) Pictogram follows a Hierarchical MVC pattern (the old PAC pattern)
We have a main controller (see main.js) and then others that are associated to We have a main controller (see main.js) and then others that are associated to
different headers (by means of AngularJS directives) different headers (by means of AngularJS directives)
Here we are just defining those directives Here we are just defining those directives
*/ */
...@@ -70,9 +70,9 @@ dashboardDirectives.directive('draggable', function() { ...@@ -70,9 +70,9 @@ dashboardDirectives.directive('draggable', function() {
return function(scope, element) { return function(scope, element) {
// this gives us the native JS object // this gives us the native JS object
var el = element[0]; var el = element[0];
el.draggable = true; el.draggable = true;
el.addEventListener( el.addEventListener(
'dragstart', 'dragstart',
function(e) { function(e) {
...@@ -83,7 +83,7 @@ dashboardDirectives.directive('draggable', function() { ...@@ -83,7 +83,7 @@ dashboardDirectives.directive('draggable', function() {
}, },
false false
); );
el.addEventListener( el.addEventListener(
'dragend', 'dragend',
function(e) { function(e) {
...@@ -104,7 +104,7 @@ dashboardDirectives.directive('droppable', function() { ...@@ -104,7 +104,7 @@ dashboardDirectives.directive('droppable', function() {
link: function(scope, element) { link: function(scope, element) {
// again we need the native object // again we need the native object
var el = element[0]; var el = element[0];
el.addEventListener( el.addEventListener(
'dragover', 'dragover',
function(e) { function(e) {
...@@ -116,7 +116,7 @@ dashboardDirectives.directive('droppable', function() { ...@@ -116,7 +116,7 @@ dashboardDirectives.directive('droppable', function() {
}, },
false false
); );
el.addEventListener( el.addEventListener(
'dragenter', 'dragenter',
function(e) { function(e) {
...@@ -125,7 +125,7 @@ dashboardDirectives.directive('droppable', function() { ...@@ -125,7 +125,7 @@ dashboardDirectives.directive('droppable', function() {
}, },
false false
); );
el.addEventListener( el.addEventListener(
'dragleave', 'dragleave',
function(e) { function(e) {
...@@ -134,20 +134,20 @@ dashboardDirectives.directive('droppable', function() { ...@@ -134,20 +134,20 @@ dashboardDirectives.directive('droppable', function() {
}, },
false false
); );
el.addEventListener( el.addEventListener(
'drop', 'drop',
function(e) { function(e) {
e.preventDefault(); // Added to avoid openning the picto image e.preventDefault(); // Added to avoid openning the picto image
// Stops some browsers from redirecting. // Stops some browsers from redirecting.
if (e.stopPropagation) e.stopPropagation(); if (e.stopPropagation) e.stopPropagation();
this.classList.remove('over'); this.classList.remove('over');
var destination = this.id; var destination = this.id;
var origin = e.dataTransfer.getData('Text'); var origin = e.dataTransfer.getData('Text');
// ERASE this 2 lines and move in other directive // ERASE this 2 lines and move in other directive
// One for drop in general view and other to drop in add pictos view // One for drop in general view and other to drop in add pictos view
//var item = document.getElementById(origin); //var item = document.getElementById(origin);
//this.appendChild(item); //this.appendChild(item);
...@@ -155,11 +155,11 @@ dashboardDirectives.directive('droppable', function() { ...@@ -155,11 +155,11 @@ dashboardDirectives.directive('droppable', function() {
// call the passed drop function // call the passed drop function
scope.$apply(function(scope) { scope.$apply(function(scope) {
var fn = scope.drop(); var fn = scope.drop();
if ('undefined' !== typeof fn) { if ('undefined' !== typeof fn) {
fn(origin, destination); fn(origin, destination);
} }
}); });
return false; return false;
}, },
false false
...@@ -178,7 +178,7 @@ dashboardDirectives.directive('droppableadd', function() { ...@@ -178,7 +178,7 @@ dashboardDirectives.directive('droppableadd', function() {
link: function(scope, element) { link: function(scope, element) {
// again we need the native object // again we need the native object
var el = element[0]; var el = element[0];
el.addEventListener( el.addEventListener(
'dragover', 'dragover',
function(e) { function(e) {
...@@ -190,7 +190,7 @@ dashboardDirectives.directive('droppableadd', function() { ...@@ -190,7 +190,7 @@ dashboardDirectives.directive('droppableadd', function() {
}, },
false false
); );
el.addEventListener( el.addEventListener(
'dragenter', 'dragenter',
function(e) { function(e) {
...@@ -199,7 +199,7 @@ dashboardDirectives.directive('droppableadd', function() { ...@@ -199,7 +199,7 @@ dashboardDirectives.directive('droppableadd', function() {
}, },
false false
); );
el.addEventListener( el.addEventListener(
'dragleave', 'dragleave',
function(e) { function(e) {
...@@ -208,31 +208,46 @@ dashboardDirectives.directive('droppableadd', function() { ...@@ -208,31 +208,46 @@ dashboardDirectives.directive('droppableadd', function() {
}, },
false false
); );
el.addEventListener( el.addEventListener(
'drop', 'drop',
function(e) { function(e) {
e.preventDefault(); // Added to avoid openning the picto image e.preventDefault(); // Added to avoid openning the picto image
// Stops some browsers from redirecting. // Stops some browsers from redirecting.
if (e.stopPropagation) e.stopPropagation(); if (e.stopPropagation) e.stopPropagation();
this.classList.remove('over'); this.classList.remove('over');
var destination = this.id; var destination = this.id;
var origin = e.dataTransfer.getData('Text'); var origin = e.dataTransfer.getData('Text');
// call the passed drop function // call the passed drop function
scope.$apply(function(scope) { scope.$apply(function(scope) {
var fn = scope.drop(); var fn = scope.drop();
if ('undefined' !== typeof fn) { if ('undefined' !== typeof fn) {
fn(origin, destination); fn(origin, destination);
} }
}); });
return false; return false;
}, },
false false
); );
} }
} }
}); });
\ No newline at end of file dashboardDirectives.directive('popoveraddpicto', function() {
var y=99999;
return {
restrict: 'A',
link: function (scope, element, attrs) {
if(element[0].y <= y){
y=element[0].y;
attrs.popoverPlacement="bottom";
}
console.log(element[0].y);
console.log(angular.element( document.querySelector( '#collections' ) ));
}
}
});
...@@ -316,9 +316,16 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -316,9 +316,16 @@ dashboardControllers.controller('AddPictoCtrl', function (
$scope.search = function() { $scope.search = function() {
$scope.page=1; // Reset pagination $scope.page=1; // Reset pagination
var length = $scope.srch_term_picto == undefined ? 0 : $scope.srch_term_picto.length; var length = $scope.srch_term_picto == undefined ? 0 : $scope.srch_term_picto.length;
if(length <2){ //Check the word length if(length == 1){ //Check the word length
$scope.alert = { type: 'warning', msg: 'warning_two_characters', show: true }; $scope.alert = { type: 'warning', msg: 'warning_two_characters', show: true };
}else if(length == 0){ // If there is no word, reset pictos
if ($scope.onlyOwn || $scope.source == "ownpictos"){
$scope.load_own_pictos();
}else{
$scope.open_category_from_bc(0);
}
}else{ }else{
var request = ""; var request = "";
var source = 1; var source = 1;
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<hr> <hr>
<!-- Bread and categories --> <!-- Bread and categories -->
<div id="bread_and_categories" ng-show="source == 'symbolstx'" class="panel panel-default" style="z-index:1000"> <div id="bread_and_categories" ng-show="source == 'symbolstx'" class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<div class="pull-left" ng-repeat="b in breadcrumbs"> <div class="pull-left" ng-repeat="b in breadcrumbs">
<a ng-click="open_category_from_bc(b.id)"> <a ng-click="open_category_from_bc(b.id)">
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
<div id="clearfix-infiniteScroll-parent" infinite-scroll="scroll()" infinite-scroll-container="'#collections'"> <div id="clearfix-infiniteScroll-parent" infinite-scroll="scroll()" infinite-scroll-container="'#collections'">
<div class="picto_peq pull-left" ng-repeat="p in pictos" > <div class="picto_peq pull-left" ng-repeat="p in pictos" >
<img ng-src="{{p.uri}}" popover="{{p.expressions[0].text}}" popover-trigger="mouseenter"/> <img ng-src="{{p.uri}}" popover="{{p.expressions[0].text}}" popover-trigger="mouseenter" popover-placement="top" style="z-index:9000" popoveraddpicto/>
<!-- Options to remove picto (Only for own pictos) --> <!-- Options to remove picto (Only for own pictos) -->
<div class="picto_options"> <div class="picto_options">
<a ng-click="remove_own_picto(p.id)" class="picto_remove" title="{{ 'delete' | translate }}" ng-show="source == 'ownpictos'"> <a ng-click="remove_own_picto(p.id)" class="picto_remove" title="{{ 'delete' | translate }}" ng-show="source == 'ownpictos'">
......
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