Android Watch support, project app module refactorized to tablet+commonlibrary+watch modules

parent 07119460
Showing with 103 additions and 833 deletions
...@@ -4,3 +4,51 @@ ...@@ -4,3 +4,51 @@
/.idea/libraries /.idea/libraries
.DS_Store .DS_Store
/build /build
app-DefaultFlavor-release.apk
build - copia.gradle
common.iml
src/fernandoFlavor/
src/main/assets/core_vocabulary/12303.png
src/main/assets/core_vocabulary/12499.png
src/main/assets/core_vocabulary/12504.png
src/main/assets/core_vocabulary/49287.png
src/main/assets/core_vocabulary/49654.png
src/main/assets/core_vocabulary/49673.png
src/main/assets/core_vocabulary/49786.png
src/main/assets/core_vocabulary/49789.png
src/main/assets/core_vocabulary/49835.png
src/main/assets/core_vocabulary/49839.png
src/main/assets/core_vocabulary/50070.png
src/main/assets/core_vocabulary/50259.png
src/main/assets/core_vocabulary/50266.png
src/main/assets/core_vocabulary/50343.png
src/main/assets/core_vocabulary/50388.png
src/main/assets/core_vocabulary/50391.png
src/main/assets/core_vocabulary/50694.png
src/main/assets/core_vocabulary/50956.png
src/main/assets/core_vocabulary/51151.png
src/main/assets/core_vocabulary/51174.png
src/main/assets/core_vocabulary/51192.png
src/main/assets/core_vocabulary/51295.png
src/main/assets/core_vocabulary/51336.png
src/main/assets/core_vocabulary/51518.png
src/main/assets/core_vocabulary/51522.png
src/main/assets/core_vocabulary/51558.png
src/main/assets/core_vocabulary/51605.png
src/main/assets/core_vocabulary/52212.png
src/main/assets/core_vocabulary/52670.png
src/main/assets/core_vocabulary/52736.png
src/main/assets/core_vocabulary/52751.png
src/main/assets/core_vocabulary/52758.png
src/main/assets/core_vocabulary/52781.png
src/main/assets/core_vocabulary/52800.png
src/main/assets/core_vocabulary/53077.png
src/main/assets/core_vocabulary/53111.png
src/main/assets/core_vocabulary/54220.png
src/main/assets/core_vocabulary/54270.png
src/main/assets/core_vocabulary/55704.png
src/main/assets/core_vocabulary/56262.png
src/main/assets/core_vocabulary/57236.png
src/main/assets/core_vocabulary/57384.png
src/main/createdoc.bat
src/main/resources/
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" /> <excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="Pictogrammar" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":app" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugTestSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://E:/Users/Fernando/Google Drive/experimentos/Pictogrammar/android/app/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/test/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<content url="file://E:/Users/Fernando/Google Drive/experimentos/Pictogrammar/android/app/src/main/java">
<sourceFolder url="file://E:/Users/Fernando/Google Drive/experimentos/Pictogrammar/android/app/src/main/java" isTestSource="false" />
</content>
<content url="file://E:/Users/Fernando/Google Drive/experimentos/Pictogrammar/android/app/src/main/res">
<sourceFolder url="file://E:/Users/Fernando/Google Drive/experimentos/Pictogrammar/android/app/src/main/res" type="java-resource" />
</content>
<content url="file://E:/Users/Fernando/Google Drive/experimentos/Pictogrammar/android/app/src/main/resources">
<sourceFolder url="file://E:/Users/Fernando/Google Drive/experimentos/Pictogrammar/android/app/src/main/resources" type="java-resource" />
</content>
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="okhttp-ws-2.3.0" level="project" />
<orderEntry type="library" exported="" name="androidasync-2.1.6" level="project" />
<orderEntry type="library" exported="" name="socket.io-client-0.5.0" level="project" />
<orderEntry type="library" exported="" name="okhttp-2.3.0" level="project" />
<orderEntry type="library" exported="" name="JPGF-1.1" level="project" />
<orderEntry type="library" exported="" name="okio-1.3.0" level="project" />
<orderEntry type="library" exported="" name="engine.io-client-0.5.0" level="project" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yottacode.pictogram"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
CONNECTIVITY_SERVICE
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.yottacode.pictogrammar.Translate"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yottacode.pictogram">
<uses-sdk android:minSdkVersion="21" />
<!-- The app has the permission to receive the RECEIVE_BOOT_COMPLETED broadcast -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- For kiosk mode -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- For the service that restarts the app when another app go to foreground -->
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<android:uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<android:uses-permission android:name="android.permission.READ_PHONE_STATE" />
<android:uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name=".kiosk.AppContext"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".gui.SplashScreenActivity"
android:label="@string/app_name"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".gui.MainActivity"
android:label="@string/app_name"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name=".gui.SerialActivity"
android:label="@string/title_activity_serial"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name=".gui.LoginActivity"
android:exported="true"
android:label="@string/title_activity_login_activity_fragments"
android:screenOrientation="landscape"/>
<activity
android:name="com.yottacode.pictogrammar.UploadActivity"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".gui.PictogramActivity"
android:exported="true"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="landscape"/>
<activity
android:name="com.yottacode.pictogrammar.Translate"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Intent Filter to run the app when the boot is completed -->
<receiver android:name=".kiosk.BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<!-- Service for restarting the app when another app go to foreground -->
<service
android:name=".kiosk.KioskService"
android:exported="false" />
<service
android:name=".net.NetService"
android:exported="false"/>
</application>
</manifest>
package com.yottacode.pictogram.grammar;
import android.util.Log;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.tools.PCBcontext;
import org.grammaticalframework.pgf.Concr;
import org.grammaticalframework.pgf.PGF;
import org.grammaticalframework.pgf.ParseError;
import org.grammaticalframework.pgf.TokenProb;
import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.Vector;
/**
* Created by Fernando on 01/06/2016.
*/
public class SemanticGrammar {
private PGF pgf;
Concr language;
String current_msg;
Hashtable<String,Integer> exp_cat; //for a given expression, which is the category. It's required for predictive grammar
public SemanticGrammar(String grammar, String language) {
System.loadLibrary("jpgf");
this.exp_cat = new Hashtable<>(Vocabulary.DEFAULT_VOCABULARY_SIZE);
try {
InputStream in = null;
in = PCBcontext.getContext().getAssets().open(grammar);
Log.i(this.getClass().getCanonicalName(), "Trying to open " + grammar);
this.language = this.pgf.getLanguages().get(language);
this.pgf = PGF.readPGF(in);
this.current_msg="";
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* It adds a new expresion with a given cat
*/
public void add_translation(String translation, int cat) {
this.exp_cat.put(translation,cat);
}
/**
* It returns the category for a given expression. It is required to implement the semantic grammar
* @param translation
* @return
*/
public int get_expr_cat(String translation) {
return this.exp_cat.get(translation);
}
public LinkedList<Picto> startSentence() {
this.current_msg="";
return PCBcontext.getVocabulary().pictos.get(Picto.NO_CATEGORY);
}
public LinkedList<Picto> next_categories(String expression) {
LinkedList<Picto> next_cats;
this.current_msg += expression + " ";
try {
Iterable<TokenProb> next_tokens = language.complete(pgf.getStartCat(), this.current_msg, "");
if (!next_tokens.iterator().hasNext())
next_cats = startSentence();
else {
next_cats = new LinkedList<>();
java.util.LinkedList<Picto> categories = PCBcontext.getVocabulary().pictos.get(Picto.NO_CATEGORY);
for (TokenProb tk : next_tokens) {
String translation = tk.getToken();
int cat = get_expr_cat(tk.getToken());
Log.i(this.getClass().getSimpleName(), "Next: " + translation + ". Cat: " + cat);
if (!next_cats.contains(cat)) {
next_cats.add(categories.get(cat));
}
}
}
} catch (ParseError parseError) {
Log.e(this.getClass().getCanonicalName(), "Error parsing " + this.current_msg + ". Error:" + parseError.getMessage() + " (token " + parseError.getToken() + ")");
next_cats = startSentence();
}
return next_cats;
}
}
package com.yottacode.pictogrammar;
import java.io.Serializable;
public class Language implements Serializable {
private static final long serialVersionUID = 1L;
private final String mLangCode;
private final String mLangName;
private final String mConcrete;
public Language(String langCode, String langName, String concrete) {
mLangCode = langCode;
mLangName = langName;
mConcrete = concrete;
}
public String getLangCode() {
return mLangCode;
}
public String getLangName() {
return mLangName;
}
String getConcrete() {
return mConcrete;
}
@Override
public String toString() {
return getLangName();
}
@Override
public boolean equals(Object o) {
Language other = (Language) o;
return mLangCode.equals(other.mLangCode);
}
}
\ No newline at end of file
package com.yottacode.pictogrammar;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.ListView;
import android.widget.ArrayAdapter;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.widget.Toast;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Vector;
import org.grammaticalframework.sg.SG;
import org.grammaticalframework.pgf.*;
import com.yottacode.pictogram.dao.PCBDBHelper;
import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.pictogram.tts.TTSHelper;
import com.yottacode.pictogram.R;
public class Translate extends Activity
{
private ArrayAdapter mArrayAdapter;
private PGF mPGF;
private TTSHelper tts;
private GrammarLoader mGrammarLoader;
private ConcrLoader mSourceLoader;
private ConcrLoader mTargetLoader;
private ConcrLoader mOtherLoader;
private String mGrammar = "SUpO.pgf" ;
// String constant for logs
private final String TAG = this.getClass().getSimpleName(); // Or .getCanonicalName()
// String constan for token
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mGrammarLoader = new GrammarLoader();
mGrammarLoader.start();
Language prefSourceLang = new Language("es-ES", "Spanish", "SUpO-ES");
Language prefTargetLang = new Language("en-US", "English", "SUpO-EN");
mSourceLoader = new ConcrLoader(prefSourceLang);
mSourceLoader.start();
if (prefSourceLang == prefTargetLang) {
mTargetLoader = mSourceLoader;
} else {
mTargetLoader = new ConcrLoader(prefTargetLang);
mTargetLoader.start();
}
mArrayAdapter = new ArrayAdapter(this, R.layout.listitem);
ListView list = (ListView)findViewById(R.id.list);
list.setAdapter(mArrayAdapter);
}
@Override
public void onDestroy() {
super.onDestroy();
this.tts.destroy();
}
public void translate(View v) {
TextView tv = (TextView)findViewById(R.id.edittext);
String input = tv.getText().toString();
new TranslateTask().execute(input);
}
public void readit(View v) {
TextView tv = (TextView)findViewById(R.id.edittext);
String input = tv.getText().toString();
tts.speakText(input);
mArrayAdapter.clear();
mArrayAdapter.add(input);
}
public void changeit(View v) {
}
public void showTTS(View v) {
mArrayAdapter.clear();
// ITERAR SOBRE EL VOCABULARIO
TextView tv = (TextView)findViewById(R.id.edittts_engine);
String input = tv.getText().toString();
if (input.length()>0)
tts.createTTS(this,input);
tv = (TextView)findViewById(R.id.edittts_voice);
input = tv.getText().toString();
if (input.length()>0)
tts.setVoice(this, input);
tts.show(mArrayAdapter);
}
/**
* This class is used to parse a sentence asychronously.
* It display a blocking progress dialog while doing so.
*/
private class TranslateTask extends AsyncTask<String, Void, String[]> {
private ProgressDialog progress;
protected void onPreExecute() {
// Display loading popup
this.progress =
ProgressDialog.show(Translate.this,"Translate","Parsing, please wait",true);
}
protected String[] doInBackground(String... s) {
return null;
}
protected void onPostExecute(String[] result) {
mArrayAdapter.clear();
for (String sentence : result)
mArrayAdapter.add(sentence);
if (this.progress != null)
this.progress.dismiss(); // Remove loading popup
}
}
private class GrammarLoader extends Thread {
private PGF mPGF;
public GrammarLoader() {
mPGF = null;
}
public PGF getGrammar() {
return mPGF;
}
public void run() {
InputStream in = null;
try {
System.loadLibrary("jpgf");
for (String lo: getAssets().list("."))
Log.i(this.getClass().getSimpleName(),"LOCALES:"+lo);
in = getAssets().open(mGrammar);
Log.i(TAG, "Trying to open " + mGrammar);
long t1 = System.currentTimeMillis();
mPGF = PGF.readPGF(in);
long t2 = System.currentTimeMillis();
Log.i(TAG, mGrammar + " loaded (" + (t2 - t1) + " ms)");
// Type typ = mPGF.getFunctionType("Bulgarian");
// System.out.println(typ.getCategory());
System.out.println(mPGF .getAbstractName());
for (Map.Entry<String,Concr> entry : mPGF .getLanguages().entrySet()) {
Log.i(this.getClass().getSimpleName(), entry.getKey() + " Language: " + entry.getValue().getName());
}
Concr eng = mPGF.getLanguages().get("SUpO_EN");
InputStream is_es= in = getAssets().open("SUpO_ES.gfo");
eng.unload();
eng.load(is_es);
try {
int i=0;
for (ExprProb ep : eng.parse(mPGF.getStartCat(), "I want salty chips")) {
if (i++>5) break;
Log.e(this.getClass().getSimpleName(), "Next: [" + ep.getProb() + "] " + ep.getExpr());
}
i=0;
java.util.Vector<Integer> categories=new Vector<>();
for (TokenProb tk : eng.complete(mPGF.getStartCat(),"I want salty","")) {
String translation=tk.getToken();
Log.i(this.getClass().getSimpleName(), "Next: " + translation );
}
} catch (ParseError e) {
Log.e(this.getClass().getSimpleName(),"Parsing failed at token \""+e.getToken()+"\"");
}
} catch (FileNotFoundException e) {
Log.e(TAG, "File not found", e);
} catch (IOException e) {
Log.e(TAG, "Error loading grammar", e);
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
Log.e(TAG, "Error closing the stream", e);
}
}
}
}
}
private class ConcrLoader extends Thread {
private Language mLanguage;
private Concr mConcr;
public ConcrLoader(Language lang) {
this.mLanguage = lang;
this.mConcr = null;
}
public Language getLanguage() {
return mLanguage;
}
public Concr getConcr() {
return mConcr;
}
public void run() {
try {
mGrammarLoader.join();
} catch (InterruptedException e) {
Log.d(TAG, "interrupted", e);
}
InputStream in = null;
try {
String name = mLanguage.getConcrete();
in = getAssets().open(name);
Log.d(TAG, "Trying to load " + name);
long t1 = System.currentTimeMillis();
mConcr = mGrammarLoader.getGrammar().getLanguages().get(mLanguage.getConcrete());
mConcr.load(in);
long t2 = System.currentTimeMillis();
Log.d(TAG, name + " loaded ("+(t2-t1)+" ms)");
} catch (FileNotFoundException e) {
Log.e(TAG, "File not found", e);
} catch (IOException e) {
Log.e(TAG, "Error loading concrete", e);
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
Log.e(TAG, "Error closing the stream", e);
}
}
}
}
}
}
\ No newline at end of file
package com.yottacode.pictogrammar;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.widget.ProgressBar;
import com.github.nkzawa.socketio.client.IO;
import com.google.gson.JsonObject;
import com.koushikdutta.async.future.FutureCallback;
import com.koushikdutta.ion.Ion;
import com.yottacode.net.FakeSSLTrustManager;
import com.yottacode.net.SSLDummyContext;
import com.yottacode.pictogram.R;
import com.yottacode.pictogram.tools.PCBcontext;
import java.io.File;
import java.security.NoSuchAlgorithmException;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import static com.yottacode.pictogram.R.layout.activity_upload;
public class UploadActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(activity_upload);
ProgressBar uploadProgressBar;
uploadProgressBar = (ProgressBar) findViewById(R.id.progressBar2);
SSLDummyContext.init(getResources().getBoolean(R.bool.ssl_connect));
final Context context = UploadActivity.this;
SSLContext mySSLContext = SSLDummyContext.get();
PCBcontext.init(this);
PCBcontext.getRestapiWrapper().setToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJvZmZpY2UiOnsiaWQiOjM4MywibmFtZSI6IkNvbXVuaWNhY2nDs24gQXVtZW50YXRpdmEgSkHDqW4gKENBSkEpIiwiYWRkcmVzcyI6IlBhcmFqZSBMYXMgTGFndW5pbGxhcywgRWQgQTMsIHByaW1lcmEgcGxhdGEsIDIzMDcxLiBKYcOpbiIsImVtYWlsIjoiZG9mZXJAdWphZW4uZXMiLCJwaG9uZTEiOiIrMzQgOTUzIDIxIDI4IDg4IiwicGhvbmUyIjpudWxsLCJsYW5nIjoiZXMtZXMiLCJjb3VudHJ5IjoiRVMiLCJhZG1pbiI6MjMsImNvbnRhY3RQZXJzb24iOiJGZXJuYW5kbyBNYXJ0w61uZXogU2FudGlhZ28iLCJtYXhTdHVkZW50cyI6MiwiY3VycmVudFN0dWRlbnRzIjowfSwiaWQiOjIzLCJuYW1lIjoiRmVybmFuZG8iLCJzdXJuYW1lIjoiTWFydMOtbmV6IFNhbnRpYWdvIiwiZ2VuZGVyIjoiTSIsInBpYyI6Imh0dHA6Ly93d3dkaS51amFlbi5lcy9zaXRlcy9kZWZhdWx0L2ZpbGVzL3lvLmpwZz8xNDQ4MDE5MzU2IiwiYWRkcmVzcyI6bnVsbCwiY291bnRyeSI6bnVsbCwiZW1haWwiOiJkb2ZlckB1amFlbi5lcyIsInBob25lIjoiKzM0OTUzMjEyODg4IiwibGFuZyI6ImVzLWVzIiwiYWN0aXZlIjp0cnVlLCJ0dHNFbmdpbmUiOm51bGwsImlzU3VwQWRtaW4iOnRydWUsImlhdCI6MTQ1NDM4OTI0MywiZXhwIjoxNDU0Mzk2NDQzfQ.X-31SdZDYHH1SdBEsFVmajavg1VlIQQhImc3ROrnDzg");
Ion ion = Ion.getDefault(context);
try {
ion.configure().createSSLContext("TLS");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
Log.i(this.getClass().getCanonicalName(), " Uploading 1 ");
ion.getHttpClient().getSSLSocketMiddleware().setSSLContext(mySSLContext);
ion.getHttpClient().getSSLSocketMiddleware().setTrustManagers(new TrustManager[]{new FakeSSLTrustManager()});
Log.i(this.getClass().getCanonicalName(), " Uploading 2 ");
ion.with(context)
.load(context.getResources().getString(R.string.server) + "/picto/upload")
.uploadProgressBar(uploadProgressBar).setTimeout(20000)
.setMultipartParameter("filename", "foo-bar")
.setMultipartParameter("extension", "jpg")
.setMultipartParameter("owner", "10")
.setMultipartParameter("folder", "custompictos")
.setMultipartParameter("source", "1")
.setMultipartParameter("token", PCBcontext.getRestapiWrapper().getToken())
.setMultipartFile("file", "image/jpeg", new File("/storage/emulated/0/DCIM/Camera/IMG_20160202_053728.jpg"))
.asJsonObject()
.setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
if (e == null)
Log.i(this.getClass().getCanonicalName(), " Uploaded to " + context.getResources().getString(R.string.server) + " " + result);
else
Log.e(this.getClass().getCanonicalName(), "Upload error:" + e.getMessage());
if (result != null)
Log.i(this.getClass().getCanonicalName(), "Upload result:" + result.toString());
else
Log.i(this.getClass().getCanonicalName(), "no result");
}
});
Log.i(this.getClass().getCanonicalName(), " Uploading 3 ");
ion.dump();
}
}
SET CLASSPATH="E:\Users\Fernando\AppData\Local\Android\android-sdk\platforms\android-21\android.jar;F:\Users\Fernando\GoogleDrive\experimentos\2014-2015\Pictogrammar\android\app\src\main\java;F:\Users\Fernando\GoogleDrive\experimentos\2014-2015\Pictogrammar\android\app\libs\JPGF-1.1.jar"
javadoc.exe -d doc -classpath %CLASSPATH% java\com\yottacode\pictogram\dao\*
javadoc.exe -d doc -classpath %CLASSPATH% java\com\yottacode\pictogram\tools\*
javadoc.exe -d doc -classpath %CLASSPATH% java\com\yottacode\pictogram\grammar\*
javadoc.exe -d doc -classpath %CLASSPATH% java\com\yottacode\pictogram\tts\*
\ No newline at end of file
insert into student values(1,"student1","surname st1","picto1","M","es-es",NULL);
insert into student values(2,"student2","surname st2","picto2","M","es-es",NULL);
insert into student values(3,"student3","surname st3","picto3","M","es-es",NULL);
insert into student values(4,"student4","surname st4","picto4","F","es-es",NULL);
insert into student values(5,"student5","surname st5","picto5","F","en-gb",NULL);
insert into student values(6,"student6","surname st6","picto6","F","es-es",NULL);
insert into supervisor values(1,"supervisor1","surname sup1","pictos1","F","es-es",NULL);
insert into supervisor values(2,"supervisor2","surname sup2","pictos2""F","en-gb",NULL);
insert into users(id_stu) values (1);
insert into users values (1,1);
insert into users values (2,1);
insert into users values (3,1);
insert into users(id_stu) values (4);
insert into users values (5,2);
insert into users values (6,2);
insert into users_detail values (7,"student7","surname student7","picto7",
3,"supervisor3","surname sup3","pictos3");
insert into users_detail values (7,"student7","surname student7","picto7",
2,"supervisor3","surname sup3","pictos3");
insert into action values ("act1","2015-02-18 10:00:00",1,-1,"action <student1>",NULL,NULL);
insert into action values ("act1","2015-02-18 10:01:00",1,-1,"action 2 <student1>",NULL,NULL);
insert into action values ("act1","2015-02-18 10:02:00",1,1,"action 1 <student1,supervisor1>",NULL,NULL);
insert into action values ("act1","2015-02-18 10:03:00",5,2,"action 1 <student5,supervisor2>",NULL,NULL);
apply plugin: 'com.android.application' apply plugin: 'com.android.library'
android { android {
signingConfigs { compileSdkVersion 24
release_config { buildToolsVersion "23.0.2"
}
}
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.yottacode.pictogram"
minSdkVersion 21
targetSdkVersion 21
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"
defaultConfig {
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
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 "bool", "force_db_create", "false"
resValue "bool", "ssl_connect", "false"
resValue "bool", "force_img_download", "false"
resValue "integer", "netservice_timing", "20"
} }
buildTypes { debug {
release { resValue "string", "server", "https://dev.yottacode.com"
minifyEnabled false resValue "bool", "force_db_create", "false"
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' resValue "bool", "ssl_connect", "false"
resValue "string", "server", "https://pre.yottacode.com" resValue "bool", "force_img_download", "false"
resValue "bool", "force_db_create", "false" resValue "integer", "netservice_timing", "20"
resValue "bool", "ssl_connect", "false"
resValue "bool", "force_img_download", "false"
resValue "integer", "netservice_timing", "20"
}
debug {
//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"
}
}
productFlavors {
FernandoFlavor {
resValue "string", "server", "https://127.0.0.1:9944"
applicationId "com.yottacode.pictogrammar"
}
LocalFlavor {
resValue "string", "server", "https://192.168.1.37:1337"
}
DevFlavor {
resValue "string", "server", "https://dev.yottacode.com"
}
DefaultFlavor {
resValue "string", "server", "https://pre.yottacode.com"
signingConfig signingConfigs.release_config
}
} }
}
} }
dependencies { dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:6.5.87' testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:21.0.3' compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.github.nkzawa:socket.io-client:0.5.0' compile 'com.github.nkzawa:socket.io-client:0.5.0'
compile 'com.koushikdutta.async:androidasync:2.+' compile 'com.koushikdutta.async:androidasync:2.+'
compile 'com.android.support:support-v4:21.0.+' compile 'com.android.support:support-v4:24.1.1'
compile 'com.koushikdutta.ion:ion:2.+' //required for upload images compile 'com.koushikdutta.ion:ion:2.+'
compile 'com.google.android.gms:play-services-ads:9.2.1'
compile 'com.google.android.gms:play-services-auth:9.2.1'
compile 'com.google.android.gms:play-services-gcm:9.2.1'
compile 'com.android.support:support-v4:24.1.1'
} }
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yottacode.pictogram">
<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true">
</application>
</manifest>
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