Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix-Added missing string resource #204

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 29 additions & 15 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ android {
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
Expand Down Expand Up @@ -81,6 +82,9 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$rootProject.kotlinVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$rootProject.kotlinVersion"

// Circle Image View
implementation 'de.hdodenhof:circleimageview:3.0.1'

// Support Dependencies
implementation "androidx.appcompat:appcompat:$rootProject.supportLibraryVersion"
implementation "com.google.android.material:material:$rootProject.supportLibraryVersion"
Expand Down Expand Up @@ -127,14 +131,18 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:4.8.0'
kapt 'com.github.bumptech.glide:compiler:4.8.0'

implementation 'me.dm7.barcodescanner:zxing:1.9.13'
implementation 'com.karumi:dexter:5.0.0'
implementation 'com.hover:android-sdk:1.5.1'

//dbFlow for database
kapt "com.github.Raizlabs.DBFlow:dbflow-processor:$rootProject.dbFlowVersion"
implementation "com.github.Raizlabs.DBFlow:dbflow-core:$rootProject.dbFlowVersion"
implementation "com.github.Raizlabs.DBFlow:dbflow:$rootProject.dbFlowVersion"
implementation "com.github.Raizlabs.DBFlow:dbflow-kotlinextensions:$rootProject.dbFlowVersion"
implementation "com.github.Raizlabs.DBFlow:dbflow-rx2:$rootProject.dbFlowVersion"
implementation "com.github.Raizlabs.DBFlow:dbflow-rx2-kotlinextensions:$rootProject.dbFlowVersion"

implementation 'com.android.support:multidex:1.0.3'
//OpenSource Licences
implementation "com.google.android.gms:play-services-oss-licenses:17.0.0"

Expand All @@ -161,35 +169,41 @@ dependencies {
testImplementation "org.hamcrest:hamcrest-core:$rootProject.hamcrestVersion"
testImplementation "org.hamcrest:hamcrest-library:$rootProject.hamcrestVersion"
testImplementation "org.hamcrest:hamcrest-integration:$rootProject.hamcrestVersion"
testImplementation 'org.robolectric:robolectric:3.3.1'
testImplementation 'org.robolectric:robolectric:4.2.1'

//Navigation
def nav_version = "2.3.2"

implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
}

// Log out test results to console
tasks.matching { it instanceof Test }.all {
testLogging.events = ["failed", "passed", "skipped"]
}
// Log out test results to console
tasks.matching { it instanceof Test }.all {
testLogging.events = ["failed", "passed", "skipped"]
}

/*
/*
Resolves dependency versions across test and production APKs, specifically, transitive
dependencies. This is required since Espresso internally has a dependency on support-annotations.
*/
configurations.all {
resolutionStrategy {
force 'com.android.support:support-annotations:27.1.1'
force 'com.google.code.findbugs:jsr305:1.3.9'
}
configurations.all {
resolutionStrategy {
force 'com.android.support:support-annotations:27.1.1'
force 'com.google.code.findbugs:jsr305:1.3.9'
}
}


/*
/*
All direct/transitive dependencies shared between your test and production APKs need to be
excluded from the test APK! This is necessary because both APKs will contain the same classes. Not
excluding these dependencies from your test configuration will result in an dex pre-verifier error
at runtime. More info in this tools bug: (https://code.google.com/p/android/issues/detail?id=192497)
*/
configurations.compile.dependencies.each { compileDependency ->
configurations.compile.dependencies.each { compileDependency ->
println "Excluding compile dependency: ${compileDependency.getName()}"
configurations.androidTestCompile.dependencies.each { androidTestCompileDependency ->
configurations.androidTestCompile.exclude module: "${compileDependency.getName()}"
}
}
}
40 changes: 30 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.mifos.mobile.cn">
package="org.mifos.mobile.cn">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />

<application
android:name=".MifosApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:name=".MifosApplication"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ui.mifos.launcher.LauncherActivity"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity
android:name=".ui.mifos.launcher.LauncherActivity"
android:theme="@style/LauncherTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".ui.mifos.DashboardActivity" />
<activity android:name=".ui.mifos.login.LoginActivity"
android:screenOrientation="portrait"/>
Expand All @@ -38,9 +44,23 @@
<activity android:name=".ui.mifos.debtincomereport.DebtIncomeReportActivity"/>
<activity android:name=".ui.mifos.aboutus.AboutUsActivity"/>
<activity android:name=".ui.mifos.privacypolicy.PrivacyPolicyActivity"/>
<activity
<activity android:name=".ui.mifos.Main" />
<activity android:name=".ui.mifos.signup.SignupActivity" />
<activity android:name=".ui.mifos.Notification" />
<activity android:name=".ui.mifos.Send" >
<intent-filter>
<action android:name="com.hover.sdk.RETURN_FROM_SETTINGS" />
</intent-filter>
</activity>
<activity android:name=".ui.mifos.QRGenerator" />

<activity android:name=".ui.mifos.beneficiaries.BeneficiariesActivity" />
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar" />
<meta-data
android:name="com.hover.ApiKey"
android:value="Your API key"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package org.mifos.mobile.cn.data.datamanager

import android.util.Base64
import io.reactivex.Observable
import io.reactivex.ObservableSource
import io.reactivex.functions.Function
import org.mifos.mobile.cn.data.local.PreferencesHelper
import org.mifos.mobile.cn.data.models.Authentication
import org.mifos.mobile.cn.data.remote.BaseApiManager
import org.mifos.mobile.cn.fakesource.FakeRemoteDataSource
import java.nio.charset.Charset
import javax.inject.Inject
import javax.inject.Singleton

Expand Down Expand Up @@ -43,6 +48,10 @@ class DataManagerAuth @Inject constructor(private val baseApiManager: BaseApiMan
return@concatMap Observable.just(loginResponse)
})
}*/
fun login(username: String, password: String): Observable<Authentication> {
return baseApiManager.getAuthApi().login(username,
Base64.encodeToString(password.toByteArray(Charset.forName("UTF-8")), Base64.NO_WRAP))
}
fun refreshToken(): Observable<Authentication> {
return baseApiManager.getAuthApi().refreshToken()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package org.mifos.mobile.cn.data.local

object PreferenceKey {

const val PREF_ICOMMIT = "preferences_icommit"
const val PREF_MIFOS = "preferences_mifos"

const val PREF_KEY_ACCESS_TOKEN = "PREF_KEY_ACCESS_TOKEN"

const val PREF_KEY_COOKIES = "PREF_KEY_COOKIES"
const val PREF_KEY_LOGIN_STATUS = "PREF_KEY_LOGIN_STATUS"

const val PREF_KEY_TENANT_IDENTIFIER = "PREF_KEY_TENANT_IDENTIFIER"
const val PREF_KEY_USER_NAME = "PREF_KEY_USER_NAME"

//TODO:remove this while implementing API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PreferencesHelper
constructor(@ApplicationContext context: Context) {

private val preferences: SharedPreferences = context.getSharedPreferences(
PreferenceKey.PREF_ICOMMIT, Context.MODE_PRIVATE)
PreferenceKey.PREF_MIFOS, Context.MODE_PRIVATE)
private val gson: Gson = GsonBuilder()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz")
.create()
Expand Down Expand Up @@ -74,11 +74,12 @@ constructor(@ApplicationContext context: Context) {

fun putAccessToken(accessToken: String) {
preferences.edit().putString(
PreferenceKey.PREF_KEY_ACCESS_TOKEN, "Basic $accessToken").apply()
PreferenceKey.PREF_KEY_ACCESS_TOKEN, accessToken).apply()
}

val accessToken: String
get() = preferences.getString(PreferenceKey.PREF_KEY_ACCESS_TOKEN, null)
fun getAccessToken(): String? {
return preferences.getString(PreferenceKey.PREF_KEY_ACCESS_TOKEN, null)
}

fun putLoginStatus(loginStatus: Boolean) {
preferences.edit().putBoolean(PreferenceKey.PREF_KEY_LOGIN_STATUS, loginStatus).apply()
Expand All @@ -91,26 +92,34 @@ constructor(@ApplicationContext context: Context) {
preferences.edit().putString(PreferenceKey.PREF_KEY_USER_NAME, username).apply()
}

fun getUserName(): String? {
return preferences.getString(PreferenceKey.PREF_KEY_USER_NAME, null)
}
fun getSignedInUser(): Authentication? {
val userJson = preferences.getString(PreferenceKey.PREF_KEY_SIGNED_IN_USER, null)
?: return null
return gson.fromJson<Authentication>(userJson, Authentication::class.java!!)
return gson.fromJson(userJson, Authentication::class.java)
}

fun putSignInUser(user: Authentication) {
preferences.edit().putString(PreferenceKey.PREF_KEY_SIGNED_IN_USER,
gson.toJson(user)).apply()
}
fun putTenantIdentifier(tenantIdentifier: String) {
preferences.edit().putString(PreferenceKey.PREF_KEY_TENANT_IDENTIFIER,
tenantIdentifier).apply()
}

val username: String
get() = preferences.getString(PreferenceKey.PREF_KEY_USER_NAME, null)
fun getTenantIdentifier(): String? {
return preferences.getString(PreferenceKey.PREF_KEY_TENANT_IDENTIFIER, null)
}

//TODO: remove the password prefernce helper
fun putPassword(password: String) {
/* fun putPassword(password: String) {
preferences.edit().putString(PreferenceKey.PREF_KEY_PASSWORD, password).apply()
}

val password: String
get() = preferences.getString(PreferenceKey.PREF_KEY_PASSWORD, null)

*/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.mifos.mobile.cn.data.models.beneficiaries

data class Beneficiary(val name: String, val description: String, val price: String)
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import org.mifos.mobile.cn.BuildConfig
object BaseUrl {

private const val PROTOCOL_HTTPS = "http://"
private const val API_TEST_ENDPOINT = "example.com"
private const val API_TEST_ENDPOINT = "buffalo.mifos.io"
private const val API_PRODUCTION_ENDPOINT = "example.com"
private const val PORT = "8000"
private const val PORT = "4200"
// "/" in the last of the base url always

val defaultBaseUrl: String
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.mifos.mobile.cn.data.remote

import android.content.Context
import okhttp3.Interceptor
import okhttp3.Response
import org.mifos.mobile.cn.exceptions.NoConnectivityException
import org.mifos.mobile.cn.ui.utils.Network
import java.io.IOException

/**
* @author Rajan Maurya
* On 23/09/17.
*/
class ConnectivityInterceptor(private val context: Context) : Interceptor {
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response {
if (!Network.isConnected(context)) {
throw NoConnectivityException()
}
val builder = chain.request().newBuilder()
return chain.proceed(builder.build())
}

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package org.mifos.mobile.cn.data.remote

import android.content.Context
import androidx.annotation.NonNull
import android.text.TextUtils
import androidx.annotation.NonNull
import okhttp3.Interceptor
import okhttp3.Response
import org.mifos.mobile.cn.MifosApplication
import org.mifos.mobile.cn.data.local.PreferenceKey
import org.mifos.mobile.cn.data.local.PreferencesHelper
import org.mifos.mobile.cn.injection.ApplicationContext
import java.io.IOException
import java.util.*
import javax.inject.Inject

class MifosInterceptor @Inject constructor(@ApplicationContext context: Context) : Interceptor {
Expand All @@ -22,18 +24,54 @@ class MifosInterceptor @Inject constructor(@ApplicationContext context: Context)

companion object {
val HEADER_ACCESS_TOKEN = "access_token"
val HEADER_TENANT = "X-Tenant-Identifier"
val HEADER_AUTH = "Authorization"
val HEADER_ACCEPT_JSON = "Accept"
val HEADER_CONTENT_TYPE = "Content-type"
val HEADER_USER = "User"
}

@Throws(IOException::class)
override fun intercept(@NonNull chain: Interceptor.Chain): Response {
val chainRequest = chain.request()
val builder = chainRequest.newBuilder()

val accessToken = preferencesHelper.accessToken
//TODO fix call single time instead of calling every request
val authToken: String? = preferencesHelper.getAccessToken()
val tenantIdentifier = preferencesHelper.getTenantIdentifier()
val user: String? = preferencesHelper.getUserName()
val refreshTokenStatus = preferencesHelper.getBoolean(
PreferenceKey.PREF_KEY_REFRESH_ACCESS_TOKEN, false)

builder.header(HEADER_ACCEPT_JSON, "application/json")
builder.header(HEADER_CONTENT_TYPE, "application/json")

if (refreshTokenStatus) {
//Add Cookies
val cookies = preferencesHelper.getStringSet(
PreferenceKey.PREF_KEY_COOKIES) as HashSet<String>?
if (cookies != null) {
for (cookie in cookies) {
builder.addHeader("Cookie", cookie)
}
}
} else {
if (!TextUtils.isEmpty(authToken)) {
builder.header(HEADER_AUTH, authToken)
}
if (!TextUtils.isEmpty(user)) {
builder.header(HEADER_USER, user)
}
}

if (!TextUtils.isEmpty(tenantIdentifier)) {
builder.header(HEADER_TENANT, "tn01")
}
/*val accessToken = preferencesHelper.accessToken

if (!TextUtils.isEmpty(accessToken)) {
builder.header(HEADER_ACCESS_TOKEN, preferencesHelper.accessToken)
}
}*/

val request = builder.build()
return chain.proceed(request)
Expand Down
Loading