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 #6 from maxisoft/dev
Browse files Browse the repository at this point in the history
Publish 1.1
  • Loading branch information
maxisoft authored Nov 12, 2020
2 parents db55016 + d418f30 commit 3e4e90f
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/signed_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Build release APK
run: bash ./gradlew assembleRelease --stacktrace

- uses: jobobby04/sign-android-release@v1.0.3
- uses: zhuhaow/sign-android-release@master
with:
releaseDirectory: app/build/outputs/apk/release
signingKeyBase64: ${{ secrets.signingKeyBase64 }}
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ Application Android libre pour faire une attestation simplement, sans tracker et
- 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
## Téléchargement

<a href="https://github.com/maxisoft/AutoAttestation/releases/latest/download/AutoAttestation_v1.0.0.apk"><img src="https://i.ibb.co/WFdrZjM/download-apk.png" alt="download-apk" border="0" width="100"></a>

## Fonctionnalités
- 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/)

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
targetSdkVersion 29
versionCode 1
multiDexEnabled true
versionName "1.0"
versionName "1.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package io.github.maxisoft.autoattestation

import android.content.Context
import android.content.Intent
import android.graphics.Paint
import android.graphics.Point
import android.graphics.Rect
import android.os.AsyncTask
import android.os.Bundle
import android.os.Handler
import android.util.Log
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
Expand Down Expand Up @@ -49,14 +50,20 @@ class AttestationSummary : AppCompatActivity() {
}

findViewById<View>(R.id.backButton).apply {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
elevation = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
7f,
resources.displayMetrics
)
}
setOnClickListener {
packageManager.getLaunchIntentForPackage("fr.gouv.android.stopcovid")?.let {
startActivity(it)
return@setOnClickListener
}
finish()
}

setOnLongClickListener {
finish()
true
Expand All @@ -65,28 +72,44 @@ class AttestationSummary : AppCompatActivity() {
}


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

private fun resizeTextToFit(textView: TextView, counter: Long = 0) {
val minTextSize = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP,
7f,
3f,
resources.displayMetrics
)

val measurePaint = Paint(textView.paint)
var width: Float = measurePaint.measureText(text)
val labelWidth: Float = textView.width.toFloat()
val maxLines: Int = textView.maxLines
if (!textView.getGlobalVisibleRect(Rect())) {
require(counter < 130L)
Handler(mainLooper).post { resizeTextToFit(textView, counter + 1) }
return
}

while (labelWidth > 0 && width / maxLines > labelWidth - 20) {
val textSize: Float = measurePaint.textSize
measurePaint.textSize = textSize - 1
width = measurePaint.measureText(text)
if (textSize < minTextSize) break
Log.d("Attestation", "iter: ${counter + 1}")
if (textView.layout.getEllipsisCount(textView.lineCount - 1) > 0) {
if (counter == 0L) {
textView.alpha = 0.1f
}
val newSize = textView.textSize * 0.9f
if (newSize > minTextSize) {
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, newSize)
Handler(mainLooper).post { resizeTextToFit(textView, counter + 1) }
} else {
Log.w(
"Attestation",
"unable to find font size in ${counter + 1} iteration for text ${textView.text}"
)
textView.alpha = 1f
require(counter != 0L)
}
} else {
textView.alpha = 1f
Log.d(
"Attestation",
"Using text size ${textView.textSize} using ${counter + 1} iterations"
)
}

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

private class GenQrTask(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class MainActivity : AppCompatActivity() {
calendar,
birthday,
leavingTime,
reasons.map { it.hashCode() }.reduce { acc, reason -> acc * 31 + reason })
reasons.map { it.hashCode() }.reduceOrNull { acc, reason -> acc * 31 + reason } ?: 0)
.map { it.hashCode().toLong() }
.reduce { acc, it ->
31 * acc + it
Expand Down
110 changes: 58 additions & 52 deletions app/src/main/res/layout/activity_attestation_summary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,78 +13,84 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="0">


<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false"
android:clipToPadding="false"
android:descendantFocusability="afterDescendants"
android:minHeight="60dp"
android:scaleX="1.2"
android:scaleY="1.2"
android:translationY="-6dp"
app:cardCornerRadius="1dp"
app:cardElevation="4dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true">
app:cardUseCompatPadding="true"
tools:targetApi="lollipop">

<!-- put whatever you want -->

<ImageView
android:id="@+id/backButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginLeft="25dp"
android:layout_marginTop="4dp"
android:scaleType="fitCenter"
android:scaleX="0.8"
android:scaleY="0.8"
android:translationX="16dp"
app:srcCompat="@drawable/baseline_arrow_back_black_36"
app:tint="#5770BE"
tools:layout_editor_absoluteX="14dp"
tools:layout_editor_absoluteY="35dp" />
</androidx.cardview.widget.CardView>

<ImageView
android:id="@+id/backButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="25dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingBottom="5dp"
android:scaleType="fitCenter"
app:srcCompat="@drawable/baseline_arrow_back_black_36"
app:tint="#5770BE" />
</FrameLayout>

<ImageView
android:id="@+id/qrcode"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_marginHorizontal="0dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="4dp"
android:layout_marginRight="4dp"
android:layout_weight="0.5"
android:minWidth="150dp"
android:minHeight="150dp"
android:scaleType="fitCenter"
android:scaleX="1"
android:scaleY="1"
app:srcCompat="@mipmap/ic_launcher" />
android:layout_height="match_parent"
android:orientation="vertical">

<ImageView
android:id="@+id/qrcode"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_marginHorizontal="0dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="4dp"
android:layout_marginRight="4dp"
android:layout_weight="0.5"
android:scaleType="fitCenter"
android:scaleX="1"
android:scaleY="1"
app:srcCompat="@mipmap/ic_launcher" />

<TextView
android:id="@+id/qrtranscription"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"
android:layout_weight="0.5"
android:ellipsize="end"
android:fontFamily="@font/marianne_bold"
android:gravity="center_horizontal"
android:maxLines="8"
android:scrollbars="vertical"
android:scrollHorizontally="true"
android:text="@string/qr_transcription_example"
android:textColor="@color/black"
android:textIsSelectable="false"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>

<TextView
android:id="@+id/qrtranscription"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"
android:layout_weight="0.4"
android:fontFamily="@font/marianne_bold"
android:gravity="center_horizontal"
android:maxLines="8"
android:minHeight="400dp"
android:minLines="7"
android:text="@string/qr_transcription_example"
android:textColor="@color/black"
android:textIsSelectable="false"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>

0 comments on commit 3e4e90f

Please sign in to comment.