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

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