An Android app that runs Elm in a webview. And a Python script to build the app or install it on the device.

Overview

Requirements

You need to have installed:
  • the Android SDK
  • Elm
  • Python
  • git

Starting a project

Clone this repo and cd into it:

$ git clone https://github.com/leforestier/elm-android-app
$ cd elm-android-app

Then run:

$ elm init

That will create an elm.json file in the current directory.

The entry point of your Elm application is src/Main.elm. This file contains a basic counter app that you can try to build to test that everything is working on your system.

To create a great app, modify src/Main.elm and add other Elm source files to the src/ directory .

To install additional elm packages, you can use elm install just like with any normal Elm project.

Build script

The script that enables you to build and/or install the app onto the device is manage.py. It's a single Python script without any dependencies. You can call it like this on the command line:

$ python manage.py (see next section for available commands)

On Linux you should be able to do simply:

$ ./manage.py (see next section for available commands)

To build an Elm application (running in a webview)

Keystore

First, and this is something you only have to do once per project, create a debug Android keystore using the command:

$ ./manage.py create-debug-key

This creates a keystore in the current directory under the file name debug.keystore.

Environment variables

You need to supply three environment variables to the script:

- BUILD_TOOLS_DIR: the directory of the Android SDK where reside tools such as `aapt` and `dx`.
  For example, I use `BUILD_TOOLS_DIR=/home/myusername/Android/build-tools/30.0.3/`

- PLATFORM_DIR: the directory of the Android SDK where reside `android.jar`.
  For example I use `PLATFORM_DIR=/home/myusername/Android/platforms/android-30/`

- KEYSTORE_FILE: the keystore file. If you created it by `manage.py create-debug-keystore`,
  then the file is `debug.keystore` and you should use `KEYSTORE_FILE=debug.keystore`

The rest of this tutorial assume you have exported these 3 environment variables using:

$ export BUILD_TOOLS_DIR=... PLATFORM_DIR=... KEYSTORE_FILE=...

Build the apk

Build an apk with the command:

$ ./manage.py build

The apk is created inside the build directory.

Install the app on an Android device

Make sure your device is connected to your computer in debug mode (you can use the command adb devices to check if your device appear in the list). Then:

$ ./manage.py install

You can also install the app and start it automatically using:

$ ./manage.py install+run

Changing the name of the application

You change the name of the application exactly like you would in a normal Java only android application.

The name of our example application is "Elm App" and our package name is com.example.elmwebviewapp. Here's how to change it, for, say, a bird watching application called "Bird Watch" with package name net.birdwatchers.birdspot.

To change the application name to "Bird Watch":

  • in AndroidManifest.xml replace android:label="Elm App" with android:label="Bird Watch"

To change the package name to net.birdwatchers.birdspot:

  • rename the directory java/com/example/elmwebviewapp to java/net/birdwatchers/birdspot
  • in MainActivity.java, replace the first line package com.example.elmwebviewapp; with package net.birdwatchers.birdspot;
  • in AndroidManifest.xml, replace the package="com.example.elmwebviewapp" manifest attribute with package="net.birdwatchers.birdspot"

Changing the icon of the application

Same as with a normal Java only android application. Refer to Android development documentation.

Viewing the app in the browser using elm-live

Before loading the app on the device, you can develop using elm-live and see your changes in the browser of your laptop/desktop. This requires to have installed elm-live.

Then:

$ ./manage.py elm-live

This is just a shortcut for:

$ elm-live src/Main.elm -d assets -- --output=assets/main.js
Owner
Benjamin Le Forestier
Benjamin Le Forestier
Hello World in different languages !

Hello World And some Examples in different Programming Languages This repository contains a big list of programming languages and some examples for th

AmirHossein Mohammadi 131 Dec 26, 2022
Simple macOS StatusBar app to remind you to unplug your laptop when sufficiently charged

ChargeMon Simple macOS StatusBar app to monitor battery charge status and remind you to unplug your Mac when the battery is sufficiently charged Overv

Rhet Turnbull 5 Jan 25, 2022
Script for resizing MTD partitions on a QNAP device in order to be available to upgrade from buster to bullseye

