rescaling local images only (images from server are no longer rescaled)

some bugs fixed
parent cde7a3cb
......@@ -31,7 +31,7 @@ android {
debug {
resValue "string", "db_name", "PCB.db"
resValue "bool", "force_db_create", "true"
resValue "bool", "force_db_create", "false"
resValue "bool", "ssl_connect", "false"
resValue "bool", "force_img_download", "false"
resValue "integer", "netservice_timing", "20"
......
......@@ -71,7 +71,11 @@ public class Picto extends Img {
}
/**
*
* @return true if it's a local pictogram
*/
public boolean is_local() {return this.get_id()<0;}
/**
*
* @return de id of the picto
......@@ -253,7 +257,7 @@ public class Picto extends Img {
int color = this.get_color();
int red = Color.red(color)+LIGHT, blue = Color.blue(color)+LIGHT, green = Color.green(color)+LIGHT;
return Color.rgb(red,green,blue);
return Color.rgb(red, green, blue);
}
/**
......@@ -325,12 +329,14 @@ public class Picto extends Img {
try {
this.attributes.put(JSON_ATTTRS.STATUS, status);
set_local_status(true);
new PictoUploader(this).uploadState();
if (!is_local()) {
new PictoUploader(this).uploadState();
PCBcontext.getActionLog().log(new VocabularyAction(VocabularyAction.ALTERATTRS, this));
}
} catch (JSONException e) {
e.printStackTrace();
Log.e(this.getClass().getCanonicalName(),e.getMessage());
}
PCBcontext.getActionLog().log(new VocabularyAction(VocabularyAction.ALTERATTRS,this));
return is_enabled();
}
......
......@@ -321,6 +321,7 @@ public class Vocabulary implements Iterable<Picto> {
public boolean isVisibleCategory(int id) {
if (empty_category(id)) return false;
if (PCBcontext.getPcbdb().getCurrentUser().is_supervisor()) return true;
boolean visible=false;
for (Picto picto : this.pictos.get(id)) {
......
......@@ -69,7 +69,6 @@ public class ImgDownloader extends AsyncTask<Vector<Img>, Void, Img> {
if (!img.exists_bitmap(this.context) || this.force_download) try {
this.activityManager.getMemoryInfo(mi);
Log.i(this.getClass().getCanonicalName(), "Picto Img "+img.get_url() + " to be downloaded");
if (this.source==source.remote) {
String surl = context.getResources().getString(R.string.server) + "/" + img.get_url();
URL url = new URL(surl);
......@@ -79,7 +78,7 @@ public class ImgDownloader extends AsyncTask<Vector<Img>, Void, Img> {
File file=new File(img.get_url());
is=new FileInputStream(file);
}
int size=img.save_bitmap(this.context, is);
int size=img.save_bitmap(this.context, is,this.source==source.local);
allsize+=size;
i++;
} catch (IOException e) {
......
......@@ -124,12 +124,13 @@ public class Img {
* @param is the stream where the image is available
* @throws IOException
*/
public int save_bitmap(Context context, InputStream is) throws IOException {
public int save_bitmap(Context context, InputStream is,boolean resize) throws IOException {
File file = file(context);
FileOutputStream os = new FileOutputStream(file);
try {
this.bitmap = new ImgTools(BitmapFactory.decodeStream(is)).resize(78,66);
this.bitmap=BitmapFactory.decodeStream(is);
if (resize) this.bitmap=new ImgTools(this.bitmap).resize(78,66);
}catch(java.lang.OutOfMemoryError err) {
Log.e(Img.class.getCanonicalName(), "Out of memory when decoding "+this.get_url());
}
......
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