Skip to content

Commit

Permalink
Merge pull request #15 from dmitriy-ilchenko/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
wewewe718 authored Sep 9, 2020
2 parents e7691d7 + 6737f2c commit aaa5300
Show file tree
Hide file tree
Showing 55 changed files with 1,370 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
"kind": "Directory"
},
"applicationId": "org.barcodescanner",
"variantName": "googlePlayRelease",
"variantName": "amazonRelease",
"elements": [
{
"type": "SINGLE",
"filters": [],
"properties": [],
"versionCode": 2,
"versionName": "1.0",
"versionCode": 3,
"versionName": "1.1",
"enabled": true,
"outputFile": "app-googlePlay-release.apk"
"outputFile": "app-amazon-release.apk"
}
]
}
23 changes: 18 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
apply plugin: 'io.sentry.android.gradle'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
Expand Down Expand Up @@ -38,14 +39,16 @@ android {

buildTypes {
release {
minifyEnabled false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

flavorDimensions "market"
productFlavors {
appGallery {}
getApps {}
googlePlay {
applicationId "org.barcodescanner"
}
Expand All @@ -56,20 +59,24 @@ android {
buildConfigField "boolean", "ERROR_REPORTS_ENABLED_BY_DEFAULT", "false"
}
}

sentry {
autoProguardConfig true
autoUpload true
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
kapt 'com.android.databinding:compiler:3.1.4'

// Android
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.multidex:multidex:2.0.1'

// Room
Expand All @@ -91,7 +98,13 @@ dependencies {
implementation 'com.journeyapps:zxing-android-embedded:3.4.0'

// VCard Parser
implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.6'
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.0'

// Base32 Encoder
implementation "commons-codec:commons-codec:1.15"

// OTP
implementation "dev.turingcomplete:kotlin-onetimepassword:2.0.1"

// Rx
implementation "io.reactivex.rxjava2:rxkotlin:2.3.0"
Expand Down
20 changes: 20 additions & 0 deletions app/fDroid/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 1,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.example.barcodescanner",
"variantName": "fDroidRelease",
"elements": [
{
"type": "SINGLE",
"filters": [],
"properties": [],
"versionCode": 3,
"versionName": "1.1",
"enabled": true,
"outputFile": "app-fDroid-release.apk"
}
]
}
20 changes: 20 additions & 0 deletions app/getApps/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 1,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.example.barcodescanner",
"variantName": "getAppsRelease",
"elements": [
{
"type": "SINGLE",
"filters": [],
"properties": [],
"versionCode": 3,
"versionName": "1.1",
"enabled": true,
"outputFile": "app-getApps-release.apk"
}
]
}
100 changes: 79 additions & 21 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,21 +1,79 @@
# 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
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

# Kotlin
#https://stackoverflow.com/questions/33547643/how-to-use-kotlin-with-proguard
#https://medium.com/@AthorNZ/kotlin-metadata-jackson-and-proguard-f64f51e5ed32
-keepclassmembers class **$WhenMappings {
<fields>;
}
-keep class kotlin.Metadata { *; }
-keepclassmembers class kotlin.Metadata {
public <methods>;
}

# Android X
-dontwarn androidx.**
-dontwarn com.google.android.material.**
-keep interface androidx.* { *; }
-keep class androidx.** { *; }
-keep class com.google.android.material.** { *; }

# RxJava, RxAndroid (https://gist.github.com/kosiara/487868792fbd3214f9c9)
-keep class rx.schedulers.Schedulers {
public static <methods>;
}
-keep class rx.schedulers.ImmediateScheduler {
public <methods>;
}
-keep class rx.schedulers.TestScheduler {
public <methods>;
}
-keep class rx.schedulers.Schedulers {
public static ** test();
}
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
long producerIndex;
long consumerIndex;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
long producerNode;
long consumerNode;
}
-dontwarn sun.misc.Unsafe
-dontwarn org.reactivestreams.FlowAdapters
-dontwarn org.reactivestreams.**
-dontwarn java.util.concurrent.flow.**
-dontwarn java.util.concurrent.**

### Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }

# Prevent proguard from stripping interface information from TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

# LeakCanary
-keep class org.eclipse.mat.** { *; }
-keep class com.squareup.leakcanary.** { *; }

# Room
-dontwarn androidx.room.paging.**
-keep class * extends androidx.room.RoomDatabase

# VCard Parser
-dontwarn ezvcard.**
-keep,includedescriptorclasses class ezvcard.** { *; }
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@
android:screenOrientation="fullSensor"
android:configChanges="orientation|screenSize"
/>
<activity
android:name=".feature.barcode.otp.OtpActivity"
android:screenOrientation="fullSensor"
android:configChanges="orientation|screenSize"
/>
<activity
android:name=".feature.barcode.save.SaveBarcodeAsTextActivity"
android:screenOrientation="fullSensor"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.example.barcodescanner.di

import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import com.example.barcodescanner.*
import com.example.barcodescanner.App
import com.example.barcodescanner.usecase.*


Expand All @@ -28,6 +28,9 @@ val AppCompatActivity.barcodeImageSaver
val AppCompatActivity.wifiConnector
get() = WifiConnector

val AppCompatActivity.otpGenerator
get() = OTPGenerator

val AppCompatActivity.barcodeDatabase
get() = BarcodeDatabase.getInstance(this)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import com.example.barcodescanner.model.schema.BarcodeSchema
fun BarcodeSchema.toImageId(): Int? {
return when (this) {
BarcodeSchema.BOOKMARK -> R.drawable.ic_bookmark
BarcodeSchema.CRYPTOCURRENCY -> R.drawable.ic_bitcoin
BarcodeSchema.EMAIL -> R.drawable.ic_email
BarcodeSchema.GEO -> R.drawable.ic_location
BarcodeSchema.APP -> R.drawable.ic_app
BarcodeSchema.MMS -> R.drawable.ic_mms
BarcodeSchema.MECARD -> R.drawable.ic_contact
BarcodeSchema.PHONE -> R.drawable.ic_phone
BarcodeSchema.OTP_AUTH -> R.drawable.ic_otp
BarcodeSchema.SMS -> R.drawable.ic_sms
BarcodeSchema.URL -> R.drawable.ic_link
BarcodeSchema.VEVENT -> R.drawable.ic_calendar
Expand All @@ -32,6 +34,7 @@ fun BarcodeSchema.toStringId(): Int? {
BarcodeSchema.MMS -> R.string.barcode_schema_mms
BarcodeSchema.MECARD -> R.string.barcode_schema_me_card
BarcodeSchema.PHONE -> R.string.barcode_schema_phone
BarcodeSchema.OTP_AUTH -> R.string.barcode_schema_otp
BarcodeSchema.SMS -> R.string.barcode_schema_sms
BarcodeSchema.URL -> R.string.barcode_schema_url
BarcodeSchema.VEVENT -> R.string.barcode_schema_v_event
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.barcodescanner.extension

import org.apache.commons.codec.binary.Base32

fun ByteArray.encodeBase32(): String {
return Base32().encodeAsString(this)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.example.barcodescanner.extension

fun Long?.orZero(): Long {
return this ?: 0L
}
38 changes: 38 additions & 0 deletions app/src/main/java/com/example/barcodescanner/extension/String.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,50 @@
package com.example.barcodescanner.extension

import android.provider.ContactsContract
import dev.turingcomplete.kotlinonetimepassword.HmacAlgorithm
import org.apache.commons.codec.binary.Base32
import java.util.*

fun String?.toHmacAlgorithm(): HmacAlgorithm {
return when (this) {
"SHA1" -> HmacAlgorithm.SHA1
"SHA256" -> HmacAlgorithm.SHA256
"SHA512" -> HmacAlgorithm.SHA512
else -> HmacAlgorithm.SHA1
}
}

fun String?.decodeBase32(): ByteArray? {
if (isNullOrBlank()) {
return null
}
return Base32().decode(this)
}

fun String.toCaps(): String {
return toUpperCase(Locale.ROOT)
}

fun String.removeStartAll(symbol: Char): String {
var newStart = 0

run loop@ {
forEachIndexed { index, c ->
if (c == symbol) {
newStart = index + 1
} else {
return@loop
}
}
}

return if (newStart >= length) {
""
} else {
substring(newStart)
}
}

fun String.removePrefixIgnoreCase(prefix: String): String {
return substring(prefix.length)
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/example/barcodescanner/extension/Uri.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.example.barcodescanner.extension

import android.net.Uri

fun Uri.Builder.appendQueryParameterIfNotNullOrBlank(key: String, value: String?): Uri.Builder {
if (value.isNullOrBlank().not()) {
appendQueryParameter(key, value)
}
return this
}
Loading

0 comments on commit aaa5300

Please sign in to comment.