Skip to content

Commit

Permalink
Release v4.0. Merge branch 'develop'
Browse files Browse the repository at this point in the history
Ui refactoring, fix some issue
  • Loading branch information
alexandr7035 committed Jul 19, 2022
2 parents 8a58674 + 9918c45 commit 6eb7570
Show file tree
Hide file tree
Showing 85 changed files with 1,183 additions and 793 deletions.
22 changes: 11 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
applicationId "by.alexandr7035.affinidi_id"
minSdk 21
targetSdk 31
versionCode 500
versionName "3.0"
versionCode 600
versionName "4.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -62,10 +62,10 @@ dependencies {
implementation project(path:":domain")
implementation project(path: ":data")

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
Expand All @@ -81,21 +81,21 @@ dependencies {
// Retrofit
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation "com.squareup.okhttp3:logging-interceptor:4.9.1"
implementation "com.squareup.okhttp3:logging-interceptor:4.9.3"

// Room
def room_version = "2.4.1"
def room_version = "2.4.2"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"

// Navigation
def nav_version = "2.4.1"
def nav_version = "2.5.0"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

// ViewBinding delegate
def viewbindingdelegate_version = "1.5.3"
def viewbindingdelegate_version = "1.5.6"
implementation "com.github.kirich1409:viewbindingpropertydelegate-noreflection:$viewbindingdelegate_version"

// Coil
Expand All @@ -109,5 +109,5 @@ dependencies {
implementation('com.journeyapps:zxing-android-embedded:4.3.0') { transitive = false }
implementation 'com.google.zxing:core:3.3.0'

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1")
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.net.Uri
import android.os.Build
import android.os.VibrationEffect
import android.os.Vibrator
import android.os.VibratorManager
import android.provider.Settings
import android.widget.Toast
import by.alexandr7035.affinidi_id.presentation.common.VibrationMode
Expand All @@ -23,10 +24,11 @@ fun Context.vibrate(vibrationMode: VibrationMode) {
}.toLong()

val vibrator = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
this.getSystemService(Context.VIBRATOR_MANAGER_SERVICE)
val vibratorManager = this.getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager
vibratorManager.defaultVibrator
} else {
this.getSystemService(Context.VIBRATOR_SERVICE)
} as Vibrator
this.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
vibrator.vibrate(VibrationEffect.createOneShot(vibrationTimeMills, VibrationEffect.DEFAULT_AMPLITUDE))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import android.text.TextPaint
import android.text.style.ClickableSpan
import android.text.style.StyleSpan
import android.view.View
import timber.log.Timber
import java.lang.Exception

fun String.getClickableSpannable(
clickableText: String,
Expand Down Expand Up @@ -49,3 +51,23 @@ fun String.getClickableSpannable(

return spannableString
}


fun String.getPrettifiedDid(): String {
return try {
Timber.debug(this)

val didSplit = this.split(":")
val didValue = didSplit[2]

Timber.debug(didValue)
Timber.debug(didValue.takeLast(4))

val prettifiedValue = "${didSplit[0]}:${didSplit[1]}:${didValue.take(4)}...${didValue.takeLast(4)}"
prettifiedValue
}
// In case of any problem retur initial value
catch (e: Exception) {
this
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class SingleLiveEvent<T> : MutableLiveData<T>() {
}

// Observe the internal MutableLiveData
super.observe(owner, { t ->
super.observe(owner) { t ->
if (pending.compareAndSet(true, false)) {
observer.onChanged(t)
}
})
}
}

@MainThread
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package by.alexandr7035.affinidi_id.di

import android.content.Context
import by.alexandr7035.affinidi_id.presentation.common.credentials.CredentialToDetailsModelMapper
import by.alexandr7035.affinidi_id.presentation.common.credentials.CredentialToDetailsModelMapperImpl
import by.alexandr7035.affinidi_id.presentation.common.credentials.credential_metadata.CredentialMetadataToFieldsMapper
import by.alexandr7035.affinidi_id.presentation.common.credentials.credential_metadata.CredentialMetadataToFieldsMapperImpl
import by.alexandr7035.affinidi_id.presentation.common.credentials.credential_card.CredentialCardMapper
import by.alexandr7035.affinidi_id.presentation.common.credentials.credential_card.CredentialCardMapperImpl
import by.alexandr7035.affinidi_id.presentation.common.credentials.credential_proof.CredentialProofToFieldsMapper
import by.alexandr7035.affinidi_id.presentation.common.credentials.credential_proof.CredentialProofToFieldsMapperImpl
import by.alexandr7035.affinidi_id.presentation.common.credentials.credential_status.CredentialStatusMapper
Expand All @@ -21,8 +19,10 @@ import by.alexandr7035.affinidi_id.presentation.common.permissions.PermissionsPr
import by.alexandr7035.affinidi_id.presentation.common.permissions.PermissionsPreferencesImpl
import by.alexandr7035.affinidi_id.presentation.common.resources.ResourceProvider
import by.alexandr7035.affinidi_id.presentation.common.resources.ResourceProviderImpl
import by.alexandr7035.affinidi_id.presentation.credentials_list.CredentialsListMapper
import by.alexandr7035.affinidi_id.presentation.credentials_list.CredentialsListMapperImpl
import by.alexandr7035.affinidi_id.presentation.credential_details.model.CredentialToDetailsModelMapper
import by.alexandr7035.affinidi_id.presentation.credential_details.model.CredentialToDetailsModelMapperImpl
import by.alexandr7035.affinidi_id.presentation.credentials_list.model.CredentialsListMapper
import by.alexandr7035.affinidi_id.presentation.credentials_list.model.CredentialsListMapperImpl
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand Down Expand Up @@ -50,21 +50,25 @@ object PresentationModule {

@Provides
fun provideCredentialsListMapper(
resourceProvider: ResourceProvider,
credentialStatusMapper: CredentialStatusMapper,
errorTypeMapper: ErrorTypeMapper
errorTypeMapper: ErrorTypeMapper,
credentialCardMapper: CredentialCardMapper
): CredentialsListMapper {
return CredentialsListMapperImpl(resourceProvider, credentialStatusMapper, errorTypeMapper)
return CredentialsListMapperImpl(credentialCardMapper, errorTypeMapper)
}

@Provides
fun provideCredentialCardMapper(resourceProvider: ResourceProvider, credentialStatusMapper: CredentialStatusMapper): CredentialCardMapper {
return CredentialCardMapperImpl(resourceProvider, credentialStatusMapper)
}

@Provides
fun provideCredentialToDetailsModelMapper(
statusMapper: CredentialStatusMapper,
credentialCardMapper: CredentialCardMapper,
credentialSubjectMapper: CredentialSubjectToFieldsMapper,
metadataMapper: CredentialMetadataToFieldsMapper,
proofMapper: CredentialProofToFieldsMapper
): CredentialToDetailsModelMapper {
return CredentialToDetailsModelMapperImpl(statusMapper, credentialSubjectMapper, metadataMapper, proofMapper)
proofMapper: CredentialProofToFieldsMapper,
statusMapper: CredentialStatusMapper,
): CredentialToDetailsModelMapper {
return CredentialToDetailsModelMapperImpl(credentialCardMapper, statusMapper, credentialSubjectMapper, proofMapper)
}


Expand All @@ -78,11 +82,6 @@ object PresentationModule {
return CredentialSubjectToFieldsMapperImpl()
}

@Provides
fun provideCredentialMetadataToFieldsMapper(resourceProvider: ResourceProvider): CredentialMetadataToFieldsMapper {
return CredentialMetadataToFieldsMapperImpl(resourceProvider)
}

@Provides
fun provideCredentialProofToFieldsMapper(resourceProvider: ResourceProvider): CredentialProofToFieldsMapper {
return CredentialProofToFieldsMapperImpl(resourceProvider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class MainActivity : AppCompatActivity() {
}

// navigateSafe method allow us not check current destination
viewModel.getAuthCheckLiveData().observe(this, { authCheckResult ->
viewModel.getAuthCheckLiveData().observe(this) { authCheckResult ->
binding.progressView.root.isVisible = false

when (authCheckResult) {
Expand Down Expand Up @@ -108,7 +108,7 @@ class MainActivity : AppCompatActivity() {
}
}
}
})
}
}


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package by.alexandr7035.affinidi_id.presentation.common.credentials
package by.alexandr7035.affinidi_id.presentation.common.credentials.credential_card

import by.alexandr7035.affinidi_id.domain.model.credentials.stored_credentials.Credential

interface CredentialToDetailsModelMapper {
fun map(credential: Credential): CredentialDetailsUiModel.Success
interface CredentialCardMapper {
fun map(credential: Credential): CredentialCardUi
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package by.alexandr7035.affinidi_id.presentation.common.credentials.credential_card

import by.alexandr7035.affinidi_id.R
import by.alexandr7035.affinidi_id.core.extensions.getStringDateFromLong
import by.alexandr7035.affinidi_id.core.extensions.getPrettifiedDid
import by.alexandr7035.affinidi_id.domain.model.credentials.stored_credentials.Credential
import by.alexandr7035.affinidi_id.domain.model.credentials.stored_credentials.CredentialStatus
import by.alexandr7035.affinidi_id.presentation.common.credentials.credential_status.CredentialStatusMapper
import by.alexandr7035.affinidi_id.presentation.common.resources.ResourceProvider
import javax.inject.Inject

class CredentialCardMapperImpl @Inject constructor(
private val resourceProvider: ResourceProvider,
private val credentialStatusMapper: CredentialStatusMapper
) : CredentialCardMapper {
override fun map(credential: Credential): CredentialCardUi {

val credentialExpirationText = if (credential.expirationDate != null) {

when (credential.credentialStatus) {
CredentialStatus.ACTIVE -> {
resourceProvider.getString(
R.string.credential_active_until_template,
credential.expirationDate!!.getStringDateFromLong(CARD_DATE_FORMAT)
)
}

CredentialStatus.EXPIRED -> {
resourceProvider.getString(
R.string.credential_expired_at_template,
credential.expirationDate!!.getStringDateFromLong(CARD_DATE_FORMAT)
)
}
}

} else {
resourceProvider.getString(
R.string.no_expiration
)
}

val issuanceDate = resourceProvider.getString(
R.string.credential_issued_on_template,
credential.issuanceDate.getStringDateFromLong(CARD_DATE_FORMAT)
)

val formattedIssuerDid = credential.issuerDid.split(";").first()
val prettifiedIssuerDid = formattedIssuerDid.getPrettifiedDid()

val formattedHolderDid = credential.holderDid.split(";").first()
val prettifiedHolderDid = formattedHolderDid.getPrettifiedDid()

val credentialStatusUi = credentialStatusMapper.map(credential.credentialStatus)

return CredentialCardUi(
id = credential.id,
issuerDid = prettifiedHolderDid,
holderDid = prettifiedHolderDid,
issuanceDateText = issuanceDate,
credentialStatusUi = credentialStatusUi,
credentialExpirationText = credentialExpirationText,
credentialTypeText = credential.vcType,
)
}

companion object {
private const val CARD_DATE_FORMAT = "dd/MMM/YYYY"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package by.alexandr7035.affinidi_id.presentation.common.credentials.credential_card

import by.alexandr7035.affinidi_id.presentation.common.credentials.credential_status.CredentialStatusUi

data class CredentialCardUi(
val id: String,
val holderDid: String,
val issuerDid: String,
val issuanceDateText: String,
val credentialStatusUi: CredentialStatusUi,
val credentialTypeText: String,
val credentialExpirationText: String,
)

This file was deleted.

Loading

0 comments on commit 6eb7570

Please sign in to comment.