issue #958 closed

parent 10c0dae0
...@@ -399,24 +399,24 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -399,24 +399,24 @@ public class Vocabulary implements Iterable<Picto> {
/* /*
* It saves locally a new picto obtained from the PCB * It saves locally a new picto obtained from the PCB
*/ */
public Picto saveLocalPicto(String url, String exp, int cat, int coord_x, int coord_y, int free_category_coord_x, int free_category_coord_y, final iLocalPicto listener) { public void saveLocalPicto(String url, String exp, int cat, int coord_x, int coord_y, int free_category_coord_x, int free_category_coord_y, final iLocalPicto listener) {
Picto prev_picto=find_picto(cat, coord_x,coord_y); //¿estamos reemplazanddo un picto que ya existe? Picto prev_picto=find_picto(cat, coord_x,coord_y); //¿estamos reemplazanddo un picto que ya existe?
if (prev_picto!=null) { //El picto ya existe if (prev_picto!=null) { //El picto ya existe
removePicto(prev_picto.get_category(),prev_picto.get_id()); //borramos el picto local actual removePicto(prev_picto.get_category(),prev_picto.get_id()); //borramos el picto local actual
Log.i(LOG_TAG,"Picto "+exp+" already exists. Previous local picto "+prev_picto.get_id()+" is deleted."); Log.i(LOG_TAG,"Picto "+exp+" position is filled with "+prev_picto.get_translation()+"(id "+prev_picto.get_id()+"). Previous local picto "+prev_picto.get_id()+" is deleted.");
} }
int id=PCBcontext.getDevice().getNextLocalPictoID(); int id=PCBcontext.getDevice().getNextLocalPictoID();
final Picto picto[]=new Picto[1];
try { try {
picto[0] = new Picto(id, url, exp, cat, coord_x, coord_y, free_category_coord_x, free_category_coord_y, prev_picto!=null ? prev_picto.get_stupicto_id() : Picto.STUPICTO_NULL); final Picto picto = new Picto(id, url, exp, cat, coord_x, coord_y, free_category_coord_x, free_category_coord_y, prev_picto!=null ? prev_picto.get_stupicto_id() : Picto.STUPICTO_NULL);
addPicto(picto[0], ImgDownloader.tsource.local, new ImgDownloader.iImgDownloaderListener() { addPicto(picto, ImgDownloader.tsource.local, new ImgDownloader.iImgDownloaderListener() {
@Override @Override
public void loadComplete() { public void loadComplete() {
listener.saved(picto[0]); listener.saved(picto);
PCBcontext.getActionLog().log(new VocabularyAction(VocabularyAction.ADD, picto));
} }
@Override @Override
public void loadImg(Img image) { public void loadImg(Img image) {
...@@ -428,12 +428,10 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -428,12 +428,10 @@ public class Vocabulary implements Iterable<Picto> {
} }
}); });
} catch (Exception e) { } catch (Exception e) {
picto[0]=null;
e.printStackTrace(); e.printStackTrace();
Log.e(Vocabulary.class.getCanonicalName(), e.getMessage()); Log.e(Vocabulary.class.getCanonicalName(), e.getMessage());
} }
PCBcontext.getActionLog().log(new VocabularyAction(VocabularyAction.ADD, picto[0]));
return picto[0];
} }
/** /**
......
...@@ -174,7 +174,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin { ...@@ -174,7 +174,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
Log.e(LOG_TAG, "New version is required! from v" + DeviceHelper.getAppVersion(PCBcontext.getContext()) + " to v" + version); Log.e(LOG_TAG, "New version is required! from v" + DeviceHelper.getAppVersion(PCBcontext.getContext()) + " to v" + version);
newVersionAlert(PCBcontext.getActivityContext(), version); newVersionAlert(PCBcontext.getActivityContext(), version);
} }
} catch (JSONException e) { } catch (Exception e) {
Log.e(LOG_TAG, "PING JSON ERROR: " + result + " " + e.getMessage()); Log.e(LOG_TAG, "PING JSON ERROR: " + result + " " + e.getMessage());
} }
if (!updated) { if (!updated) {
......
...@@ -317,8 +317,7 @@ public class PictoUploader { ...@@ -317,8 +317,7 @@ 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.getVocabulary().removePicto(picto.get_category(), local_img_id); PCBcontext.getPcbdb().deletePicto(local_img_id);
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.getActivityContext(), R.string.upload_ok,PictoUploader.this.picto.get_translation()); GUITools.show_alert(PCBcontext.getActivityContext(), R.string.upload_ok,PictoUploader.this.picto.get_translation());
......
...@@ -134,6 +134,11 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -134,6 +134,11 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// blockNotificationBar(); // blockNotificationBar();
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
// after a long inactivity, the pcbdb is discarded
if (!PCBcontext.is_user_logged()) {
Log.i(LOG_TAG,"PCBDB was discarded. App restarting");
NetServiceTablet.restart_PictogramTablet(null,false);
}
setContentView(PCBcontext.getPcbdb().getCurrentUser().is_picto_size_big() ? R.layout.activity_pictogram_big : R.layout.activity_pictogram); setContentView(PCBcontext.getPcbdb().getCurrentUser().is_picto_size_big() ? R.layout.activity_pictogram_big : R.layout.activity_pictogram);
this.mainLayout = (RelativeLayout) findViewById(R.id.pictogramLayout); this.mainLayout = (RelativeLayout) findViewById(R.id.pictogramLayout);
......
package com.yottacode.pictogram.tabletlibrary.net; package com.yottacode.pictogram.tabletlibrary.net;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent; import android.content.Intent;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
import android.util.Log; import android.util.Log;
import com.yottacode.pictogram.dao.User; import com.yottacode.pictogram.dao.User;
...@@ -22,6 +20,7 @@ import com.yottacode.pictogram.tools.PCBcontext; ...@@ -22,6 +20,7 @@ import com.yottacode.pictogram.tools.PCBcontext;
public class NetServiceTablet implements NetService.iNetServiceDevice { public class NetServiceTablet implements NetService.iNetServiceDevice {
private static final String LOG_TAG = NetServiceTablet.class.getName();
private static NotificationCompat.Builder builder; private static NotificationCompat.Builder builder;
private PictogramActivity pictogramActivity; private PictogramActivity pictogramActivity;
int notifyID = 666; int notifyID = 666;
...@@ -72,14 +71,18 @@ public class NetServiceTablet implements NetService.iNetServiceDevice { ...@@ -72,14 +71,18 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
* offline * offline
*/ */
public void restart_app(Intent serialActivity, boolean direct_login) { public void restart_app(Intent serialActivity, boolean direct_login) {
NetServiceTablet.restart_PictogramTablet(serialActivity,direct_login);
}
public static void restart_PictogramTablet(Intent serialActivity, boolean direct_login) {
Log.i(this.getClass().getCanonicalName(),"App restarting"); Log.i(LOG_TAG,"App restarting");
if (serialActivity==null) { if (serialActivity==null) {
Class serialClass; Class serialClass;
try { try {
serialClass=Class.forName(PCBcontext.getContext().getString(R.string.SerialClass)); serialClass=Class.forName(PCBcontext.getContext().getString(R.string.SerialClass));
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
Log.e(this.getClass().getCanonicalName(),"S:"+PCBcontext.getContext().getString(R.string.SerialClass)); Log.e(LOG_TAG,"S:"+PCBcontext.getContext().getString(R.string.SerialClass));
serialClass=SerialActivity.class; serialClass=SerialActivity.class;
} }
serialActivity = new Intent(PCBcontext.getContext(), serialClass); serialActivity = new Intent(PCBcontext.getContext(), serialClass);
......
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