I’m sorry I do not know how use tools you’re using in your community, this below
I. How to transfer a Processing Web App to Android App?
First approach: transfer the Web on Processinginto IntelliJ
On the early beginning of the project I searched “how to do” into Google. I usedthose keywords: “install processing IntelliJ windows 10” and then look at the tutorialeditedby Margot Rutgers on June 3, 2016 through the link below:
How to develop an Android app with IntelliJ?
Used Google key-words : “intellij install android module”
Other issues investigated:
cordova
Mobile apps with HTML, CSS & JS
Target multiple platforms with one code base
Free and open source
First TO DO list
After those several searches, I arrived to this TO DO list:
- Configuration processing plugin on IntelliJ
- Implementation of existing JavaEE solutions on IntelliJ
- Transfer on Android App on IntelliJ
- Study the use of this application under Android Studio of JetBrains like IntelliJ
- Study the use of the open source solution Cordova
Why my first TO DO list failed?
Once I began to work with Processing, I discovered that the whole project can be export as an Android Project within few clicks.
And if I could finally use Processing directly into Android Studio?
Used Google key-words: “processing with android studio” Do
II. Studying the lead of this project with another point of view
Using processing directly for the transfer to Android App
Useful link:
What I did on June 11st 2019
⦁ Installations of all librariesrequired
⦁ Software isworking
⦁ Android extension install on Processing
⦁ Android projectbuilt on Processing
⦁ Download android studio
⦁ Transferedproject to android studio
⦁ I can work the project directly on android studio
Step-by-step: Initial code
We found below the folder containing Progessing code (Java languThese classes are well documented and represent tools of sketch_3615_neuro_vivo :
• Attractor
• Boundary
• Mover
• Surface
Commentas far as possiblesketch_3615_neuro_Vivoand do not use the parts of acquisition through webcam (it will be done if I have the time thereafter).
Once done I transferred to Android and open with Android Studio
This is great job! But as doing without the first TO DO list planned, I forget one important fact: how to use the software without keyboard?
Use Button with Android Studio directly
On our application it was impossible to deal with button on first plan and processing design on the second.
I tried several things such as below while using those kinds of link:
/**END OF VOID DRAW **/
/**
* START CUSTOMIZED THE APP BY MAXIME
**/
Button b1;
Button b2;
Button b3;
Button b7;
Button b9;
/**STOP CUSTOMIZED THE APP BY MAXIME**/
/**
* STARTING VOID KEYRELEASED ie. what happened once we touch the keyboard
**/
void keyReleased() {
if (key == 's' || key == 'S') saveFrame(timestamp() + "_##.png");
switch (state) {
case 0:
// WAITING
if (b1.isPressed()) {
mode = 1;
state = 10;
} else if (b2.isPressed()) {
mode = 2;
state = 1;
} else if (b3.isPressed()) {
mode = 3;
state = 1;
}
break;
case 1:
// IF NEEDED, CHOICE OF PARAMS
// WAITING
if (b1.isPressed()) {
objectifValence= 25;
objectifArousal= 25;
state = 10;
} else if (b3.isPressed()) {
objectifValence= 75;
objectifArousal= 25;
state = 10;
} else if (b7.isPressed()) {
objectifValence= 25;
objectifArousal= 75;
state = 10;
} else if (b9.isPressed()) {
objectifValence= 75;
objectifArousal= 75;
state = 10;
}
break;
case 20:
if (key == ' ') state = 30;
break;
}
}
/**END OF VOID KEY RELEASED **/
III. Implementation of processing code directly on Android studio
Search key-word on Google: “Use processing with android studio “
- Implementation of sketch module following tutorial linked below
I’m already at the step 6, right write Sketch and not sketch for the Java class: I lost almost the day before to deal with it !
Once done, processing library isn’t taking into account:
⦁ Go to file ??Project structure ??Modules ?? “+”?? import.JAR package?? set the .JAR of Processing module
Than “apply and “OK”
Once, the library is taken into account
IV. Make a button using processing
Key word on goggle : “create button processing for android”
Install a library ?
The code in the link above in Processing and transfer it into android studio and have on AVD such as below:
The “Special Sketch Android Button” is on Android Studio
Android Studio MainActivity is:
package processing.test.sketch_proto_button_android;
import android.os.Bundle;
import android.content.Intent;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.support.v7.app.AppCompatActivity;
import processing.android.PFragment;
import processing.android.CompatUtils;
import processing.core.PApplet;
public class MainActivityextends AppCompatActivity {
private PAppletsketch;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FrameLayout frame = new FrameLayout(this);
frame.setId(CompatUtils.getUniqueViewId());
setContentView(frame, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
sketch = new sketch_proto_button_android();
PFragment fragment = new PFragment(sketch);
fragment.setView(frame, this);
}
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
if (sketch != null) {
sketch.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
@Override
public void onNewIntent(Intent intent) {
if (sketch != null) {
sketch.onNewIntent(intent);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (sketch != null) {
sketch.onActivityResult(requestCode, resultCode, data);
}
}
@Override
public void onBackPressed() {
if (sketch != null) {
sketch.onBackPressed();
}
}
}
The special Sketch is:
package processing.test.sketch_proto_button_android;
import processing.core.*;
public class sketch_proto_button_androidextends PApplet {
/** PARAM NEEDED FOR THE BUTTON**/
int buttonX, buttonY; // Position of button
int buttonSize= 90; // Diameter of rect
int buttonColor; //default color
int buttonHighlight; //color once we on it
booleanbuttonOver= false; // We by definition outside the button
/**VOID SETUP OF THE SKETCH**/
public void setup() {
buttonColor= color(0);
buttonHighlight= color(255);
buttonX= width-width/2-buttonSize/2; //position X of button
buttonY= height-height/2-buttonSize/2; //position Y
}
/**VOID DRAW OF THE SKETCH**/
public void draw() {
update(mouseX, mouseY);
background(255);
if (buttonOver) {
fill(buttonHighlight);
} else {
fill(buttonColor);
}
stroke(0);
rect(buttonX, buttonY, buttonSize, buttonSize);
}
/**VOID UPDATE WHICH ALLOWS TO FOLLOWS IF BUTTON IS OVER OR NOT**/
public void update(int x, int y) {
if ( overButton(buttonX, buttonY, buttonSize, buttonSize) ) {
buttonOver= true;
}
else buttonOver= false;
}
/**BOOLEAN METHOD ALLOWING TO RETURN TRUE OR FALSE TO THE UPDATE VOID**/
public booleanoverButton(int x, int y, int width, int height) {
if (mouseX>= x &&mouseX<= x+width&&
mouseY>= y &&mouseY<= y+height) {
return true;
} else {
return false;
}
}
}
Its main.xlm layout is
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragment"
android:name=".sketch_proto_button_android"
tools:layout="@layout/fragment_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
V. “Special Sketch Android Button”
Give functionalities to this button
The used Void keyReleased into software is as below, I need to base on it to transfer keyboard entries to custom made buttons.
/**STARTING VOID KEYRELEASED ie. what happened once we touch the keyboard**/
public void keyReleased() {
if (key == 's' || key == 'S') saveFrame(timestamp()+"_##.png");
/** Below is in comments as we do not use the camera for now**/
/**if (key == 'c' || key == 'C')
{
modeCamera = !modeCamera;
if (modeCamera == false)
{
bg = loadImage("bg.png");
}
}**/
switch (state)
{
case 0:
// WAITING
if (key == '1')
{
mode = 1;
state = 10;
} else if (key == '2')
{
mode = 2;
state = 1;
} else if (key == '3')
{
mode = 3;
state = 1;
}
break;
case 1:
// IF NEEDED, CHOICE OF PARAMS
// WAITING
if (key == '1')
{
objectifValence= 25;
objectifArousal= 25;
state = 10;
} else if (key == '3')
{
objectifValence= 75;
objectifArousal= 25;
state = 10;
} else if (key == '7')
{
objectifValence= 25;
objectifArousal= 75;
state = 10;
} else if (key == '9')
{
objectifValence= 75;
objectifArousal= 75;
state = 10;
}
break;
case 20:
if (key ==' ') state = 30;
break;
}
}
/**END OF VOID KEY RELEASED **/