Git Product home page Git Product logo

phonk's Introduction

PHONK

github version PRs welcome

PHONK is a coding playground for new and old Android devices.

Create scripts rapidly from your phone or using the remote Web Editor on your computer using Javascript. The API is simple and extensive. GUI, audio, graphics, Bluetooth BLE, Arduino, OSC, MIDI, and much more.

PHONK WebsiteTutorialForumDiscord

animation

Features

  • Takes 1 min to set up on your phone
  • No need to install anything on your computer
  • PHONK uses JavaScript but it calls native Java functions, getting close to native speed
  • Simplified API. Create custom interfaces and access on-device sensors in a couple of lines of code
  • Pseudo Live Coding (select your code and Control (or Cmd) + Enter to live execute)
  • Bluetooth and Arduino in a few lines of code
  • MQTT, HTTP requests, WebSockets, OSC, MIDI
  • Access to Processing.org API
  • Use your PureData skills thanks to the embedded LibPd
  • OpenStreetMaps and muuuch more!

How to install it

Get it from

If you have an Android phone with a version higher than 4.1 (that's from 2012!) then it should work! If you find a problem, please create an issue.

During the first install, the app will

  1. Ask you for a bunch of permissions. I recommend accepting all of them to be able to run the examples. You can always revoke them :)
  2. Install the examples in the device "sdcard" folder. Doing this we can easily access the examples and self-made scripts from any other app.

How to create your first script

Check the Getting started guide for a more detailed explanation

Run the PHONK app in your Android device. You can create your first script within the device, although it might be a bit cumbersome using the device virtual keyboard.

Instead, connect your computer and Android to the same Wi-Fi network. On your computer open the browser and type the IP address indicated on your phone after pressing "Start web editor". A web editor will load, allowing you to code on the phone.

You can create a new project and copy and paste this into the editor.

// ui elements need x, y, w, h normalized paramaters
ui.addButton('Start accelerometer', 0.1, 0.45, 0.8, 0.1).onClick(function () {
  sensors.accelerometer.start()
})

sensors.accelerometer.onChange(function (e) {
  console.log(e.x, e.y, e.z)
})

Now run the project. 🎉

You can explore the variety of examples included in PHONK and modify them in order to explore its capabilities.

Compile it yourself

PHONK depends on 3 subprojects contained in this repository.

  1. PHONK-android. The main PHONK Android project.
  2. PHONK-editor. The Web Editor written in an old version of Vue.js
  3. PHONK-examples. The examples

In order to compile PHONK you also need to:

  1. Copy the examples into the main app assets folder. In PHONK-examples run npm run cleanAndDeploy
  2. Build and copy the WebEditor into the main app assets folder. In PHONK-editor npm run cleanBuildAndDeploy
  3. Run the Android project using Android studio

Once you've done that, there is no necessity to do the first steps anymore unless you want to update the Web Editor or the examples.

Project structure

The PHONK app is divided into two modules: phonk_app and phonk_apprunner.

  • phonk_app is the app that you see when you start PHONK and it manages all the stuff to let you make projects.
  • phonk_apprunner is the part in charge of running the scripts and it contains all the API. If you want to add or improve the API you can go to the folder phonk/phonk_apprunner/src/main/java/io/phonk/runner/apprunner/api. All the methods you include there will automatically be exposed to JavaScript.

Get Involved

  • Write about it
  • Make something with PHONK.app and tell me about it. I would love to know how you use it. (GitHub, e-mail, etc.)
  • Have a look at the issues

Roadmap

  • Getting started guide
  • Improve documentation
  • How-to-contribute guide

License

This project is licensed under the terms of the GPL / LGPL v3 License. You can check out the full LICENSE description on the file LICENSE.txt.

phonk's People

Contributors

adasq avatar baptistelabat avatar boriskohen avatar chocolateboy avatar dependabot[bot] avatar polhomarkho avatar rerpha avatar tophercantrell avatar victordiaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phonk's Issues

Code changes do not take effect until PHONK is restarted.

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.

Video tutorials? suggestions?

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

  • Sound synth using LibPd (Pure Data)
  • How to live-execute code

Any chance to develop the UI for landscape orientation?

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).

Is there any problem with Camera.turnOnFlash(true)?

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).

Processing / LibPd crashes on Android 4.1

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

tablet layout alignments

There is a few missalignments on tablets both vertical and horizontal

  • Installing the app
  • While on the main view

Update the JS interpreter with something more modern

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? :)

title in buttons is not displayed

it's appears only on devices with kitkat (android 4.4).
affected 1.2.0 and 1.2.2 versions. affected installation wizard and projects view.
Screenshot_2020-06-29-15-57-47

Advanced / Capture Notification error

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

Add examples to assets folder

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)

Add Continous Integration

A basic workflow

  • Check if project compiles
  • Check if examples run without issues

would be more than enough

Typo in Settings option

In-App Settings show "hided" instead of "hidden"

  1. Launch mobile app
  2. Navigate to Settings
  3. Under "Mask the Web Editor address" -> "The IP address will be hided as..."

image

PHONK for background automation

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

media.useCamera('back') crashes on tablet when no back-camera available

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

Lat and Lon mixed up on adding map marker

GeoPoint loc = new GeoPoint((double) params.get("lon"), (double) params.get("lat"));

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");

slider and knob with different behaviour

  • The slider moves exactly to the place you touch,
  • Knob needs to touch and then move

I think the second should be the default for both view types but is nicer to have the option to change

Upload to F-droid

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.

Firebase integration

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 :-)

HTTP Server crash app on exit

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

different behavior when it should be the same

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)
  })
}

LeakCanary?

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?...

Util.parseBytes only supports chars

    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?

Draft: Theming and Styling views

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
})

Output:
photo_2020-07-04_20-06-07

Spreading the word about Phonk

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 :)

APK 1.2.x do not install on Android 4.1.2

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 :-)

Idea: close app with a command

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.

example Advanced / Background App displays "script has crashed"

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.

OpenStreetMaps do not work on Android 4.x.x

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

Add events on information box

  • XXX.XXX.XXX.XXX connected / disconnected
  • load project
  • save project
  • start / stop server
  • connection changed: WIFI / Celular
  • open settings / about / editor
  • file uploaded
  • file load / save

ARCore integration

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.

app console has small font size

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

Unable to download it via Play Store (incompatible device)

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.

LiveCodingOverlay has small font size

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

Create tutorials and/or showcases

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:

  • Simple videogame
  • Musical instrument
  • Small robot with an Arduino attached
  • Controlling lights using MQTT

No Permission to send SMS, smsSend()

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.
Screenshot_20200708-105759

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.