Skip to content

Commit

Permalink
Merge pull request #202 from SecUSo/development
Browse files Browse the repository at this point in the history
Update to version 4.5.0
  • Loading branch information
udenr authored Jan 11, 2024
2 parents 243182d + 7baa371 commit e15ce4d
Show file tree
Hide file tree
Showing 49 changed files with 678 additions and 340 deletions.
62 changes: 39 additions & 23 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'com.google.devtools.ksp'
}

android {
compileSdkVersion 33
defaultConfig {
applicationId "com.secuso.privacyFriendlyCodeScanner"
minSdkVersion 17
targetSdkVersion 33
compileSdk 34
targetSdkVersion 34
multiDexEnabled true
versionCode 30
versionName "4.4.0"
versionCode 31
versionName "4.5.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
buildFeatures.dataBinding = true
vectorDrawables.useSupportLibrary = true
Expand All @@ -26,7 +29,7 @@ android {
}
}

android.applicationVariants.all { variant ->
android.applicationVariants.configureEach { variant ->
variant.outputs.all {
def appName = "pfa-qr-scanner"
outputFileName = appName + "-${variant.name}-v${variant.versionName}.apk"
Expand All @@ -39,13 +42,24 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}

compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}

kotlin {
jvmToolchain(17)
}

namespace 'com.secuso.privacyfriendlycodescanner.qrscanner'
lint {
lintConfig = file("lint.xml")
}
}

Expand All @@ -54,7 +68,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.cardview:cardview:1.0.0'
testImplementation 'junit:junit:4.13.2'
Expand All @@ -64,23 +78,25 @@ dependencies {
implementation('com.journeyapps:zxing-android-embedded:4.3.0') { transitive = false }
implementation 'com.google.zxing:core:3.4.1' //newer version requires java.nio.charset.StandardCharsets in Encoder.java -> minSdkVersion = 19

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
implementation "androidx.multidex:multidex:2.0.1"

implementation 'com.github.bumptech.glide:glide:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.9.0'
implementation 'androidx.room:room-runtime:2.5.2'
kapt 'androidx.room:room-compiler:2.5.2'
androidTestImplementation 'androidx.room:room-testing:2.5.2'
ksp 'com.github.bumptech.glide:compiler:4.9.0'

def room_version = "2.6.1"
implementation "androidx.room:room-runtime:$room_version"
ksp "androidx.room:room-compiler:$room_version"
androidTestImplementation "androidx.room:room-testing:$room_version"

implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.google.code.gson:gson:2.10'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation "androidx.core:core-ktx:1.10.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1"
implementation "androidx.core:core-ktx:1.12.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation project(path: ':backup-api')
def work_version = "2.8.1"
def work_version = "2.9.0"
implementation "androidx.work:work-runtime:$work_version"
implementation "androidx.work:work-runtime-ktx:$work_version"
androidTestImplementation "androidx.work:work-testing:$work_version"
Expand Down
10 changes: 10 additions & 0 deletions app/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<!-- Disable the NotificationPermission check for glide -->
<issue id="NotificationPermission">
<ignore regexp="com.bumptech.glide.request.target.NotificationTarget" />
</issue>

<!-- Set the severity of missing translations to warning instead of error -->
<issue id="MissingTranslation" severity="warning" />
</lint>
35 changes: 23 additions & 12 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?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="com.secuso.privacyfriendlycodescanner.qrscanner">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission
Expand All @@ -12,28 +11,30 @@
android:maxSdkVersion="28" />

<uses-sdk tools:overrideLibrary="com.google.zxing.client.android" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />

<application
android:name=".PFACodeScannerApplication"
android:allowBackup="true"
android:fullBackupContent="false"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:name=".PFACodeScannerApplication"
android:installLocation="preferExternal"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">

<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="${applicationId}.workmanager-init"
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
tools:node="remove" />

<activity
android:name=".ui.activities.SplashActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -44,7 +45,6 @@
android:name=".ui.activities.ScannerActivity"
android:clearTaskOnLaunch="true"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.SEND" />
Expand All @@ -66,8 +66,20 @@
android:parentActivityName=".ui.activities.ScannerActivity" />
<activity
android:name=".ui.activities.generator.QrGeneratorOverviewActivity"
android:exported="true"
android:label="@string/QRGenerator"
android:parentActivityName=".ui.activities.ScannerActivity" />
android:parentActivityName=".ui.activities.ScannerActivity">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/x-vcard" />
</intent-filter>
</activity>
<activity
android:name=".ui.activities.TutorialActivity"
android:parentActivityName=".ui.activities.ScannerActivity"
Expand Down Expand Up @@ -144,16 +156,15 @@
android:process=":backup"
tools:ignore="ExportedService">
<intent-filter>
<action
android:name="org.secuso.privacyfriendlybackup.api.pfa.PFAAuthService" />
<action android:name="org.secuso.privacyfriendlybackup.api.pfa.PFAAuthService" />
</intent-filter>
</service>

<service
android:name=".QuickTileService"
android:exported="true"
android:icon="@drawable/ic_tile"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
android:exported="true">
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">

<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class PFACodeScannerApplication : MultiDexApplication(), Configuration.Provider
}
}

