This repository has been archived by the owner on May 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from maxisoft/dev
Dev
- Loading branch information
Showing
237 changed files
with
1,345 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -455,3 +455,4 @@ fabric.properties | |
.externalNativeBuild | ||
.cxx | ||
local.properties | ||
/app/release/output-metadata.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/io/github/maxisoft/autoattestation/Application.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} | ||
} |
130 changes: 130 additions & 0 deletions
130
app/src/main/java/io/github/maxisoft/autoattestation/AttestationSummary.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} |
Oops, something went wrong.