issues #445, #435, #433, #427, #400 closed.

Issues #448, #447,#446 in progress
parent aad01231
...@@ -14,29 +14,28 @@ android { ...@@ -14,29 +14,28 @@ android {
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
signingConfig signingConfigs.release_config signingConfig signingConfigs.release_config
resValue "string", "db_name", "PCB.db"
resValue "string", "core_vocabulary", "core_vocabulary"
resValue "integer", "rows", "5"
resValue "integer", "columns", "10"
} }
buildTypes { buildTypes {
release { release {
minifyEnabled false minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
resValue "string", "server", "https://pre.yottacode.com" resValue "string", "server", "https://pre.yottacode.com"
resValue "string", "db_name", "PCB.db"
resValue "bool", "force_db_create", "false" resValue "bool", "force_db_create", "false"
resValue "bool", "ssl_connect", "false" resValue "bool", "ssl_connect", "false"
resValue "bool", "force_img_download", "false" resValue "bool", "force_img_download", "false"
resValue "integer", "netservice_timing", "20" resValue "integer", "netservice_timing", "20"
resValue "integer", "rows", "5"
resValue "integer", "columns", "10"
} }
debug { debug {
resValue "string", "server", "https://dev.yottacode.com"
resValue "string", "db_name", "PCB.db"
resValue "bool", "force_db_create", "false" resValue "bool", "force_db_create", "false"
resValue "bool", "ssl_connect", "false" resValue "bool", "ssl_connect", "false"
resValue "bool", "force_img_download", "false" resValue "bool", "force_img_download", "false"
resValue "integer", "netservice_timing", "20" resValue "integer", "netservice_timing", "20"
resValue "integer", "rows", "5"
resValue "integer", "columns", "10"
} }
} }
productFlavors { productFlavors {
......
...@@ -21,6 +21,7 @@ import java.io.OutputStream; ...@@ -21,6 +21,7 @@ import java.io.OutputStream;
import java.util.Vector; import java.util.Vector;
import com.yottacode.pictogram.R;
import com.yottacode.pictogram.gui.LoginActivity; import com.yottacode.pictogram.gui.LoginActivity;
import com.yottacode.pictogram.tools.Img; import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.net.ImgDownloader; import com.yottacode.pictogram.net.ImgDownloader;
...@@ -411,8 +412,8 @@ public class Device extends SQLiteOpenHelper { ...@@ -411,8 +412,8 @@ public class Device extends SQLiteOpenHelper {
public void onCreate(SQLiteDatabase db) throws RuntimeException { public void onCreate(SQLiteDatabase db) throws RuntimeException {
try { try {
executeSQLScript(db, DeviceHelper.getDBScriptStream(this.context)); executeSQLScript(db, DeviceHelper.getDBScriptStream(this.context));
copyCoreVocabulary();
Img.mkDirs(this.context); Img.mkDirs(this.context);
copyCoreVocabulary();
} catch (java.io.IOException io) { } catch (java.io.IOException io) {
throw new RuntimeException("Update database error", io); throw new RuntimeException("Update database error", io);
} }
...@@ -421,8 +422,10 @@ public class Device extends SQLiteOpenHelper { ...@@ -421,8 +422,10 @@ public class Device extends SQLiteOpenHelper {
private void copyCoreVocabulary() { private void copyCoreVocabulary() {
AssetManager assetManager = this.context.getAssets(); AssetManager assetManager = this.context.getAssets();
String[] files = null; String[] files = null;
int size=0;
int filesok=0;
try { try {
files = assetManager.list("core_vocabulary"); files = assetManager.list(context.getResources().getString(R.string.core_vocabulary));
} catch (IOException e) { } catch (IOException e) {
Log.e(this.getClass().getCanonicalName(), "Failed to get asset file list.", e); Log.e(this.getClass().getCanonicalName(), "Failed to get asset file list.", e);
} }
...@@ -430,39 +433,42 @@ public class Device extends SQLiteOpenHelper { ...@@ -430,39 +433,42 @@ public class Device extends SQLiteOpenHelper {
InputStream in = null; InputStream in = null;
OutputStream out = null; OutputStream out = null;
try { try {
in = assetManager.open("core_vocabulary/"+"java"+"/"+filename); in = assetManager.open(context.getResources().getString(R.string.core_vocabulary)+File.separatorChar+filename);
File outFile = new File(Img.path(this.context, Img.VOCABULARY)); File outFile = new File(Img.path(this.context, Img.VOCABULARY)+filename);
out = new FileOutputStream(outFile); out = new FileOutputStream(outFile);
copyFile(in, out); size+=copyFile(in, out);
} catch(IOException e) { } catch(IOException e) {
Log.e(this.getClass().getCanonicalName(), "Failed to copy asset file: " + filename, e); Log.e(this.getClass().getCanonicalName(), "Failed to copy asset image: " + context.getResources().getString(R.string.core_vocabulary)+File.separatorChar+filename, e);
} }
finally { finally {
if (in != null) { if (in != null) {
try { try {
in.close(); in.close();
Log.i(Device.class.getName(), "Core vocabulary copied ("+files.length+" pictos)");
} catch (IOException e) { } catch (IOException e) {
Log.e(this.getClass().getCanonicalName(), "Failed to copy asset file: " + filename, e); Log.e(this.getClass().getCanonicalName(), "Failed to copy asset image: " + filename, e);
} }
} }
if (out != null) { if (out != null) {
try { try {
out.close(); out.close();
filesok++;
} catch (IOException e) { } catch (IOException e) {
Log.e(this.getClass().getCanonicalName(), "Failed to copy asset file: " + filename, e); Log.e(this.getClass().getCanonicalName(), "Failed to copy asset file: " + filename, e);
} }
} }
} }
} }
Log.i(Device.class.getName(), "Core vocabulary Images installed ("+filesok+" pictos,"+(size/1024)+" KB)");
} }
private void copyFile(InputStream in, OutputStream out) throws IOException { private int copyFile(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[8192]; byte[] buffer = new byte[8192];
int read; int read;
int size=0;
while((read = in.read(buffer)) != -1){ while((read = in.read(buffer)) != -1){
out.write(buffer, 0, read); out.write(buffer, 0, read);
size+=read;
} }
return size;
} }
......
...@@ -66,7 +66,6 @@ public class ImgDownloader extends AsyncTask<Vector<Img>, Void, Img> { ...@@ -66,7 +66,6 @@ public class ImgDownloader extends AsyncTask<Vector<Img>, Void, Img> {
try { try {
for (Img img: imgs) { for (Img img: imgs) {
if (!img.exists_bitmap(this.context) || this.force_download) try { if (!img.exists_bitmap(this.context) || this.force_download) try {
this.activityManager.getMemoryInfo(mi); this.activityManager.getMemoryInfo(mi);
if (this.source==source.remote) { if (this.source==source.remote) {
......
...@@ -154,14 +154,20 @@ public class NetService implements Runnable { ...@@ -154,14 +154,20 @@ public class NetService implements Runnable {
PendingIntent resultPendingIntent = PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(resultPendingIntent); builder.setContentIntent(resultPendingIntent);
String user="";
if (PCBcontext.getPcbdb()!=null) {
user=PCBcontext.getPcbdb().getCurrentUser().get_name_stu();
if (PCBcontext.getPcbdb().getCurrentUser().is_supervisor())
user += " (" + PCBcontext.getPcbdb().getCurrentUser().get_name_sup() + ")";
}
if (updated) if (updated)
builder.setSmallIcon(R.drawable.application_online) builder.setSmallIcon(R.drawable.application_online)
.setContentTitle("Pictogram online") .setContentTitle(PCBcontext.getContext().getResources().getString(R.string.pictogram_online))
.setContentText(PCBcontext.getContext().getResources().getString(R.string.pictogram_online)+":"+PCBcontext.getContext().getResources().getString(R.string.server)); .setContentText(user);
else else
builder.setSmallIcon(R.drawable.application_offline) builder.setSmallIcon(R.drawable.application_offline)
.setContentTitle("Pictogram offline") .setContentTitle(PCBcontext.getContext().getResources().getString(R.string.pictogram_offline))
.setContentText(PCBcontext.getContext().getResources().getString(R.string.pictogram_offline)); .setContentText(user);
NotificationManager mNotificationManager = NotificationManager mNotificationManager =
(NotificationManager) PCBcontext.getContext().getSystemService(PCBcontext.getContext().NOTIFICATION_SERVICE); (NotificationManager) PCBcontext.getContext().getSystemService(PCBcontext.getContext().NOTIFICATION_SERVICE);
......
...@@ -54,6 +54,6 @@ ...@@ -54,6 +54,6 @@
<string name="enterImgLabel">Enter img label</string> <string name="enterImgLabel">Enter img label</string>
<string name="notNewCats">Including new categories is not allowed</string> <string name="notNewCats">Including new categories is not allowed</string>
<!--online/offline status--> <!--online/offline status-->
<string name="pictogram_offline">Please check your internet connection. </string> <string name="pictogram_offline">Pictogram offline</string>
<string name="pictogram_online">Server connection established. </string> <string name="pictogram_online">Pictogram online</string>
</resources> </resources>
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
<string name="enterImgLabel">Introduzca etiqueta de la imagen</string> <string name="enterImgLabel">Introduzca etiqueta de la imagen</string>
<string name="notNewCats">No puede añadir nuevas categorias</string> <string name="notNewCats">No puede añadir nuevas categorias</string>
<!--online/offline status--> <!--online/offline status-->
<string name="pictogram_offline">Compruebe si tiene conexión a Internet. </string> <string name="pictogram_offline">Pictogram offline</string>
<string name="pictogram_online">Conexón con el servidor establecida. </string> <string name="pictogram_online">Pictogram online</string>
</resources> </resources>
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