victordiaz / phonk Goto Github PK
View Code? Open in Web Editor NEWPHONK is a coding playground for new and old Android devices
Home Page: https://phonk.app
License: GNU General Public License v3.0
PHONK is a coding playground for new and old Android devices
Home Page: https://phonk.app
License: GNU General Public License v3.0
Add a logging mechanism that writes crash information in a .log file
I think the second should be the default for both view types but is nicer to have the option to change
Hi,
I'm working in an app to upload a picture to a server, and I'm experimenting a weird behavior. In the flowing code, when I use filename1 inside data it crashes, but when I use filename2 it works flawlessly, but both should be the same. Is it something I did wrong or is a bug? (btw, when it crashes, how can i read the log or see whats going on?)
Thanks Victor for your work, awesome project!
ui.addTitle(app.name)
var url = 'http://192.168.1.159:9000/addpic'
ui.addButton('Upload picture', 0.8, 0.6, 0.19, 0.09).onClick(uploadPicture)
function uploadPicture() {
var prefix = 'pic'
var num = 1
var extension = '.png'
// this two should be the same:
var filename1 = prefix + num + extension
var filename2 = 'pic1.png'
console.log(typeof(filename1))
console.log(typeof(filename2))
console.log('"' + filename1 + '"')
console.log('"' + filename2 + '"')
if (filename1 === filename2){
console.log("same")
}
else {
console.log("different")
}
// When I use filename2 here, it works. With filename1 it crashes
var data = [{ 'name' : 'userfile', 'content' : filename1, 'type' : 'file', 'mediaType': 'image/png'}]
network.httpPost(url, data, function (e) {
console.log(e)
})
}
Problem description
I was not able to download/install Phonk to my device through Play Store, it says that my device is not compatible. I downloaded the APK from phonk.io and it works perfect (as far as I have tested it), so it looks as it is compatible really.
I have had similar issues with other (few) apps and I am quite sure it happens because my tablet has an Intel Atom processor.
Device model
Lenovo Yoga Book (YB1-X90F)
Android version
7.1.1
Steps to reproduce the bug
In the description.
This duration + delay timing is uncomfortably slow for some purposes, like when user is expecting a fast UI update with new buttons and text. Would appreciate some way to adjust these values.
There is a few things that might be a bit difficult to grasp without a video tutorial, so I want to ask here if there is any request to make a tutorial or video tutorial of something in specific.
I start with this couple ideas as I've seen some interest and add more as requested
It is possible to wrap the scripts into an APK file for easy distribution. Not easy though.
If there is interest I will write a guide.
The Lat and Lon parameters are backwards in this initalisation.
Docs ref
Simple Repro:
/*
* Description Live map
* by Sam :)
*/
ui.addTitle(app.name)
console.log("Hello!");
var map = ui.addMap(0, 0, 1, 1);
map.center(1, 12);
map.zoom(3);
map.showControls(true);
var marker = null;
sensors.location.onChange(function (data) {
console.log("chg");
if(!marker){
console.log("new");
marker = map.addMarker({
lon: data.longitude,
lat: data.latitude
});
} else {
console.log("update", data);
marker.position(data.latitude, data.longitude);
}
console.log("marker", marker);
});
sensors.location.start()
console.log("sensor started");
Main website, while on desktop, it's easy to click in "APK File", however, on mobile, opens the PNG itself, not the link.
Problem description
As reported in #32
example Advanced / LiveCoding : when pressing Ctrl+Shift+X from the Web Editor, there is a very tiny unreadable line of text displayed temporarily at the bottom of the application on the tablet.
Device model
Acer Iconia B1-A71 tablet
Android version
Android 4.1.2.
Steps to reproduce the bug
Devices like Google Pixel show round icons in the launcher.
The current icon (squared) doesn't look nice inside the circle.
Problem description
As reported in #32
when testing Network / HTTP Server a error box appeared after i connected to the /helloworld page
: error : Method 'io.phonk.runner.apprunner.api.PUI.toast(string.number)' can't be found (HTTPServer#24). And once I leave this example, a dialog popup "The application PHONK was stopped".
Device model
Acer Iconia B1-A71 tablet
Android version
Android 4.1.2.
Steps to reproduce the bug
I'm guessing it should pop up an app chooser to edit the file? But it seems to crash the app.
Using the Web Editor is a workaround.
Would it be possible to integrate Firebase?
This would be great to log some data into a database or use the ML kit since you've already integrated the camera...
And you really should setup a donation button somewhere, because you have no clue how long I've searched for something like this :-)
The Idea
A command to close phonk and not only the current script.
What would be the benefit
Im currently trying to use phonk as a way to send mqtt commands quickly.
My idea was to create a script which just connect to the mqtt broker, send the message and then closes the app. Then i create a shortcut to the desktop and i would be able to send mqtt commands with one button press. However, the current app.close()
command only closes the script, but not the application and i end up on the script overview screen.
With an command to close the application you could create buttons to controll your applications easy and fast.
A basic workflow
would be more than enough
public Object parseBytes(byte[] bytes, String type) {
BluetoothBytesParser parser = new BluetoothBytesParser(bytes);
switch (type) {
case "uint8":
return parser.getIntValue(BluetoothBytesParser.FORMAT_UINT8);
case "string":
return parser.getStringValue(0);
default:
return null;
}
}
Ideally this section in PUtil.java should support more datatypes than just 8 bit values. Presumably BluetoothBytesParser supports more data types?
This API is added now to style the widgets (you can try it out already).
Is there any property that is interesting to add?
Example:
// change the main script theme
ui.setTheme({
background: '#000055',
primary: '#FF0000',
secondary: '#00FF00',
textPrimary: '#FFFF00',
animationOnViewAdd: true
})
// get the theme properties
console.log(ui.getTheme())
ui.addTitle(app.name)
var slider = ui.addSlider(0.1, 0.5, 0.8, 0.2).mode('drag').onChange(function (e) {
console.log(e)
})
// get all the slider properties
console.log(slider.getProps())
// change individual properties of a widget
slider.props.slider = "#00FF00"
var btn = ui.addButton('Click me', 0.1, 0.2, 0.8, 0.2).onClick(function () {
console.log('clicked')
})
// change many properties at once
btn.setProps({
background : '#00bbbb',
textSize: 50
})
When compiled as a debug version (when using Android Studio), Phonks include LeakCanary to catch and report memory leaks.
Would it be useful to share LeakCanary reports? Is so, how?...
I think Phonk fits quite nicely the requirements to be included in F-droid. I think it would be a very good channel to distribute it.
If there is somebody out there willing to include it to F-droid it would be neat.
Note:
Currently Phonk, needs 2 projects to work, the WebIde repo and this one (Android App). I guess it will have some implications for building the project for F-droid.
It would be nice so spread a bit the word about Phonk using certain websites and social networks. I'm not the greatest doing PR ๐ and somebody willing to help me on that would be supernice :)
I was able to compile the APK, but the examples are not included in the source code (in the assets folder, sot the compiled app has no examples available. Either include the examples to the source code or provide a method to add examples from a remote computer. (I would also like to get in touch with the developer(s) without writing github issues...)
Edit: I was able to copy the examples from the official app to the assets folder of phonk_apprunner (before recompiling)
It was suggested if PHONK could automate things based on system events. I will play with the idea and open this issue to keep track of things
Hello,
I've just discovered your project which seems quite promising.
I'm testing it on an Acer Iconia B1-A71 tablet with Android 4.1.2. (CPU: MTK8317T dual-cores 1.2GHz ; RAM : 512MB ; Display : 1024x600 ).
Unfortunaltely, none of APK 1.2.x could be installed on this device.
Only APK 1.0.0 installed and works with some bugs, errors and a few crashes when I test the examples.
If you want to extend the compatibility down to Android 4.1.2 or even 2.3.3, I could make some more tests for you if you need :-)
Hello again,
I'm testing the new Phonk 1.2.7 on my Acer B7-A71 tablet (Android 4.1.2).
Problem description
PHONK 1.2.x crashes when running example media/camera.
media.useCamera('back')
crashes PHONK because there is no back-camera.
media.useCamera('front')
works.
Device model
Acer B7-A71 tablet
CPU : MT6517 armv7l
GPU : PowerVR SGX 531
RAM : 512 MB
Display : 600x1024 @ 169 dpi
Android version
Android 4.1.2
API Level 16
OpenGL ES 2.0
Problem description
As reported in #32
example Advanced / Capture Notification displays this error dialog : Wrapped android.content.Activity/NotFoundException : No Activity found to handle Intent { act=android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS } (Capture Notification)
Device model
Acer Iconia B1-A71 tablet
Android version
Android 4.1.2.
Steps to reproduce the bug
I appreiciate your work. It's very handy for beginners.
When trying the SMS function I faced an error.
Blackberry Key 2 (BBF100-6)
Android 8.1.0 (Kernel 4.4.78...) Security Patch May 2020
Phonk Version 1.2.5 normal / extended (from github, tried both versions)
calling the function
smsSend(012345,'test')
throws the error Wrapped java.lang.SecurityExeption: Sending SMS message: uid 10238 does not have andoird.permissionSEND_SMS.
https://support.google.com/googleplay/android-developer/answer/9047303?hl=en
I granted all permissions Phonk asked for. The android settings menu says that the app has permission to send SMS.
Problem description
As mentioned in #32
example GUI / Maps (OpenStreetMaps) : It does not display any map. The background is a gray grid with a "MAPS (OPENSTREEMAPS)" title in bold yellow, a red circle, a cyan circle, two blue segments and a pinpoint-location icone. Zooming and scrolling moves them randomly.
Device model
Acer Iconia B1-A71
Android version
4.1.2
Steps to reproduce the bug
There is a few missalignments on tablets both vertical and horizontal
There is some suggestions to include ARCore into PHONK. That would be quite neat. Since the only way to add 3d is through Processing, maybe having a look on how Processing adds ARCore would be handy.
It would be great to create a few tutorials or script showcases that people can learn from and get inspired.
I could suggest something like:
Hello again !
When I run the Background App example, the background-app show up into my notification list.
And when I click/touch it into the notification list, the screen turn black and a tiny box at the bottom says "The script has crashed :(" and the PHonk application seems to reboot.
Device model
Acer Iconia B1-A71 tablet with Android 4.1.2
Steps to reproduce the bug
Run the Background App example, open the notification list, click/touch the "Background app" notification.
Phonk uses Mozilla Rhino interpreter to execute the scripts as it binds very easily with Java.
Although it works quite nicely, it feels a bit old. There is no support of ES6 among other things.
Maybe somebody with experience out there? :)
Code edits I make to my project on both the mobile text editor and the web editor do not take effect the next time I save and run my project. As a workaround, I have to do to following:
Save my changes
Stop the webserver
Remove the app from recent apps ("kill it")
Re-open PHONK
Start my project (works from web editor and phone)
I am using a OnePlus 5 (version w/ 6GB ram, 64GB storage) on Android 10 (Oxygen OS 10.0.0). App is version 1.2.7_normal
To reproduce, open the project, edit in web browser, and run the project. Stop, save new changes, then run again, and old behavior persists.
Problem description
As reported in #32
Processing and LibPd crash on Android 4.1
Device model
Acer Iconia B1-A71 tablet
Android version
Android 4.1.2.
Steps to reproduce the bug
Problem description
Crash on script launching
https://pastebin.com/acSt8gJW
Device model / Android Version
Redmi Note 8 (Android 10 custom rom)
Steps to reproduce the bug
Launch a script from the device or the Web Editor
List:
Problem description
As reported in #32
The text into the kind of error box is very small an almost unreadable (but i've just noticed they appear into the Console box of the WebEditor too).
Device model
Acer Iconia B1-A71 tablet
Android version
Android 4.1.2.
Steps to reproduce the bug
I am exploring this awesome PHONK project.
In the main.js file, if I write only one line Camera.turnOnFlash(true)
and run the PHONK project, then should it turn the flash on? I tried this after looking in the Reference guide, but it is not working. I also tried below lines:
camera.turnOnFlash(true)
device.Camera.turnOnFlash(true)
device.camera.turnOnFlash(true)
But none of these are working. This is the error showing in the Console in the PHONK editor in web browser:
ReferenceError: "Camera" is not defined. (test proj#1)
Am I missing anything? Am I doing any mistake? Or is there any bug?
I tried these in my phone Moto X Play (XT1562) with Android 7.1.1 (Nougat).
Right now is just a "square" dummy icon.
Problem description
Not sure if this is already done and I have just not seen it: I use to use Phonk to develop right in my tablet using physical keyboard. This setting force me to use my tablet in landscape mode. Then when I run the program, the orientation of it is portrait, which is not convenient. Is there any change to tell Phonk I want to stay landscape, so it draws the UI I program landscape (x, y, text orientation, etc)?
Hint: the device information bubble tells me that Phonk recognizes my tablet is in landscape mode and also the embedded IDE is in perfectly comfortable landscape setup.
Hint: it is clear that Phonk knows the orientation of my device even during the run of my code, because if I turn it, the program will restart when going from landscape to portrait (or vice versa) - So the onPause-onResume cycle happens, even though the UI will not change at all.
Device model
Lenovo Yoga Book (YB1-X90F)
Android version
7.1.1
Steps to reproduce the bug
Use Phonk in landscape mode, run a program with UI. If you don't turn the Android device, the coordinates of your elements will be 0,0 in the bottom-left corner, the text will appear vertical (bottom to top).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.