You need help for something ? Go to https://xr4dev.pages.xr4all.eu

-Updated Javadoc

-Improved UI for final demo
parent c6b1fc5c
......@@ -28,6 +28,7 @@ import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.finconsgroup.xr4all.ecar.augmentedimage.eCARNode.eCARNode;
......@@ -40,15 +41,18 @@ import com.finconsgroup.xr4all.ecar.utils.ImageUtils;
import com.google.ar.core.Anchor;
import com.google.ar.core.AugmentedImage;
import com.google.ar.core.Frame;
import com.google.ar.core.Pose;
import com.google.ar.core.TrackingState;
import com.google.ar.core.exceptions.NotYetAvailableException;
import com.google.ar.sceneform.AnchorNode;
import com.google.ar.sceneform.FrameTime;
import com.google.ar.sceneform.Node;
import com.google.ar.sceneform.ux.ArFragment;
import com.google.zxing.FormatException;
import com.google.zxing.NotFoundException;
import com.google.zxing.oned.Code128Reader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
......@@ -153,8 +157,8 @@ public class AugmentedImageActivity extends AppCompatActivity {
eCARNode node = eCARNodeFactory.makeNode(AugmentedImageActivity.this,resource);
nodeMap.put(code,node);
node.prepareAnchor(a);
arFragment.getArSceneView().getScene().addChild(node);
Toast.makeText(AugmentedImageActivity.this,"Please, select a resource",Toast.LENGTH_LONG).show();
//arFragment.getArSceneView().getScene().addChild(node);
}
});
......@@ -180,11 +184,30 @@ public class AugmentedImageActivity extends AppCompatActivity {
}
@Override
public void onBackPressed() {
//Remove and reset AR
if(nodeMap.values().isEmpty()){
super.onBackPressed();
}
codes.clear();
for (AnchorNode node : nodeMap.values()){
if(node.getAnchor()!=null) node.getAnchor().detach();
node.setParent(null);
}
nodeMap.clear();
resourceLists.clear();
((LinearLayout)findViewById(R.id.resource_selector)).removeAllViews();
fitToScanView.setVisibility(View.VISIBLE);
}
private void addResourceSelector(final String code){
LinearLayout resource_selector = findViewById(R.id.resource_selector);
int size = (resourceLists.get(code)).size();
int size = (resourceLists.get(code)).size();
ArrayList<Button> buttons = new ArrayList<>();
for(int i = 0;i < size; i++){
Button button = new Button(this);
button.setText(""+(i+1));
......@@ -193,10 +216,18 @@ public class AugmentedImageActivity extends AppCompatActivity {
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//Reset button colour
for(Button b : buttons){
b.setBackground(getDrawable(R.drawable.circle));
}
//Set current button colour
view.setBackground(getDrawable(R.drawable.circle_sel));
loadResource(code, index);
}
});
resource_selector.addView(button);
buttons.add(button);
}
}
......@@ -207,7 +238,7 @@ public class AugmentedImageActivity extends AppCompatActivity {
Anchor anchor = node.getAnchor();
arFragment.getArSceneView().getScene().removeChild(node);
if(node!=null){
node.getAnchor().detach();
if(node.getAnchor()!=null) node.getAnchor().detach();
node.setParent(null);
node.setRenderable(null);
}
......
......@@ -168,12 +168,11 @@ public class AugmentedPdfNodeView extends eCARNode {
setAnchor(anchor);
Vector3 localPosition = new Vector3(0,0,0);
Vector3 localPosition = new Vector3(0,-0.5f,-1f);
Node cornerNode = new Node();
cornerNode.setParent(this);
cornerNode.setLocalPosition(localPosition);
cornerNode.setLocalRotation(new Quaternion(localPosition,0));
//cornerNode.setLocalRotation(new Quaternion(localPosition,0));
cornerNode.setRenderable(renderableCompletableFuture.get());
......@@ -195,6 +194,7 @@ public class AugmentedPdfNodeView extends eCARNode {
private Bitmap getPageBitmap(PdfRenderer pdfRenderer, int page_index){
PdfRenderer.Page page = pdfRenderer.openPage(page_index);
Bitmap bitmap = Bitmap.createBitmap(page.getWidth(),page.getHeight(), Bitmap.Config.ARGB_8888);
page.render(bitmap,null,null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY);
page.close();
......
......@@ -54,16 +54,9 @@ public class CpabeManager {
pubkey = Base64.decode(pub_str,Base64.URL_SAFE);
String sk = "AAAAgC2jS5hki5ePwEQPQRwttLqapWQMUeBLWdm_rfdlP1eg72KIvur6jYKst1_0wiJ4dUd5n7Wl" +
"kDFZlpwmr7VXPt1IVk_d9RDeB_S-WB61YM-9Uq7Lp7Z-Ohcnenas-2uUVZTxuIsW4KM2bZGI5L8c" +
"v5p3_a4d2pQ1OyPiLyWct1XLAAAAAQAAAARjOklUAAAAgKJ2ChLUqlZA99ouSziziG05sU4GqDPL" +
"uP12RGobFwixc7Kd__Vhz8pbd3RT8FcbNvoMC6UZ_SUlgAOhQzCTVaMmHorMJhUeAi6PrilEE1MV" +
"aIWU91qrqgLG30owki4m4yevqMsVDmcVIzposJcJ2X0o1V3x0axTs3Ief0DVJrNbAAAAgEkgjPXm" +
"3Q3TUCTS6rCkHJXeYScFBFxcjnabq_RccMgC7atLNDR5zOmxwVPVbrMSSMfPaAkWW3fVGl0FBujo" +
"vGNfZWGoBP3SlYhgrITWLNudxF8oYTYxvDh93iLGkvXDZTMRFK7o-6oFJQoUbIDE4R69U0Pl7Ped" +
"iwJOlGn_TbQp";
String sk_scope = "default";
//operator private key
String sk = "AAAAgJtavvLKUT90o7VU9cPBQECSSJmZgczxxm0-HySQUdFaSYTRZhJ1DmfUTejogHjtHaejM-Vz8210S2dIbFpnLUqOjiePVUMq__p4CqlkYKKwpk0xct9RqYFfwU9MG1vtXdUjzh45Mlz9WFfEoHw5Yf69fM7OwByLD4AYpV5n0P1YAAAAAwAAAARjOklUAAAAgGw2O8BylxoYmmVNOYpUr5R27cxob5feCpX5etXGyhzSGkdsU-_XLGUsmoYtlUthp9sqdz-cXpERu_8kkRzySGtxqmPrN8i1qjcjt16ZkDhZfKW1AqyGZA-12wLmGYoG51DukygremH_rJ3q0U4klkdMuAgOCQNWPel9L_hYhFeIAAAAgGWk1qDNEzES8WVfMFG8_h_iYViWmgyQHYnNR37bjV3gHxsyIxeOwRsIyDIZxRJ2dbvsOe74xiyLUjhN3KnbT2VkYcBXoMBAIHUjqnR1ifDWuFodhTmLMhjMji79qFA2Uvkk8wnBeifqzy2JxIPcAYMUe_npZhnw3VZ8p1_zSt4OAAAAEG86VEVDTkFSUkVET19TcmwAAACAbAg_koiwp9yTLiRAYtyEnNEkarCpzAUFy61ktg0qU-Kdh1yHM0q3dCIYQ6xycyRUgS2Tfo-Jnv403tfkIWQyq4BsLwtw7MjseGUK_GLpuxz_LJSfi1ofw8ZB4BHOhueiPuJYXEIhyMuXt6aDSvoxGIPDkLdqJv8GvM2WlUwFSYsAAACAC5MEbxNI6Y1jK4fBvRXCI0PNutRyujX81f_5AgUMNGvxoxWP3GdOVs-44AFy7KpnWiQ7NRSndhw2glIkHdmiGnbOX3OViMU7YcVHaCSnMEMRNikwopGVVC8vFGJ-JJCdlitO_oA3fOMjUhNTCjUqWjWWAFq_T7IYRMmgfTOEQFEAAAAMb3U6T3BlcmF0b3JzAAAAgBOn3hS_r2_4o3phi759CHfyYtFx1lRUrFyXe7w_IInupAwBvhM5sa48IkwT0RN35QELobQVCTo3jAZUk5RNQWEGcgstI7Rrce0dUahHQxixvOVBnnOqMQNMGSWNd2heqHy4hARpKUNXF16XiyyY8jYfML18o714UpBcdaKHh4O5AAAAgCKnfU12uWWxqzkhopEipGLljqwiW1mK440q7ptaMszO-HqdOHm_712YzR1gPmAolJXBvcQ6n2oh8s8NTHTvnQ-ft-dS_PcGbvWECshB7df-sh0lxCcWVs1HBHpbk-4nhxuJrIc166H_m02_cOAl4Id9lM2yGAJZjuUxxWeQ0d4P";
String sk_scope = "RestrictedScope";
keyring = new HashMap<>();
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#333333"
android:alpha="0.6">
<path
android:fillColor="#FF000000"
android:pathData="M5,15L3,15v4c0,1.1 0.9,2 2,2h4v-2L5,19v-4zM5,5h4L9,3L5,3c-1.1,0 -2,0.9 -2,2v4h2L5,5zM19,3h-4v2h4v4h2L21,5c0,-1.1 -0.9,-2 -2,-2zM19,19h-4v2h4c1.1,0 2,-0.9 2,-2v-4h-2v4zM12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM12,14c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"/>
</vector>
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#A3A2A2" />
<stroke android:width="1dp" android:color="#2196F3" />
<padding android:left="1dp" android:top="1dp" android:right="1dp"
android:bottom="1dp" />
</shape>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="10dp">
<solid android:color="#03A9F4"/> <!-- this one is ths color of the Rounded Button -->
<solid android:color="#BCC5CC"/> <!-- this one is ths color of the Rounded Button -->
<corners
android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="10dp">
<solid android:color="#03A9F4"/> <!-- this one is ths color of the Rounded Button -->
<corners
android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp"/>
</shape>
\ No newline at end of file
......@@ -6,26 +6,133 @@
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="eCAR PoC v1.0"
app:layout_constraintBottom_toTopOf="@+id/button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.795" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_marginTop="8dp"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|center_horizontal|center_vertical"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:gravity="center|center_horizontal|center_vertical"
android:text="TECNARREDO Srl\nPoC v1.0"
android:textAlignment="center"
android:textSize="18sp" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_gravity="center|center_horizontal|center_vertical"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
app:srcCompat="@drawable/ecarlogo" />
<TextView
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|center_horizontal|center_vertical"
android:ems="10"
android:gravity="start|top"
android:text="@string/poc_description"
android:textAlignment="center"
android:textSize="13sp" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/floatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:clickable="true"
android:onClick="startAR"
app:srcCompat="@drawable/cameraar" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="208dp"
android:onClick="startAR"
android:text="Start AR"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.517"
app:layout_constraintStart_toStartOf="parent" />
android:layout_marginBottom="8dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:text="Developed by" />
<ImageView
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="75dp"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
app:srcCompat="@drawable/logo_fincons" />
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView5"
android:layout_width="42dp"
android:layout_height="43dp"
android:layout_marginStart="8dp"
android:scaleType="centerInside"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@drawable/logo_xr4all" />
<TextView
android:id="@+id/textView4"
android:layout_width="0dp"
android:layout_height="44dp"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:text="This project received funding from the European Union’s Horizon 2020 Research and Innovation Programme under Grant Agreement Nº 825545."
android:textAlignment="center"
android:textSize="8sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/imageView6"
app:layout_constraintStart_toEndOf="@+id/imageView5" />
<ImageView
android:id="@+id/imageView6"
android:layout_width="48dp"
android:layout_height="33dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/logo_eu" />
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
......@@ -18,21 +18,22 @@
android:id="@+id/left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/arrow_back"
android:background="@drawable/border" />
android:background="@drawable/arrow_back" />
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/colorAccent"
app:srcCompat="@color/colorPrimary" />
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/colorAccent"
app:srcCompat="@color/colorPrimary" />
<ImageView
android:id="@+id/right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/arrow_forward" />
android:src="@drawable/arrow_forward"
android:background="@drawable/border"/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
<color name="colorPrimary">#FF9800</color>
<color name="colorPrimaryDark">#FF5722</color>
<color name="colorAccent">#F44336</color>
<color name="black_overlay">#66000000</color>
</resources>
......@@ -4,4 +4,5 @@
<string name="title_activity_ar">ArActivity</string>s
<string name="fit_image_to_scan">Fit image to scan</string>
<string name="poc_description">Press the red button below\nto start the AR/MR view</string>
</resources>
......@@ -6,6 +6,15 @@
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar" >
<item name="android:titleTextStyle">@style/textStyleActionBar</item>
</style>
<style name="textStyleActionBar" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:gravity">center</item>
</style>
<style name="FullscreenTheme" parent="AppTheme">
......@@ -17,6 +26,7 @@
</style>
<style name="FullscreenActionBarStyle" parent="Widget.AppCompat.ActionBar">
<item name="android:background">@color/black_overlay</item>
</style>
</resources>
......@@ -16,7 +16,7 @@
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>hivemq-mqtt-client</name>
<name>eCAR-dynamic-stream-client</name>
<url>http://maven.apache.org</url>
<properties>
......
package com.finconsgroup.xr4all.ecar.messages;
/**
* Pojo class for storing Encrypted AES Key Info
*
*/
public class KeyInfo {
private String key_id;
private String key;
/**
*
* @param key_id the key id associated to the encrypted key assigned by the KSS
* @param key the Encrypted key encoded in base64 url safe
*/
public KeyInfo(String key_id, String key) {
this.key_id = key_id;
......
package com.finconsgroup.xr4all.ecar.messages;
/**
* Pojo class of the MQTT message payload
*
*
*/
public class Payload {
private String key_id;
private String payload;
/**
*
* @param key_id the id of the encrypted AES key to be used to decrypted the {@param payload}
* @param payload the encrypted message
*/
public Payload(String key_id, String payload) {
this.key_id = key_id;
this.payload = payload;
......
......@@ -31,6 +31,12 @@ import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
/**
* This class provides the method to perform an MQTT message publish operation
* using CP-ABE/AES encryption; It also handles the encryption keys
* generation and store
*
*/
public class MessagePublisherService {
private static MessagePublisherService service;
......@@ -43,11 +49,7 @@ public class MessagePublisherService {
private static ObjectMapper mapper;
/**This class provides the method to perform an MQTT message publish operation
* using CP-ABE/AES encryption; It also handles the encryption keys
* generation and store
*
*/
private MessagePublisherService() throws NoSuchAlgorithmException, IOException {
mapper = new ObjectMapper();
......
package com.finconsgroup.xr4all.ecar.stream_client;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import com.finconsgroup.xr4all.ecar.stream_client.utils.PropertiesHelper;
import com.hivemq.client.mqtt.datatypes.MqttQos;
import com.hivemq.client.mqtt.mqtt3.Mqtt3BlockingClient;
import com.hivemq.client.mqtt.mqtt3.Mqtt3Client;
/**
* Example Usage of MessagePublisherService
*
*/
public class Publisher
{
public static void main( String[] args ) throws Exception {
......
......@@ -16,6 +16,10 @@ import javax.crypto.spec.SecretKeySpec;
import cpabe.Cpabe;
/**
* Singleton class handling the Cpabe operations
*
*/
public class CpabeManager {
private static CpabeManager cpabeManager = null;
......@@ -46,7 +50,10 @@ public class CpabeManager {
this.cpabe = new Cpabe();
}
/**
* Initialize and/or retrieve the CpabeManager instance according to the singleton pattern
* @return CpabeManager Instance
*/
public static CpabeManager getInstance(){
if(cpabeManager == null){
cpabeManager = new CpabeManager();
......@@ -55,11 +62,27 @@ public class CpabeManager {
return cpabeManager;
}
/**
* Encrypt a message using the {@code pubkey} and the specified {@code policy}
* @param policy The policy used to encrypt the message