Skip to content

Commit

Permalink
Merge pull request #22 from initflow/development
Browse files Browse the repository at this point in the history
pre-release v1.0.0-alpha.2
  • Loading branch information
iNomaD authored Sep 19, 2018
2 parents 6ed35c7 + 73096b5 commit 6079dc6
Show file tree
Hide file tree
Showing 292 changed files with 2,636 additions and 2,004 deletions.
17 changes: 6 additions & 11 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
image: jangrewe/gitlab-ci-android

stages:
- telegram
- distribution

before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle
Expand All @@ -12,15 +12,10 @@ cache:
paths:
- .gradle/


telegram:
stage: telegram
# only:
# - master
distribution:
stage: distribution
only:
- development
script:
- cd presentation
- ../gradlew assembleDebug
- cd ..
- git log -p -1 > release_notes.txt
- /bin/bash telegram.sh -t ${TELEGRAM_TOKEN} -c ${TELEGRAM_CHAT_ID} -f release_notes.txt "Build comments"
- /bin/bash telegram.sh -t ${TELEGRAM_TOKEN} -c ${TELEGRAM_CHAT_ID} -f presentation/build/outputs/apk/debug/presentation-debug.apk
- ../gradlew assembleRelease crashlyticsUploadDistributionDebug
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@ buildscript {
mavenCentral()
google()
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'me.tatarka:gradle-retrolambda:3.2.3'
classpath 'io.fabric.tools:gradle:1.25.4'
}
}

allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }
google()
maven { url "https://dl.bintray.com/drummer-aidan/maven/" }
}
ext {
androidApplicationId = 'io.forus.me.android.presentation'
Expand Down
7 changes: 7 additions & 0 deletions buildsystem/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ext {
androidAnnotationsVersion = '21.0.3'
arrowVersion = '1.0.0'
circleIndicatorVersion = '1.2.2@aar'
materialDialogs = '0.9.6.0'

//Testing
robolectricVersion = '3.1.1'
Expand All @@ -47,11 +48,13 @@ ext {
ahbottomNavigationVersion='2.0.4'
slidingUpPanelVersion='3.3.1'
glideVersion='3.7.0'
fingerprintAuthVersion='1.0.1'

//Development
leakCanaryVersion = '1.3.1'
qrReaderVersion='2.0.3@aar'
animoVersion='1.1.8'
fabric='2.9.5@aar'


presentationDependencies = [
Expand Down Expand Up @@ -84,6 +87,10 @@ ext {

circleIndicator: "me.relex:circleindicator:$rootProject.circleIndicatorVersion",
qrReader: "com.dlazaro66.qrcodereaderview:qrcodereaderview:${rootProject.qrReaderVersion}",
materialDialogs: "com.afollestad.material-dialogs:core:${rootProject.materialDialogs}",
fingerprint: "com.multidots:fingerprint-auth:${rootProject.fingerprintAuthVersion}",
fabric: "com.crashlytics.sdk.android:crashlytics:${rootProject.fabric}"

]

presentationTestDependencies = [
Expand Down
2 changes: 1 addition & 1 deletion data/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.forus.me.android.data">

<application android:allowBackup="true" />
<application android:allowBackup="false" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

public interface Database {

void refresh();

boolean exists();

boolean isOpen();

boolean open(String pin);

boolean checkPin(String pin);

boolean close();

boolean delete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class DatabaseManager private constructor() : Database {

lateinit var database: Database

override fun refresh() {
return database.refresh()
}

override fun exists(): Boolean {
return database.exists()
}
Expand All @@ -26,6 +30,10 @@ class DatabaseManager private constructor() : Database {
return database.open(pin)
}

override fun checkPin(pin: String): Boolean {
return database.checkPin(pin)
}

override fun close(): Boolean {
return database.close()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,12 @@ public SortCategories() {
public SortCategories(List<Long> categories) {
this.categories = categories;
}

public List<Long> getCategories() {
return categories;
}

public void setCategories(List<Long> categories) {
this.categories = categories;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void write(JsonWriter out, SignRecords value) throws IOException {
}

@Override
public SignRecords read(JsonReader in) throws IOException {
public SignRecords read(JsonReader in) {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.forus.me.android.data.entity.sign.response;

import com.google.gson.annotations.SerializedName;

public class CheckTokenResult {

public enum State {
active, invalid, pending
}

@SerializedName("message")
private State state;

public CheckTokenResult() { }

public CheckTokenResult(State state) {
this.state = state;
}

public State getState() {
return state;
}

public void setState(State state) {
this.state = state;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package io.forus.me.android.data.exception
*/
class NetworkConnectionException : Exception {

constructor() : super() {}
constructor() : super()

constructor(cause: Throwable) : super(cause) {}
constructor(cause: Throwable) : super(cause)
}

This file was deleted.

3 changes: 2 additions & 1 deletion data/src/main/java/io/forus/me/android/data/net/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package io.forus.me.android.data.net


import io.forus.me.android.data.BuildConfig
public object Constants {

object Constants {


val BASE_SERVICE_ENDPOINT = if (BuildConfig.DEBUG) "https://test.platform.forus.io/" else "https://test.platform.forus.io/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static MeServiceFactory getInstance() {
}

private MeServiceFactory(AccountLocalDataSource accountLocalDataSource) {
this.accountLocalDataSource = accountLocalDataSource;
MeServiceFactory.accountLocalDataSource = accountLocalDataSource;
}

public static void init(Context context, AccountLocalDataSource accountLocalDataSource){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import io.forus.me.android.data.entity.common.Success
import io.forus.me.android.data.entity.sign.request.AuthorizeCode
import io.forus.me.android.data.entity.sign.request.AuthorizeToken
import io.forus.me.android.data.entity.sign.request.RestoreByEmail
import io.forus.me.android.data.entity.sign.response.AccessToken
import io.forus.me.android.data.entity.sign.response.IdentityPinResult
import io.forus.me.android.data.entity.sign.response.IdentityTokenResult
import io.forus.me.android.data.entity.sign.response.SignUpResult
import io.forus.me.android.data.entity.sign.response.*
import io.forus.me.android.data.net.Constants
import io.reactivex.Observable
import retrofit2.http.*
Expand Down Expand Up @@ -46,4 +43,8 @@ interface SignService {
@POST("api/v1/identity/proxy/authorize/token")
fun authorizeToken(@Body authorizeToken: AuthorizeToken): Observable<Success>


@GET("api/v1/identity/proxy/check-token")
fun checkToken(@Query("access_token") token: String): Observable<CheckTokenResult>

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ package io.forus.me.android.data.repository.account
import com.gigawatt.android.data.net.sign.models.request.SignUp
import io.forus.me.android.data.entity.sign.request.SignRecords
import io.forus.me.android.data.repository.account.datasource.AccountDataSource
import io.forus.me.android.data.repository.account.datasource.remote.CheckActivationDataSource
import io.forus.me.android.data.repository.records.RecordsRepository
import io.forus.me.android.data.repository.settings.SettingsDataSource
import io.forus.me.android.domain.models.account.*
import io.reactivex.Observable
import io.reactivex.Single
import io.reactivex.functions.BiFunction
import java.util.concurrent.TimeUnit
import java.util.stream.Stream

class AccountRepository(private val accountLocalDataSource: AccountDataSource, private val accountRemoteDataSource: AccountDataSource, private val recordsRepository: RecordsRepository) : io.forus.me.android.domain.repository.account.AccountRepository {
class AccountRepository(private val settingsDataSource: SettingsDataSource,
private val accountLocalDataSource: AccountDataSource,
private val accountRemoteDataSource: AccountDataSource,
private val checkActivationDataSource: CheckActivationDataSource,
private val recordsRepository: RecordsRepository) : io.forus.me.android.domain.repository.account.AccountRepository {

override fun newUser(model: NewAccountRequest): Observable<String> {
val signUp = SignUp()
Expand Down Expand Up @@ -54,24 +60,54 @@ class AccountRepository(private val accountLocalDataSource: AccountDataSource, p
}

override fun createIdentity(identity: Identity): Observable<Boolean> {
return Single.just(accountLocalDataSource.saveIdentity(identity.accessToken, identity.pin)).toObservable()
.delay(100, TimeUnit.MILLISECONDS)
return Single.fromCallable {
if(accountLocalDataSource.saveIdentity(identity.accessToken, identity.pin)) {
settingsDataSource.clear()
settingsDataSource.setPin(identity.pin)
}else false
}.toObservable().delay(100, TimeUnit.MILLISECONDS)
}

override fun unlockIdentity(pin: String): Observable<Boolean> {
return Single.just(accountLocalDataSource.unlockIdentity(pin)).toObservable()
//.delay(100, TimeUnit.MILLISECONDS)
}

override fun checkPin(pin: String): Observable<Boolean> {
return try {
Single.just(settingsDataSource.getPin() == pin)
}
catch(e: Exception){
Single.error<Boolean>(e)
}
.toObservable()
}

override fun setFingerprintEnabled(isFingerprintEnabled: Boolean): Observable<Boolean> {
return Single.fromCallable { settingsDataSource.setFingerprintEnabled(isFingerprintEnabled); true }.toObservable()
}


override fun changePin(oldPin: String, newPin: String): Observable<Boolean> {
return Single.fromCallable{
if(accountLocalDataSource.changePin(oldPin, newPin)) {
if(newPin == "") settingsDataSource.setFingerprintEnabled(false)
settingsDataSource.setPin(newPin)
} else false
}.toObservable()
}

override fun exitIdentity(): Observable<Boolean> {
return Single.fromCallable {accountLocalDataSource.logout(); true }.toObservable()
.delay(100, TimeUnit.MILLISECONDS)
return Single.fromCallable {
accountLocalDataSource.logout()
settingsDataSource.clear()
true
}.toObservable()
}

override fun getAccount(): Observable<Account> {
return recordsRepository.getRecords().map {

val account = Account();
val account = Account()
val email = com.annimon.stream.Stream.of(it).filter { x->x.recordType.key == "primary_email" }.findFirst()
val givanName = com.annimon.stream.Stream.of(it).filter { x->x.recordType.key == "given_name" }.findFirst()
val familyName = com.annimon.stream.Stream.of(it).filter { x->x.recordType.key == "family_name" }.findFirst()
Expand All @@ -81,4 +117,22 @@ class AccountRepository(private val accountLocalDataSource: AccountDataSource, p
account
}
}

override fun getSecurityOptions(): Observable<SecurityOptions> {
return Single.zip(
Single.just(settingsDataSource.isPinEnabled()),
Single.just(settingsDataSource.isFingerprintEnabled()),
BiFunction { pinEnabled: Boolean, fingerprintEnabled: Boolean ->
SecurityOptions(pinEnabled, fingerprintEnabled)
}
).toObservable()
}

override fun checkCurrentToken(): Observable<Boolean>{
return checkActivationDataSource.checkActivation(accountLocalDataSource.getCurrentToken())
}

override fun unlockByFingerprint(): Observable<Boolean> {
return Single.just(accountLocalDataSource.unlockIdentity(settingsDataSource.getPin())).toObservable()
}
}
Loading

0 comments on commit 6079dc6

Please sign in to comment.