Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 4 additions & 9 deletions presentation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ plugins {
id('com.android.application')
id('kotlin-android')
id('kotlin-kapt')
id ('kotlin-parcelize')
id('kotlin-parcelize')
id('org.greenrobot.greendao')
id('com.google.gms.google-services')
id ('androidx.navigation.safeargs')
id('androidx.navigation.safeargs')
}

def secretsPropertiesFile = rootProject.file("secrets.properties")
Expand Down Expand Up @@ -54,7 +54,6 @@ android {
}



compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
Expand Down Expand Up @@ -192,7 +191,7 @@ dependencies {
implementation "com.hannesdorfmann.mosby3:mvi:3.1.1"
implementation "com.hannesdorfmann.mosby3:viewstate:3.1.1"

// implementation 'com.github.sockeqwe:mosby:345efbb0c0'
// implementation 'com.github.sockeqwe:mosby:345efbb0c0'


implementation "com.jakewharton.rxbinding2:rxbinding:2.2.0"
Expand Down Expand Up @@ -225,10 +224,6 @@ dependencies {
implementation("androidx.annotation:annotation:1.8.2")






compileOnly presentationDependencies.javaxAnnotation

androidTestImplementation presentationTestDependencies.mockito
Expand All @@ -253,7 +248,7 @@ dependencies {

//implementation ('com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.3@aar'){
// transitive = true
// }
// }

implementation 'com.github.dlazaro66:QRCodeReaderView:2.0.3'

Expand Down
4 changes: 2 additions & 2 deletions presentation/src/demo/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
</adaptive-icon>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
</adaptive-icon>
1 change: 1 addition & 0 deletions presentation/src/dev/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application android:usesCleartextTraffic="true" />
</manifest>
4 changes: 2 additions & 2 deletions presentation/src/dev/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
</adaptive-icon>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
</adaptive-icon>
12 changes: 5 additions & 7 deletions presentation/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,16 @@
android:theme="@style/AppTheme">



<uses-library
android:name="org.apache.http.legacy"
android:required="false" />



<activity
android:name=".view.screens.vouchers.voucher_with_actions.payment.ActionPaymentActivity"
android:exported="false"
android:screenOrientation="portrait"
android:stateNotNeeded="true"
android:exported="false"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".view.screens.vouchers.voucher_with_actions.ActionsActivity"
Expand Down Expand Up @@ -73,8 +71,8 @@
<activity
android:name=".view.screens.main.MainActivity"
android:exported="true"
android:launchMode="singleTask"
android:label="@string/app_name">
android:label="@string/app_name"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down Expand Up @@ -104,8 +102,8 @@
android:name=".view.screens.welcome.WelcomeActivity"
android:exported="false"
android:label="@string/app_name"
android:theme="@style/WelcomeMaterialTheme"
android:launchMode="singleTop" />
android:launchMode="singleTop"
android:theme="@style/WelcomeMaterialTheme" />
<activity
android:name=".view.screens.lock.PinLockActivity"
android:exported="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,16 @@ class AndroidApplication : Application() {

SharedPref.init(this)
if (!BuildConfig.APPLICATION_ID.equals("io.forus.me")) {
val savedApiOption = SharedPref.read(SharedPref.OPTION_API_TYPE,"") ?: ""
val savedApiOption = SharedPref.read(SharedPref.OPTION_API_TYPE, "") ?: ""
if (savedApiOption.isNotEmpty()) {
val apiType = ApiConfig.stringToApiType(savedApiOption)
if (apiType == ApiType.OTHER) {
ApiConfig.changeToCustomApi(SharedPref.read(SharedPref.OPTION_CUSTOM_API_URL, BuildConfig.SERVER_URL))
ApiConfig.changeToCustomApi(
SharedPref.read(
SharedPref.OPTION_CUSTOM_API_URL,
BuildConfig.SERVER_URL
)
)
} else {
ApiConfig.changeApi(apiType)
}
Expand Down Expand Up @@ -83,7 +88,6 @@ class AndroidApplication : Application() {
}



private fun initRetrofit() {
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
Expand Down Expand Up @@ -122,7 +126,6 @@ class AndroidApplication : Application() {
}



override fun onActivityDestroyed(activity: Activity) {}
})
}
Expand All @@ -141,7 +144,7 @@ class AndroidApplication : Application() {
.build()
}
FirebaseFirestore.getInstance().addSnapshotsInSyncListener {
Log.d("FirebaseFirestore","FirebaseFirestore addSnapshotsInSyncListener")
Log.d("FirebaseFirestore", "FirebaseFirestore addSnapshotsInSyncListener")
}

FirebaseStorage.getInstance().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import io.forus.me.android.presentation.helpers.SHA256
import io.forus.me.android.presentation.internal.Injection
import java.security.interfaces.RSAKey

class DatabaseHelper(private val context: Context): Database{
class DatabaseHelper(private val context: Context) : Database {

companion object {
const val DB_NAME = "main-db"
Expand All @@ -30,33 +30,33 @@ class DatabaseHelper(private val context: Context): Database{
private var daoSession: DaoSession? = null
set(value) {
field = value
if(Injection.instance.daoSession != daoSession) Injection.instance.daoSession = daoSession
if (Injection.instance.daoSession != daoSession) Injection.instance.daoSession =
daoSession
}

private fun getPassword(pin: String) = (pin+secret).SHA256()
private fun getPassword(pin: String) = (pin + secret).SHA256()

override fun refresh() {
Injection.instance.accessTokenUpdated()
}

override fun exists(): Boolean{
override fun exists(): Boolean {
val dbFile = context.getDatabasePath(DB_NAME)
return dbFile.exists()
}

override fun isOpen(): Boolean{
override fun isOpen(): Boolean {
return daoSession != null
}

override fun open(pin: String): Boolean{
override fun open(pin: String): Boolean {
return try {
close()
val helper = DaoMaster.DevOpenHelper(context, DB_NAME)
db = helper.getEncryptedWritableDb(getPassword(pin))
daoSession = DaoMaster(db).newSession()
true
}
catch (e: Exception){
} catch (e: Exception) {
false
}
}
Expand All @@ -67,24 +67,22 @@ class DatabaseHelper(private val context: Context): Database{
val db = helper.getEncryptedReadableDb(getPassword(pin))
db?.close()
true
}
catch (e: Exception){
} catch (e: Exception) {
false
}
}

override fun close(): Boolean{
override fun close(): Boolean {
db?.close()
db = null
daoSession = null
return true
}

override fun delete(): Boolean{
return if(exists()){
override fun delete(): Boolean {
return if (exists()) {
close()
context.deleteDatabase(DB_NAME)
}
else false
} else false
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright (C) 2015 Fernando Cejas Open Source Project
*
* <p>
* 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading