Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1 from maxisoft/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
maxisoft authored Nov 11, 2020
2 parents 4f80a18 + 08b7bcc commit db55016
Show file tree
Hide file tree
Showing 237 changed files with 1,345 additions and 243 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Android Pull Request & main CI

on:
pull_request:
branches:
- main
- dev
push:
branches:
- main
- dev

jobs:
test:
name: Run Unit Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Unit tests
run: bash ./gradlew test --stacktrace

apk:
name: Generate APK
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build debug APK
run: bash ./gradlew assembleDebug --stacktrace
- name: Upload APK
uses: actions/upload-artifact@v1
with:
name: app
path: app/build/outputs/apk/debug/app-debug.apk
48 changes: 48 additions & 0 deletions .github/workflows/signed_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Android Release Signed

on:
push:
branches:
- main
- dev

jobs:
test:
name: Run Unit Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Unit tests
run: bash ./gradlew test --stacktrace

apk:
name: Generate APK
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build release APK
run: bash ./gradlew assembleRelease --stacktrace

- uses: jobobby04/sign-android-release@v1.0.3
with:
releaseDirectory: app/build/outputs/apk/release
signingKeyBase64: ${{ secrets.signingKeyBase64 }}
alias: ${{ secrets.alias }}
keyStorePassword: ${{ secrets.keyStorePassword }}
keyPassword: ${{ secrets.keyPassword }}

- name: Upload APK
uses: actions/upload-artifact@v1
with:
name: app
path: ${{ env.SIGNED_RELEASE_FILE }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,4 @@ fabric.properties
.externalNativeBuild
.cxx
local.properties
/app/release/output-metadata.json
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Auto Attestation
<img src="https://raw.githubusercontent.com/maxisoft/AutoAttestation/dev/app/src/main/res/raw/web_hi_res_512.png" alt="logo" width="100"/>
Application Android libre pour faire une attestation simplement, sans tracker et sans internet

## Disclaimer
- Cette application n'est **pas officielle**.
- Aucune garantie sur le fait que les données (e.g. *documents pdf*, *codes qr*) produits par cette application soient valides et/ou conformes à quoi que ça soit.
- Voir le fichier *LICENSE* pour d'autres disclaimers effectifs.

## Fonctionalitées
- Générer une attestation en mode qrcode similaire à l'application [TousAntiCovid](https://play.google.com/store/apps/details?id=fr.gouv.android.stopcovid)
- Générer une attestation PDF similaire au site [Générateur de certificat de déplacement](https://media.interieur.gouv.fr/deplacement-covid-19/)

## Design et philosophie
Le but principal de cette application est de pouvoir créer des attestations au moins aussi simplement que l'application [TousAntiCovid](https://play.google.com/store/apps/details?id=fr.gouv.android.stopcovid) et ce sans contenir de code directement lié à la communication réseau / pistage.
Pour ce faire l'application est conçue pour utiliser exclusivement des logiciels/librairies [FLOSS](https://fr.wikipedia.org/wiki/Free/Libre_Open_Source_Software) tout en étant elle même publiée sous licence libre.
De plus l'application ne possede pas l'autorisation de communiquer en réseau.
Enfin l'application enregistre comme information personelle le strict minimum nécessaire à son fonctionement. La totalité des informations enregistrées sont à tout moment supprimables en utilisant la fonctionalité native "Effacer données application" d'Android.

## Captures d'écran
14 changes: 12 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}

testOptions {
unitTests.includeAndroidResources = true
}

}

