Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Android camera app #11

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0a2fa70
Can use the camera in the app.
niccokunzmann Jun 20, 2018
84b75f8
use backfacing camera
niccokunzmann Jun 20, 2018
b5778f1
use maximum available resolution
niccokunzmann Jun 20, 2018
8604c7a
Android app is compatible with Android 2.3
niccokunzmann Jun 22, 2018
6ae7374
cannot use parse because of dependency problems
niccokunzmann Jun 26, 2018
dcfbf79
order elements
niccokunzmann Jun 26, 2018
e6d19fc
log output onCreate
niccokunzmann Jun 26, 2018
af1d0dc
ignore cache
niccokunzmann Jun 26, 2018
6ef139a
add inputs for ip and port
niccokunzmann Jun 26, 2018
0b6e23f
describe the API which is provided to the app
niccokunzmann Jun 26, 2018
3ba1ef6
explain the API more
niccokunzmann Jun 26, 2018
5330392
add posting method
niccokunzmann Jun 26, 2018
2892bea
can post without dying
niccokunzmann Jun 26, 2018
50a159d
content type of API requests
niccokunzmann Jun 26, 2018
f6b0446
refactor port into default variable
niccokunzmann Jun 26, 2018
5c9bd3a
can notify book scanner about app
niccokunzmann Jun 26, 2018
6cb661b
meaningful error message if parse server is not started
niccokunzmann Jun 27, 2018
e89b23a
openbookscanner is running
niccokunzmann Jun 27, 2018
6abd5f7
using daemon execution of thread to abort program
niccokunzmann Jun 27, 2018
b773ba0
refactor treadsave transitioning out of running state
niccokunzmann Jun 27, 2018
4b1303e
Fix Error: could not serialize dict to JSON
niccokunzmann Jun 27, 2018
8673cbe
print traceback of flask requests
niccokunzmann Jun 27, 2018
b6517a7
transitioning into states depending on timeout
niccokunzmann Jun 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions software/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ ENV
*.pyc
__pycache__
.pytest_cache
OpenBookScannerApp_
78 changes: 78 additions & 0 deletions software/OpenBookScannerApp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
/.idea/caches
.DS_Store
/build
/captures
.externalNativeBuild

# from https://github.com/github/gitignore/blob/master/Android.gitignore

# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches

# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

# Google Services (e.g. APIs or Firebase)
google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
29 changes: 29 additions & 0 deletions software/OpenBookScannerApp/.idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions software/OpenBookScannerApp/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions software/OpenBookScannerApp/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions software/OpenBookScannerApp/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions software/OpenBookScannerApp/.idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions software/OpenBookScannerApp/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions software/OpenBookScannerApp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# OpenBookScannerApp

This Android App takes the pictures and registers as a scanner.
You can develop this app with Android Studio 3.1.3.
This app is compatible with old phones until Android 2.3.

## API

The OpenBookScannerApp requires this API endpoint:

- `POST /scanner` with data
Headers:
- `Content-Type: application/json`
```
{
"type": "scanner",
"name": "<name of the phone>",
"id": "random id for this run of the app"
}
```
The attributes have the following meaning:
- `type` is `"scanner"` because this is what the app is going to do.
- `name` is the name of the device which should be displayed.
- `id` is the id of the scanner as there might be multiple devices of the same name.
This results in `200`.
Headers:
- `Content-Type: application/json`
- if no picture shall be taken:
```
{
"status": "ok",
"refresh": 0.5
}
```
- if a picture shall be taken:
```
{
"status": "ok",
"refresh": SECONDS,
"picture": "<full url>"
```
These are the values explained:
- `status` should be `"ok"`. Otherwise, there was an error.
- `refresh` is the seconds as float
when to re-post to keep the scanner active.
- `picture` is the full url including `http://hostname:port/path` where
to post the picture once taken.
Method: `POST`
Headers:
- `Content-Type: image/jpeg`

## Thanks

- Big thanks to [isnotmenow](https://github.com/isnotmenow/AndroidProjectForAPI9)
for the [APIv9 app](https://github.com/isnotmenow/AndroidProjectForAPI9).
1 change: 1 addition & 0 deletions software/OpenBookScannerApp/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
33 changes: 33 additions & 0 deletions software/OpenBookScannerApp/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
defaultConfig {
applicationId "com.github.fablabcb.openbookscannerapp"
minSdkVersion 9
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:support-v4:25.4.0'
implementation 'com.android.support:appcompat-v7:25.4.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
// implementation 'com.parse:parse-android:1.17.3' // http://docs.parseplatform.org/android/guide/ needs version 14+
testImplementation 'junit:junit:4.12'

// this is the last support test for api >= 9
androidTestImplementation 'com.android.support.test:runner:1.0.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.0'
implementation 'com.android.support:design:25.4.0'
}
21 changes: 21 additions & 0 deletions software/OpenBookScannerApp/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.github.fablabcb.openbookscannerapp;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.github.fablabcb.openbookscannerapp", appContext.getPackageName());
}
}
28 changes: 28 additions & 0 deletions software/OpenBookScannerApp/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.fablabcb.openbookscannerapp">
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity
android:name="com.github.fablabcb.openbookscannerapp.MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

</manifest>
Loading