* 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