override fun getWorkManagerConfiguration(): Configuration {
return Configuration.Builder().setMinimumLoggingLevel(Log.INFO).build()
}
override val workManagerConfiguration = Configuration.Builder().setMinimumLoggingLevel(Log.INFO).build()

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public void migrate(@NonNull SupportSQLiteDatabase database) {

while (!c.isAfterLast()) {
items[i] = new HistoryItem();
items[i].set_id(c.getInt(c.getColumnIndex("_id")));
items[i].setText(c.getString(c.getColumnIndex("text")));
items[i].set_id(c.getInt(c.getColumnIndexOrThrow("_id")));
items[i].setText(c.getString(c.getColumnIndexOrThrow("text")));
items[i].setImage(Utils.generateCode(items[i].getText(), BarcodeFormat.QR_CODE, null));

i++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import android.graphics.Bitmap;
import android.graphics.Color;

import androidx.annotation.DrawableRes;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
Expand All @@ -14,6 +16,7 @@
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.journeyapps.barcodescanner.BarcodeResult;
import com.secuso.privacyfriendlycodescanner.qrscanner.R;
import com.secuso.privacyfriendlycodescanner.qrscanner.database.HistoryItem;

import java.util.EnumMap;
Expand Down Expand Up @@ -46,6 +49,18 @@ private static BarcodeFormat getFormat(BarcodeFormat format) {
}
}

@DrawableRes
public static Integer getBarcodeFormatIcon(BarcodeFormat format) {
return switch (format) {
case QR_CODE -> R.drawable.ic_baseline_qr_code_24dp;
case MAXICODE -> R.drawable.ic_maxicode_24dp;
case CODABAR, CODE_39, CODE_93, CODE_128, EAN_8, EAN_13, ITF, RSS_14, RSS_EXPANDED, UPC_A, UPC_E, UPC_EAN_EXTENSION -> R.drawable.ic_barcode_24dp;
case PDF_417 -> R.drawable.ic_pdf_417_code_24dp;
case DATA_MATRIX -> R.drawable.ic_data_matrix_code_24dp;
case AZTEC -> R.drawable.ic_aztec_code_24dp;
};
}

public static Bitmap generateCode(String data, BarcodeFormat format, Map<EncodeHintType, Object> hints, Map<ResultMetadataType, Object> metadata) {
return generateCode(data, format, DEFAULT_CODE_WIDTH, DEFAULT_CODE_HEIGHT, hints, metadata);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
package com.secuso.privacyfriendlycodescanner.qrscanner.ui.activities;

import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.secuso.privacyfriendlycodescanner.qrscanner.R;
import com.secuso.privacyfriendlycodescanner.qrscanner.database.AppRepository;
import com.secuso.privacyfriendlycodescanner.qrscanner.ui.adapter.DeleteActionMode;
import com.secuso.privacyfriendlycodescanner.qrscanner.ui.adapter.HistoryAdapter;
import com.secuso.privacyfriendlycodescanner.qrscanner.ui.viewmodel.HistoryViewModel;

Expand All @@ -27,26 +22,25 @@
public class HistoryActivity extends AppCompatActivity {

private HistoryAdapter mHistoryAdapter;
private RecyclerView mHistoryRecyclerView;
private HistoryViewModel mViewModel;
private DeleteActionMode mDeleteActionMode;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_history);

mViewModel = new ViewModelProvider(this).get(HistoryViewModel.class);
HistoryViewModel mViewModel = new ViewModelProvider(this).get(HistoryViewModel.class);

mHistoryAdapter = new HistoryAdapter(this);
mDeleteActionMode = new DeleteActionMode(this);

mHistoryRecyclerView = findViewById(R.id.activity_history_list);
mHistoryAdapter = new HistoryAdapter(this, mDeleteActionMode);

RecyclerView mHistoryRecyclerView = findViewById(R.id.activity_history_list);
mHistoryRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mHistoryRecyclerView.setAdapter(mHistoryAdapter);

mViewModel.getHistoryItems().observe(this, (list) -> {
mHistoryAdapter.setHistoryEntries(list);
});
mViewModel.getHistoryItems().observe(this, (list) -> mHistoryAdapter.setHistoryEntries(list));
}

@Override
Expand All @@ -58,27 +52,14 @@ public boolean onCreateOptionsMenu(Menu menu) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_clear) {
Drawable icon = AppCompatResources.getDrawable(getApplicationContext(), android.R.drawable.ic_dialog_alert);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (icon != null) {
icon.setTint(getResources().getColor(R.color.red));
}
}

new MaterialAlertDialogBuilder(this)
.setTitle(R.string.D_all)
.setMessage(R.string.all_records)
.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
AppRepository.getInstance(HistoryActivity.this).deleteAllHistoryEntries();
}
})
.setNegativeButton(android.R.string.cancel, null)
.setIcon(icon)
.create().show();
this.startActionMode(mDeleteActionMode);
return true;
}
return false;
}

public HistoryAdapter getHistoryAdapter() {
return mHistoryAdapter;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.ViewModelProvider;

Expand All @@ -26,6 +28,7 @@
import com.secuso.privacyfriendlycodescanner.qrscanner.R;
import com.secuso.privacyfriendlycodescanner.qrscanner.database.HistoryItem;
import com.secuso.privacyfriendlycodescanner.qrscanner.generator.Contents;
import com.secuso.privacyfriendlycodescanner.qrscanner.helpers.Utils;
import com.secuso.privacyfriendlycodescanner.qrscanner.ui.dialogfragments.QRCodeImageDialogFragment;
import com.secuso.privacyfriendlycodescanner.qrscanner.ui.dialogfragments.RawDataDialogFragment;
import com.secuso.privacyfriendlycodescanner.qrscanner.ui.resultfragments.CalendarResultFragment;
Expand Down Expand Up @@ -173,6 +176,13 @@ private void displayGeneralData() {
ImageView qrImageView = findViewById(R.id.activity_result_qr_image);
TextView qrTypeText = findViewById(R.id.textView);
TextView timestampTextView = findViewById(R.id.textViewTimestamp);
TextView codeTypeText = findViewById(R.id.textViewCodeType);
ImageView codeTypeImageView = findViewById(R.id.item_history_type_image);

@DrawableRes int codeTypeDrawableRes = Utils.getBarcodeFormatIcon(viewModel.currentHistoryItem.getFormat());
Glide.with(this).load(AppCompatResources.getDrawable(this, codeTypeDrawableRes)).placeholder(AppCompatResources.getDrawable(this, R.drawable.ic_no_image_accent_24dp)).into(codeTypeImageView);

codeTypeText.setText(viewModel.currentHistoryItem.getFormat().toString());

Glide.with(this).load(viewModel.mCodeImage).into(qrImageView);
qrTypeText.setText(Contents.Type.parseParsedResultType(viewModel.mParsedResult.getType()).toLocalizedString(getApplicationContext()));
Expand Down
Loading

0 comments on commit e15ce4d

Please sign in to comment.