QNAP partitions resize for kirkwood devices. As explained by Marin Michlmayr, Debian bullseye support on kirkwood QNAP devices was dropped due to [mai

Arnaud Mouiche 26 Jan 05, 2023
This is a a CSMA/CA simulator written in Python based on simulator of the same type

This is a a CSMA/CA simulator written in Python based on simulator of the same type found the link https://github.com/StevenSLXie/CSMA-Simulator with

M. Ismail 4 Nov 22, 2022
Wordle is fun, so let's ruin it with computers.

ruin-wordle Wordle is fun, so let's ruin it with computers. Metrics This repository assesses two metrics about each algorithm: Success: how many of th

Charles Tapley Hoyt 11 Feb 11, 2022
Camera track the tip of a pen to use as a drawing tablet

cablet Camera track the tip of a pen to use as a drawing tablet Setup You will need: Writing utensil with a colored tip (preferably blue or green) Bac

14 Feb 20, 2022
Ice Skating Simulator for Winter and Christmas [yay]

Ice Skating Simulator for Winter and Christmas [yay]

1 Aug 21, 2022
Expression interpreter written in Python

Calc Interpreter An interpreter modeled after a calculator implemented in Python 3. The program currently only supports basic mathematical expressions

1 Oct 17, 2021
Lenovo Yoga Ideapad Autocharge

Description This program uses the conservation_mode of Lonovo Ideapad / Yoga not

1 Jan 09, 2022
Packages of Example Data for The Effect

causaldata This repository will contain R, Stata, and Python packages, all called causaldata, which contain data sets that can be used to implement th

103 Dec 24, 2022
A NetBox Plugin that gives a UI for generating, comparing and deploying configurations to devices.

netbox_config_plugin - A plugin to generate, compare and deploy configurations This plugin allows you to execute your code to generate a config for a

Jo 11 Dec 21, 2022
Explore related sequences in the OEIS

OEIS explorer This is a tool for exploring two different kinds of relationships between sequences in the OEIS: mentions (links) of other sequences on

Alex Hall 6 Mar 15, 2022
🦠 A simple and fast (< 200ms) API for tracking the global coronavirus (COVID-19, SARS-CoV-2) outbreak.

🦠 A simple and fast ( 200ms) API for tracking the global coronavirus (COVID-19, SARS-CoV-2) outbreak. It's written in python using the 🔥 FastAPI framework. Supports multiple sources!

Marius 1.6k Jan 04, 2023
reproduces experiments from

Installation To enable importing of modules, from the parent directory execute: pip install -e . To install requirements: python -m pip install requir

Meta Research 15 Aug 11, 2022
Tutorials on advanced python topics, and literate programming framework to write them.

Advanced course on Python3 This course covers several topics Python decorators The python object system / meta classes Also see my text on Python impo

Michael Moser 59 Dec 19, 2022
Py4J enables Python programs to dynamically access arbitrary Java objects

Py4J Py4J enables Python programs running in a Python interpreter to dynamically access Java objects in a Java Virtual Machine. Methods are called as

Barthelemy Dagenais 1k Jan 02, 2023
An addin for Autodesk Fusion 360 that lets you view your design in a Looking Glass Portrait 3D display

An addin for Autodesk Fusion 360 that lets you view your design in a Looking Glass Portrait 3D display

Brian Peiris 12 Nov 02, 2022
Audio-analytics for music-producers! Automate tedious tasks such as musical scale detection, BPM rate classification and audio file conversion.

Click here to be re-directed to the Beat Inspect Streamlit Web-App You are a music producer? Let's get in touch via LinkedIn Fundamental Analytics for

Stefan Rummer 11 Dec 27, 2022
A tool to help plan vacations with friends and family

Vacationer In Development A tool to help plan vacations with friends and family Deployment Requirements: NPM Docker Docker-Compose Deployment Instruct

JK 2 Oct 05, 2021
Just a little benchmark for scrapper PC's

PopMark Just a little benchmark for scrapper PC's This benchmark is for old computer that dont support other benchmark because of support. Like lack o

Garry 1 Nov 24, 2021