dependencies {
Expand All @@ -42,7 +47,10 @@ dependencies {
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.cardview:cardview:1.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
Expand All @@ -52,5 +60,7 @@ dependencies {
implementation 'com.google.zxing:core:3.3.2'
implementation 'com.tom_roush:pdfbox-android:1.8.10.1'
implementation "com.squareup.moshi:moshi-kotlin:1.11.0"

implementation "com.squareup.moshi:moshi-adapters:1.11.0"
implementation 'com.takisoft.preferencex:preferencex:1.1.0'
implementation 'com.takisoft.preferencex:preferencex-datetimepicker:1.1.0'
}
18 changes: 0 additions & 18 deletions app/release/output-metadata.json

This file was deleted.

27 changes: 23 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="io.github.maxisoft.autoattestation">
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />

<uses-sdk tools:overrideLibrary="com.dr1009.app.chronodialogpreference" />
<application
android:name=".Application"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:supportsRtl="false"
android:theme="@style/Theme.AutoAttestation">
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">

<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/fileprovider" />
</provider>

<activity
android:name=".AttestationSummary"
android:screenOrientation="portrait"
android:theme="@style/Theme.AutoAttestationSummary"/>
<activity
android:name=".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>
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
package io.github.maxisoft.autoattestation

import androidx.multidex.MultiDexApplication
import com.squareup.moshi.Moshi
import com.squareup.moshi.adapters.Rfc3339DateJsonAdapter
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import com.tom_roush.pdfbox.util.PDFBoxResourceLoader
import java.util.*


class Application : MultiDexApplication() {
override fun onCreate() {
super.onCreate()
PDFBoxResourceLoader.init(this)
}

companion object {
val moshi: Moshi by lazy {
Moshi.Builder()
.add(Date::class.java, Rfc3339DateJsonAdapter())
.addLast(KotlinJsonAdapterFactory())
.build()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package io.github.maxisoft.autoattestation

import android.content.Context
import android.content.Intent
import android.graphics.Paint
import android.graphics.Point
import android.os.AsyncTask
import android.os.Bundle
import android.util.TypedValue
import android.view.View
import android.view.WindowManager
import android.widget.ImageButton
import android.widget.ImageView
import android.widget.TextView
import androidmads.library.qrgenearator.QRGEncoder
import androidx.appcompat.app.AppCompatActivity
import com.squareup.moshi.JsonAdapter
import io.github.maxisoft.autoattestation.Application.Companion.moshi
import io.github.maxisoft.autoattestation.attestation.AttestationGenerator
import io.github.maxisoft.autoattestation.attestation.AttestationSettings
import java.lang.ref.WeakReference
import kotlin.math.min


class AttestationSummary : AppCompatActivity() {
private var settings: AttestationSettings? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
intent.extras?.getString("payload")?.let {
settings = adapter.fromJson(it)
}
setContentView(R.layout.activity_attestation_summary)

settings?.let {
findViewById<ImageView>(R.id.qrcode).apply {
visibility = View.INVISIBLE
val dim = (getSystemService(WINDOW_SERVICE) as WindowManager).let { wm ->
Point().also { pt -> wm.defaultDisplay.getSize(pt) }
.let { pt -> min(pt.x, pt.y) }
}
GenQrTask(it, WeakReference(this)).execute(dim.coerceAtLeast(150))
}

findViewById<TextView>(R.id.qrtranscription).apply {
text = it.qrData
resizeTextToFit(this)
}
}

findViewById<View>(R.id.backButton).apply {
setOnClickListener {
packageManager.getLaunchIntentForPackage("fr.gouv.android.stopcovid")?.let {
startActivity(it)
return@setOnClickListener
}
finish()
}

setOnLongClickListener {
finish()
true
}
}
}


private fun resizeTextToFit(textView: TextView) {
val text = textView.text.toString()

val minTextSize = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP,
7f,
resources.displayMetrics
)

val measurePaint = Paint(textView.paint)
var width: Float = measurePaint.measureText(text)
val labelWidth: Float = textView.width.toFloat()
val maxLines: Int = textView.maxLines

while (labelWidth > 0 && width / maxLines > labelWidth - 20) {
val textSize: Float = measurePaint.textSize
measurePaint.textSize = textSize - 1
width = measurePaint.measureText(text)
if (textSize < minTextSize) break
}

textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, measurePaint.textSize)
}

private class GenQrTask(
val settings: AttestationSettings,
val imageView: WeakReference<ImageView>
) : AsyncTask<Int, Void, QRGEncoder>() {
override fun doInBackground(vararg params: Int?): QRGEncoder {
return AttestationGenerator(settings).genQRCode(params[0]!!)
}

override fun onPostExecute(result: QRGEncoder?) {
result?.let {
imageView.get()?.apply {
setImageBitmap(it.bitmap!!)
visibility = View.VISIBLE
invalidate()
}
}
}

override fun onCancelled() {
imageView.get()?.apply {
visibility = View.GONE
}
}
}

companion object {
fun create(context: Context, attestationSettings: AttestationSettings): Intent {
return Intent(context, AttestationSummary::class.java).also {
it.putExtras(Bundle().apply {
putString("payload", adapter.toJson(attestationSettings))
})
}
}

private val adapter: JsonAdapter<AttestationSettings> by lazy {
moshi.adapter(AttestationSettings::class.java)
}
}
}
Loading

0 comments on commit db55016

Please sign in to comment.