diff --git a/presentation/build.gradle b/presentation/build.gradle index 041cebdb0..46f92ab44 100755 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -2,10 +2,10 @@ plugins { id('com.android.application') id('kotlin-android') id('kotlin-kapt') - id ('kotlin-parcelize') + id('kotlin-parcelize') id('org.greenrobot.greendao') id('com.google.gms.google-services') - id ('androidx.navigation.safeargs') + id('androidx.navigation.safeargs') } def secretsPropertiesFile = rootProject.file("secrets.properties") @@ -54,7 +54,6 @@ android { } - compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 @@ -192,7 +191,7 @@ dependencies { implementation "com.hannesdorfmann.mosby3:mvi:3.1.1" implementation "com.hannesdorfmann.mosby3:viewstate:3.1.1" - // implementation 'com.github.sockeqwe:mosby:345efbb0c0' + // implementation 'com.github.sockeqwe:mosby:345efbb0c0' implementation "com.jakewharton.rxbinding2:rxbinding:2.2.0" @@ -225,10 +224,6 @@ dependencies { implementation("androidx.annotation:annotation:1.8.2") - - - - compileOnly presentationDependencies.javaxAnnotation androidTestImplementation presentationTestDependencies.mockito @@ -253,7 +248,7 @@ dependencies { //implementation ('com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.3@aar'){ // transitive = true - // } + // } implementation 'com.github.dlazaro66:QRCodeReaderView:2.0.3' diff --git a/presentation/src/demo/res/mipmap-anydpi-v26/ic_launcher.xml b/presentation/src/demo/res/mipmap-anydpi-v26/ic_launcher.xml index 036d09bc5..c9ad5f98f 100644 --- a/presentation/src/demo/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/presentation/src/demo/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/presentation/src/demo/res/mipmap-anydpi-v26/ic_launcher_round.xml b/presentation/src/demo/res/mipmap-anydpi-v26/ic_launcher_round.xml index 036d09bc5..c9ad5f98f 100644 --- a/presentation/src/demo/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/presentation/src/demo/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/presentation/src/dev/AndroidManifest.xml b/presentation/src/dev/AndroidManifest.xml index 5230cc750..0f014e88f 100644 --- a/presentation/src/dev/AndroidManifest.xml +++ b/presentation/src/dev/AndroidManifest.xml @@ -1,3 +1,4 @@ + \ No newline at end of file diff --git a/presentation/src/dev/res/mipmap-anydpi-v26/ic_launcher.xml b/presentation/src/dev/res/mipmap-anydpi-v26/ic_launcher.xml index c4a603d4c..00f9eaaf3 100644 --- a/presentation/src/dev/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/presentation/src/dev/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/presentation/src/dev/res/mipmap-anydpi-v26/ic_launcher_round.xml b/presentation/src/dev/res/mipmap-anydpi-v26/ic_launcher_round.xml index c4a603d4c..00f9eaaf3 100644 --- a/presentation/src/dev/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/presentation/src/dev/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index 1300e9ec9..8648dbd17 100755 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -23,18 +23,16 @@ android:theme="@style/AppTheme"> - - + android:label="@string/app_name" + android:launchMode="singleTask"> @@ -104,8 +102,8 @@ android:name=".view.screens.welcome.WelcomeActivity" android:exported="false" android:label="@string/app_name" - android:theme="@style/WelcomeMaterialTheme" - android:launchMode="singleTop" /> + android:launchMode="singleTop" + android:theme="@style/WelcomeMaterialTheme" /> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,10 +29,12 @@ @Singleton public class UIThread implements PostExecutionThread { - @Inject - public UIThread() {} + @Inject + public UIThread() { + } - @Override public Scheduler getScheduler() { - return AndroidSchedulers.mainThread(); - } + @Override + public Scheduler getScheduler() { + return AndroidSchedulers.mainThread(); + } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/api_config/ApiConfig.java b/presentation/src/main/java/io/forus/me/android/presentation/api_config/ApiConfig.java index 83c8fdd46..c2830d77a 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/api_config/ApiConfig.java +++ b/presentation/src/main/java/io/forus/me/android/presentation/api_config/ApiConfig.java @@ -5,47 +5,44 @@ public class ApiConfig { - - public static String SERVER_URL = BuildConfig.SERVER_URL; + public static String SERVER_URL = BuildConfig.SERVER_URL; private static String[] apiVariants = {"https://api.forus.io/", "https://demo.api.forus.io/", "https://staging.api.forus.io/", "https://dev.api.forus.io/" }; - - public static ApiType getCurrentApiType(){ - if(SERVER_URL.equals(apiVariants[0])) return ApiType.PROD; - else if(SERVER_URL.equals(apiVariants[1])) return ApiType.DEMO; - else if(SERVER_URL.equals(apiVariants[2])) return ApiType.STAGING; - else if(SERVER_URL.equals(apiVariants[3])) return ApiType.DEV; + public static ApiType getCurrentApiType() { + if (SERVER_URL.equals(apiVariants[0])) return ApiType.PROD; + else if (SERVER_URL.equals(apiVariants[1])) return ApiType.DEMO; + else if (SERVER_URL.equals(apiVariants[2])) return ApiType.STAGING; + else if (SERVER_URL.equals(apiVariants[3])) return ApiType.DEV; else return ApiType.OTHER; } - public static void changeApi(ApiType apiType){ + public static void changeApi(ApiType apiType) { - if(apiType == ApiType.PROD) SERVER_URL = apiVariants[0]; - else if(apiType == ApiType.DEMO) SERVER_URL = apiVariants[1]; - else if(apiType == ApiType.STAGING) SERVER_URL = apiVariants[2]; - else if(apiType == ApiType.DEV) SERVER_URL = apiVariants[3]; - else SERVER_URL = apiVariants[0]; + if (apiType == ApiType.PROD) SERVER_URL = apiVariants[0]; + else if (apiType == ApiType.DEMO) SERVER_URL = apiVariants[1]; + else if (apiType == ApiType.STAGING) SERVER_URL = apiVariants[2]; + else if (apiType == ApiType.DEV) SERVER_URL = apiVariants[3]; + else SERVER_URL = apiVariants[0]; } - public static void changeToCustomApi(String customUrl){ + public static void changeToCustomApi(String customUrl) { SERVER_URL = customUrl; } - - public static ApiType stringToApiType(String str){ - if(str.equalsIgnoreCase("PROD")) return ApiType.PROD; - if(str.equalsIgnoreCase("DEMO")) return ApiType.DEMO; - if(str.equalsIgnoreCase("STAGING")) return ApiType.STAGING; - if(str.equalsIgnoreCase("DEV")) return ApiType.DEV; - else return ApiType.OTHER; + public static ApiType stringToApiType(String str) { + if (str.equalsIgnoreCase("PROD")) return ApiType.PROD; + if (str.equalsIgnoreCase("DEMO")) return ApiType.DEMO; + if (str.equalsIgnoreCase("STAGING")) return ApiType.STAGING; + if (str.equalsIgnoreCase("DEV")) return ApiType.DEV; + else return ApiType.OTHER; } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/api_config/Utils.kt b/presentation/src/main/java/io/forus/me/android/presentation/api_config/Utils.kt index 9b63ed9cb..36f22347e 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/api_config/Utils.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/api_config/Utils.kt @@ -24,7 +24,12 @@ class Utils private constructor() { fun restartApp(context: Context) { val mStartActivity = Intent(context, MainActivity::class.java) val mPendingIntentId = 123456 - val mPendingIntent = PendingIntent.getActivity(context, mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT) + val mPendingIntent = PendingIntent.getActivity( + context, + mPendingIntentId, + mStartActivity, + PendingIntent.FLAG_CANCEL_CURRENT + ) val mgr = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent) System.exit(0) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/api_config/check_api_status/CheckApiPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/api_config/check_api_status/CheckApiPresenter.kt index 1cd42207e..8a2c4897d 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/api_config/check_api_status/CheckApiPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/api_config/check_api_status/CheckApiPresenter.kt @@ -11,7 +11,10 @@ import io.reactivex.schedulers.Schedulers class CheckApiPresenter(val context: Context) { fun checkApi(apiString: String, success: (Boolean) -> Unit, error: (Throwable) -> Unit) { try { - val commonRemoteDataSource = CommonRemoteDataSource { MeServiceFactory.getInstance().createRetrofitService(CommonService::class.java, apiString) } + val commonRemoteDataSource = CommonRemoteDataSource { + MeServiceFactory.getInstance() + .createRetrofitService(CommonService::class.java, apiString) + } val commonRepository = CommonRepository(commonRemoteDataSource) commonRepository.status() diff --git a/presentation/src/main/java/io/forus/me/android/presentation/api_config/dialogs/ChooseApiDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/api_config/dialogs/ChooseApiDialog.kt index ba5a6becf..0e8bd82a8 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/api_config/dialogs/ChooseApiDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/api_config/dialogs/ChooseApiDialog.kt @@ -5,18 +5,20 @@ import com.afollestad.materialdialogs.MaterialDialog import io.forus.me.android.presentation.R -class ChooseApiDialog(private val context: Context, itemCallback: MaterialDialog.ListCallback, - private val cancelListener: () -> Unit){ +class ChooseApiDialog( + private val context: Context, itemCallback: MaterialDialog.ListCallback, + private val cancelListener: () -> Unit +) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title("Choose api") - .items(R.array.api_items) - .negativeText("Cancel") - .itemsCallback(itemCallback) - .cancelListener { cancelListener.invoke() } - .build() + .title("Choose api") + .items(R.array.api_items) + .negativeText("Cancel") + .itemsCallback(itemCallback) + .cancelListener { cancelListener.invoke() } + .build() - fun show(){ + fun show() { dialog.show() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/api_config/dialogs/CustomApiDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/api_config/dialogs/CustomApiDialog.kt index a4ca76123..3a62c28b5 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/api_config/dialogs/CustomApiDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/api_config/dialogs/CustomApiDialog.kt @@ -5,22 +5,28 @@ import androidx.core.text.HtmlCompat import com.afollestad.materialdialogs.MaterialDialog -class CustomApiDialog(private val context: Context, customApiStr: String, inputCallback: MaterialDialog.InputCallback, - private val saveListener: (MaterialDialog) -> Unit, - private val cancelListener: () -> Unit){ +class CustomApiDialog( + private val context: Context, customApiStr: String, inputCallback: MaterialDialog.InputCallback, + private val saveListener: (MaterialDialog) -> Unit, + private val cancelListener: () -> Unit +) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title("Custom API server") - .content(HtmlCompat.fromHtml("API format:
https://{address}/ api/v1/...", - HtmlCompat.FROM_HTML_MODE_LEGACY)) - .positiveText("Save") - .input("",customApiStr,inputCallback) - .negativeText("Cancel") - .onPositive { dialog, which -> saveListener.invoke(dialog) } - .cancelListener { cancelListener.invoke() } - .build() + .title("Custom API server") + .content( + HtmlCompat.fromHtml( + "API format:
https://{address}/ api/v1/...", + HtmlCompat.FROM_HTML_MODE_LEGACY + ) + ) + .positiveText("Save") + .input("", customApiStr, inputCallback) + .negativeText("Cancel") + .onPositive { dialog, which -> saveListener.invoke(dialog) } + .cancelListener { cancelListener.invoke() } + .build() - fun show(){ + fun show() { dialog.show() } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/api_config/dialogs/SaveApiAndRestartDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/api_config/dialogs/SaveApiAndRestartDialog.kt index 0d6123518..717b4d6fb 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/api_config/dialogs/SaveApiAndRestartDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/api_config/dialogs/SaveApiAndRestartDialog.kt @@ -5,19 +5,21 @@ import com.afollestad.materialdialogs.MaterialDialog import io.forus.me.android.presentation.R -class SaveApiAndRestartDialog(private val context: Context, - private val positiveCallback: () -> Unit) { +class SaveApiAndRestartDialog( + private val context: Context, + private val positiveCallback: () -> Unit +) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title("Confirm") - .content("You must restart the application for the changes to take effect") - .positiveText("Save and restart") - .negativeText(context.resources.getString(R.string.me_cancel)) - .onPositive { dialog, which -> - positiveCallback.invoke() - - } - .build() + .title("Confirm") + .content("You must restart the application for the changes to take effect") + .positiveText("Save and restart") + .negativeText(context.resources.getString(R.string.me_cancel)) + .onPositive { dialog, which -> + positiveCallback.invoke() + + } + .build() fun show() { dialog.show() diff --git a/presentation/src/main/java/io/forus/me/android/presentation/crypt/KeyStoreWrapper.kt b/presentation/src/main/java/io/forus/me/android/presentation/crypt/KeyStoreWrapper.kt index 908702d8a..74db01e74 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/crypt/KeyStoreWrapper.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/crypt/KeyStoreWrapper.kt @@ -1,7 +1,6 @@ package io.forus.me.android.presentation.crypt - import android.annotation.TargetApi import android.content.Context import android.os.Build @@ -24,8 +23,9 @@ class KeyStoreWrapper(private val context: Context) { private val keyStore: KeyStore = createAndroidKeyStore() - fun getOrCreateAndroidKeyStoreAsymmetricKeyPair(alias: String): KeyPair = getAndroidKeyStoreAsymmetricKeyPair(alias) - ?: createAndroidKeyStoreAsymmetricKey(alias) + fun getOrCreateAndroidKeyStoreAsymmetricKeyPair(alias: String): KeyPair = + getAndroidKeyStoreAsymmetricKeyPair(alias) + ?: createAndroidKeyStoreAsymmetricKey(alias) fun getAndroidKeyStoreAsymmetricKeyPair(alias: String): KeyPair? { @@ -60,20 +60,23 @@ class KeyStoreWrapper(private val context: Context) { endDate.add(Calendar.YEAR, 20) val builder = KeyPairGeneratorSpec.Builder(context) - .setAlias(alias) - .setSerialNumber(BigInteger.ONE) - .setSubject(X500Principal("CN=${alias} CA Certificate")) - .setStartDate(startDate.time) - .setEndDate(endDate.time) + .setAlias(alias) + .setSerialNumber(BigInteger.ONE) + .setSubject(X500Principal("CN=${alias} CA Certificate")) + .setStartDate(startDate.time) + .setEndDate(endDate.time) generator.initialize(builder.build()) } @TargetApi(Build.VERSION_CODES.M) private fun initGeneratorWithKeyGenParameterSpec(generator: KeyPairGenerator, alias: String) { - val builder = KeyGenParameterSpec.Builder(alias, KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT) - .setBlockModes(KeyProperties.BLOCK_MODE_ECB) - .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_RSA_PKCS1) + val builder = KeyGenParameterSpec.Builder( + alias, + KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT + ) + .setBlockModes(KeyProperties.BLOCK_MODE_ECB) + .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_RSA_PKCS1) generator.initialize(builder.build()) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/deeplinks/UriToIntentMapper.kt b/presentation/src/main/java/io/forus/me/android/presentation/deeplinks/UriToIntentMapper.kt index 2310e9775..37bf61b47 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/deeplinks/UriToIntentMapper.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/deeplinks/UriToIntentMapper.kt @@ -38,6 +38,7 @@ class UriToIntentMapper(private val mContext: Context, private val navigator: Na } + "identity-confirmation" -> { val bQuery = uri.getQueryParameter("token") bQuery?.let { navigator.navigateToResoreAccountSuccess(mContext, it, true) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/exception/ErrorMessageFactory.java b/presentation/src/main/java/io/forus/me/android/presentation/exception/ErrorMessageFactory.java index 8fe8731c9..128d8392d 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/exception/ErrorMessageFactory.java +++ b/presentation/src/main/java/io/forus/me/android/presentation/exception/ErrorMessageFactory.java @@ -1,12 +1,12 @@ /** * Copyright (C) 2015 Fernando Cejas Open Source Project - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,24 +24,24 @@ */ public class ErrorMessageFactory { - private ErrorMessageFactory() { - //empty - } + private ErrorMessageFactory() { + //empty + } - /** - * Creates a String representing an error message. - * - * @param context Context needed to retrieve string resources. - * @param exception An exception used as a condition to retrieve the correct error message. - * @return {@link String} an error message. - */ - public static String create(Context context, Exception exception) { - String message = context.getString(io.forus.me.android.presentation.R.string.app_exception_message_generic); + /** + * Creates a String representing an error message. + * + * @param context Context needed to retrieve string resources. + * @param exception An exception used as a condition to retrieve the correct error message. + * @return {@link String} an error message. + */ + public static String create(Context context, Exception exception) { + String message = context.getString(io.forus.me.android.presentation.R.string.app_exception_message_generic); - if (exception instanceof NetworkConnectionException) { - message = context.getString(io.forus.me.android.presentation.R.string.app_exception_message_no_connection); - } + if (exception instanceof NetworkConnectionException) { + message = context.getString(io.forus.me.android.presentation.R.string.app_exception_message_no_connection); + } - return message; - } + return message; + } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/extensions/String.kt b/presentation/src/main/java/io/forus/me/android/presentation/extensions/String.kt index 002f61e81..0bc3d58cd 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/extensions/String.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/extensions/String.kt @@ -1,11 +1,12 @@ package io.forus.me.android.presentation.extensions fun String.maskSymbols(from: Int, to: Char): String { - if(from >= this.length) return this + if (from >= this.length) return this return this.substring(0, from) + this.substring(from).map { _ -> to }.joinToString("") } -fun String.maskStartingFromPreservingTail(from: Int, to: Char, unmaskedEnd:Int): String { - if(from >= this.length) return this - return this.substring(0, from) + this.substring(from, this.length-unmaskedEnd).map { _ -> to }.joinToString("") + this.substring(this.length-unmaskedEnd) +fun String.maskStartingFromPreservingTail(from: Int, to: Char, unmaskedEnd: Int): String { + if (from >= this.length) return this + return this.substring(0, from) + this.substring(from, this.length - unmaskedEnd).map { _ -> to } + .joinToString("") + this.substring(this.length - unmaskedEnd) } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/firestore_logging/FirestoreTokenManager.kt b/presentation/src/main/java/io/forus/me/android/presentation/firestore_logging/FirestoreTokenManager.kt index c8a5e4bb3..0c8c42e3e 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/firestore_logging/FirestoreTokenManager.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/firestore_logging/FirestoreTokenManager.kt @@ -12,18 +12,16 @@ import io.reactivex.schedulers.Schedulers import java.math.BigDecimal class FirestoreTokenManager constructor( - private val accountRepository: AccountRepository) { + private val accountRepository: AccountRepository +) { private val TAG = "FirestoreLogger" - private fun getServerApiKey() = if (BuildConfig.SERVER_API_KEY.isNullOrEmpty()) null else BuildConfig.SERVER_API_KEY - - - public fun authorizeFirestore(onComplete: (()->(Unit))?) { + public fun authorizeFirestore(onComplete: (() -> (Unit))?) { getServerApiKey()?.let { serverApiKey -> getFirestoreToken(serverApiKey, onComplete) } ?: kotlin.run { @@ -34,7 +32,7 @@ class FirestoreTokenManager constructor( } } - private fun getFirestoreToken(serverApiKey: String,onComplete: (()->(Unit))?) { + private fun getFirestoreToken(serverApiKey: String, onComplete: (() -> (Unit))?) { accountRepository.getFirestoreToken(serverApiKey) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) @@ -55,20 +53,20 @@ class FirestoreTokenManager constructor( } - private fun registerFirestoreUser(firestoreToken: String, onComplete: (()->(Unit))?) { + private fun registerFirestoreUser(firestoreToken: String, onComplete: (() -> (Unit))?) { FirebaseAuth.getInstance().signInWithCustomToken(firestoreToken) .addOnCompleteListener { task -> if (task.isSuccessful) { val user = FirebaseAuth.getInstance().currentUser - Log.d(TAG,"Firestore user uid: ${user?.uid}") + Log.d(TAG, "Firestore user uid: ${user?.uid}") onComplete?.invoke() - }else { + } else { Log.w("FirestoreLogger", "signInWithCustomToken:failure", task.exception) } } .addOnFailureListener { - Log.e( TAG, it.localizedMessage) + Log.e(TAG, it.localizedMessage) } } // @@ -79,11 +77,11 @@ class FirestoreTokenManager constructor( ) { if (FirebaseAuth.getInstance().currentUser == null) { - authorizeFirestore{ - logTransaction(address,amount,note,organizationId,success,error) + authorizeFirestore { + logTransaction(address, amount, note, organizationId, success, error) } - }else{ - logTransaction(address,amount,note,organizationId,success,error) + } else { + logTransaction(address, amount, note, organizationId, success, error) } } @@ -139,20 +137,20 @@ class FirestoreTokenManager constructor( //GetVoucherAsProvider public fun writeGetVoucherAsProvider( - address: String, success: Boolean, error: String? + address: String, success: Boolean, error: String? ) { if (FirebaseAuth.getInstance().currentUser == null) { - authorizeFirestore{ - logGetVoucherAsProvider(address,success,error) + authorizeFirestore { + logGetVoucherAsProvider(address, success, error) } - }else{ - logGetVoucherAsProvider(address,success,error) + } else { + logGetVoucherAsProvider(address, success, error) } } private fun logGetVoucherAsProvider( - address: String, success: Boolean, error: String? + address: String, success: Boolean, error: String? ) { val currentUser = FirebaseAuth.getInstance().currentUser @@ -199,20 +197,20 @@ class FirestoreTokenManager constructor( //GetProductVoucherAsProvider public fun writeGetProductVoucherAsProvider( - address: String, success: Boolean, error: String? + address: String, success: Boolean, error: String? ) { if (FirebaseAuth.getInstance().currentUser == null) { - authorizeFirestore{ - logGetProductVoucherAsProvider(address,success,error) + authorizeFirestore { + logGetProductVoucherAsProvider(address, success, error) } - }else{ - logGetProductVoucherAsProvider(address,success,error) + } else { + logGetProductVoucherAsProvider(address, success, error) } } private fun logGetProductVoucherAsProvider( - address: String, success: Boolean, error: String? + address: String, success: Boolean, error: String? ) { val currentUser = FirebaseAuth.getInstance().currentUser diff --git a/presentation/src/main/java/io/forus/me/android/presentation/helpers/AppSettings.kt b/presentation/src/main/java/io/forus/me/android/presentation/helpers/AppSettings.kt index eac72cdeb..612904a7e 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/helpers/AppSettings.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/helpers/AppSettings.kt @@ -35,7 +35,8 @@ class AppSettings(private val context: Context) : SettingsDataSource { publicKey = store.public } - private var sPref: SharedPreferences = context.getSharedPreferences(SETTINGS_FILENAME, MODE_PRIVATE) + private var sPref: SharedPreferences = + context.getSharedPreferences(SETTINGS_FILENAME, MODE_PRIVATE) override fun clear() { sPref.edit().clear().commit() @@ -62,7 +63,7 @@ class AppSettings(private val context: Context) : SettingsDataSource { override fun getPin(): String { val pin = sPref.getString(PINCODE_ENCRYPTED, "") - return if (pin != "") cipher.decrypt(pin?:"", privateKey) else "" + return if (pin != "") cipher.decrypt(pin ?: "", privateKey) else "" } override fun setFCMToken(token: String): Boolean { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/helpers/Converter.kt b/presentation/src/main/java/io/forus/me/android/presentation/helpers/Converter.kt index 7e2603cb3..d2c50a86f 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/helpers/Converter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/helpers/Converter.kt @@ -37,7 +37,7 @@ object Converter { fun convertBigDecimalToStringNL(currency: BigDecimal): String { var out = NumberFormat.getCurrencyInstance(Locale("nl", "NL")) - .format(currency) + .format(currency) out = out.replace(".00", ",-") out = out.replace(",00", ",-") return out @@ -46,11 +46,11 @@ object Converter { fun convertBigDecimalToDiscountString(discount: BigDecimal): String { var out = discount.toPlainString()// = NumberFormat.getCurrencyInstance(Locale("nl", "NL")) - //.format(discount) - if((discount.toDouble() - discount.toDouble().roundToInt()) == 0.0){ + //.format(discount) + if ((discount.toDouble() - discount.toDouble().roundToInt()) == 0.0) { out = out.replace(".00", "%") out = out.replace(",00", "%") - }else{ + } else { out += "%" } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/helpers/FontCache.java b/presentation/src/main/java/io/forus/me/android/presentation/helpers/FontCache.java index bd08aaaf8..435bc6a99 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/helpers/FontCache.java +++ b/presentation/src/main/java/io/forus/me/android/presentation/helpers/FontCache.java @@ -11,11 +11,10 @@ public class FontCache { public static Typeface getTypeface(String name, Context context) { Typeface tf = fontCache.get(name); - if(tf == null) { + if (tf == null) { try { tf = Typeface.createFromAsset(context.getAssets(), name); - } - catch (Exception e) { + } catch (Exception e) { return null; } fontCache.put(name, tf); diff --git a/presentation/src/main/java/io/forus/me/android/presentation/helpers/ImageLoader.java b/presentation/src/main/java/io/forus/me/android/presentation/helpers/ImageLoader.java index ca5d37205..27ec2322c 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/helpers/ImageLoader.java +++ b/presentation/src/main/java/io/forus/me/android/presentation/helpers/ImageLoader.java @@ -20,9 +20,6 @@ private ImageLoader(Context context) { } - - - public static void load(Context context, String url, final ImageView imageView) { if (imageView == null || url == null) @@ -35,7 +32,4 @@ public static void load(Context context, String url, final ImageView imageView) } - - - } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/helpers/NumberUtils.kt b/presentation/src/main/java/io/forus/me/android/presentation/helpers/NumberUtils.kt index 825336f1d..e011329c5 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/helpers/NumberUtils.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/helpers/NumberUtils.kt @@ -5,8 +5,6 @@ import java.util.Locale object NumberUtils { - - fun roundFloatToTwoDigits(number: Float): Float { var pow = 10 @@ -22,10 +20,10 @@ object NumberUtils { } - } -fun Double?.format(digits: Int = 6) = (if (this == null) "" else java.lang.String.format(Locale.US, "%.${digits}f", this))!! +fun Double?.format(digits: Int = 6) = + (if (this == null) "" else java.lang.String.format(Locale.US, "%.${digits}f", this))!! fun Float?.format(digits: Int = 6) = this?.toDouble().format(digits) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/helpers/OnCompleteListener.java b/presentation/src/main/java/io/forus/me/android/presentation/helpers/OnCompleteListener.java index e99c1442f..cca299aa2 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/helpers/OnCompleteListener.java +++ b/presentation/src/main/java/io/forus/me/android/presentation/helpers/OnCompleteListener.java @@ -1,5 +1,5 @@ package io.forus.me.android.presentation.helpers; -public interface OnCompleteListener { +public interface OnCompleteListener { void onResume(); } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/helpers/PaginationScrollListener.java b/presentation/src/main/java/io/forus/me/android/presentation/helpers/PaginationScrollListener.java index 5293166ff..2f9d61404 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/helpers/PaginationScrollListener.java +++ b/presentation/src/main/java/io/forus/me/android/presentation/helpers/PaginationScrollListener.java @@ -3,7 +3,7 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -public abstract class PaginationScrollListener extends RecyclerView.OnScrollListener { +public abstract class PaginationScrollListener extends RecyclerView.OnScrollListener { private LinearLayoutManager layoutManager; @@ -12,7 +12,6 @@ public PaginationScrollListener(LinearLayoutManager layoutManager) { } - @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); diff --git a/presentation/src/main/java/io/forus/me/android/presentation/helpers/Strings.kt b/presentation/src/main/java/io/forus/me/android/presentation/helpers/Strings.kt index 5d1cbcbd8..54136451d 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/helpers/Strings.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/helpers/Strings.kt @@ -18,7 +18,8 @@ object Strings { fun capitalize(str: String): String? { if (isNullOrEmpty(str)) return str - return if (str.length == 0) str else str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase() + return if (str.length == 0) str else str.substring(0, 1).toUpperCase() + str.substring(1) + .toLowerCase() } @@ -28,11 +29,10 @@ object Strings { } - } -fun String?.capitalize() : String { +fun String?.capitalize(): String { if (this == null) return "" @@ -40,20 +40,20 @@ fun String?.capitalize() : String { } -fun String?.toAppFloat() : Float? { +fun String?.toAppFloat(): Float? { if (this == null) return null return this.toAppFloat() } -fun String.toAppFloat() : Float { +fun String.toAppFloat(): Float { val myNumForm = NumberFormat.getInstance(Locale.getDefault()) val myParsedFrenchNumber = myNumForm.parse(this).toFloat() return myParsedFrenchNumber } -fun String?.toAppDoubleOrNull() : Double { +fun String?.toAppDoubleOrNull(): Double { val myNumForm = NumberFormat.getInstance(Locale.getDefault()) val myParsedFrenchNumber = myNumForm.parse(this).toFloat().toDouble() return myParsedFrenchNumber diff --git a/presentation/src/main/java/io/forus/me/android/presentation/helpers/ViewUtils.kt b/presentation/src/main/java/io/forus/me/android/presentation/helpers/ViewUtils.kt index 4a8a2f1a1..01434132e 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/helpers/ViewUtils.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/helpers/ViewUtils.kt @@ -7,7 +7,7 @@ import android.widget.ViewAnimator import androidx.annotation.LayoutRes fun ViewGroup.inflate(@LayoutRes layoutRes: Int, attachToRoot: Boolean = false): View = - LayoutInflater.from(context).inflate(layoutRes, this, attachToRoot) + LayoutInflater.from(context).inflate(layoutRes, this, attachToRoot) fun ViewAnimator.showIfNotYet(child: Int) { if (child != displayedChild) { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/helpers/fcm/FCMHandler.kt b/presentation/src/main/java/io/forus/me/android/presentation/helpers/fcm/FCMHandler.kt index 2eee0325b..cc509552c 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/helpers/fcm/FCMHandler.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/helpers/fcm/FCMHandler.kt @@ -12,7 +12,10 @@ import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers -class FCMHandler(private val accountRepository: AccountRepository, private val settings: SettingsDataSource) { +class FCMHandler( + private val accountRepository: AccountRepository, + private val settings: SettingsDataSource +) { fun checkFCMToken(activity: Activity): Observable { return Observable.fromPublisher { publisher -> @@ -38,26 +41,24 @@ class FCMHandler(private val accountRepository: AccountRepository, private val s fun registerFCMToken(token: String): Observable { return accountRepository.registerFCMToken(token) - .map { - Log.d("FCM_TOKEN_REGISTERED", token) - settings.setFCMToken(token) - Unit - } - .onErrorReturn { - Log.e("FCM_TOKEN_REGISTER_ERR", it.message, it) - } - } - - fun clearFCMToken()= Observable.fromCallable { - FirebaseMessaging.getInstance().deleteToken().addOnSuccessListener { - Log.d("FCM_TOKEN_CLEAR", "OK") + .map { + Log.d("FCM_TOKEN_REGISTERED", token) + settings.setFCMToken(token) Unit } - }.doOnError { - Log.e("FCM_TOKEN_CLEAR_THROWS", it.message?:"") - } - + .onErrorReturn { + Log.e("FCM_TOKEN_REGISTER_ERR", it.message, it) + } + } + fun clearFCMToken() = Observable.fromCallable { + FirebaseMessaging.getInstance().deleteToken().addOnSuccessListener { + Log.d("FCM_TOKEN_CLEAR", "OK") + Unit + } + }.doOnError { + Log.e("FCM_TOKEN_CLEAR_THROWS", it.message ?: "") + } companion object { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/helpers/reactivex/AccessTokenChecker.kt b/presentation/src/main/java/io/forus/me/android/presentation/helpers/reactivex/AccessTokenChecker.kt index d1fe2843f..b275f5ac5 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/helpers/reactivex/AccessTokenChecker.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/helpers/reactivex/AccessTokenChecker.kt @@ -9,25 +9,41 @@ import io.reactivex.schedulers.Schedulers import io.reactivex.subjects.PublishSubject import java.util.concurrent.TimeUnit -class AccessTokenChecker(val serviceEndpoint: String){ +class AccessTokenChecker(val serviceEndpoint: String) { companion object { private const val CHECK_ACTIVATION_DELAY_MILLIS = 1000L } - fun startCheckingActivation(accessToken: String, activationComplete: PublishSubject): Disposable{ - val checkActivationDataSource = CheckActivationDataSource(MeServiceFactory.getInstance().createRetrofitService(SignService::class.java, serviceEndpoint)) + fun startCheckingActivation( + accessToken: String, + activationComplete: PublishSubject + ): Disposable { + val checkActivationDataSource = CheckActivationDataSource( + MeServiceFactory.getInstance() + .createRetrofitService(SignService::class.java, serviceEndpoint) + ) return checkActivationDataSource.checkActivation(accessToken) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .retryWhen{throwables -> throwables.delay(CHECK_ACTIVATION_DELAY_MILLIS, TimeUnit.MILLISECONDS)} - .repeatWhen{observable -> observable.delay(CHECK_ACTIVATION_DELAY_MILLIS, TimeUnit.MILLISECONDS)} - .takeUntil{it == true} - .subscribe { isActivated -> - if(isActivated) activationComplete.onNext(Unit) - } + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .retryWhen { throwables -> + throwables.delay( + CHECK_ACTIVATION_DELAY_MILLIS, + TimeUnit.MILLISECONDS + ) + } + .repeatWhen { observable -> + observable.delay( + CHECK_ACTIVATION_DELAY_MILLIS, + TimeUnit.MILLISECONDS + ) + } + .takeUntil { it == true } + .subscribe { isActivated -> + if (isActivated) activationComplete.onNext(Unit) + } } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/helpers/reactivex/DisposableHolder.kt b/presentation/src/main/java/io/forus/me/android/presentation/helpers/reactivex/DisposableHolder.kt index ce18f31ae..b1378dff6 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/helpers/reactivex/DisposableHolder.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/helpers/reactivex/DisposableHolder.kt @@ -2,15 +2,15 @@ package io.forus.me.android.presentation.helpers.reactivex import io.reactivex.disposables.Disposable -class DisposableHolder{ +class DisposableHolder { private val disposables: MutableList = mutableListOf() - fun add(disposable: Disposable){ + fun add(disposable: Disposable) { disposables.add(disposable) } - fun disposeAll(){ + fun disposeAll() { disposables.forEach { it.dispose() } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/interfaces/FragmentListener.java b/presentation/src/main/java/io/forus/me/android/presentation/interfaces/FragmentListener.java index 5813058e4..f8700c9c2 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/interfaces/FragmentListener.java +++ b/presentation/src/main/java/io/forus/me/android/presentation/interfaces/FragmentListener.java @@ -3,8 +3,7 @@ public interface FragmentListener { - String getTitle(); - + String getTitle(); } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/internal/Injection.kt b/presentation/src/main/java/io/forus/me/android/presentation/internal/Injection.kt index c64881c26..cf87a1db8 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/internal/Injection.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/internal/Injection.kt @@ -72,15 +72,18 @@ class Injection private constructor() { } - - val commonRepository: CommonRepository by lazy { - return@lazy io.forus.me.android.data.repository.common.CommonRepository(commonRemoteDataSource) + return@lazy io.forus.me.android.data.repository.common.CommonRepository( + commonRemoteDataSource + ) } private val commonRemoteDataSource: CommonRemoteDataSource by lazy { - return@lazy CommonRemoteDataSource{MeServiceFactory.getInstance().createRetrofitService(CommonService::class.java, ApiConfig.SERVER_URL) } + return@lazy CommonRemoteDataSource { + MeServiceFactory.getInstance() + .createRetrofitService(CommonService::class.java, ApiConfig.SERVER_URL) + } } @@ -89,7 +92,13 @@ class Injection private constructor() { } val accountRepository: AccountRepository by lazy { - return@lazy io.forus.me.android.data.repository.account.AccountRepository(settingsDataSource, accountLocalDataSource, accountRemoteDataSource, checkActivationDataSource, recordsRepository) + return@lazy io.forus.me.android.data.repository.account.AccountRepository( + settingsDataSource, + accountLocalDataSource, + accountRemoteDataSource, + checkActivationDataSource, + recordsRepository + ) } val firestoreTokenManager: FirestoreTokenManager by lazy { @@ -101,7 +110,10 @@ class Injection private constructor() { } private val accountRemoteDataSource: AccountRemoteDataSource by lazy { - return@lazy AccountRemoteDataSource { MeServiceFactory.getInstance().createRetrofitService(SignService::class.java, ApiConfig.SERVER_URL) } + return@lazy AccountRemoteDataSource { + MeServiceFactory.getInstance() + .createRetrofitService(SignService::class.java, ApiConfig.SERVER_URL) + } } val accountLocalDataSource: AccountLocalDataSource by lazy { @@ -109,7 +121,10 @@ class Injection private constructor() { } private val checkActivationDataSource: CheckActivationDataSource by lazy { - return@lazy CheckActivationDataSource(MeServiceFactory.getInstance().createRetrofitService(SignService::class.java, ApiConfig.SERVER_URL)) + return@lazy CheckActivationDataSource( + MeServiceFactory.getInstance() + .createRetrofitService(SignService::class.java, ApiConfig.SERVER_URL) + ) } private val web3LocalDataSource: Web3DataSource by lazy { @@ -125,16 +140,23 @@ class Injection private constructor() { } val vouchersDataSource: VouchersDataSource by lazy { - return@lazy VouchersRemoteDataSource { MeServiceFactory.getInstance().createRetrofitService(VouchersService::class.java, ApiConfig.SERVER_URL) } + return@lazy VouchersRemoteDataSource { + MeServiceFactory.getInstance() + .createRetrofitService(VouchersService::class.java, ApiConfig.SERVER_URL) + } } val vouchersRepository: VouchersRepository by lazy { - return@lazy io.forus.me.android.data.repository.vouchers.VouchersRepository(vouchersDataSource) + return@lazy io.forus.me.android.data.repository.vouchers.VouchersRepository( + vouchersDataSource + ) } val recordsRepository: RecordsRepository by lazy { - return@lazy io.forus.me.android.data.repository.records.RecordsRepository(recordRemoteDataSource) + return@lazy io.forus.me.android.data.repository.records.RecordsRepository( + recordRemoteDataSource + ) } private val recordsMockDataSource: RecordsMockDataSource by lazy { @@ -142,7 +164,10 @@ class Injection private constructor() { } private val recordRemoteDataSource: RecordsRemoteDataSource by lazy { - return@lazy RecordsRemoteDataSource { MeServiceFactory.getInstance().createRetrofitService(RecordsService::class.java, ApiConfig.SERVER_URL) } + return@lazy RecordsRemoteDataSource { + MeServiceFactory.getInstance() + .createRetrofitService(RecordsService::class.java, ApiConfig.SERVER_URL) + } } val retrofitExceptionMapper: RetrofitExceptionMapper by lazy { @@ -150,7 +175,10 @@ class Injection private constructor() { } private val validatorsRemoteDataSource: ValidatorsRemoteDataSource by lazy { - return@lazy ValidatorsRemoteDataSource { MeServiceFactory.getInstance().createRetrofitService(ValidatorsService::class.java, ApiConfig.SERVER_URL) } + return@lazy ValidatorsRemoteDataSource { + MeServiceFactory.getInstance() + .createRetrofitService(ValidatorsService::class.java, ApiConfig.SERVER_URL) + } } val validatorsRepository: ValidatorsRepository by lazy { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/mappers/OfficeDataMapper.kt b/presentation/src/main/java/io/forus/me/android/presentation/mappers/OfficeDataMapper.kt index 8024ec445..dda80d19a 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/mappers/OfficeDataMapper.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/mappers/OfficeDataMapper.kt @@ -5,26 +5,30 @@ import io.forus.me.android.presentation.models.vouchers.Organization import io.forus.me.android.presentation.models.vouchers.Schedule import io.forus.me.android.domain.models.vouchers.Office as OfficeDomain -class OfficeDataMapper(val shedullerDataMapper: SchedulerDataMapper) : Mapper() { +class OfficeDataMapper(val shedullerDataMapper: SchedulerDataMapper) : + Mapper() { override fun transform(domainModel: OfficeDomain) = - Office(domainModel.id, domainModel.organizationId, domainModel.address ?: "", - domainModel.phone ?: "", domainModel.lat, domainModel.lon, domainModel.photo, - if (domainModel.organization != null) { - Organization(domainModel.organization!!.id, - domainModel.organization!!.name ?: "", - domainModel.organization!!.logo ?: "", - domainModel.organization!!.lat - ?: 0f.toDouble(), domainModel.organization!!.lon - ?: 0f.toDouble(), - domainModel.organization!!.address - ?: "", domainModel.organization!!.phone ?: "", - domainModel.organization!!.email ?: "") - } else { - null - }, + Office( + domainModel.id, domainModel.organizationId, domainModel.address ?: "", + domainModel.phone ?: "", domainModel.lat, domainModel.lon, domainModel.photo, + if (domainModel.organization != null) { + Organization( + domainModel.organization!!.id, + domainModel.organization!!.name ?: "", + domainModel.organization!!.logo ?: "", + domainModel.organization!!.lat + ?: 0f.toDouble(), domainModel.organization!!.lon + ?: 0f.toDouble(), + domainModel.organization!!.address + ?: "", domainModel.organization!!.phone ?: "", + domainModel.organization!!.email ?: "" + ) + } else { + null + }, - shedullerDataMapper.transform(domainModel.schedulers) as List + shedullerDataMapper.transform(domainModel.schedulers) as List - ) + ) } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/mappers/OrganizationDataMapper.kt b/presentation/src/main/java/io/forus/me/android/presentation/mappers/OrganizationDataMapper.kt index bca9b119e..2f90f0c4f 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/mappers/OrganizationDataMapper.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/mappers/OrganizationDataMapper.kt @@ -6,5 +6,5 @@ import io.forus.me.android.domain.models.vouchers.Organization as OrganizationDo class OrganizationDataMapper : Mapper() { override fun transform(domainModel: OrganizationDomain) = - Organization(domainModel.id, domainModel.name ?: "", domainModel.logo ?: "") + Organization(domainModel.id, domainModel.name ?: "", domainModel.logo ?: "") } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/mappers/ProductDataMapper.kt b/presentation/src/main/java/io/forus/me/android/presentation/mappers/ProductDataMapper.kt index fc49de2e7..1db89a9b7 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/mappers/ProductDataMapper.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/mappers/ProductDataMapper.kt @@ -8,29 +8,42 @@ import io.forus.me.android.domain.models.vouchers.Product as ProductDomain class ProductDataMapper : Mapper() { override fun transform(domainModel: ProductDomain): Product = - Product(domainModel.id ?: -1L, domainModel.organizationId - ?: -1L, domainModel.productCategoryId - ?: -1L, domainModel.name, domainModel.description, domainModel.price ?: BigDecimal(-1), - domainModel.oldPrice ?: BigDecimal(-1), domainModel.totalAmount - ?: -1L, domainModel.soldAmount ?: -1L, - if (domainModel.productCategory != null) { - ProductCategory(domainModel.productCategory!!.id, domainModel.productCategory!!.key - ?: "", - domainModel.productCategory!!.name ?: "") - } else { - null - }, - if (domainModel.organization != null) { - Organization(domainModel.organization!!.id, - domainModel.organization!!.name ?: "", - domainModel.organization!!.logo ?: "", - domainModel.organization!!.lat - ?: 0f.toDouble(), domainModel.organization!!.lon - ?: 0f.toDouble(), - domainModel.organization!!.address - ?: "", domainModel.organization!!.phone ?: "", - domainModel.organization!!.email ?: "") - } else { - null - }) + Product( + domainModel.id ?: -1L, + domainModel.organizationId + ?: -1L, + domainModel.productCategoryId + ?: -1L, + domainModel.name, + domainModel.description, + domainModel.price ?: BigDecimal(-1), + domainModel.oldPrice ?: BigDecimal(-1), + domainModel.totalAmount + ?: -1L, + domainModel.soldAmount ?: -1L, + if (domainModel.productCategory != null) { + ProductCategory( + domainModel.productCategory!!.id, domainModel.productCategory!!.key + ?: "", + domainModel.productCategory!!.name ?: "" + ) + } else { + null + }, + if (domainModel.organization != null) { + Organization( + domainModel.organization!!.id, + domainModel.organization!!.name ?: "", + domainModel.organization!!.logo ?: "", + domainModel.organization!!.lat + ?: 0f.toDouble(), domainModel.organization!!.lon + ?: 0f.toDouble(), + domainModel.organization!!.address + ?: "", domainModel.organization!!.phone ?: "", + domainModel.organization!!.email ?: "" + ) + } else { + null + } + ) } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/mappers/SchedulerDataMapper.kt b/presentation/src/main/java/io/forus/me/android/presentation/mappers/SchedulerDataMapper.kt index cb3327e30..36ed34462 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/mappers/SchedulerDataMapper.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/mappers/SchedulerDataMapper.kt @@ -6,6 +6,8 @@ import io.forus.me.android.domain.models.vouchers.Schedule as ScheduleDomain class SchedulerDataMapper : Mapper() { override fun transform(domainModel: ScheduleDomain) = - Schedule(domainModel.id, domainModel.officeId ?: -1L , domainModel.weekDay ?: 0, - domainModel.startTime ?: "", domainModel.endTime ?:"" ) + Schedule( + domainModel.id, domainModel.officeId ?: -1L, domainModel.weekDay ?: 0, + domainModel.startTime ?: "", domainModel.endTime ?: "" + ) } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/models/currency/Currency.kt b/presentation/src/main/java/io/forus/me/android/presentation/models/currency/Currency.kt index e04f1d1af..aa881ee80 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/models/currency/Currency.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/models/currency/Currency.kt @@ -5,7 +5,7 @@ import android.os.Parcelable class Currency(var name: String? = "", var logoUrl: String? = "") : Parcelable { - constructor(parcel: Parcel) : this(parcel.readString() ?: "", parcel.readString() ?: "") + constructor(parcel: Parcel) : this(parcel.readString() ?: "", parcel.readString() ?: "") override fun writeToParcel(parcel: Parcel, flags: Int) { parcel.writeString(name) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/Office.kt b/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/Office.kt index 83c8e015d..25aaf360e 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/Office.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/Office.kt @@ -4,25 +4,28 @@ import android.os.Parcel import android.os.Parcelable -class Office(var id: Long = -1L, - var organizationId: Long? = -1L, - var address: String? = "", - var phone: String? = "", - var lat: Double? = 0.0, - var lon: Double? = 0.0, - var photo: String? = "", - var organization: Organization?, - var schedulers: List) : Parcelable { +class Office( + var id: Long = -1L, + var organizationId: Long? = -1L, + var address: String? = "", + var phone: String? = "", + var lat: Double? = 0.0, + var lon: Double? = 0.0, + var photo: String? = "", + var organization: Organization?, + var schedulers: List +) : Parcelable { constructor(parcel: Parcel) : this( - parcel.readLong(), - parcel.readLong(), - parcel.readString(), - parcel.readString(), - parcel.readDouble(), - parcel.readDouble(), - parcel.readString(), - parcel.readParcelable(Organization::class.java.classLoader) ?: Organization(), - parcel.createTypedArrayList(Schedule)?: listOf()) { + parcel.readLong(), + parcel.readLong(), + parcel.readString(), + parcel.readString(), + parcel.readDouble(), + parcel.readDouble(), + parcel.readString(), + parcel.readParcelable(Organization::class.java.classLoader) ?: Organization(), + parcel.createTypedArrayList(Schedule) ?: listOf() + ) { } override fun writeToParcel(parcel: Parcel, flags: Int) { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/Organization.kt b/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/Organization.kt index 080297b5d..7c5b6edfd 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/Organization.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/Organization.kt @@ -3,23 +3,26 @@ package io.forus.me.android.presentation.models.vouchers import android.os.Parcel import android.os.Parcelable -class Organization(var id: Long = -1L, - var name: String? = "", - var logo: String? = "", - var lat: Double? = 0.0, - var lon: Double? = 0.0, - var address: String? = "", - var phone: String? = "", - var email: String? = "") : Parcelable { +class Organization( + var id: Long = -1L, + var name: String? = "", + var logo: String? = "", + var lat: Double? = 0.0, + var lon: Double? = 0.0, + var address: String? = "", + var phone: String? = "", + var email: String? = "" +) : Parcelable { constructor(parcel: Parcel) : this( - parcel.readLong(), - parcel.readString(), - parcel.readString(), - parcel.readDouble(), - parcel.readDouble(), - parcel.readString(), - parcel.readString(), - parcel.readString()) { + parcel.readLong(), + parcel.readString(), + parcel.readString(), + parcel.readDouble(), + parcel.readDouble(), + parcel.readString(), + parcel.readString(), + parcel.readString() + ) { } override fun writeToParcel(parcel: Parcel, flags: Int) { @@ -27,7 +30,7 @@ class Organization(var id: Long = -1L, parcel.writeString(name) parcel.writeString(logo) parcel.writeDouble(lat ?: 0.0) - parcel.writeDouble(lon ?: 0.0) + parcel.writeDouble(lon ?: 0.0) parcel.writeString(address) parcel.writeString(phone) parcel.writeString(email) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/Product.kt b/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/Product.kt index dd811d452..39be09c72 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/Product.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/Product.kt @@ -4,29 +4,32 @@ import android.os.Parcel import android.os.Parcelable import java.math.BigDecimal -class Product(var id: Long = -1L, - var organizationId: Long = -1L, - var productCategoryId: Long = -1L, - var name: String?, - var description: String?, - var price: BigDecimal = BigDecimal(0), - var oldPrice: BigDecimal= BigDecimal(0), - var totalAmount: Long = -1L, - var soldAmount: Long = -1L, - var productCategory: ProductCategory?, - var organization: Organization?) : Parcelable { +class Product( + var id: Long = -1L, + var organizationId: Long = -1L, + var productCategoryId: Long = -1L, + var name: String?, + var description: String?, + var price: BigDecimal = BigDecimal(0), + var oldPrice: BigDecimal = BigDecimal(0), + var totalAmount: Long = -1L, + var soldAmount: Long = -1L, + var productCategory: ProductCategory?, + var organization: Organization? +) : Parcelable { constructor(parcel: Parcel) : this( - parcel.readLong(), - parcel.readLong(), - parcel.readLong(), - parcel.readString(), - parcel.readString(), - BigDecimal(parcel.readDouble()), - BigDecimal(parcel.readDouble()), - parcel.readLong(), - parcel.readLong(), - parcel.readParcelable(ProductCategory::class.java.classLoader), - parcel.readParcelable(Organization::class.java.classLoader)) + parcel.readLong(), + parcel.readLong(), + parcel.readLong(), + parcel.readString(), + parcel.readString(), + BigDecimal(parcel.readDouble()), + BigDecimal(parcel.readDouble()), + parcel.readLong(), + parcel.readLong(), + parcel.readParcelable(ProductCategory::class.java.classLoader), + parcel.readParcelable(Organization::class.java.classLoader) + ) override fun writeToParcel(parcel: Parcel, flags: Int) { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/ProductCategory.kt b/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/ProductCategory.kt index 9dc1f0ceb..a85e3d253 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/ProductCategory.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/ProductCategory.kt @@ -5,9 +5,10 @@ import android.os.Parcelable class ProductCategory(var id: Long, var key: String?, var name: String?) : Parcelable { constructor(parcel: Parcel) : this( - parcel.readLong(), - parcel.readString() ?: "", - parcel.readString() ?: "") + parcel.readLong(), + parcel.readString() ?: "", + parcel.readString() ?: "" + ) override fun writeToParcel(parcel: Parcel, flags: Int) { parcel.writeLong(id) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/Schedule.kt b/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/Schedule.kt index 416988641..d92ce038f 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/Schedule.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/Schedule.kt @@ -3,17 +3,20 @@ package io.forus.me.android.presentation.models.vouchers import android.os.Parcel import android.os.Parcelable -class Schedule(var id: Long = -1L, - var officeId: Long = -1L, - var weekDay: Long = -1L, - var startTime: String?, - var endTime: String?) : Parcelable { +class Schedule( + var id: Long = -1L, + var officeId: Long = -1L, + var weekDay: Long = -1L, + var startTime: String?, + var endTime: String? +) : Parcelable { constructor(parcel: Parcel) : this( - parcel.readLong(), - parcel.readLong(), - parcel.readLong(), - parcel.readString(), - parcel.readString()) + parcel.readLong(), + parcel.readLong(), + parcel.readLong(), + parcel.readString(), + parcel.readString() + ) override fun writeToParcel(parcel: Parcel, flags: Int) { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/VoucherProvider.kt b/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/VoucherProvider.kt index 34500cdc8..20351ec00 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/VoucherProvider.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/models/vouchers/VoucherProvider.kt @@ -4,31 +4,35 @@ import android.os.Parcelable import kotlinx.android.parcel.Parcelize @Parcelize -class VoucherProvider(var voucher: Voucher, var allowedOrganizations: List, var allowedProductCategories: List) : Parcelable { - /* constructor(parcel: Parcel) : this( - parcel.readParcelable(Voucher::class.java.classLoader) as Voucher, - parcel.createTypedArrayList(Organization)?: listOf(), - parcel.createTypedArrayList(ProductCategory)?: listOf()) { - } +class VoucherProvider( + var voucher: Voucher, + var allowedOrganizations: List, + var allowedProductCategories: List +) : Parcelable { + /* constructor(parcel: Parcel) : this( + parcel.readParcelable(Voucher::class.java.classLoader) as Voucher, + parcel.createTypedArrayList(Organization)?: listOf(), + parcel.createTypedArrayList(ProductCategory)?: listOf()) { + } - override fun writeToParcel(parcel: Parcel, flags: Int) { - parcel.writeParcelable(voucher, flags) - parcel.writeTypedList(allowedOrganizations) - parcel.writeTypedList(allowedProductCategories) - } + override fun writeToParcel(parcel: Parcel, flags: Int) { + parcel.writeParcelable(voucher, flags) + parcel.writeTypedList(allowedOrganizations) + parcel.writeTypedList(allowedProductCategories) + } - override fun describeContents(): Int { - return 0 - } + override fun describeContents(): Int { + return 0 + } - companion object CREATOR : Parcelable.Creator { - override fun createFromParcel(parcel: Parcel): VoucherProvider { - return VoucherProvider(parcel) - } + companion object CREATOR : Parcelable.Creator { + override fun createFromParcel(parcel: Parcel): VoucherProvider { + return VoucherProvider(parcel) + } - override fun newArray(size: Int): Array { - return arrayOfNulls(size) - } - }*/ + override fun newArray(size: Int): Array { + return arrayOfNulls(size) + } + }*/ } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/navigation/Navigator.kt b/presentation/src/main/java/io/forus/me/android/presentation/navigation/Navigator.kt index 2ecf01fbd..42ab327e7 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/navigation/Navigator.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/navigation/Navigator.kt @@ -46,12 +46,16 @@ constructor()//empty { fun navigateToDashboardPinlocked(context: Context?, useFingerprint: Boolean) { if (context != null) { - val lockIntent = PinLockActivity.getCallingIntent(context, DashboardActivity.getCallingIntent(context), useFingerprint) + val lockIntent = PinLockActivity.getCallingIntent( + context, + DashboardActivity.getCallingIntent(context), + useFingerprint + ) context.startActivity(lockIntent) } } - fun navigateToCheckTransactionPin(context: Context?,intent: Intent, useFingerprint: Boolean) { + fun navigateToCheckTransactionPin(context: Context?, intent: Intent, useFingerprint: Boolean) { if (context != null) { val lockIntent = PinLockActivity.getCallingIntent(context, intent, useFingerprint) context.startActivity(lockIntent) @@ -67,10 +71,10 @@ constructor()//empty } - fun navigateToWelcomeScreen(context: Context?,goToLogin: Boolean) { + fun navigateToWelcomeScreen(context: Context?, goToLogin: Boolean) { if (context != null) { - val intentToLaunch = WelcomeActivity.getCallingIntent(context,goToLogin) - if(goToLogin) { + val intentToLaunch = WelcomeActivity.getCallingIntent(context, goToLogin) + if (goToLogin) { intentToLaunch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or FLAG_ACTIVITY_CLEAR_TASK) } context.startActivity(intentToLaunch) @@ -114,7 +118,7 @@ constructor()//empty } } - fun navigateToPinNew(context: Context?, accessToken: String){ + fun navigateToPinNew(context: Context?, accessToken: String) { if (context != null) { val intentToLaunch = NewPinActivity.getCallingIntent(context, accessToken) context.startActivity(intentToLaunch) @@ -131,14 +135,12 @@ constructor()//empty fun navigateToConfirmRegistration(context: Context?, accessToken: String) { if (context != null) { - val intentToLaunch = ConfirmRegistrationActivity.getCallingIntent(context,accessToken) + val intentToLaunch = ConfirmRegistrationActivity.getCallingIntent(context, accessToken) context.startActivity(intentToLaunch) } } - - fun navigateToAccountRestoreByEmailExchangeToken(context: Context?, token: String) { if (context != null) { val intentToLaunch = RestoreByEmailActivity.getCallingIntent(context, token) @@ -157,8 +159,6 @@ constructor()//empty } - - fun navigateToLoginSignUp(context: Context?, token: String) { if (context != null) { val intentToLaunch = LogInSignUpActivity.getCallingIntent(context, token) @@ -169,14 +169,14 @@ constructor()//empty fun navigateToResoreAccountSuccess(context: Context?, token: String, isExchangeToken: Boolean) { if (context != null) { - val intentToLaunch = RestoreAccountSuccessActivity.getCallingIntent(context, token, isExchangeToken) + val intentToLaunch = + RestoreAccountSuccessActivity.getCallingIntent(context, token, isExchangeToken) intentToLaunch.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) context.startActivity(intentToLaunch) } } - fun navigateToWallet(context: Context?, wallet: Wallet) { if (context != null) { val intentToLaunch = WalletDetailsActivity.getCallingIntent(context, wallet) @@ -226,18 +226,26 @@ constructor()//empty } } - fun navigateToRecordDetailsForResult(context: AppCompatActivity, record: Record, REQUEST_CODE: Int) { + fun navigateToRecordDetailsForResult( + context: AppCompatActivity, + record: Record, + REQUEST_CODE: Int + ) { if (context != null) { val intentToLaunch = RecordDetailsActivity.getCallingIntent(context, record) - context.startActivityForResult(intentToLaunch,REQUEST_CODE) + context.startActivityForResult(intentToLaunch, REQUEST_CODE) } } - - fun navigateToVoucherProvider(context: Context?, voucherAddress: String, isDemoVoucher: Boolean? = false) { + fun navigateToVoucherProvider( + context: Context?, + voucherAddress: String, + isDemoVoucher: Boolean? = false + ) { if (context != null) { - val intentToLaunch = ProviderActivity.getCallingIntent(context, voucherAddress,isDemoVoucher) + val intentToLaunch = + ProviderActivity.getCallingIntent(context, voucherAddress, isDemoVoucher) context.startActivity(intentToLaunch) } } @@ -249,17 +257,25 @@ constructor()//empty } } - fun navigateToProductReservation(context: Context?, voucherAddress: String, showParentVoucher: Boolean) { + fun navigateToProductReservation( + context: Context?, + voucherAddress: String, + showParentVoucher: Boolean + ) { if (context != null) { - val intentToLaunch = ProductReservationActivity.getCallingIntent(context, voucherAddress, showParentVoucher) + val intentToLaunch = ProductReservationActivity.getCallingIntent( + context, + voucherAddress, + showParentVoucher + ) context.startActivity(intentToLaunch) } } - fun navigateToChangePin(caller: Fragment, mode: ChangePinMode, requestCode: Int){ + fun navigateToChangePin(caller: Fragment, mode: ChangePinMode, requestCode: Int) { val context = caller.context - if(context != null){ + if (context != null) { val intentToLaunch = ChangePinActivity.getCallingIntent(context, mode) caller.startActivityForResult(intentToLaunch, requestCode) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/qr/QrDecoder.kt b/presentation/src/main/java/io/forus/me/android/presentation/qr/QrDecoder.kt index 7df423c22..e6825a157 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/qr/QrDecoder.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/qr/QrDecoder.kt @@ -3,7 +3,7 @@ package io.forus.me.android.presentation.qr import com.google.gson.GsonBuilder import io.forus.me.android.domain.models.qr.QrCode -class QrDecoder{ +class QrDecoder { private val gson = GsonBuilder().create() @@ -11,15 +11,19 @@ class QrDecoder{ return try { val qr: QrCode = gson.fromJson(text, QrCode::class.java) - when(qr.type){ + when (qr.type) { QrCode.Type.AUTH_TOKEN -> QrDecoderResult.RestoreIdentity(qr.value) QrCode.Type.VOUCHER -> QrDecoderResult.ScanVoucher(qr.value) QrCode.Type.P2P_RECORD -> QrDecoderResult.ApproveValidation(qr.value) - QrCode.Type.P2P_IDENTITY -> QrDecoderResult.UnknownQr(UnsupportedOperationException("Not implemented")) + QrCode.Type.P2P_IDENTITY -> QrDecoderResult.UnknownQr( + UnsupportedOperationException( + "Not implemented" + ) + ) + QrCode.Type.DEMO_VOUCHER -> QrDecoderResult.DemoVoucher(qr.value) } - } - catch (e: Exception){ + } catch (e: Exception) { QrDecoderResult.UnknownQr(e) } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/MeBottomSheetDialogFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/MeBottomSheetDialogFragment.kt index 27ddd0af1..4205a856d 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/MeBottomSheetDialogFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/MeBottomSheetDialogFragment.kt @@ -1,4 +1,5 @@ package io.forus.me.android.presentation.view + import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -8,7 +9,8 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment import io.forus.me.android.presentation.R import io.forus.me.android.presentation.databinding.FragmentBottomSheetBinding -class MeBottomSheetDialogFragment(private val fragment: Fragment, private val title: String) : BottomSheetDialogFragment() { +class MeBottomSheetDialogFragment(private val fragment: Fragment, private val title: String) : + BottomSheetDialogFragment() { private lateinit var binding: FragmentBottomSheetBinding diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/activity/BaseActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/activity/BaseActivity.kt index ce17f0bc8..731bafdfa 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/activity/BaseActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/activity/BaseActivity.kt @@ -26,15 +26,17 @@ abstract class BaseActivity : AppCompatActivity() { protected fun addFragment(containerViewId: Int, fragment: Fragment) { supportFragmentManager - .beginTransaction() - .add(containerViewId, fragment) - .commit() + .beginTransaction() + .add(containerViewId, fragment) + .commit() } - protected fun addFragment(containerViewId: Int, fragment: Fragment, - sharedViews: List>) { + protected fun addFragment( + containerViewId: Int, fragment: Fragment, + sharedViews: List> + ) { val transaction = supportFragmentManager - .beginTransaction() + .beginTransaction() fragment.sharedElementEnterTransition = Explode() fragment.enterTransition = Fade() @@ -47,33 +49,37 @@ abstract class BaseActivity : AppCompatActivity() { } transaction - .add(containerViewId, fragment) - .commit() + .add(containerViewId, fragment) + .commit() } protected fun replaceFragment(containerViewId: Int, fragment: Fragment) { supportFragmentManager - .beginTransaction() - .replace(containerViewId, fragment) - .commit() + .beginTransaction() + .replace(containerViewId, fragment) + .commit() } - open fun replaceFragment(fragment: Fragment, - sharedViews: List = emptyList()) { + open fun replaceFragment( + fragment: Fragment, + sharedViews: List = emptyList() + ) { } - fun replaceFragment(containerViewId: Int, fragment: Fragment, - sharedViews: List, addToBackStack: Boolean) { + fun replaceFragment( + containerViewId: Int, fragment: Fragment, + sharedViews: List, addToBackStack: Boolean + ) { val transaction = supportFragmentManager - .beginTransaction() + .beginTransaction() if (addToBackStack) transaction.addToBackStack(null) transaction - .replace(containerViewId, fragment) - .commit() + .replace(containerViewId, fragment) + .commit() } protected fun removeFragment(containerViewId: Int) { @@ -81,9 +87,9 @@ abstract class BaseActivity : AppCompatActivity() { val fragment = supportFragmentManager.findFragmentById(containerViewId) if (fragment != null) { supportFragmentManager - .beginTransaction() - .remove(fragment) - .commit() + .beginTransaction() + .remove(fragment) + .commit() } } @@ -91,7 +97,8 @@ abstract class BaseActivity : AppCompatActivity() { try { val view = currentFocus if (view != null) { - val inputManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + val inputManager = + getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager inputManager.hideSoftInputFromWindow(view.windowToken, 0) } } catch (e: Exception) { @@ -101,5 +108,4 @@ abstract class BaseActivity : AppCompatActivity() { } - } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/activity/CommonActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/activity/CommonActivity.kt index 91cad9ab9..3154d350f 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/activity/CommonActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/activity/CommonActivity.kt @@ -24,7 +24,6 @@ abstract class CommonActivity : BaseActivity() { } - override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { android.R.id.home -> { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/adapters/MainViewPagerAdapter.java b/presentation/src/main/java/io/forus/me/android/presentation/view/adapters/MainViewPagerAdapter.java index 5fbabaded..a8887f715 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/adapters/MainViewPagerAdapter.java +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/adapters/MainViewPagerAdapter.java @@ -22,8 +22,7 @@ public class MainViewPagerAdapter extends FragmentPagerAdapter { private Fragment currentFragment; - - public MainViewPagerAdapter(FragmentManager fm, Context context, List fragments,List titles) { + public MainViewPagerAdapter(FragmentManager fm, Context context, List fragments, List titles) { super(fm); diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/adapters/RVListAdapter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/adapters/RVListAdapter.kt index 957805226..a53129387 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/adapters/RVListAdapter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/adapters/RVListAdapter.kt @@ -4,9 +4,9 @@ import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView -class RVListAdapter>( - private val createVH: (ViewGroup) -> VH, - private val clickListener: ((Item) -> Unit)? +class RVListAdapter>( + private val createVH: (ViewGroup) -> VH, + private val clickListener: ((Item) -> Unit)? ) : RecyclerView.Adapter() { var items: List = emptyList() @@ -16,8 +16,11 @@ class RVListAdapter>( DiffUtil.calculateDiff(object : DiffUtil.Callback() { override fun getOldListSize() = old.size override fun getNewListSize() = field.size - override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] - override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] }).dispatchUpdatesTo(this) notifyDataSetChanged() } @@ -35,6 +38,7 @@ class RVListAdapter>( holder.render(items[position]) } + override fun getItemCount() = items.size override fun getItemId(position: Int) = position.toLong() } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/base/NoInternetDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/base/NoInternetDialog.kt index 7551e6c87..947bfa1eb 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/base/NoInternetDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/base/NoInternetDialog.kt @@ -5,18 +5,20 @@ import com.afollestad.materialdialogs.MaterialDialog import io.forus.me.android.presentation.R -class NoInternetDialog(private val context: Context, - private val dismissListener: () -> Unit){ +class NoInternetDialog( + private val context: Context, + private val dismissListener: () -> Unit +) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title(R.string.dialog_no_internet_warning) - .content(R.string.dialog_no_internet_message) - .positiveText(context.resources.getString(R.string.me_ok)) - .dismissListener { dismissListener.invoke() } - .contentColor(context.resources.getColor(R.color.error)) - .build() + .title(R.string.dialog_no_internet_warning) + .content(R.string.dialog_no_internet_message) + .positiveText(context.resources.getString(R.string.me_ok)) + .dismissListener { dismissListener.invoke() } + .contentColor(context.resources.getColor(R.color.error)) + .build() - fun show(){ + fun show() { dialog.show() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/base/lr/LRFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/base/lr/LRFragment.kt index 32a263ffa..cd15fcc48 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/base/lr/LRFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/base/lr/LRFragment.kt @@ -63,7 +63,8 @@ abstract class LRFragment, P : MviBasePresenter navigator.navigateToLoginSignUp(activity) activity?.finish() @@ -83,7 +84,6 @@ abstract class LRFragment, P : MviBasePresenter( - val loading: Boolean, - val loadingError: Throwable?, - val canRefresh: Boolean, - val refreshing: Boolean, - val refreshingError: Throwable?, - val closeScreen: Boolean, - val model: M, - val exitIdentity: Boolean + val loading: Boolean, + val loadingError: Throwable?, + val canRefresh: Boolean, + val refreshing: Boolean, + val refreshingError: Throwable?, + val closeScreen: Boolean, + val model: M, + val exitIdentity: Boolean ) \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/CustomTypefaceSpan.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/CustomTypefaceSpan.kt index ffbe29add..1a74c7eb5 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/CustomTypefaceSpan.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/CustomTypefaceSpan.kt @@ -1,4 +1,5 @@ package io.forus.me.android.presentation.view.component + import android.graphics.Paint; import android.graphics.Typeface; import android.text.TextPaint; diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/FontType.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/FontType.kt index 106e93bf5..433047f48 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/FontType.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/FontType.kt @@ -2,7 +2,7 @@ package io.forus.me.android.presentation.view.component enum class FontType(val prefix: String) { - Bold ("bold"), + Bold("bold"), BoldItalic("bolditalic"), Italic("italic"), Medium("medium"), @@ -10,7 +10,7 @@ enum class FontType(val prefix: String) { Regular("regular"); - fun getFontPath(): String{ + fun getFontPath(): String { val prefix = "googlesans_" if (this == FontType.Bold) @@ -38,9 +38,9 @@ enum class FontType(val prefix: String) { companion object { - fun getFromString(value: String, default: FontType) : FontType { + fun getFromString(value: String, default: FontType): FontType { val items = FontType.values() - for ( item in items) { + for (item in items) { if (item.prefix == value) return item } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/ValidationRegex.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/ValidationRegex.kt index 66066c8d5..49add29a9 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/ValidationRegex.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/ValidationRegex.kt @@ -1,7 +1,7 @@ package io.forus.me.android.presentation.view.component enum class ValidationRegex(val pattern: String) { - none (""), + none(""), not_empty("^(.*)\$"), email("(?:[a-z0-9!#\$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#\$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), decimal("^(\\d*\\.)?\\d+\$"); diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/animation/VisibleAnimations.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/animation/VisibleAnimations.kt index 8b95dc413..72c7470c9 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/animation/VisibleAnimations.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/animation/VisibleAnimations.kt @@ -35,7 +35,7 @@ fun View.expandView() { } -fun View.collapseView() { +fun View.collapseView() { val initialHeight = measuredHeight val animator = ValueAnimator.ofInt(initialHeight, 0) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/Button.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/Button.kt index 2b76af5fd..2dd7ed274 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/Button.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/Button.kt @@ -14,10 +14,10 @@ import io.forus.me.android.presentation.view.component.FontType class Button : androidx.appcompat.widget.AppCompatButton { - private var reverse : Boolean = false + private var reverse: Boolean = false private var customTextSize: Float = 16f - var active : Boolean = true + var active: Boolean = true set(value) { field = value initFont() @@ -32,17 +32,20 @@ class Button : androidx.appcompat.widget.AppCompatButton { initNonStyle(context, attrs) } - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) { init(context, attrs) } - private fun initNonStyle(context: Context, attrs: AttributeSet?) { + private fun initNonStyle(context: Context, attrs: AttributeSet?) { init(context, attrs) } - - private fun init(context: Context, attrs: AttributeSet?) { + private fun init(context: Context, attrs: AttributeSet?) { this.minimumHeight = Converter.convertDpToPixel(55f, context) @@ -64,8 +67,16 @@ class Button : androidx.appcompat.widget.AppCompatButton { initBackground() } - private fun initFont(){ - setTextColor(if (!active) ContextCompat.getColor(context, R.color.body_1_38) else (if (reverse) ContextCompat.getColor(context, R.color.colorAccent) else Color.WHITE)) + private fun initFont() { + setTextColor( + if (!active) ContextCompat.getColor( + context, + R.color.body_1_38 + ) else (if (reverse) ContextCompat.getColor( + context, + R.color.colorAccent + ) else Color.WHITE) + ) setTextSize(TypedValue.COMPLEX_UNIT_DIP, customTextSize) val fontType = FontType.Bold @@ -74,8 +85,8 @@ class Button : androidx.appcompat.widget.AppCompatButton { } } - private fun initBackground(){ - setBackgroundResource(if (!reverse && active) R.drawable.button_main_raund else R.drawable.button_main_raund_reverse) + private fun initBackground() { + setBackgroundResource(if (!reverse && active) R.drawable.button_main_raund else R.drawable.button_main_raund_reverse) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { this.stateListAnimator = null } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/ButtonNext.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/ButtonNext.kt index 949593c4e..99cd79852 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/ButtonNext.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/ButtonNext.kt @@ -12,10 +12,10 @@ import io.forus.me.android.presentation.helpers.Converter class ButtonNext : androidx.appcompat.widget.AppCompatButton { - private var reverse : Boolean = false + private var reverse: Boolean = false private var customTextSize: Float = 16f - var active : Boolean = true + var active: Boolean = true set(value) { field = value initFont() @@ -30,18 +30,21 @@ class ButtonNext : androidx.appcompat.widget.AppCompatButton { initNonStyle(context, attrs) } - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) { init(context, attrs) } - private fun initNonStyle(context: Context, attrs: AttributeSet?) { + private fun initNonStyle(context: Context, attrs: AttributeSet?) { init(context, attrs) } - - private fun init(context: Context, attrs: AttributeSet?) { + private fun init(context: Context, attrs: AttributeSet?) { this.minimumHeight = Converter.convertDpToPixel(40f, context) if (attrs != null) { @@ -62,8 +65,16 @@ class ButtonNext : androidx.appcompat.widget.AppCompatButton { initBackground() } - private fun initFont(){ - setTextColor(if (!active) ContextCompat.getColor(context, R.color.body_1_38) else (if (reverse) ContextCompat.getColor(context, R.color.colorAccent) else ContextCompat.getColor(context, R.color.colorAccent))) + private fun initFont() { + setTextColor( + if (!active) ContextCompat.getColor( + context, + R.color.body_1_38 + ) else (if (reverse) ContextCompat.getColor( + context, + R.color.colorAccent + ) else ContextCompat.getColor(context, R.color.colorAccent)) + ) setTextSize(TypedValue.COMPLEX_UNIT_DIP, customTextSize) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { @@ -71,8 +82,8 @@ class ButtonNext : androidx.appcompat.widget.AppCompatButton { } } - private fun initBackground(){ - setBackgroundResource(if (!reverse && active ) R.drawable.button_welcome_round_blue else R.drawable.button_main_raund_reverse) + private fun initBackground() { + setBackgroundResource(if (!reverse && active) R.drawable.button_welcome_round_blue else R.drawable.button_main_raund_reverse) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { this.stateListAnimator = null } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/ButtonWhite.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/ButtonWhite.kt index a8e815100..edc2d0ec5 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/ButtonWhite.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/ButtonWhite.kt @@ -12,10 +12,10 @@ import io.forus.me.android.presentation.helpers.Converter class ButtonWhite : androidx.appcompat.widget.AppCompatButton { - private var reverse : Boolean = false + private var reverse: Boolean = false private var customTextSize: Float = 16f - var active : Boolean = true + var active: Boolean = true set(value) { field = value initFont() @@ -30,19 +30,22 @@ class ButtonWhite : androidx.appcompat.widget.AppCompatButton { initNonStyle(context, attrs) } - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) { init(context, attrs) } - private fun initNonStyle(context: Context, attrs: AttributeSet?) { + private fun initNonStyle(context: Context, attrs: AttributeSet?) { init(context, attrs) } - - private fun init(context: Context, attrs: AttributeSet?) { + private fun init(context: Context, attrs: AttributeSet?) { this.minimumHeight = Converter.convertDpToPixel(55f, context) @@ -64,16 +67,24 @@ class ButtonWhite : androidx.appcompat.widget.AppCompatButton { initBackground() } - private fun initFont(){ - setTextColor(if (!active) ContextCompat.getColor(context, R.color.body_1_38) else (if (reverse) ContextCompat.getColor(context, R.color.colorAccent) else ContextCompat.getColor(context,R.color.colorAccent))) + private fun initFont() { + setTextColor( + if (!active) ContextCompat.getColor( + context, + R.color.body_1_38 + ) else (if (reverse) ContextCompat.getColor( + context, + R.color.colorAccent + ) else ContextCompat.getColor(context, R.color.colorAccent)) + ) setTextSize(TypedValue.COMPLEX_UNIT_DIP, customTextSize) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { this.typeface = ResourcesCompat.getFont(context, R.font.google_sans_medium) } } - private fun initBackground(){ - setBackgroundResource(if (!reverse && active) R.drawable.button_main_raund_white else R.drawable.button_main_raund_reverse) + private fun initBackground() { + setBackgroundResource(if (!reverse && active) R.drawable.button_main_raund_white else R.drawable.button_main_raund_reverse) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { this.stateListAnimator = null } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/QrButton.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/QrButton.kt index 3da8efe51..d5f0c2007 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/QrButton.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/QrButton.kt @@ -7,6 +7,7 @@ import android.widget.FrameLayout import io.forus.me.android.presentation.R import io.forus.me.android.presentation.helpers.FontCache import io.forus.me.android.presentation.view.component.FontType + //import kotlinx.android.synthetic.main.view_qr_button.view.* @@ -15,7 +16,7 @@ class QrButton : FrameLayout { protected val layout: Int get() = R.layout.view_qr_button - private lateinit var qr_click : androidx.appcompat.widget.AppCompatButton + private lateinit var qr_click: androidx.appcompat.widget.AppCompatButton constructor(context: Context) : super(context) { initNonStyle(context, null) @@ -25,24 +26,29 @@ class QrButton : FrameLayout { initNonStyle(context, attrs) } - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) { init(context, attrs) } - private fun initNonStyle(context: Context, attrs: AttributeSet?) { + private fun initNonStyle(context: Context, attrs: AttributeSet?) { init(context, attrs) } - private fun init(context: Context, attrs: AttributeSet?) { + private fun init(context: Context, attrs: AttributeSet?) { val inflater = LayoutInflater.from(context) val mRootView = inflater.inflate(layout, this) - val btn_qr = mRootView.findViewById(R.id.qr_click) + val btn_qr = + mRootView.findViewById(R.id.qr_click) qr_click = mRootView.findViewById(R.id.qr_click) val fontType = FontType.Regular btn_qr.typeface = FontCache.getTypeface(fontType.getFontPath(), context) val ta = context.obtainStyledAttributes(attrs, R.styleable.QRButtonAttrs, 0, 0) - if(ta.hasValue(R.styleable.QRButtonAttrs_android_text)){ + if (ta.hasValue(R.styleable.QRButtonAttrs_android_text)) { val text = ta.getString(R.styleable.QRButtonAttrs_android_text) qr_click.text = text } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/ShareButton.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/ShareButton.kt index 07759fe4e..6f74c01cf 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/ShareButton.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/ShareButton.kt @@ -21,9 +21,9 @@ class ShareButton : FrameLayout { var color: Int? = null - private lateinit var mRootView : View + private lateinit var mRootView: View - private lateinit var mContainer : LinearLayout + private lateinit var mContainer: LinearLayout constructor(context: Context) : super(context) { @@ -34,16 +34,20 @@ class ShareButton : FrameLayout { initNonStyle(context, attrs) } - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) { init(context, attrs) } - private fun initNonStyle(context: Context, attrs: AttributeSet?) { + private fun initNonStyle(context: Context, attrs: AttributeSet?) { init(context, attrs) } - private fun init(context: Context, attrs: AttributeSet?) { + private fun init(context: Context, attrs: AttributeSet?) { val inflater = LayoutInflater.from(context) mRootView = inflater.inflate(R.layout.view_share_button, this) @@ -70,14 +74,15 @@ class ShareButton : FrameLayout { this.color = color } - val imageView : ImageView = mContainer.findViewById(R.id.iv_icon) - if(icon != null) { + val imageView: ImageView = mContainer.findViewById(R.id.iv_icon) + if (icon != null) { imageView.setImageDrawable(icon) - if(color != null){ + if (color != null) { imageView.setColorFilter(color!!) } } - val textView : io.forus.me.android.presentation.view.component.text.TextView = mContainer.findViewById(R.id.tv_text) + val textView: io.forus.me.android.presentation.view.component.text.TextView = + mContainer.findViewById(R.id.tv_text) textView.text = text ta.recycle() diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/ShareButtonNoBorders.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/ShareButtonNoBorders.kt index 211d7198e..259ad2379 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/ShareButtonNoBorders.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/buttons/ShareButtonNoBorders.kt @@ -19,9 +19,9 @@ class ShareButtonNoBorders : FrameLayout { var color: Int? = null - private lateinit var mRootView : View + private lateinit var mRootView: View - private lateinit var mContainer : LinearLayout + private lateinit var mContainer: LinearLayout constructor(context: Context) : super(context) { initNonStyle(context, null) @@ -31,16 +31,20 @@ class ShareButtonNoBorders : FrameLayout { initNonStyle(context, attrs) } - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) { init(context, attrs) } - private fun initNonStyle(context: Context, attrs: AttributeSet?) { + private fun initNonStyle(context: Context, attrs: AttributeSet?) { init(context, attrs) } - private fun init(context: Context, attrs: AttributeSet?) { + private fun init(context: Context, attrs: AttributeSet?) { val inflater = LayoutInflater.from(context) mRootView = inflater.inflate(R.layout.view_share_button, this) @@ -68,20 +72,21 @@ class ShareButtonNoBorders : FrameLayout { this.color = color } - val imageView : ImageView = mContainer.findViewById(R.id.iv_icon) - if(icon != null) { + val imageView: ImageView = mContainer.findViewById(R.id.iv_icon) + if (icon != null) { imageView.setImageDrawable(icon) - if(color != null){ + if (color != null) { imageView.setColorFilter(color!!) } } - val textView : io.forus.me.android.presentation.view.component.text.TextView = mContainer.findViewById(R.id.tv_text) + val textView: io.forus.me.android.presentation.view.component.text.TextView = + mContainer.findViewById(R.id.tv_text) textView.text = text ta.recycle() } - public fun clearBackground(){ + public fun clearBackground() { mContainer.background = null } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/card/CommonCard.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/card/CommonCard.kt index 3acc6903d..33db7d14e 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/card/CommonCard.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/card/CommonCard.kt @@ -11,7 +11,6 @@ import io.forus.me.android.presentation.R class CommonCard : CardView { - constructor(context: Context) : super(context) { initNonStyle(context, null) } @@ -20,24 +19,27 @@ class CommonCard : CardView { initNonStyle(context, attrs) } - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) { init(context, attrs) } - private fun initNonStyle(context: Context, attrs: AttributeSet?) { + private fun initNonStyle(context: Context, attrs: AttributeSet?) { init(context, attrs) } - - private fun init(context: Context, attrs: AttributeSet?) { + private fun init(context: Context, attrs: AttributeSet?) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { this.elevation = 4f } - this.setCardBackgroundColor(ContextCompat.getColor(context,R.color.card_background)) + this.setCardBackgroundColor(ContextCompat.getColor(context, R.color.card_background)) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/card/SettingsCard.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/card/SettingsCard.kt index 157613788..93be3ba12 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/card/SettingsCard.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/card/SettingsCard.kt @@ -56,7 +56,11 @@ open class SettingsCard : FrameLayout { init(context) } - constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) { + constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super( + context, + attrs, + defStyle + ) { init(context) } @@ -71,24 +75,23 @@ open class SettingsCard : FrameLayout { //DUMMY DATA } - open fun prepareItems(){ + open fun prepareItems() { tvTitle = mRootView!!.findViewById(R.id.title) tvText = mRootView!!.findViewById(R.id.text) vDevider = mRootView!!.findViewById(R.id.devider) vConteiner = mRootView!!.findViewById(R.id.container) - iIcon = mRootView!!.findViewById(R.id.icon) + iIcon = mRootView!!.findViewById(R.id.icon) initUI() } - internal fun initUI() { tvTitle?.text = title tvText?.text = text - if (icon > 0){ + if (icon > 0) { iIcon?.setImageResource(icon) } @@ -107,9 +110,6 @@ open class SettingsCard : FrameLayout { } - - - } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/card/SettingsSwitchCard.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/card/SettingsSwitchCard.kt index fa76d421a..e18c7112b 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/card/SettingsSwitchCard.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/card/SettingsSwitchCard.kt @@ -18,7 +18,11 @@ open class SettingsSwitchCard : SettingsCard { constructor(context: Context) : super(context) constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) + constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super( + context, + attrs, + defStyle + ) override fun prepareItems() { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/dividers/FDividerItemDecoration.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/dividers/FDividerItemDecoration.kt index 2f64bcd96..7c88f17e8 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/dividers/FDividerItemDecoration.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/dividers/FDividerItemDecoration.kt @@ -8,7 +8,7 @@ import androidx.recyclerview.widget.RecyclerView import io.forus.me.android.presentation.helpers.Converter -class FDividerItemDecoration : RecyclerView.ItemDecoration { +class FDividerItemDecoration : RecyclerView.ItemDecoration { private val ATTRS = intArrayOf(android.R.attr.listDivider) @@ -25,7 +25,6 @@ class FDividerItemDecoration : RecyclerView.ItemDecoration { } - constructor(context: Context, resId: Int) { this.context = context divider = ContextCompat.getDrawable(context, resId) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/editors/AmountTextInputEditText.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/editors/AmountTextInputEditText.kt index 2bd1bd5ec..bfb544b84 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/editors/AmountTextInputEditText.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/editors/AmountTextInputEditText.kt @@ -128,7 +128,4 @@ class AmountTextInputEditText : TextInputEditText { } - - - } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/editors/EditText.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/editors/EditText.kt index 08ba1901f..76b898c12 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/editors/EditText.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/editors/EditText.kt @@ -19,7 +19,7 @@ import io.forus.me.android.presentation.view.component.ValidationRegex import java.util.regex.Pattern -open class EditText : FrameLayout{ +open class EditText : FrameLayout { protected open val layout: Int get() = R.layout.view_edit_text @@ -31,7 +31,8 @@ open class EditText : FrameLayout{ var validationRegex: String? = "" set(value) { field = value ?: "" - validationPattern = Pattern.compile(if (field.isNullOrEmpty()) ".*" else validationRegex) + validationPattern = + Pattern.compile(if (field.isNullOrEmpty()) ".*" else validationRegex) } var isErrorLayoutEnabled: Boolean = true @@ -43,25 +44,25 @@ open class EditText : FrameLayout{ var showError: Boolean = true set(value) { field = value - mTextInputLayout.error = if(value) fieldError else "" + mTextInputLayout.error = if (value) fieldError else "" } var fieldError: String? = null set(value) { field = value - if(showError) mTextInputLayout.error = value + if (showError) mTextInputLayout.error = value } var isEditable: Boolean = true - set(value){ + set(value) { field = value - mTextEdit.inputType = if(value) inputType else InputType.TYPE_NULL + mTextEdit.inputType = if (value) inputType else InputType.TYPE_NULL } - private lateinit var mContainer : RelativeLayout - private lateinit var mTextEdit : TextInputEditText - private lateinit var mTextInputLayout : TextInputLayout - private var validationPattern : Pattern? = null + private lateinit var mContainer: RelativeLayout + private lateinit var mTextEdit: TextInputEditText + private lateinit var mTextInputLayout: TextInputLayout + private var validationPattern: Pattern? = null constructor(context: Context) : super(context) @@ -69,7 +70,11 @@ open class EditText : FrameLayout{ init(context, attrs) } - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) { init(context, attrs) } @@ -81,7 +86,10 @@ open class EditText : FrameLayout{ mContainer = mRootView.findViewById(R.id.container) mTextEdit = mContainer.findViewById(R.id.text_edit) mTextInputLayout = mContainer.findViewById(R.id.text_input_layout) - mTextInputLayout.hint = if(required) TextUtils.concat(hint, Html.fromHtml(getContext().getString(R.string.me_validation_required_asterisk))) else hint + mTextInputLayout.hint = if (required) TextUtils.concat( + hint, + Html.fromHtml(getContext().getString(R.string.me_validation_required_asterisk)) + ) else hint mTextInputLayout.isHintAnimationEnabled = true mTextInputLayout.isErrorEnabled = true if (inputType != EditorInfo.TYPE_NULL) { @@ -90,7 +98,7 @@ open class EditText : FrameLayout{ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mTextEdit.typeface = ResourcesCompat.getFont(context, R.font.google_sans_regular) } - mTextEdit.addTextChangedListener(object: android.text.TextWatcher { + mTextEdit.addTextChangedListener(object : android.text.TextWatcher { override fun afterTextChanged(p0: Editable?) { } @@ -103,29 +111,30 @@ open class EditText : FrameLayout{ }) } - private fun initAttrs(context: Context, attrs: AttributeSet){ + private fun initAttrs(context: Context, attrs: AttributeSet) { val ta = context.obtainStyledAttributes(attrs, R.styleable.CustomEditFieldAttrs, 0, 0) hint = ta.getString(R.styleable.CustomEditFieldAttrs_hint) required = ta.getBoolean(R.styleable.CustomEditFieldAttrs_required, false) val validationRegexValue = ta.getInt(R.styleable.CustomEditFieldAttrs_validationRegex, 0) validationRegex = ValidationRegex.values().get(validationRegexValue).pattern validationError = ta.getString(R.styleable.CustomEditFieldAttrs_validationError) - inputType = ta.getInt(R.styleable.CustomEditFieldAttrs_android_inputType, EditorInfo.TYPE_NULL) + inputType = + ta.getInt(R.styleable.CustomEditFieldAttrs_android_inputType, EditorInfo.TYPE_NULL) ta.recycle() } - private fun validate(text: String) : Boolean { - val isValid = isValid() - fieldError = if(!isValid) validationError else "" + private fun validate(text: String): Boolean { + val isValid = isValid() + fieldError = if (!isValid) validationError else "" return isValid } - private fun isValid() : Boolean{ + private fun isValid(): Boolean { return validationPattern == null || validationPattern!!.matcher(mTextEdit.text).matches() } - fun validate() : Boolean { + fun validate(): Boolean { return validate(this.mTextEdit.text.toString()) } @@ -135,14 +144,14 @@ open class EditText : FrameLayout{ fun getTextOrNullIfBlank(): String? { val text = mTextEdit.text.toString() - return if(text.isBlank()) null else text + return if (text.isBlank()) null else text } - fun setError(error: String){ + fun setError(error: String) { fieldError = error } - fun setTextChangedListener(listener : android.text.TextWatcher) { + fun setTextChangedListener(listener: android.text.TextWatcher) { mTextEdit.addTextChangedListener(listener) } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/editors/EditTextOutlined.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/editors/EditTextOutlined.kt index d210de5e1..0d4cd6b98 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/editors/EditTextOutlined.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/editors/EditTextOutlined.kt @@ -13,5 +13,9 @@ class EditTextOutlined : EditText { constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/images/AutoLoadImageView.java b/presentation/src/main/java/io/forus/me/android/presentation/view/component/images/AutoLoadImageView.java index 7721ae71a..61aaeda6e 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/images/AutoLoadImageView.java +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/images/AutoLoadImageView.java @@ -1,4 +1,3 @@ - package io.forus.me.android.presentation.view.component.images; import android.app.Activity; @@ -28,305 +27,311 @@ */ public class AutoLoadImageView extends AppCompatImageView { - private static final String BASE_IMAGE_NAME_CACHED = "image_"; - - private String imageUrl = null; - private int imagePlaceHolderResId = -1; - private DiskCache cache = new DiskCache(getContext().getCacheDir()); + private static final String BASE_IMAGE_NAME_CACHED = "image_"; - public AutoLoadImageView(Context context) { - super(context); - } + private String imageUrl = null; + private int imagePlaceHolderResId = -1; + private DiskCache cache = new DiskCache(getContext().getCacheDir()); - public AutoLoadImageView(Context context, AttributeSet attrs) { - super(context, attrs); - } + public AutoLoadImageView(Context context) { + super(context); + } - public AutoLoadImageView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } + public AutoLoadImageView(Context context, AttributeSet attrs) { + super(context, attrs); + } - @Override protected Parcelable onSaveInstanceState() { - Parcelable superState = super.onSaveInstanceState(); - SavedState savedState = new SavedState(superState); - savedState.imagePlaceHolderResId = this.imagePlaceHolderResId; - savedState.imageUrl = this.imageUrl; - return savedState; - } + public AutoLoadImageView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } - @Override protected void onRestoreInstanceState(Parcelable state) { - if(!(state instanceof SavedState)) { - super.onRestoreInstanceState(state); - return; + @Override + protected Parcelable onSaveInstanceState() { + Parcelable superState = super.onSaveInstanceState(); + SavedState savedState = new SavedState(superState); + savedState.imagePlaceHolderResId = this.imagePlaceHolderResId; + savedState.imageUrl = this.imageUrl; + return savedState; } - SavedState savedState = (SavedState)state; - super.onRestoreInstanceState(savedState.getSuperState()); - this.imagePlaceHolderResId = savedState.imagePlaceHolderResId; - this.imageUrl = savedState.imageUrl; - this.setImageUrl(this.imageUrl); - } - - - - /** - * Set an image from a remote url. - * - * @param imageUrl The url of the resource to load. - */ - public void setImageUrl(final String imageUrl) { - this.imageUrl = imageUrl; - ImageLoader.load(getContext(), imageUrl, this); - } - - /** - * Loads and image from the internet (and cache it) or from the internal cache. - * - * @param imageUrl The remote image url to load. - */ - private void loadImageFromUrl(final String imageUrl) { - new Thread() { - @Override public void run() { - final Bitmap bitmap = AutoLoadImageView.this.getFromCache(getFileNameFromUrl(imageUrl)); - if (bitmap != null) { - AutoLoadImageView.this.loadBitmap(bitmap); - } else { - if (isThereInternetConnection()) { - final ImageDownloader imageDownloader = new ImageDownloader(); - imageDownloader.download(imageUrl, new ImageDownloader.Callback() { - @Override public void onImageDownloaded(Bitmap bitmap) { - AutoLoadImageView.this.cacheBitmap(bitmap, getFileNameFromUrl(imageUrl)); - AutoLoadImageView.this.loadBitmap(bitmap); - } - - @Override public void onError() { - AutoLoadImageView.this.loadImagePlaceHolder(); - } - }); - } else { - AutoLoadImageView.this.loadImagePlaceHolder(); - } - } - } - }.start(); - } - - /** - * Run the operation of loading a bitmap on the UI thread. - * - * @param bitmap The image to load. - */ - private void loadBitmap(final Bitmap bitmap) { - ((Activity) getContext()).runOnUiThread(new Runnable() { - @Override public void run() { - AutoLoadImageView.this.setImageBitmap(bitmap); - } - }); - } - - /** - * Loads the image place holder if any has been assigned. - */ - private void loadImagePlaceHolder() { - if (this.imagePlaceHolderResId != -1) { - ((Activity) getContext()).runOnUiThread(new Runnable() { - @Override public void run() { - AutoLoadImageView.this.setImageResource( - AutoLoadImageView.this.imagePlaceHolderResId); + + @Override + protected void onRestoreInstanceState(Parcelable state) { + if (!(state instanceof SavedState)) { + super.onRestoreInstanceState(state); + return; } - }); - } - } - - /** - * Get a {@link android.graphics.Bitmap} from the internal cache or null if it does not exist. - * - * @param fileName The name of the file to look for in the cache. - * @return A valid cached bitmap, otherwise null. - */ - private Bitmap getFromCache(String fileName) { - Bitmap bitmap = null; - if (this.cache != null) { - bitmap = this.cache.get(fileName); - } - return bitmap; - } - - /** - * Cache an image using the internal cache. - * - * @param bitmap The bitmap to cache. - * @param fileName The file name used for caching the bitmap. - */ - private void cacheBitmap(Bitmap bitmap, String fileName) { - if (this.cache != null) { - this.cache.put(bitmap, fileName); + SavedState savedState = (SavedState) state; + super.onRestoreInstanceState(savedState.getSuperState()); + this.imagePlaceHolderResId = savedState.imagePlaceHolderResId; + this.imageUrl = savedState.imageUrl; + this.setImageUrl(this.imageUrl); } - } - - /** - * Checks if the device has any active internet connection. - * - * @return true device with internet connection, otherwise false. - */ - private boolean isThereInternetConnection() { - boolean isConnected; - - final ConnectivityManager connectivityManager = - (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE); - final NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); - isConnected = (networkInfo != null && networkInfo.isConnectedOrConnecting()); - - return isConnected; - } - - /** - * Creates a file name from an image url - * - * @param imageUrl The image url used to build the file name. - * @return An String representing a unique file name. - */ - private String getFileNameFromUrl(String imageUrl) { - //we could generate an unique MD5/SHA-1 here - String hash = String.valueOf(imageUrl.hashCode()); - if (hash.startsWith("-")) { - hash = hash.substring(1); - } - return BASE_IMAGE_NAME_CACHED + hash; - } - /** - * Class used to download images from the internet - */ - private static class ImageDownloader { - interface Callback { - void onImageDownloaded(Bitmap bitmap); - void onError(); + /** + * Set an image from a remote url. + * + * @param imageUrl The url of the resource to load. + */ + public void setImageUrl(final String imageUrl) { + this.imageUrl = imageUrl; + ImageLoader.load(getContext(), imageUrl, this); } - ImageDownloader() {} - /** - * Download an image from an url. + * Loads and image from the internet (and cache it) or from the internal cache. * - * @param imageUrl The url of the image to download. - * @param callback A callback used to be reported when the task is finished. + * @param imageUrl The remote image url to load. */ - void download(String imageUrl, Callback callback) { - try { - final URLConnection conn = new URL(imageUrl).openConnection(); - conn.connect(); - final Bitmap bitmap = BitmapFactory.decodeStream(conn.getInputStream()); - if (callback != null) { - callback.onImageDownloaded(bitmap); - } - } catch (IOException e) { - reportError(callback); - } + private void loadImageFromUrl(final String imageUrl) { + new Thread() { + @Override + public void run() { + final Bitmap bitmap = AutoLoadImageView.this.getFromCache(getFileNameFromUrl(imageUrl)); + if (bitmap != null) { + AutoLoadImageView.this.loadBitmap(bitmap); + } else { + if (isThereInternetConnection()) { + final ImageDownloader imageDownloader = new ImageDownloader(); + imageDownloader.download(imageUrl, new ImageDownloader.Callback() { + @Override + public void onImageDownloaded(Bitmap bitmap) { + AutoLoadImageView.this.cacheBitmap(bitmap, getFileNameFromUrl(imageUrl)); + AutoLoadImageView.this.loadBitmap(bitmap); + } + + @Override + public void onError() { + AutoLoadImageView.this.loadImagePlaceHolder(); + } + }); + } else { + AutoLoadImageView.this.loadImagePlaceHolder(); + } + } + } + }.start(); } /** - * Report an error to the caller + * Run the operation of loading a bitmap on the UI thread. * - * @param callback Caller implementing {@link Callback} + * @param bitmap The image to load. */ - private void reportError(Callback callback) { - if (callback != null) { - callback.onError(); - } + private void loadBitmap(final Bitmap bitmap) { + ((Activity) getContext()).runOnUiThread(new Runnable() { + @Override + public void run() { + AutoLoadImageView.this.setImageBitmap(bitmap); + } + }); } - } - - /** - * A simple disk cache implementation - */ - private static class DiskCache { - - private static final String TAG = "DiskCache"; - private final File cacheDir; - - DiskCache(File cacheDir) { - this.cacheDir = cacheDir; + /** + * Loads the image place holder if any has been assigned. + */ + private void loadImagePlaceHolder() { + if (this.imagePlaceHolderResId != -1) { + ((Activity) getContext()).runOnUiThread(new Runnable() { + @Override + public void run() { + AutoLoadImageView.this.setImageResource( + AutoLoadImageView.this.imagePlaceHolderResId); + } + }); + } } /** - * Get an element from the cache. + * Get a {@link android.graphics.Bitmap} from the internal cache or null if it does not exist. * - * @param fileName The name of the file to look for. - * @return A valid element, otherwise false. + * @param fileName The name of the file to look for in the cache. + * @return A valid cached bitmap, otherwise null. */ - synchronized Bitmap get(String fileName) { - Bitmap bitmap = null; - File file = buildFileFromFilename(fileName); - if (file.exists()) { - bitmap = BitmapFactory.decodeFile(file.getPath()); - } - return bitmap; + private Bitmap getFromCache(String fileName) { + Bitmap bitmap = null; + if (this.cache != null) { + bitmap = this.cache.get(fileName); + } + return bitmap; } /** - * Cache an element. + * Cache an image using the internal cache. * - * @param bitmap The bitmap to be put in the cache. - * @param fileName A string representing the name of the file to be cached. + * @param bitmap The bitmap to cache. + * @param fileName The file name used for caching the bitmap. */ - synchronized void put(Bitmap bitmap, String fileName) { - final File file = buildFileFromFilename(fileName); - if (!file.exists()) { - try { - final FileOutputStream fileOutputStream = new FileOutputStream(file); - bitmap.compress(Bitmap.CompressFormat.PNG, 90, fileOutputStream); - fileOutputStream.flush(); - fileOutputStream.close(); - } catch (IOException e) { - Log.e(TAG, e.getMessage()); + private void cacheBitmap(Bitmap bitmap, String fileName) { + if (this.cache != null) { + this.cache.put(bitmap, fileName); } - } + } + + /** + * Checks if the device has any active internet connection. + * + * @return true device with internet connection, otherwise false. + */ + private boolean isThereInternetConnection() { + boolean isConnected; + + final ConnectivityManager connectivityManager = + (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE); + final NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); + isConnected = (networkInfo != null && networkInfo.isConnectedOrConnecting()); + + return isConnected; } /** * Creates a file name from an image url * - * @param fileName The image url used to build the file name. - * @return A {@link java.io.File} representing a unique element. + * @param imageUrl The image url used to build the file name. + * @return An String representing a unique file name. */ - private File buildFileFromFilename(String fileName) { - String fullPath = this.cacheDir.getPath() + File.separator + fileName; - return new File(fullPath); + private String getFileNameFromUrl(String imageUrl) { + //we could generate an unique MD5/SHA-1 here + String hash = String.valueOf(imageUrl.hashCode()); + if (hash.startsWith("-")) { + hash = hash.substring(1); + } + return BASE_IMAGE_NAME_CACHED + hash; } - } - private static class SavedState extends BaseSavedState { - int imagePlaceHolderResId; - String imageUrl; + /** + * Class used to download images from the internet + */ + private static class ImageDownloader { + ImageDownloader() { + } - SavedState(Parcelable superState) { - super(superState); - } + /** + * Download an image from an url. + * + * @param imageUrl The url of the image to download. + * @param callback A callback used to be reported when the task is finished. + */ + void download(String imageUrl, Callback callback) { + try { + final URLConnection conn = new URL(imageUrl).openConnection(); + conn.connect(); + final Bitmap bitmap = BitmapFactory.decodeStream(conn.getInputStream()); + if (callback != null) { + callback.onImageDownloaded(bitmap); + } + } catch (IOException e) { + reportError(callback); + } + } - private SavedState(Parcel in) { - super(in); - this.imagePlaceHolderResId = in.readInt(); - this.imageUrl = in.readString(); + /** + * Report an error to the caller + * + * @param callback Caller implementing {@link Callback} + */ + private void reportError(Callback callback) { + if (callback != null) { + callback.onError(); + } + } + + interface Callback { + void onImageDownloaded(Bitmap bitmap); + + void onError(); + } } - @Override - public void writeToParcel(Parcel out, int flags) { - super.writeToParcel(out, flags); - out.writeInt(this.imagePlaceHolderResId); - out.writeString(this.imageUrl); + /** + * A simple disk cache implementation + */ + private static class DiskCache { + + private static final String TAG = "DiskCache"; + + private final File cacheDir; + + DiskCache(File cacheDir) { + this.cacheDir = cacheDir; + } + + /** + * Get an element from the cache. + * + * @param fileName The name of the file to look for. + * @return A valid element, otherwise false. + */ + synchronized Bitmap get(String fileName) { + Bitmap bitmap = null; + File file = buildFileFromFilename(fileName); + if (file.exists()) { + bitmap = BitmapFactory.decodeFile(file.getPath()); + } + return bitmap; + } + + /** + * Cache an element. + * + * @param bitmap The bitmap to be put in the cache. + * @param fileName A string representing the name of the file to be cached. + */ + synchronized void put(Bitmap bitmap, String fileName) { + final File file = buildFileFromFilename(fileName); + if (!file.exists()) { + try { + final FileOutputStream fileOutputStream = new FileOutputStream(file); + bitmap.compress(Bitmap.CompressFormat.PNG, 90, fileOutputStream); + fileOutputStream.flush(); + fileOutputStream.close(); + } catch (IOException e) { + Log.e(TAG, e.getMessage()); + } + } + } + + /** + * Creates a file name from an image url + * + * @param fileName The image url used to build the file name. + * @return A {@link java.io.File} representing a unique element. + */ + private File buildFileFromFilename(String fileName) { + String fullPath = this.cacheDir.getPath() + File.separator + fileName; + return new File(fullPath); + } } - public static final Parcelable.Creator CREATOR = - new Parcelable.Creator() { - public SavedState createFromParcel(Parcel in) { - return new SavedState(in); - } - - public SavedState[] newArray(int size) { - return new SavedState[size]; - } - }; - } + private static class SavedState extends BaseSavedState { + public static final Parcelable.Creator CREATOR = + new Parcelable.Creator() { + public SavedState createFromParcel(Parcel in) { + return new SavedState(in); + } + + public SavedState[] newArray(int size) { + return new SavedState[size]; + } + }; + int imagePlaceHolderResId; + String imageUrl; + + SavedState(Parcelable superState) { + super(superState); + } + + private SavedState(Parcel in) { + super(in); + this.imagePlaceHolderResId = in.readInt(); + this.imageUrl = in.readString(); + } + + @Override + public void writeToParcel(Parcel out, int flags) { + super.writeToParcel(out, flags); + out.writeInt(this.imagePlaceHolderResId); + out.writeString(this.imageUrl); + } + } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/images/CircleImageView.java b/presentation/src/main/java/io/forus/me/android/presentation/view/component/images/CircleImageView.java index 1145d729e..94c4de1ea 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/images/CircleImageView.java +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/images/CircleImageView.java @@ -217,7 +217,6 @@ public void setCircleBackgroundColorResource(@ColorRes int circleBackgroundRes) * Return the color drawn behind the circle-shaped drawable. * * @return The color drawn behind the drawable - * * @deprecated Use {@link #getCircleBackgroundColor()} instead. */ @Deprecated @@ -230,7 +229,6 @@ public int getFillColor() { * this has no effect if the drawable is opaque or no drawable is set. * * @param fillColor The color to be drawn behind the drawable - * * @deprecated Use {@link #setCircleBackgroundColor(int)} instead. */ @Deprecated @@ -244,7 +242,6 @@ public void setFillColor(@ColorInt int fillColor) { * * @param fillColorRes The color resource to be resolved to a color and * drawn behind the drawable - * * @deprecated Use {@link #setCircleBackgroundColorResource(int)} instead. */ @Deprecated @@ -315,6 +312,11 @@ public void setImageURI(Uri uri) { initializeBitmap(); } + @Override + public ColorFilter getColorFilter() { + return mColorFilter; + } + @Override public void setColorFilter(ColorFilter cf) { if (cf == mColorFilter) { @@ -326,11 +328,6 @@ public void setColorFilter(ColorFilter cf) { invalidate(); } - @Override - public ColorFilter getColorFilter() { - return mColorFilter; - } - private void applyColorFilter() { if (mBitmapPaint != null) { mBitmapPaint.setColorFilter(mColorFilter); @@ -421,7 +418,7 @@ private void setup() { } private RectF calculateBounds() { - int availableWidth = getWidth() - getPaddingLeft() - getPaddingRight(); + int availableWidth = getWidth() - getPaddingLeft() - getPaddingRight(); int availableHeight = getHeight() - getPaddingTop() - getPaddingBottom(); int sideLength = Math.min(availableWidth, availableHeight); @@ -461,7 +458,7 @@ public boolean onTouchEvent(MotionEvent event) { private boolean inTouchableArea(float x, float y) { return Math.pow(x - mBorderRect.centerX(), 2) + Math.pow(y - mBorderRect.centerY(), 2) <= Math.pow(mBorderRadius, 2); } - + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) private class OutlineProvider extends ViewOutlineProvider { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/images/QRCodeImageView.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/images/QRCodeImageView.kt index 137828059..0a278ee04 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/images/QRCodeImageView.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/images/QRCodeImageView.kt @@ -12,11 +12,21 @@ class QRCodeImageView : AutoLoadImageView { var onColor = Color.WHITE var offColor = Color.BLACK - constructor(context: Context) : super(context) { initUI(context, null) } + constructor(context: Context) : super(context) { + initUI(context, null) + } - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { initUI(context, attrs) } + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { + initUI(context, attrs) + } - constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) { initUI(context, attrs) } + constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super( + context, + attrs, + defStyle + ) { + initUI(context, attrs) + } private fun initUI(context: Context, attrs: AttributeSet?) { val ta = context.obtainStyledAttributes(attrs, R.styleable.QRCodeImageView, 0, 0) @@ -26,30 +36,41 @@ class QRCodeImageView : AutoLoadImageView { } fun setQRText(text: String) { - this.setImageBitmap(getQrBitmap(text, + this.setImageBitmap( + getQrBitmap( + text, bitmapSize, onColor, - offColor)) + offColor + ) + ) } - - private fun getQrBitmap(text:String, size:Int, onColor: Int = Color.BLACK, offColor:Int = Color.WHITE): Bitmap { + private fun getQrBitmap( + text: String, + size: Int, + onColor: Int = Color.BLACK, + offColor: Int = Color.WHITE + ): Bitmap { - var bitmap = FQRCode.generateFromVector( context,text, - R.drawable.ic_ic_forus_logo_backgr_w, size ) + var bitmap = FQRCode.generateFromVector( + context, text, + R.drawable.ic_ic_forus_logo_backgr_w, size + ) var margin = 4 if (size > 200) { margin = 6 } bitmap = Bitmap.createBitmap( - bitmap, - margin, - margin, - bitmap.width - 2*margin, - bitmap.height - 2*margin) + bitmap, + margin, + margin, + bitmap.width - 2 * margin, + bitmap.height - 2 * margin + ) return bitmap } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/pin/PinView.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/pin/PinView.kt index f67ecee66..92d583922 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/pin/PinView.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/pin/PinView.kt @@ -35,7 +35,11 @@ class PinView : FrameLayout { initNonStyle(context, attrs) } - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) { init(context, attrs) } @@ -86,15 +90,24 @@ class PinView : FrameLayout { private fun addTextView(showdot: Boolean) { val lparams = LinearLayout.LayoutParams( - FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT) + FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT + ) - lparams.setMargins(Converter.convertDpToPixel(7f, context), 0, Converter.convertDpToPixel(7f, context), 0) + lparams.setMargins( + Converter.convertDpToPixel(7f, context), + 0, + Converter.convertDpToPixel(7f, context), + 0 + ) val tv = io.forus.me.android.presentation.view.component.text.TextView(context) tv.layoutParams = lparams tv.setTextColor(ContextCompat.getColor(context, R.color.textColor)) - tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimension(R.dimen.auth_pin_text_size)); + tv.setTextSize( + TypedValue.COMPLEX_UNIT_PX, + resources.getDimension(R.dimen.auth_pin_text_size) + ); tv.text = "" tv.type = FontType.Medium mContainer.addView(tv) @@ -110,7 +123,10 @@ class PinView : FrameLayout { val parent = LinearLayout(context) parent.gravity = Gravity.CENTER_VERTICAL - parent.layoutParams = LinearLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.MATCH_PARENT) + parent.layoutParams = LinearLayout.LayoutParams( + FrameLayout.LayoutParams.WRAP_CONTENT, + FrameLayout.LayoutParams.MATCH_PARENT + ) parent.orientation = LinearLayout.VERTICAL //children of parent linearlayout diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/pinlock/IndicatorDots.java b/presentation/src/main/java/io/forus/me/android/presentation/view/component/pinlock/IndicatorDots.java index 6f0a108d3..faade673e 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/pinlock/IndicatorDots.java +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/pinlock/IndicatorDots.java @@ -77,8 +77,8 @@ private void initView(Context context) { } } - public void setErrorAnimation(Context context){ - for (int i = 0; i(parent, content, content) { init { - getView().setBackgroundColor(ContextCompat.getColor(view.context, android.R.color.transparent)) + getView().setBackgroundColor( + ContextCompat.getColor( + view.context, + android.R.color.transparent + ) + ) getView().setPadding(0, 0, 0, 0) } @@ -27,13 +32,13 @@ class UpdateAppSnackbar( fun make(view: View, updateClickListener: View.OnClickListener?): UpdateAppSnackbar { val parent = view.findSuitableParent() ?: throw IllegalArgumentException( - "No suitable parent found from the given view. Please provide a valid view." + "No suitable parent found from the given view. Please provide a valid view." ) val customView = LayoutInflater.from(view.context).inflate( - R.layout.layout_snackbar_update_app, - parent, - false + R.layout.layout_snackbar_update_app, + parent, + false ) as UpdateAppSnackbarView if (updateClickListener != null) { @@ -41,8 +46,8 @@ class UpdateAppSnackbar( } val updateAppSnackbar = UpdateAppSnackbar( - parent, - customView + parent, + customView ) updateAppSnackbar.setDuration(Snackbar.LENGTH_INDEFINITE) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/snackbar/UpdateAppSnackbarView.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/snackbar/UpdateAppSnackbarView.kt index 34b9977a0..c8306eba6 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/snackbar/UpdateAppSnackbarView.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/snackbar/UpdateAppSnackbarView.kt @@ -14,9 +14,9 @@ import io.forus.me.android.presentation.R class UpdateAppSnackbarView @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0 + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 ) : ConstraintLayout(context, attrs, defStyleAttr), ContentViewCallback { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/text/TextView.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/component/text/TextView.kt index 32d65eaa9..4c591e316 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/text/TextView.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/text/TextView.kt @@ -15,7 +15,6 @@ class TextView : AppCompatTextView { var type: FontType = FontType.Regular - constructor(context: Context) : super(context) { initUI(context, null) } @@ -25,7 +24,11 @@ class TextView : AppCompatTextView { } - constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { + constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) { initUI(context, attrs) } @@ -45,16 +48,17 @@ class TextView : AppCompatTextView { } - - - private fun initType(context: Context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { when (type) { - FontType.Medium, FontType.Bold -> this.typeface = ResourcesCompat.getFont(context, R.font.google_sans_medium) - FontType.Regular -> this.typeface = ResourcesCompat.getFont(context, R.font.google_sans_regular) + FontType.Medium, FontType.Bold -> this.typeface = + ResourcesCompat.getFont(context, R.font.google_sans_medium) + + FontType.Regular -> this.typeface = + ResourcesCompat.getFont(context, R.font.google_sans_regular) + else -> this.typeface = ResourcesCompat.getFont(context, R.font.google_sans_regular) } } @@ -63,6 +67,4 @@ class TextView : AppCompatTextView { } - - } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/component/viewpager/NonSwipeableViewPager.java b/presentation/src/main/java/io/forus/me/android/presentation/view/component/viewpager/NonSwipeableViewPager.java index 869da7265..a82766ddc 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/component/viewpager/NonSwipeableViewPager.java +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/component/viewpager/NonSwipeableViewPager.java @@ -7,15 +7,17 @@ import androidx.viewpager.widget.ViewPager; public class NonSwipeableViewPager extends ViewPager { - + private Boolean disable = true; - + public NonSwipeableViewPager(Context context) { super(context); } - public NonSwipeableViewPager(Context context, AttributeSet attrs){ - super(context,attrs); + + public NonSwipeableViewPager(Context context, AttributeSet attrs) { + super(context, attrs); } + @Override public boolean onInterceptTouchEvent(MotionEvent event) { return !disable && super.onInterceptTouchEvent(event); @@ -26,7 +28,7 @@ public boolean onTouchEvent(MotionEvent event) { return !disable && super.onTouchEvent(event); } - public void disableScroll(Boolean disable){ + public void disableScroll(Boolean disable) { //When disable = true not work the scroll and when disble = false work the scroll this.disable = disable; } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/fragment/BaseFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/fragment/BaseFragment.kt index 633c2e415..8bbc9bb95 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/fragment/BaseFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/fragment/BaseFragment.kt @@ -100,9 +100,9 @@ abstract class BaseFragment : Fragment(), FragmentListener { setToolbarTitle(toolbarTitle) if (toolbarType == ToolbarLRFragment.ToolbarType.Small) { toolbar_title?.setPadding( - toolbar_title?.paddingLeft?:0, + toolbar_title?.paddingLeft ?: 0, Converter.convertDpToPixel(5f, requireActivity().applicationContext), - toolbar_title?.paddingRight?:0, + toolbar_title?.paddingRight ?: 0, 0 ) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/fragment/QrFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/fragment/QrFragment.kt index eb780752d..2abd70615 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/fragment/QrFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/fragment/QrFragment.kt @@ -8,7 +8,6 @@ import io.forus.me.android.presentation.R import io.forus.me.android.presentation.databinding.FragmentPopupQrBinding - class QrFragment : BaseFragment() { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/fragment/ToolbarLRFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/fragment/ToolbarLRFragment.kt index 42194e328..d19b34cf0 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/fragment/ToolbarLRFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/fragment/ToolbarLRFragment.kt @@ -16,16 +16,19 @@ import io.forus.me.android.presentation.view.base.lr.LRView import io.forus.me.android.presentation.view.base.lr.LRViewState import io.forus.me.android.presentation.view.base.lr.LoadRefreshPanel -abstract class ToolbarLRFragment, P : MviBasePresenter>> : LRFragment() { +abstract class ToolbarLRFragment, P : MviBasePresenter>> : + LRFragment() { protected var toolbar: Toolbar? = null - // get() = toolbar_view + // get() = toolbar_view var toolbar_title: TextView? = null - var profile_button: io.forus.me.android.presentation.view.component.images.AutoLoadImageView? = null - open var info_button: io.forus.me.android.presentation.view.component.images.AutoLoadImageView? = null + var profile_button: io.forus.me.android.presentation.view.component.images.AutoLoadImageView? = + null + open var info_button: io.forus.me.android.presentation.view.component.images.AutoLoadImageView? = + null open val showAccount: Boolean @@ -47,7 +50,7 @@ abstract class ToolbarLRFragment, P : MviBasePresenter, P : MviBasePresenter, P : MviBasePresenter setActionBarActivity(castActivity) } - } - private fun setActionBarActivity( _activity: AppCompatActivity){ + private fun setActionBarActivity(_activity: AppCompatActivity) { _activity.setSupportActionBar(toolbar) FragmentHelper.setHomeIconToolbar(_activity, toolbar, profile_button, allowBack) @@ -96,7 +105,7 @@ abstract class ToolbarLRFragment, P : MviBasePresenter(), AccountView { +class AccountFragment : ToolbarLRFragment(), + AccountView { companion object { private const val REQUEST_CHANGE_PIN = 10001 } - + private lateinit var binding: FragmentAccountDetailsBinding override val allowBack: Boolean @@ -62,15 +63,15 @@ class AccountFragment : ToolbarLRFragment dialogInterface.dismiss() } - .setPositiveButton(R.string.send_voucher_email_dialog_positive_button) { dialogInterface: DialogInterface, _ -> - dialogInterface.dismiss() - val intent = Intent(Intent.ACTION_SENDTO) - intent.data = Uri.parse("mailto:${binding.supportEmail.text}") - - startActivity(Intent.createChooser(intent, getString(R.string.send_email_title))) - } + .setTitle(R.string.send_feedback_email_dialog_title) + .setNegativeButton(R.string.send_voucher_email_dialog_cancel_button) { dialogInterface, _ -> dialogInterface.dismiss() } + .setPositiveButton(R.string.send_voucher_email_dialog_positive_button) { dialogInterface: DialogInterface, _ -> + dialogInterface.dismiss() + val intent = Intent(Intent.ACTION_SENDTO) + intent.data = Uri.parse("mailto:${binding.supportEmail.text}") + + startActivity(Intent.createChooser(intent, getString(R.string.send_email_title))) + } } @@ -89,7 +90,11 @@ class AccountFragment : ToolbarLRFragment() override fun refreshDataIntent(): Observable = refreshTrigger - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { binding = FragmentAccountDetailsBinding.inflate(inflater) return binding.root } @@ -115,8 +120,10 @@ class AccountFragment : ToolbarLRFragment) { super.render(vs) @@ -196,11 +203,16 @@ class AccountFragment : ToolbarLRFragment() { +class AccountPresenter constructor( + private val accountRepository: AccountRepository, + sendCrashReportsEnabled: Boolean +) : LRPresenter() { private var sendCrashReportsEnabled = false @@ -23,24 +26,28 @@ class AccountPresenter constructor(private val accountRepository: AccountReposit } override fun initialModelSingle(): Single = Single.zip( - Single.fromObservable(accountRepository.getAccount()), - Single.fromObservable(accountRepository.getSecurityOptions()), - BiFunction { account, securityOptions -> - if(sendCrashReportsEnabled) { - sendCrashReportsEnabled = false - AccountModel(account, - securityOptions.pinEnabled, - securityOptions.fingerprintEnabled, - securityOptions.startFromScanner, - true) - }else{ - AccountModel(account, - securityOptions.pinEnabled, - securityOptions.fingerprintEnabled, - securityOptions.startFromScanner, - securityOptions.sendCrashReportsEnabled) - } - }) + Single.fromObservable(accountRepository.getAccount()), + Single.fromObservable(accountRepository.getSecurityOptions()), + BiFunction { account, securityOptions -> + if (sendCrashReportsEnabled) { + sendCrashReportsEnabled = false + AccountModel( + account, + securityOptions.pinEnabled, + securityOptions.fingerprintEnabled, + securityOptions.startFromScanner, + true + ) + } else { + AccountModel( + account, + securityOptions.pinEnabled, + securityOptions.fingerprintEnabled, + securityOptions.startFromScanner, + securityOptions.sendCrashReportsEnabled + ) + } + }) override fun AccountModel.changeInitialModel(i: AccountModel): AccountModel = i.copy() @@ -49,105 +56,133 @@ class AccountPresenter constructor(private val accountRepository: AccountReposit override fun bindIntents() { val observable = Observable.mergeArray( - loadRefreshPartialChanges(), - intent { it.logout() } - .switchMap { - accountRepository.exitIdentity() - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .flatMap { - Injection.instance.fcmHandler.clearFCMToken() - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { AccountPartialChanges.NavigateToWelcomeScreen(true) } - .onErrorReturn { LRPartialChange.LoadingError(it) } - } - .onErrorReturn { - LRPartialChange.LoadingError(it) - } - .startWith(LRPartialChange.LoadingStarted) - }, - - intent { it.switchFingerprint() } - .switchMap { newState -> - accountRepository.setFingerprintEnabled(newState) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { success -> - AccountPartialChanges.FingerprintEnabled(if (success) newState else !newState) - } - .onErrorReturn { - LRPartialChange.LoadingError(it) - } - }, - - intent { it.switchStartFromScanner() } - .switchMap { newState -> - accountRepository.setStartFromScannerEnabled(newState) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { success -> - AccountPartialChanges.StartFromScannerEnabled(if (success) newState else !newState) - } - .onErrorReturn { - LRPartialChange.LoadingError(it) - } - }, - - intent { it.switchSendCrashReports() } - .switchMap { newState -> - accountRepository.setSendCrashReportsEnabled(newState) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { success -> - AccountPartialChanges.SendCrashReportsEnabled(if (success) newState else !newState) - } - .onErrorReturn { - LRPartialChange.LoadingError(it) - } - }, - - intent { it.refreshDataIntent() } - .switchMap { - initialModelSingle() - .toObservable() - .subscribeOn(Schedulers.io()) - .map { LRPartialChange.InitialModelLoaded(it) } - .onErrorReturn { throwable -> - throwable.printStackTrace() - LRPartialChange.LoadingError(throwable) - } - .startWith(LRPartialChange.LoadingStarted) - } + loadRefreshPartialChanges(), + intent { it.logout() } + .switchMap { + accountRepository.exitIdentity() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .flatMap { + Injection.instance.fcmHandler.clearFCMToken() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + AccountPartialChanges.NavigateToWelcomeScreen( + true + ) + } + .onErrorReturn { LRPartialChange.LoadingError(it) } + } + .onErrorReturn { + LRPartialChange.LoadingError(it) + } + .startWith(LRPartialChange.LoadingStarted) + }, + + intent { it.switchFingerprint() } + .switchMap { newState -> + accountRepository.setFingerprintEnabled(newState) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { success -> + AccountPartialChanges.FingerprintEnabled(if (success) newState else !newState) + } + .onErrorReturn { + LRPartialChange.LoadingError(it) + } + }, + + intent { it.switchStartFromScanner() } + .switchMap { newState -> + accountRepository.setStartFromScannerEnabled(newState) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { success -> + AccountPartialChanges.StartFromScannerEnabled(if (success) newState else !newState) + } + .onErrorReturn { + LRPartialChange.LoadingError(it) + } + }, + + intent { it.switchSendCrashReports() } + .switchMap { newState -> + accountRepository.setSendCrashReportsEnabled(newState) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { success -> + AccountPartialChanges.SendCrashReportsEnabled(if (success) newState else !newState) + } + .onErrorReturn { + LRPartialChange.LoadingError(it) + } + }, + + intent { it.refreshDataIntent() } + .switchMap { + initialModelSingle() + .toObservable() + .subscribeOn(Schedulers.io()) + .map { LRPartialChange.InitialModelLoaded(it) } + .onErrorReturn { throwable -> + throwable.printStackTrace() + LRPartialChange.LoadingError(throwable) + } + .startWith(LRPartialChange.LoadingStarted) + } ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - AccountModel(), - false) + false, + null, + false, + false, + null, + false, + AccountModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - AccountView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + AccountView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { if (change !is AccountPartialChanges) return super.stateReducer(vs, change) return when (change) { - is AccountPartialChanges.NavigateToWelcomeScreen -> vs.copy(model = vs.model.copy(navigateToWelcome = true)) - is AccountPartialChanges.FingerprintEnabled -> vs.copy(model = vs.model.copy(fingerprintEnabled = change.value)) - is AccountPartialChanges.StartFromScannerEnabled -> vs.copy(model = vs.model.copy(startFromScanner = change.value)) - is AccountPartialChanges.SendCrashReportsEnabled -> vs.copy(model = vs.model.copy(sendCrashReportsEnabled = change.value)) + is AccountPartialChanges.NavigateToWelcomeScreen -> vs.copy( + model = vs.model.copy( + navigateToWelcome = true + ) + ) + + is AccountPartialChanges.FingerprintEnabled -> vs.copy( + model = vs.model.copy( + fingerprintEnabled = change.value + ) + ) + + is AccountPartialChanges.StartFromScannerEnabled -> vs.copy( + model = vs.model.copy( + startFromScanner = change.value + ) + ) + + is AccountPartialChanges.SendCrashReportsEnabled -> vs.copy( + model = vs.model.copy( + sendCrashReportsEnabled = change.value + ) + ) } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/AccountView.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/AccountView.kt index 21a42c494..94d34fc47 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/AccountView.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/AccountView.kt @@ -10,7 +10,6 @@ import io.forus.me.android.presentation.view.base.lr.LRView interface AccountView : LRView { - fun logout(): io.reactivex.Observable fun switchFingerprint(): io.reactivex.Observable diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/check_email/CheckEmailActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/check_email/CheckEmailActivity.kt index 6cd099109..31a0c4fe2 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/check_email/CheckEmailActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/check_email/CheckEmailActivity.kt @@ -39,8 +39,12 @@ class CheckEmailActivity : CommonActivity() { SharedPref.init(this@CheckEmailActivity) val restoreEmail = SharedPref.read(SharedPref.RESTORE_EMAIL, "") - val descriptionText = getString(R.string.check_email_description_part1) + " " + restoreEmail + " " + getString(R.string.check_email_description_part2) - binding.description.text = HtmlCompat.fromHtml(descriptionText, HtmlCompat.FROM_HTML_MODE_LEGACY); + val descriptionText = + getString(R.string.check_email_description_part1) + " " + restoreEmail + " " + getString( + R.string.check_email_description_part2 + ) + binding.description.text = + HtmlCompat.fromHtml(descriptionText, HtmlCompat.FROM_HTML_MODE_LEGACY); binding.back.setOnClickListener { finish() } @@ -51,7 +55,12 @@ class CheckEmailActivity : CommonActivity() { val intent = Intent(Intent.ACTION_MAIN) intent.addCategory(Intent.CATEGORY_APP_EMAIL) startActivity(intent) - startActivity(Intent.createChooser(intent, getString(R.string.check_email_open_mail_app))) + startActivity( + Intent.createChooser( + intent, + getString(R.string.check_email_open_mail_app) + ) + ) } } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/dialogs/AboutMeDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/dialogs/AboutMeDialog.kt index 43bf934ec..d7e8dd5b1 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/dialogs/AboutMeDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/dialogs/AboutMeDialog.kt @@ -7,24 +7,25 @@ import android.text.util.Linkify import com.afollestad.materialdialogs.MaterialDialog import io.forus.me.android.presentation.R -class AboutMeDialog(private val context: Context){ +class AboutMeDialog(private val context: Context) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title(context.getString(R.string.profile_about_me)) - .customView(R.layout.view_about_me, false) - .positiveText(context.resources.getString(R.string.me_ok)) - .build() + .title(context.getString(R.string.profile_about_me)) + .customView(R.layout.view_about_me, false) + .positiveText(context.resources.getString(R.string.me_ok)) + .build() init { val view = dialog.customView - val message = view?.findViewById(R.id.message); + val message = + view?.findViewById(R.id.message); val s = SpannableString(context.getText(R.string.profile_about_me_text)); Linkify.addLinks(s, Linkify.WEB_URLS); message?.setText(s); message?.setMovementMethod(LinkMovementMethod.getInstance()); } - fun show(){ + fun show() { dialog.show() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/dialogs/LogoutDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/dialogs/LogoutDialog.kt index f69da8184..cdc0576ed 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/dialogs/LogoutDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/dialogs/LogoutDialog.kt @@ -5,29 +5,31 @@ import com.afollestad.materialdialogs.MaterialDialog import io.forus.me.android.presentation.R -class LogoutDialog(private val context: Context, - private val positiveCallback: () -> Unit){ +class LogoutDialog( + private val context: Context, + private val positiveCallback: () -> Unit +) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title(context.resources.getString(R.string.profile_logout_dialog_title)) - .content(R.string.profile_logout_dialog_content) - .positiveText(context.resources.getString(R.string.profile_logout)) - .negativeText(context.resources.getString(R.string.cancel)) - .onPositive { dialog, which -> positiveCallback.invoke() } - .onNegative{ dialog, which -> dismiss() } - .cancelListener { dismiss() } - .build() + .title(context.resources.getString(R.string.profile_logout_dialog_title)) + .content(R.string.profile_logout_dialog_content) + .positiveText(context.resources.getString(R.string.profile_logout)) + .negativeText(context.resources.getString(R.string.cancel)) + .onPositive { dialog, which -> positiveCallback.invoke() } + .onNegative { dialog, which -> dismiss() } + .cancelListener { dismiss() } + .build() init { val view = dialog.customView } - fun show(){ + fun show() { dialog.show() } - fun dismiss(){ + fun dismiss() { dialog.dismiss() } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/dialogs/SessionExpiredDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/dialogs/SessionExpiredDialog.kt index a1769c676..eb04d4ebe 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/dialogs/SessionExpiredDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/dialogs/SessionExpiredDialog.kt @@ -7,27 +7,30 @@ import android.text.util.Linkify import com.afollestad.materialdialogs.MaterialDialog import io.forus.me.android.presentation.R -class SessionExpiredDialog(private val context: Context, callback: MaterialDialog.SingleButtonCallback){ +class SessionExpiredDialog( + private val context: Context, + callback: MaterialDialog.SingleButtonCallback +) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title(context.getString(R.string.warning)) - .customView(R.layout.view_about_me, false) - .positiveText(context.resources.getString(R.string.me_ok)) - .onPositive(callback) - .build() - + .title(context.getString(R.string.warning)) + .customView(R.layout.view_about_me, false) + .positiveText(context.resources.getString(R.string.me_ok)) + .onPositive(callback) + .build() init { val view = dialog.customView - val message = view?.findViewById(R.id.message); + val message = + view?.findViewById(R.id.message); val s = SpannableString(context.getText(R.string.session_has_expired)); Linkify.addLinks(s, Linkify.WEB_URLS); message?.setText(s); message?.setMovementMethod(LinkMovementMethod.getInstance()); } - fun show(){ + fun show() { dialog.show() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/pin/ChangePinActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/pin/ChangePinActivity.kt index fb5714822..950e9278a 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/pin/ChangePinActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/pin/ChangePinActivity.kt @@ -24,7 +24,6 @@ class ChangePinActivity : CommonActivity(), MViewModelProvider changeHeaders( resources.getString(R.string.passcode_subtitle_pinlock_checking), "", false ) + ChangePinModel.State.WRONG_OLD_PIN -> changeHeaders( resources.getString(R.string.passcode_subtitle_pinlock_confirm), resources.getString(R.string.passcode_subtitle_pinlock_error), true ) + ChangePinModel.State.CREATE_NEW_PIN -> changeHeaders( resources.getString(R.string.passcode_title_create), resources.getString(R.string.passcode_subtitle_create), false ) + ChangePinModel.State.CONFIRM_NEW_PIN -> changeHeaders( resources.getString(R.string.passcode_title_new_confirm), resources.getString(R.string.passcode_subtitle_new_confirm), false ) + ChangePinModel.State.PASS_NOT_MATCH -> changeHeaders( resources.getString(R.string.passcode_title_create), resources.getString(R.string.passcode_subtitle_create_not_match), true ) + ChangePinModel.State.CHANGING_PIN -> changeHeaders( resources.getString(R.string.passcode_title_create_identity_wait), resources.getString(R.string.passcode_changing), false ) + ChangePinModel.State.CHANGE_PIN_ERROR -> changeHeaders( "", resources.getString(R.string.passcode_subtitle_change_error), @@ -168,17 +175,19 @@ class ChangePinFragment : ToolbarLRFragment { if (vs.model.prevState != ChangePinModel.State.PASS_NOT_MATCH) binding.pinLockView.resetPinLockView() } + ChangePinModel.State.CONFIRM_NEW_PIN -> binding.pinLockView.resetPinLockView() ChangePinModel.State.PASS_NOT_MATCH, ChangePinModel.State.WRONG_OLD_PIN -> { binding.pinLockView.resetPinLockView() binding.pinLockView.setErrorAnimation() } + else -> {} } if (vs.closeScreen) { - val usePin = (vs.model.state == ChangePinModel.State.CHANGING_PIN)&& + val usePin = (vs.model.state == ChangePinModel.State.CHANGING_PIN) && (vs.model.prevState == ChangePinModel.State.CONFIRM_NEW_PIN) closeScreen(usePin) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/pin/ChangePinModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/pin/ChangePinModel.kt index d8616e59a..c466eb941 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/pin/ChangePinModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/pin/ChangePinModel.kt @@ -1,17 +1,25 @@ package io.forus.me.android.presentation.view.screens.account.account.pin data class ChangePinModel( - val state: State = State.CONFIRM_OLD_PIN, - val prevState: State = State.CONFIRM_OLD_PIN, - val passcodeOld: String = "", - val passcodeNew: String? = null -) -{ + val state: State = State.CONFIRM_OLD_PIN, + val prevState: State = State.CONFIRM_OLD_PIN, + val passcodeOld: String = "", + val passcodeNew: String? = null +) { enum class State { CONFIRM_OLD_PIN, CHECKING_OLD_PIN, WRONG_OLD_PIN, CREATE_NEW_PIN, CONFIRM_NEW_PIN, PASS_NOT_MATCH, CHANGING_PIN, CHANGE_PIN_ERROR, } - fun changeState(newState: State = this.state, passcodeOld: String = this.passcodeOld, passcodeNew: String? = this.passcodeNew): ChangePinModel = copy(prevState = state, state = newState, passcodeOld = passcodeOld, passcodeNew = passcodeNew) + fun changeState( + newState: State = this.state, + passcodeOld: String = this.passcodeOld, + passcodeNew: String? = this.passcodeNew + ): ChangePinModel = copy( + prevState = state, + state = newState, + passcodeOld = passcodeOld, + passcodeNew = passcodeNew + ) val valid: Boolean get() { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/pin/ChangePinPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/pin/ChangePinPresenter.kt index 50369ab59..c29adebf4 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/pin/ChangePinPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/pin/ChangePinPresenter.kt @@ -12,14 +12,17 @@ import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers import io.reactivex.subjects.PublishSubject -class ChangePinPresenter constructor(private val mode: ChangePinMode, private val accountRepository: AccountRepository) : LRPresenter() { +class ChangePinPresenter constructor( + private val mode: ChangePinMode, + private val accountRepository: AccountRepository +) : LRPresenter() { override fun initialModelSingle(): Single = Single.just(Unit) - override fun ChangePinModel.changeInitialModel(i: Unit): ChangePinModel{ - val initialState = when(mode){ + override fun ChangePinModel.changeInitialModel(i: Unit): ChangePinModel { + val initialState = when (mode) { ChangePinMode.SET_NEW -> ChangePinModel.State.CREATE_NEW_PIN - ChangePinMode.REMOVE_OLD, ChangePinMode.CHANGE_OLD -> ChangePinModel.State.CONFIRM_OLD_PIN + ChangePinMode.REMOVE_OLD, ChangePinMode.CHANGE_OLD -> ChangePinModel.State.CONFIRM_OLD_PIN } return copy(prevState = initialState, state = initialState) } @@ -34,103 +37,151 @@ class ChangePinPresenter constructor(private val mode: ChangePinMode, private va val observable = Observable.merge( - loadRefreshPartialChanges(), - - Observable.mergeArray( - intent { it.pinOnComplete() } - .map { ChangePinPartialChanges.PinOnComplete(it) }, - intent { it.pinOnChange() } - .map { ChangePinPartialChanges.PinOnChange(it) } - ), - - intent { checkPin() } - .switchMap { - accountRepository.checkPin(it) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - if(it) ChangePinPartialChanges.CheckPinSuccess(Unit) - else ChangePinPartialChanges.CheckPinError(Unit) - } - .onErrorReturn { - ChangePinPartialChanges.CheckPinError(Unit) - } - }, - - intent { changePin() } - .switchMap { - accountRepository.changePin(it.oldPin, it.newPin) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - if(it) ChangePinPartialChanges.ChangePinEnd(Unit) - else ChangePinPartialChanges.ChangePinError(Unit) - } - .onErrorReturn { - ChangePinPartialChanges.ChangePinError(Unit) - } + loadRefreshPartialChanges(), + + Observable.mergeArray( + intent { it.pinOnComplete() } + .map { ChangePinPartialChanges.PinOnComplete(it) }, + intent { it.pinOnChange() } + .map { ChangePinPartialChanges.PinOnChange(it) } + ), + + intent { checkPin() } + .switchMap { + accountRepository.checkPin(it) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + if (it) ChangePinPartialChanges.CheckPinSuccess(Unit) + else ChangePinPartialChanges.CheckPinError(Unit) } + .onErrorReturn { + ChangePinPartialChanges.CheckPinError(Unit) + } + }, + + intent { changePin() } + .switchMap { + accountRepository.changePin(it.oldPin, it.newPin) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + if (it) ChangePinPartialChanges.ChangePinEnd(Unit) + else ChangePinPartialChanges.ChangePinError(Unit) + } + .onErrorReturn { + ChangePinPartialChanges.ChangePinError(Unit) + } + } ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - ChangePinModel(), - false) + false, + null, + false, + false, + null, + false, + ChangePinModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - ChangePinView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + ChangePinView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { if (change !is ChangePinPartialChanges) return super.stateReducer(vs, change) return when (change) { is ChangePinPartialChanges.PinOnComplete -> { - when(vs.model.state){ + when (vs.model.state) { ChangePinModel.State.CONFIRM_OLD_PIN -> { checkPin.onNext(change.passcode) - vs.copy(model = vs.model.changeState(ChangePinModel.State.CHECKING_OLD_PIN, passcodeOld = change.passcode)) + vs.copy( + model = vs.model.changeState( + ChangePinModel.State.CHECKING_OLD_PIN, + passcodeOld = change.passcode + ) + ) } - ChangePinModel.State.CREATE_NEW_PIN -> vs.copy(model = vs.model.changeState(ChangePinModel.State.CONFIRM_NEW_PIN, passcodeNew = change.passcode)) + + ChangePinModel.State.CREATE_NEW_PIN -> vs.copy( + model = vs.model.changeState( + ChangePinModel.State.CONFIRM_NEW_PIN, + passcodeNew = change.passcode + ) + ) + ChangePinModel.State.CONFIRM_NEW_PIN -> { - if(vs.model.passcodeNew.equals(change.passcode) && vs.model.valid){ - changePin.onNext(ChangePin(vs.model.passcodeOld, vs.model.passcodeNew!!)) + if (vs.model.passcodeNew.equals(change.passcode) && vs.model.valid) { + changePin.onNext( + ChangePin( + vs.model.passcodeOld, + vs.model.passcodeNew!! + ) + ) vs.copy(model = vs.model.changeState(ChangePinModel.State.CHANGING_PIN)) - } - else{ + } else { vs.copy(model = vs.model.changeState(ChangePinModel.State.PASS_NOT_MATCH)) } } - else -> { vs.copy(model = vs.model.changeState(vs.model.state))} + + else -> { + vs.copy(model = vs.model.changeState(vs.model.state)) + } } } + is ChangePinPartialChanges.PinOnChange -> { - when(vs.model.state){ - ChangePinModel.State.WRONG_OLD_PIN -> vs.copy(model = vs.model.changeState(ChangePinModel.State.CONFIRM_OLD_PIN)) - ChangePinModel.State.PASS_NOT_MATCH -> vs.copy(model = vs.model.changeState(ChangePinModel.State.CREATE_NEW_PIN, passcodeNew = null)) - else -> { vs.copy(model = vs.model.changeState())} + when (vs.model.state) { + ChangePinModel.State.WRONG_OLD_PIN -> vs.copy( + model = vs.model.changeState( + ChangePinModel.State.CONFIRM_OLD_PIN + ) + ) + + ChangePinModel.State.PASS_NOT_MATCH -> vs.copy( + model = vs.model.changeState( + ChangePinModel.State.CREATE_NEW_PIN, + passcodeNew = null + ) + ) + + else -> { + vs.copy(model = vs.model.changeState()) + } } } - is ChangePinPartialChanges.CheckPinError -> vs.copy(model = vs.model.changeState(ChangePinModel.State.WRONG_OLD_PIN)) + + is ChangePinPartialChanges.CheckPinError -> vs.copy( + model = vs.model.changeState( + ChangePinModel.State.WRONG_OLD_PIN + ) + ) + is ChangePinPartialChanges.CheckPinSuccess -> { - if(mode == ChangePinMode.REMOVE_OLD) { + if (mode == ChangePinMode.REMOVE_OLD) { changePin.onNext(ChangePin(vs.model.passcodeOld, "")) vs.copy(model = vs.model.changeState(ChangePinModel.State.CHANGING_PIN)) - } - else vs.copy(model = vs.model.changeState(ChangePinModel.State.CREATE_NEW_PIN)) + } else vs.copy(model = vs.model.changeState(ChangePinModel.State.CREATE_NEW_PIN)) } - is ChangePinPartialChanges.ChangePinError -> vs.copy(model = vs.model.changeState(ChangePinModel.State.CHANGE_PIN_ERROR)) + is ChangePinPartialChanges.ChangePinError -> vs.copy( + model = vs.model.changeState( + ChangePinModel.State.CHANGE_PIN_ERROR + ) + ) + is ChangePinPartialChanges.ChangePinEnd -> vs.copy(closeScreen = true) } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/pin/ChangePinViewModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/pin/ChangePinViewModel.kt index 295f499c9..a47390b92 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/pin/ChangePinViewModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/account/pin/ChangePinViewModel.kt @@ -4,11 +4,11 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import io.forus.me.android.presentation.models.ChangePinMode -class ChangePinViewModel: ViewModel() { +class ChangePinViewModel : ViewModel() { - private var _changePinMode = MutableLiveData() + private var _changePinMode = MutableLiveData() val changePinMode get() = _changePinMode - fun setPinMode(changePinMode: ChangePinMode){ + fun setPinMode(changePinMode: ChangePinMode) { _changePinMode.value = changePinMode } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/AssignDelegatesAccountActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/AssignDelegatesAccountActivity.kt index 005f7fa7b..820554047 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/AssignDelegatesAccountActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/AssignDelegatesAccountActivity.kt @@ -27,9 +27,10 @@ class AssignDelegatesAccountActivity : CommonActivity() { } } - fun showPopupQRFragment(){ + fun showPopupQRFragment() { val meBottomSheet = MeBottomSheetDialogFragment.newInstance( - RestoreByQRFragment(), resources.getString(R.string.restore_title_qr)) + RestoreByQRFragment(), resources.getString(R.string.restore_title_qr) + ) meBottomSheet.show(supportFragmentManager, meBottomSheet.tag) } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/AssignDelegatesAccountFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/AssignDelegatesAccountFragment.kt index 66b54db78..e2102a491 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/AssignDelegatesAccountFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/AssignDelegatesAccountFragment.kt @@ -16,7 +16,9 @@ import io.reactivex.Observable /** * Fragment Assign Delegates Screen. */ -class AssignDelegatesAccountFragment : ToolbarLRFragment(), AssignDelegatesView{ +class AssignDelegatesAccountFragment : + ToolbarLRFragment(), + AssignDelegatesView { val disposableHolder = DisposableHolder() @@ -37,15 +39,17 @@ class AssignDelegatesAccountFragment : ToolbarLRFragment) { @@ -77,12 +81,11 @@ class AssignDelegatesAccountFragment : ToolbarLRFragment() { - - override fun initialModelSingle(): Single = Single.fromObservable(accountRepository.restoreByPinCode()) - - override fun AssignDelegatesAccountModel.changeInitialModel(i: RequestDelegatesPinModel): AssignDelegatesAccountModel = copy(item = i).also { - disposableHolder.add(accessTokenChecker.startCheckingActivation(i.accessToken, activationComplete)) - } +class AssignDelegatesPresenter constructor( + private val disposableHolder: DisposableHolder, + private val accessTokenChecker: AccessTokenChecker, + private val accountRepository: AccountRepository +) : LRPresenter() { + + override fun initialModelSingle(): Single = + Single.fromObservable(accountRepository.restoreByPinCode()) + + override fun AssignDelegatesAccountModel.changeInitialModel(i: RequestDelegatesPinModel): AssignDelegatesAccountModel = + copy(item = i).also { + disposableHolder.add( + accessTokenChecker.startCheckingActivation( + i.accessToken, + activationComplete + ) + ) + } private val activationComplete = PublishSubject.create() fun activationComplete(): Observable = activationComplete @@ -29,33 +39,41 @@ class AssignDelegatesPresenter constructor(private val disposableHolder: Disposa val observable = Observable.merge( - loadRefreshPartialChanges(), + loadRefreshPartialChanges(), - intent { activationComplete() }.map { AssignDelegatesAccountPartialChanges.RestoreIdentity() } + intent { activationComplete() }.map { AssignDelegatesAccountPartialChanges.RestoreIdentity() } ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - AssignDelegatesAccountModel(), - false) + false, + null, + false, + false, + null, + false, + AssignDelegatesAccountModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - AssignDelegatesView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + AssignDelegatesView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { if (change !is AssignDelegatesAccountPartialChanges) return super.stateReducer(vs, change) return when (change) { - is AssignDelegatesAccountPartialChanges.RestoreIdentity -> vs.copy(closeScreen = true, model = vs.model.copy(isPinConfirmed = true)) + is AssignDelegatesAccountPartialChanges.RestoreIdentity -> vs.copy( + closeScreen = true, + model = vs.model.copy(isPinConfirmed = true) + ) } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/InstructionsDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/InstructionsDialog.kt index 1c66abea4..8f08739c1 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/InstructionsDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/InstructionsDialog.kt @@ -7,12 +7,12 @@ import io.forus.me.android.presentation.R class InstructionsDialog(private val context: Context) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title(context.resources.getString(R.string.restore_inloggen_by_email)) - .content(context.resources.getString(R.string.restore_email_instructions)) - .positiveText(context.resources.getString(R.string.me_ok)) - .build() + .title(context.resources.getString(R.string.restore_inloggen_by_email)) + .content(context.resources.getString(R.string.restore_email_instructions)) + .positiveText(context.resources.getString(R.string.me_ok)) + .build() - fun show(){ + fun show() { dialog.show() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/RestoreByEmailActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/RestoreByEmailActivity.kt index ef358d8d0..1cac11249 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/RestoreByEmailActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/RestoreByEmailActivity.kt @@ -41,7 +41,7 @@ class RestoreByEmailActivity : CommonActivity(), MViewModelProvider(), RestoreByEmailView, +class RestoreByEmailFragment : + ToolbarLRFragment(), + RestoreByEmailView, MViewModelProvider { - override val viewModel by lazy { + override val viewModel by lazy { ViewModelProvider(requireActivity())[RestoreByEmailViewModel::class.java].apply { } } @@ -41,7 +43,7 @@ class RestoreByEmailFragment : ToolbarLRFragment() override fun exchangeToken() = exchangeToken - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View - { + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { binding = FragmentAccountRestoreEmailBinding.inflate(inflater) return binding.root } - - + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -96,7 +100,7 @@ class RestoreByEmailFragment : ToolbarLRFragment SharedPref.init(it1) + context?.let { it1 -> + SharedPref.init(it1) SharedPref.write(SharedPref.RESTORE_EMAIL, binding.email.getText()); } @@ -126,32 +131,34 @@ class RestoreByEmailFragment : ToolbarLRFragment) { super.render(vs) - binding.restore.visibility = if(vs.model.sendingRestoreByEmail == true || vs.model.sendingRestoreByEmailSuccess == true) View.INVISIBLE else View.VISIBLE - binding.emailDescription.visibility = if(vs.model.sendingRestoreByEmailSuccess == true) View.VISIBLE else View.INVISIBLE + binding.restore.visibility = + if (vs.model.sendingRestoreByEmail == true || vs.model.sendingRestoreByEmailSuccess == true) View.INVISIBLE else View.VISIBLE + binding.emailDescription.visibility = + if (vs.model.sendingRestoreByEmailSuccess == true) View.VISIBLE else View.INVISIBLE binding.email.isEditable = !(vs.model.sendingRestoreByEmailSuccess == true) - if(vs.model.sendingRestoreByEmailSuccess == true && !instructionsAlreadyShown){ + if (vs.model.sendingRestoreByEmailSuccess == true && !instructionsAlreadyShown) { navigator.navigateToCheckEmail(requireContext()) } - if(vs.model.sendingRestoreByEmail == true){ + if (vs.model.sendingRestoreByEmail == true) { (activity as? BaseActivity)?.hideSoftKeyboard() } - if(vs.model.sendingRestoreByEmailError != null){ + if (vs.model.sendingRestoreByEmailError != null) { binding.email.setError(resources.getString(R.string.restore_email_not_found)) } - if(vs.model.exchangeTokenError != null){ + if (vs.model.exchangeTokenError != null) { showToastMessage(resources.getString(R.string.restore_email_invalid_link)) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/RestoreByEmailModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/RestoreByEmailModel.kt index a755bffee..5c5a11533 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/RestoreByEmailModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/RestoreByEmailModel.kt @@ -2,9 +2,9 @@ package io.forus.me.android.presentation.view.screens.account.assigndelegates.em data class RestoreByEmailModel( - val sendingRestoreByEmail: Boolean? = null, - val sendingRestoreByEmailSuccess: Boolean? = null, - val sendingRestoreByEmailError: Throwable? = null, - val exchangeTokenError: Throwable? = null, - val accessToken: String? = null + val sendingRestoreByEmail: Boolean? = null, + val sendingRestoreByEmailSuccess: Boolean? = null, + val sendingRestoreByEmailError: Throwable? = null, + val exchangeTokenError: Throwable? = null, + val accessToken: String? = null ) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/RestoreByEmailPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/RestoreByEmailPresenter.kt index 1b912ec3c..0a283d014 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/RestoreByEmailPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/RestoreByEmailPresenter.kt @@ -10,18 +10,22 @@ import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers -class RestoreByEmailPresenter constructor(private val token: String, private val accountRepository: AccountRepository) : - LRPresenter() { +class RestoreByEmailPresenter constructor( + private val token: String, + private val accountRepository: AccountRepository +) : + LRPresenter() { override fun initialModelSingle(): Single { - return if(token.isBlank()) + return if (token.isBlank()) Single.just("") else { - Single.fromObservable(accountRepository.restoreExchangeToken(token).map { it.accessToken }) + Single.fromObservable( + accountRepository.restoreExchangeToken(token).map { it.accessToken }) } } - override fun RestoreByEmailModel.changeInitialModel(i: String?): RestoreByEmailModel{ + override fun RestoreByEmailModel.changeInitialModel(i: String?): RestoreByEmailModel { return copy(accessToken = i) } @@ -30,65 +34,103 @@ class RestoreByEmailPresenter constructor(private val token: String, private val val observable = Observable.merge( - loadRefreshPartialChanges(), - - intent { it.register() } - .switchMap { - accountRepository.restoreByEmail(it) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - if(it) RestoreByEmailPartialChanges.RestoreByEmailRequestEnd() - else RestoreByEmailPartialChanges.RestoreByEmailRequestError(Exception(it.toString())) - } - .onErrorReturn { - RestoreByEmailPartialChanges.RestoreByEmailRequestError(it) - } - .startWith(RestoreByEmailPartialChanges.RestoreByEmailRequestStart()) - - }, - - intent { it.exchangeToken() } - .flatMap { - accountRepository.restoreExchangeToken(it) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - RestoreByEmailPartialChanges.ExchangeTokenResult(it.accessToken) - } - .onErrorReturn { - RestoreByEmailPartialChanges.ExchangeTokenError(it) - } + loadRefreshPartialChanges(), + + intent { it.register() } + .switchMap { + accountRepository.restoreByEmail(it) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + if (it) RestoreByEmailPartialChanges.RestoreByEmailRequestEnd() + else RestoreByEmailPartialChanges.RestoreByEmailRequestError( + Exception( + it.toString() + ) + ) } + .onErrorReturn { + RestoreByEmailPartialChanges.RestoreByEmailRequestError(it) + } + .startWith(RestoreByEmailPartialChanges.RestoreByEmailRequestStart()) + + }, + + intent { it.exchangeToken() } + .flatMap { + accountRepository.restoreExchangeToken(it) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + RestoreByEmailPartialChanges.ExchangeTokenResult(it.accessToken) + } + .onErrorReturn { + RestoreByEmailPartialChanges.ExchangeTokenError(it) + } + } ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - RestoreByEmailModel(), - false) + false, + null, + false, + false, + null, + false, + RestoreByEmailModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - RestoreByEmailView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + RestoreByEmailView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { if (change !is RestoreByEmailPartialChanges) return super.stateReducer(vs, change) return when (change) { - is RestoreByEmailPartialChanges.RestoreByEmailRequestStart -> vs.copy(model = vs.model.copy(sendingRestoreByEmail = true, sendingRestoreByEmailError = null)) - is RestoreByEmailPartialChanges.RestoreByEmailRequestEnd -> vs.copy(model = vs.model.copy(sendingRestoreByEmail = false, sendingRestoreByEmailSuccess = true)) - is RestoreByEmailPartialChanges.RestoreByEmailRequestError -> vs.copy(model = vs.model.copy(sendingRestoreByEmail = false, sendingRestoreByEmailError = change.error)) - is RestoreByEmailPartialChanges.ExchangeTokenResult -> vs.copy(model = vs.model.copy(accessToken = change.accessToken, sendingRestoreByEmail = false, sendingRestoreByEmailError = null)) - is RestoreByEmailPartialChanges.ExchangeTokenError -> vs.copy(model = vs.model.copy(exchangeTokenError = change.error)) + is RestoreByEmailPartialChanges.RestoreByEmailRequestStart -> vs.copy( + model = vs.model.copy( + sendingRestoreByEmail = true, + sendingRestoreByEmailError = null + ) + ) + + is RestoreByEmailPartialChanges.RestoreByEmailRequestEnd -> vs.copy( + model = vs.model.copy( + sendingRestoreByEmail = false, + sendingRestoreByEmailSuccess = true + ) + ) + + is RestoreByEmailPartialChanges.RestoreByEmailRequestError -> vs.copy( + model = vs.model.copy( + sendingRestoreByEmail = false, + sendingRestoreByEmailError = change.error + ) + ) + + is RestoreByEmailPartialChanges.ExchangeTokenResult -> vs.copy( + model = vs.model.copy( + accessToken = change.accessToken, + sendingRestoreByEmail = false, + sendingRestoreByEmailError = null + ) + ) + + is RestoreByEmailPartialChanges.ExchangeTokenError -> vs.copy( + model = vs.model.copy( + exchangeTokenError = change.error + ) + ) } } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/RestoreByEmailViewModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/RestoreByEmailViewModel.kt index cbf58b948..93a87f867 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/RestoreByEmailViewModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/email/RestoreByEmailViewModel.kt @@ -3,11 +3,11 @@ package io.forus.me.android.presentation.view.screens.account.assigndelegates.em import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel -class RestoreByEmailViewModel: ViewModel() { +class RestoreByEmailViewModel : ViewModel() { - private var _token = MutableLiveData("") + private var _token = MutableLiveData("") val token get() = _token - fun setToken(token: String){ + fun setToken(token: String) { _token.value = token } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/qr/RestoreByQRFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/qr/RestoreByQRFragment.kt index a93129c07..5c46ad279 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/qr/RestoreByQRFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/assigndelegates/qr/RestoreByQRFragment.kt @@ -14,11 +14,12 @@ import io.forus.me.android.presentation.view.base.lr.LRViewState import io.forus.me.android.presentation.view.base.lr.LoadRefreshPanel import io.reactivex.Observable -class RestoreByQRFragment : LRFragment(), RestoreByQRView { +class RestoreByQRFragment : LRFragment(), + RestoreByQRView { - var qrText : String = "" + var qrText: String = "" set(value) { - if(field != value){ + if (field != value) { field = value if (binding.qrImage != null) { binding.qrImage.setQRText(QrCode(QrCode.Type.AUTH_TOKEN, value).toJson()) @@ -42,8 +43,11 @@ class RestoreByQRFragment : LRFragment() { +class RestoreByQRPresenter constructor( + private val disposableHolder: DisposableHolder, + private val accessTokenChecker: AccessTokenChecker, + private val accountRepository: AccountRepository +) : LRPresenter() { - override fun initialModelSingle(): Single = Single.fromObservable(accountRepository.restoreByQrToken()) + override fun initialModelSingle(): Single = + Single.fromObservable(accountRepository.restoreByQrToken()) - override fun RestoreByQRModel.changeInitialModel(i: RequestDelegatesQrModel): RestoreByQRModel = copy(item = i).also { - disposableHolder.add(accessTokenChecker.startCheckingActivation(i.accessToken, activationComplete)) - } + override fun RestoreByQRModel.changeInitialModel(i: RequestDelegatesQrModel): RestoreByQRModel = + copy(item = i).also { + disposableHolder.add( + accessTokenChecker.startCheckingActivation( + i.accessToken, + activationComplete + ) + ) + } private val activationComplete = PublishSubject.create() fun activationComplete(): Observable = activationComplete @@ -27,33 +38,41 @@ class RestoreByQRPresenter constructor(private val disposableHolder: DisposableH val observable = Observable.merge( - loadRefreshPartialChanges(), + loadRefreshPartialChanges(), - intent { activationComplete() }.map { RestoreByQRPartialChanges.RestoreIdentity() } + intent { activationComplete() }.map { RestoreByQRPartialChanges.RestoreIdentity() } ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - RestoreByQRModel(), - false) + false, + null, + false, + false, + null, + false, + RestoreByQRModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - RestoreByQRView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + RestoreByQRView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { if (change !is RestoreByQRPartialChanges) return super.stateReducer(vs, change) return when (change) { - is RestoreByQRPartialChanges.RestoreIdentity -> vs.copy(closeScreen = true, model = vs.model.copy(isQrConfirmed = true)) + is RestoreByQRPartialChanges.RestoreIdentity -> vs.copy( + closeScreen = true, + model = vs.model.copy(isQrConfirmed = true) + ) } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/ErrorDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/ErrorDialog.kt index 784ca1635..5048dddf5 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/ErrorDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/ErrorDialog.kt @@ -4,24 +4,28 @@ import android.content.Context import com.afollestad.materialdialogs.MaterialDialog import io.forus.me.android.presentation.R -class ErrorDialog(private val context: Context, private val title: String, private val message: String){ +class ErrorDialog( + private val context: Context, + private val title: String, + private val message: String +) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title(title) - .customView(R.layout.view_about_me, false) - .positiveText(context.resources.getString(R.string.me_ok)) - .build() - + .title(title) + .customView(R.layout.view_about_me, false) + .positiveText(context.resources.getString(R.string.me_ok)) + .build() init { val view = dialog.customView - val messageTV = view?.findViewById(R.id.message); + val messageTV = + view?.findViewById(R.id.message); messageTV?.setText(message); } - fun show(){ + fun show() { dialog.show() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpActivity.kt index eb53d052b..7fe1e8477 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpActivity.kt @@ -42,13 +42,16 @@ class LogInSignUpActivity : CommonActivity(), MViewModelProvider(R.id.fragmentContainer) fragmentContainer.layoutParams = - RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT) + RelativeLayout.LayoutParams( + RelativeLayout.LayoutParams.MATCH_PARENT, + RelativeLayout.LayoutParams.MATCH_PARENT + ) addFragment(R.id.fragmentContainer, fragment) } @@ -56,7 +59,7 @@ class LogInSignUpActivity : CommonActivity(), MViewModelProvider(), LogInSignUpView, +class LogInSignUpFragment : + ToolbarLRFragment(), LogInSignUpView, MViewModelProvider { @@ -66,7 +67,7 @@ class LogInSignUpFragment : ToolbarLRFragment) { @@ -178,7 +181,7 @@ class LogInSignUpFragment : ToolbarLRFragment - - val newApiType = ApiConfig.stringToApiType(text.toString()) - devOptionsBt!!.text = newApiType.name - - if (newApiType == ApiType.OTHER) { - - CustomApiDialog(requireContext(), storedOtherApiStr, MaterialDialog.InputCallback { _, input -> - - val customApiStr = input.toString() - storedOtherApiStr = customApiStr - - CheckApiPresenter(requireContext()).checkApi(customApiStr, - { result -> - run { - if (result) { - TestApiSuccessDialog(requireContext(), customApiStr) { - SaveApiAndRestartDialog(requireContext()) { - SharedPref.write(SharedPref.OPTION_CUSTOM_API_URL, customApiStr) - SharedPref.write(SharedPref.OPTION_API_TYPE, newApiType.name) - ApiConfig.changeToCustomApi(customApiStr) - Utils.instance.restartApp(requireContext()) + ChooseApiDialog( + requireContext(), + MaterialDialog.ListCallback { dialog, itemView, position, text -> + + val newApiType = ApiConfig.stringToApiType(text.toString()) + devOptionsBt!!.text = newApiType.name + + if (newApiType == ApiType.OTHER) { + + CustomApiDialog( + requireContext(), + storedOtherApiStr, + MaterialDialog.InputCallback { _, input -> + + val customApiStr = input.toString() + storedOtherApiStr = customApiStr + + CheckApiPresenter(requireContext()).checkApi( + customApiStr, + { result -> + run { + if (result) { + TestApiSuccessDialog( + requireContext(), + customApiStr + ) { + SaveApiAndRestartDialog(requireContext()) { + SharedPref.write( + SharedPref.OPTION_CUSTOM_API_URL, + customApiStr + ) + SharedPref.write( + SharedPref.OPTION_API_TYPE, + newApiType.name + ) + ApiConfig.changeToCustomApi(customApiStr) + Utils.instance.restartApp(requireContext()) + }.show() }.show() - }.show() - } else { - TestApiErrorDialog(requireContext(), "", {}).show() + } else { + TestApiErrorDialog( + requireContext(), + "", + {}).show() + } + } + }, + { throwable -> + run { + TestApiErrorDialog( + requireContext(), + throwable.localizedMessage, + {}).show() } } - }, - { throwable -> - run { - TestApiErrorDialog(requireContext(), throwable.localizedMessage, {}).show() - } - } - ) - - }, {}, {}).show() - } else { - SaveApiAndRestartDialog(requireContext()) { - SharedPref.write(SharedPref.OPTION_API_TYPE, newApiType.name) - ApiConfig.changeApi(newApiType) - Utils.instance.restartApp(requireContext()) - }.show() - } + ) + + }, + {}, + {}).show() + } else { + SaveApiAndRestartDialog(requireContext()) { + SharedPref.write(SharedPref.OPTION_API_TYPE, newApiType.name) + ApiConfig.changeApi(newApiType) + Utils.instance.restartApp(requireContext()) + }.show() + } - }) { }.show() + }) { }.show() } } } - private fun processError(error: Throwable){ + private fun processError(error: Throwable) { if (error is io.forus.me.android.data.exception.RetrofitException && error.kind == RetrofitException.Kind.NETWORK) { NoInternetDialog(requireContext()) { }.show() @@ -312,22 +340,27 @@ class LogInSignUpFragment : ToolbarLRFragment { - val newRecordError : BaseApiError = retrofitExceptionMapper.mapToBaseApiError(error) - val title = if (newRecordError.message == null) "" else newRecordError.message - ErrorDialog(requireContext(),title,"").show() + val newRecordError: BaseApiError = + retrofitExceptionMapper.mapToBaseApiError(error) + val title = + if (newRecordError.message == null) "" else newRecordError.message + ErrorDialog(requireContext(), title, "").show() } + 422 -> { val newRecordError = retrofitExceptionMapper.mapToApiError(error) - val title = if (newRecordError.message == null) "" else newRecordError.message - val message = if (newRecordError.message == null) "" else newRecordError.emailFormatted - ErrorDialog(requireContext(),title,message).show() + val title = + if (newRecordError.message == null) "" else newRecordError.message + val message = + if (newRecordError.message == null) "" else newRecordError.emailFormatted + ErrorDialog(requireContext(), title, message).show() } } } catch (e: Exception) { - Log.d("forus","processError $e") + Log.d("forus", "processError $e") } - }else{ - if(clickLoginUserAction) { + } else { + if (clickLoginUserAction) { clickLoginUserAction = false navigator.navigateToCheckEmail(requireContext()) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpModel.kt index 914fa4b28..752efa04c 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpModel.kt @@ -2,11 +2,11 @@ package io.forus.me.android.presentation.view.screens.account.login_signup_accou data class LogInSignUpModel( - val sendingRestoreByEmail: Boolean? = null, - val sendingRestoreByEmailSuccess: Boolean? = null, - val validateEmail: io.forus.me.android.domain.models.account.ValidateEmail? = null, - val sendingRestoreByEmailError: Throwable? = null, - val exchangeTokenError: Throwable? = null, - val accessToken: String? = null, - val validateEmailError: Throwable? = null - ) \ No newline at end of file + val sendingRestoreByEmail: Boolean? = null, + val sendingRestoreByEmailSuccess: Boolean? = null, + val validateEmail: io.forus.me.android.domain.models.account.ValidateEmail? = null, + val sendingRestoreByEmailError: Throwable? = null, + val exchangeTokenError: Throwable? = null, + val accessToken: String? = null, + val validateEmailError: Throwable? = null +) \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpPartialChanges.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpPartialChanges.kt index 3b95fbd5e..894e5a92e 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpPartialChanges.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpPartialChanges.kt @@ -9,7 +9,8 @@ sealed class LogInSignUpPartialChanges : PartialChange { class RestoreByEmailRequestEnd : LogInSignUpPartialChanges() - data class ValidateEmailRequest(val validateEmail: io.forus.me.android.domain.models.account.ValidateEmail) : LogInSignUpPartialChanges() + data class ValidateEmailRequest(val validateEmail: io.forus.me.android.domain.models.account.ValidateEmail) : + LogInSignUpPartialChanges() data class RestoreByEmailRequestError(val error: Throwable) : LogInSignUpPartialChanges() diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpPresenter.kt index 52ad04d89..9176c22f2 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpPresenter.kt @@ -10,14 +10,18 @@ import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers -class LogInSignUpPresenter constructor(private val token: String, private val accountRepository: AccountRepository) : - LRPresenter() { +class LogInSignUpPresenter constructor( + private val token: String, + private val accountRepository: AccountRepository +) : + LRPresenter() { override fun initialModelSingle(): Single { return if (token.isBlank()) Single.just("") else { - Single.fromObservable(accountRepository.restoreExchangeToken(token).map { it.accessToken }) + Single.fromObservable( + accountRepository.restoreExchangeToken(token).map { it.accessToken }) } } @@ -31,109 +35,163 @@ class LogInSignUpPresenter constructor(private val token: String, private val ac val observable = Observable.mergeArray( - loadRefreshPartialChanges(), - - intent { it.register() } - .switchMap { - accountRepository.restoreByEmail(it) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - if(it) LogInSignUpPartialChanges.RestoreByEmailRequestEnd() - else LogInSignUpPartialChanges.RestoreByEmailRequestError(Exception(it.toString())) - } - .onErrorReturn { - LogInSignUpPartialChanges.RestoreByEmailRequestError(it) - } - .startWith(LogInSignUpPartialChanges.RestoreByEmailRequestStart()) - - }, - - intent { it.validateEmail() } - .switchMap { - accountRepository.validateEmail(it) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - LogInSignUpPartialChanges.ValidateEmailRequest(it) - // else LogInSignUpPartialChanges.RestoreByEmailRequestError(Exception(it.toString())) - } - .onErrorReturn { - LogInSignUpPartialChanges.ValidateEmailRequestError(it) - } - .startWith(LogInSignUpPartialChanges.RestoreByEmailRequestStart()) - - }, - - intent { it.exchangeToken() } - .flatMap { - accountRepository.restoreExchangeToken(it) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - LogInSignUpPartialChanges.ExchangeTokenResult(it.accessToken) - } - .onErrorReturn { - LogInSignUpPartialChanges.ExchangeTokenError(it) - } - }, - - intent { it.registerNewAccount() } - .switchMap { - accountRepository.newUser(it) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - //NewAccountPartialChanges.RegisterEnd(it) - if(it) LogInSignUpPartialChanges.RestoreByEmailRequestEnd() - else LogInSignUpPartialChanges.RestoreByEmailRequestError(Exception(it.toString())) - } - .onErrorReturn { - //NewAccountPartialChanges.RegisterError(it) - LogInSignUpPartialChanges.RestoreByEmailRequestError(it) - } - .startWith(//NewAccountPartialChanges.RegisterStart(it) - LogInSignUpPartialChanges.RestoreByEmailRequestStart() - ) + loadRefreshPartialChanges(), + + intent { it.register() } + .switchMap { + accountRepository.restoreByEmail(it) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + if (it) LogInSignUpPartialChanges.RestoreByEmailRequestEnd() + else LogInSignUpPartialChanges.RestoreByEmailRequestError(Exception(it.toString())) + } + .onErrorReturn { + LogInSignUpPartialChanges.RestoreByEmailRequestError(it) + } + .startWith(LogInSignUpPartialChanges.RestoreByEmailRequestStart()) + + }, + + intent { it.validateEmail() } + .switchMap { + accountRepository.validateEmail(it) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + LogInSignUpPartialChanges.ValidateEmailRequest(it) + // else LogInSignUpPartialChanges.RestoreByEmailRequestError(Exception(it.toString())) + } + .onErrorReturn { + LogInSignUpPartialChanges.ValidateEmailRequestError(it) + } + .startWith(LogInSignUpPartialChanges.RestoreByEmailRequestStart()) + + }, + + intent { it.exchangeToken() } + .flatMap { + accountRepository.restoreExchangeToken(it) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + LogInSignUpPartialChanges.ExchangeTokenResult(it.accessToken) + } + .onErrorReturn { + LogInSignUpPartialChanges.ExchangeTokenError(it) + } + }, + + intent { it.registerNewAccount() } + .switchMap { + accountRepository.newUser(it) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + //NewAccountPartialChanges.RegisterEnd(it) + if (it) LogInSignUpPartialChanges.RestoreByEmailRequestEnd() + else LogInSignUpPartialChanges.RestoreByEmailRequestError(Exception(it.toString())) } + .onErrorReturn { + //NewAccountPartialChanges.RegisterError(it) + LogInSignUpPartialChanges.RestoreByEmailRequestError(it) + } + .startWith(//NewAccountPartialChanges.RegisterStart(it) + LogInSignUpPartialChanges.RestoreByEmailRequestStart() + ) + } ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - io.forus.me.android.presentation.view.screens.account.login_signup_account.LogInSignUpModel(), - false) + false, + null, + false, + false, + null, + false, + io.forus.me.android.presentation.view.screens.account.login_signup_account.LogInSignUpModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - LogInSignUpView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + LogInSignUpView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { if (change !is LogInSignUpPartialChanges) return super.stateReducer(vs, change) return when (change) { - is LogInSignUpPartialChanges.RestoreByEmailRequestStart -> vs.copy(model = vs.model.copy(sendingRestoreByEmail = true, - sendingRestoreByEmailError = null, validateEmail = null, validateEmailError = null)) - is LogInSignUpPartialChanges.RestoreByEmailRequestEnd -> vs.copy(model = vs.model.copy(sendingRestoreByEmail = false, - sendingRestoreByEmailSuccess = true, validateEmail = null, validateEmailError = null)) - is LogInSignUpPartialChanges.RestoreByEmailRequestError -> vs.copy(model = vs.model.copy(sendingRestoreByEmail = false, - sendingRestoreByEmailError = change.error, validateEmail = null, validateEmailError = null)) - is LogInSignUpPartialChanges.ExchangeTokenResult -> vs.copy(model = vs.model.copy(accessToken = change.accessToken, sendingRestoreByEmail = false, - sendingRestoreByEmailError = null, validateEmail = null, validateEmailError = null)) - is LogInSignUpPartialChanges.ExchangeTokenError -> vs.copy(model = vs.model.copy(exchangeTokenError = change.error, - validateEmail = null, validateEmailError = null)) - is LogInSignUpPartialChanges.ValidateEmailRequest -> vs.copy(model = vs.model.copy(validateEmail = change.validateEmail, validateEmailError = null, - sendingRestoreByEmail = false,sendingRestoreByEmailError = null,sendingRestoreByEmailSuccess = false)) - is LogInSignUpPartialChanges.ValidateEmailRequestError -> vs.copy(model = vs.model.copy(validateEmailError = change.error, validateEmail = null, - sendingRestoreByEmail = false,sendingRestoreByEmailError = null, sendingRestoreByEmailSuccess = false)) + is LogInSignUpPartialChanges.RestoreByEmailRequestStart -> vs.copy( + model = vs.model.copy( + sendingRestoreByEmail = true, + sendingRestoreByEmailError = null, + validateEmail = null, + validateEmailError = null + ) + ) + + is LogInSignUpPartialChanges.RestoreByEmailRequestEnd -> vs.copy( + model = vs.model.copy( + sendingRestoreByEmail = false, + sendingRestoreByEmailSuccess = true, + validateEmail = null, + validateEmailError = null + ) + ) + + is LogInSignUpPartialChanges.RestoreByEmailRequestError -> vs.copy( + model = vs.model.copy( + sendingRestoreByEmail = false, + sendingRestoreByEmailError = change.error, + validateEmail = null, + validateEmailError = null + ) + ) + + is LogInSignUpPartialChanges.ExchangeTokenResult -> vs.copy( + model = vs.model.copy( + accessToken = change.accessToken, + sendingRestoreByEmail = false, + sendingRestoreByEmailError = null, + validateEmail = null, + validateEmailError = null + ) + ) + + is LogInSignUpPartialChanges.ExchangeTokenError -> vs.copy( + model = vs.model.copy( + exchangeTokenError = change.error, + validateEmail = null, validateEmailError = null + ) + ) + + is LogInSignUpPartialChanges.ValidateEmailRequest -> vs.copy( + model = vs.model.copy( + validateEmail = change.validateEmail, + validateEmailError = null, + sendingRestoreByEmail = false, + sendingRestoreByEmailError = null, + sendingRestoreByEmailSuccess = false + ) + ) + + is LogInSignUpPartialChanges.ValidateEmailRequestError -> vs.copy( + model = vs.model.copy( + validateEmailError = change.error, + validateEmail = null, + sendingRestoreByEmail = false, + sendingRestoreByEmailError = null, + sendingRestoreByEmailSuccess = false + ) + ) } } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpView.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpView.kt index b946839df..0b646eedc 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpView.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LogInSignUpView.kt @@ -4,8 +4,6 @@ import io.forus.me.android.domain.models.account.NewAccountRequest import io.forus.me.android.presentation.view.base.lr.LRView - - interface LogInSignUpView : LRView { fun register(): io.reactivex.Observable diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LoginSignUpViewModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LoginSignUpViewModel.kt index a9aea0422..78fe36f61 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LoginSignUpViewModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/login_signup_account/LoginSignUpViewModel.kt @@ -3,11 +3,11 @@ package io.forus.me.android.presentation.view.screens.account.login_signup_accou import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel -class LoginSignUpViewModel: ViewModel() { +class LoginSignUpViewModel : ViewModel() { - private var _token = MutableLiveData("") + private var _token = MutableLiveData("") val token get() = _token - fun setToken(token: String){ + fun setToken(token: String) { _token.value = token } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/NewAccountFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/NewAccountFragment.kt index b30722a9b..87595ed5a 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/NewAccountFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/NewAccountFragment.kt @@ -21,7 +21,8 @@ import io.reactivex.subjects.PublishSubject /** * Fragment New User Account Screen. */ -class NewAccountFragment : ToolbarLRFragment(), NewAccountView { +class NewAccountFragment : + ToolbarLRFragment(), NewAccountView { private val viewIsValid: Boolean @@ -31,11 +32,9 @@ class NewAccountFragment : ToolbarLRFragment() override fun register() = registerAction - + private lateinit var binding: FragmentAccountNewBinding - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View - { + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { binding = FragmentAccountNewBinding.inflate(inflater) return binding.root } - + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -87,7 +89,7 @@ class NewAccountFragment : ToolbarLRFragment) { super.render(vs) - binding.progressBar.visibility = if (vs.loading || vs.model.sendingRegistration) View.VISIBLE else View.INVISIBLE + binding.progressBar.visibility = + if (vs.loading || vs.model.sendingRegistration) View.VISIBLE else View.INVISIBLE - if(vs.model.sendingRegistrationError != null) { + if (vs.model.sendingRegistrationError != null) { val error: Throwable = vs.model.sendingRegistrationError - val errorMessage = if(error is RetrofitException && error.kind == RetrofitException.Kind.HTTP) R.string.new_account_error_already_in_use else R.string.app_error_text + val errorMessage = + if (error is RetrofitException && error.kind == RetrofitException.Kind.HTTP) R.string.new_account_error_already_in_use else R.string.app_error_text Snackbar.make(viewForSnackbar(), errorMessage, Snackbar.LENGTH_SHORT).show() } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/NewAccountModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/NewAccountModel.kt index c72186c1c..004ee8f6c 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/NewAccountModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/NewAccountModel.kt @@ -4,8 +4,8 @@ import io.forus.me.android.domain.models.account.NewAccountRequest data class NewAccountModel( - val item: NewAccountRequest = NewAccountRequest(), - val sendingRegistration: Boolean = false, - val sendingRegistrationError: Throwable? = null, - val isSuccess: Boolean? = null - ) \ No newline at end of file + val item: NewAccountRequest = NewAccountRequest(), + val sendingRegistration: Boolean = false, + val sendingRegistrationError: Throwable? = null, + val isSuccess: Boolean? = null +) \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/NewAccountPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/NewAccountPresenter.kt index e7e4fc3ab..2f95e9cc4 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/NewAccountPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/NewAccountPresenter.kt @@ -11,61 +11,86 @@ import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers -class NewAccountPresenter constructor(private val accountRepository: AccountRepository) : LRPresenter() { +class NewAccountPresenter constructor(private val accountRepository: AccountRepository) : + LRPresenter() { override fun initialModelSingle(): Single = Single.just(NewAccountRequest()) - .flatMap { Single.just(it) } + .flatMap { Single.just(it) } - override fun NewAccountModel.changeInitialModel(i: NewAccountRequest): NewAccountModel = copy(item = i) + override fun NewAccountModel.changeInitialModel(i: NewAccountRequest): NewAccountModel = + copy(item = i) override fun bindIntents() { val observable = Observable.merge( - loadRefreshPartialChanges(), - intent { it.register() } - .switchMap { - accountRepository.newUser(it) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - NewAccountPartialChanges.RegisterEnd(it) - } - .onErrorReturn { - NewAccountPartialChanges.RegisterError(it) - } - .startWith(NewAccountPartialChanges.RegisterStart(it)) + loadRefreshPartialChanges(), + intent { it.register() } + .switchMap { + accountRepository.newUser(it) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + NewAccountPartialChanges.RegisterEnd(it) } + .onErrorReturn { + NewAccountPartialChanges.RegisterError(it) + } + .startWith(NewAccountPartialChanges.RegisterStart(it)) + } ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - NewAccountModel(), - false) + false, + null, + false, + false, + null, + false, + NewAccountModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - NewAccountView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + NewAccountView::render + ) } - override fun stateReducer(viewState: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + viewState: LRViewState, + change: PartialChange + ): LRViewState { if (change !is NewAccountPartialChanges) return super.stateReducer(viewState, change) return when (change) { - is NewAccountPartialChanges.RegisterEnd -> viewState.copy(closeScreen = true, model = viewState.model.copy(sendingRegistration = false, isSuccess = change.isSuccess)) - is NewAccountPartialChanges.RegisterStart -> viewState.copy(model = viewState.model.copy(sendingRegistration = true, sendingRegistrationError = null)) - is NewAccountPartialChanges.RegisterError -> viewState.copy(model = viewState.model.copy(sendingRegistration = false, sendingRegistrationError = change.error)) + is NewAccountPartialChanges.RegisterEnd -> viewState.copy( + closeScreen = true, + model = viewState.model.copy( + sendingRegistration = false, + isSuccess = change.isSuccess + ) + ) + + is NewAccountPartialChanges.RegisterStart -> viewState.copy( + model = viewState.model.copy( + sendingRegistration = true, + sendingRegistrationError = null + ) + ) + + is NewAccountPartialChanges.RegisterError -> viewState.copy( + model = viewState.model.copy( + sendingRegistration = false, + sendingRegistrationError = change.error + ) + ) } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/confirmRegistration/ConfirmRegistrationActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/confirmRegistration/ConfirmRegistrationActivity.kt index f3f2fbc7b..5fb93bfdc 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/confirmRegistration/ConfirmRegistrationActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/confirmRegistration/ConfirmRegistrationActivity.kt @@ -9,7 +9,8 @@ import io.forus.me.android.presentation.R import io.forus.me.android.presentation.view.activity.CommonActivity import io.forus.me.android.presentation.view.base.MViewModelProvider -class ConfirmRegistrationActivity : CommonActivity(), MViewModelProvider { +class ConfirmRegistrationActivity : CommonActivity(), + MViewModelProvider { override val viewModel: ConfirmRegistrationViewModel by viewModels() @@ -37,7 +38,7 @@ class ConfirmRegistrationActivity : CommonActivity(), MViewModelProvider(), ConfirmRegistrationView, +class ConfirmRegistrationFragment : + ToolbarLRFragment(), + ConfirmRegistrationView, MViewModelProvider { override val viewModel by lazy { @@ -26,11 +28,12 @@ class ConfirmRegistrationFragment : ToolbarLRFragment() override fun exchangeToken() = exchangeToken - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View - { + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { binding = FragmentConfirmRegistrationBinding.inflate(inflater) val bundle = this.arguments @@ -82,8 +88,8 @@ class ConfirmRegistrationFragment : ToolbarLRFragment() { +class ConfirmRegistrationPresenter constructor( + private val token: String, + private val accountRepository: AccountRepository +) : + LRPresenter() { override fun initialModelSingle(): Single { - return if(token.isBlank()) + return if (token.isBlank()) Single.just("") else - Single.fromObservable(accountRepository.registerExchangeToken(token).map { it.accessToken }) + Single.fromObservable( + accountRepository.registerExchangeToken(token).map { it.accessToken }) } - override fun ConfirmRegistrationModel.changeInitialModel(i: String?): ConfirmRegistrationModel{ + override fun ConfirmRegistrationModel.changeInitialModel(i: String?): ConfirmRegistrationModel { return copy(accessToken = i) } @@ -29,51 +33,84 @@ class ConfirmRegistrationPresenter constructor(private val token: String, privat val observable = Observable.merge( - loadRefreshPartialChanges(), + loadRefreshPartialChanges(), - - intent { it.exchangeToken() } - .flatMap { - accountRepository.registerExchangeToken(it) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - ConfirmRegistrationPartialChanges.ExchangeTokenResult(it.accessToken) - } - .onErrorReturn { - ConfirmRegistrationPartialChanges.ExchangeTokenError(it) - } + intent { it.exchangeToken() } + .flatMap { + accountRepository.registerExchangeToken(it) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + ConfirmRegistrationPartialChanges.ExchangeTokenResult(it.accessToken) + } + .onErrorReturn { + ConfirmRegistrationPartialChanges.ExchangeTokenError(it) } + } ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - ConfirmRegistrationModel(), - false) + false, + null, + false, + false, + null, + false, + ConfirmRegistrationModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - ConfirmRegistrationView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + ConfirmRegistrationView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { if (change !is ConfirmRegistrationPartialChanges) return super.stateReducer(vs, change) return when (change) { - is ConfirmRegistrationPartialChanges.RestoreByEmailRequestStart -> vs.copy(model = vs.model.copy(sendingRestoreByEmail = true, sendingRestoreByEmailError = null)) - is ConfirmRegistrationPartialChanges.RestoreByEmailRequestEnd -> vs.copy(model = vs.model.copy(sendingRestoreByEmail = false, sendingRestoreByEmailSuccess = true)) - is ConfirmRegistrationPartialChanges.RestoreByEmailRequestError -> vs.copy(model = vs.model.copy(sendingRestoreByEmail = false, sendingRestoreByEmailError = change.error)) - is ConfirmRegistrationPartialChanges.ExchangeTokenResult -> vs.copy(model = vs.model.copy(accessToken = change.accessToken, sendingRestoreByEmail = false, sendingRestoreByEmailError = null)) - is ConfirmRegistrationPartialChanges.ExchangeTokenError -> vs.copy(model = vs.model.copy(exchangeTokenError = change.error)) + is ConfirmRegistrationPartialChanges.RestoreByEmailRequestStart -> vs.copy( + model = vs.model.copy( + sendingRestoreByEmail = true, + sendingRestoreByEmailError = null + ) + ) + + is ConfirmRegistrationPartialChanges.RestoreByEmailRequestEnd -> vs.copy( + model = vs.model.copy( + sendingRestoreByEmail = false, + sendingRestoreByEmailSuccess = true + ) + ) + + is ConfirmRegistrationPartialChanges.RestoreByEmailRequestError -> vs.copy( + model = vs.model.copy( + sendingRestoreByEmail = false, + sendingRestoreByEmailError = change.error + ) + ) + + is ConfirmRegistrationPartialChanges.ExchangeTokenResult -> vs.copy( + model = vs.model.copy( + accessToken = change.accessToken, + sendingRestoreByEmail = false, + sendingRestoreByEmailError = null + ) + ) + + is ConfirmRegistrationPartialChanges.ExchangeTokenError -> vs.copy( + model = vs.model.copy( + exchangeTokenError = change.error + ) + ) } } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/confirmRegistration/ConfirmRegistrationView.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/confirmRegistration/ConfirmRegistrationView.kt index e61c2814c..a1826ba23 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/confirmRegistration/ConfirmRegistrationView.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/confirmRegistration/ConfirmRegistrationView.kt @@ -6,6 +6,5 @@ import io.forus.me.android.presentation.view.base.lr.LRView interface ConfirmRegistrationView : LRView { - fun exchangeToken(): io.reactivex.Observable } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/confirmRegistration/ConfirmRegistrationViewModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/confirmRegistration/ConfirmRegistrationViewModel.kt index ca4ca6212..d938188f9 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/confirmRegistration/ConfirmRegistrationViewModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/confirmRegistration/ConfirmRegistrationViewModel.kt @@ -3,11 +3,11 @@ package io.forus.me.android.presentation.view.screens.account.newaccount.confirm import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel -class ConfirmRegistrationViewModel: ViewModel() { +class ConfirmRegistrationViewModel : ViewModel() { - private var _token = MutableLiveData("") + private var _token = MutableLiveData("") val token get() = _token - fun setToken(token: String){ + fun setToken(token: String) { _token.value = token } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/pin/NewPinFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/pin/NewPinFragment.kt index d393c1749..712ab09a6 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/pin/NewPinFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/pin/NewPinFragment.kt @@ -17,11 +17,11 @@ import io.forus.me.android.presentation.view.fragment.ToolbarLRFragment import io.reactivex.Observable import io.reactivex.subjects.PublishSubject -class NewPinFragment : ToolbarLRFragment(), NewPinView , +class NewPinFragment : ToolbarLRFragment(), NewPinView, MViewModelProvider { - override val viewModel by lazy { + override val viewModel by lazy { ViewModelProvider(requireActivity())[NewPinViewModel::class.java].apply { } } @@ -40,7 +40,6 @@ class NewPinFragment : ToolbarLRFragment() override fun skip(): Observable = skip - + private lateinit var binding: FragmentAccountSetPinBinding - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + - binding = FragmentAccountSetPinBinding.inflate(inflater) - + return binding.root } @@ -76,9 +79,9 @@ class NewPinFragment : ToolbarLRFragment) { super.render(vs) - binding.progressBar.visibility = if (vs.loading || vs.model.state == NewPinModel.State.CREATING_IDENTITY) View.VISIBLE else View.INVISIBLE - binding.pinLockView.visibility = when (vs.model.state) { NewPinModel.State.CREATING_IDENTITY, NewPinModel.State.CREATING_IDENTITY_ERROR -> View.INVISIBLE else -> View.VISIBLE} - binding.indicatorDots.visibility = when (vs.model.state) { NewPinModel.State.CREATING_IDENTITY, NewPinModel.State.CREATING_IDENTITY_ERROR -> View.INVISIBLE else -> View.VISIBLE} - binding.btnExit.visibility = if(vs.model.skipEnabled) View.VISIBLE else View.INVISIBLE - - when(vs.model.state){ - NewPinModel.State.CREATE -> changeHeaders(resources.getString(R.string.passcode_title_create), resources.getString(R.string.passcode_subtitle_create), false) - NewPinModel.State.CONFIRM -> changeHeaders(resources.getString(R.string.passcode_title_confirm), resources.getString(R.string.passcode_subtitle_create), false) - NewPinModel.State.PASS_NOT_MATCH -> changeHeaders(resources.getString(R.string.passcode_title_create), resources.getString(R.string.passcode_subtitle_create_not_match), true) - NewPinModel.State.CREATING_IDENTITY -> changeHeaders(resources.getString(R.string.passcode_title_create_identity_wait), resources.getString(R.string.passcode_subtitle_create_identity), false) - NewPinModel.State.CREATING_IDENTITY_ERROR -> changeHeaders(resources.getString(R.string.passcode_subtitle_change_error), vs.model.createIdentityError?.message ?: "", true) + binding.progressBar.visibility = + if (vs.loading || vs.model.state == NewPinModel.State.CREATING_IDENTITY) View.VISIBLE else View.INVISIBLE + binding.pinLockView.visibility = when (vs.model.state) { + NewPinModel.State.CREATING_IDENTITY, NewPinModel.State.CREATING_IDENTITY_ERROR -> View.INVISIBLE + else -> View.VISIBLE + } + binding.indicatorDots.visibility = when (vs.model.state) { + NewPinModel.State.CREATING_IDENTITY, NewPinModel.State.CREATING_IDENTITY_ERROR -> View.INVISIBLE + else -> View.VISIBLE + } + binding.btnExit.visibility = if (vs.model.skipEnabled) View.VISIBLE else View.INVISIBLE + + when (vs.model.state) { + NewPinModel.State.CREATE -> changeHeaders( + resources.getString(R.string.passcode_title_create), + resources.getString(R.string.passcode_subtitle_create), + false + ) + + NewPinModel.State.CONFIRM -> changeHeaders( + resources.getString(R.string.passcode_title_confirm), + resources.getString(R.string.passcode_subtitle_create), + false + ) + + NewPinModel.State.PASS_NOT_MATCH -> changeHeaders( + resources.getString(R.string.passcode_title_create), + resources.getString(R.string.passcode_subtitle_create_not_match), + true + ) + + NewPinModel.State.CREATING_IDENTITY -> changeHeaders( + resources.getString(R.string.passcode_title_create_identity_wait), + resources.getString(R.string.passcode_subtitle_create_identity), + false + ) + + NewPinModel.State.CREATING_IDENTITY_ERROR -> changeHeaders( + resources.getString(R.string.passcode_subtitle_change_error), + vs.model.createIdentityError?.message ?: "", + true + ) } - if(vs.model.state != vs.model.prevState) when(vs.model.state){ + if (vs.model.state != vs.model.prevState) when (vs.model.state) { NewPinModel.State.CONFIRM -> binding.pinLockView.resetPinLockView() NewPinModel.State.PASS_NOT_MATCH -> { binding.pinLockView.resetPinLockView() binding.pinLockView.setErrorAnimation() } + else -> {} } @@ -133,10 +168,14 @@ class NewPinFragment : ToolbarLRFragment() { +class NewPinPresenter constructor( + private val accountRepository: AccountRepository, + private val accessToken: String +) : LRPresenter() { override fun initialModelSingle(): Single = Single.just(accessToken) - override fun NewPinModel.changeInitialModel(i: String): NewPinModel = copy(accessToken=i) + override fun NewPinModel.changeInitialModel(i: String): NewPinModel = copy(accessToken = i) private val createIdentity = PublishSubject.create() private fun createIdentity(): Observable = createIdentity @@ -24,86 +27,124 @@ class NewPinPresenter constructor(private val accountRepository: AccountReposito val observable = Observable.merge( - loadRefreshPartialChanges(), + loadRefreshPartialChanges(), - Observable.merge( + Observable.merge( - intent { it.pinOnComplete() } - .map { NewPinPartialChanges.PinOnComplete(it) }, + intent { it.pinOnComplete() } + .map { NewPinPartialChanges.PinOnComplete(it) }, - intent { it.pinOnChange() } - .map { NewPinPartialChanges.PinOnChange(it) }, + intent { it.pinOnChange() } + .map { NewPinPartialChanges.PinOnChange(it) }, - intent { it.skip() } - .map { NewPinPartialChanges.SkipPin() } - ), + intent { it.skip() } + .map { NewPinPartialChanges.SkipPin() } + ), - intent { createIdentity() } - .switchMap { - accountRepository.createIdentity(it) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - NewPinPartialChanges.CreateIdentityEnd(Unit) - } - .onErrorReturn { - NewPinPartialChanges.CreateIdentityError(it) - } + intent { createIdentity() } + .switchMap { + accountRepository.createIdentity(it) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + NewPinPartialChanges.CreateIdentityEnd(Unit) } + .onErrorReturn { + NewPinPartialChanges.CreateIdentityError(it) + } + } ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - NewPinModel(), - false) + false, + null, + false, + false, + null, + false, + NewPinModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - NewPinView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + NewPinView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { if (change !is NewPinPartialChanges) return super.stateReducer(vs, change) return when (change) { is NewPinPartialChanges.PinOnComplete -> { - when(vs.model.state){ - NewPinModel.State.CREATE -> vs.copy(model = vs.model.changeState(NewPinModel.State.CONFIRM, change.passcode)) + when (vs.model.state) { + NewPinModel.State.CREATE -> vs.copy( + model = vs.model.changeState( + NewPinModel.State.CONFIRM, + change.passcode + ) + ) + NewPinModel.State.CONFIRM -> { - if(vs.model.passcode.equals(change.passcode) && vs.model.valid){ - createIdentity.onNext(Identity(vs.model.accessToken!!, vs.model.passcode!!)) + if (vs.model.passcode.equals(change.passcode) && vs.model.valid) { + createIdentity.onNext( + Identity( + vs.model.accessToken!!, + vs.model.passcode!! + ) + ) vs.copy(model = vs.model.changeState(NewPinModel.State.CREATING_IDENTITY)) - } - else{ - vs.copy(model = vs.model.changeState(NewPinModel.State.PASS_NOT_MATCH, skipEnabled = true)) + } else { + vs.copy( + model = vs.model.changeState( + NewPinModel.State.PASS_NOT_MATCH, + skipEnabled = true + ) + ) } } - else -> { vs.copy(model = vs.model.changeState())} + + else -> { + vs.copy(model = vs.model.changeState()) + } } } + is NewPinPartialChanges.PinOnChange -> { - when(vs.model.state){ + when (vs.model.state) { NewPinModel.State.CREATE -> vs.copy(model = vs.model.changeState(skipEnabled = change.passcode.isEmpty())) - NewPinModel.State.PASS_NOT_MATCH -> vs.copy(model = vs.model.changeState(NewPinModel.State.CREATE, null, skipEnabled = change.passcode.isEmpty())) - else -> { vs.copy(model = vs.model.changeState())} + NewPinModel.State.PASS_NOT_MATCH -> vs.copy( + model = vs.model.changeState( + NewPinModel.State.CREATE, + null, + skipEnabled = change.passcode.isEmpty() + ) + ) + + else -> { + vs.copy(model = vs.model.changeState()) + } } } is NewPinPartialChanges.SkipPin -> { - if(vs.model.skipEnabled) createIdentity.onNext(Identity(accessToken,"")) + if (vs.model.skipEnabled) createIdentity.onNext(Identity(accessToken, "")) vs.copy(model = vs.model.changeState(NewPinModel.State.CREATING_IDENTITY)) } - is NewPinPartialChanges.CreateIdentityError -> vs.copy(model = vs.model.changeState(NewPinModel.State.CREATING_IDENTITY_ERROR).copy(createIdentityError = change.error)) + is NewPinPartialChanges.CreateIdentityError -> vs.copy( + model = vs.model.changeState( + NewPinModel.State.CREATING_IDENTITY_ERROR + ).copy(createIdentityError = change.error) + ) + is NewPinPartialChanges.CreateIdentityEnd -> vs.copy(closeScreen = true) } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/pin/NewPinViewModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/pin/NewPinViewModel.kt index 6af06405d..b042c697b 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/pin/NewPinViewModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/newaccount/pin/NewPinViewModel.kt @@ -3,11 +3,11 @@ package io.forus.me.android.presentation.view.screens.account.newaccount.pin import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel -class NewPinViewModel: ViewModel() { +class NewPinViewModel : ViewModel() { - private var _accessToken = MutableLiveData() + private var _accessToken = MutableLiveData() val accessToken get() = _accessToken - fun setAccessToken(accessToken: String){ + fun setAccessToken(accessToken: String) { _accessToken.value = accessToken } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/pair_device/PairDeviceFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/pair_device/PairDeviceFragment.kt index 28ac84813..b24653e7b 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/pair_device/PairDeviceFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/pair_device/PairDeviceFragment.kt @@ -19,7 +19,8 @@ import io.reactivex.Observable /** * Fragment User PairDevice Screen. */ -class PairDeviceFragment : ToolbarLRFragment(), PairDeviceView { +class PairDeviceFragment : + ToolbarLRFragment(), PairDeviceView { val disposableHolder = DisposableHolder() @@ -43,28 +44,32 @@ class PairDeviceFragment : ToolbarLRFragment) { @@ -86,12 +91,11 @@ class PairDeviceFragment : ToolbarLRFragment() { - - override fun initialModelSingle(): Single = Single.fromObservable(accountRepository.restoreByPinCode()) - - override fun PairDeviceModel.changeInitialModel(i: RequestDelegatesPinModel): PairDeviceModel = copy(item = i).also { - disposableHolder.add(accessTokenChecker.startCheckingActivation(i.accessToken, activationComplete)) - } +class PairDevicePresenter constructor( + private val disposableHolder: DisposableHolder, + private val accessTokenChecker: AccessTokenChecker, + private val accountRepository: AccountRepository +) : LRPresenter() { + + override fun initialModelSingle(): Single = + Single.fromObservable(accountRepository.restoreByPinCode()) + + override fun PairDeviceModel.changeInitialModel(i: RequestDelegatesPinModel): PairDeviceModel = + copy(item = i).also { + disposableHolder.add( + accessTokenChecker.startCheckingActivation( + i.accessToken, + activationComplete + ) + ) + } private val activationComplete = PublishSubject.create() fun activationComplete(): Observable = activationComplete @@ -29,33 +39,41 @@ class PairDevicePresenter constructor(private val disposableHolder: DisposableHo val observable = Observable.merge( - loadRefreshPartialChanges(), + loadRefreshPartialChanges(), - intent { activationComplete() }.map { PairDevicePartialChanges.RestoreIdentity() } + intent { activationComplete() }.map { PairDevicePartialChanges.RestoreIdentity() } ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - PairDeviceModel(), - false) + false, + null, + false, + false, + null, + false, + PairDeviceModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - PairDeviceView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + PairDeviceView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { if (change !is PairDevicePartialChanges) return super.stateReducer(vs, change) return when (change) { - is PairDevicePartialChanges.RestoreIdentity -> vs.copy(closeScreen = true, model = vs.model.copy(isPinConfirmed = true)) + is PairDevicePartialChanges.RestoreIdentity -> vs.copy( + closeScreen = true, + model = vs.model.copy(isPinConfirmed = true) + ) } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/pair_device/PairDeviceView.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/pair_device/PairDeviceView.kt index 5df8ec96a..e5cd070f1 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/pair_device/PairDeviceView.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/pair_device/PairDeviceView.kt @@ -3,5 +3,4 @@ package io.forus.me.android.presentation.view.screens.account.pair_device import io.forus.me.android.presentation.view.base.lr.LRView - interface PairDeviceView : LRView \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/restore_account_success/RestoreAccountSuccessActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/restore_account_success/RestoreAccountSuccessActivity.kt index 7dd6dab7f..73fb7b752 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/restore_account_success/RestoreAccountSuccessActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/restore_account_success/RestoreAccountSuccessActivity.kt @@ -12,7 +12,8 @@ import io.forus.me.android.presentation.view.base.MViewModelProvider /** * Created by maestrovs on 22.04.2020. */ -class RestoreAccountSuccessActivity : CommonActivity(), MViewModelProvider { +class RestoreAccountSuccessActivity : CommonActivity(), + MViewModelProvider { override val viewModel: RestoreAccountSuccessViewModel by viewModels() @@ -46,9 +47,9 @@ class RestoreAccountSuccessActivity : CommonActivity(), MViewModelProvider(), RestoreAccountSuccessView, +class RestoreAccountSuccessFragment : + ToolbarLRFragment(), + RestoreAccountSuccessView, MViewModelProvider { override val viewModel by lazy { @@ -34,12 +35,13 @@ class RestoreAccountSuccessFragment : ToolbarLRFragment) { @@ -109,7 +115,8 @@ class RestoreAccountSuccessFragment : ToolbarLRFragment() { +class RestoreAccountSuccessPresenter constructor( + private val token: String, + private val accountRepository: AccountRepository, + private val isExchangeToken: Boolean +) : + LRPresenter() { override fun initialModelSingle(): Single { @@ -22,14 +26,15 @@ class RestoreAccountSuccessPresenter constructor(private val token: String, priv return if (token.isBlank()) Single.just("") else { - Single.fromObservable(accountRepository.registerExchangeToken(token).map { it.accessToken }) + Single.fromObservable( + accountRepository.registerExchangeToken(token).map { it.accessToken }) } - }else{ - return Single.just("") + } else { + return Single.just("") } } - override fun RestoreAccountSuccessModel.changeInitialModel(i: String?): RestoreAccountSuccessModel{ + override fun RestoreAccountSuccessModel.changeInitialModel(i: String?): RestoreAccountSuccessModel { return copy(accessToken = i) } @@ -38,50 +43,84 @@ class RestoreAccountSuccessPresenter constructor(private val token: String, priv val observable = Observable.merge( - loadRefreshPartialChanges(), + loadRefreshPartialChanges(), - intent { it.exchangeToken() } - .flatMap { - accountRepository.registerExchangeToken(it) //restoreExchangeToken(it) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - RestoreAccountSuccessPartialChanges.ExchangeTokenResult(it.accessToken) - } - .onErrorReturn { - RestoreAccountSuccessPartialChanges.ExchangeTokenError(it) - } + intent { it.exchangeToken() } + .flatMap { + accountRepository.registerExchangeToken(it) //restoreExchangeToken(it) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + RestoreAccountSuccessPartialChanges.ExchangeTokenResult(it.accessToken) } + .onErrorReturn { + RestoreAccountSuccessPartialChanges.ExchangeTokenError(it) + } + } ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - RestoreAccountSuccessModel(), - false) + false, + null, + false, + false, + null, + false, + RestoreAccountSuccessModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - RestoreAccountSuccessView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + RestoreAccountSuccessView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { if (change !is RestoreAccountSuccessPartialChanges) return super.stateReducer(vs, change) return when (change) { - is RestoreAccountSuccessPartialChanges.RestoreByEmailRequestStart -> vs.copy(model = vs.model.copy(sendingRestoreByEmail = true, sendingRestoreByEmailError = null)) - is RestoreAccountSuccessPartialChanges.RestoreByEmailRequestEnd -> vs.copy(model = vs.model.copy(sendingRestoreByEmail = false, sendingRestoreByEmailSuccess = true)) - is RestoreAccountSuccessPartialChanges.RestoreByEmailRequestError -> vs.copy(model = vs.model.copy(sendingRestoreByEmail = false, sendingRestoreByEmailError = change.error)) - is RestoreAccountSuccessPartialChanges.ExchangeTokenResult -> vs.copy(model = vs.model.copy(accessToken = change.accessToken, sendingRestoreByEmail = false, sendingRestoreByEmailError = null)) - is RestoreAccountSuccessPartialChanges.ExchangeTokenError -> vs.copy(model = vs.model.copy(exchangeTokenError = change.error)) + is RestoreAccountSuccessPartialChanges.RestoreByEmailRequestStart -> vs.copy( + model = vs.model.copy( + sendingRestoreByEmail = true, + sendingRestoreByEmailError = null + ) + ) + + is RestoreAccountSuccessPartialChanges.RestoreByEmailRequestEnd -> vs.copy( + model = vs.model.copy( + sendingRestoreByEmail = false, + sendingRestoreByEmailSuccess = true + ) + ) + + is RestoreAccountSuccessPartialChanges.RestoreByEmailRequestError -> vs.copy( + model = vs.model.copy( + sendingRestoreByEmail = false, + sendingRestoreByEmailError = change.error + ) + ) + + is RestoreAccountSuccessPartialChanges.ExchangeTokenResult -> vs.copy( + model = vs.model.copy( + accessToken = change.accessToken, + sendingRestoreByEmail = false, + sendingRestoreByEmailError = null + ) + ) + + is RestoreAccountSuccessPartialChanges.ExchangeTokenError -> vs.copy( + model = vs.model.copy( + exchangeTokenError = change.error + ) + ) } } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/restore_account_success/RestoreAccountSuccessViewModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/restore_account_success/RestoreAccountSuccessViewModel.kt index 80426aa25..d67b4ea54 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/restore_account_success/RestoreAccountSuccessViewModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/restore_account_success/RestoreAccountSuccessViewModel.kt @@ -3,17 +3,17 @@ package io.forus.me.android.presentation.view.screens.account.restore_account_su import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel -class RestoreAccountSuccessViewModel: ViewModel() { +class RestoreAccountSuccessViewModel : ViewModel() { - private var _token = MutableLiveData() + private var _token = MutableLiveData() val token get() = _token - fun setToken(token: String){ + fun setToken(token: String) { _token.value = token } - private var _isExchangeToken = MutableLiveData(true) + private var _isExchangeToken = MutableLiveData(true) val isExchangeToken get() = _isExchangeToken - fun setIsExchangeToken(isExchangeToken: Boolean){ + fun setIsExchangeToken(isExchangeToken: Boolean) { _isExchangeToken.value = isExchangeToken } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/send_crash_reports/SendReportsActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/send_crash_reports/SendReportsActivity.kt index e94145245..011c53fd2 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/send_crash_reports/SendReportsActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/send_crash_reports/SendReportsActivity.kt @@ -38,7 +38,7 @@ class SendReportsActivity : CommonActivity() { if (savedInstanceState == null) { val token = intent.getStringExtra(TOKEN_EXTRA) - fragment = if(token != null){ + fragment = if (token != null) { SendReportsFragment.newIntent(token) } else SendReportsFragment() addFragment(R.id.fragmentContainer, fragment) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/send_crash_reports/SendReportsFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/send_crash_reports/SendReportsFragment.kt index 65664cdb6..0290cf899 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/send_crash_reports/SendReportsFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/send_crash_reports/SendReportsFragment.kt @@ -103,7 +103,7 @@ class SendReportsFragment : override fun render(vs: LRViewState) { super.render(vs) - Log.d("Popupp","Popupp render>>>") + Log.d("Popupp", "Popupp render>>>") binding.enableSendCrashLog.setChecked(vs.model.sendCrashReportsEnabled) binding.enableSendCrashLog.setOnClickListener { @@ -115,8 +115,9 @@ class SendReportsFragment : } binding.nextStep.setOnClickListener { - Log.d("Popupp","Popupp NEXT>>>") - closeScreen(token) } + Log.d("Popupp", "Popupp NEXT>>>") + closeScreen(token) + } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/send_crash_reports/SendReportsModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/send_crash_reports/SendReportsModel.kt index 9bdd9d983..1c9c25381 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/send_crash_reports/SendReportsModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/send_crash_reports/SendReportsModel.kt @@ -4,5 +4,5 @@ package io.forus.me.android.presentation.view.screens.account.send_crash_reports * Created by maestrovs on 23.04.2020. */ data class SendReportsModel( - val sendCrashReportsEnabled: Boolean = false + val sendCrashReportsEnabled: Boolean = false ) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/send_crash_reports/SendReportsPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/send_crash_reports/SendReportsPresenter.kt index 4f54c933e..20015784c 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/send_crash_reports/SendReportsPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/account/send_crash_reports/SendReportsPresenter.kt @@ -15,15 +15,15 @@ import io.reactivex.schedulers.Schedulers * Created by maestrovs on 23.04.2020. */ class SendReportsPresenter constructor(private val accountRepository: AccountRepository) : - LRPresenter() { + LRPresenter() { override fun initialModelSingle(): Single = Single.zip( - Single.fromObservable(accountRepository.getAccount()), - Single.fromObservable(accountRepository.getSecurityOptions()), - BiFunction { account, securityOptions -> - SendReportsModel(false) - }) + Single.fromObservable(accountRepository.getAccount()), + Single.fromObservable(accountRepository.getSecurityOptions()), + BiFunction { account, securityOptions -> + SendReportsModel(false) + }) override fun SendReportsModel.changeInitialModel(i: SendReportsModel): SendReportsModel { return i.copy() @@ -35,46 +35,55 @@ class SendReportsPresenter constructor(private val accountRepository: AccountRep val observable = Observable.merge( - loadRefreshPartialChanges(), + loadRefreshPartialChanges(), - intent { it.switchSendCrashReports() } - .switchMap { newState -> + intent { it.switchSendCrashReports() } + .switchMap { newState -> - accountRepository.setSendCrashReportsEnabled(newState) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { success -> - SendReportsPartialChanges.SendCrashReportsEnabled(if (success) newState else !newState) - } - .onErrorReturn { - LRPartialChange.LoadingError(it) - } + accountRepository.setSendCrashReportsEnabled(newState) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { success -> + SendReportsPartialChanges.SendCrashReportsEnabled(if (success) newState else !newState) } + .onErrorReturn { + LRPartialChange.LoadingError(it) + } + } ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - SendReportsModel(), - false) + false, + null, + false, + false, + null, + false, + SendReportsModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - SendReportsView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + SendReportsView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { if (change !is SendReportsPartialChanges) return super.stateReducer(vs, change) return when (change) { - is SendReportsPartialChanges.SendCrashReportsEnabled -> vs.copy(model = vs.model.copy(sendCrashReportsEnabled = change.value)) + is SendReportsPartialChanges.SendCrashReportsEnabled -> vs.copy( + model = vs.model.copy( + sendCrashReportsEnabled = change.value + ) + ) } } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/assets/AssetsAdapter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/assets/AssetsAdapter.kt index b3d8c5bf5..29f6bd98f 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/assets/AssetsAdapter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/assets/AssetsAdapter.kt @@ -17,13 +17,16 @@ class AssetsAdapter : RecyclerView.Adapter() { DiffUtil.calculateDiff(object : DiffUtil.Callback() { override fun getOldListSize() = old.size override fun getNewListSize() = field.size - override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] - override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] }).dispatchUpdatesTo(this) notifyDataSetChanged() } - + init { setHasStableIds(true) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/assets/AssetsFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/assets/AssetsFragment.kt index 7fae4bbb3..737bbc046 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/assets/AssetsFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/assets/AssetsFragment.kt @@ -15,7 +15,8 @@ import io.forus.me.android.presentation.view.base.lr.LRViewState /** * Fragment Assign Delegates Screen. */ -class AssetsFragment : LRFragment(), AssetsView, FragmentListener { +class AssetsFragment : LRFragment(), AssetsView, + FragmentListener { companion object { fun newIntent(): AssetsFragment { @@ -33,11 +34,14 @@ class AssetsFragment : LRFragment(), A private lateinit var binding: FragmentRecyclerBinding - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View - { + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { binding = FragmentRecyclerBinding.inflate(inflater) adapter = AssetsAdapter() - return binding.root + return binding.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -50,7 +54,7 @@ class AssetsFragment : LRFragment(), A override fun createPresenter() = AssetsPresenter( - Injection.instance.assetsRepository + Injection.instance.assetsRepository ) @@ -61,8 +65,6 @@ class AssetsFragment : LRFragment(), A adapter.assets = vs.model.items - - } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/assets/AssetsModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/assets/AssetsModel.kt index 8965b0f37..3c46f706c 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/assets/AssetsModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/assets/AssetsModel.kt @@ -3,5 +3,5 @@ package io.forus.me.android.presentation.view.screens.assets import io.forus.me.android.domain.models.assets.Asset data class AssetsModel( - val items: List = emptyList() - ) \ No newline at end of file + val items: List = emptyList() +) \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/assets/AssetsPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/assets/AssetsPresenter.kt index bdf538c90..3f72e27e1 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/assets/AssetsPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/assets/AssetsPresenter.kt @@ -9,10 +9,12 @@ import io.reactivex.Single import io.reactivex.android.schedulers.AndroidSchedulers -class AssetsPresenter constructor(val assetsRepository: AssetsRepository) : LRPresenter, AssetsModel, AssetsView>() { +class AssetsPresenter constructor(val assetsRepository: AssetsRepository) : + LRPresenter, AssetsModel, AssetsView>() { - override fun initialModelSingle(): Single> = Single.fromObservable(assetsRepository.getAssets()) + override fun initialModelSingle(): Single> = + Single.fromObservable(assetsRepository.getAssets()) //.delay(1, TimeUnit.SECONDS) .map { it @@ -29,24 +31,29 @@ class AssetsPresenter constructor(val assetsRepository: AssetsRepository) : LRPr val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - AssetsModel(), - false) + false, + null, + false, + false, + null, + false, + AssetsModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - AssetsView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + AssetsView::render + ) } - override fun stateReducer(viewState: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + viewState: LRViewState, + change: PartialChange + ): LRViewState { if (change !is AssetsPartialChanges) return super.stateReducer(viewState, change) @@ -60,13 +67,4 @@ class AssetsPresenter constructor(val assetsRepository: AssetsRepository) : LRPr } - - - - - - - - - } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/dashboard/DashboardActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/dashboard/DashboardActivity.kt index 505388844..d1414a639 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/dashboard/DashboardActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/dashboard/DashboardActivity.kt @@ -25,7 +25,7 @@ import io.reactivex.schedulers.Schedulers class DashboardActivity : AppCompatActivity() { - val viewModel: VoucherViewModel by viewModels() + val viewModel: VoucherViewModel by viewModels() private val db = Injection.instance.databaseHelper val systemServices by lazy(LazyThreadSafetyMode.NONE) { SystemServices(this) } @@ -40,7 +40,6 @@ class DashboardActivity : AppCompatActivity() { } - private var settings = Injection.instance.settingsDataSource private var fcmHandler = Injection.instance.fcmHandler private var disposableHolder = DisposableHolder() @@ -57,7 +56,7 @@ class DashboardActivity : AppCompatActivity() { setContentView(binding.root) - if(!db.isOpen){ + if (!db.isOpen) { startActivity(Intent(this, MainActivity::class.java)) finish() } @@ -78,14 +77,17 @@ class DashboardActivity : AppCompatActivity() { navController.navigate(R.id.vouchersFragment) true } + R.id.dashboard_profile -> { navController.navigate(R.id.accountFragment) true } + R.id.dashboard_qr -> { navigateToQrScanner() false } + else -> false } } @@ -97,11 +99,10 @@ class DashboardActivity : AppCompatActivity() { Handler(Looper.getMainLooper()).postDelayed({ loggingViewModel.authorizeFirestore() - },100) + }, 100) } - fun navigateToQrScanner() { this.navigator.navigateToQrScanner(this) } @@ -112,18 +113,26 @@ class DashboardActivity : AppCompatActivity() { } } - fun showPopupQRFragment(address: String,qrHead: String? = null, qrSubtitle: String? = null, qrDescription: String? = null) { + fun showPopupQRFragment( + address: String, + qrHead: String? = null, + qrSubtitle: String? = null, + qrDescription: String? = null + ) { val meBottomSheet = MeBottomSheetDialogFragment.newInstance( - QrFragment.newIntent(address, qrHead, qrSubtitle, qrDescription),"QR code") + QrFragment.newIntent(address, qrHead, qrSubtitle, qrDescription), "QR code" + ) meBottomSheet.show(supportFragmentManager, meBottomSheet.tag) } private fun checkFCM() { - disposableHolder.add(fcmHandler.checkFCMToken(this) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe()) + disposableHolder.add( + fcmHandler.checkFCMToken(this) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe() + ) } fun logout() { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/dashboard/DashboardPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/dashboard/DashboardPresenter.kt index d46859e5d..770e818a9 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/dashboard/DashboardPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/dashboard/DashboardPresenter.kt @@ -8,18 +8,21 @@ import io.forus.me.android.domain.models.account.Account import io.forus.me.android.domain.repository.account.AccountRepository -class DashboardPresenter(private var view: DashboardContract.View?, - private val checkLoginUseCase: UseCase, - private val loadAccountUseCase: UseCase, - private val checkSendCrashReportsEnabledUseCase: UseCase, - private val exitIdentityUseCase: UseCase, - private val accountRepository: AccountRepository +class DashboardPresenter( + private var view: DashboardContract.View?, + private val checkLoginUseCase: UseCase, + private val loadAccountUseCase: UseCase, + private val checkSendCrashReportsEnabledUseCase: UseCase, + private val exitIdentityUseCase: UseCase, + private val accountRepository: AccountRepository ) : DashboardContract.Presenter { override fun onCreate() { - checkLoginUseCase.execute(CheckLoginObserver(), - CheckLoginUseCase.Params()) + checkLoginUseCase.execute( + CheckLoginObserver(), + CheckLoginUseCase.Params() + ) } override fun onDestroy() { @@ -63,5 +66,4 @@ class DashboardPresenter(private var view: DashboardContract.View?, } - } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/dashboard/LoggingViewModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/dashboard/LoggingViewModel.kt index f9fc0956b..248ddb3fc 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/dashboard/LoggingViewModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/dashboard/LoggingViewModel.kt @@ -15,12 +15,13 @@ class LoggingViewModelFactory(private val firestoreTokenManager: FirestoreTokenM } } -class LoggingViewModel constructor(private val firestoreTokenManager: FirestoreTokenManager) : ViewModel() { +class LoggingViewModel constructor(private val firestoreTokenManager: FirestoreTokenManager) : + ViewModel() { - fun authorizeFirestore(){ - firestoreTokenManager.authorizeFirestore{ - Log.d("FirestoreLogger","Firestore success authorized!") + fun authorizeFirestore() { + firestoreTokenManager.authorizeFirestore { + Log.d("FirestoreLogger", "Firestore success authorized!") } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/PinLockActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/PinLockActivity.kt index f6295e2d6..67608d07d 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/PinLockActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/PinLockActivity.kt @@ -16,7 +16,11 @@ class PinLockActivity : CommonActivity() { private val LOCK_INTENT_EXTRA = "LOCK_INTENT_EXTRA" private val USE_FINGERPRINT = "USE_FINGERPRINT" - fun getCallingIntent(context: Context, navigationIntent: Intent, useFingerprint: Boolean): Intent { + fun getCallingIntent( + context: Context, + navigationIntent: Intent, + useFingerprint: Boolean + ): Intent { val intent = Intent(context, PinLockActivity::class.java) intent.putExtra(LOCK_INTENT_EXTRA, navigationIntent) intent.putExtra(USE_FINGERPRINT, useFingerprint) @@ -36,31 +40,29 @@ class PinLockActivity : CommonActivity() { navigationIntent = intent.getParcelableExtra(LOCK_INTENT_EXTRA)!! val useFingerprint = intent.getBooleanExtra(USE_FINGERPRINT, false) - if(useFingerprint){ + if (useFingerprint) { useFingerprint() - } - else{ + } else { usePinlock() } } } - fun useFingerprint(){ + fun useFingerprint() { val fragment = FingerprintFragment.newIntent() replaceFragment(R.id.fragmentContainer, fragment) } - fun usePinlock(){ + fun usePinlock() { val fragment = PinLockFragment.newIntent() replaceFragment(R.id.fragmentContainer, fragment) } - - fun unlockSuccess(){ + fun unlockSuccess() { navigationIntent?.let { this.startActivity(navigationIntent) - }?:run{ + } ?: run { this.startActivity(DashboardActivity.getCallingIntent(this)) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/fingerprint/BiometricPromptManager.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/fingerprint/BiometricPromptManager.kt index 3d6cf17d6..874a84816 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/fingerprint/BiometricPromptManager.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/fingerprint/BiometricPromptManager.kt @@ -21,7 +21,7 @@ class BiometricPromptManager( description: String ) { val manager = BiometricManager.from(activity) - val authenticators = if(Build.VERSION.SDK_INT >= 28) { + val authenticators = if (Build.VERSION.SDK_INT >= 28) { BIOMETRIC_STRONG or DEVICE_CREDENTIAL } else BIOMETRIC_STRONG @@ -30,23 +30,26 @@ class BiometricPromptManager( .setDescription(description) .setAllowedAuthenticators(authenticators) - if(Build.VERSION.SDK_INT < 28) { + if (Build.VERSION.SDK_INT < 28) { promptInfo.setNegativeButtonText(activity.getString(android.R.string.cancel)) } - when(manager.canAuthenticate(authenticators)) { + when (manager.canAuthenticate(authenticators)) { BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE -> { resultChannel.trySend(BiometricResult.HardwareUnavailable) return } + BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE -> { resultChannel.trySend(BiometricResult.FeatureUnavailable) return } + BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED -> { resultChannel.trySend(BiometricResult.AuthenticationNotSet) return } + else -> Unit } @@ -73,11 +76,11 @@ class BiometricPromptManager( } sealed interface BiometricResult { - data object HardwareUnavailable: BiometricResult - data object FeatureUnavailable: BiometricResult - data class AuthenticationError(val error: String): BiometricResult - data object AuthenticationFailed: BiometricResult - data object AuthenticationSuccess: BiometricResult - data object AuthenticationNotSet: BiometricResult + data object HardwareUnavailable : BiometricResult + data object FeatureUnavailable : BiometricResult + data class AuthenticationError(val error: String) : BiometricResult + data object AuthenticationFailed : BiometricResult + data object AuthenticationSuccess : BiometricResult + data object AuthenticationNotSet : BiometricResult } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/fingerprint/FingerprintFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/fingerprint/FingerprintFragment.kt index 61aa83e65..6fc9dd0fb 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/fingerprint/FingerprintFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/fingerprint/FingerprintFragment.kt @@ -44,7 +44,7 @@ class FingerprintFragment : override val toolbarTitle: String get() = resources.getString(R.string.lock_fingerprint_title) - // private lateinit var mFingerPrintAuthHelper: FingerPrintAuthHelper + // private lateinit var mFingerPrintAuthHelper: FingerPrintAuthHelper override fun viewForSnackbar(): View = binding.root @@ -89,22 +89,27 @@ class FingerprintFragment : lifecycleScope.launch { promptManager.promptResults.collect { result -> - when(result) { + when (result) { is BiometricPromptManager.BiometricResult.AuthenticationError -> { result.error } + BiometricPromptManager.BiometricResult.AuthenticationFailed -> { authFail.onNext(errorAuthFail) } + BiometricPromptManager.BiometricResult.AuthenticationNotSet -> { authFail.onNext(errorNoFingerprints) } + BiometricPromptManager.BiometricResult.AuthenticationSuccess -> { authSuccess.onNext(Unit) } + BiometricPromptManager.BiometricResult.FeatureUnavailable -> { authFail.onNext(errorHwNotFound) } + BiometricPromptManager.BiometricResult.HardwareUnavailable -> { authFail.onNext(errorHwNotFound) } @@ -114,10 +119,6 @@ class FingerprintFragment : } - - - - override fun onResume() { super.onResume() val uiHandler = Handler(Looper.getMainLooper()) @@ -130,8 +131,6 @@ class FingerprintFragment : } - - override fun createPresenter() = FingerprintPresenter( Injection.instance.accountRepository ) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/fingerprint/FingerprintModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/fingerprint/FingerprintModel.kt index 42fa4f6c1..1036c4cf0 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/fingerprint/FingerprintModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/fingerprint/FingerprintModel.kt @@ -2,8 +2,8 @@ package io.forus.me.android.presentation.view.screens.lock.fingerprint data class FingerprintModel( - val unlockSuccess: Boolean = false, - val unlockFail: Boolean = false, - val unlockFailMessage: String? = null, - val usePin: Boolean = false + val unlockSuccess: Boolean = false, + val unlockFail: Boolean = false, + val unlockFailMessage: String? = null, + val usePin: Boolean = false ) \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/fingerprint/FingerprintPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/fingerprint/FingerprintPresenter.kt index 16a031dcc..81d02a76d 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/fingerprint/FingerprintPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/fingerprint/FingerprintPresenter.kt @@ -10,7 +10,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers import io.reactivex.subjects.PublishSubject -class FingerprintPresenter constructor(val accountRepository: AccountRepository) : LRPresenter() { +class FingerprintPresenter constructor(val accountRepository: AccountRepository) : + LRPresenter() { override fun initialModelSingle(): Single = Single.just(Unit) @@ -23,54 +24,72 @@ class FingerprintPresenter constructor(val accountRepository: AccountRepository) val observable = Observable.merge( - loadRefreshPartialChanges(), - - intent { it.exit() } - .map { FingerprintPartialChanges.Exit(it) }, - - intent { it.authFail() } - .map { FingerprintPartialChanges.UnlockFail(it) }, - - intent { it.authSuccess() } - .switchMap { - accountRepository.unlockByFingerprint() - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - FingerprintPartialChanges.UnlockSuccess(Unit) - } - .onErrorReturn { - FingerprintPartialChanges.UnlockFail(it.toString()) - } + loadRefreshPartialChanges(), + + intent { it.exit() } + .map { FingerprintPartialChanges.Exit(it) }, + + intent { it.authFail() } + .map { FingerprintPartialChanges.UnlockFail(it) }, + + intent { it.authSuccess() } + .switchMap { + accountRepository.unlockByFingerprint() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + FingerprintPartialChanges.UnlockSuccess(Unit) } + .onErrorReturn { + FingerprintPartialChanges.UnlockFail(it.toString()) + } + } ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - FingerprintModel(), - false) + false, + null, + false, + false, + null, + false, + FingerprintModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - FingerprintView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + FingerprintView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { if (change !is FingerprintPartialChanges) return super.stateReducer(vs, change) return when (change) { - is FingerprintPartialChanges.Exit -> vs.copy(closeScreen = true, model = vs.model.copy(usePin = true)) - is FingerprintPartialChanges.UnlockFail -> vs.copy(model = vs.model.copy(unlockFail = true, unlockFailMessage = change.reason)) - is FingerprintPartialChanges.UnlockSuccess -> vs.copy(closeScreen = true, model = vs.model.copy(unlockSuccess = true)) + is FingerprintPartialChanges.Exit -> vs.copy( + closeScreen = true, + model = vs.model.copy(usePin = true) + ) + + is FingerprintPartialChanges.UnlockFail -> vs.copy( + model = vs.model.copy( + unlockFail = true, + unlockFailMessage = change.reason + ) + ) + + is FingerprintPartialChanges.UnlockSuccess -> vs.copy( + closeScreen = true, + model = vs.model.copy(unlockSuccess = true) + ) } } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/pin/PinLockFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/pin/PinLockFragment.kt index 37358fb02..c082ea231 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/pin/PinLockFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/pin/PinLockFragment.kt @@ -131,7 +131,8 @@ class PinLockFragment : LRFragment( } PinLockModel.State.CONFIRM, PinLockModel.State.CHECKING, - PinLockModel.State.SUCCESS -> {} + PinLockModel.State.SUCCESS -> { + } } if (vs.closeScreen) { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/pin/PinLockModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/pin/PinLockModel.kt index 4fd55eaab..dfda3022c 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/pin/PinLockModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/pin/PinLockModel.kt @@ -1,13 +1,13 @@ package io.forus.me.android.presentation.view.screens.lock.pin data class PinLockModel( - val state: State = State.CONFIRM, - val prevState: State = State.CONFIRM -) -{ + val state: State = State.CONFIRM, + val prevState: State = State.CONFIRM +) { enum class State { CONFIRM, CHECKING, WRONG_PIN, SUCCESS } - fun changeState(newState: State = this.state): PinLockModel = copy(prevState = state, state = newState) + fun changeState(newState: State = this.state): PinLockModel = + copy(prevState = state, state = newState) } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/pin/PinLockPartialChanges.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/pin/PinLockPartialChanges.kt index a0e2c39c5..9f434d7a4 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/pin/PinLockPartialChanges.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/pin/PinLockPartialChanges.kt @@ -14,7 +14,7 @@ sealed class PinLockPartialChanges : PartialChange { data class Exit(val void: Unit) : PinLockPartialChanges() - data class ExitIdentity(val void: Unit): PinLockPartialChanges() + data class ExitIdentity(val void: Unit) : PinLockPartialChanges() data class Nothing(val void: Unit) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/pin/PinLockPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/pin/PinLockPresenter.kt index 53afa0e35..fedd4d54b 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/pin/PinLockPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/lock/pin/PinLockPresenter.kt @@ -12,7 +12,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers import io.reactivex.subjects.PublishSubject -class PinLockPresenter constructor(private val accountRepository: AccountRepository) : LRPresenter() { +class PinLockPresenter constructor(private val accountRepository: AccountRepository) : + LRPresenter() { override fun initialModelSingle(): Single = Single.just(Unit) @@ -25,78 +26,83 @@ class PinLockPresenter constructor(private val accountRepository: AccountReposit val observable = Observable.mergeArray( - loadRefreshPartialChanges(), - - Observable.mergeArray( - intent { it.pinOnComplete() } - .map { PinLockPartialChanges.PinOnComplete(it) }, - intent { it.pinOnChange() } - .map { PinLockPartialChanges.PinOnChange(it) } - ), - - intent { it.exit() } - .switchMap { - accountRepository.exitIdentity() - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .flatMap { - Injection.instance.fcmHandler.clearFCMToken() - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { PinLockPartialChanges.Exit(Unit) } - .onErrorReturn { LRPartialChange.LoadingError(it) } - } - .onErrorReturn { - LRPartialChange.LoadingError(it) - } - }, - - intent { checkPin() } - .switchMap { - accountRepository.unlockIdentity(it) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - if (it) PinLockPartialChanges.CheckPinSuccess(Unit) - else PinLockPartialChanges.CheckPinError(Unit) - } - .onErrorReturn { - PinLockPartialChanges.CheckPinError(Unit) - } - }, - intent { it.logout() } - .switchMap { - accountRepository - .exitIdentity() - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .single(false) - .map { - PinLockPartialChanges.ExitIdentity(Unit) - } - .toObservable() + loadRefreshPartialChanges(), + + Observable.mergeArray( + intent { it.pinOnComplete() } + .map { PinLockPartialChanges.PinOnComplete(it) }, + intent { it.pinOnChange() } + .map { PinLockPartialChanges.PinOnChange(it) } + ), + + intent { it.exit() } + .switchMap { + accountRepository.exitIdentity() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .flatMap { + Injection.instance.fcmHandler.clearFCMToken() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { PinLockPartialChanges.Exit(Unit) } + .onErrorReturn { LRPartialChange.LoadingError(it) } } + .onErrorReturn { + LRPartialChange.LoadingError(it) + } + }, + + intent { checkPin() } + .switchMap { + accountRepository.unlockIdentity(it) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + if (it) PinLockPartialChanges.CheckPinSuccess(Unit) + else PinLockPartialChanges.CheckPinError(Unit) + } + .onErrorReturn { + PinLockPartialChanges.CheckPinError(Unit) + } + }, + intent { it.logout() } + .switchMap { + accountRepository + .exitIdentity() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .single(false) + .map { + PinLockPartialChanges.ExitIdentity(Unit) + } + .toObservable() + } ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - PinLockModel(), - false) + false, + null, + false, + false, + null, + false, + PinLockModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - PinLockView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + PinLockView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { if (change !is PinLockPartialChanges) return super.stateReducer(vs, change) @@ -107,22 +113,38 @@ class PinLockPresenter constructor(private val accountRepository: AccountReposit checkPin.onNext(change.passcode) vs.copy(model = vs.model.changeState(PinLockModel.State.CHECKING)) } + else -> { vs.copy(model = vs.model.changeState(vs.model.state)) } } } + is PinLockPartialChanges.PinOnChange -> { when (vs.model.state) { - PinLockModel.State.WRONG_PIN -> vs.copy(model = vs.model.changeState(PinLockModel.State.CONFIRM)) + PinLockModel.State.WRONG_PIN -> vs.copy( + model = vs.model.changeState( + PinLockModel.State.CONFIRM + ) + ) + else -> { vs.copy(model = vs.model.changeState()) } } } - is PinLockPartialChanges.CheckPinError -> vs.copy(model = vs.model.changeState(PinLockModel.State.WRONG_PIN)) - is PinLockPartialChanges.CheckPinSuccess -> vs.copy(closeScreen = true, model = vs.model.changeState(PinLockModel.State.SUCCESS)) + is PinLockPartialChanges.CheckPinError -> vs.copy( + model = vs.model.changeState( + PinLockModel.State.WRONG_PIN + ) + ) + + is PinLockPartialChanges.CheckPinSuccess -> vs.copy( + closeScreen = true, + model = vs.model.changeState(PinLockModel.State.SUCCESS) + ) + is PinLockPartialChanges.Exit -> vs.copy(closeScreen = true) is PinLockPartialChanges.ExitIdentity -> vs.copy(exitIdentity = true) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/main/MainActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/main/MainActivity.kt index f65ec9e77..7114eebec 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/main/MainActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/main/MainActivity.kt @@ -42,11 +42,16 @@ class MainActivity : BaseActivity() { if (!BuildConfig.APPLICATION_ID.equals("io.forus.me")) { - val savedApiOption = SharedPref.read(SharedPref.OPTION_API_TYPE,"") ?: "" + val savedApiOption = SharedPref.read(SharedPref.OPTION_API_TYPE, "") ?: "" if (savedApiOption.isNotEmpty()) { val apiType = ApiConfig.stringToApiType(savedApiOption) if (apiType == ApiType.OTHER) { - ApiConfig.changeToCustomApi(SharedPref.read(SharedPref.OPTION_CUSTOM_API_URL, BuildConfig.SERVER_URL)) + ApiConfig.changeToCustomApi( + SharedPref.read( + SharedPref.OPTION_CUSTOM_API_URL, + BuildConfig.SERVER_URL + ) + ) } else { ApiConfig.changeApi(apiType) } @@ -72,7 +77,7 @@ class MainActivity : BaseActivity() { } else { navigateToWelcomeScreen() //old behavior - // navigateToLogInsignUpScreen() //current behavior + // navigateToLogInsignUpScreen() //current behavior } } @@ -92,9 +97,9 @@ class MainActivity : BaseActivity() { private fun navigateToWelcomeScreen() { val notShowAgain = SharedPref.read(SharedPref.WELCOME_NOT_SHOW_AGAIN, false) - if(notShowAgain){ + if (notShowAgain) { this.navigator.navigateToLoginSignUp(this) - }else{ + } else { this.navigator.navigateToWelcomeScreen(this, goToLogin = true) } @@ -127,8 +132,10 @@ class MainActivity : BaseActivity() { val result = googleAPI.isGooglePlayServicesAvailable(this) if (result != ConnectionResult.SUCCESS) { if (googleAPI.isUserResolvableError(result)) { - googleAPI.getErrorDialog(this, result, - PLAY_SERVICES_RESOLUTION_REQUEST)?.show() + googleAPI.getErrorDialog( + this, result, + PLAY_SERVICES_RESOLUTION_REQUEST + )?.show() } return false @@ -154,7 +161,8 @@ class MainActivity : BaseActivity() { val appUpdateInfoTask = appUpdateManager!!.appUpdateInfo appUpdateInfoTask.addOnSuccessListener { appUpdateInfo -> if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE - && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) { + && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE) + ) { SharedPref.write(SharedPref.OPTION_NEED_APP_UPDATE, true) @@ -179,16 +187,15 @@ class MainActivity : BaseActivity() { @Throws(IntentSender.SendIntentException::class) private fun updateApp(appUpdateInfo: AppUpdateInfo) { appUpdateManager!!.startUpdateFlowForResult( - appUpdateInfo, - AppUpdateType.IMMEDIATE, - this, - MY_REQUEST_CODE) + appUpdateInfo, + AppUpdateType.IMMEDIATE, + this, + MY_REQUEST_CODE + ) } - - override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == MY_REQUEST_CODE) { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/property/PropertyFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/property/PropertyFragment.kt index cee13b0a3..68ac2a3b6 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/property/PropertyFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/property/PropertyFragment.kt @@ -1,4 +1,3 @@ - package io.forus.me.android.presentation.view.screens.property import android.os.Bundle @@ -25,6 +24,7 @@ class PropertyFragment : BaseFragment() { return PropertyFragment() } } + override fun getLayoutID(): Int { return R.layout.fragment_property } @@ -65,7 +65,12 @@ class PropertyFragment : BaseFragment() { titles.add(getString(R.string.dashboard_vouchers)) - val adapter = MainViewPagerAdapter(childFragmentManager, activity?.applicationContext, fragments, titles) + val adapter = MainViewPagerAdapter( + childFragmentManager, + activity?.applicationContext, + fragments, + titles + ) binding.viewpager.adapter = adapter binding.viewpager.offscreenPageLimit = 3 binding.slidingTabs.setupWithViewPager(binding.viewpager) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/QrActionProcessor.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/QrActionProcessor.kt index 841d36a3c..9f35f164a 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/QrActionProcessor.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/QrActionProcessor.kt @@ -25,11 +25,13 @@ import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers import java.math.BigDecimal -class QrActionProcessor(private val scanner: QrScannerActivity, - private val recordsRepository: RecordsRepository, - private val accountRepository: AccountRepository, - private val vouchersRepository: VouchersRepository, - private val settingsDataSource: SettingsDataSource) { +class QrActionProcessor( + private val scanner: QrScannerActivity, + private val recordsRepository: RecordsRepository, + private val accountRepository: AccountRepository, + private val vouchersRepository: VouchersRepository, + private val settingsDataSource: SettingsDataSource +) { private val resources by lazy { return@lazy scanner.resources @@ -50,21 +52,21 @@ class QrActionProcessor(private val scanner: QrScannerActivity, fun approveValidation(uuid: String) { recordsRepository.readValidation(uuid) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { validation -> - if (validation.state == Validation.State.pending && validation.uuid != null) { - if (scanner.hasWindowFocus()) - showChooseValidatorDialog(validation) - - } else { - onResultValidationAlreadyDone() - } - } - .onErrorReturn { - onResultUnexpectedError() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { validation -> + if (validation.state == Validation.State.pending && validation.uuid != null) { + if (scanner.hasWindowFocus()) + showChooseValidatorDialog(validation) + + } else { + onResultValidationAlreadyDone() } - .subscribe() + } + .onErrorReturn { + onResultUnexpectedError() + } + .subscribe() } fun restoreIdentity(token: String) { @@ -72,11 +74,12 @@ class QrActionProcessor(private val scanner: QrScannerActivity, Log.d("forusQR", "restore identity $token") val confirmLoginDeviceDialog = ConfirmLoginDeviceDialog() - confirmLoginDeviceDialog.submitClickListener = object :ConfirmLoginDeviceDialog.SubmitClickListener{ - override fun confirm(dialog: ConfirmLoginDeviceDialog?) { - confirmLoginDeviceDialog.dismiss() - scanner.finish() - accountRepository.authorizeToken(token) + confirmLoginDeviceDialog.submitClickListener = + object : ConfirmLoginDeviceDialog.SubmitClickListener { + override fun confirm(dialog: ConfirmLoginDeviceDialog?) { + confirmLoginDeviceDialog.dismiss() + scanner.finish() + accountRepository.authorizeToken(token) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .map { @@ -91,22 +94,22 @@ class QrActionProcessor(private val scanner: QrScannerActivity, } .subscribe() - } + } - override fun dismiss(dialog: ConfirmLoginDeviceDialog?) { - confirmLoginDeviceDialog.dismiss() - scanner.finish() - } + override fun dismiss(dialog: ConfirmLoginDeviceDialog?) { + confirmLoginDeviceDialog.dismiss() + scanner.finish() + } - } + } confirmLoginDeviceDialog.show(scanner.supportFragmentManager, "") - } - private var retrofitExceptionMapper: RetrofitExceptionMapper = Injection.instance.retrofitExceptionMapper + private var retrofitExceptionMapper: RetrofitExceptionMapper = + Injection.instance.retrofitExceptionMapper fun scanVoucher(address: String, isDemoVoucher: Boolean? = false) { scanner.allowReactivate() @@ -115,64 +118,70 @@ class QrActionProcessor(private val scanner: QrScannerActivity, scanner.finish() } else { vouchersRepository.getVoucherAsProvider(address) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - if (it.voucher.fundType == FundType.subsidies.name) { - navigator.navigateToActionsVoucherProvider(scanner, it.voucher.address!!) - scanner.finish() - } else { - if (it.voucher.isProduct != true && it.allowedOrganizations.isEmpty()) { - if (scanner.hasWindowFocus()) - ScanVoucherNotEligibleDialog(scanner, reactivateDecoding).show() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + if (it.voucher.fundType == FundType.subsidies.name) { + navigator.navigateToActionsVoucherProvider(scanner, it.voucher.address!!) + scanner.finish() + } else { + if (it.voucher.isProduct != true && it.allowedOrganizations.isEmpty()) { + if (scanner.hasWindowFocus()) + ScanVoucherNotEligibleDialog(scanner, reactivateDecoding).show() - } else { - val isAvailableScannedVoucher = !(it.voucher.isProduct != true && ( - it.voucher.amount - ?: 0.toBigDecimal()).compareTo(BigDecimal.ZERO) == 0) - onResultVoucherScanned(address, isAvailableScannedVoucher) + } else { + val isAvailableScannedVoucher = !(it.voucher.isProduct != true && ( + it.voucher.amount + ?: 0.toBigDecimal()).compareTo(BigDecimal.ZERO) == 0) + onResultVoucherScanned(address, isAvailableScannedVoucher) - } } } - .onErrorReturn { + } + .onErrorReturn { - var canOnResultVoucherScanned = true + var canOnResultVoucherScanned = true - Log.e("QR_ACTION", "scan voucher_error", it) + Log.e("QR_ACTION", "scan voucher_error", it) - val error: Throwable = it + val error: Throwable = it - if (error is io.forus.me.android.data.exception.RetrofitException && error.kind == RetrofitException.Kind.NETWORK) { - NoInternetDialog(scanner, reactivateDecoding).show(); - } else { + if (error is io.forus.me.android.data.exception.RetrofitException && error.kind == RetrofitException.Kind.NETWORK) { + NoInternetDialog(scanner, reactivateDecoding).show(); + } else { - if (error is RetrofitException && error.kind == RetrofitException.Kind.HTTP) { + if (error is RetrofitException && error.kind == RetrofitException.Kind.HTTP) { - try { - val newRecordError = retrofitExceptionMapper.mapToBaseApiError(error) + try { + val newRecordError = + retrofitExceptionMapper.mapToBaseApiError(error) - if (error.responseCode == 403) { - canOnResultVoucherScanned = false - val message = if (newRecordError.message == null) "" else newRecordError.message - ScanVoucherBaseErrorDialog(message, scanner, reactivateDecoding).show() - } - } catch (_: Exception) { + if (error.responseCode == 403) { + canOnResultVoucherScanned = false + val message = + if (newRecordError.message == null) "" else newRecordError.message + ScanVoucherBaseErrorDialog( + message, + scanner, + reactivateDecoding + ).show() } + } catch (_: Exception) { } + } - if (canOnResultVoucherScanned) { + if (canOnResultVoucherScanned) { - if (scanner.hasWindowFocus()) { - onResultVoucherScanned(address, false) - } + if (scanner.hasWindowFocus()) { + onResultVoucherScanned(address, false) } } - scanner.setScannerLayoutVisiblity(true) } - .subscribe() + scanner.setScannerLayoutVisiblity(true) + } + .subscribe() } } @@ -213,11 +222,14 @@ class QrActionProcessor(private val scanner: QrScannerActivity, } } - ScanVoucherBaseErrorDialog(errorMessage, scanner, object : DialogInterface.OnDismissListener, - () -> Unit { - override fun invoke() {} - override fun onDismiss(p0: DialogInterface?) {} - }).show() + ScanVoucherBaseErrorDialog( + errorMessage, + scanner, + object : DialogInterface.OnDismissListener, + () -> Unit { + override fun invoke() {} + override fun onDismiss(p0: DialogInterface?) {} + }).show() reactivateDecoding() scanner.setScannerLayoutVisiblity(true) } @@ -228,7 +240,11 @@ class QrActionProcessor(private val scanner: QrScannerActivity, if (false and settingsDataSource.isPinEnabled()) { // Database will be opened later val useFingerprint = settingsDataSource.isFingerprintEnabled() - navigator.navigateToCheckTransactionPin(scanner, ProviderActivity.getCallingIntent(scanner, address), useFingerprint) + navigator.navigateToCheckTransactionPin( + scanner, + ProviderActivity.getCallingIntent(scanner, address), + useFingerprint + ) (android.os.Handler()).postDelayed({ reactivateDecoding() }, 1000) @@ -248,35 +264,37 @@ class QrActionProcessor(private val scanner: QrScannerActivity, val validators = validation.organizationsAvailable if (validators != null && validators.size > 0) { ValidatorsListDialog(scanner, validators!!) { - ApproveValidationDialog(scanner, - validation, - { - //scanner.allowReactivate() - scanner.finish() - recordsRepository.approveValidation(validation.uuid!!, it.id) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { onResultValidationApproved() } - .onErrorReturn { - onResultUnexpectedError() - } - .subscribe() - }, - { - scanner.finish() - recordsRepository.declineValidation(validation.uuid!!) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - onResultValidationDeclined() - } - .onErrorReturn { - onResultUnexpectedError() - } - .subscribe() - }, - reactivateDecoding) - .show() + ApproveValidationDialog( + scanner, + validation, + { + //scanner.allowReactivate() + scanner.finish() + recordsRepository.approveValidation(validation.uuid!!, it.id) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { onResultValidationApproved() } + .onErrorReturn { + onResultUnexpectedError() + } + .subscribe() + }, + { + scanner.finish() + recordsRepository.declineValidation(validation.uuid!!) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + onResultValidationDeclined() + } + .onErrorReturn { + onResultUnexpectedError() + } + .subscribe() + }, + reactivateDecoding + ) + .show() }.show() } else { @@ -290,46 +308,50 @@ class QrActionProcessor(private val scanner: QrScannerActivity, vouchersRepository.getProductVouchersAsProvider(address)//getVoucherAsProvider(address) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - - if (it.size > 0) { - //Show product vouchers list - navigator.navigateToProductReservation(scanner, address, isAvailableScannedVoucher) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + + if (it.size > 0) { + //Show product vouchers list + navigator.navigateToProductReservation( + scanner, + address, + isAvailableScannedVoucher + ) + scanner.finish() + + } else { + + if (isAvailableScannedVoucher) { + //Show voucher + navigator.navigateToVoucherProvider(scanner, address) scanner.finish() - } else { - - if (isAvailableScannedVoucher) { - //Show voucher - navigator.navigateToVoucherProvider(scanner, address) - scanner.finish() - } else { - if (scanner.hasWindowFocus()) - ScanVoucherEmptyDialog(scanner, reactivateDecoding).show() - scanner.setScannerLayoutVisiblity(true) - } - + if (scanner.hasWindowFocus()) + ScanVoucherEmptyDialog(scanner, reactivateDecoding).show() + scanner.setScannerLayoutVisiblity(true) } } - .onErrorReturn { - if (scanner.hasWindowFocus()) { - if (isAvailableScannedVoucher) { + } + .onErrorReturn { + if (scanner.hasWindowFocus()) { - navigator.navigateToVoucherProvider(scanner, address) - scanner.finish() - } else { - //ScanVoucherNotEligibleDialog(scanner, reactivateDecoding).show() + if (isAvailableScannedVoucher) { - processScannerError(it) + navigator.navigateToVoucherProvider(scanner, address) + scanner.finish() + } else { + //ScanVoucherNotEligibleDialog(scanner, reactivateDecoding).show() + + processScannerError(it) - } } } - .subscribe() + } + .subscribe() } @@ -354,12 +376,15 @@ class QrActionProcessor(private val scanner: QrScannerActivity, } } - ScanVoucherBaseErrorDialog(errorMessage, scanner, object : DialogInterface.OnDismissListener, - () -> Unit { - override fun invoke() {} - override fun onDismiss(p0: DialogInterface?) {} - }).show() - scanner.setScannerLayoutVisiblity(true) + ScanVoucherBaseErrorDialog( + errorMessage, + scanner, + object : DialogInterface.OnDismissListener, + () -> Unit { + override fun invoke() {} + override fun onDismiss(p0: DialogInterface?) {} + }).show() + scanner.setScannerLayoutVisiblity(true) } @@ -367,7 +392,7 @@ class QrActionProcessor(private val scanner: QrScannerActivity, private fun onResultUnexpectedError() { showToastMessage(resources.getString(R.string.qr_unexpected_error)) reactivateDecoding() - scanner.setScannerLayoutVisiblity(true) + scanner.setScannerLayoutVisiblity(true) } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/QrScannerActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/QrScannerActivity.kt index 23ec04627..1444c9a13 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/QrScannerActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/QrScannerActivity.kt @@ -155,7 +155,7 @@ class QrScannerActivity : FragmentActivity(), MY_PERMISSION_REQUEST_CAMERA ) } - }else{ + } else { finish() } } @@ -178,7 +178,11 @@ class QrScannerActivity : FragmentActivity(), } else { Log.d("forusQR", "Permission not granted") - if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) { + if (ActivityCompat.shouldShowRequestPermissionRationale( + this, + Manifest.permission.CAMERA + ) + ) { Snackbar.make( binding.mainLayout, resources.getString(R.string.qr_camera_permission_required), diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ApproveValidationDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ApproveValidationDialog.kt index 512cf7e5f..f67ab4b5b 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ApproveValidationDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ApproveValidationDialog.kt @@ -8,21 +8,23 @@ import io.forus.me.android.presentation.R import io.forus.me.android.presentation.view.component.text.TextView -class ApproveValidationDialog(private val context: Context, - private val validation: Validation, - private val positiveCallback: () -> Unit, - private val negativeCallback: () -> Unit, - private val cancelListener: () -> Unit){ +class ApproveValidationDialog( + private val context: Context, + private val validation: Validation, + private val positiveCallback: () -> Unit, + private val negativeCallback: () -> Unit, + private val cancelListener: () -> Unit +) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title(context.resources.getString(R.string.qr_popup_approve_validation_title)) - .customView(R.layout.view_approve_validation, false) - .positiveText(context.resources.getString(R.string.qr_popup_approve_validation_positive)) - .negativeText(context.resources.getString(R.string.qr_popup_approve_validation_negative)) - .onPositive { dialog, which -> positiveCallback.invoke() } - .onNegative { dialog, which -> negativeCallback.invoke() } - .cancelListener { cancelListener.invoke() } - .build() + .title(context.resources.getString(R.string.qr_popup_approve_validation_title)) + .customView(R.layout.view_approve_validation, false) + .positiveText(context.resources.getString(R.string.qr_popup_approve_validation_positive)) + .negativeText(context.resources.getString(R.string.qr_popup_approve_validation_negative)) + .onPositive { dialog, which -> positiveCallback.invoke() } + .onNegative { dialog, which -> negativeCallback.invoke() } + .cancelListener { cancelListener.invoke() } + .build() init { val view = dialog.customView @@ -30,8 +32,8 @@ class ApproveValidationDialog(private val context: Context, view?.findViewById(R.id.value)?.text = validation.value } - fun show(){ - Log.d("DialogScan","ApproveValidationDialog") + fun show() { + Log.d("DialogScan", "ApproveValidationDialog") dialog.show() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ConfirmLoginDeviceDialog.java b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ConfirmLoginDeviceDialog.java index 77b1f84d8..61c73214c 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ConfirmLoginDeviceDialog.java +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ConfirmLoginDeviceDialog.java @@ -20,13 +20,11 @@ public class ConfirmLoginDeviceDialog extends DialogFragment { - View rootView; - - - public SubmitClickListener submitClickListener; + View rootView; + boolean isSmallScreen = false; - public static ConfirmLoginDeviceDialog display(FragmentManager fragmentManager,SubmitClickListener submitClickListener) { + public static ConfirmLoginDeviceDialog display(FragmentManager fragmentManager, SubmitClickListener submitClickListener) { ConfirmLoginDeviceDialog dialog = new ConfirmLoginDeviceDialog(); dialog.submitClickListener = submitClickListener; @@ -41,8 +39,6 @@ public void onCreate(Bundle savedInstanceState) { setStyle(DialogFragment.STYLE_NORMAL, R.style.AppTheme_FullScreenDialog); } - boolean isSmallScreen = false; - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -53,7 +49,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa float dpHeight = outMetrics.heightPixels / density; float dpWidth = outMetrics.widthPixels / density; - if (dpWidth <= 320 || dpHeight < 522){ + if (dpWidth <= 320 || dpHeight < 522) { isSmallScreen = true; } @@ -83,7 +79,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat io.forus.me.android.presentation.view.component.buttons.Button submitButton = rootView.findViewById(R.id.submitButton); LinearLayout imageL = rootView.findViewById(R.id.imageL); - if(isSmallScreen){ + if (isSmallScreen) { imageL.setVisibility(View.INVISIBLE); } @@ -101,8 +97,6 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat }); - - if (submitClickListener != null) { submitButton.setOnClickListener(view13 -> { if (submitClickListener != null) { @@ -122,6 +116,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { public interface SubmitClickListener { void confirm(ConfirmLoginDeviceDialog dialog); + void dismiss(ConfirmLoginDeviceDialog dialog); } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/RestoreIdentityDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/RestoreIdentityDialog.kt index fceb6d067..98e444a6a 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/RestoreIdentityDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/RestoreIdentityDialog.kt @@ -5,19 +5,21 @@ import com.afollestad.materialdialogs.MaterialDialog import io.forus.me.android.presentation.R -class RestoreIdentityDialog(private val context: Context, - private val positiveCallback: () -> Unit, - private val cancelListener: () -> Unit){ +class RestoreIdentityDialog( + private val context: Context, + private val positiveCallback: () -> Unit, + private val cancelListener: () -> Unit +) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title(context.resources.getString(R.string.qr_popup_restore_identity_title)) - .content(context.resources.getString(R.string.qr_popup_restore_identity_description)) - .positiveText(context.resources.getString(R.string.me_ok)) - .onPositive { dialog, which -> positiveCallback.invoke() } - .cancelListener { cancelListener.invoke() } - .build() + .title(context.resources.getString(R.string.qr_popup_restore_identity_title)) + .content(context.resources.getString(R.string.qr_popup_restore_identity_description)) + .positiveText(context.resources.getString(R.string.me_ok)) + .onPositive { dialog, which -> positiveCallback.invoke() } + .cancelListener { cancelListener.invoke() } + .build() - fun show(){ + fun show() { dialog.show() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ScanDemoTransactionDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ScanDemoTransactionDialog.kt index 707c46344..f21f816ab 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ScanDemoTransactionDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ScanDemoTransactionDialog.kt @@ -5,22 +5,24 @@ import com.afollestad.materialdialogs.MaterialDialog import io.forus.me.android.presentation.R -class ScanDemoTransactionDialog(private val context: Context, - private val positiveCallback: () -> Unit){ +class ScanDemoTransactionDialog( + private val context: Context, + private val positiveCallback: () -> Unit +) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title(context.resources.getString(R.string.voucher_send_email_success)) - .content(context.resources.getString(R.string.voucher_demo_transaction_operation_completed)) - .positiveText(context.resources.getString(R.string.me_ok)) - .onPositive { dialog, which -> positiveCallback.invoke() } - .cancelListener { dismiss() } - .build() + .title(context.resources.getString(R.string.voucher_send_email_success)) + .content(context.resources.getString(R.string.voucher_demo_transaction_operation_completed)) + .positiveText(context.resources.getString(R.string.me_ok)) + .onPositive { dialog, which -> positiveCallback.invoke() } + .cancelListener { dismiss() } + .build() - fun show(){ + fun show() { dialog.show() } - fun dismiss(){ + fun dismiss() { dialog.dismiss() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ScanVoucherBaseErrorDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ScanVoucherBaseErrorDialog.kt index d7ed0d9a1..d06095101 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ScanVoucherBaseErrorDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ScanVoucherBaseErrorDialog.kt @@ -20,7 +20,7 @@ class ScanVoucherBaseErrorDialog( //.positiveText(context.resources.getString(R.string.me_ok)) .dismissListener { dismissListener.invoke() } .negativeText(R.string.close) - .cancelListener { dismissListener.invoke() } + .cancelListener { dismissListener.invoke() } .build() init { @@ -44,7 +44,7 @@ class ScanVoucherBaseErrorDialog( } // Застосовуємо тінт колір - // setColorFilter(context.getColor(R.color.my_tint_color), PorterDuff.Mode.SRC_IN) + // setColorFilter(context.getColor(R.color.my_tint_color), PorterDuff.Mode.SRC_IN) } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ScanVoucherEmptyDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ScanVoucherEmptyDialog.kt index 396bed420..5fe4de856 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ScanVoucherEmptyDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/qr/dialogs/ScanVoucherEmptyDialog.kt @@ -6,21 +6,23 @@ import com.afollestad.materialdialogs.MaterialDialog import io.forus.me.android.presentation.R -class ScanVoucherEmptyDialog(private val context: Context, - private val dismissListener: () -> Unit){ +class ScanVoucherEmptyDialog( + private val context: Context, + private val dismissListener: () -> Unit +) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title(R.string.qr_popup_error) - .content(R.string.qr_voucher_empty) - //.icon(context.resources.getDrawable(R.drawable.ic_close)) - //.positiveText(context.resources.getString(R.string.me_ok)) - .dismissListener { dismissListener.invoke() } - .negativeText(R.string.close) - .cancelListener { dismissListener.invoke() } - .build() + .title(R.string.qr_popup_error) + .content(R.string.qr_voucher_empty) + //.icon(context.resources.getDrawable(R.drawable.ic_close)) + //.positiveText(context.resources.getString(R.string.me_ok)) + .dismissListener { dismissListener.invoke() } + .negativeText(R.string.close) + .cancelListener { dismissListener.invoke() } + .build() - fun show(){ - Log.d("DialogScan","ScanVoucherEmptyDialog") + fun show() { + Log.d("DialogScan", "ScanVoucherEmptyDialog") dialog.show() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesAdapter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesAdapter.kt index f0b7a97b3..23c62432b 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesAdapter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesAdapter.kt @@ -15,8 +15,11 @@ class RecordCategoriesAdapter : RecyclerView.Adapter() { DiffUtil.calculateDiff(object : DiffUtil.Callback() { override fun getOldListSize() = old.size override fun getNewListSize() = field.size - override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] - override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] }).dispatchUpdatesTo(this) notifyDataSetChanged() } @@ -28,7 +31,9 @@ class RecordCategoriesAdapter : RecyclerView.Adapter() { var clickListener: ((RecordCategory) -> Unit)? = null - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = RecordCategoriesVH(parent, clickListener) + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = + RecordCategoriesVH(parent, clickListener) + override fun onBindViewHolder(holder: RecordCategoriesVH, position: Int) { holder.render(items[position]) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesFragment.kt index 2b1b661f9..fdf354491 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesFragment.kt @@ -14,7 +14,9 @@ import io.forus.me.android.presentation.view.component.dividers.FDividerItemDeco import io.forus.me.android.presentation.view.fragment.ToolbarLRFragment -class RecordCategoriesFragment : ToolbarLRFragment(), RecordCategoriesView { +class RecordCategoriesFragment : + ToolbarLRFragment(), + RecordCategoriesView { companion object { fun newIntent(): RecordCategoriesFragment { @@ -42,8 +44,7 @@ class RecordCategoriesFragment : ToolbarLRFragment) { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesModel.kt index 382edd5a8..79cfae9f7 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesModel.kt @@ -3,5 +3,5 @@ package io.forus.me.android.presentation.view.screens.records.categories import io.forus.me.android.domain.models.records.RecordCategory data class RecordCategoriesModel( - val items: List = emptyList() - ) \ No newline at end of file + val items: List = emptyList() +) \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesPresenter.kt index 1583f2f4c..6c868c628 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesPresenter.kt @@ -8,14 +8,17 @@ import io.reactivex.Single import io.reactivex.android.schedulers.AndroidSchedulers -class RecordCategoriesPresenter constructor(val recordsRepository: RecordsRepository) : LRPresenter, RecordCategoriesModel, RecordCategoriesView>() { +class RecordCategoriesPresenter constructor(val recordsRepository: RecordsRepository) : + LRPresenter, RecordCategoriesModel, RecordCategoriesView>() { - override fun initialModelSingle(): Single> = Single.fromObservable( + override fun initialModelSingle(): Single> = + Single.fromObservable( recordsRepository.getCategoriesWithRecordCount() - ) + ) - override fun RecordCategoriesModel.changeInitialModel(i: List): RecordCategoriesModel = copy(items = i) + override fun RecordCategoriesModel.changeInitialModel(i: List): RecordCategoriesModel = + copy(items = i) override fun bindIntents() { @@ -23,22 +26,27 @@ class RecordCategoriesPresenter constructor(val recordsRepository: RecordsReposi val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - RecordCategoriesModel(), - false) + false, + null, + false, + false, + null, + false, + RecordCategoriesModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - RecordCategoriesView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + RecordCategoriesView::render + ) } - override fun stateReducer(viewState: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + viewState: LRViewState, + change: PartialChange + ): LRViewState { if (change !is RecordCategoriesPartialChanges) return super.stateReducer(viewState, change) @@ -52,13 +60,4 @@ class RecordCategoriesPresenter constructor(val recordsRepository: RecordsReposi } - - - - - - - - - } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesVH.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesVH.kt index 3bc90a2db..2f9efd378 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesVH.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/categories/RecordCategoriesVH.kt @@ -10,9 +10,12 @@ import io.forus.me.android.presentation.R import io.forus.me.android.presentation.helpers.inflate -class RecordCategoriesVH(parent: ViewGroup, private val clickListener: ((RecordCategory) -> Unit)?) : RecyclerView.ViewHolder(parent.inflate(R.layout.item_record_categories)) { +class RecordCategoriesVH( + parent: ViewGroup, + private val clickListener: ((RecordCategory) -> Unit)? +) : RecyclerView.ViewHolder(parent.inflate(R.layout.item_record_categories)) { - private var name: TextView? = null + private var name: TextView? = null private var selectedCheckBox: CheckBox? = null private var root: View? = null @@ -22,7 +25,7 @@ class RecordCategoriesVH(parent: ViewGroup, private val clickListener: ((RecordC root = itemView.findViewById(R.id.root) } - fun render(item: RecordCategory) = with(itemView) { + fun render(item: RecordCategory) = with(itemView) { name?.text = item.name diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/CreateRecordActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/CreateRecordActivity.kt index f9988a213..bc19fafcc 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/CreateRecordActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/CreateRecordActivity.kt @@ -27,7 +27,8 @@ import io.forus.me.android.presentation.view.screens.records.create_record.dialo import io.forus.me.android.presentation.view.screens.records.types.RecordTypesFragment -class CreateRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSelected, CreateRecordFragment.OnInputRecordNameText { +class CreateRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSelected, + CreateRecordFragment.OnInputRecordNameText { companion object { @@ -44,10 +45,11 @@ class CreateRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSele var recordNameText: String? = null - private var retrofitExceptionMapper: RetrofitExceptionMapper = Injection.instance.retrofitExceptionMapper + private var retrofitExceptionMapper: RetrofitExceptionMapper = + Injection.instance.retrofitExceptionMapper var waitDialog: WaitDialog? = null - + private lateinit var binding: ActivityCreateCategoryFlowBinding private lateinit var navController: NavController @@ -59,11 +61,11 @@ class CreateRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSele navController = findNavController(R.id.nav_host_fragment) val navOptions = NavOptions.Builder() - .setEnterAnim(R.anim.nav_default_enter_anim) - .setExitAnim(R.anim.nav_default_exit_anim) - .setPopEnterAnim(R.anim.nav_default_pop_enter_anim) - .setPopExitAnim(R.anim.nav_default_pop_exit_anim) - .build() + .setEnterAnim(R.anim.nav_default_enter_anim) + .setExitAnim(R.anim.nav_default_exit_anim) + .setPopEnterAnim(R.anim.nav_default_pop_enter_anim) + .setPopExitAnim(R.anim.nav_default_pop_exit_anim) + .build() statusNextButton(false) statusCurrentStep(step) @@ -72,7 +74,7 @@ class CreateRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSele if (step == 1) { val args = Bundle() if (recordType != null) { - // args.putString(RECORD_TYPE_KEY_EXTRA, recordType!!.key) + // args.putString(RECORD_TYPE_KEY_EXTRA, recordType!!.key) args.putString(RECORD_TYPE_NAME_EXTRA, recordType!!.name) args.putString(RECORD_INPUT_FIELD_TYPE_EXTRA, recordType!!.type) navController.navigate(R.id.createRecordFragment, args, navOptions) @@ -86,13 +88,19 @@ class CreateRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSele waitDialog = WaitDialog(this@CreateRecordActivity) waitDialog!!.show() val model = CreateRecordModel(Injection.instance.recordsRepository) - model.createRecord(NewRecordRequest(recordType, null, mutableListOf(), recordNameText!!), { createRecordResponse -> - if(waitDialog!=null)waitDialog!!.dismiss() - showSuccessDialog(recordType!!.name, recordNameText!!) - }, { error -> - if(waitDialog!=null)waitDialog!!.dismiss() - parseError(error) - }) + model.createRecord( + NewRecordRequest( + recordType, + null, + mutableListOf(), + recordNameText!! + ), { createRecordResponse -> + if (waitDialog != null) waitDialog!!.dismiss() + showSuccessDialog(recordType!!.name, recordNameText!!) + }, { error -> + if (waitDialog != null) waitDialog!!.dismiss() + parseError(error) + }) } } } @@ -107,8 +115,10 @@ class CreateRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSele } private fun showSuccessDialog(recordType: String, recordName: String) { - CreateRecordSuccessDialog.display(supportFragmentManager, recordType, - recordName) { finish() } + CreateRecordSuccessDialog.display( + supportFragmentManager, recordType, + recordName + ) { finish() } } private fun parseError(error: Throwable) { @@ -124,11 +134,11 @@ class CreateRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSele val detailsError = retrofitExceptionMapper.mapToDetailsApiError(error) - CreateRecordErrorDialog(this@CreateRecordActivity,detailsError.message,detailsError.errorsString, - MaterialDialog.SingleButtonCallback { _, _ -> - - } ).show() + CreateRecordErrorDialog( + this@CreateRecordActivity, detailsError.message, detailsError.errorsString, + MaterialDialog.SingleButtonCallback { _, _ -> + }).show() } catch (e: Exception) { @@ -167,20 +177,41 @@ class CreateRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSele private fun statusNextButton(isActive: Boolean) { binding.nextBt.isEnabled = isActive - binding.nextBt.background = if (isActive) ContextCompat.getDrawable(this@CreateRecordActivity, R.drawable.button_main_round_blue) - else ContextCompat.getDrawable(this@CreateRecordActivity, R.drawable.button_main_raund_reverse) - binding.nextBt.setTextColor(if (isActive) ContextCompat.getColor(this@CreateRecordActivity, R.color.colorAccent) - else ContextCompat.getColor(this@CreateRecordActivity, R.color.body_1_38)) + binding.nextBt.background = if (isActive) ContextCompat.getDrawable( + this@CreateRecordActivity, + R.drawable.button_main_round_blue + ) + else ContextCompat.getDrawable( + this@CreateRecordActivity, + R.drawable.button_main_raund_reverse + ) + binding.nextBt.setTextColor( + if (isActive) ContextCompat.getColor(this@CreateRecordActivity, R.color.colorAccent) + else ContextCompat.getColor(this@CreateRecordActivity, R.color.body_1_38) + ) } private fun statusCurrentStep(step: Int) { - binding.step1View.background = if (step == 1) ContextCompat.getDrawable(this@CreateRecordActivity, R.drawable.button_main_raund) - else ContextCompat.getDrawable(this@CreateRecordActivity, R.drawable.button_main_raund_reverse) - binding.step2View.background = if (step == 2) ContextCompat.getDrawable(this@CreateRecordActivity, R.drawable.button_main_raund) - else ContextCompat.getDrawable(this@CreateRecordActivity, R.drawable.button_main_raund_reverse) - - binding.nextBt.text = if (step == 1) getString(R.string.next_step) else getString(R.string.submit) + binding.step1View.background = if (step == 1) ContextCompat.getDrawable( + this@CreateRecordActivity, + R.drawable.button_main_raund + ) + else ContextCompat.getDrawable( + this@CreateRecordActivity, + R.drawable.button_main_raund_reverse + ) + binding.step2View.background = if (step == 2) ContextCompat.getDrawable( + this@CreateRecordActivity, + R.drawable.button_main_raund + ) + else ContextCompat.getDrawable( + this@CreateRecordActivity, + R.drawable.button_main_raund_reverse + ) + + binding.nextBt.text = + if (step == 1) getString(R.string.next_step) else getString(R.string.submit) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/EditRecordActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/EditRecordActivity.kt index ae11ea82d..96833bb1a 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/EditRecordActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/EditRecordActivity.kt @@ -29,7 +29,8 @@ import io.forus.me.android.presentation.view.screens.records.create_record.dialo import io.forus.me.android.presentation.view.screens.records.types.RecordTypesFragment -class EditRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSelected, CreateRecordFragment.OnInputRecordNameText { +class EditRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSelected, + CreateRecordFragment.OnInputRecordNameText { companion object { @@ -39,7 +40,12 @@ class EditRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSelect val RECORD_TYPE = "RECORD_TYPE" val RECORD_VALUE = "RECORD_VALUE" - fun getCallingIntent(context: Context, recordId: Long,recordType: String, recordValue: String): Intent { + fun getCallingIntent( + context: Context, + recordId: Long, + recordType: String, + recordValue: String + ): Intent { val intent = Intent(context, EditRecordActivity::class.java) intent.putExtra(RECORD_ID, recordId) @@ -59,7 +65,8 @@ class EditRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSelect var recordNameText: String? = null - private var retrofitExceptionMapper: RetrofitExceptionMapper = Injection.instance.retrofitExceptionMapper + private var retrofitExceptionMapper: RetrofitExceptionMapper = + Injection.instance.retrofitExceptionMapper private lateinit var binding: ActivityCreateCategoryFlowBinding private lateinit var navController: NavController @@ -70,20 +77,20 @@ class EditRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSelect setContentView(binding.root) val navOptions = NavOptions.Builder() - .setEnterAnim(R.anim.nav_default_enter_anim) - .setExitAnim(R.anim.nav_default_exit_anim) - .setPopEnterAnim(R.anim.nav_default_pop_enter_anim) - .setPopExitAnim(R.anim.nav_default_pop_exit_anim) - .build() + .setEnterAnim(R.anim.nav_default_enter_anim) + .setExitAnim(R.anim.nav_default_exit_anim) + .setPopEnterAnim(R.anim.nav_default_pop_enter_anim) + .setPopExitAnim(R.anim.nav_default_pop_exit_anim) + .build() if (savedInstanceState == null) { - recordId = intent.getLongExtra(RECORD_ID,-1) - recordName = intent.getStringExtra(RECORD_TYPE)?:"" - recordValue = intent.getStringExtra(RECORD_VALUE)?:"" + recordId = intent.getLongExtra(RECORD_ID, -1) + recordName = intent.getStringExtra(RECORD_TYPE) ?: "" + recordValue = intent.getStringExtra(RECORD_VALUE) ?: "" } - navController = findNavController(R.id.nav_host_fragment) + navController = findNavController(R.id.nav_host_fragment) val bundle = Bundle() bundle.putInt("showList", 0) @@ -101,19 +108,25 @@ class EditRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSelect waitDialog!!.show() if (recordNameText != null) { val model = CreateRecordModel(Injection.instance.recordsRepository) - model.createRecord(NewRecordRequest(recordType, null, mutableListOf(), recordNameText!!), { createRecordResponse -> - if(recordId != null) { - model.deleteRecord(recordId!!, { - showSuccessDialog(recordType!!.name, recordNameText!!) - }, { error -> - if(waitDialog!=null)waitDialog!!.dismiss() - parseError(error) - }) - } - }, { error -> - if(waitDialog!=null)waitDialog!!.dismiss() - parseError(error) - }) + model.createRecord( + NewRecordRequest( + recordType, + null, + mutableListOf(), + recordNameText!! + ), { createRecordResponse -> + if (recordId != null) { + model.deleteRecord(recordId!!, { + showSuccessDialog(recordType!!.name, recordNameText!!) + }, { error -> + if (waitDialog != null) waitDialog!!.dismiss() + parseError(error) + }) + } + }, { error -> + if (waitDialog != null) waitDialog!!.dismiss() + parseError(error) + }) } } @@ -125,11 +138,11 @@ class EditRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSelect } - - private fun showSuccessDialog(recordType: String, recordName: String) { - CreateRecordSuccessDialog.display(supportFragmentManager, recordType, - recordName) { finish() } + CreateRecordSuccessDialog.display( + supportFragmentManager, recordType, + recordName + ) { finish() } } private fun parseError(error: Throwable) { @@ -144,10 +157,11 @@ class EditRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSelect val detailsError = retrofitExceptionMapper.mapToDetailsApiError(error) - CreateRecordErrorDialog(this@EditRecordActivity, detailsError.message, detailsError.errorsString, - MaterialDialog.SingleButtonCallback { _, _ -> + CreateRecordErrorDialog( + this@EditRecordActivity, detailsError.message, detailsError.errorsString, + MaterialDialog.SingleButtonCallback { _, _ -> - }).show() + }).show() } catch (e: Exception) { @@ -192,7 +206,7 @@ class EditRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSelect override fun onTextInput(text: String) { - Log.d("forus","onTextInput = $text") + Log.d("forus", "onTextInput = $text") recordNameText = text if (recordNameText!!.isNotEmpty() && recordNameText!!.length > 0) { statusNextButton(true) @@ -203,23 +217,43 @@ class EditRecordActivity : AppCompatActivity(), RecordTypesFragment.OnItemSelect private fun statusNextButton(isActive: Boolean) { binding.nextBt.isEnabled = isActive - binding.nextBt.background = if (isActive) ContextCompat.getDrawable(this@EditRecordActivity, R.drawable.button_main_round_blue) - else ContextCompat.getDrawable(this@EditRecordActivity, R.drawable.button_main_raund_reverse) - binding.nextBt.setTextColor(if (isActive) ContextCompat.getColor(this@EditRecordActivity, R.color.colorAccent) - else ContextCompat.getColor(this@EditRecordActivity, R.color.body_1_38)) + binding.nextBt.background = if (isActive) ContextCompat.getDrawable( + this@EditRecordActivity, + R.drawable.button_main_round_blue + ) + else ContextCompat.getDrawable( + this@EditRecordActivity, + R.drawable.button_main_raund_reverse + ) + binding.nextBt.setTextColor( + if (isActive) ContextCompat.getColor(this@EditRecordActivity, R.color.colorAccent) + else ContextCompat.getColor(this@EditRecordActivity, R.color.body_1_38) + ) } private fun statusCurrentStep(step: Int) { - binding.step1View.background = if (step == 1) ContextCompat.getDrawable(this@EditRecordActivity, R.drawable.button_main_raund) - else ContextCompat.getDrawable(this@EditRecordActivity, R.drawable.button_main_raund_reverse) - binding.step2View.background = if (step == 2) ContextCompat.getDrawable(this@EditRecordActivity, R.drawable.button_main_raund) - else ContextCompat.getDrawable(this@EditRecordActivity, R.drawable.button_main_raund_reverse) - - binding.nextBt.text = if (step == 1) getString(R.string.next_step) else getString(R.string.submit) + binding.step1View.background = if (step == 1) ContextCompat.getDrawable( + this@EditRecordActivity, + R.drawable.button_main_raund + ) + else ContextCompat.getDrawable( + this@EditRecordActivity, + R.drawable.button_main_raund_reverse + ) + binding.step2View.background = if (step == 2) ContextCompat.getDrawable( + this@EditRecordActivity, + R.drawable.button_main_raund + ) + else ContextCompat.getDrawable( + this@EditRecordActivity, + R.drawable.button_main_raund_reverse + ) + + binding.nextBt.text = + if (step == 1) getString(R.string.next_step) else getString(R.string.submit) } - } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/FFragmentNavigator.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/FFragmentNavigator.kt index dd667ecfd..7a7f27553 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/FFragmentNavigator.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/FFragmentNavigator.kt @@ -35,7 +35,7 @@ class FFragmentNavigator( val shouldSkip = navOptions?.run { getPopUpTo() == destination.id && !isPopUpToInclusive() - } ?: false + } ?: false return if (shouldSkip) null else super.navigate(destination, args, navOptions, navigatorExtras) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/create_record_fragment/CreateRecordFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/create_record_fragment/CreateRecordFragment.kt index 45f46c1cd..bfc7fc514 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/create_record_fragment/CreateRecordFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/create_record_fragment/CreateRecordFragment.kt @@ -26,7 +26,11 @@ class CreateRecordFragment : Fragment() { val RECORD_TYPE_VALUE_EXTRA = "RECORD_TYPE_VALUE_EXTRA" val RECORD_INPUT_FIELD_TYPE_EXTRA = "RECORD_INPUT_FIELD_TYPE_EXTRA" - fun newIntent( recordTypeName: String, recordValue: String, recordTypeType: String): RecordDetailsFragment = RecordDetailsFragment().also { + fun newIntent( + recordTypeName: String, + recordValue: String, + recordTypeType: String + ): RecordDetailsFragment = RecordDetailsFragment().also { val bundle = Bundle() bundle.putSerializable(RECORD_TYPE_NAME_EXTRA, recordTypeName) @@ -40,11 +44,13 @@ class CreateRecordFragment : Fragment() { private var recordTypeName: String = "" private var recordValue: String = "" private var recordInputFieldType: String = "" - + private lateinit var binding: FragmentCreateRecordBinding - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle?): View? { + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { // Inflate the layout for this fragment val bundle = this.arguments @@ -56,7 +62,7 @@ class CreateRecordFragment : Fragment() { } Log.d("forus", "name = $recordTypeName") - + binding = FragmentCreateRecordBinding.inflate(inflater) return binding.root @@ -74,8 +80,8 @@ class CreateRecordFragment : Fragment() { binding.recordGroupNameTV.text = recordTypeName binding.recordNameEditText.setText(recordValue) - if(inputTextListener!=null){ - if(recordValue.isNotEmpty()){ + if (inputTextListener != null) { + if (recordValue.isNotEmpty()) { inputTextListener!!.onTextInput(recordValue) } } @@ -86,10 +92,12 @@ class CreateRecordFragment : Fragment() { binding.recordNameEditText.inputType = InputType.TYPE_CLASS_TEXT //binding.recordNameEditText.imeOptions = EditorInfo.IME_ACTION_DONE } + "text" -> { binding.recordNameEditText.maxLines = 1000 binding.recordNameEditText.inputType = InputType.TYPE_CLASS_TEXT } + "number" -> { binding.recordNameEditText.maxLines = 1 binding.recordNameEditText.inputType = InputType.TYPE_CLASS_NUMBER diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/create_record_fragment/CreateRecordModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/create_record_fragment/CreateRecordModel.kt index dded6b166..1e83984a7 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/create_record_fragment/CreateRecordModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/create_record_fragment/CreateRecordModel.kt @@ -13,38 +13,44 @@ import io.reactivex.schedulers.Schedulers class CreateRecordModel(private val recordRepository: RecordsRepository) { - fun createRecord(request: NewRecordRequest, success: (CreateRecordResponse) -> Unit, error: (Throwable) -> Unit) { - Single.fromObservable(recordRepository.newRecord(request!!) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .switchMap { createRecordResponse -> - success(createRecordResponse) - Observable.just(NewRecordPartialChanges.CreateRecordEnd(createRecordResponse)) - } - .onErrorReturn { - error(it) - NewRecordPartialChanges.CreateRecordError(it) - }) - .subscribe() + fun createRecord( + request: NewRecordRequest, + success: (CreateRecordResponse) -> Unit, + error: (Throwable) -> Unit + ) { + Single.fromObservable( + recordRepository.newRecord(request!!) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .switchMap { createRecordResponse -> + success(createRecordResponse) + Observable.just(NewRecordPartialChanges.CreateRecordEnd(createRecordResponse)) + } + .onErrorReturn { + error(it) + NewRecordPartialChanges.CreateRecordError(it) + }) + .subscribe() } fun getRecordTypes(success: (CreateRecordResponse) -> Unit, error: (Throwable) -> Unit) { Single.fromObservable(recordRepository.getRecordTypes()) - .subscribe() + .subscribe() } fun deleteRecord(id: Long, success: (Boolean) -> Unit, error: (Throwable) -> Unit) { - Single.fromObservable(recordRepository.deleteRecord(id) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .switchMap { - success(it) - Observable.just(true) - } - .onErrorReturn { - error(it) - false - }).subscribe() + Single.fromObservable( + recordRepository.deleteRecord(id) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .switchMap { + success(it) + Observable.just(true) + } + .onErrorReturn { + error(it) + false + }).subscribe() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/dialog/CreateRecordErrorDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/dialog/CreateRecordErrorDialog.kt index 4b71ab1b9..ae6d40efb 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/dialog/CreateRecordErrorDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/dialog/CreateRecordErrorDialog.kt @@ -5,25 +5,30 @@ import com.afollestad.materialdialogs.MaterialDialog import io.forus.me.android.presentation.R -class CreateRecordErrorDialog(private val context: Context,private val title: String,private val message: String, callback: MaterialDialog.SingleButtonCallback){ +class CreateRecordErrorDialog( + private val context: Context, + private val title: String, + private val message: String, + callback: MaterialDialog.SingleButtonCallback +) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title(title) - .customView(R.layout.view_about_me, false) - .positiveText(context.resources.getString(R.string.me_ok)) - .onPositive(callback) - .build() - + .title(title) + .customView(R.layout.view_about_me, false) + .positiveText(context.resources.getString(R.string.me_ok)) + .onPositive(callback) + .build() init { val view = dialog.customView - val messageTV = view?.findViewById(R.id.message); + val messageTV = + view?.findViewById(R.id.message); messageTV?.setText(message); } - fun show(){ + fun show() { dialog.show() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/dialog/CreateRecordSuccessDialog.java b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/dialog/CreateRecordSuccessDialog.java index f38184370..d5314213d 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/dialog/CreateRecordSuccessDialog.java +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/dialog/CreateRecordSuccessDialog.java @@ -19,14 +19,10 @@ public class CreateRecordSuccessDialog extends DialogFragment { View rootView; - + String positiveButtonText = "OK"; + SubmitClickListener submitClickListener; private String recordType = ""; private String recordName = ""; - String positiveButtonText= "OK"; - - SubmitClickListener submitClickListener; - - public static CreateRecordSuccessDialog display(FragmentManager fragmentManager, String recordType, String recordNameTV, SubmitClickListener submitClickListener) { CreateRecordSuccessDialog fullscreenDialog = new CreateRecordSuccessDialog(); diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/dialog/WaitDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/dialog/WaitDialog.kt index 33c258240..cb18b53ee 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/dialog/WaitDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/create_record/dialog/WaitDialog.kt @@ -8,10 +8,9 @@ import android.view.WindowManager import android.widget.LinearLayout import io.forus.me.android.presentation.R -class WaitDialog(private val context: Activity){ - - var dialog: AlertDialog +class WaitDialog(private val context: Activity) { + var dialog: AlertDialog init { @@ -26,7 +25,7 @@ class WaitDialog(private val context: Activity){ } } - fun show(){ + fun show() { dialog.show() val window = dialog.window if (window != null) { @@ -38,8 +37,8 @@ class WaitDialog(private val context: Activity){ } } - fun dismiss(){ - if(dialog.isShowing){ + fun dismiss() { + if (dialog.isShowing) { dialog.dismiss() } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/dialogs/validators_list_dialog/ValidatorsAdapter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/dialogs/validators_list_dialog/ValidatorsAdapter.kt index 538687c66..be90483b0 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/dialogs/validators_list_dialog/ValidatorsAdapter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/dialogs/validators_list_dialog/ValidatorsAdapter.kt @@ -7,16 +7,27 @@ import androidx.recyclerview.widget.RecyclerView import io.forus.me.android.presentation.R -class ValidatorsAdapter(var items: List, val callback: Callback) : RecyclerView.Adapter() { - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = MainHolder(LayoutInflater.from(parent.context).inflate(R.layout.row_validator, parent, false)) +class ValidatorsAdapter( + var items: List, + val callback: Callback +) : RecyclerView.Adapter() { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = MainHolder( + LayoutInflater.from(parent.context).inflate(R.layout.row_validator, parent, false) + ) + override fun getItemCount() = items.size override fun onBindViewHolder(holder: MainHolder, position: Int) { holder.bind(items[position]) } inner class MainHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { - private val iv_organization_icon = itemView.findViewById(R.id.iv_organization_icon) - private val tv_organization_name = itemView.findViewById(R.id.tv_organization_name) + private val iv_organization_icon = + itemView.findViewById( + R.id.iv_organization_icon + ) + private val tv_organization_name = + itemView.findViewById(R.id.tv_organization_name) + fun bind(item: io.forus.me.android.domain.models.records.ValidatorOrganization) { tv_organization_name.text = item.name itemView.setOnClickListener { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/dialogs/validators_list_dialog/ValidatorsListDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/dialogs/validators_list_dialog/ValidatorsListDialog.kt index 04f6aae56..9e34794fa 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/dialogs/validators_list_dialog/ValidatorsListDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/dialogs/validators_list_dialog/ValidatorsListDialog.kt @@ -13,13 +13,15 @@ import com.afollestad.materialdialogs.MaterialDialog import io.forus.me.android.presentation.R -class ValidatorsListDialog(private val context: Context, - private val organizations: List, - private val selectItemCallback: (io.forus.me.android.domain.models.records.ValidatorOrganization) -> Unit) { +class ValidatorsListDialog( + private val context: Context, + private val organizations: List, + private val selectItemCallback: (io.forus.me.android.domain.models.records.ValidatorOrganization) -> Unit +) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .customView(R.layout.view_validators_list, true) - .build() + .customView(R.layout.view_validators_list, true) + .build() init { @@ -42,7 +44,12 @@ class ValidatorsListDialog(private val context: Context, context, LinearLayoutManager.VERTICAL ) - dividerItemDecoration.setDrawable(ContextCompat.getDrawable(context,R.drawable.shape_divider)!!) + dividerItemDecoration.setDrawable( + ContextCompat.getDrawable( + context, + R.drawable.shape_divider + )!! + ) recycler.addItemDecoration(dividerItemDecoration) recycler.adapter = mAdapter diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/RecordDetailsActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/RecordDetailsActivity.kt index ab900bce5..e0b136978 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/RecordDetailsActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/RecordDetailsActivity.kt @@ -36,14 +36,15 @@ class RecordDetailsActivity : CommonActivity() { } - fun showPopupQRFragment(recordId: Long){ + fun showPopupQRFragment(recordId: Long) { val meBottomSheet = MeBottomSheetDialogFragment.newInstance( - RecordQRFragment.newIntent(recordId), "QR code") + RecordQRFragment.newIntent(recordId), "QR code" + ) meBottomSheet.show(supportFragmentManager, meBottomSheet.tag) } - fun closeQRFragment(){ + fun closeQRFragment() { fragment.updateModel() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/RecordDetailsModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/RecordDetailsModel.kt index 716c4c3d4..798185662 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/RecordDetailsModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/RecordDetailsModel.kt @@ -4,14 +4,13 @@ import io.forus.me.android.domain.models.records.Record import io.forus.me.android.presentation.view.screens.records.item.validations.ValidationViewModel data class RecordDetailsModel( - val item: Record? = null, - val validations: List = emptyList(), - val requestValidationError: Throwable? = null, - val recordDeleteSuccess: Boolean? = false, - val recordDeleteError: Throwable? = null -) -{ - fun changeStatus(validatorId: Long) : RecordDetailsModel { + val item: Record? = null, + val validations: List = emptyList(), + val requestValidationError: Throwable? = null, + val recordDeleteSuccess: Boolean? = false, + val recordDeleteError: Throwable? = null +) { + fun changeStatus(validatorId: Long): RecordDetailsModel { return copy() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/RecordDetailsPartialChanges.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/RecordDetailsPartialChanges.kt index 4677b85b2..905187dc2 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/RecordDetailsPartialChanges.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/RecordDetailsPartialChanges.kt @@ -4,14 +4,14 @@ import io.forus.me.android.presentation.view.base.lr.PartialChange sealed class RecordDetailsPartialChanges : PartialChange { - data class RequestValidationStart(val validatorId: Long): RecordDetailsPartialChanges() + data class RequestValidationStart(val validatorId: Long) : RecordDetailsPartialChanges() - data class RequestValidationEnd(val validatorId: Long): RecordDetailsPartialChanges() + data class RequestValidationEnd(val validatorId: Long) : RecordDetailsPartialChanges() - data class RequestValidationError(val error: Throwable): RecordDetailsPartialChanges() + data class RequestValidationError(val error: Throwable) : RecordDetailsPartialChanges() - data class DeleteRecordSuccess(val success: Boolean): RecordDetailsPartialChanges() + data class DeleteRecordSuccess(val success: Boolean) : RecordDetailsPartialChanges() - data class DeleteRecordError(val error: Throwable): RecordDetailsPartialChanges() + data class DeleteRecordError(val error: Throwable) : RecordDetailsPartialChanges() } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/RecordDetailsPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/RecordDetailsPresenter.kt index 153942e5b..8a9d62b22 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/RecordDetailsPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/RecordDetailsPresenter.kt @@ -13,89 +13,124 @@ import io.reactivex.Single import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers -class RecordDetailsPresenter constructor(private val context: Context, private val recordId: Long, private val recordsRepository: RecordsRepository, private val validatorsRepository: ValidatorsRepository) : LRPresenter() { +class RecordDetailsPresenter constructor( + private val context: Context, + private val recordId: Long, + private val recordsRepository: RecordsRepository, + private val validatorsRepository: ValidatorsRepository +) : LRPresenter() { override fun initialModelSingle(): Single = Single.fromObservable( - recordsRepository.getRecord(recordId).map { + recordsRepository.getRecord(recordId).map { - val allValidations = mutableListOf() - if (it.validations.isNotEmpty()) { - allValidations.add(ValidationViewModel(context.getString(R.string.validations))) - allValidations.addAll(it.validations.map { ValidationViewModel(it) }) + val allValidations = mutableListOf() + if (it.validations.isNotEmpty()) { + allValidations.add(ValidationViewModel(context.getString(R.string.validations))) + allValidations.addAll(it.validations.map { ValidationViewModel(it) }) - } + } - if (allValidations.isEmpty()) allValidations.add(ValidationViewModel(context.getString(R.string.validations_empty))) + if (allValidations.isEmpty()) allValidations.add(ValidationViewModel(context.getString(R.string.validations_empty))) - RecordDetailsModel(item = it, validations = allValidations) - } + RecordDetailsModel(item = it, validations = allValidations) + } ) - override fun RecordDetailsModel.changeInitialModel(i: RecordDetailsModel): RecordDetailsModel = copy(item = i.item, validations = i.validations, requestValidationError = null) + override fun RecordDetailsModel.changeInitialModel(i: RecordDetailsModel): RecordDetailsModel = + copy(item = i.item, validations = i.validations, requestValidationError = null) override fun bindIntents() { val observable = Observable.merge( - loadRefreshPartialChanges(), - - intent { it.requestValidation() } - .switchMap { validatorId -> - validatorsRepository.requestValidation(recordId, validatorId) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - RecordDetailsPartialChanges.RequestValidationEnd(validatorId) - } - .onErrorReturn { - RecordDetailsPartialChanges.RequestValidationError(it) - } - .startWith(RecordDetailsPartialChanges.RequestValidationStart(validatorId)) - }, - - intent(RecordDetailsView::deleteRecord).switchMap { - recordsRepository.deleteRecord(it) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - RecordDetailsPartialChanges.DeleteRecordSuccess(it) - } - .onErrorReturn { - RecordDetailsPartialChanges.DeleteRecordError(it) - } - } + loadRefreshPartialChanges(), + + intent { it.requestValidation() } + .switchMap { validatorId -> + validatorsRepository.requestValidation(recordId, validatorId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + RecordDetailsPartialChanges.RequestValidationEnd(validatorId) + } + .onErrorReturn { + RecordDetailsPartialChanges.RequestValidationError(it) + } + .startWith(RecordDetailsPartialChanges.RequestValidationStart(validatorId)) + }, + + intent(RecordDetailsView::deleteRecord).switchMap { + recordsRepository.deleteRecord(it) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + RecordDetailsPartialChanges.DeleteRecordSuccess(it) + } + .onErrorReturn { + RecordDetailsPartialChanges.DeleteRecordError(it) + } + } ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - RecordDetailsModel(), - false) + false, + null, + false, + false, + null, + false, + RecordDetailsModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - RecordDetailsView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + RecordDetailsView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { if (change !is RecordDetailsPartialChanges) return super.stateReducer(vs, change) return when (change) { - is RecordDetailsPartialChanges.RequestValidationStart -> vs.copy(model = vs.model.copy(requestValidationError = null)) - is RecordDetailsPartialChanges.RequestValidationEnd -> vs.copy(model = vs.model.changeStatus(change.validatorId)) - is RecordDetailsPartialChanges.RequestValidationError -> vs.copy(model = vs.model.copy(requestValidationError = change.error)) - is RecordDetailsPartialChanges.DeleteRecordSuccess -> vs.copy(model = vs.model.copy(recordDeleteSuccess = change.success)) - is RecordDetailsPartialChanges.DeleteRecordError -> vs.copy(model = vs.model.copy(recordDeleteError = change.error)) + is RecordDetailsPartialChanges.RequestValidationStart -> vs.copy( + model = vs.model.copy( + requestValidationError = null + ) + ) + + is RecordDetailsPartialChanges.RequestValidationEnd -> vs.copy( + model = vs.model.changeStatus( + change.validatorId + ) + ) + + is RecordDetailsPartialChanges.RequestValidationError -> vs.copy( + model = vs.model.copy( + requestValidationError = change.error + ) + ) + + is RecordDetailsPartialChanges.DeleteRecordSuccess -> vs.copy( + model = vs.model.copy( + recordDeleteSuccess = change.success + ) + ) + + is RecordDetailsPartialChanges.DeleteRecordError -> vs.copy( + model = vs.model.copy( + recordDeleteError = change.error + ) + ) } } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/dialogs/DeleteRecordErrorDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/dialogs/DeleteRecordErrorDialog.kt index 028c5b057..7f036076b 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/dialogs/DeleteRecordErrorDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/dialogs/DeleteRecordErrorDialog.kt @@ -5,20 +5,20 @@ import com.afollestad.materialdialogs.MaterialDialog import io.forus.me.android.presentation.R -class DeleteRecordErrorDialog(private val message: String, private val context: Context){ +class DeleteRecordErrorDialog(private val message: String, private val context: Context) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title(R.string.qr_popup_error) - .content(message) - .positiveText(context.resources.getString(R.string.me_ok)) - .dismissListener { dismiss()} - .build() + .title(R.string.qr_popup_error) + .content(message) + .positiveText(context.resources.getString(R.string.me_ok)) + .dismissListener { dismiss() } + .build() - fun show(){ + fun show() { dialog.show() } - fun dismiss(){ + fun dismiss() { dialog.dismiss() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/dialogs/RecordModifyDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/dialogs/RecordModifyDialog.kt index f4d0cfcd4..48fefe5de 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/dialogs/RecordModifyDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/dialogs/RecordModifyDialog.kt @@ -8,7 +8,11 @@ import android.widget.TextView import io.forus.me.android.presentation.R -class RecordModifyDialog(private val context: Activity, val action: Action, private val edit: () -> Unit) { +class RecordModifyDialog( + private val context: Activity, + val action: Action, + private val edit: () -> Unit +) { private var dialog: AlertDialog @@ -21,7 +25,7 @@ class RecordModifyDialog(private val context: Activity, val action: Action, pri val cancel_bt = dialogView.findViewById(R.id.cancel_bt) cancel_bt.setOnClickListener { dismiss() } val ok_bt = dialogView.findViewById(R.id.ok_bt) - ok_bt.setOnClickListener{ + ok_bt.setOnClickListener { edit.invoke() dismiss() } @@ -31,8 +35,8 @@ class RecordModifyDialog(private val context: Activity, val action: Action, pri Action.DELETE -> context.getString(R.string.dialog_button_archive) } - val description = dialogView.findViewById(R.id.description) - description.text = when (action) { + val description = dialogView.findViewById(R.id.description) + description.text = when (action) { Action.EDIT -> context.getString(R.string.dialog_record_edit_description) Action.DELETE -> context.getString(R.string.dialog_record_archive_description) } @@ -54,7 +58,6 @@ class RecordModifyDialog(private val context: Activity, val action: Action, pri } - public enum class Action { EDIT, DELETE } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/qr/RecordQRFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/qr/RecordQRFragment.kt index 8006932f8..5908482ef 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/qr/RecordQRFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/qr/RecordQRFragment.kt @@ -16,7 +16,8 @@ import io.forus.me.android.presentation.view.base.lr.LoadRefreshPanel import io.forus.me.android.presentation.view.screens.records.item.RecordDetailsActivity import io.reactivex.Observable -class RecordQRFragment : LRFragment(), RecordQRView { +class RecordQRFragment : LRFragment(), + RecordQRView { companion object { private val RECORD_ID_EXTRA = "RECORD_ID_EXTRA" @@ -30,9 +31,9 @@ class RecordQRFragment : LRFragment() { +class RecordQRPresenter constructor( + private val recordId: Long, + private val disposableHolder: DisposableHolder, + private val recordsRepository: RecordsRepository +) : LRPresenter() { - override fun initialModelSingle(): Single = Single.fromObservable(recordsRepository.getRecordUuid(recordId)) + override fun initialModelSingle(): Single = + Single.fromObservable(recordsRepository.getRecordUuid(recordId)) override fun RecordQRModel.changeInitialModel(i: String): RecordQRModel = copy(uuid = i).also { - disposableHolder.add(recordsRepository.readValidation(i) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .retryWhen{throwables -> throwables.delay(1000, TimeUnit.MILLISECONDS)} - .repeatWhen{observable -> observable.delay(1000, TimeUnit.MILLISECONDS)} - .takeUntil{it.state != Validation.State.pending} - .subscribe { - if(it.state != Validation.State.pending) validationComplete.onNext(it.state) - }) + disposableHolder.add( + recordsRepository.readValidation(i) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .retryWhen { throwables -> throwables.delay(1000, TimeUnit.MILLISECONDS) } + .repeatWhen { observable -> observable.delay(1000, TimeUnit.MILLISECONDS) } + .takeUntil { it.state != Validation.State.pending } + .subscribe { + if (it.state != Validation.State.pending) validationComplete.onNext(it.state) + }) } private val validationComplete = PublishSubject.create() @@ -36,33 +42,41 @@ class RecordQRPresenter constructor(private val recordId: Long, private val disp val observable = Observable.merge( - loadRefreshPartialChanges(), + loadRefreshPartialChanges(), - intent { validationComplete() }.map { RecordQRPartialChanges.RecordValidated(it) } + intent { validationComplete() }.map { RecordQRPartialChanges.RecordValidated(it) } ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - RecordQRModel(), - false) + false, + null, + false, + false, + null, + false, + RecordQRModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - RecordQRView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + RecordQRView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { if (change !is RecordQRPartialChanges) return super.stateReducer(vs, change) return when (change) { - is RecordQRPartialChanges.RecordValidated -> vs.copy(closeScreen = true, model = vs.model.copy(recordValidatedState = change.state)) + is RecordQRPartialChanges.RecordValidated -> vs.copy( + closeScreen = true, + model = vs.model.copy(recordValidatedState = change.state) + ) } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/validations/ValidationAdapter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/validations/ValidationAdapter.kt index aacf36233..9bfec4823 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/validations/ValidationAdapter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/validations/ValidationAdapter.kt @@ -55,15 +55,15 @@ class ValidationAdapter(private val clickListener: ((ValidationViewModel) -> Uni LayoutInflater.from(parent.context), parent, false ) ValidationVH(binding) - } } + } override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { if (holder is ValidationVH) { val item = items[position] - holder.bind(item){ item: ValidationViewModel -> - clickListener?.invoke(item) + holder.bind(item) { item: ValidationViewModel -> + clickListener?.invoke(item) } } else if (holder is ValidationHeaderVH) { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/validations/ValidationViewModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/validations/ValidationViewModel.kt index 769625a93..e92ff7aef 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/validations/ValidationViewModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/validations/ValidationViewModel.kt @@ -1,6 +1,6 @@ package io.forus.me.android.presentation.view.screens.records.item.validations -class ValidationViewModel{ +class ValidationViewModel { enum class Type { header, validator @@ -16,20 +16,17 @@ class ValidationViewModel{ var title: String? = null - - - constructor(sectionName: String){ + constructor(sectionName: String) { this.type = Type.header this.sectionName = sectionName } - - constructor(simpleValidation: io.forus.me.android.domain.models.records.Validation){ + constructor(simpleValidation: io.forus.me.android.domain.models.records.Validation) { this.type = Type.validator - if(simpleValidation.organization != null) { + if (simpleValidation.organization != null) { this.name = simpleValidation.organization!!.name!! - }else{ + } else { this.name = simpleValidation.identityAddress } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/validators/ValidatorHeaderVH.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/validators/ValidatorHeaderVH.kt index 6c3bb4ed7..ff797a09a 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/validators/ValidatorHeaderVH.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/validators/ValidatorHeaderVH.kt @@ -5,7 +5,8 @@ import androidx.recyclerview.widget.RecyclerView import io.forus.me.android.presentation.R import io.forus.me.android.presentation.helpers.inflate -class ValidatorHeaderVH(parent: ViewGroup) : RecyclerView.ViewHolder(parent.inflate(R.layout.item_validator_list_header)) { +class ValidatorHeaderVH(parent: ViewGroup) : + RecyclerView.ViewHolder(parent.inflate(R.layout.item_validator_list_header)) { var tv_header: io.forus.me.android.presentation.view.component.text.TextView? = null diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/validators/ValidatorViewModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/validators/ValidatorViewModel.kt index 2179bd299..264f3a9a3 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/validators/ValidatorViewModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/item/validators/ValidatorViewModel.kt @@ -2,7 +2,7 @@ package io.forus.me.android.presentation.view.screens.records.item.validators import io.forus.me.android.domain.models.validators.SimpleValidator -class ValidatorViewModel{ +class ValidatorViewModel { enum class Type { header, validator, p2p @@ -27,12 +27,18 @@ class ValidatorViewModel{ var status: Status = Status.none - constructor(sectionName: String){ + constructor(sectionName: String) { this.type = Type.header this.sectionName = sectionName } - constructor(id: Long, name: String, title: String, imageUrl: String, status: Status = Status.approved) { + constructor( + id: Long, + name: String, + title: String, + imageUrl: String, + status: Status = Status.approved + ) { this.type = Type.p2p this.id = id this.name = name @@ -41,7 +47,7 @@ class ValidatorViewModel{ this.status = status } - constructor(simpleValidator: SimpleValidator){ + constructor(simpleValidator: SimpleValidator) { this.type = Type.validator this.id = simpleValidator.id this.name = simpleValidator.name diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsActivity.kt index 1804f7edb..fe576949a 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsActivity.kt @@ -17,7 +17,7 @@ class RecordsActivity : CommonActivity() { fun getCallingIntent(context: Context, recordCategory: RecordCategory?): Intent { val intent = Intent(context, RecordsActivity::class.java) - if(recordCategory!=null) { + if (recordCategory != null) { intent.putExtra(CATEGORY_ID_EXTRA, recordCategory.id) intent.putExtra(CATEGORY_NAME_EXTRA, recordCategory.name) } @@ -25,14 +25,13 @@ class RecordsActivity : CommonActivity() { } } - lateinit var fragment : RecordsFragment + lateinit var fragment: RecordsFragment override val viewID: Int get() = R.layout.activity_toolbar - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsAdapter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsAdapter.kt index 65186f20c..5e36199cc 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsAdapter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsAdapter.kt @@ -17,13 +17,16 @@ class RecordsAdapter : RecyclerView.Adapter() { DiffUtil.calculateDiff(object : DiffUtil.Callback() { override fun getOldListSize() = old.size override fun getNewListSize() = field.size - override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] - override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] }).dispatchUpdatesTo(this) notifyDataSetChanged() } - + init { setHasStableIds(true) } @@ -38,7 +41,7 @@ class RecordsAdapter : RecyclerView.Adapter() { override fun onBindViewHolder(holder: RecordsVH, position: Int) { val item = records[position] - holder.bind(item ){ + holder.bind(item) { } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsFragment.kt index 61b049b3d..a11bcaf87 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsFragment.kt @@ -26,7 +26,8 @@ import io.reactivex.subjects.PublishSubject /** * Fragment Records Delegates Screen. */ -class RecordsFragment : ToolbarLRFragment(), RecordsView { +class RecordsFragment : ToolbarLRFragment(), + RecordsView { private var isRecords = true @@ -43,12 +44,13 @@ class RecordsFragment : ToolbarLRFragment = emptyList(), - val archives: List = emptyList(), - val requestError: Throwable? = null - ) \ No newline at end of file + val items: List = emptyList(), + val archives: List = emptyList(), + val requestError: Throwable? = null +) \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsPartialChanges.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsPartialChanges.kt index 3500a4003..bb2f16d3e 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsPartialChanges.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsPartialChanges.kt @@ -7,9 +7,9 @@ import io.forus.me.android.presentation.view.base.lr.PartialChange sealed class RecordsPartialChanges : PartialChange { - data class RequestRecordsSuccess(val recordsR: List): RecordsPartialChanges() + data class RequestRecordsSuccess(val recordsR: List) : RecordsPartialChanges() - data class RequestArchivesSuccess(val archiveR: List): RecordsPartialChanges() + data class RequestArchivesSuccess(val archiveR: List) : RecordsPartialChanges() - data class RequestError(val error: Throwable): RecordsPartialChanges() + data class RequestError(val error: Throwable) : RecordsPartialChanges() } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsPresenter.kt index 455cbf130..81fad6381 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsPresenter.kt @@ -11,11 +11,14 @@ import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers -class RecordsPresenter constructor(private val recordCategoryId: Long, private val recordsRepository: RecordsRepository) : LRPresenter, RecordsModel, RecordsView>() { +class RecordsPresenter constructor( + private val recordCategoryId: Long, + private val recordsRepository: RecordsRepository +) : LRPresenter, RecordsModel, RecordsView>() { override fun initialModelSingle(): Single> = - Single.fromObservable(recordsRepository.getRecords()) + Single.fromObservable(recordsRepository.getRecords()) override fun RecordsModel.changeInitialModel(i: List): RecordsModel = copy(items = i) @@ -25,66 +28,76 @@ class RecordsPresenter constructor(private val recordCategoryId: Long, private v val observable = Observable.merge( - loadRefreshPartialChanges(), - - intent { it.records() } - .switchMap { validatorId -> - recordsRepository.getRecords() - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - RecordsPartialChanges.RequestRecordsSuccess(it) - } - .onErrorReturn { - RecordsPartialChanges.RequestError(it) - - } - }, - - intent { it.archives() } - .switchMap { validatorId -> - recordsRepository.getRecordsArchived() - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - RecordsPartialChanges.RequestArchivesSuccess(it) - } - .onErrorReturn { - RecordsPartialChanges.RequestError(it) - - } + loadRefreshPartialChanges(), + + intent { it.records() } + .switchMap { validatorId -> + recordsRepository.getRecords() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + RecordsPartialChanges.RequestRecordsSuccess(it) + } + .onErrorReturn { + RecordsPartialChanges.RequestError(it) + + } + }, + + intent { it.archives() } + .switchMap { validatorId -> + recordsRepository.getRecordsArchived() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + RecordsPartialChanges.RequestArchivesSuccess(it) + } + .onErrorReturn { + RecordsPartialChanges.RequestError(it) + } + } ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - RecordsModel(), - false) + false, + null, + false, + false, + null, + false, + RecordsModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - RecordsView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + RecordsView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { if (change !is RecordsPartialChanges) return super.stateReducer(vs, change) return when (change) { is RecordsPartialChanges.RequestRecordsSuccess -> vs.copy( - model = vs.model.copy(items = change.recordsR, requestError = null)) + model = vs.model.copy(items = change.recordsR, requestError = null) + ) + is RecordsPartialChanges.RequestArchivesSuccess -> vs.copy( - model = vs.model.copy(archives = change.archiveR, requestError = null)) + model = vs.model.copy(archives = change.archiveR, requestError = null) + ) + is RecordsPartialChanges.RequestError -> vs.copy( - model = vs.model.copy(requestError = change.error)) + model = vs.model.copy(requestError = change.error) + ) } } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsView.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsView.kt index 19c3e3552..a5ced38ea 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsView.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/list/RecordsView.kt @@ -8,7 +8,7 @@ import io.reactivex.Observable */ -interface RecordsView : LRView{ +interface RecordsView : LRView { fun records(): Observable fun archives(): Observable } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/NewRecordActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/NewRecordActivity.kt index eeaf92001..1920347a8 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/NewRecordActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/NewRecordActivity.kt @@ -15,21 +15,19 @@ class NewRecordActivity : CommonActivity() { companion object { - - fun getCallingIntent(context: Context ): Intent { + fun getCallingIntent(context: Context): Intent { val intent = Intent(context, NewRecordActivity::class.java) return intent } } - lateinit var fragment : NewRecordFragment + lateinit var fragment: NewRecordFragment override val viewID: Int get() = R.layout.activity_toolbar - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -43,7 +41,7 @@ class NewRecordActivity : CommonActivity() { } override fun onBackPressed() { - if(fragment.onBackPressed()) + if (fragment.onBackPressed()) super.onBackPressed() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/NewRecordFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/NewRecordFragment.kt index ec375f0b5..8c6dca297 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/NewRecordFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/NewRecordFragment.kt @@ -40,7 +40,8 @@ import io.reactivex.subjects.PublishSubject /** * Fragment New Record Screen. */ -class NewRecordFragment : ToolbarLRFragment(), NewRecordView { +class NewRecordFragment : ToolbarLRFragment(), + NewRecordView { companion object { @@ -50,7 +51,7 @@ class NewRecordFragment : ToolbarLRFragment 1){ + if (binding.mainViewPager.currentItem > 1) { previousStep.onNext(true) return false - } - else return true + } else return true } private val previousStep = PublishSubject.create() @@ -118,9 +119,13 @@ class NewRecordFragment : ToolbarLRFragment) { super.render(vs) - binding.progressBar.visibility = if (vs.loading || vs.model.sendingCreateRecord) View.VISIBLE else View.INVISIBLE + binding.progressBar.visibility = + if (vs.loading || vs.model.sendingCreateRecord) View.VISIBLE else View.INVISIBLE recordCategoriesAdapter.items = vs.model.categories recordTypesAdapter.items = vs.model.types @@ -203,31 +215,33 @@ class NewRecordFragment : ToolbarLRFragment if(vs.model.item.category != null) selectedCategoryVH.render(vs.model.item.category!!) + when (vs.model.currentStep) { + 1 -> if (vs.model.item.category != null) selectedCategoryVH.render(vs.model.item.category!!) 2 -> { - if(vs.model.item.category != null) selectedCategoryVH2.render(vs.model.item.category!!) - if(vs.model.item.recordType != null) selectedTypeVH2.render(vs.model.item.recordType!!) + if (vs.model.item.category != null) selectedCategoryVH2.render(vs.model.item.category!!) + if (vs.model.item.recordType != null) selectedTypeVH2.render(vs.model.item.recordType!!) } + 3 -> { - if(vs.model.item.category != null) selectedCategoryVH3.render(vs.model.item.category!!) - if(vs.model.item.recordType != null) selectedTypeVH3.render(vs.model.item.recordType!!) + if (vs.model.item.category != null) selectedCategoryVH3.render(vs.model.item.category!!) + if (vs.model.item.recordType != null) selectedTypeVH3.render(vs.model.item.recordType!!) selectedTextVH3.render(vs.model.item.value) } } - if(vs.model.sendingCreateRecordError != null){ + if (vs.model.sendingCreateRecordError != null) { val error: Throwable = vs.model.sendingCreateRecordError - if(error is RetrofitException && error.kind == RetrofitException.Kind.HTTP){ + if (error is RetrofitException && error.kind == RetrofitException.Kind.HTTP) { try { val newRecordError = retrofitExceptionMapper.mapToNewRecordError(error) showError(newRecordError.message) + } catch (e: Exception) { } - catch (e: Exception){} } } @@ -237,8 +251,9 @@ class NewRecordFragment : ToolbarLRFragment getString(R.string.new_record_title_choose_category) - 1 -> getString(R.string.new_record_title_choose_type) - 2 -> getString(R.string.new_record_title_choose_text) - 3 -> getString(R.string.new_record_title_choose_validators) - else -> getString(R.string.new_record_title) - } + when (position) { + 0 -> getString(R.string.new_record_title_choose_category) + 1 -> getString(R.string.new_record_title_choose_type) + 2 -> getString(R.string.new_record_title_choose_text) + 3 -> getString(R.string.new_record_title_choose_validators) + else -> getString(R.string.new_record_title) + } setToolbarTitle(title) } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/NewRecordModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/NewRecordModel.kt index ff7ae0957..5e238f3f9 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/NewRecordModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/NewRecordModel.kt @@ -8,18 +8,18 @@ import io.forus.me.android.presentation.models.ValidationResult import io.forus.me.android.presentation.view.screens.records.newrecord.NewRecordView.Companion.NUM_PAGES data class NewRecordModel( - val item: NewRecordRequest = NewRecordRequest(), - val currentStep: Int = 0, - val sendingCreateRecord: Boolean = false, - val sendingCreateRecordError: Throwable? = null, - val types: List = emptyList(), - val categories: List = emptyList(), - val validators: List = emptyList() + val item: NewRecordRequest = NewRecordRequest(), + val currentStep: Int = 0, + val sendingCreateRecord: Boolean = false, + val sendingCreateRecordError: Throwable? = null, + val types: List = emptyList(), + val categories: List = emptyList(), + val validators: List = emptyList() ) { val isFinalStep: Boolean get() { - return if(validators.isNotEmpty()) (currentStep >= NUM_PAGES - 1) else (currentStep >= NUM_PAGES - 2) + return if (validators.isNotEmpty()) (currentStep >= NUM_PAGES - 1) else (currentStep >= NUM_PAGES - 2) } val buttonIsActive: Boolean @@ -33,20 +33,19 @@ data class NewRecordModel( return active } - val validationResult: ValidationResult + val validationResult: ValidationResult get() { var valid = false var error = "" when { - sendingCreateRecord -> error = ("Request in progress") + sendingCreateRecord -> error = ("Request in progress") item.category == null -> error = ("Please select category") - item.recordType == null -> error = ("Please select validator") - item.value.isEmpty() -> error = ("Value is not valid") + item.recordType == null -> error = ("Please select validator") + item.value.isEmpty() -> error = ("Value is not valid") else -> valid = true } return ValidationResult(valid, error) } - } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/NewRecordPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/NewRecordPresenter.kt index ede2fcb23..ba5b5015d 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/NewRecordPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/NewRecordPresenter.kt @@ -15,22 +15,25 @@ import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.functions.Function3 import io.reactivex.schedulers.Schedulers -class NewRecordPresenter constructor(private val recordRepository: RecordsRepository, private val validatorsRepository: ValidatorsRepository) : LRPresenter() { +class NewRecordPresenter constructor( + private val recordRepository: RecordsRepository, + private val validatorsRepository: ValidatorsRepository +) : LRPresenter() { var request: NewRecordRequest? = null override fun initialModelSingle(): Single = Single.zip( - Single.fromObservable(recordRepository.getRecordTypes()), - Single.fromObservable(recordRepository.getCategories()), - Single.fromObservable(validatorsRepository.getValidators()), - Function3 { types : List, categories: List, validators: List -> - NewRecordModel(types = types, categories = categories, validators = validators) - } + Single.fromObservable(recordRepository.getRecordTypes()), + Single.fromObservable(recordRepository.getCategories()), + Single.fromObservable(validatorsRepository.getValidators()), + Function3 { types: List, categories: List, validators: List -> + NewRecordModel(types = types, categories = categories, validators = validators) + } ) - override fun NewRecordModel.changeInitialModel(i: NewRecordModel): NewRecordModel{ - val defaultCategory = i.categories.find{ it -> it.name == "Persoonlijk"} + override fun NewRecordModel.changeInitialModel(i: NewRecordModel): NewRecordModel { + val defaultCategory = i.categories.find { it -> it.name == "Persoonlijk" } return i.copy(currentStep = 1, item = i.item.copy(category = defaultCategory)) } @@ -38,86 +41,125 @@ class NewRecordPresenter constructor(private val recordRepository: RecordsReposi val observable = Observable.merge( - loadRefreshPartialChanges(), - Observable.mergeArray( - intent { it.selectCategory() } - .map { NewRecordPartialChanges.SelectCategory(it) }, - intent { it.selectType() } - .map { NewRecordPartialChanges.SelectType(it) }, - intent { it.setValue() } - .map { NewRecordPartialChanges.SetValue(it) }, - intent { it.selectValidator()} - .map { NewRecordPartialChanges.SelectValidator(it) }, - intent { it.previousStep()} - .map { NewRecordPartialChanges.PreviousStep() }, - intent { it.nextStep() } - .map { NewRecordPartialChanges.NextStep() }, - - intent { it.submit() } - .switchMap { - recordRepository.newRecord(request!!) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .switchMap { createRecordResponse -> - if(request!!.validators.isNotEmpty()) { - validatorsRepository.requestValidations(createRecordResponse.id, request!!.validators.map { it.id }) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - NewRecordPartialChanges.CreateRecordEnd(createRecordResponse) - } - } - else Observable.just(NewRecordPartialChanges.CreateRecordEnd(createRecordResponse)) - - } - .onErrorReturn { - NewRecordPartialChanges.CreateRecordError(it) - } - .startWith(NewRecordPartialChanges.CreateRecordStart(request!!)) - } - - ) + loadRefreshPartialChanges(), + Observable.mergeArray( + intent { it.selectCategory() } + .map { NewRecordPartialChanges.SelectCategory(it) }, + intent { it.selectType() } + .map { NewRecordPartialChanges.SelectType(it) }, + intent { it.setValue() } + .map { NewRecordPartialChanges.SetValue(it) }, + intent { it.selectValidator() } + .map { NewRecordPartialChanges.SelectValidator(it) }, + intent { it.previousStep() } + .map { NewRecordPartialChanges.PreviousStep() }, + intent { it.nextStep() } + .map { NewRecordPartialChanges.NextStep() }, + + intent { it.submit() } + .switchMap { + recordRepository.newRecord(request!!) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .switchMap { createRecordResponse -> + if (request!!.validators.isNotEmpty()) { + validatorsRepository.requestValidations( + createRecordResponse.id, + request!!.validators.map { it.id }) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + NewRecordPartialChanges.CreateRecordEnd( + createRecordResponse + ) + } + } else Observable.just( + NewRecordPartialChanges.CreateRecordEnd( + createRecordResponse + ) + ) + + } + .onErrorReturn { + NewRecordPartialChanges.CreateRecordError(it) + } + .startWith(NewRecordPartialChanges.CreateRecordStart(request!!)) + } + + ) ) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - NewRecordModel(), - false) + false, + null, + false, + false, + null, + false, + NewRecordModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - NewRecordView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + NewRecordView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { - var result : LRViewState? = null + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { + var result: LRViewState? = null if (change !is NewRecordPartialChanges) - result = super.stateReducer(vs, change) + result = super.stateReducer(vs, change) when (change) { - is NewRecordPartialChanges.CreateRecordEnd -> result = vs.copy(closeScreen = true, model = vs.model.copy(sendingCreateRecord = false, sendingCreateRecordError = null)) - is NewRecordPartialChanges.CreateRecordStart -> result = vs.copy(model = vs.model.copy(sendingCreateRecord = true, sendingCreateRecordError = null)) - is NewRecordPartialChanges.CreateRecordError -> result = vs.copy(model = vs.model.copy(sendingCreateRecord = false, sendingCreateRecordError = change.error)) - is NewRecordPartialChanges.SelectCategory -> result = vs.copy(model = vs.model.copy(item = vs.model.item.copy(category = change.category))) - is NewRecordPartialChanges.SelectType -> result = vs.copy(model = vs.model.copy(item = vs.model.item.copy(recordType = change.type))) - is NewRecordPartialChanges.SetValue -> result = vs.copy(model = vs.model.copy(item = vs.model.item.copy(value = change.value))) - is NewRecordPartialChanges.SelectValidator -> result = vs.copy(model = vs.model.copy(item = vs.model.item.selectValidator(change.validator))) - is NewRecordPartialChanges.PreviousStep -> result = vs.copy(model = vs.model.copy(currentStep = vs.model.currentStep - (if (vs.model.currentStep < NewRecordView.NUM_PAGES && vs.model.currentStep > 0) 1 else 0))) - is NewRecordPartialChanges.NextStep -> result = vs.copy(model = vs.model.copy(currentStep = vs.model.currentStep + (if (vs.model.currentStep < NewRecordView.NUM_PAGES - 1 && vs.model.currentStep >= 0) 1 else 0))) + is NewRecordPartialChanges.CreateRecordEnd -> result = vs.copy( + closeScreen = true, + model = vs.model.copy(sendingCreateRecord = false, sendingCreateRecordError = null) + ) + + is NewRecordPartialChanges.CreateRecordStart -> result = vs.copy( + model = vs.model.copy( + sendingCreateRecord = true, + sendingCreateRecordError = null + ) + ) + + is NewRecordPartialChanges.CreateRecordError -> result = vs.copy( + model = vs.model.copy( + sendingCreateRecord = false, + sendingCreateRecordError = change.error + ) + ) + + is NewRecordPartialChanges.SelectCategory -> result = + vs.copy(model = vs.model.copy(item = vs.model.item.copy(category = change.category))) + + is NewRecordPartialChanges.SelectType -> result = + vs.copy(model = vs.model.copy(item = vs.model.item.copy(recordType = change.type))) + + is NewRecordPartialChanges.SetValue -> result = + vs.copy(model = vs.model.copy(item = vs.model.item.copy(value = change.value))) + + is NewRecordPartialChanges.SelectValidator -> result = + vs.copy(model = vs.model.copy(item = vs.model.item.selectValidator(change.validator))) + + is NewRecordPartialChanges.PreviousStep -> result = + vs.copy(model = vs.model.copy(currentStep = vs.model.currentStep - (if (vs.model.currentStep < NewRecordView.NUM_PAGES && vs.model.currentStep > 0) 1 else 0))) + + is NewRecordPartialChanges.NextStep -> result = + vs.copy(model = vs.model.copy(currentStep = vs.model.currentStep + (if (vs.model.currentStep < NewRecordView.NUM_PAGES - 1 && vs.model.currentStep >= 0) 1 else 0))) } request = result?.model?.item - return result!! + return result!! } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/adapters/RecordCategoriesAdapter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/adapters/RecordCategoriesAdapter.kt index d22f54c4f..caa9d726d 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/adapters/RecordCategoriesAdapter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/adapters/RecordCategoriesAdapter.kt @@ -8,7 +8,8 @@ import io.forus.me.android.domain.models.records.RecordCategory import io.forus.me.android.presentation.databinding.ItemRecordSelectCategoryBinding import io.forus.me.android.presentation.view.screens.records.newrecord.viewholders.RecordCategoryVH -class RecordCategoriesAdapter(private val clickListener: ((RecordCategory) -> Unit)?): RecyclerView.Adapter() { +class RecordCategoriesAdapter(private val clickListener: ((RecordCategory) -> Unit)?) : + RecyclerView.Adapter() { private var lastSelectedPosition: Int = -1 @@ -19,8 +20,11 @@ class RecordCategoriesAdapter(private val clickListener: ((RecordCategory) -> Un DiffUtil.calculateDiff(object : DiffUtil.Callback() { override fun getOldListSize() = old.size override fun getNewListSize() = field.size - override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] - override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] }).dispatchUpdatesTo(this) notifyDataSetChanged() } @@ -31,13 +35,17 @@ class RecordCategoriesAdapter(private val clickListener: ((RecordCategory) -> Un override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecordCategoryVH { - val binding = ItemRecordSelectCategoryBinding.inflate(LayoutInflater.from(parent.context), parent, false) + val binding = ItemRecordSelectCategoryBinding.inflate( + LayoutInflater.from(parent.context), + parent, + false + ) return RecordCategoryVH(binding) } override fun onBindViewHolder(holder: RecordCategoryVH, position: Int) { val item = items[position] - holder.bind(item,lastSelectedPosition){ recordCategory: RecordCategory, position: Int -> + holder.bind(item, lastSelectedPosition) { recordCategory: RecordCategory, position: Int -> lastSelectedPosition = position clickListener?.invoke(recordCategory) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/adapters/RecordTypesAdapter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/adapters/RecordTypesAdapter.kt index 5416b6880..586eff6fa 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/adapters/RecordTypesAdapter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/adapters/RecordTypesAdapter.kt @@ -8,7 +8,8 @@ import io.forus.me.android.domain.models.records.RecordType import io.forus.me.android.presentation.databinding.ItemRecordSelectTypeBinding import io.forus.me.android.presentation.view.screens.records.newrecord.viewholders.RecordTypeVH -class RecordTypesAdapter(private val clickListener: ((RecordType) -> Unit)?): RecyclerView.Adapter() { +class RecordTypesAdapter(private val clickListener: ((RecordType) -> Unit)?) : + RecyclerView.Adapter() { private var lastSelectedPosition: Int = -1 @@ -19,8 +20,11 @@ class RecordTypesAdapter(private val clickListener: ((RecordType) -> Unit)?): Re DiffUtil.calculateDiff(object : DiffUtil.Callback() { override fun getOldListSize() = old.size override fun getNewListSize() = field.size - override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] - override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] }).dispatchUpdatesTo(this) notifyDataSetChanged() } @@ -30,13 +34,14 @@ class RecordTypesAdapter(private val clickListener: ((RecordType) -> Unit)?): Re } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecordTypeVH { - val binding = ItemRecordSelectTypeBinding.inflate(LayoutInflater.from(parent.context), parent, false) + val binding = + ItemRecordSelectTypeBinding.inflate(LayoutInflater.from(parent.context), parent, false) return RecordTypeVH(binding) } override fun onBindViewHolder(holder: RecordTypeVH, position: Int) { val item = items[position] - holder.bind(item, lastSelectedPosition){ recordType: RecordType, position: Int -> + holder.bind(item, lastSelectedPosition) { recordType: RecordType, position: Int -> lastSelectedPosition = position notifyDataSetChanged() clickListener?.invoke(recordType) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/adapters/RecordValidatorAdapter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/adapters/RecordValidatorAdapter.kt index 12ad9494f..16d43a894 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/adapters/RecordValidatorAdapter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/adapters/RecordValidatorAdapter.kt @@ -8,7 +8,8 @@ import io.forus.me.android.domain.models.validators.SimpleValidator import io.forus.me.android.presentation.databinding.ItemRecordSelectValidatorBinding import io.forus.me.android.presentation.view.screens.records.newrecord.viewholders.RecordValidatorVH -class RecordValidatorAdapter(private val clickListener: ((SimpleValidator) -> Unit)?): RecyclerView.Adapter() { +class RecordValidatorAdapter(private val clickListener: ((SimpleValidator) -> Unit)?) : + RecyclerView.Adapter() { var checkedStatus = BooleanArray(0) var items: List = emptyList() @@ -18,12 +19,15 @@ class RecordValidatorAdapter(private val clickListener: ((SimpleValidator) -> Un DiffUtil.calculateDiff(object : DiffUtil.Callback() { override fun getOldListSize() = old.size override fun getNewListSize() = field.size - override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] - override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] }).dispatchUpdatesTo(this) notifyDataSetChanged() - if(field.size != checkedStatus.size) checkedStatus = BooleanArray(field.size) + if (field.size != checkedStatus.size) checkedStatus = BooleanArray(field.size) } init { @@ -31,13 +35,17 @@ class RecordValidatorAdapter(private val clickListener: ((SimpleValidator) -> Un } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecordValidatorVH { - val binding = ItemRecordSelectValidatorBinding.inflate(LayoutInflater.from(parent.context), parent, false) + val binding = ItemRecordSelectValidatorBinding.inflate( + LayoutInflater.from(parent.context), + parent, + false + ) return RecordValidatorVH(binding) } override fun onBindViewHolder(holder: RecordValidatorVH, position: Int) { val item = items[position] - holder.bind(item, checkedStatus[position]){ validator: SimpleValidator, position: Int -> + holder.bind(item, checkedStatus[position]) { validator: SimpleValidator, position: Int -> checkedStatus[position] = !checkedStatus[position] clickListener?.invoke(validator) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/viewholders/RecordCategoryVH.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/viewholders/RecordCategoryVH.kt index 8b2e3abbe..30fae9b5f 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/viewholders/RecordCategoryVH.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/viewholders/RecordCategoryVH.kt @@ -9,7 +9,11 @@ import io.forus.me.android.presentation.databinding.ItemRecordSelectCategoryBind class RecordCategoryVH(private val binding: ItemRecordSelectCategoryBinding) : RecyclerView.ViewHolder(binding.root) { - fun bind(item: RecordCategory, lastSelectedPosition: Int, clickListener: ((RecordCategory, Int) -> Unit)?) { + fun bind( + item: RecordCategory, + lastSelectedPosition: Int, + clickListener: ((RecordCategory, Int) -> Unit)? + ) { binding.apply { bg.setBackgroundResource(if (lastSelectedPosition == adapterPosition) R.color.rippleColor else R.color.alabaster) tvName.text = item.name diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/viewholders/SelectedCategoryVH.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/viewholders/SelectedCategoryVH.kt index 958611013..cf8bddeb6 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/viewholders/SelectedCategoryVH.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/newrecord/viewholders/SelectedCategoryVH.kt @@ -15,8 +15,8 @@ class SelectedCategoryVH(root: View) { iv_icon = root.findViewById(R.id.iv_icon) } - fun render(item: RecordCategory) { + fun render(item: RecordCategory) { tv_name.text = item.name - if(item.logo.isNotEmpty()) iv_icon.setImageUrl(item.logo) + if (item.logo.isNotEmpty()) iv_icon.setImageUrl(item.logo) } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/types/RecordTypesModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/types/RecordTypesModel.kt index ffe5d4425..cb3761ef2 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/types/RecordTypesModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/types/RecordTypesModel.kt @@ -1,5 +1,5 @@ package io.forus.me.android.presentation.view.screens.records.types data class RecordTypesModel( - val items: List = emptyList() - ) \ No newline at end of file + val items: List = emptyList() +) \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/types/RecordTypesPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/types/RecordTypesPresenter.kt index a8a3e4b43..4582c41eb 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/types/RecordTypesPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/records/types/RecordTypesPresenter.kt @@ -8,14 +8,17 @@ import io.reactivex.Single import io.reactivex.android.schedulers.AndroidSchedulers -class RecordTypesPresenter constructor(val recordsRepository: RecordsRepository) : LRPresenter, RecordTypesModel, RecordTypesView>() { +class RecordTypesPresenter constructor(val recordsRepository: RecordsRepository) : + LRPresenter, RecordTypesModel, RecordTypesView>() { - override fun initialModelSingle(): Single> = Single.fromObservable( - recordsRepository.getRecordTypes() - ) + override fun initialModelSingle(): Single> = + Single.fromObservable( + recordsRepository.getRecordTypes() + ) - override fun RecordTypesModel.changeInitialModel(i: List): RecordTypesModel = copy(items = i) + override fun RecordTypesModel.changeInitialModel(i: List): RecordTypesModel = + copy(items = i) override fun bindIntents() { @@ -23,22 +26,27 @@ class RecordTypesPresenter constructor(val recordsRepository: RecordsRepository) val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - RecordTypesModel(), - false) + false, + null, + false, + false, + null, + false, + RecordTypesModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - RecordTypesView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + RecordTypesView::render + ) } - override fun stateReducer(viewState: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + viewState: LRViewState, + change: PartialChange + ): LRViewState { if (change !is RecordTypesPartialChanges) return super.stateReducer(viewState, change) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/VoucherViewModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/VoucherViewModel.kt index 099ecdf6d..58068f2d4 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/VoucherViewModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/VoucherViewModel.kt @@ -4,25 +4,25 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import io.forus.me.android.presentation.models.vouchers.Voucher -class VoucherViewModel: ViewModel() { +class VoucherViewModel : ViewModel() { val TAG = "VoucherViewModel" - private var _address = MutableLiveData() + private var _address = MutableLiveData() val address get() = _address - fun setAddress(address: String){ + fun setAddress(address: String) { _address.value = address } - private var _voucher = MutableLiveData() + private var _voucher = MutableLiveData() val voucher get() = _voucher - fun setVoucher(voucher: Voucher?){ + fun setVoucher(voucher: Voucher?) { _voucher.value = voucher } - private var _isDemoVoucher = MutableLiveData(false) + private var _isDemoVoucher = MutableLiveData(false) val isDemoVoucher get() = _isDemoVoucher - fun setIsDemoVoucher(isDemoVoucher: Boolean){ + fun setIsDemoVoucher(isDemoVoucher: Boolean) { _isDemoVoucher.value = isDemoVoucher } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/ApplyActionTransactionDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/ApplyActionTransactionDialog.kt index 5fc1e024a..d9c406577 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/ApplyActionTransactionDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/ApplyActionTransactionDialog.kt @@ -9,9 +9,11 @@ import com.afollestad.materialdialogs.MaterialDialog import io.forus.me.android.presentation.R -class ApplyActionTransactionDialog(private val context: Activity, private val title: String, - private val toPayText: String, private val subtitle: String, - private val positiveCallback: () -> Unit) { +class ApplyActionTransactionDialog( + private val context: Activity, private val title: String, + private val toPayText: String, private val subtitle: String, + private val positiveCallback: () -> Unit +) { var dialog: MaterialDialog? = null @@ -26,7 +28,7 @@ class ApplyActionTransactionDialog(private val context: Activity, private val ti val viewId = if (dpWidth <= 320 || dpHeight < 522) { R.layout.dialog_apply_action_nokia1 - }else{ + } else { R.layout.dialog_apply_action } @@ -34,14 +36,14 @@ class ApplyActionTransactionDialog(private val context: Activity, private val ti val titleTV = customLayout.findViewById(R.id.title) val bottomTV = customLayout.findViewById(R.id.bottom) - val amountTV = customLayout.findViewById(R.id.amount) + val amountTV = customLayout.findViewById(R.id.amount) - amountTV.text = toPayText - titleTV.text = title - bottomTV.text = subtitle + amountTV.text = toPayText + titleTV.text = title + bottomTV.text = subtitle @@ -55,8 +57,8 @@ class ApplyActionTransactionDialog(private val context: Activity, private val ti dialog = MaterialDialog.Builder(context) - .customView(customLayout, false) - .build() + .customView(customLayout, false) + .build() dialog!!.show() } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/ConfirmExtraPaymentDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/ConfirmExtraPaymentDialog.kt index 4f3227b97..406eb76c3 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/ConfirmExtraPaymentDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/ConfirmExtraPaymentDialog.kt @@ -25,7 +25,7 @@ class ConfirmExtraPaymentDialog( var extraInfoTextView: View? = null var icMoreInfo: ImageView? = null var extraAmountTV: TextView? = null - var alertTitleTV : TextView? = null + var alertTitleTV: TextView? = null var textInputLayout: com.google.android.material.textfield.TextInputLayout? = null var extraAmountInput: com.google.android.material.textfield.TextInputEditText? = null var cancel: View? = null @@ -66,11 +66,21 @@ class ConfirmExtraPaymentDialog( alertTitleTV?.setTextColor(ContextCompat.getColor(requireContext(), R.color.textColor)) extraAmountInput?.onFocusChangeListener = View.OnFocusChangeListener { _, hasFocus -> if (hasFocus) { - alertTitleTV?.setTextColor(ContextCompat.getColor(requireContext(), R.color.forus_blue)) + alertTitleTV?.setTextColor( + ContextCompat.getColor( + requireContext(), + R.color.forus_blue + ) + ) extraAmountInput?.hint = "" } else { if (extraAmountInput?.text.isNullOrEmpty()) { - alertTitleTV?.setTextColor(ContextCompat.getColor(requireContext(), R.color.textColor)) + alertTitleTV?.setTextColor( + ContextCompat.getColor( + requireContext(), + R.color.textColor + ) + ) extraAmountInput?.hint = "€ 0,00" } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/FullscreenDialog.java b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/FullscreenDialog.java index 48f1d7ced..1e396ac3b 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/FullscreenDialog.java +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/FullscreenDialog.java @@ -19,12 +19,10 @@ public class FullscreenDialog extends DialogFragment { View rootView; - + String positiveButtonText = "OK"; + SubmitClickListener submitClickListener; private String title = ""; private String description = ""; - String positiveButtonText= "OK"; - - SubmitClickListener submitClickListener; public static FullscreenDialog display(FragmentManager fragmentManager, String title, String details, String positiveButtonText, SubmitClickListener submitClickListener) { FullscreenDialog fullscreenDialog = new FullscreenDialog(); diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/SuccessDialogActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/SuccessDialogActivity.kt index 6cec75b09..9cfe4d72d 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/SuccessDialogActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/SuccessDialogActivity.kt @@ -15,7 +15,12 @@ class SuccessDialogActivity : AppCompatActivity() { val DESCRIPTION_EXTRA = "DESCRIPTION_EXTRA" val SUBMIT_EXTRA = "SUBMIT_EXTRA" - fun getCallingIntent(context: Context, title: String, description: String = "", submitButtonText: String? = "OK"): Intent { + fun getCallingIntent( + context: Context, + title: String, + description: String = "", + submitButtonText: String? = "OK" + ): Intent { val intent = Intent(context, SuccessDialogActivity::class.java) intent.putExtra(TITLE_EXTRA, title) intent.putExtra(DESCRIPTION_EXTRA, description) @@ -37,10 +42,10 @@ class SuccessDialogActivity : AppCompatActivity() { binding = DialogFullscreenBinding.inflate(layoutInflater) setContentView(binding.root) - if(intent != null) { - titleTxt = intent.getStringExtra(TITLE_EXTRA)?:"" - descriptionTxt = intent.getStringExtra(DESCRIPTION_EXTRA)?:"" - submitButtonText = intent.getStringExtra(SUBMIT_EXTRA)?:"" + if (intent != null) { + titleTxt = intent.getStringExtra(TITLE_EXTRA) ?: "" + descriptionTxt = intent.getStringExtra(DESCRIPTION_EXTRA) ?: "" + submitButtonText = intent.getStringExtra(SUBMIT_EXTRA) ?: "" } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/ThrowableErrorDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/ThrowableErrorDialog.kt index 72f5ef996..3fd832c36 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/ThrowableErrorDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/dialogs/ThrowableErrorDialog.kt @@ -8,11 +8,14 @@ import io.forus.me.android.presentation.R import io.forus.me.android.presentation.internal.Injection -class ThrowableErrorDialog(private val error: Throwable, private val context: Context, - private val dismissListener: () -> Unit){ +class ThrowableErrorDialog( + private val error: Throwable, private val context: Context, + private val dismissListener: () -> Unit +) { private var message = "" - private var retrofitExceptionMapper: RetrofitExceptionMapper = Injection.instance.retrofitExceptionMapper + private var retrofitExceptionMapper: RetrofitExceptionMapper = + Injection.instance.retrofitExceptionMapper init { if (error is RetrofitException) { @@ -35,14 +38,14 @@ class ThrowableErrorDialog(private val error: Throwable, private val context: Co private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title(R.string.qr_popup_error) - .content(message) - .icon(context.resources.getDrawable(R.drawable.ic_close)) - .positiveText(context.resources.getString(R.string.me_ok)) - .dismissListener { dismissListener.invoke() } - .build() - - fun show(){ + .title(R.string.qr_popup_error) + .content(message) + .icon(context.resources.getDrawable(R.drawable.ic_close)) + .positiveText(context.resources.getString(R.string.me_ok)) + .dismissListener { dismissListener.invoke() } + .build() + + fun show() { dialog.show() } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/VoucherActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/VoucherActivity.kt index 65f4ce173..18b6b78e8 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/VoucherActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/VoucherActivity.kt @@ -17,8 +17,8 @@ class VoucherActivity : CommonActivity(), MViewModelProvider { override val viewModel: VoucherViewModel by viewModels() companion object { - const val ID_EXTRA = "ID_EXTRA" - const val VOUCHER_EXTRA = "VOUCHER_EXTRA" + const val ID_EXTRA = "ID_EXTRA" + const val VOUCHER_EXTRA = "VOUCHER_EXTRA" fun getCallingIntent(context: Context, id: String): Intent { val intent = Intent(context, VoucherActivity::class.java) @@ -42,11 +42,11 @@ class VoucherActivity : CommonActivity(), MViewModelProvider { val voucher = intent.getParcelableExtra(VOUCHER_EXTRA) viewModel.setVoucher(voucher) - viewModel.setAddress(voucher?.address?:"") + viewModel.setAddress(voucher?.address ?: "") if (savedInstanceState == null) { fragment = when (voucher) { - null -> VoucherFragment.newInstance(intent.getStringExtra(ID_EXTRA)?:"") + null -> VoucherFragment.newInstance(intent.getStringExtra(ID_EXTRA) ?: "") else -> VoucherFragment.newInstance(voucher) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/VoucherFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/VoucherFragment.kt index c87d2b3e9..69d5d89af 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/VoucherFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/VoucherFragment.kt @@ -197,7 +197,12 @@ class VoucherFragment : ToolbarLRFragment{ +interface VoucherView : LRView { fun sendEmail(): io.reactivex.Observable diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/dialogs/SendVoucherSuccessDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/dialogs/SendVoucherSuccessDialog.kt index fffa0c698..12852c206 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/dialogs/SendVoucherSuccessDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/dialogs/SendVoucherSuccessDialog.kt @@ -4,18 +4,20 @@ import android.content.Context import com.afollestad.materialdialogs.MaterialDialog import io.forus.me.android.presentation.R -class SendVoucherSuccessDialog(private val context: Context, - private val dismissListener: () -> Unit){ +class SendVoucherSuccessDialog( + private val context: Context, + private val dismissListener: () -> Unit +) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title(R.string.voucher_send_email_success) - .content(R.string.voucher_send_email_description) - .icon(context.resources.getDrawable(R.drawable.ic_baseline_check_24px)) - .positiveText(context.resources.getString(R.string.me_ok)) - .dismissListener { dismissListener.invoke() } - .build() + .title(R.string.voucher_send_email_success) + .content(R.string.voucher_send_email_description) + .icon(context.resources.getDrawable(R.drawable.ic_baseline_check_24px)) + .positiveText(context.resources.getString(R.string.me_ok)) + .dismissListener { dismissListener.invoke() } + .build() - fun show(){ + fun show() { dialog.show() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/offices_adapter/DaysGroup.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/offices_adapter/DaysGroup.kt index 2c51017c2..24922d1e5 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/offices_adapter/DaysGroup.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/offices_adapter/DaysGroup.kt @@ -31,20 +31,28 @@ class DaysGroup { group.isEmpty() -> { "" } + group.size == 1 -> { val day = group.first() - getDayOfWeekName(ctx, day.weekDay.toInt()) + ": " + day.startTime + " - " + day.endTime + getDayOfWeekName( + ctx, + day.weekDay.toInt() + ) + ": " + day.startTime + " - " + day.endTime } + else -> { val firstDay = group.first() val lastDay = group.last() - (getDayOfWeekName(ctx, firstDay.weekDay.toInt()) + " - " + getDayOfWeekName(ctx, lastDay.weekDay.toInt()) + ": " + (getDayOfWeekName(ctx, firstDay.weekDay.toInt()) + " - " + getDayOfWeekName( + ctx, + lastDay.weekDay.toInt() + ) + ": " + firstDay.startTime + " - " + firstDay.endTime) } } } - fun isEmptyGroup():Boolean{ + fun isEmptyGroup(): Boolean { return group.isEmpty() } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/offices_adapter/OfficesAdapter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/offices_adapter/OfficesAdapter.kt index 6a0ede771..9022593f0 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/offices_adapter/OfficesAdapter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/offices_adapter/OfficesAdapter.kt @@ -10,7 +10,8 @@ import io.forus.me.android.presentation.R import io.forus.me.android.presentation.models.vouchers.Office import io.forus.me.android.presentation.models.vouchers.Schedule -class OfficesAdapter(private val items: List, private val context: Context) : PagerAdapter() { +class OfficesAdapter(private val items: List, private val context: Context) : + PagerAdapter() { private var layoutInflater: LayoutInflater? = null override fun getCount(): Int { return items.size @@ -20,7 +21,7 @@ class OfficesAdapter(private val items: List, private val context: Conte return view == obj } - var showMapCallback : ShowMapCallback? = null + var showMapCallback: ShowMapCallback? = null override fun instantiateItem(container: ViewGroup, position: Int): Any { layoutInflater = LayoutInflater.from(context) @@ -31,11 +32,10 @@ class OfficesAdapter(private val items: List, private val context: Conte val timeTV: TextView = view.findViewById(R.id.timeTV) - val office = items[position] showMapTV.setOnClickListener { - if(showMapCallback != null){ + if (showMapCallback != null) { showMapCallback!!.showMap(office) } } @@ -68,21 +68,21 @@ class OfficesAdapter(private val items: List, private val context: Conte for (i in 0 until (schedulers.size)) { val gr = schedulers[i] - if(gr.startTime.isNullOrEmpty() || gr.endTime.isNullOrEmpty()) { + if (gr.startTime.isNullOrEmpty() || gr.endTime.isNullOrEmpty()) { - }else{ + } else { var searchCompatibleGroup = false - for(group in groups){ + for (group in groups) { if (group.isDayCompatibleInGroup(gr)) { group.addSchedule(gr) searchCompatibleGroup = true } } - if(!searchCompatibleGroup) { + if (!searchCompatibleGroup) { val group = DaysGroup() - groups.add(group) + groups.add(group) group.addSchedule(gr) } } @@ -99,24 +99,24 @@ class OfficesAdapter(private val items: List, private val context: Conte for (i in 0 until (schedulers.size)) { val gr = schedulers[i] - if(gr.startTime.isNullOrEmpty() || gr.endTime.isNullOrEmpty()) { - if(!group.isEmptyGroup()) { + if (gr.startTime.isNullOrEmpty() || gr.endTime.isNullOrEmpty()) { + if (!group.isEmptyGroup()) { group = DaysGroup() groups.add(group) } - }else{ + } else { if (group.isDayCompatibleInGroup(gr)) { group.addSchedule(gr) } else { - if(!group.isEmptyGroup()) { + if (!group.isEmptyGroup()) { group = DaysGroup() groups.add(group) } group.addSchedule(gr) } } - if(i==schedulers.size-1){ - if(group.isEmptyGroup()){ + if (i == schedulers.size - 1) { + if (group.isEmptyGroup()) { groups.remove(group) } } @@ -130,9 +130,7 @@ class OfficesAdapter(private val items: List, private val context: Conte } - - - public interface ShowMapCallback{ + public interface ShowMapCallback { fun showMap(office: Office) } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/transactions/TransactionsAdapter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/transactions/TransactionsAdapter.kt index 2b7493c69..38450acf3 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/transactions/TransactionsAdapter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/transactions/TransactionsAdapter.kt @@ -13,7 +13,7 @@ class TransactionsAdapter : RecyclerView.Adapter() { var transactions: List = emptyList() set(value) { - Log.d("my","set value transactions ${transactions.size}") + Log.d("my", "set value transactions ${transactions.size}") val old = field field = value DiffUtil.calculateDiff(object : DiffUtil.Callback() { @@ -37,7 +37,6 @@ class TransactionsAdapter : RecyclerView.Adapter() { var clickListener: ((Transaction) -> Unit)? = null - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TransactionsVH { val binding = ItemVoucherTranscationsListBinding.inflate( LayoutInflater.from(parent.context), diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/transactions/TransactionsVH.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/transactions/TransactionsVH.kt index 8b1315496..d2e3f58dd 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/transactions/TransactionsVH.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/item/transactions/TransactionsVH.kt @@ -25,11 +25,15 @@ class TransactionsVH(private val binding: ItemVoucherTranscationsListBinding) : } } else item.organization?.name overline1.text = if (isActionsVoucher) { - if (item.product != null ) { - if(item.product!!.organization != null) { + if (item.product != null) { + if (item.product!!.organization != null) { item.product!!.organization!!.name - }else{ ""} - } else { ""} + } else { + "" + } + } else { + "" + } } else VoucherFragment.dateFormat.format(item.createdAt) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/list/VouchersModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/list/VouchersModel.kt index e67c2b708..b1ee7d954 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/list/VouchersModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/list/VouchersModel.kt @@ -3,5 +3,5 @@ package io.forus.me.android.presentation.view.screens.vouchers.list import io.forus.me.android.presentation.models.vouchers.Voucher data class VouchersModel( - val items: List = emptyList() - ) \ No newline at end of file + val items: List = emptyList() +) \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/list/VouchersVH.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/list/VouchersVH.kt index 3189afaab..a68453530 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/list/VouchersVH.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/list/VouchersVH.kt @@ -37,13 +37,16 @@ class VouchersVH(private val binding: ItemVouchersListBinding) : if (item.isProduct && item.isUsed) { usedOrExpiredLb.visibility = View.VISIBLE - usedOrExpiredLb.text = usedOrExpiredLb.context.getString(R.string.voucher_is_used) + usedOrExpiredLb.text = + usedOrExpiredLb.context.getString(R.string.voucher_is_used) } else if (item.expired) { usedOrExpiredLb.visibility = View.VISIBLE - usedOrExpiredLb.text = usedOrExpiredLb.context.getString(R.string.voucher_expired) + usedOrExpiredLb.text = + usedOrExpiredLb.context.getString(R.string.voucher_expired) } else if (item.deactivated) { usedOrExpiredLb.visibility = View.VISIBLE - usedOrExpiredLb.text = usedOrExpiredLb.context.getString(R.string.voucher_deactivated) + usedOrExpiredLb.text = + usedOrExpiredLb.context.getString(R.string.voucher_deactivated) } else { usedOrExpiredLb.visibility = View.GONE value.text = item.amount_locale ?: "" diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/product_reservation/ProductReservationActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/product_reservation/ProductReservationActivity.kt index 573b06869..72ba7e3b0 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/product_reservation/ProductReservationActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/product_reservation/ProductReservationActivity.kt @@ -31,14 +31,16 @@ class ProductReservationActivity : CommonActivity(), MViewModelProvider(), ProductReservationView, +class ProductReservationFragment : + ToolbarLRFragment(), + ProductReservationView, MViewModelProvider { override val viewModel by lazy { @@ -29,17 +31,17 @@ class ProductReservationFragment : ToolbarLRFragment, _: Int -> - if(context != null ) { - val intentToLaunch = ProviderActivity.getCallingIntent(requireContext(), voucher.address!!) + if (context != null) { + val intentToLaunch = + ProviderActivity.getCallingIntent(requireContext(), voucher.address!!) requireContext().startActivity(intentToLaunch) } } @@ -92,7 +102,7 @@ class ProductReservationFragment : ToolbarLRFragment) { super.render(vs) - binding.tvNoVouchers.visibility = if (!vs.loading && vs.loadingError == null && vs.model.items.isEmpty()) View.VISIBLE else View.INVISIBLE + binding.tvNoVouchers.visibility = + if (!vs.loading && vs.loadingError == null && vs.model.items.isEmpty()) View.VISIBLE else View.INVISIBLE adapter.vouchers = vs.model.items - if(vs.closeScreen) closeScreen() + if (vs.closeScreen) closeScreen() } private fun closeScreen() { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/product_reservation/ProductReservationModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/product_reservation/ProductReservationModel.kt index f1f5d9fbd..c4ceb2d74 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/product_reservation/ProductReservationModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/product_reservation/ProductReservationModel.kt @@ -3,5 +3,5 @@ package io.forus.me.android.presentation.view.screens.vouchers.product_reservati import io.forus.me.android.presentation.models.vouchers.Voucher data class ProductReservationModel( - val items: List = emptyList() + val items: List = emptyList() ) \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderActivity.kt index ba3a149c0..dde5e9110 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderActivity.kt @@ -9,7 +9,7 @@ import io.forus.me.android.presentation.view.activity.CommonActivity import io.forus.me.android.presentation.view.base.MViewModelProvider import io.forus.me.android.presentation.view.screens.vouchers.VoucherViewModel -class ProviderActivity : CommonActivity() , MViewModelProvider { +class ProviderActivity : CommonActivity(), MViewModelProvider { override val viewModel: VoucherViewModel by viewModels() @@ -18,10 +18,14 @@ class ProviderActivity : CommonActivity() , MViewModelProvider val VOUCHER_ADDRESS_EXTRA = "VOUCHER_ADDRESS_EXTRA" val IS_DEMO_VOUCHER = "IS_DEMO_VOUCHER" - fun getCallingIntent(context: Context, id: String, isDemoVoucher: Boolean? = false): Intent { + fun getCallingIntent( + context: Context, + id: String, + isDemoVoucher: Boolean? = false + ): Intent { val intent = Intent(context, ProviderActivity::class.java) intent.putExtra(VOUCHER_ADDRESS_EXTRA, id) - if(isDemoVoucher != null)intent.putExtra(IS_DEMO_VOUCHER, isDemoVoucher) + if (isDemoVoucher != null) intent.putExtra(IS_DEMO_VOUCHER, isDemoVoucher) return intent } } @@ -31,13 +35,12 @@ class ProviderActivity : CommonActivity() , MViewModelProvider get() = R.layout.activity_toolbar - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) if (savedInstanceState == null) { - val voucherAddress = intent.getStringExtra(VOUCHER_ADDRESS_EXTRA)?:"" + val voucherAddress = intent.getStringExtra(VOUCHER_ADDRESS_EXTRA) ?: "" val isDemoVoucher = intent.getBooleanExtra(IS_DEMO_VOUCHER, false) viewModel.setAddress(voucherAddress) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderFragment.kt index 36c76bb17..a64b2b5de 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderFragment.kt @@ -61,8 +61,10 @@ class ProviderFragment : ToolbarLRFragment() override fun selectOrganization(): Observable = selectOrganization - //private val charge = PublishSubject.create() + //private val charge = PublishSubject.create() //override fun charge(): Observable = charge private val charge = PublishSubject.create>() @@ -104,8 +106,7 @@ class ProviderFragment : ToolbarLRFragment - charge.onNext(Pair(chargeAmount, extraAmount.toBigDecimal())) - }, { + if (needExtra) { + val bottomSheetFragment = + ConfirmExtraPaymentDialog( + extraAmount = extra.toFloat(), + { extraAmount -> + charge.onNext(Pair(chargeAmount, extraAmount.toBigDecimal())) + }, { - }) + }) bottomSheetFragment.show(requireFragmentManager(), "BottomSheetDialog") - } - else - { + } else { //charge.onNext(chargeAmount) ChargeDialog(requireContext(), chargeAmount, 0.toBigDecimal() /*extra*/) { charge.onNext(Pair(chargeAmount, 0.toBigDecimal())) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderModel.kt index 54c72938d..1c6e09e32 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderModel.kt @@ -5,23 +5,22 @@ import io.forus.me.android.presentation.models.vouchers.VoucherProvider import java.math.BigDecimal data class ProviderModel( - val item: VoucherProvider? = null, - val selectedOrganization: Organization? = null, - val selectedAmount: BigDecimal = BigDecimal.ZERO, - val selectedNote: String = "", - val sendingMakeTransaction: Boolean = false, - val makeTransactionError: Throwable? = null -) -{ + val item: VoucherProvider? = null, + val selectedOrganization: Organization? = null, + val selectedAmount: BigDecimal = BigDecimal.ZERO, + val selectedNote: String = "", + val sendingMakeTransaction: Boolean = false, + val makeTransactionError: Throwable? = null +) { val amountIsValid: Boolean - get(){ + get() { return selectedAmount >= BigDecimal("0.01") } val buttonIsActive: Boolean get() { - return if(item != null && item.voucher.isProduct) true - else (selectedOrganization != null && amountIsValid) + return if (item != null && item.voucher.isProduct) true + else (selectedOrganization != null && amountIsValid) } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderPresenter.kt index 8decadf5d..5d7aa776c 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderPresenter.kt @@ -93,162 +93,173 @@ class ProviderPresenter( }, it.allowedProductCategories.map { productCategory -> - ProductCategory(productCategory.id, productCategory.key, productCategory.name) + ProductCategory( + productCategory.id, + productCategory.key, + productCategory.name + ) }) }) } else { - return Single.fromObservable(vouchersRepository.getVoucherAsProvider(address).map { it -> - firestoreTokenManager.writeGetVoucherAsProvider(address, true, null) - - val officesList = mutableListOf() - - it.voucher.offices.forEach { - val schedulers = mutableListOf() - - if (it.schedulers != null) { - it.schedulers!!.map { - schedulers.add( - io.forus.me.android.presentation.models.vouchers.Schedule( - it.id, it.officeId ?: -1L, it.weekDay ?: 0, it.startTime, it.endTime + return Single.fromObservable( + vouchersRepository.getVoucherAsProvider(address).map { it -> + firestoreTokenManager.writeGetVoucherAsProvider(address, true, null) + + val officesList = mutableListOf() + + it.voucher.offices.forEach { + val schedulers = + mutableListOf() + + if (it.schedulers != null) { + it.schedulers!!.map { + schedulers.add( + io.forus.me.android.presentation.models.vouchers.Schedule( + it.id, + it.officeId ?: -1L, + it.weekDay ?: 0, + it.startTime, + it.endTime + ) ) - ) + } } - } - - val organization = Organization( - it.organization?.id ?: 0, - it.organization?.name ?: "", - it.organization?.logo ?: "", - it.organization?.lat ?: 0.0, - it.organization?.lon ?: 0.0, - it.organization?.address ?: "", - it.organization?.phone ?: "", - it.organization?.email ?: "" - ) - officesList.add( - Office( - it.id, - it.organizationId, - it.address, - it.phone, - it.lat, - it.lon, - it.photo, - organization, - schedulers + val organization = Organization( + it.organization?.id ?: 0, + it.organization?.name ?: "", + it.organization?.logo ?: "", + it.organization?.lat ?: 0.0, + it.organization?.lon ?: 0.0, + it.organization?.address ?: "", + it.organization?.phone ?: "", + it.organization?.email ?: "" ) - ) - - } - VoucherProvider( - Voucher( - it.voucher.isProduct ?: false, - it.voucher.isUsed ?: false, - it.voucher.address, - it.voucher.identyAddress, - it.voucher.name, - it.voucher.organizationName, - it.voucher.fundName, - it.voucher.fundType, - it.voucher.fundWebShopUrl, - it.voucher.description, - it.voucher.createdAt, - it.voucher.amount, - it.voucher.amount_locale, - it.voucher.logo, - it.voucher.transactions.map { transaction -> - val organization = Organization( - transaction.organization?.id ?: 0, - transaction.organization?.name, - transaction.organization?.logo, - transaction.organization?.lat, - transaction.organization?.lon, - transaction.organization?.address, - transaction.organization?.phone, - transaction.organization?.email + officesList.add( + Office( + it.id, + it.organizationId, + it.address, + it.phone, + it.lat, + it.lon, + it.photo, + organization, + schedulers ) + ) - val product: io.forus.me.android.presentation.models.vouchers.Product? = - if (transaction.product == null) { - null - } else { - io.forus.me.android.presentation.models.vouchers.Product( - transaction.product?.id ?: -1L, - transaction.product!!.organizationId!!, - transaction.product!!.productCategoryId!!, - transaction.product!!.name, - transaction.product!!.description, - transaction.product!!.price!!, - transaction.product!!.oldPrice!!, - transaction.product!!.totalAmount!!, - transaction.product!!.soldAmount!!, - ProductCategory( - transaction.product!!.productCategory?.id ?: -1L, - transaction.product!!.productCategory?.key, - transaction.product!!.productCategory?.name - ), - organization - ) - } - + } + VoucherProvider( + Voucher( + it.voucher.isProduct ?: false, + it.voucher.isUsed ?: false, + it.voucher.address, + it.voucher.identyAddress, + it.voucher.name, + it.voucher.organizationName, + it.voucher.fundName, + it.voucher.fundType, + it.voucher.fundWebShopUrl, + it.voucher.description, + it.voucher.createdAt, + it.voucher.amount, + it.voucher.amount_locale, + it.voucher.logo, + it.voucher.transactions.map { transaction -> + val organization = Organization( + transaction.organization?.id ?: 0, + transaction.organization?.name, + transaction.organization?.logo, + transaction.organization?.lat, + transaction.organization?.lon, + transaction.organization?.address, + transaction.organization?.phone, + transaction.organization?.email + ) - Transaction( - transaction.id, - organization, - transaction.amount ?: 0f.toBigDecimal(), - transaction.amount_locale, - transaction.amount_extra_cash ?: 0f.toBigDecimal(), - transaction.amount_extra_cash_locale, - transaction.createdAt, - Transaction.Type.valueOf(transaction.type.name), - product + val product: io.forus.me.android.presentation.models.vouchers.Product? = + if (transaction.product == null) { + null + } else { + io.forus.me.android.presentation.models.vouchers.Product( + transaction.product?.id ?: -1L, + transaction.product!!.organizationId!!, + transaction.product!!.productCategoryId!!, + transaction.product!!.name, + transaction.product!!.description, + transaction.product!!.price!!, + transaction.product!!.oldPrice!!, + transaction.product!!.totalAmount!!, + transaction.product!!.soldAmount!!, + ProductCategory( + transaction.product!!.productCategory?.id ?: -1L, + transaction.product!!.productCategory?.key, + transaction.product!!.productCategory?.name + ), + organization + ) + } + + + + Transaction( + transaction.id, + organization, + transaction.amount ?: 0f.toBigDecimal(), + transaction.amount_locale, + transaction.amount_extra_cash ?: 0f.toBigDecimal(), + transaction.amount_extra_cash_locale, + transaction.createdAt, + Transaction.Type.valueOf(transaction.type.name), + product + ) + }, + null, + it.voucher.deactivated ?: false, + it.voucher.expired ?: false, + "", + officesList, + it.voucher.amount_visible ?: false + ), + + it.allowedOrganizations.map { organization -> + Organization( + organization.id, + organization.name, + organization.logo, + organization.lat, + organization.lon, + organization.address, + organization.phone, + organization.email ) }, - null, - it.voucher.deactivated ?: false, - it.voucher.expired ?: false, - "", - officesList, - it.voucher.amount_visible ?: false - ), - it.allowedOrganizations.map { organization -> - Organization( - organization.id, - organization.name, - organization.logo, - organization.lat, - organization.lon, - organization.address, - organization.phone, - organization.email - ) - }, - - it.allowedProductCategories.map { productCategory -> - ProductCategory( - productCategory.id, productCategory.key, productCategory.name - ) - }) - }) + it.allowedProductCategories.map { productCategory -> + ProductCategory( + productCategory.id, productCategory.key, productCategory.name + ) + }) + }) } } override fun ProviderModel.changeInitialModel(i: VoucherProvider): ProviderModel { - val organization = if (i.allowedOrganizations.isNotEmpty()) i.allowedOrganizations.get(0) else Organization( - organizationId, - i.voucher.organizationName, - "", - i.voucher.product?.organization?.lat ?: 0.0, - i.voucher.product?.organization?.lon ?: 0.0, - i.voucher.product?.organization?.address ?: "", - i.voucher.product?.organization?.phone ?: "", - i.voucher.product?.organization?.email ?: "" - ) + val organization = + if (i.allowedOrganizations.isNotEmpty()) i.allowedOrganizations.get(0) else Organization( + organizationId, + i.voucher.organizationName, + "", + i.voucher.product?.organization?.lat ?: 0.0, + i.voucher.product?.organization?.lon ?: 0.0, + i.voucher.product?.organization?.address ?: "", + i.voucher.product?.organization?.phone ?: "", + i.voucher.product?.organization?.email ?: "" + ) organizationId = organization.id return copy(item = i, selectedOrganization = organization) } @@ -264,19 +275,29 @@ class ProviderPresenter( intent { it.charge() }.switchMap { amount -> vouchersRepository.makeTransaction( address, amount.first, amount.second, note, organizationId - ).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).map { - firestoreTokenManager.writeTransaction( - address, amount.first, note, organizationId, true, null - ) - ProviderPartialChanges.MakeTransactionEnd() - }.onErrorReturn { throwable -> + ).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) + .map { + firestoreTokenManager.writeTransaction( + address, amount.first, note, organizationId, true, null + ) + ProviderPartialChanges.MakeTransactionEnd() + }.onErrorReturn { throwable -> firestoreTokenManager.writeTransaction( - address, amount.first, note, organizationId, false, throwable.localizedMessage + address, + amount.first, + note, + organizationId, + false, + throwable.localizedMessage ) ProviderPartialChanges.MakeTransactionError(throwable) }.startWith(ProviderPartialChanges.MakeTransactionStart()) }, - intent { it.selectOrganization() }.map { ProviderPartialChanges.SelectOrganization(it) }, + intent { it.selectOrganization() }.map { + ProviderPartialChanges.SelectOrganization( + it + ) + }, intent { it.demoCharge() }.switchMap { vouchersRepository.makeDemoTransaction(address).subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()).map { @@ -288,10 +309,12 @@ class ProviderPresenter( ) - val initialViewState = LRViewState(false, null, false, false, null, false, ProviderModel(), false) + val initialViewState = + LRViewState(false, null, false, false, null, false, ProviderModel(), false) subscribeViewState( - observable.scan(initialViewState, this::stateReducer).observeOn(AndroidSchedulers.mainThread()), + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), ProviderView::render ) } @@ -310,11 +333,15 @@ class ProviderPresenter( ) is ProviderPartialChanges.MakeTransactionStart -> vs.copy( - model = vs.model.copy(sendingMakeTransaction = true, makeTransactionError = null), loading = true + model = vs.model.copy(sendingMakeTransaction = true, makeTransactionError = null), + loading = true ) is ProviderPartialChanges.MakeTransactionError -> vs.copy( - model = vs.model.copy(sendingMakeTransaction = false, makeTransactionError = change.error) + model = vs.model.copy( + sendingMakeTransaction = false, + makeTransactionError = change.error + ) ) is ProviderPartialChanges.SetAmount -> vs.copy( @@ -323,12 +350,22 @@ class ProviderPresenter( is ProviderPartialChanges.SetNote -> { note = change.note - vs.copy(model = vs.model.copy(selectedNote = change.note, makeTransactionError = null)) + vs.copy( + model = vs.model.copy( + selectedNote = change.note, + makeTransactionError = null + ) + ) } is ProviderPartialChanges.SelectOrganization -> { organizationId = change.organization.id - vs.copy(model = vs.model.copy(selectedOrganization = change.organization, makeTransactionError = null)) + vs.copy( + model = vs.model.copy( + selectedOrganization = change.organization, + makeTransactionError = null + ) + ) } } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderViewModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderViewModel.kt index d230aba4d..2f255a1df 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderViewModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/ProviderViewModel.kt @@ -14,9 +14,8 @@ class ProviderViewModelFactory(private val firestoreTokenManager: FirestoreToken } } -class ProviderViewModel constructor(private val firestoreTokenManager: FirestoreTokenManager) : ViewModel() { - - +class ProviderViewModel constructor(private val firestoreTokenManager: FirestoreTokenManager) : + ViewModel() { } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/categories/CategoriesAdapter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/categories/CategoriesAdapter.kt index b6469a83f..fa9b0165a 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/categories/CategoriesAdapter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/categories/CategoriesAdapter.kt @@ -18,8 +18,11 @@ class CategoriesAdapter : RecyclerView.Adapter() { DiffUtil.calculateDiff(object : DiffUtil.Callback() { override fun getOldListSize() = old.size override fun getNewListSize() = field.size - override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] - override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] }).dispatchUpdatesTo(this) notifyDataSetChanged() } @@ -30,7 +33,8 @@ class CategoriesAdapter : RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CategoryVH { - val binding = ItemProductCategoryBinding.inflate(LayoutInflater.from(parent.context), parent, false) + val binding = + ItemProductCategoryBinding.inflate(LayoutInflater.from(parent.context), parent, false) return CategoryVH(binding) } @@ -38,6 +42,7 @@ class CategoriesAdapter : RecyclerView.Adapter() { val item = items[position] holder.bind(item) } + override fun getItemCount() = items.size override fun getItemId(position: Int) = position.toLong() } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/dialogs/ApplyDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/dialogs/ApplyDialog.kt index 33e3db7ac..310cb6ea0 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/dialogs/ApplyDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/dialogs/ApplyDialog.kt @@ -4,18 +4,20 @@ import android.content.Context import com.afollestad.materialdialogs.MaterialDialog import io.forus.me.android.presentation.R -class ApplyDialog(private val context: Context, - private val positiveCallback: () -> Unit) { +class ApplyDialog( + private val context: Context, + private val positiveCallback: () -> Unit +) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title(context.resources.getString(R.string.vouchers_pay_title)) - .content(context.resources.getString(R.string.vouchers_apply_question)) - .positiveText(context.resources.getString(R.string.voucher_request)) - .negativeText(context.resources.getString(R.string.me_cancel)) - .onPositive { dialog, which -> positiveCallback.invoke() } - .build() + .title(context.resources.getString(R.string.vouchers_pay_title)) + .content(context.resources.getString(R.string.vouchers_apply_question)) + .positiveText(context.resources.getString(R.string.voucher_request)) + .negativeText(context.resources.getString(R.string.me_cancel)) + .onPositive { dialog, which -> positiveCallback.invoke() } + .build() - fun show(){ + fun show() { dialog.show() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/dialogs/ChargeDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/dialogs/ChargeDialog.kt index f543018c5..d2c28eb2c 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/dialogs/ChargeDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/dialogs/ChargeDialog.kt @@ -5,31 +5,40 @@ import com.afollestad.materialdialogs.MaterialDialog import io.forus.me.android.presentation.R import java.math.BigDecimal -class ChargeDialog(private val context: Context, - private val chargeAmount: BigDecimal, - private val extra: BigDecimal, - private val positiveCallback: () -> Unit) { +class ChargeDialog( + private val context: Context, + private val chargeAmount: BigDecimal, + private val extra: BigDecimal, + private val positiveCallback: () -> Unit +) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title(context.resources.getString(R.string.vouchers_pay_title)) - .customView(if(extra.compareTo(BigDecimal.ZERO) == 0) R.layout.view_provider_charge else R.layout.view_provider_charge_extra, false) - .positiveText(context.resources.getString(R.string.voucher_request)) - .negativeText(context.resources.getString(R.string.me_cancel)) - .onPositive { dialog, which -> positiveCallback.invoke() } - .build() + .title(context.resources.getString(R.string.vouchers_pay_title)) + .customView( + if (extra.compareTo(BigDecimal.ZERO) == 0) R.layout.view_provider_charge else R.layout.view_provider_charge_extra, + false + ) + .positiveText(context.resources.getString(R.string.voucher_request)) + .negativeText(context.resources.getString(R.string.me_cancel)) + .onPositive { dialog, which -> positiveCallback.invoke() } + .build() init { val view = dialog.customView - val tvCharge = view?.findViewById(R.id.tv_charge) - val tvExtra = view?.findViewById(R.id.tv_extra) + val tvCharge = + view?.findViewById(R.id.tv_charge) + val tvExtra = + view?.findViewById(R.id.tv_extra) - tvCharge?.text = context.resources.getString(R.string.vouchers_pay_question, chargeAmount.toString()) - if(extra.compareTo(BigDecimal.ZERO) != 0){ - tvExtra?.text = context.resources.getString(R.string.vouchers_pay_question_extra, extra.toString()) + tvCharge?.text = + context.resources.getString(R.string.vouchers_pay_question, chargeAmount.toString()) + if (extra.compareTo(BigDecimal.ZERO) != 0) { + tvExtra?.text = + context.resources.getString(R.string.vouchers_pay_question_extra, extra.toString()) } } - fun show(){ + fun show() { dialog.show() } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/dialogs/organizations_dialog/OrganizationsAdapter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/dialogs/organizations_dialog/OrganizationsAdapter.kt index ff3673f65..eff77e0a6 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/dialogs/organizations_dialog/OrganizationsAdapter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/dialogs/organizations_dialog/OrganizationsAdapter.kt @@ -8,16 +8,25 @@ import io.forus.me.android.presentation.R import io.forus.me.android.presentation.models.vouchers.Organization -class OrganizationsAdapter(var items: List, val callback: Callback) : RecyclerView.Adapter() { - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = MainHolder(LayoutInflater.from(parent.context).inflate(R.layout.view_organization, parent, false)) +class OrganizationsAdapter(var items: List, val callback: Callback) : + RecyclerView.Adapter() { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = MainHolder( + LayoutInflater.from(parent.context).inflate(R.layout.view_organization, parent, false) + ) + override fun getItemCount() = items.size override fun onBindViewHolder(holder: MainHolder, position: Int) { holder.bind(items[position]) } inner class MainHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { - private val iv_organization_icon = itemView.findViewById(R.id.iv_organization_icon) - private val tv_organization_name = itemView.findViewById(R.id.tv_organization_name) + private val iv_organization_icon = + itemView.findViewById( + R.id.iv_organization_icon + ) + private val tv_organization_name = + itemView.findViewById(R.id.tv_organization_name) + fun bind(item: Organization) { tv_organization_name.text = item.name if (item.logo?.isBlank() != true) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/dialogs/organizations_dialog/OrganizationsListDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/dialogs/organizations_dialog/OrganizationsListDialog.kt index be03a628c..e1292b1e6 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/dialogs/organizations_dialog/OrganizationsListDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/provider/dialogs/organizations_dialog/OrganizationsListDialog.kt @@ -8,15 +8,17 @@ import io.forus.me.android.presentation.R import io.forus.me.android.presentation.models.vouchers.Organization -class OrganizationsListDialog(private val context: Context, - private val organizations: List, - private val selectItemCallback: (Organization) -> Unit) { +class OrganizationsListDialog( + private val context: Context, + private val organizations: List, + private val selectItemCallback: (Organization) -> Unit +) { private val dialog: MaterialDialog = MaterialDialog.Builder(context) - .title(context.resources.getString(R.string.voucher_dialog_choose_organization)) - .customView(R.layout.view_organizations_list, true) - .negativeText(context.resources.getString(R.string.me_cancel)) - .build() + .title(context.resources.getString(R.string.voucher_dialog_choose_organization)) + .customView(R.layout.view_organizations_list, true) + .negativeText(context.resources.getString(R.string.me_cancel)) + .build() init { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/transactions_log/TransactionsFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/transactions_log/TransactionsFragment.kt index 717a17fd1..9ad50997f 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/transactions_log/TransactionsFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/transactions_log/TransactionsFragment.kt @@ -174,7 +174,10 @@ class TransactionsFragment : Fragment(), DatePickerDialog.OnDateSetListener { fun showPopupTransactionDetailsFragment(transaction: Transaction) { val transactionDetailsPopupDialog = TransactionDetailsPopupDialog(transaction) - transactionDetailsPopupDialog.show(requireActivity().supportFragmentManager, "TransactionDetailsPopupDialog") + transactionDetailsPopupDialog.show( + requireActivity().supportFragmentManager, + "TransactionDetailsPopupDialog" + ) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/transactions_log/adapter/TransactionsLogAdapter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/transactions_log/adapter/TransactionsLogAdapter.kt index aedd5a7c4..070fc9d3c 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/transactions_log/adapter/TransactionsLogAdapter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/transactions_log/adapter/TransactionsLogAdapter.kt @@ -12,8 +12,10 @@ import io.forus.me.android.presentation.view.screens.vouchers.transactions_log.u import java.text.SimpleDateFormat import java.util.Locale -class TransactionsLogAdapter(val context: Context, var items: ArrayList, - val callback: Callback) : RecyclerView.Adapter() { +class TransactionsLogAdapter( + val context: Context, var items: ArrayList, + val callback: Callback +) : RecyclerView.Adapter() { private val LOADING = 0 private val ITEM = 1 @@ -21,8 +23,9 @@ class TransactionsLogAdapter(val context: Context, var items: ArrayList overline2.text = context.getString(R.string.status_success) "pending" -> overline2.text = context.getString(R.string.status_pending) - else -> overline2.text = "++" + else -> overline2.text = "++" } root.setOnClickListener { callback.onItemClicked(item) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/transactions_log/details/TransactionDetailsPopupDialog.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/transactions_log/details/TransactionDetailsPopupDialog.kt index 2763e1e15..9a3199eae 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/transactions_log/details/TransactionDetailsPopupDialog.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/transactions_log/details/TransactionDetailsPopupDialog.kt @@ -67,7 +67,10 @@ class TransactionDetailsPopupDialog( try { dismiss() } catch (e: IllegalStateException) { - Log.e("TransactionDetailsPopupDialog", "Error while dismissing TransactionDetailsPopupDialog: ${e.message}") + Log.e( + "TransactionDetailsPopupDialog", + "Error while dismissing TransactionDetailsPopupDialog: ${e.message}" + ) } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/transactions_log/viewmodels/TransactionsLogViewModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/transactions_log/viewmodels/TransactionsLogViewModel.kt index c7c95d7eb..6eb88e85e 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/transactions_log/viewmodels/TransactionsLogViewModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/transactions_log/viewmodels/TransactionsLogViewModel.kt @@ -19,8 +19,8 @@ class TransactionsLogViewModel : ViewModel() { var transactionsLiveData: MutableLiveData> = MutableLiveData() - lateinit var dateFormatForDisplay :SimpleDateFormat - lateinit var dateFormatForApi :SimpleDateFormat + lateinit var dateFormatForDisplay: SimpleDateFormat + lateinit var dateFormatForApi: SimpleDateFormat val progress = MutableLiveData() @@ -37,7 +37,6 @@ class TransactionsLogViewModel : ViewModel() { val calendarStringForApi = MutableLiveData() - init { progress.value = true @@ -60,7 +59,7 @@ class TransactionsLogViewModel : ViewModel() { } - fun setCalendar(cal: Calendar){ + fun setCalendar(cal: Calendar) { calendarFrom.value = cal calendarStringForDisplay.value = (dateFormatForDisplay.format(calendarFrom.value!!.time)) @@ -73,19 +72,19 @@ class TransactionsLogViewModel : ViewModel() { fun getTransactions(page: Int) { progress.postValue(true) vouchersRepository.getTransactionsLogAsProvider(calendarStringForApi.value!!, page, perPage) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - progress.postValue(false) - val arr: MutableList = mutableListOf() - arr.addAll(it) - transactionsLiveData.postValue(arr) - - } - .onErrorReturn { - progress.postValue(false) - } - .subscribe() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + progress.postValue(false) + val arr: MutableList = mutableListOf() + arr.addAll(it) + transactionsLiveData.postValue(arr) + + } + .onErrorReturn { + progress.postValue(false) + } + .subscribe() } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/ActionsActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/ActionsActivity.kt index 63c5e22b3..134f31d26 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/ActionsActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/ActionsActivity.kt @@ -29,7 +29,8 @@ import io.forus.me.android.presentation.view.screens.vouchers.voucher_with_actio class ActionsActivity : AppCompatActivity() { private var toolbar_title: TextView? = null - private var profile_button: io.forus.me.android.presentation.view.component.images.AutoLoadImageView? = null + private var profile_button: io.forus.me.android.presentation.view.component.images.AutoLoadImageView? = + null companion object { @@ -155,7 +156,8 @@ class ActionsActivity : AppCompatActivity() { binding.recycler.layoutManager = linearLayoutManager binding.recycler.adapter = transactionsAdapter - binding.recycler.addOnScrollListener(object : PaginationScrollListener(linearLayoutManager) { + binding.recycler.addOnScrollListener(object : + PaginationScrollListener(linearLayoutManager) { override fun isLastPage(): Boolean { return this@ActionsActivity.isLastPage } @@ -196,25 +198,26 @@ class ActionsActivity : AppCompatActivity() { binding.organizationsSpinner.adapter = adapter binding.organizationsSpinner.setSelection(0, false); - binding.organizationsSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { - override fun onNothingSelected(p0: AdapterView<*>?) {} + binding.organizationsSpinner.onItemSelectedListener = + object : AdapterView.OnItemSelectedListener { + override fun onNothingSelected(p0: AdapterView<*>?) {} - override fun onItemSelected(p0: AdapterView<*>?, view: View?, p2: Int, p3: Long) { + override fun onItemSelected(p0: AdapterView<*>?, view: View?, p2: Int, p3: Long) { - if (canWork) { - canWork = false - val tv = view as androidx.appcompat.widget.AppCompatTextView - val orgName = tv.text.toString() + if (canWork) { + canWork = false + val tv = view as androidx.appcompat.widget.AppCompatTextView + val orgName = tv.text.toString() - val id = mainViewModel.selectedOrgIdByName(orgName) - transactionsAdapter!!.clearAll() - currentPage = 1 - mainViewModel.getVoucherActionGoods(currentPage) - this@ActionsActivity.currentPage += 1; + val id = mainViewModel.selectedOrgIdByName(orgName) + transactionsAdapter!!.clearAll() + currentPage = 1 + mainViewModel.getVoucherActionGoods(currentPage) + this@ActionsActivity.currentPage += 1; + } } - } - } + } } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/adapter/ActionsAdapter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/adapter/ActionsAdapter.kt index 31e50fd00..00bb00018 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/adapter/ActionsAdapter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/adapter/ActionsAdapter.kt @@ -13,14 +13,19 @@ import io.forus.me.android.domain.models.vouchers.ProductAction import io.forus.me.android.presentation.R -class ActionsAdapter(var items: ArrayList, val callback: Callback, val context: Context) : RecyclerView.Adapter() { +class ActionsAdapter( + var items: ArrayList, + val callback: Callback, + val context: Context +) : RecyclerView.Adapter() { private val LOADING = 0 private val ITEM = 1 private var isLoadingAdded = false - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = MainHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_action, parent, false)) + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = + MainHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_action, parent, false)) override fun getItemCount() = items.size @@ -40,12 +45,11 @@ class ActionsAdapter(var items: ArrayList, val callback: Callback priceTV.text = item.priceUserLocale - val url = item.photoURL if (url != null && url.isNotEmpty()) { Glide.with(context).load(url) - .diskCacheStrategy(DiskCacheStrategy.ALL) - .into(icon) + .diskCacheStrategy(DiskCacheStrategy.ALL) + .into(icon) } itemView.setOnClickListener { diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/model/ActionsViewModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/model/ActionsViewModel.kt index a21fa6cb1..4226d3a0a 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/model/ActionsViewModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/model/ActionsViewModel.kt @@ -1,4 +1,5 @@ package io.forus.me.android.presentation.view.screens.vouchers.voucher_with_actions.model + import android.view.View import android.widget.AdapterView import androidx.lifecycle.MutableLiveData @@ -66,9 +67,9 @@ class ActionsViewModel : ViewModel() { fun onSelectItem(parent: AdapterView<*>?, view: View?, pos: Int, id: Long) { - if(init){ + if (init) { init = false - }else { + } else { val tv = view as androidx.appcompat.widget.AppCompatTextView @@ -78,11 +79,11 @@ class ActionsViewModel : ViewModel() { } } - - fun selectedOrgIdByName(name: String) : Long?{ - if(voucher.value == null) return null - for(org in voucher.value!!.allowedOrganizations){ - if(org.name == name){ + + fun selectedOrgIdByName(name: String): Long? { + if (voucher.value == null) return null + for (org in voucher.value!!.allowedOrganizations) { + if (org.name == name) { organizationId = org.id return org.id } @@ -92,56 +93,62 @@ class ActionsViewModel : ViewModel() { public fun getVoucherDetails() { - vouchersRepository.getVoucherAsProvider(voucherAddress?:"") - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { + vouchersRepository.getVoucherAsProvider(voucherAddress ?: "") + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { - firestoreTokenManager.writeGetVoucherAsProvider( - voucherAddress?:"null", true, null) + firestoreTokenManager.writeGetVoucherAsProvider( + voucherAddress ?: "null", true, null + ) - actionName.postValue(it.voucher.name?:"") - organizationId = it.allowedOrganizations[0].id - fundName.postValue(it.voucher.organizationName?:"") + actionName.postValue(it.voucher.name ?: "") + organizationId = it.allowedOrganizations[0].id + fundName.postValue(it.voucher.organizationName ?: "") - voucher.postValue(it) - } - .onErrorReturn { - firestoreTokenManager.writeGetVoucherAsProvider( - voucherAddress?:"null", false, it.localizedMessage - ) - } - .subscribe() + voucher.postValue(it) + } + .onErrorReturn { + firestoreTokenManager.writeGetVoucherAsProvider( + voucherAddress ?: "null", false, it.localizedMessage + ) + } + .subscribe() } - public fun getVoucherActionGoods( page: Int) { + public fun getVoucherActionGoods(page: Int) { if (organizationId != null) { - vouchersRepository.getVoucherProductsActionsAsProvider(voucherAddress!!, organizationId!!, page, perPage) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - val arr: MutableList = mutableListOf() - arr.addAll(it) - productActionsLiveData.postValue(arr) - init = true - - - if(productActionsLiveData.value != null) { - if (productActionsLiveData.value!!.isEmpty()) { - productsListIsEmpty.postValue(true) - } else { - productsListIsEmpty.postValue(false) - - } - }else { + vouchersRepository.getVoucherProductsActionsAsProvider( + voucherAddress!!, + organizationId!!, + page, + perPage + ) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + val arr: MutableList = mutableListOf() + arr.addAll(it) + productActionsLiveData.postValue(arr) + init = true + + + if (productActionsLiveData.value != null) { + if (productActionsLiveData.value!!.isEmpty()) { productsListIsEmpty.postValue(true) - } + } else { + productsListIsEmpty.postValue(false) + } + } else { + productsListIsEmpty.postValue(true) } - .onErrorReturn { - } - .subscribe() + } + .onErrorReturn { + + } + .subscribe() } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/ActionPaymentActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/ActionPaymentActivity.kt index d9b9cc483..b60205be5 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/ActionPaymentActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/ActionPaymentActivity.kt @@ -25,7 +25,11 @@ class ActionPaymentActivity : BaseActivity() { const val VOUCHER_ADDRESS_EXTRA = "VOUCHER_ADDRESS_EXTRA" - fun getCallingIntent(context: Context, product: ProductSerializable, voucherAddress: String): Intent { + fun getCallingIntent( + context: Context, + product: ProductSerializable, + voucherAddress: String + ): Intent { val intent = Intent(context, ActionPaymentActivity::class.java) val bundle = Bundle() bundle.putSerializable(ACTION_PRODUCT_EXTRA, product) @@ -57,19 +61,28 @@ class ActionPaymentActivity : BaseActivity() { val intent = this.intent intent.extras.let { product = it?.getSerializable(ACTION_PRODUCT_EXTRA) as ProductSerializable - voucherAddress = intent.getSerializableExtra(ActionsActivity.VOUCHER_ADDRESS_EXTRA) as String + voucherAddress = + intent.getSerializableExtra(ActionsActivity.VOUCHER_ADDRESS_EXTRA) as String } product.let { - replaceFragment(R.id.dashboard_content, ActionPaymentFragment.newIntent(product!!, voucherAddress!! - )) + replaceFragment( + R.id.dashboard_content, ActionPaymentFragment.newIntent( + product!!, voucherAddress!! + ) + ) } toolbar_title?.text = getString(R.string.payment) - profile_button?.setImageDrawable(ContextCompat.getDrawable(this@ActionPaymentActivity, R.drawable.ic_back)) + profile_button?.setImageDrawable( + ContextCompat.getDrawable( + this@ActionPaymentActivity, + R.drawable.ic_back + ) + ) profile_button?.setOnClickListener { finish() } @@ -82,5 +95,4 @@ class ActionPaymentActivity : BaseActivity() { } - } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/ActionPaymentViewModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/ActionPaymentViewModel.kt index c1e2c32bc..a54df859e 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/ActionPaymentViewModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/ActionPaymentViewModel.kt @@ -33,8 +33,8 @@ class ActionPaymentViewModel(application: Application) : AndroidViewModel(applic val successPayment = MutableLiveData() val errorPayment = MutableLiveData() - val commitButtonEnable = MutableLiveData() - val commitButtonAlpha = MutableLiveData() + val commitButtonEnable = MutableLiveData() + val commitButtonAlpha = MutableLiveData() val progress = MutableLiveData() @@ -69,8 +69,6 @@ class ActionPaymentViewModel(application: Application) : AndroidViewModel(applic } - - private fun refreshUI() { @@ -84,18 +82,18 @@ class ActionPaymentViewModel(application: Application) : AndroidViewModel(applic progress.postValue(true) commitButtonEnable.postValue(false) - vouchersRepository.makeActionTransaction(voucherAddress!!, note.value ?: "", product!!.id) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .map { - progress.postValue(false) - successPayment.postValue(true) - } - .onErrorReturn { - progress.postValue(false) - errorPayment.postValue(it) - } - .subscribe() + vouchersRepository.makeActionTransaction(voucherAddress!!, note.value ?: "", product!!.id) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .map { + progress.postValue(false) + successPayment.postValue(true) + } + .onErrorReturn { + progress.postValue(false) + errorPayment.postValue(it) + } + .subscribe() } @@ -110,9 +108,15 @@ class ActionPaymentViewModel(application: Application) : AndroidViewModel(applic } - fun setCommitButtonEnable(enable:Boolean){ + fun setCommitButtonEnable(enable: Boolean) { commitButtonEnable.value = enable - commitButtonAlpha.postValue(if(enable){1.0f}else{0.6f}) + commitButtonAlpha.postValue( + if (enable) { + 1.0f + } else { + 0.6f + } + ) } /** diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/PriceType.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/PriceType.kt index cf5e1f837..2d8940ebc 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/PriceType.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/PriceType.kt @@ -1,5 +1,5 @@ package io.forus.me.android.presentation.view.screens.vouchers.voucher_with_actions.payment enum class PriceType { - free , regular, discount_percentage, discount_fixed + free, regular, discount_percentage, discount_fixed } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/ProductSerializable.java b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/ProductSerializable.java index e941beec0..99fad0f61 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/ProductSerializable.java +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/ProductSerializable.java @@ -27,10 +27,10 @@ public class ProductSerializable implements Serializable { public ProductSerializable(long id, String name, String companyName, long companyId, BigDecimal price, BigDecimal priceUser, - String priceType, BigDecimal priceDiscount, - String priceLocale,String priceUserLocale, + String priceType, BigDecimal priceDiscount, + String priceLocale, String priceUserLocale, BigDecimal sponsorSubsidy, String sponsorName, - String photoURL) { + String photoURL) { this.id = id; this.name = name; this.price = price; diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/popup/PriceAgreementFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/popup/PriceAgreementFragment.kt index 620ceccf8..7cb5234a3 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/popup/PriceAgreementFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/popup/PriceAgreementFragment.kt @@ -23,12 +23,14 @@ class PriceAgreementFragment : BaseFragment() { const val ACTION_PRODUCT_EXTRA = "ACTION_PRODUCT_EXTRA" - fun newIntent(product: ProductSerializable): PriceAgreementFragment = PriceAgreementFragment().also { - val bundle = Bundle() - bundle.putSerializable(ACTION_PRODUCT_EXTRA, product) - it.arguments = bundle - } + fun newIntent(product: ProductSerializable): PriceAgreementFragment = + PriceAgreementFragment().also { + val bundle = Bundle() + bundle.putSerializable(ACTION_PRODUCT_EXTRA, product) + it.arguments = bundle + } } + override fun getLayoutID(): Int { return R.layout.fragment_price_agreement } @@ -36,11 +38,16 @@ class PriceAgreementFragment : BaseFragment() { var product: ProductSerializable? = null - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - return super.onCreateView(inflater, container, savedInstanceState).also{ + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + return super.onCreateView(inflater, container, savedInstanceState).also { val bundle = this.arguments if (bundle != null) { - product = bundle.getSerializable(ActionPaymentFragment.ACTION_PRODUCT_EXTRA) as ProductSerializable + product = + bundle.getSerializable(ActionPaymentFragment.ACTION_PRODUCT_EXTRA) as ProductSerializable } binding = FragmentPriceAgreementBinding.inflate(inflater) diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/popup/PriceAgreementViewModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/popup/PriceAgreementViewModel.kt index d0b0469dd..16da784f8 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/popup/PriceAgreementViewModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/vouchers/voucher_with_actions/payment/popup/PriceAgreementViewModel.kt @@ -13,7 +13,8 @@ import io.forus.me.android.presentation.view.screens.vouchers.voucher_with_actio import java.math.BigDecimal -class PriceAgreementViewModel(application: Application) : AndroidViewModel(application), Observable { +class PriceAgreementViewModel(application: Application) : AndroidViewModel(application), + Observable { private var product: ProductSerializable? = null @@ -84,68 +85,75 @@ class PriceAgreementViewModel(application: Application) : AndroidViewModel(appli totalPriceVisiblity.value = product!!.priceType == PriceType.regular.name discountProviderVisiblity.value = - product!!.priceType == PriceType.discount_percentage.name || - product!!.priceType == PriceType.discount_fixed.name + product!!.priceType == PriceType.discount_percentage.name || + product!!.priceType == PriceType.discount_fixed.name contributionSponsorVisiblity.value = //(!(product!!.priceType == PriceType.discount_percentage.name || - // product!!.priceType == PriceType.free.name)) && - ( product!!.sponsorSubsidy != null && - product!!.sponsorSubsidy > BigDecimal.ZERO) + // product!!.priceType == PriceType.free.name)) && + (product!!.sponsorSubsidy != null && + product!!.sponsorSubsidy > BigDecimal.ZERO) totalAmountVisiblity.value = product!!.priceType == PriceType.regular.name priceAgreementVisiblity.value = totalPriceVisiblity.value!! || - discountProviderVisiblity.value!! || contributionSponsorVisiblity.value!! || + discountProviderVisiblity.value!! || contributionSponsorVisiblity.value!! || totalAmountVisiblity.value!! - if(product!!.priceType == PriceType.regular.name ){ + if (product!!.priceType == PriceType.regular.name) { - if(product!!.price == product!!.sponsorSubsidy){ + if (product!!.price == product!!.sponsorSubsidy) { headTitle.value = "" headPrice.value = resources.getString(R.string.free) - }else{ + } else { headTitle.value = resources.getString(R.string.price_agreement_client_price) headPrice.value = Converter.convertBigDecimalToStringNL(product!!.priceUser) } - if(product!!.price != null){ + if (product!!.price != null) { totalPrice.value = Converter.convertBigDecimalToStringNL(product!!.price) } } - if(product!!.priceType == PriceType.free.name){ + if (product!!.priceType == PriceType.free.name) { headTitle.value = "" headPrice.value = resources.getString(R.string.free) } - userPrice.value = headPrice.value + userPrice.value = headPrice.value - if(product!!.priceType == PriceType.discount_percentage.name ){ - discountByProviderPrice.value = Converter.convertBigDecimalToDiscountString(product!!.priceDiscount) - if(product!!.sponsorSubsidy != null&& - product!!.sponsorSubsidy > BigDecimal.ZERO){ - contributionBySponsorPrice.value = Converter.convertBigDecimalToStringNL(product!!.sponsorSubsidy) + if (product!!.priceType == PriceType.discount_percentage.name) { + discountByProviderPrice.value = + Converter.convertBigDecimalToDiscountString(product!!.priceDiscount) + if (product!!.sponsorSubsidy != null && + product!!.sponsorSubsidy > BigDecimal.ZERO + ) { + contributionBySponsorPrice.value = + Converter.convertBigDecimalToStringNL(product!!.sponsorSubsidy) } } - if(product!!.priceType == PriceType.discount_fixed.name - || product!!.priceType == PriceType.regular.name){ - if(product!!.priceDiscount != null && - product!!.priceDiscount > BigDecimal.ZERO ) { - discountByProviderPrice.value = Converter.convertBigDecimalToStringNL(product!!.priceDiscount) + if (product!!.priceType == PriceType.discount_fixed.name + || product!!.priceType == PriceType.regular.name + ) { + if (product!!.priceDiscount != null && + product!!.priceDiscount > BigDecimal.ZERO + ) { + discountByProviderPrice.value = + Converter.convertBigDecimalToStringNL(product!!.priceDiscount) } - if(product!!.sponsorSubsidy != null && - product!!.sponsorSubsidy > BigDecimal.ZERO){ + if (product!!.sponsorSubsidy != null && + product!!.sponsorSubsidy > BigDecimal.ZERO + ) { - contributionBySponsorPrice.value =Converter.convertBigDecimalToStringNL(product!!.sponsorSubsidy) - + contributionBySponsorPrice.value = + Converter.convertBigDecimalToStringNL(product!!.sponsorSubsidy) } @@ -153,8 +161,10 @@ class PriceAgreementViewModel(application: Application) : AndroidViewModel(appli - contributionBySponsorName.value = resources.getString(R.string.price_agreement_sponsor_pays_you, - product!!.sponsorName) + contributionBySponsorName.value = resources.getString( + R.string.price_agreement_sponsor_pays_you, + product!!.sponsorName + ) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/WalletsAdapter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/WalletsAdapter.kt index 8b355f2a1..58ee17d6b 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/WalletsAdapter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/WalletsAdapter.kt @@ -17,13 +17,16 @@ class WalletsAdapter : RecyclerView.Adapter() { DiffUtil.calculateDiff(object : DiffUtil.Callback() { override fun getOldListSize() = old.size override fun getNewListSize() = field.size - override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] - override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = old[oldItemPosition] == field[newItemPosition] + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = + old[oldItemPosition] == field[newItemPosition] }).dispatchUpdatesTo(this) notifyDataSetChanged() } - + init { setHasStableIds(true) } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/WalletsFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/WalletsFragment.kt index f7737bddb..fb4653793 100755 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/WalletsFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/WalletsFragment.kt @@ -15,7 +15,8 @@ import io.forus.me.android.presentation.view.base.lr.LRViewState /** * Fragment Assign Delegates Screen. */ -class WalletsFragment : LRFragment(), WalletsView, FragmentListener { +class WalletsFragment : LRFragment(), WalletsView, + FragmentListener { companion object { fun newIntent(): WalletsFragment { @@ -33,8 +34,11 @@ class WalletsFragment : LRFragment( private lateinit var binding: FragmentRecyclerBinding - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View - { + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { binding = FragmentRecyclerBinding.inflate(inflater) @@ -57,7 +61,7 @@ class WalletsFragment : LRFragment( override fun createPresenter() = WalletsPresenter( - Injection.instance.walletsRepository + Injection.instance.walletsRepository ) @@ -68,8 +72,6 @@ class WalletsFragment : LRFragment( adapter.wallets = vs.model.items - - } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/WalletsModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/WalletsModel.kt index 56222ce7c..eeb1dc31e 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/WalletsModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/WalletsModel.kt @@ -3,5 +3,5 @@ package io.forus.me.android.presentation.view.screens.wallets import io.forus.me.android.domain.models.wallets.Wallet data class WalletsModel( - val items: List = emptyList() - ) \ No newline at end of file + val items: List = emptyList() +) \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/WalletsPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/WalletsPresenter.kt index 4009aacbd..fa18834f2 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/WalletsPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/WalletsPresenter.kt @@ -9,10 +9,12 @@ import io.reactivex.Single import io.reactivex.android.schedulers.AndroidSchedulers -class WalletsPresenter constructor(val walletsRepository: WalletsRepository) : LRPresenter, WalletsModel, WalletsView>() { +class WalletsPresenter constructor(val walletsRepository: WalletsRepository) : + LRPresenter, WalletsModel, WalletsView>() { - override fun initialModelSingle(): Single> = Single.fromObservable(walletsRepository.getWallets()) + override fun initialModelSingle(): Single> = + Single.fromObservable(walletsRepository.getWallets()) //.delay(1, TimeUnit.SECONDS) .map { it @@ -33,26 +35,31 @@ class WalletsPresenter constructor(val walletsRepository: WalletsRepository) : L val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - WalletsModel(), - false) + false, + null, + false, + false, + null, + false, + WalletsModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - WalletsView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + WalletsView::render + ) // val observable = loadRefreshPartialChanges() // val initialViewState = LRViewState(false, null, false, false, null, MapModel("", "" )) // subscribeViewState(observable.scan(initialViewState, this::stateReducer).observeOn(AndroidSchedulers.mainThread()),MapView::render) } - override fun stateReducer(viewState: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + viewState: LRViewState, + change: PartialChange + ): LRViewState { if (change !is WalletsPartialChanges) return super.stateReducer(viewState, change) @@ -66,13 +73,4 @@ class WalletsPresenter constructor(val walletsRepository: WalletsRepository) : L } - - - - - - - - - } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/item/WalletDetailsFragment.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/item/WalletDetailsFragment.kt index 3687109fb..0817e0ab7 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/item/WalletDetailsFragment.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/item/WalletDetailsFragment.kt @@ -14,7 +14,9 @@ import io.forus.me.android.presentation.view.fragment.ToolbarLRFragment //import kotlinx.android.synthetic.main.fragment_wallet_details.* -class WalletDetailsFragment : ToolbarLRFragment(), WalletDetailsView{ +class WalletDetailsFragment : + ToolbarLRFragment(), + WalletDetailsView { companion object { private val WALLET_ID_EXTRA = "WALLET_ID_EXTRA" @@ -37,13 +39,17 @@ class WalletDetailsFragment : ToolbarLRFragment) { super.render(vs) val item = vs.model.item - binding.tvBalanceCrypto.text = if(item != null) ""+item.balance.format(5)+" "+item.currency?.name else "" - binding.tvBalanceFiat.text = resources.getString(R.string.wallet_balance_fiat, (item?.balance?.times(244.60)).format(2), (item?.balance?.times(281.60)).format(2)) + binding.tvBalanceCrypto.text = + if (item != null) "" + item.balance.format(5) + " " + item.currency?.name else "" + binding.tvBalanceFiat.text = resources.getString( + R.string.wallet_balance_fiat, + (item?.balance?.times(244.60)).format(2), + (item?.balance?.times(281.60)).format(2) + ) binding.ivLogo.setImageUrl(item?.logoUrl) } } \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/item/WalletDetailsModel.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/item/WalletDetailsModel.kt index 6996bfbff..d2b6a5270 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/item/WalletDetailsModel.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/item/WalletDetailsModel.kt @@ -5,8 +5,8 @@ import io.forus.me.android.domain.models.wallets.Transaction import io.forus.me.android.domain.models.wallets.Wallet data class WalletDetailsModel( - val item: Wallet? = null, - val transactions: List = emptyList(), - val creatingQrCode: Boolean = false, - val qrCode: Bitmap? = null + val item: Wallet? = null, + val transactions: List = emptyList(), + val creatingQrCode: Boolean = false, + val qrCode: Bitmap? = null ) \ No newline at end of file diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/item/WalletDetailsPresenter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/item/WalletDetailsPresenter.kt index 77aafd7cc..947c0f572 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/item/WalletDetailsPresenter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/wallets/item/WalletDetailsPresenter.kt @@ -12,23 +12,27 @@ import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.functions.BiFunction import io.reactivex.subjects.PublishSubject -class WalletDetailsPresenter constructor(private val walletId: Long, private val walletsRepository: WalletsRepository) : LRPresenter() { +class WalletDetailsPresenter constructor( + private val walletId: Long, + private val walletsRepository: WalletsRepository +) : LRPresenter() { override fun initialModelSingle(): Single = Single.zip( - Single.fromObservable(walletsRepository.getWallet(walletId)), - Single.fromObservable(walletsRepository.getTransactions(walletId)), - BiFunction { wallet: Wallet, transactions: List -> - WalletDetailsModel(wallet, transactions) - } + Single.fromObservable(walletsRepository.getWallet(walletId)), + Single.fromObservable(walletsRepository.getTransactions(walletId)), + BiFunction { wallet: Wallet, transactions: List -> + WalletDetailsModel(wallet, transactions) + } ) - override fun WalletDetailsModel.changeInitialModel(i: WalletDetailsModel): WalletDetailsModel = copy(item = i.item, transactions = i.transactions).also { - if(i.item?.address != null && i.item.address.isNotEmpty()) { - loadQrCode.onNext(i.item.address) + override fun WalletDetailsModel.changeInitialModel(i: WalletDetailsModel): WalletDetailsModel = + copy(item = i.item, transactions = i.transactions).also { + if (i.item?.address != null && i.item.address.isNotEmpty()) { + loadQrCode.onNext(i.item.address) + } } - } private val loadQrCode = PublishSubject.create() private fun loadQrCode(): Observable = loadQrCode @@ -58,28 +62,44 @@ class WalletDetailsPresenter constructor(private val walletId: Long, private val val initialViewState = LRViewState( - false, - null, - false, - false, - null, - false, - WalletDetailsModel(), - false) + false, + null, + false, + false, + null, + false, + WalletDetailsModel(), + false + ) subscribeViewState( - observable.scan(initialViewState, this::stateReducer) - .observeOn(AndroidSchedulers.mainThread()), - WalletDetailsView::render) + observable.scan(initialViewState, this::stateReducer) + .observeOn(AndroidSchedulers.mainThread()), + WalletDetailsView::render + ) } - override fun stateReducer(vs: LRViewState, change: PartialChange): LRViewState { + override fun stateReducer( + vs: LRViewState, + change: PartialChange + ): LRViewState { if (change !is WalletDetailsPartialChanges) return super.stateReducer(vs, change) return when (change) { - is WalletDetailsPartialChanges.CreateQrCodeStart -> vs.copy(model = vs.model.copy(creatingQrCode = true, qrCode = null)) - is WalletDetailsPartialChanges.CreateQrCodeEnd -> vs.copy(model = vs.model.copy(creatingQrCode = false, qrCode = change.bitmap)) + is WalletDetailsPartialChanges.CreateQrCodeStart -> vs.copy( + model = vs.model.copy( + creatingQrCode = true, + qrCode = null + ) + ) + + is WalletDetailsPartialChanges.CreateQrCodeEnd -> vs.copy( + model = vs.model.copy( + creatingQrCode = false, + qrCode = change.bitmap + ) + ) } } diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/welcome/WelcomeActivity.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/welcome/WelcomeActivity.kt index 3664d8a10..79b101fc1 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/welcome/WelcomeActivity.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/welcome/WelcomeActivity.kt @@ -16,7 +16,7 @@ import io.forus.me.android.presentation.view.screens.welcome.adapter.SectionPage class WelcomeActivity : BaseActivity() { private var mustGoToLogin = false - + private lateinit var binding: ActivityWelcomeBinding override fun onCreate(savedInstanceState: Bundle?) { @@ -41,7 +41,7 @@ class WelcomeActivity : BaseActivity() { binding.backBt.setOnClickListener { if (viewPager.currentItem == 0) { exitWelcome() - }else{ + } else { val nextItem = viewPager.currentItem - 1 if (nextItem >= 0) { viewPager.currentItem = nextItem @@ -99,8 +99,8 @@ class WelcomeActivity : BaseActivity() { .alpha(1.0f) .start() } - } else if (position == 4) { - if(mustGoToLogin) { + } else if (position == 4) { + if (mustGoToLogin) { binding.cbCheckBox.apply { visibility = View.VISIBLE alpha = 0.0f @@ -109,11 +109,10 @@ class WelcomeActivity : BaseActivity() { .alpha(1.0f) .start() } - }else{ + } else { binding.cbCheckBox.visibility = View.GONE } - } - else { + } else { binding.btSkipTutorial.animate() .setDuration(200) .alpha(0.0f) @@ -140,6 +139,7 @@ class WelcomeActivity : BaseActivity() { .alpha(0.0f) .withEndAction { visibility = View.GONE } .start() + 1 -> { visibility = View.VISIBLE alpha = 0.0f diff --git a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/welcome/adapter/SectionPagerAdapter.kt b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/welcome/adapter/SectionPagerAdapter.kt index 258c61aa8..ad2210195 100644 --- a/presentation/src/main/java/io/forus/me/android/presentation/view/screens/welcome/adapter/SectionPagerAdapter.kt +++ b/presentation/src/main/java/io/forus/me/android/presentation/view/screens/welcome/adapter/SectionPagerAdapter.kt @@ -9,7 +9,7 @@ import io.forus.me.android.presentation.view.screens.welcome.pages.WelcomeFragme import io.forus.me.android.presentation.view.screens.welcome.pages.WelcomeFragment4 import io.forus.me.android.presentation.view.screens.welcome.pages.WelcomeFragment5 -class SectionPagerAdapter(activity: AppCompatActivity): FragmentStateAdapter(activity) { +class SectionPagerAdapter(activity: AppCompatActivity) : FragmentStateAdapter(activity) { override fun getItemCount(): Int { // Returns the number of fragments you want to include in welcome slider diff --git a/presentation/src/main/res/anim/shake_animation.xml b/presentation/src/main/res/anim/shake_animation.xml index 57b36c373..d3ebcabbd 100644 --- a/presentation/src/main/res/anim/shake_animation.xml +++ b/presentation/src/main/res/anim/shake_animation.xml @@ -4,17 +4,17 @@ + android:toXDelta="10" /> \ No newline at end of file diff --git a/presentation/src/main/res/anim/slide_out_left.xml b/presentation/src/main/res/anim/slide_out_left.xml index 020a1bee1..964d042f7 100644 --- a/presentation/src/main/res/anim/slide_out_left.xml +++ b/presentation/src/main/res/anim/slide_out_left.xml @@ -1,7 +1,11 @@ - - + + \ No newline at end of file diff --git a/presentation/src/main/res/anim/slide_out_right.xml b/presentation/src/main/res/anim/slide_out_right.xml index c4de80064..c51d03c61 100644 --- a/presentation/src/main/res/anim/slide_out_right.xml +++ b/presentation/src/main/res/anim/slide_out_right.xml @@ -1,7 +1,11 @@ - - + + \ No newline at end of file diff --git a/presentation/src/main/res/anim/wait_anim.xml b/presentation/src/main/res/anim/wait_anim.xml index d955e6df7..069b2ab6b 100644 --- a/presentation/src/main/res/anim/wait_anim.xml +++ b/presentation/src/main/res/anim/wait_anim.xml @@ -1,4 +1,3 @@ - \ No newline at end of file + android:duration="300"> \ No newline at end of file diff --git a/presentation/src/main/res/color/checkbox_selector.xml b/presentation/src/main/res/color/checkbox_selector.xml index ed98aa702..642c5f7d6 100644 --- a/presentation/src/main/res/color/checkbox_selector.xml +++ b/presentation/src/main/res/color/checkbox_selector.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/presentation/src/main/res/drawable-hdpi/ic_google_play_store.xml b/presentation/src/main/res/drawable-hdpi/ic_google_play_store.xml index 33a541138..24df3dd3f 100644 --- a/presentation/src/main/res/drawable-hdpi/ic_google_play_store.xml +++ b/presentation/src/main/res/drawable-hdpi/ic_google_play_store.xml @@ -1,42 +1,83 @@ - + - - - - + + + + - - - + + + - - - - - + + + + + - - - + + + diff --git a/presentation/src/main/res/drawable-hdpi/shape_text_view_gray.xml b/presentation/src/main/res/drawable-hdpi/shape_text_view_gray.xml index e1f780571..08ee7cb77 100644 --- a/presentation/src/main/res/drawable-hdpi/shape_text_view_gray.xml +++ b/presentation/src/main/res/drawable-hdpi/shape_text_view_gray.xml @@ -1,9 +1,11 @@ - + - + \ No newline at end of file diff --git a/presentation/src/main/res/drawable-mdpi/shape_round_view.xml b/presentation/src/main/res/drawable-mdpi/shape_round_view.xml index 14b83746b..61fae6a28 100644 --- a/presentation/src/main/res/drawable-mdpi/shape_round_view.xml +++ b/presentation/src/main/res/drawable-mdpi/shape_round_view.xml @@ -1,9 +1,11 @@ - + - + \ No newline at end of file diff --git a/presentation/src/main/res/drawable-mdpi/shape_text_view_blue.xml b/presentation/src/main/res/drawable-mdpi/shape_text_view_blue.xml index f04740ac2..d53e35b50 100644 --- a/presentation/src/main/res/drawable-mdpi/shape_text_view_blue.xml +++ b/presentation/src/main/res/drawable-mdpi/shape_text_view_blue.xml @@ -1,9 +1,11 @@ - + - + \ No newline at end of file diff --git a/presentation/src/main/res/drawable-v21/button_main_raund.xml b/presentation/src/main/res/drawable-v21/button_main_raund.xml index 7697609b8..f6759a5d2 100644 --- a/presentation/src/main/res/drawable-v21/button_main_raund.xml +++ b/presentation/src/main/res/drawable-v21/button_main_raund.xml @@ -1,9 +1,12 @@ - + - - + + diff --git a/presentation/src/main/res/drawable-v21/button_main_raund_reverse.xml b/presentation/src/main/res/drawable-v21/button_main_raund_reverse.xml index 7d3668b2f..24ba38568 100644 --- a/presentation/src/main/res/drawable-v21/button_main_raund_reverse.xml +++ b/presentation/src/main/res/drawable-v21/button_main_raund_reverse.xml @@ -1,9 +1,12 @@ - + - - + + diff --git a/presentation/src/main/res/drawable-v21/button_main_raund_white.xml b/presentation/src/main/res/drawable-v21/button_main_raund_white.xml index 620b01fe9..1a3a34069 100644 --- a/presentation/src/main/res/drawable-v21/button_main_raund_white.xml +++ b/presentation/src/main/res/drawable-v21/button_main_raund_white.xml @@ -1,9 +1,12 @@ - + - - + + diff --git a/presentation/src/main/res/drawable-v21/button_main_round_blue.xml b/presentation/src/main/res/drawable-v21/button_main_round_blue.xml index 92e6fd280..f4841b008 100644 --- a/presentation/src/main/res/drawable-v21/button_main_round_blue.xml +++ b/presentation/src/main/res/drawable-v21/button_main_round_blue.xml @@ -1,9 +1,12 @@ - + - - + + diff --git a/presentation/src/main/res/drawable-v21/button_qr_raund.xml b/presentation/src/main/res/drawable-v21/button_qr_raund.xml index acc0e07f2..1b0df2e98 100644 --- a/presentation/src/main/res/drawable-v21/button_qr_raund.xml +++ b/presentation/src/main/res/drawable-v21/button_qr_raund.xml @@ -1,9 +1,12 @@ - + - - + + diff --git a/presentation/src/main/res/drawable-v21/oval_ripple.xml b/presentation/src/main/res/drawable-v21/oval_ripple.xml index b35528048..efa808cb9 100644 --- a/presentation/src/main/res/drawable-v21/oval_ripple.xml +++ b/presentation/src/main/res/drawable-v21/oval_ripple.xml @@ -1,6 +1,6 @@ + android:color="@color/rippleColor"> diff --git a/presentation/src/main/res/drawable-xxhdpi/appbar_always_elevated.xml b/presentation/src/main/res/drawable-xxhdpi/appbar_always_elevated.xml index 1d5f3c7aa..975e9e980 100644 --- a/presentation/src/main/res/drawable-xxhdpi/appbar_always_elevated.xml +++ b/presentation/src/main/res/drawable-xxhdpi/appbar_always_elevated.xml @@ -1,9 +1,6 @@ - + \ No newline at end of file diff --git a/presentation/src/main/res/drawable-xxhdpi/ic_person.xml b/presentation/src/main/res/drawable-xxhdpi/ic_person.xml index 6260e5432..6b9296f15 100644 --- a/presentation/src/main/res/drawable-xxhdpi/ic_person.xml +++ b/presentation/src/main/res/drawable-xxhdpi/ic_person.xml @@ -8,6 +8,5 @@ - + \ No newline at end of file diff --git a/presentation/src/main/res/drawable-xxxhdpi/button_welcome_round_blue.xml b/presentation/src/main/res/drawable-xxxhdpi/button_welcome_round_blue.xml index 8c0a4cb2e..f6dde61d5 100644 --- a/presentation/src/main/res/drawable-xxxhdpi/button_welcome_round_blue.xml +++ b/presentation/src/main/res/drawable-xxxhdpi/button_welcome_round_blue.xml @@ -2,8 +2,8 @@ - - + + diff --git a/presentation/src/main/res/drawable-xxxhdpi/shape_input_text_blue.xml b/presentation/src/main/res/drawable-xxxhdpi/shape_input_text_blue.xml index 881d9571a..abb0624cb 100644 --- a/presentation/src/main/res/drawable-xxxhdpi/shape_input_text_blue.xml +++ b/presentation/src/main/res/drawable-xxxhdpi/shape_input_text_blue.xml @@ -1,9 +1,11 @@ - + - + \ No newline at end of file diff --git a/presentation/src/main/res/drawable/bg_bottom_sheet.xml b/presentation/src/main/res/drawable/bg_bottom_sheet.xml index aea017dfd..1b7c48e2c 100644 --- a/presentation/src/main/res/drawable/bg_bottom_sheet.xml +++ b/presentation/src/main/res/drawable/bg_bottom_sheet.xml @@ -1,8 +1,8 @@ + android:topRightRadius="16dp" /> \ No newline at end of file diff --git a/presentation/src/main/res/drawable/bg_bottom_sheet_gray.xml b/presentation/src/main/res/drawable/bg_bottom_sheet_gray.xml index 8584d1d0a..90ded1706 100644 --- a/presentation/src/main/res/drawable/bg_bottom_sheet_gray.xml +++ b/presentation/src/main/res/drawable/bg_bottom_sheet_gray.xml @@ -1,8 +1,8 @@ + android:topRightRadius="16dp" /> \ No newline at end of file diff --git a/presentation/src/main/res/drawable/button_main_raund.xml b/presentation/src/main/res/drawable/button_main_raund.xml index 40a7710af..b3c19032a 100644 --- a/presentation/src/main/res/drawable/button_main_raund.xml +++ b/presentation/src/main/res/drawable/button_main_raund.xml @@ -2,8 +2,8 @@ - - + + diff --git a/presentation/src/main/res/drawable/button_main_raund_reverse.xml b/presentation/src/main/res/drawable/button_main_raund_reverse.xml index dba92d509..aa2ac1e92 100644 --- a/presentation/src/main/res/drawable/button_main_raund_reverse.xml +++ b/presentation/src/main/res/drawable/button_main_raund_reverse.xml @@ -2,11 +2,11 @@ - - + + - + \ No newline at end of file diff --git a/presentation/src/main/res/drawable/button_main_raund_white.xml b/presentation/src/main/res/drawable/button_main_raund_white.xml index 9d49db628..10ca2baa6 100644 --- a/presentation/src/main/res/drawable/button_main_raund_white.xml +++ b/presentation/src/main/res/drawable/button_main_raund_white.xml @@ -2,8 +2,8 @@ - - + + diff --git a/presentation/src/main/res/drawable/button_main_round_blue.xml b/presentation/src/main/res/drawable/button_main_round_blue.xml index 19bba12b9..4a3fd512e 100644 --- a/presentation/src/main/res/drawable/button_main_round_blue.xml +++ b/presentation/src/main/res/drawable/button_main_round_blue.xml @@ -2,8 +2,8 @@ - - + + diff --git a/presentation/src/main/res/drawable/button_qr_background.xml b/presentation/src/main/res/drawable/button_qr_background.xml index ebcaa3cdd..0e15822b0 100644 --- a/presentation/src/main/res/drawable/button_qr_background.xml +++ b/presentation/src/main/res/drawable/button_qr_background.xml @@ -1,7 +1,14 @@ - - + + \ No newline at end of file diff --git a/presentation/src/main/res/drawable/button_qr_raund.xml b/presentation/src/main/res/drawable/button_qr_raund.xml index 80cabde71..117d58250 100644 --- a/presentation/src/main/res/drawable/button_qr_raund.xml +++ b/presentation/src/main/res/drawable/button_qr_raund.xml @@ -2,8 +2,8 @@ - - + + diff --git a/presentation/src/main/res/drawable/circle_empty.xml b/presentation/src/main/res/drawable/circle_empty.xml index 11560bb0f..2e624fd8e 100644 --- a/presentation/src/main/res/drawable/circle_empty.xml +++ b/presentation/src/main/res/drawable/circle_empty.xml @@ -1,6 +1,5 @@ - + \ No newline at end of file diff --git a/presentation/src/main/res/drawable/corner_card_background.xml b/presentation/src/main/res/drawable/corner_card_background.xml index f6dbbbea5..2f28ac4bc 100644 --- a/presentation/src/main/res/drawable/corner_card_background.xml +++ b/presentation/src/main/res/drawable/corner_card_background.xml @@ -1,7 +1,8 @@ - + \ No newline at end of file diff --git a/presentation/src/main/res/drawable/dialog_round_bg.xml b/presentation/src/main/res/drawable/dialog_round_bg.xml index 2a8dd7a1a..c19c0482a 100644 --- a/presentation/src/main/res/drawable/dialog_round_bg.xml +++ b/presentation/src/main/res/drawable/dialog_round_bg.xml @@ -1,16 +1,12 @@ - + - - + + android:top="0dp" /> \ No newline at end of file diff --git a/presentation/src/main/res/drawable/edit_text_rounded_corners.xml b/presentation/src/main/res/drawable/edit_text_rounded_corners.xml index d614510c2..2d9d5710d 100644 --- a/presentation/src/main/res/drawable/edit_text_rounded_corners.xml +++ b/presentation/src/main/res/drawable/edit_text_rounded_corners.xml @@ -1,6 +1,9 @@ - + \ No newline at end of file diff --git a/presentation/src/main/res/drawable/grey_circle.xml b/presentation/src/main/res/drawable/grey_circle.xml index 2bf73c1fd..e40964df1 100644 --- a/presentation/src/main/res/drawable/grey_circle.xml +++ b/presentation/src/main/res/drawable/grey_circle.xml @@ -1,12 +1,10 @@ - - + + android:height="5dp" /> \ No newline at end of file diff --git a/presentation/src/main/res/drawable/ic_access_time_24px_rounded.xml b/presentation/src/main/res/drawable/ic_access_time_24px_rounded.xml index e6c6cb788..5663a2584 100644 --- a/presentation/src/main/res/drawable/ic_access_time_24px_rounded.xml +++ b/presentation/src/main/res/drawable/ic_access_time_24px_rounded.xml @@ -3,9 +3,9 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/presentation/src/main/res/drawable/ic_archived_records.xml b/presentation/src/main/res/drawable/ic_archived_records.xml index 5f078a977..87c1538f9 100644 --- a/presentation/src/main/res/drawable/ic_archived_records.xml +++ b/presentation/src/main/res/drawable/ic_archived_records.xml @@ -3,11 +3,11 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - - - - + + + + diff --git a/presentation/src/main/res/drawable/ic_arrow_bottom.xml b/presentation/src/main/res/drawable/ic_arrow_bottom.xml index 6ff27420a..fae737d3c 100644 --- a/presentation/src/main/res/drawable/ic_arrow_bottom.xml +++ b/presentation/src/main/res/drawable/ic_arrow_bottom.xml @@ -1,6 +1,11 @@ - - + + android:strokeWidth="0.5" + android:strokeColor="#446DFD" /> diff --git a/presentation/src/main/res/drawable/ic_arrow_down.xml b/presentation/src/main/res/drawable/ic_arrow_down.xml index e156911f3..e2f11e7f0 100644 --- a/presentation/src/main/res/drawable/ic_arrow_down.xml +++ b/presentation/src/main/res/drawable/ic_arrow_down.xml @@ -3,14 +3,13 @@ android:height="12dp" android:viewportWidth="12" android:viewportHeight="12"> - - - - + android:fillColor="#315EFD" + android:pathData="M11.78,4.28C12.073,3.987 12.073,3.513 11.78,3.22C11.487,2.927 11.013,2.927 10.72,3.22L6,7.939L1.28,3.22C0.987,2.927 0.513,2.927 0.22,3.22C-0.073,3.513 -0.073,3.987 0.22,4.28L4.939,9C5.525,9.586 6.475,9.586 7.061,9L11.78,4.28Z" /> + + + + diff --git a/presentation/src/main/res/drawable/ic_arrow_right.xml b/presentation/src/main/res/drawable/ic_arrow_right.xml index be22fdb01..f5cc9a441 100644 --- a/presentation/src/main/res/drawable/ic_arrow_right.xml +++ b/presentation/src/main/res/drawable/ic_arrow_right.xml @@ -3,14 +3,13 @@ android:height="12dp" android:viewportWidth="12" android:viewportHeight="12"> - - - - + android:fillColor="#315EFD" + android:pathData="M4.28,0.22C3.987,-0.073 3.513,-0.073 3.22,0.22C2.927,0.513 2.927,0.987 3.22,1.28L7.939,6L3.22,10.72C2.927,11.013 2.927,11.487 3.22,11.78C3.513,12.073 3.987,12.073 4.28,11.78L9,7.061C9.586,6.475 9.586,5.525 9,4.939L4.28,0.22Z" /> + + + + diff --git a/presentation/src/main/res/drawable/ic_back.xml b/presentation/src/main/res/drawable/ic_back.xml index 4a6bd6c35..c34d8fd15 100644 --- a/presentation/src/main/res/drawable/ic_back.xml +++ b/presentation/src/main/res/drawable/ic_back.xml @@ -3,13 +3,13 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - - - - - + + + + + diff --git a/presentation/src/main/res/drawable/ic_back_blue.xml b/presentation/src/main/res/drawable/ic_back_blue.xml index 79a87eead..ebc1e924b 100644 --- a/presentation/src/main/res/drawable/ic_back_blue.xml +++ b/presentation/src/main/res/drawable/ic_back_blue.xml @@ -3,13 +3,13 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - - - - - + + + + + diff --git a/presentation/src/main/res/drawable/ic_baseline_add_circle_outline.xml b/presentation/src/main/res/drawable/ic_baseline_add_circle_outline.xml index 8611136a9..12014aae9 100644 --- a/presentation/src/main/res/drawable/ic_baseline_add_circle_outline.xml +++ b/presentation/src/main/res/drawable/ic_baseline_add_circle_outline.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/presentation/src/main/res/drawable/ic_baseline_check_24px.xml b/presentation/src/main/res/drawable/ic_baseline_check_24px.xml index c01a7b34f..571e477fd 100644 --- a/presentation/src/main/res/drawable/ic_baseline_check_24px.xml +++ b/presentation/src/main/res/drawable/ic_baseline_check_24px.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/presentation/src/main/res/drawable/ic_baseline_crop_free_24px.xml b/presentation/src/main/res/drawable/ic_baseline_crop_free_24px.xml index 29abb4bfa..64a9b89f1 100644 --- a/presentation/src/main/res/drawable/ic_baseline_crop_free_24px.xml +++ b/presentation/src/main/res/drawable/ic_baseline_crop_free_24px.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/presentation/src/main/res/drawable/ic_baseline_mail_outline_24px.xml b/presentation/src/main/res/drawable/ic_baseline_mail_outline_24px.xml index b3e947adc..23b5a5271 100644 --- a/presentation/src/main/res/drawable/ic_baseline_mail_outline_24px.xml +++ b/presentation/src/main/res/drawable/ic_baseline_mail_outline_24px.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/presentation/src/main/res/drawable/ic_baseline_person_24px.xml b/presentation/src/main/res/drawable/ic_baseline_person_24px.xml index d8b5cb48b..e12ca9105 100644 --- a/presentation/src/main/res/drawable/ic_baseline_person_24px.xml +++ b/presentation/src/main/res/drawable/ic_baseline_person_24px.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/presentation/src/main/res/drawable/ic_call_24_px.xml b/presentation/src/main/res/drawable/ic_call_24_px.xml index 08ffd592b..ba810d4cb 100644 --- a/presentation/src/main/res/drawable/ic_call_24_px.xml +++ b/presentation/src/main/res/drawable/ic_call_24_px.xml @@ -3,9 +3,9 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/presentation/src/main/res/drawable/ic_call_24px_rounded.xml b/presentation/src/main/res/drawable/ic_call_24px_rounded.xml index c64993dea..7103c2af1 100644 --- a/presentation/src/main/res/drawable/ic_call_24px_rounded.xml +++ b/presentation/src/main/res/drawable/ic_call_24px_rounded.xml @@ -3,8 +3,8 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/presentation/src/main/res/drawable/ic_check_email.xml b/presentation/src/main/res/drawable/ic_check_email.xml index e70ffbce0..82cedf252 100644 --- a/presentation/src/main/res/drawable/ic_check_email.xml +++ b/presentation/src/main/res/drawable/ic_check_email.xml @@ -3,32 +3,32 @@ android:height="193dp" android:viewportWidth="194" android:viewportHeight="193"> - - - - - - - + + + + + + + diff --git a/presentation/src/main/res/drawable/ic_check_email_img.xml b/presentation/src/main/res/drawable/ic_check_email_img.xml index f03b8be4d..bd950b7dc 100644 --- a/presentation/src/main/res/drawable/ic_check_email_img.xml +++ b/presentation/src/main/res/drawable/ic_check_email_img.xml @@ -4,171 +4,208 @@ android:height="358dp" android:viewportWidth="375" android:viewportHeight="358"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/presentation/src/main/res/drawable/ic_chevron_right_24px.xml b/presentation/src/main/res/drawable/ic_chevron_right_24px.xml index 70a53ea12..a8439e82c 100644 --- a/presentation/src/main/res/drawable/ic_chevron_right_24px.xml +++ b/presentation/src/main/res/drawable/ic_chevron_right_24px.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/presentation/src/main/res/drawable/ic_close_black_24dp.xml b/presentation/src/main/res/drawable/ic_close_black_24dp.xml index ede4b7108..f50fd991b 100644 --- a/presentation/src/main/res/drawable/ic_close_black_24dp.xml +++ b/presentation/src/main/res/drawable/ic_close_black_24dp.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z" /> diff --git a/presentation/src/main/res/drawable/ic_confirm_registration.xml b/presentation/src/main/res/drawable/ic_confirm_registration.xml index e4cc6b13a..c3019089b 100644 --- a/presentation/src/main/res/drawable/ic_confirm_registration.xml +++ b/presentation/src/main/res/drawable/ic_confirm_registration.xml @@ -3,31 +3,31 @@ android:height="193dp" android:viewportWidth="194" android:viewportHeight="193"> - - - - - - - + + + + + + + diff --git a/presentation/src/main/res/drawable/ic_create_black_24dp.xml b/presentation/src/main/res/drawable/ic_create_black_24dp.xml index df26adda3..8985c5a44 100644 --- a/presentation/src/main/res/drawable/ic_create_black_24dp.xml +++ b/presentation/src/main/res/drawable/ic_create_black_24dp.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/presentation/src/main/res/drawable/ic_delete.xml b/presentation/src/main/res/drawable/ic_delete.xml index ef8ccd83b..06d310316 100644 --- a/presentation/src/main/res/drawable/ic_delete.xml +++ b/presentation/src/main/res/drawable/ic_delete.xml @@ -1,4 +1,9 @@ - - + + diff --git a/presentation/src/main/res/drawable/ic_delete_outline_24px.xml b/presentation/src/main/res/drawable/ic_delete_outline_24px.xml index 09503aede..83e7b7447 100644 --- a/presentation/src/main/res/drawable/ic_delete_outline_24px.xml +++ b/presentation/src/main/res/drawable/ic_delete_outline_24px.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/presentation/src/main/res/drawable/ic_error_outline_black_48dp.xml b/presentation/src/main/res/drawable/ic_error_outline_black_48dp.xml index 6b8271111..a71c82f0d 100644 --- a/presentation/src/main/res/drawable/ic_error_outline_black_48dp.xml +++ b/presentation/src/main/res/drawable/ic_error_outline_black_48dp.xml @@ -3,7 +3,7 @@ android:height="48dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/presentation/src/main/res/drawable/ic_euro_1.xml b/presentation/src/main/res/drawable/ic_euro_1.xml index a9a331896..929376120 100644 --- a/presentation/src/main/res/drawable/ic_euro_1.xml +++ b/presentation/src/main/res/drawable/ic_euro_1.xml @@ -3,14 +3,13 @@ android:height="20dp" android:viewportWidth="20" android:viewportHeight="20"> - - - - - + + + + + diff --git a/presentation/src/main/res/drawable/ic_fingerprint.xml b/presentation/src/main/res/drawable/ic_fingerprint.xml index 587db10ae..99ae54849 100644 --- a/presentation/src/main/res/drawable/ic_fingerprint.xml +++ b/presentation/src/main/res/drawable/ic_fingerprint.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/presentation/src/main/res/drawable/ic_forus_icon.xml b/presentation/src/main/res/drawable/ic_forus_icon.xml index 708a99572..c133fba1a 100644 --- a/presentation/src/main/res/drawable/ic_forus_icon.xml +++ b/presentation/src/main/res/drawable/ic_forus_icon.xml @@ -3,8 +3,8 @@ android:height="186dp" android:viewportWidth="220" android:viewportHeight="186"> - + diff --git a/presentation/src/main/res/drawable/ic_ic_forus_logo_backgr_w.xml b/presentation/src/main/res/drawable/ic_ic_forus_logo_backgr_w.xml index 45a8208ff..f9d107954 100644 --- a/presentation/src/main/res/drawable/ic_ic_forus_logo_backgr_w.xml +++ b/presentation/src/main/res/drawable/ic_ic_forus_logo_backgr_w.xml @@ -3,14 +3,14 @@ android:height="100dp" android:viewportWidth="100" android:viewportHeight="100"> - - - + + + diff --git a/presentation/src/main/res/drawable/ic_import_export_black_24dp.xml b/presentation/src/main/res/drawable/ic_import_export_black_24dp.xml index 0e54aae6c..ddc5476cd 100644 --- a/presentation/src/main/res/drawable/ic_import_export_black_24dp.xml +++ b/presentation/src/main/res/drawable/ic_import_export_black_24dp.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/presentation/src/main/res/drawable/ic_info_outline_24px.xml b/presentation/src/main/res/drawable/ic_info_outline_24px.xml index 140ebddee..84628014b 100644 --- a/presentation/src/main/res/drawable/ic_info_outline_24px.xml +++ b/presentation/src/main/res/drawable/ic_info_outline_24px.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/presentation/src/main/res/drawable/ic_qr_image.xml b/presentation/src/main/res/drawable/ic_qr_image.xml index da30c9de2..1ffb10fc9 100644 --- a/presentation/src/main/res/drawable/ic_qr_image.xml +++ b/presentation/src/main/res/drawable/ic_qr_image.xml @@ -1,11 +1,32 @@ - - + - - - - - + android:strokeWidth="1" + android:strokeColor="#305DFB" /> + + + + + diff --git a/presentation/src/main/res/drawable/ic_qr_image_2.xml b/presentation/src/main/res/drawable/ic_qr_image_2.xml index 6198dd54b..1e579efae 100644 --- a/presentation/src/main/res/drawable/ic_qr_image_2.xml +++ b/presentation/src/main/res/drawable/ic_qr_image_2.xml @@ -1,11 +1,32 @@ - - - + + - - - - + android:strokeWidth="1" + android:strokeColor="#315EFD" /> + + + + diff --git a/presentation/src/main/res/drawable/ic_qr_window.xml b/presentation/src/main/res/drawable/ic_qr_window.xml index e992e7b4d..9962ef6af 100644 --- a/presentation/src/main/res/drawable/ic_qr_window.xml +++ b/presentation/src/main/res/drawable/ic_qr_window.xml @@ -1,4 +1,10 @@ - - + + diff --git a/presentation/src/main/res/drawable/ic_room_24px_outlined.xml b/presentation/src/main/res/drawable/ic_room_24px_outlined.xml index d75f07135..7176de8f3 100644 --- a/presentation/src/main/res/drawable/ic_room_24px_outlined.xml +++ b/presentation/src/main/res/drawable/ic_room_24px_outlined.xml @@ -3,9 +3,9 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/presentation/src/main/res/drawable/ic_secure.xml b/presentation/src/main/res/drawable/ic_secure.xml index bc793fc0d..496581eb2 100644 --- a/presentation/src/main/res/drawable/ic_secure.xml +++ b/presentation/src/main/res/drawable/ic_secure.xml @@ -3,27 +3,27 @@ android:height="153dp" android:viewportWidth="122" android:viewportHeight="153"> - - - - - - + + + + + + diff --git a/presentation/src/main/res/drawable/ic_shop_location.xml b/presentation/src/main/res/drawable/ic_shop_location.xml index 1943c29ad..ef1009156 100644 --- a/presentation/src/main/res/drawable/ic_shop_location.xml +++ b/presentation/src/main/res/drawable/ic_shop_location.xml @@ -3,8 +3,8 @@ android:height="54dp" android:viewportWidth="38" android:viewportHeight="54"> - + diff --git a/presentation/src/main/res/drawable/ic_success_restore.xml b/presentation/src/main/res/drawable/ic_success_restore.xml index 1f40a75f2..f038a6f29 100644 --- a/presentation/src/main/res/drawable/ic_success_restore.xml +++ b/presentation/src/main/res/drawable/ic_success_restore.xml @@ -4,36 +4,46 @@ android:height="319dp" android:viewportWidth="359" android:viewportHeight="319"> - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/presentation/src/main/res/drawable/ic_transactions.xml b/presentation/src/main/res/drawable/ic_transactions.xml index d239312e0..41a0f90bd 100644 --- a/presentation/src/main/res/drawable/ic_transactions.xml +++ b/presentation/src/main/res/drawable/ic_transactions.xml @@ -3,7 +3,7 @@ android:height="20dp" android:viewportWidth="16" android:viewportHeight="20"> - + diff --git a/presentation/src/main/res/drawable/ic_vieapager_indicator_selected.xml b/presentation/src/main/res/drawable/ic_vieapager_indicator_selected.xml index f2b8a83db..e447b1ee8 100644 --- a/presentation/src/main/res/drawable/ic_vieapager_indicator_selected.xml +++ b/presentation/src/main/res/drawable/ic_vieapager_indicator_selected.xml @@ -3,6 +3,6 @@ android:innerRadius="0dp" android:shape="ring" android:thicknessRatio="2" - android:useLevel="false" > + android:useLevel="false"> \ No newline at end of file diff --git a/presentation/src/main/res/drawable/ic_vieapager_indicator_unselected.xml b/presentation/src/main/res/drawable/ic_vieapager_indicator_unselected.xml index 5f15b0d71..ccbc0a9b9 100644 --- a/presentation/src/main/res/drawable/ic_vieapager_indicator_unselected.xml +++ b/presentation/src/main/res/drawable/ic_vieapager_indicator_unselected.xml @@ -3,6 +3,6 @@ android:innerRadius="0dp" android:shape="ring" android:thicknessRatio="2" - android:useLevel="false" > + android:useLevel="false"> \ No newline at end of file diff --git a/presentation/src/main/res/drawable/indicator_dot.xml b/presentation/src/main/res/drawable/indicator_dot.xml index 87df0cbf7..2e894db34 100644 --- a/presentation/src/main/res/drawable/indicator_dot.xml +++ b/presentation/src/main/res/drawable/indicator_dot.xml @@ -3,6 +3,5 @@ android:padding="10dp" android:shape="oval"> - + \ No newline at end of file diff --git a/presentation/src/main/res/drawable/layout_top_corners.xml b/presentation/src/main/res/drawable/layout_top_corners.xml index 7aa656807..d55b7ebb1 100644 --- a/presentation/src/main/res/drawable/layout_top_corners.xml +++ b/presentation/src/main/res/drawable/layout_top_corners.xml @@ -4,9 +4,9 @@ - + + android:color="@color/rippleColor"> diff --git a/presentation/src/main/res/drawable/qr.xml b/presentation/src/main/res/drawable/qr.xml index 993462b79..cd95e75bb 100644 --- a/presentation/src/main/res/drawable/qr.xml +++ b/presentation/src/main/res/drawable/qr.xml @@ -7,10 +7,10 @@ + android:pathData="M9.77777778,16.8888889 L7.55555556,16.8888889 L7.55555556,14.6666667 L9.77777778,14.6666667 L9.77777778,16.8888889 Z M9.77777778,8 L7.55555556,8 L7.55555556,10.2222222 L9.77777778,10.2222222 L9.77777778,8 Z M16.4444444,8 L14.2222222,8 L14.2222222,10.2222222 L16.4444444,10.2222222 L16.4444444,8 Z M16.4444444,14.6666667 L14.2222222,14.6666667 L14.2222222,16.8888889 L16.4444444,16.8888889 L16.4444444,14.6666667 Z M10.2222222,12.8888889 L10.2222222,15.1111111 L11.3333333,15.1111111 L11.3333333,14 L12,14 L12,15.1111111 L11.5555556,15.1111111 L11.5555556,16.2222222 L12.6666667,16.2222222 L12.6666667,16.8888889 L13.7777778,16.8888889 L13.7777778,15.7777778 L12.6666667,15.7777778 L12.6666667,15.1111111 L13.1111111,15.1111111 L13.1111111,14 L12.4444444,14 L12.4444444,13.5555556 L13.5555556,13.5555556 L13.5555556,12.4444444 L12.4444444,12.4444444 L12.4444444,12.8888889 L10.2222222,12.8888889 Z M13.7777778,11.3333333 L13.7777778,12.4444444 L14.2222222,12.4444444 L14.2222222,13.3333333 L15.3333333,13.3333333 L15.3333333,14.2222222 L16.4444444,14.2222222 L16.4444444,13.1111111 L15.3333333,13.1111111 L15.3333333,12.2222222 L14.8888889,12.2222222 L14.8888889,11.3333333 L13.7777778,11.3333333 Z M7.55555556,12.8888889 L8.66666667,12.8888889 L8.66666667,13.5555556 L9.77777778,13.5555556 L9.77777778,12.4444444 L8.66666667,12.4444444 L8.66666667,11.7777778 L7.55555556,11.7777778 L7.55555556,12.8888889 Z M11.5555556,11.3333333 L10.8888889,11.3333333 L10.8888889,12.4444444 L12,12.4444444 L12,11.3333333 L12.6666667,11.3333333 L12.6666667,10.6666667 L13.7777778,10.6666667 L13.7777778,9.55555556 L12.6666667,9.55555556 L12.6666667,10.2222222 L11.5555556,10.2222222 L11.5555556,11.3333333 Z M10.2222222,8 L10.2222222,10.2222222 L11.3333333,10.2222222 L11.3333333,9.77777778 L12.4444444,9.77777778 L12.4444444,9.11111111 L13.5555556,9.11111111 L13.5555556,8 L12.4444444,8 L12.4444444,8.66666667 L11.3333333,8.66666667 L11.3333333,8 L10.2222222,8 Z M4.88888889,9.77777778 L4.88888889,7.55555556 C4.88888889,6 6,4.88888889 7.55555556,4.88888889 L9.77777778,4.88888889 L9.77777778,2 L7.55555556,2 C4.44444444,2 2,4.44444444 2,7.55555556 L2,9.77777778 L4.88888889,9.77777778 Z M14.2222222,4.88888889 L16.4444444,4.88888889 C18,4.88888889 19.1111111,6 19.1111111,7.55555556 L19.1108889,9.77777778 L22,9.77777778 L22,7.55555556 C22,4.44444444 19.5555556,2 16.4444444,2 L14.2222222,2 L14.2222222,4.88888889 Z M19.1111111,14.2222222 L19.1111111,16.4444444 C19.1111111,18 18,19.1111111 16.4444444,19.1111111 L14.2222222,19.1111111 L14.2222222,22 L16.4444444,22 C19.5555556,22 22,19.5555556 22,16.4444444 L22,14.2222222 L19.1111111,14.2222222 Z M9.77777778,19.1111111 L7.55555556,19.1111111 C6,19.1111111 4.88888889,18 4.88888889,16.4444444 L4.88911111,14.2222222 L2,14.2222222 L2,16.4444444 C2,19.5555556 4.44444444,22 7.55555556,22 L9.77777778,22 L9.77777778,19.1111111 Z M16.4444444,10.6666667 L15.3333333,10.6666667 L15.3333333,11.7777778 L16.4444444,11.7777778 L16.4444444,10.6666667 Z M11.3333333,15.7777778 L10.2222222,15.7777778 L10.2222222,16.8888889 L11.3333333,16.8888889 L11.3333333,15.7777778 Z M10.2222222,10.6666667 L9.11111111,10.6666667 L9.11111111,11.7777778 L10.2222222,11.7777778 L10.2222222,10.6666667 Z" + android:strokeWidth="1" /> + android:pathData="M9.77777778,16.8888889 L7.55555556,16.8888889 L7.55555556,14.6666667 L9.77777778,14.6666667 L9.77777778,16.8888889 Z M9.77777778,8 L7.55555556,8 L7.55555556,10.2222222 L9.77777778,10.2222222 L9.77777778,8 Z M16.4444444,8 L14.2222222,8 L14.2222222,10.2222222 L16.4444444,10.2222222 L16.4444444,8 Z M16.4444444,14.6666667 L14.2222222,14.6666667 L14.2222222,16.8888889 L16.4444444,16.8888889 L16.4444444,14.6666667 Z M10.2222222,12.8888889 L10.2222222,15.1111111 L11.3333333,15.1111111 L11.3333333,14 L12,14 L12,15.1111111 L11.5555556,15.1111111 L11.5555556,16.2222222 L12.6666667,16.2222222 L12.6666667,16.8888889 L13.7777778,16.8888889 L13.7777778,15.7777778 L12.6666667,15.7777778 L12.6666667,15.1111111 L13.1111111,15.1111111 L13.1111111,14 L12.4444444,14 L12.4444444,13.5555556 L13.5555556,13.5555556 L13.5555556,12.4444444 L12.4444444,12.4444444 L12.4444444,12.8888889 L10.2222222,12.8888889 Z M13.7777778,11.3333333 L13.7777778,12.4444444 L14.2222222,12.4444444 L14.2222222,13.3333333 L15.3333333,13.3333333 L15.3333333,14.2222222 L16.4444444,14.2222222 L16.4444444,13.1111111 L15.3333333,13.1111111 L15.3333333,12.2222222 L14.8888889,12.2222222 L14.8888889,11.3333333 L13.7777778,11.3333333 Z M7.55555556,12.8888889 L8.66666667,12.8888889 L8.66666667,13.5555556 L9.77777778,13.5555556 L9.77777778,12.4444444 L8.66666667,12.4444444 L8.66666667,11.7777778 L7.55555556,11.7777778 L7.55555556,12.8888889 Z M11.5555556,11.3333333 L10.8888889,11.3333333 L10.8888889,12.4444444 L12,12.4444444 L12,11.3333333 L12.6666667,11.3333333 L12.6666667,10.6666667 L13.7777778,10.6666667 L13.7777778,9.55555556 L12.6666667,9.55555556 L12.6666667,10.2222222 L11.5555556,10.2222222 L11.5555556,11.3333333 Z M10.2222222,8 L10.2222222,10.2222222 L11.3333333,10.2222222 L11.3333333,9.77777778 L12.4444444,9.77777778 L12.4444444,9.11111111 L13.5555556,9.11111111 L13.5555556,8 L12.4444444,8 L12.4444444,8.66666667 L11.3333333,8.66666667 L11.3333333,8 L10.2222222,8 Z M4.88888889,9.77777778 L4.88888889,7.55555556 C4.88888889,6 6,4.88888889 7.55555556,4.88888889 L9.77777778,4.88888889 L9.77777778,2 L7.55555556,2 C4.44444444,2 2,4.44444444 2,7.55555556 L2,9.77777778 L4.88888889,9.77777778 Z M14.2222222,4.88888889 L16.4444444,4.88888889 C18,4.88888889 19.1111111,6 19.1111111,7.55555556 L19.1108889,9.77777778 L22,9.77777778 L22,7.55555556 C22,4.44444444 19.5555556,2 16.4444444,2 L14.2222222,2 L14.2222222,4.88888889 Z M19.1111111,14.2222222 L19.1111111,16.4444444 C19.1111111,18 18,19.1111111 16.4444444,19.1111111 L14.2222222,19.1111111 L14.2222222,22 L16.4444444,22 C19.5555556,22 22,19.5555556 22,16.4444444 L22,14.2222222 L19.1111111,14.2222222 Z M9.77777778,19.1111111 L7.55555556,19.1111111 C6,19.1111111 4.88888889,18 4.88888889,16.4444444 L4.88911111,14.2222222 L2,14.2222222 L2,16.4444444 C2,19.5555556 4.44444444,22 7.55555556,22 L9.77777778,22 L9.77777778,19.1111111 Z M16.4444444,10.6666667 L15.3333333,10.6666667 L15.3333333,11.7777778 L16.4444444,11.7777778 L16.4444444,10.6666667 Z M11.3333333,15.7777778 L10.2222222,15.7777778 L10.2222222,16.8888889 L11.3333333,16.8888889 L11.3333333,15.7777778 Z M10.2222222,10.6666667 L9.11111111,10.6666667 L9.11111111,11.7777778 L10.2222222,11.7777778 L10.2222222,10.6666667 Z" + android:strokeWidth="1" /> \ No newline at end of file diff --git a/presentation/src/main/res/drawable/qr_blue.xml b/presentation/src/main/res/drawable/qr_blue.xml index b06122356..b30a792c0 100644 --- a/presentation/src/main/res/drawable/qr_blue.xml +++ b/presentation/src/main/res/drawable/qr_blue.xml @@ -3,42 +3,42 @@ android:height="20dp" android:viewportWidth="20" android:viewportHeight="20"> - - - - - - - - - - - + + + + + + + + + + + diff --git a/presentation/src/main/res/drawable/records.xml b/presentation/src/main/res/drawable/records.xml index d467e9f09..4ba05986f 100644 --- a/presentation/src/main/res/drawable/records.xml +++ b/presentation/src/main/res/drawable/records.xml @@ -7,10 +7,10 @@ + android:pathData="M21,20.0018478 L21,18.0036956 C21,17.4042499 20.6,17.0046195 20,17.0046195 L14,17.0046195 L14,16.2053586 C14,13.9074835 14.9,11.7095161 16.2,9.71136389 C16.7,9.01201061 17,8.0129345 17,7.0138584 C17,3.91672247 14.2,1.4190322 10.9,2.11838547 C8.9,2.51801592 7.4,4.11653769 7.1,6.1146899 C6.9,7.41348884 7.1,8.71228778 7.8,9.71136389 C9.1,11.8094237 10,14.2072064 10,16.8048042 L10,17.0046195 L4,17.0046195 C3.4,17.0046195 3,17.4042499 3,18.0036956 L3,20.0018478 L2,20.0018478 L2,22 L22,22 L22,20.0018478 L21,20.0018478 Z" + android:strokeWidth="1" /> + android:pathData="M21,20.0018478 L21,18.0036956 C21,17.4042499 20.6,17.0046195 20,17.0046195 L14,17.0046195 L14,16.2053586 C14,13.9074835 14.9,11.7095161 16.2,9.71136389 C16.7,9.01201061 17,8.0129345 17,7.0138584 C17,3.91672247 14.2,1.4190322 10.9,2.11838547 C8.9,2.51801592 7.4,4.11653769 7.1,6.1146899 C6.9,7.41348884 7.1,8.71228778 7.8,9.71136389 C9.1,11.8094237 10,14.2072064 10,16.8048042 L10,17.0046195 L4,17.0046195 C3.4,17.0046195 3,17.4042499 3,18.0036956 L3,20.0018478 L2,20.0018478 L2,22 L22,22 L22,20.0018478 L21,20.0018478 Z" + android:strokeWidth="1" /> \ No newline at end of file diff --git a/presentation/src/main/res/drawable/shape_card_view_bottom.xml b/presentation/src/main/res/drawable/shape_card_view_bottom.xml index 0cb42185b..11af65a14 100644 --- a/presentation/src/main/res/drawable/shape_card_view_bottom.xml +++ b/presentation/src/main/res/drawable/shape_card_view_bottom.xml @@ -1,9 +1,8 @@ + android:topLeftRadius="18dp" + android:topRightRadius="18dp" /> \ No newline at end of file diff --git a/presentation/src/main/res/drawable/shape_divider.xml b/presentation/src/main/res/drawable/shape_divider.xml index 8f4da3e93..1344ceb3d 100644 --- a/presentation/src/main/res/drawable/shape_divider.xml +++ b/presentation/src/main/res/drawable/shape_divider.xml @@ -1,12 +1,11 @@ - - + + + android:top="0dp" /> \ No newline at end of file diff --git a/presentation/src/main/res/drawable/shape_shadow_gradient.xml b/presentation/src/main/res/drawable/shape_shadow_gradient.xml index 10534e581..41acf8f3f 100644 --- a/presentation/src/main/res/drawable/shape_shadow_gradient.xml +++ b/presentation/src/main/res/drawable/shape_shadow_gradient.xml @@ -1,10 +1,10 @@ + android:centerY="0.7" + android:endColor="#3C000000" + android:startColor="#00000000" + android:type="linear" /> \ No newline at end of file diff --git a/presentation/src/main/res/drawable/wallet.xml b/presentation/src/main/res/drawable/wallet.xml index d04aeab55..60debff19 100644 --- a/presentation/src/main/res/drawable/wallet.xml +++ b/presentation/src/main/res/drawable/wallet.xml @@ -7,14 +7,14 @@ + android:pathData="M5.00186617,3.99946681 L22,3.99946681 L22,2 L5.00186617,2 C3.35430552,2 2,3.33830978 2,5.00186617 L2,18.9981338 C2,20.6456945 3.34897361,22 5.00186617,22 L22,22 L22,15.9962677 L18.0010664,15.9962677 C16.9026926,15.9962677 16.0015996,15.0951746 16.0015996,13.9968009 C16.0015996,12.8984271 16.9026926,11.997334 18.0010664,11.997334 L22,11.997334 L22,5.99893362 L5.00186617,5.99893362 C4.45267929,5.99893362 3.99946681,5.55105305 3.99946681,4.99653426 C3.99946681,4.44201546 4.44734737,3.99946681 5.00186617,3.99946681 Z" + android:strokeWidth="1" /> + android:pathData="M 18.15 12.80000022 C 18.7851274513 12.80000022 19.29999998 13.3148727487 19.29999998 13.9500002 C 19.29999998 14.5851276513 18.7851274513 15.10000018 18.15 15.10000018 C 17.5148725487 15.10000018 17.00000002 14.5851276513 17.00000002 13.9500002 C 17.00000002 13.3148727487 17.5148725487 12.80000022 18.15 12.80000022 Z" + android:strokeWidth="1" /> + android:pathData="M 18.15 12.80000022 C 18.7851274513 12.80000022 19.29999998 13.3148727487 19.29999998 13.9500002 C 19.29999998 14.5851276513 18.7851274513 15.10000018 18.15 15.10000018 C 17.5148725487 15.10000018 17.00000002 14.5851276513 17.00000002 13.9500002 C 17.00000002 13.3148727487 17.5148725487 12.80000022 18.15 12.80000022 Z" + android:strokeWidth="1" /> \ No newline at end of file diff --git a/presentation/src/main/res/font/google_sans_medium.xml b/presentation/src/main/res/font/google_sans_medium.xml index 8eaa8c907..bc4e1e4a4 100644 --- a/presentation/src/main/res/font/google_sans_medium.xml +++ b/presentation/src/main/res/font/google_sans_medium.xml @@ -1,7 +1,7 @@ + android:fontWeight="400" /> \ No newline at end of file diff --git a/presentation/src/main/res/font/google_sans_regular.xml b/presentation/src/main/res/font/google_sans_regular.xml index c5487d4af..4bae85fb2 100644 --- a/presentation/src/main/res/font/google_sans_regular.xml +++ b/presentation/src/main/res/font/google_sans_regular.xml @@ -1,8 +1,8 @@ + android:fontWeight="400" /> \ No newline at end of file diff --git a/presentation/src/main/res/layout/activity_action_payment.xml b/presentation/src/main/res/layout/activity_action_payment.xml index 5f4b4d7d2..0ee73bd17 100644 --- a/presentation/src/main/res/layout/activity_action_payment.xml +++ b/presentation/src/main/res/layout/activity_action_payment.xml @@ -4,34 +4,27 @@ android:layout_height="match_parent"> + + - - - - - - - + android:layout_height="match_parent" + android:layout_below="@+id/title0" /> - - - - + + diff --git a/presentation/src/main/res/layout/activity_actions.xml b/presentation/src/main/res/layout/activity_actions.xml index f8ce4b309..5410fecbd 100644 --- a/presentation/src/main/res/layout/activity_actions.xml +++ b/presentation/src/main/res/layout/activity_actions.xml @@ -4,6 +4,7 @@ xmlns:tools="http://schemas.android.com/tools"> + + - + android:layout_height="match_parent"> - + android:layout_height="wrap_content" + android:orientation="vertical" + android:visibility="gone"> - + android:layout_height="100dp" + android:layout_marginLeft="10dp" + android:layout_marginTop="8dp" + android:layout_marginRight="10dp" + android:layout_marginBottom="8dp" + app:cardBackgroundColor="@color/brightBackground" + app:cardCornerRadius="@dimen/card_radius" + app:cardElevation="@dimen/card_elevation_small"> - - - + + - - - - - - - - - - - - + android:layout_height="100dp" + android:layout_marginEnd="140dp" + android:layout_marginRight="140dp" + android:orientation="vertical" + android:paddingStart="16dp"> - - - - - - + android:layout_marginTop="15dp" + android:ellipsize="end" + android:lines="1" + android:maxLines="1" + app:type="medium" + tools:text="Bike" /> - + - - - + + + + + + app:type="regular" /> - + - + - + + + + + android:inputType="numberDecimal" + app:hint="@string/vouchers_amount" + app:validationError="@string/me_validation_error_decimal" + app:validationRegex="decimal" /> - + - + - + + - + android:layout_marginLeft="16dp" + android:layout_marginTop="16dp" + android:layout_marginRight="16dp"> - + android:layout_height="45dp" + android:layout_marginBottom="6dp" + android:text="@string/vouchers_make_transaction" /> - - - - - - - - - - - - - - - - - - - - + + + + - + + + android:layout_height="match_parent"> - + android:layout_height="80dp" + android:layout_centerVertical="true" + android:layout_marginEnd="140dp" + android:layout_marginRight="140dp" + android:orientation="vertical" + android:paddingStart="16dp"> + - - - + + + - - + + + + + + + + + + + + + + android:fontFamily="@font/google_sans_regular" + android:letterSpacing="0.01" + android:text="@string/choose_an_action_descr" + android:textColor="#1C212A" + android:textSize="13sp" + android:visibility="gone" + tools:text="@string/choose_an_action_descr" /> + - + + + + - + + diff --git a/presentation/src/main/res/layout/activity_check_email.xml b/presentation/src/main/res/layout/activity_check_email.xml index ed5778e04..bdb558f7c 100644 --- a/presentation/src/main/res/layout/activity_check_email.xml +++ b/presentation/src/main/res/layout/activity_check_email.xml @@ -21,7 +21,6 @@ app:layout_constraintTop_toBottomOf="@id/descrLayout" /> - - - - - - + android:gravity="center_horizontal" + android:orientation="vertical" + app:layout_constraintTop_toBottomOf="@id/titleLayout"> + + + - - - - + tools:context=".view.screens.records.create_record.CreateRecordActivity"> + android:src="@drawable/ic_close_black_24dp" + android:tint="@color/gray_subtitle" /> + android:text="@string/new_record" /> + android:paddingEnd="27dp" + android:text="@string/choose_type" /> + android:visibility="visible" /> @@ -74,67 +69,62 @@ android:name="io.forus.me.android.presentation.view.screens.records.create_record.FNavHostFragment" android:layout_width="match_parent" android:layout_height="match_parent" - app:defaultNavHost="true" - app:navGraph="@navigation/nav_create_record" - android:layout_below="@+id/headView" android:layout_above="@id/card_view" + android:layout_below="@+id/headView" android:layout_marginBottom="0dp" - /> + app:defaultNavHost="true" + app:navGraph="@navigation/nav_create_record" /> + + + - - - - - - - - - - - - - - - - + android:layout_height="match_parent"> + + + + + + + + + + + + diff --git a/presentation/src/main/res/layout/activity_dashboard.xml b/presentation/src/main/res/layout/activity_dashboard.xml index 03f4a866c..0049db6e1 100644 --- a/presentation/src/main/res/layout/activity_dashboard.xml +++ b/presentation/src/main/res/layout/activity_dashboard.xml @@ -1,5 +1,4 @@ - @@ -7,12 +6,12 @@ + app:navGraph="@navigation/nav_graph" /> + app:labelVisibilityMode="labeled" + app:menu="@menu/bottom_navigation_menu" /> diff --git a/presentation/src/main/res/layout/activity_layout.xml b/presentation/src/main/res/layout/activity_layout.xml index 5c224961a..7cf31493e 100755 --- a/presentation/src/main/res/layout/activity_layout.xml +++ b/presentation/src/main/res/layout/activity_layout.xml @@ -1,7 +1,7 @@ + android:layout_height="match_parent" + android:background="#FFFFFF"> + android:layout_height="match_parent"> \ No newline at end of file diff --git a/presentation/src/main/res/layout/activity_qr_decoder_content.xml b/presentation/src/main/res/layout/activity_qr_decoder_content.xml index 93b6ac895..1eba309ba 100644 --- a/presentation/src/main/res/layout/activity_qr_decoder_content.xml +++ b/presentation/src/main/res/layout/activity_qr_decoder_content.xml @@ -13,10 +13,7 @@ android:id="@+id/qrCodeReaderView" android:layout_width="match_parent" android:layout_height="match_parent" - android:visibility="visible" - /> - - + android:visibility="visible" /> + android:background="#55000000" /> + android:background="#55000000" /> + android:layout_below="@id/qr_shadow_top" + android:layout_toStartOf="@id/qr_frame" + android:background="#55000000" /> + android:layout_below="@id/qr_shadow_top" + android:layout_toEndOf="@id/qr_frame" + android:background="#55000000" /> @@ -73,17 +70,17 @@ android:layout_alignParentStart="true" android:layout_alignParentTop="true" android:gravity="center" + android:letterSpacing="0.01" android:padding="16dp" + android:text="Scan QR-code" android:textColor="#ffffff" - android:textSize="34.1sp" - android:letterSpacing="0.01" - android:text="Scan QR-code"/> + android:textSize="34.1sp" /> + android:visibility="gone" /> + android:visibility="gone" /> \ No newline at end of file diff --git a/presentation/src/main/res/layout/activity_toolbar.xml b/presentation/src/main/res/layout/activity_toolbar.xml index 18dc58e1a..4656b76f0 100644 --- a/presentation/src/main/res/layout/activity_toolbar.xml +++ b/presentation/src/main/res/layout/activity_toolbar.xml @@ -2,9 +2,9 @@ + android:layout_height="match_parent" + android:background="@color/brightBackground"> - - - - - - - - + android:layout_height="wrap_content" + android:focusableInTouchMode="true"> diff --git a/presentation/src/main/res/layout/activity_transactions_log.xml b/presentation/src/main/res/layout/activity_transactions_log.xml index 1842bac24..607cdb2bd 100644 --- a/presentation/src/main/res/layout/activity_transactions_log.xml +++ b/presentation/src/main/res/layout/activity_transactions_log.xml @@ -72,10 +72,10 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="16dp" - android:gravity="center" - android:textAllCaps="true" android:fontFamily="@font/google_sans_regular" - android:text="@string/from" /> + android:gravity="center" + android:text="@string/from" + android:textAllCaps="true" /> diff --git a/presentation/src/main/res/layout/activity_welcome.xml b/presentation/src/main/res/layout/activity_welcome.xml index 2e030df4f..c53c265eb 100644 --- a/presentation/src/main/res/layout/activity_welcome.xml +++ b/presentation/src/main/res/layout/activity_welcome.xml @@ -11,17 +11,15 @@ android:id="@+id/backBt" android:layout_width="34dp" android:layout_height="34dp" - android:layout_marginTop="44dp" - android:layout_marginStart="20dp" - android:src="@drawable/ic_back" - android:visibility="visible" android:layout_gravity="start|top" - android:clickable="true" - android:focusable="true" + android:layout_marginStart="20dp" + android:layout_marginTop="44dp" android:background="@drawable/oval_ripple" + android:clickable="true" android:elevation="1dp" - /> - + android:focusable="true" + android:src="@drawable/ic_back" + android:visibility="visible" /> + android:layout_marginBottom="73dp" /> + android:textSize="16sp" + app:backgroundTint="@null" /> - + android:text="@string/welcome_not_show_again" + android:textColor="#757575" + android:textFontWeight="500" + android:textSize="16sp" + app:backgroundTint="@null" /> + app:cardBackgroundColor="@color/alabaster" + app:cardCornerRadius="12dp" + app:cardElevation="12dp" + app:strokeColor="@color/border_color" + app:strokeWidth="2dp"> + android:textSize="11sp" + app:backgroundTint="@null" /> + app:ci_drawable="@drawable/indicator_dot" /> + android:paddingHorizontal="12dp" + android:text="@string/next_step" + android:textAllCaps="false" /> diff --git a/presentation/src/main/res/layout/activity_zxzing_capture.xml b/presentation/src/main/res/layout/activity_zxzing_capture.xml index c4ee65fe9..a4c186b8c 100644 --- a/presentation/src/main/res/layout/activity_zxzing_capture.xml +++ b/presentation/src/main/res/layout/activity_zxzing_capture.xml @@ -28,42 +28,39 @@ android:src="@drawable/ic_qr_window" /> - + android:background="#55000000" /> + android:background="#55000000" /> + android:layout_below="@id/qr_shadow_top" + android:layout_toStartOf="@id/qr_frame" + android:background="#55000000" /> + android:layout_below="@id/qr_shadow_top" + android:layout_toEndOf="@id/qr_frame" + android:background="#55000000" /> - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/dialog_apply_action.xml b/presentation/src/main/res/layout/dialog_apply_action.xml index 320df97dc..3c63ae4bf 100644 --- a/presentation/src/main/res/layout/dialog_apply_action.xml +++ b/presentation/src/main/res/layout/dialog_apply_action.xml @@ -11,11 +11,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="26dp" + android:fontFamily="@font/google_sans_medium" android:gravity="center" android:letterSpacing="0.01" android:text="@string/confirm_payment" android:textColor="#28292B" - android:fontFamily="@font/google_sans_medium" android:textSize="20sp" /> @@ -35,24 +35,23 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="5dp" + android:fontFamily="@font/google_sans_regular" android:gravity="center" android:textColor="@color/colorAccent" - android:fontFamily="@font/google_sans_regular" android:textSize="28sp" tools:text="amount" /> - @@ -189,8 +189,8 @@ android:layout_height="wrap_content" android:layout_below="@id/container" android:layout_marginHorizontal="20dp" - app:errorTextColor="#DB1E0B" - android:gravity="top|left"> + android:gravity="top|left" + app:errorTextColor="#DB1E0B"> + android:paddingRight="20dp"> @@ -36,24 +35,23 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="5dp" + android:fontFamily="@font/google_sans_regular" android:gravity="center" android:textColor="@color/colorAccent" - android:fontFamily="@font/google_sans_regular" android:textSize="28sp" tools:text="amount" /> - + android:padding="4dp" + android:text="@string/cancel" + android:textAllCaps="true" + android:textSize="14sp" /> + android:textSize="14sp" /> diff --git a/presentation/src/main/res/layout/dialog_confirm_login_device.xml b/presentation/src/main/res/layout/dialog_confirm_login_device.xml index 2a7a8fdef..7987a70c0 100644 --- a/presentation/src/main/res/layout/dialog_confirm_login_device.xml +++ b/presentation/src/main/res/layout/dialog_confirm_login_device.xml @@ -44,12 +44,12 @@ android:id="@+id/titleTV" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="11dp" android:layout_below="@+id/closeBt" + android:layout_marginTop="11dp" + android:fontFamily="@font/google_sans_medium" android:gravity="center_horizontal|top" android:text="@string/confirm_login_device_title" android:textColor="@color/textColor" - android:fontFamily="@font/google_sans_medium" android:textSize="32sp" /> @@ -59,29 +59,27 @@ android:layout_height="wrap_content" android:layout_below="@id/titleTV" android:layout_marginTop="12dp" + android:fontFamily="@font/google_sans_medium" android:gravity="center_horizontal|top" android:text="@string/confirm_login_device_subtitle" android:textColor="@color/darkGrey_Text_1" - android:fontFamily="@font/google_sans_medium" android:textSize="16sp" /> + android:orientation="horizontal"> - + android:layout_weight="0.25" /> + android:src="@drawable/ic_secure" /> + android:layout_weight="0.25" /> - - + android:textSize="13sp" /> diff --git a/presentation/src/main/res/layout/dialog_create_record_success.xml b/presentation/src/main/res/layout/dialog_create_record_success.xml index 95462b30e..83e554162 100644 --- a/presentation/src/main/res/layout/dialog_create_record_success.xml +++ b/presentation/src/main/res/layout/dialog_create_record_success.xml @@ -32,60 +32,50 @@ + android:layout_marginTop="12dp"> - + android:translationY="-0.5sp" /> + android:src="@drawable/ic_close" + android:visibility="invisible" /> - - - - - + android:textSize="30sp" /> + android:layout_marginBottom="14dp" + android:background="@drawable/shape_round_view" + android:orientation="vertical"> + android:textColor="#8D9299" + android:textSize="12sp" + tools:text="Record Type" /> + android:textColor="@color/darkGrey_Text_1" + android:textSize="20.1sp" + tools:text="Record name" /> diff --git a/presentation/src/main/res/layout/dialog_fullscreen.xml b/presentation/src/main/res/layout/dialog_fullscreen.xml index bd7ebfa30..c6182762d 100644 --- a/presentation/src/main/res/layout/dialog_fullscreen.xml +++ b/presentation/src/main/res/layout/dialog_fullscreen.xml @@ -73,20 +73,20 @@ + android:layout_above="@id/submitButton" + android:layout_below="@id/description"> @@ -107,5 +107,4 @@ - \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_about_me.xml b/presentation/src/main/res/layout/fragment_about_me.xml index f72c76088..abb9deae2 100644 --- a/presentation/src/main/res/layout/fragment_about_me.xml +++ b/presentation/src/main/res/layout/fragment_about_me.xml @@ -1,9 +1,9 @@ + android:layout_height="match_parent" + android:background="@color/brightBackground"> @@ -47,11 +47,11 @@ android:layout_marginStart="@dimen/activity_horizontal_margin" android:layout_marginTop="@dimen/activity_horizontal_margin" android:layout_marginEnd="@dimen/activity_horizontal_margin" + android:fontFamily="@font/google_sans_regular" android:letterSpacing="0.02" android:lineSpacingExtra="6sp" android:text="@string/profile_about_me_text" android:textColor="@color/body_1_87" - android:fontFamily="@font/google_sans_regular" android:textSize="15sp" /> diff --git a/presentation/src/main/res/layout/fragment_account_assign_delegates.xml b/presentation/src/main/res/layout/fragment_account_assign_delegates.xml index b7ab2b721..04d0c2b49 100644 --- a/presentation/src/main/res/layout/fragment_account_assign_delegates.xml +++ b/presentation/src/main/res/layout/fragment_account_assign_delegates.xml @@ -1,35 +1,35 @@ - + android:layout_height="match_parent"> + android:layout_height="match_parent" + android:background="@color/brightBackground" + android:orientation="vertical"> + android:layout_height="wrap_content" + android:orientation="vertical"> - + + android:layout_height="wrap_content" + app:cardBackgroundColor="@color/brightBackground" + app:cardCornerRadius="@dimen/card_radius" + app:cardElevation="@dimen/card_elevation_big" + app:cardUseCompatPadding="true"> + android:textSize="20.1sp" + app:type="medium" /> + android:text="@string/restore_auth_code_description" + android:textColor="@color/body_1" /> + android:paddingBottom="38dp"> + app:reverse="false" /> + app:reverse="true" /> diff --git a/presentation/src/main/res/layout/fragment_account_details.xml b/presentation/src/main/res/layout/fragment_account_details.xml index 773d92df4..f764c855d 100644 --- a/presentation/src/main/res/layout/fragment_account_details.xml +++ b/presentation/src/main/res/layout/fragment_account_details.xml @@ -1,6 +1,5 @@ - + android:layout_marginBottom="57dp" + android:background="@color/colorPrimary"> - + + app:valuecard_title="@string/profile_about_me" /> + app:valuecard_title="@string/app_explanation" /> + app:valuecard_text="@string/profile_privacy_policy_url" + app:valuecard_title="@string/profile_privacy_policy" /> + android:layout_marginBottom="58dp" + android:text="@string/profile_button_show_qr" + android:visibility="gone" /> diff --git a/presentation/src/main/res/layout/fragment_account_new.xml b/presentation/src/main/res/layout/fragment_account_new.xml index baefb4755..9623e6421 100644 --- a/presentation/src/main/res/layout/fragment_account_new.xml +++ b/presentation/src/main/res/layout/fragment_account_new.xml @@ -1,11 +1,10 @@ - + android:layout_height="match_parent" + android:background="@color/colorPrimary"> + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingBottom="0dp"> - + + android:lineSpacingExtra="6sp" + android:text="@string/new_account_subtitle" + android:textColor="@color/body_1_87" + android:textSize="14sp" /> + android:background="@color/secondary200" /> + android:layout_height="wrap_content" + android:orientation="vertical" + android:padding="@dimen/activity_horizontal_margin"> + android:layout_height="0px" + android:focusable="true" + android:focusableInTouchMode="true" /> + app:validationRegex="email" /> + app:validationRegex="email" /> + app:hint="@string/new_account_field_first_name" /> + app:hint="@string/new_account_field_last_name" /> + android:visibility="gone" + app:hint="@string/new_account_field_bsn" /> + android:visibility="gone" + app:hint="@string/new_account_field_phone" /> + android:text="@string/welcome_create_account" /> @@ -130,28 +129,28 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + android:layout_height="wrap_content" + android:layout_centerVertical="true" /> diff --git a/presentation/src/main/res/layout/fragment_account_pair_device.xml b/presentation/src/main/res/layout/fragment_account_pair_device.xml index 0d0b62efc..477e7db88 100644 --- a/presentation/src/main/res/layout/fragment_account_pair_device.xml +++ b/presentation/src/main/res/layout/fragment_account_pair_device.xml @@ -15,10 +15,8 @@ - + android:orientation="vertical"> - + android:layout_height="match_parent" + android:background="@color/colorPrimary"> + android:layout_height="wrap_content" + android:orientation="vertical"> - + + android:orientation="vertical"> + android:paddingEnd="27dp" + android:text="@string/restore_email_description" /> + app:validationRegex="email" /> + app:validationRegex="email" /> @@ -77,11 +76,11 @@ + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp"> @@ -68,11 +68,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" + android:layout_marginStart="30dp" android:layout_marginTop="19dp" + android:layout_marginEnd="30dp" android:adjustViewBounds="true" android:scaleType="fitXY" - android:layout_marginStart="30dp" - android:layout_marginEnd="30dp" android:src="@drawable/ic_success_restore_png" /> + android:text="@string/next_step" /> - + android:layout_height="match_parent" + android:background="@color/colorPrimary"> + android:layout_height="wrap_content" + android:layout_margin="17dp" + android:orientation="vertical"> - + @@ -48,22 +47,22 @@ + android:background="@color/secondary200" /> @@ -93,7 +92,7 @@ style="?android:attr/progressBarStyle" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_gravity="center"/> + android:layout_gravity="center" /> diff --git a/presentation/src/main/res/layout/fragment_bottom_sheet.xml b/presentation/src/main/res/layout/fragment_bottom_sheet.xml index 6a828a047..43b3a5341 100644 --- a/presentation/src/main/res/layout/fragment_bottom_sheet.xml +++ b/presentation/src/main/res/layout/fragment_bottom_sheet.xml @@ -1,37 +1,35 @@ + android:layout_height="match_parent"> - + android:src="@drawable/ic_close" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" /> @@ -39,10 +37,10 @@ android:id="@+id/fragmentContainer" android:layout_width="match_parent" android:layout_height="match_parent" - android:focusableInTouchMode="true" android:layout_marginTop="10dp" + android:focusableInTouchMode="true" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintTop_toBottomOf="@+id/slidingPanelTitle"/> + app:layout_constraintTop_toBottomOf="@+id/slidingPanelTitle" /> \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_check_email.xml b/presentation/src/main/res/layout/fragment_check_email.xml index f08beacf4..bd1bdc521 100644 --- a/presentation/src/main/res/layout/fragment_check_email.xml +++ b/presentation/src/main/res/layout/fragment_check_email.xml @@ -6,20 +6,20 @@ + android:layout_width="match_parent" + android:layout_height="192dp"> + app:toolbarId="@+id/toolbar"> + android:layout_width="match_parent" + android:layout_height="?attr/actionBarSize"> diff --git a/presentation/src/main/res/layout/fragment_confirm_registration.xml b/presentation/src/main/res/layout/fragment_confirm_registration.xml index 4a4a3e350..2b85eae25 100644 --- a/presentation/src/main/res/layout/fragment_confirm_registration.xml +++ b/presentation/src/main/res/layout/fragment_confirm_registration.xml @@ -1,11 +1,10 @@ - + android:layout_height="match_parent" + android:background="@color/colorPrimary"> + android:layout_height="wrap_content" + android:orientation="vertical"> - + + android:orientation="vertical"> + android:textSize="32sp" + app:layout_constraintTop_toBottomOf="@id/titleLayout" /> - + android:adjustViewBounds="true" + android:scaleType="fitXY" + android:src="@drawable/ic_check_email_img" + app:layout_constraintTop_toBottomOf="@id/title" /> @@ -71,7 +67,6 @@ - diff --git a/presentation/src/main/res/layout/fragment_create_record.xml b/presentation/src/main/res/layout/fragment_create_record.xml index 3eb77360f..afb34e3bd 100644 --- a/presentation/src/main/res/layout/fragment_create_record.xml +++ b/presentation/src/main/res/layout/fragment_create_record.xml @@ -2,10 +2,9 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context="io.forus.me.android.presentation.view.screens.records.create_record.create_record_fragment.CreateRecordFragment" android:layout_margin="16dp" android:orientation="vertical" - > + tools:context="io.forus.me.android.presentation.view.screens.records.create_record.create_record_fragment.CreateRecordFragment"> + android:paddingLeft="6dp" + android:paddingRight="6dp" /> - + android:gravity="top" + android:imeOptions="actionDone" + android:inputType="text" /> diff --git a/presentation/src/main/res/layout/fragment_dashboard.xml b/presentation/src/main/res/layout/fragment_dashboard.xml index a4a88adf0..d9ea9dc69 100644 --- a/presentation/src/main/res/layout/fragment_dashboard.xml +++ b/presentation/src/main/res/layout/fragment_dashboard.xml @@ -24,8 +24,7 @@ android:id="@+id/coordinator" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_above="@+id/bottom_navigation" - /> + android:layout_above="@+id/bottom_navigation" /> - + + android:text="@string/lock_fingerprint_subtitle" + android:textColor="@color/body_1_87" + android:textSize="15sp" /> + android:layout_height="wrap_content" + android:layout_centerInParent="true" + android:orientation="vertical"> + android:text="@string/lock_fingerprint_hint" + android:textColor="@color/body_1_87" + android:textSize="14.1sp" /> + android:layout_alignParentBottom="true" + android:paddingStart="35dp" + android:paddingBottom="40dp"> + android:text="@string/lock_fingerprint_cancel" + android:textColor="@color/forus_blue" + android:textSize="15sp" + app:type="bold" /> diff --git a/presentation/src/main/res/layout/fragment_login_sign_up.xml b/presentation/src/main/res/layout/fragment_login_sign_up.xml index 64b75ea8b..94ffb4efd 100644 --- a/presentation/src/main/res/layout/fragment_login_sign_up.xml +++ b/presentation/src/main/res/layout/fragment_login_sign_up.xml @@ -1,28 +1,23 @@ - - - + android:orientation="vertical"> + android:paddingRight="30dp"> - + + android:visibility="gone" /> + android:layout_gravity="center_horizontal" + android:src="@drawable/ic_me_logo" /> - - + android:textColor="#3e4a59" + android:textSize="17sp" + app:type="regular" /> + app:validationRegex="email" /> + android:text="@string/qr_popup_restore_identity_title" /> + android:text="@string/restore_account_pair" + app:reverse="true" /> \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_login_sign_up_nokia1.xml b/presentation/src/main/res/layout/fragment_login_sign_up_nokia1.xml index b1cb23158..9d12b5a26 100644 --- a/presentation/src/main/res/layout/fragment_login_sign_up_nokia1.xml +++ b/presentation/src/main/res/layout/fragment_login_sign_up_nokia1.xml @@ -57,9 +57,9 @@ android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginTop="8dp" + android:fontFamily="@font/google_sans_regular" android:lineSpacingExtra="1sp" android:text="@string/welcome_set_up_your_identity" - android:fontFamily="@font/google_sans_regular" android:textColor="#3e4a59" android:textSize="17sp" app:type="regular" /> @@ -72,10 +72,9 @@ android:layout_marginTop="17dp" android:inputType="textEmailAddress" app:hint="@string/new_account_field_email" - app:validationError="@string/me_validation_error_email_is_invalid" - app:validationRegex="email" app:type="regular" - /> + app:validationError="@string/me_validation_error_email_is_invalid" + app:validationRegex="email" /> + app:type="regular" /> diff --git a/presentation/src/main/res/layout/fragment_new_record.xml b/presentation/src/main/res/layout/fragment_new_record.xml index 4ef07c47b..e8d45a5b5 100644 --- a/presentation/src/main/res/layout/fragment_new_record.xml +++ b/presentation/src/main/res/layout/fragment_new_record.xml @@ -2,52 +2,63 @@ + android:layout_height="match_parent" + android:orientation="vertical"> - + + android:layout_height="match_parent" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - - - - + - + + + + + + + + android:background="@color/seashell"> + app:ci_height="6dp" + app:ci_margin="10dp" + app:ci_width="6dp" /> @@ -64,10 +75,10 @@ + android:layout_height="wrap_content" + android:layout_centerVertical="true" + android:paddingBottom="200dp" /> \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_pinlock.xml b/presentation/src/main/res/layout/fragment_pinlock.xml index 6c0873eac..387dea81e 100644 --- a/presentation/src/main/res/layout/fragment_pinlock.xml +++ b/presentation/src/main/res/layout/fragment_pinlock.xml @@ -23,29 +23,28 @@