This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Piorjade's profile picture

[CC 1.79] [Adv. Pocket Computer] craftAndroid [WIP]

Started by Piorjade, 17 February 2017 - 06:51 PM
Piorjade #1
Posted 17 February 2017 - 07:51 PM
craftAndroid - The OS for Adv. Pocket Computers

Information:
Spoiler
  • This OS uses cLinux as it's "kernel", tho has its own "core" ontop of it, which manages all of the tasks in the taskmanager, installing packages and making notifications
  • The core has 3 built-in buttons: back, home and the tasklist-button (which currently only shuts the system down)
  • The home button automatically minimizes your current application, kills the old launcher-task and makes a new one (this is to refresh the applist for example)
  • The back button queues an event, instead of really doing anything. This is useful for apps, as they have the ability to use that button for their own purpose (it queues "craftAndroid_back")
  • The tasklist button currently only shuts the system down. (I plan on letting it start up a default taskmanager)
  • You can make your own "app-launcher" / home-menu and make it the default one ("launcher" is the stock one and cannot be removed)
  • There are 3 extra built-in apps that cannot be removed: settings, pastebin downloader (single file only) and notifier
    • Settings currently allows you to customize the "launcher" app (background color and text color), to enable or disable the rednet API (but doesn't open the modem) and to remove user-made apps (system apps are not displayed)
    • The pastebin downloader downloads a single file and installs it as an app
    • The notifier lets you see notifications that are made by other apps (and app_crash) (NOTE: they aren't saved after a reboot)
  • There is also a testingapp that makes a notification on startup (don't get scared when starting it, it's supposed to be a black screen, just press the homebutton)

The APIs available for apps:
lib.craftAndroid:
Spoiler
  • lib.craftAndroid.goHome()
  • Is the same as pressing the homebutton, the current app gets minimized, not killed
  • lib.craftAndroid.taskmanager.runApp([string appName], [bool visible])
  • Tries to run an app. Displays the errorwindow if it failes (and it makes a notification)
  • lib.craftAndroid.displayCrash([string appName])
  • Displays the errorwindow (It says: [appName] crashed.)
  • lib.craftAndroid.udBackBtn(, )
  • Changes the colors of the back button
  • lib.craftAndroid.udHomeBtn(, )
  • Changes the colors of the home button
  • lib.craftAndroid.udTlBtn(, )
  • Changes the colors of the tasklist button

lib.candroid:
Spoiler
  • lib.candroid.package.install([string encryptedPackage])
  • Installs a package
  • lib.candroid.package.remove([string name])
  • Removes a package, if it's not a system-app
  • lib.candroid.package.list()
  • Returns a table of all installed packages (the keys are the names of the packages, the value is a table containing the type of the package and the size) Example:
    
    local t = lib.candroid.package.list()
    --Table of all packages
    --The package "launcher" looks like this:
    --t.launcher = {
    --  type = "system",
    --  size = 0,
    --}
    
  • lib.candroid.config.get([string appName], [string configName], [string variable])
  • Returns the value of the given variable, which is inside the given configfile of the given app
  • lib.candroid.config.set([string appName], [string configName], [string variable], [value])
  • Sets the value of the given variable, which is inside the given configfile of the given app
  • lib.candroid.config.create([string appName], [string configName], [table config])
  • Creates the specified configfile for the given app optionally using the given table of values
  • lib.candroid.config.exists([string appName], [string configName])
  • Returns nil if the app is not found, returns false if the config is not found and returns true if both is found
  • lib.candroid.config.getWhole([string appName], [string configName])
  • Returns a copy of the config file (table)
  • lib.candroid.notification.notify([string appName], [string message])
  • Makes a notification (puts it into the _NOTIFICATIONS table inside the core)
  • lib.candroid.notification.getList()
  • Returns a copy of the _NOTIFICATIONS table from the core
  • lib.candroid.notification.clearApp([string appName])
  • Clears the list of messages from a specific app (the table for the app is still there) Returns true if it succeeded Returns false if it couldn't find the app
  • lib.candroid.clearAll()
  • Clears the whole _NOTIFICATIONS table

Information on packages:
Packages are simply SERIALIZED tables containing minimal metadata for the package and every file/folder it includes. They are also encrypted using the password "cAndroid". (Here is the encryption API)
Example package:

{
  files = {
    "startup",
  },
  folders = {

  },
  fileData = {
    "print('hello')", --The fileData table is sorted for the order of the files, meaning that the first entry belongs to the first file in the files table
  },
  name = "myApp",
  type = "user",
  size = 0,
}
Now you only need to serialize and encrypt this table using the given API

NOTE: If you want to use a custom icon for the app, make a file called "img" (should be inside the "root" of the package) (should be made with paint)

Credits:
PixelToast - The encryption API

Screenshots:
Here's a gallery.

Download / Code:
NOTE: There is currently no pastebin downloader, as it's still WIP and I didn't have the time for it. To download, download the ZIP from GitHub and put it into your folder of your Adv. Pocket Computer
GitHub
ObloxCC #2
Posted 17 February 2017 - 09:30 PM
Icons look kind of tight, but other than that it looks good
GreenByteSoftware #3
Posted 27 March 2017 - 01:51 PM
If you need to just clone all the files run this:
pastebin run W5ZkVYSi Piorjade craftAndroid