Commit 8005ee19 by Arturo Montejo Ráez

Merge branch 'master' of http://scm.ujaen.es/softuno/pictogram

parents ac779b3b 6383f43e
Showing with 146 additions and 29 deletions
......@@ -33,10 +33,10 @@ sails/src/node_modules
sails/src/assets/app/bower_components
sails/src/.tmp
sails/config/tmp.sql
android/Pictogrammar/.idea
android/Pictogram/.idea
.idea
android/Pictogrammar/app/app.iml
android/Pictogrammar/Pictogrammar.iml
android/Pictogram/app/app.iml
android/Pictogram/Pictogrammar.iml
# Packages #
############
......
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="Pictogram" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
......@@ -4,7 +4,7 @@ android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.yottacode.pictogrammar"
applicationId "com.yottacode.pictogram"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
......@@ -37,6 +37,7 @@ android {
productFlavors {
FernandoFlavor {
resValue "string", "server", "https://127.0.0.1:9944"
applicationId "com.yottacode.pictogrammar"
}
ArturoFlavor {
resValue "string", "server", "https://192.168.1.37:1337"
......@@ -52,7 +53,6 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//compile fileTree(dir: 'E:\\Users\\Fernando\\Google Drive\\experimentos\\Pictogrammar\\android\\app\\libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.github.nkzawa:socket.io-client:0.5.0'
......
......@@ -3,6 +3,7 @@ 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;
......@@ -12,6 +13,7 @@ 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;
......@@ -30,40 +32,48 @@ public class UploadActivity extends Activity {
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 {
try {
ion.configure().createSSLContext("TLS");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
*/
//ion.getHttpClient().getSSLSocketMiddleware().setSSLContext(mySSLContext);
//ion.getHttpClient().getSSLSocketMiddleware().setTrustManagers(new TrustManager[]{new FakeSSLTrustManager()});
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)
.uploadProgressBar(uploadProgressBar).setTimeout(20000)
.setMultipartParameter("filename", "foo-bar")
.setMultipartParameter("extension", "jpg")
.setMultipartParameter("owner", "10")
.setMultipartParameter("folder", "custompictos")
.setMultipartParameter("source", "1")
.setMultipartParameter("token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJvZmZpY2UiOnsiaWQiOjM4MywibmFtZSI6IkNvbXVuaWNhY2nDs24gQXVtZW50YXRpdmEgSkHDqW4gKENBSkEpIiwiYWRkcmVzcyI6IlBhcmFqZSBMYXMgTGFndW5pbGxhcywgRWQgQTMsIHByaW1lcmEgcGxhdGEsIDIzMDcxLiBKYcOpbiIsImVtYWlsIjoiZG9mZXJAdWphZW4uZXMiLCJwaG9uZTEiOiIrMzQgOTUzIDIxIDI4IDg4IiwicGhvbmUyIjpudWxsLCJsYW5nIjoiZXMtZXMiLCJjb3VudHJ5IjoiRVMiLCJhZG1pbiI6MjMsImNvbnRhY3RQZXJzb24iOiJGZXJuYW5kbyBNYXJ0w61uZXogU2FudGlhZ28iLCJtYXhTdHVkZW50cyI6MiwiY3VycmVudFN0dWRlbnRzIjowfSwiaWQiOjIzLCJuYW1lIjoiRmVybmFuZG8iLCJzdXJuYW1lIjoiTWFydMOtbmV6IFNhbnRpYWdvIiwiZ2VuZGVyIjoiTSIsInBpYyI6Imh0dHA6Ly93d3dkaS51amFlbi5lcy9zaXRlcy9kZWZhdWx0L2ZpbGVzL3lvLmpwZz8xNDQ4MDE5MzU2IiwiYWRkcmVzcyI6bnVsbCwiY291bnRyeSI6bnVsbCwiZW1haWwiOiJkb2ZlckB1amFlbi5lcyIsInBob25lIjoiKzM0OTUzMjEyODg4IiwibGFuZyI6ImVzLWVzIiwiYWN0aXZlIjp0cnVlLCJ0dHNFbmdpbmUiOm51bGwsImlzU3VwQWRtaW4iOnRydWUsImlhdCI6MTQ1Mzg2MTkyNSwiZXhwIjoxNDUzODY5MTI1fQ.41Zpp1WHayS9x4VsYUKz0KchUAs0fcQB7wU7FotELKc")
.setMultipartFile("file", "image/jpeg", new File("/storage/emulated/0/DCIM/Camera/shot1.jpg"))
.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)
System.out.println("Uploaded to " + context.getResources().getString(R.string.server) + " " + result);
Log.i(this.getClass().getCanonicalName(), " Uploaded to " + context.getResources().getString(R.string.server) + " " + result);
else
Log.e(this.getClass().getCanonicalName(), "error uploading");
if (result != null)
Log.i(this.getClass().getCanonicalName(), result.toString());
else
System.out.println("Error " + e.getMessage());
e.printStackTrace();
Log.i(this.getClass().getCanonicalName(), "no result");
}
});
ion.dump();
Log.i(this.getClass().getCanonicalName(), " Uploading 3 ");
}
}
<?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"/>
<!-- 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>
......@@ -51,7 +51,7 @@ public class RestapiWrapper {
this.token=token;
}
public String getToken() {
return token;
if (token==null) throw new java.lang.NullPointerException("Token has no value. Use constructor properly or RestapiWrapper.setToken must be invoked previously"); return token;
}
public String getServer() {
return server;
......@@ -219,7 +219,6 @@ public class RestapiWrapper {
@Override
protected HttpAsyncTaskParams doInBackground(HttpAsyncTaskParams... params) {
Log.d(LOG_TAG, "POST params doIn:" + params[0].url_params.toString()+" Get?"+params[0].get);
params[0].result = params[0].get ? GET(params[0].url, params[0].url_params, null)
: POST(params[0].url, params[0].url_params);
return params[0];
......
......@@ -39,8 +39,7 @@ public class MainActivity extends Activity {
//PCBcontext pcb = PCBcontext.getInstance();
PCBcontext.init(this);
Log.d(LOG_TAG, "PCBcontext iniciado");
// Compruebo si tengo token ya guardado en la bbdd para abrir el intent del registro
String token = PCBcontext.getRestapiWrapper().getToken();
//if (1==0){ // Fuerzo a que entre en serialActivity
Intent serialActivity = new Intent(this, SerialActivity.class);
......
......@@ -72,35 +72,35 @@ public final class PCBcontext {
// Return the context
// modified by Fernando
public static Context getContext(){ return context; }
public static Context getContext(){ if (context==null) throw new java.lang.NullPointerException("Context is null. PCBcontext.init must be invoked previously"); return context; }
// Return the device
// modified by Fernando
public static Device getDevice(){ return device; }
public static Device getDevice(){ if (device==null) throw new java.lang.NullPointerException("Device is null. PCBcontext.init must be invoked previously");return device; }
// Return the PCBDB
// modified by Fernando
public static PCBDBHelper getPcbdb(){ return pcbdb; }
public static PCBDBHelper getPcbdb(){ if (context==null) throw new java.lang.NullPointerException("PCBDB is null. PCBcontext.set_user must be invoked previously");return pcbdb; }
// Return the NetService
// modified by Fernando
public static NetService getNetService(){ return service; }
public static NetService getNetService(){ if (service==null) throw new java.lang.NullPointerException("NetService is null. PCBcontext.set_user must be invoked previously"); return service; }
// Return the RestapiWrapper
// modified by Fernando
public static RestapiWrapper getRestapiWrapper(){ return wrapper; }
public static RestapiWrapper getRestapiWrapper(){ if (wrapper==null) throw new java.lang.NullPointerException("RestapiWrapper is null. PCBcontext.init must be invoked previously"); return wrapper; }
// Return the Room
// modified by Fernando
public static Room getRoom(){ return room; }
public static Room getRoom(){ if (room==null) throw new java.lang.NullPointerException("Room is null. PCBcontext.set_user must be invoked previously"); return room; }
// Return the Vocabulary
// modified by Fernando
public static Vocabulary getVocabulary(){ return vocabulary; }
public static Vocabulary getVocabulary(){ if (vocabulary==null) throw new java.lang.NullPointerException("Vocabulary is null. PCBcontext.set_user must be invoked previously"); return vocabulary; }
// Return the ActionLog
// modified by Fernando
public static ActionLog getActionLog(){ return actionLog; }
public static ActionLog getActionLog(){ if (actionLog==null) throw new java.lang.NullPointerException("ActionLog is null. PCBcontext.set_user must be invoked previously"); return actionLog; }
}
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