Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
:
Browse files Browse the repository at this point in the history
Feat: Adds support for creating, viewing, editing group details, deleting, editing members and leaders name and tasks of group
  • Loading branch information
miPlodder authored and therajanmaurya committed Jul 11, 2020
1 parent 5610a15 commit 592099e
Show file tree
Hide file tree
Showing 58 changed files with 3,618 additions and 27 deletions.
13 changes: 13 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ android {
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}

buildTypes {
Expand Down Expand Up @@ -85,6 +86,10 @@ dependencies {
implementation "androidx.cardview:cardview:$supportLibraryVersion"
implementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
implementation "androidx.annotation:annotation:$supportLibraryVersion"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycleExtension"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycleExtension"


// Kotlin Dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
Expand Down Expand Up @@ -145,6 +150,14 @@ dependencies {

implementation "com.mifos.mobile:mifos-passcode:$mifosPasscodeVersion"

//Easy Validation Library
implementation "com.wajahatkarim3.easyvalidation:easyvalidation-core:$easyValidationVersion"

//Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version_kotlin_coroutines"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$version_kotlin_coroutines"


// Instrumentation test dependencies
androidTestImplementation jUnit
androidTestImplementation mockito
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ public class FakeJsonName {
public static final String PRODUCT_PAGE = "productPage.json";
public static final String PRODUCT_DEFINITION = "productDefinition.json";
public static final String PAYROLL_CONFIG = "payrollConfiguration.json";
public static final String GROUPS = "groups.json";
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.gson.reflect.TypeToken;

import org.apache.fineract.data.models.Authentication;
import org.apache.fineract.data.models.Group;
import org.apache.fineract.data.models.accounts.LedgerPage;
import org.apache.fineract.data.models.accounts.AccountPage;
import org.apache.fineract.data.models.customer.Command;
Expand Down Expand Up @@ -113,4 +114,9 @@ public static PayrollConfiguration getPayrollConfig() {
return testDataFactory.getObjectTypePojo(PayrollConfiguration.class,
FakeJsonName.PAYROLL_CONFIG);
}

public static List<Group> getGroups() {
return testDataFactory.getListTypePojo(new TypeToken<List<Group>>() {
}, FakeJsonName.GROUPS);
}
}
11 changes: 10 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.apache.fineract">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand All @@ -18,8 +19,10 @@
android:allowBackup="true"
android:icon="@drawable/launcher_image"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
tools:targetApi="n">

<provider
android:name="androidx.core.content.FileProvider"
Expand Down Expand Up @@ -86,6 +89,12 @@

<activity android:name=".ui.online.customers.customeractivities.CustomerActivitiesActivity" />

<activity android:name=".ui.online.groups.groupdetails.GroupDetailsActivity" />

<activity
android:name=".ui.online.groups.creategroup.CreateGroupActivity"
android:windowSoftInputMode="adjustResize|stateHidden" />

<receiver
android:name=".jobs.JobsReceiver"
android:exported="false">
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/org/apache/fineract/data/Status.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.apache.fineract.data

/**
* Created by Ahmad Jawid Muhammadi on 6/4/20
*/
enum class Status {
LOADING,
ERROR,
DONE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.apache.fineract.data.datamanager.api

import androidx.lifecycle.MutableLiveData
import io.reactivex.Observable
import io.reactivex.ObservableSource
import io.reactivex.functions.Function
import kotlinx.coroutines.Deferred
import okhttp3.ResponseBody
import org.apache.fineract.FakeRemoteDataSource
import org.apache.fineract.data.local.PreferencesHelper
import org.apache.fineract.data.models.Group
import org.apache.fineract.data.models.customer.Command
import org.apache.fineract.data.remote.BaseApiManager
import javax.inject.Inject


/*
* Created by saksham on 15/June/2019
*/

class DataManagerGroups @Inject constructor(private val baseManagerApi: BaseApiManager,
val dataManagerAuth: DataManagerAuth,
val preferencesHelper: PreferencesHelper)
: FineractBaseDataManager(dataManagerAuth, preferencesHelper) {

fun getGroups(): MutableLiveData<ArrayList<Group>> {
val groups = MutableLiveData<ArrayList<Group>>()

groups.value = ArrayList(baseManagerApi.groupsService.getGroups()
.onErrorResumeNext(Function<Throwable, ObservableSource<List<Group>>> {
Observable.just(FakeRemoteDataSource.getGroups())
}).blockingFirst())
return groups
}

fun createGroup(group: Group): Deferred<ResponseBody> = baseManagerApi.groupsService.createGroup(group)

fun updateGroup(identifier: String, group: Group): Deferred<ResponseBody> {
return baseManagerApi.groupsService.updateGroup(identifier, group)
}

fun changeGroupStatus(identifier: String, command: Command): Deferred<ResponseBody> {
return baseManagerApi.groupsService.changeGroupStatus(identifier, command)
}
}
33 changes: 33 additions & 0 deletions app/src/main/java/org/apache/fineract/data/models/Group.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.apache.fineract.data.models

import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
import org.apache.fineract.data.models.customer.Address

/*
* Created by saksham on 16/June/2019
*/

@Parcelize
data class Group(
var identifier: String? = null,
var groupDefinitionIdentifier: String? = null,
var name: String? = null,
var leaders: List<String>? = null,
var members: List<String>? = null,
var office: String? = null,
var assignedEmployee: String? = null,
var weekday: Int? = null,
var status: Status? = null,
var address: Address? = null,
var createdOn: String? = null,
var createdBy: String? = null,
var lastModifiedBy: String? = null,
var lastModifiedOn: String? = null) : Parcelable {

enum class Status {
PENDING,
ACTIVE,
CLOSED
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.apache.fineract.data.services.AuthService;
import org.apache.fineract.data.services.CustomerService;
import org.apache.fineract.data.services.DepositService;
import org.apache.fineract.data.services.GroupsService;
import org.apache.fineract.data.services.IndividualLendingService;
import org.apache.fineract.data.services.LoanService;
import org.apache.fineract.data.services.ProductService;
Expand Down Expand Up @@ -41,6 +42,7 @@ public class BaseApiManager {
private static TellersService tellerService;
private static ProductService productService;
private static PayrollService payrollService;
private static GroupsService groupsService;

public BaseApiManager(Context context) {
createService(context);
Expand All @@ -58,6 +60,7 @@ private static void init() {
tellerService = createApi(TellersService.class);
productService = createApi(ProductService.class);
payrollService = createApi(PayrollService.class);
groupsService = createApi(GroupsService.class);
}

private static void initAnonymous() {
Expand Down Expand Up @@ -142,4 +145,8 @@ public ProductService getProductService() {
public PayrollService getPayrollService() {
return payrollService;
}

public GroupsService getGroupsService() {
return groupsService;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.apache.fineract.data.services

import io.reactivex.Observable
import kotlinx.coroutines.Deferred
import okhttp3.ResponseBody
import org.apache.fineract.data.models.Group
import org.apache.fineract.data.models.customer.Command
import retrofit2.http.*

/*
* Created by saksham on 15/June/2019
*/

interface GroupsService {

@GET("/groups")
fun getGroups(): Observable<List<Group>>

@POST("/groups")
fun createGroup(@Body group: Group): Deferred<ResponseBody>

@PUT("/groups/{identifier}")
fun updateGroup(@Path("identifier") identifier: String,
@Body group: Group): Deferred<ResponseBody>

@PUT("/groups/{identifier}/commands")
fun changeGroupStatus(@Path("identifier") identifier: String,
@Body command: Command): Deferred<ResponseBody>
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
import org.apache.fineract.ui.online.depositaccounts.depositaccountdetails
.DepositAccountDetailsFragment;
import org.apache.fineract.ui.online.depositaccounts.depositaccountslist.DepositAccountsFragment;
import org.apache.fineract.ui.online.groups.creategroup.AddGroupLeaderStepFragment;
import org.apache.fineract.ui.online.groups.creategroup.AddGroupMemberStepFragment;
import org.apache.fineract.ui.online.groups.creategroup.CreateGroupActivity;
import org.apache.fineract.ui.online.groups.creategroup.GroupAddressStepFragment;
import org.apache.fineract.ui.online.groups.creategroup.GroupReviewStepFragment;
import org.apache.fineract.ui.online.groups.groupdetails.GroupDetailsFragment;
import org.apache.fineract.ui.online.groups.grouplist.GroupListFragment;
import org.apache.fineract.ui.online.groups.grouptasks.GroupTasksBottomSheetFragment;
import org.apache.fineract.ui.online.identification.createidentification.identificationactivity
.CreateIdentificationActivity;
import org.apache.fineract.ui.online.identification.identificationdetails
Expand Down Expand Up @@ -135,5 +143,21 @@ public interface ActivityComponent {
void inject(EditPayrollAllocationFragment editPayrollAllocationFragment);

void inject(EditPayrollActivity editPayrollActivity);

void inject(GroupListFragment groupListFragment);

void inject(GroupAddressStepFragment groupAddressStepFragment);

void inject(CreateGroupActivity createGroupActivity);

void inject(AddGroupMemberStepFragment addGroupMemberStepFragment);

void inject(AddGroupLeaderStepFragment addGroupLeaderStepFragment);

void inject(GroupReviewStepFragment groupReviewStepFragment);

void inject(GroupDetailsFragment groupDetailsFragment);

void inject(GroupTasksBottomSheetFragment groupTasksBottomSheetFragment);
}

79 changes: 79 additions & 0 deletions app/src/main/java/org/apache/fineract/ui/adapters/GroupsAdapter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package org.apache.fineract.ui.adapters

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.item_group.view.*
import org.apache.fineract.R
import org.apache.fineract.data.models.Group
import org.apache.fineract.injection.ApplicationContext
import org.apache.fineract.ui.base.OnItemClickListener
import org.apache.fineract.utils.DateUtils
import org.apache.fineract.utils.StatusUtils
import javax.inject.Inject


/*
* Created by saksham on 16/June/2019
*/

class GroupsAdapter @Inject constructor(@ApplicationContext var context: Context?)
: RecyclerView.Adapter<GroupsAdapter.ViewHolder>() {

var groups = ArrayList<Group>()
lateinit var onItemClickListener: OnItemClickListener

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(LayoutInflater.from(context).inflate(R.layout.item_group, parent, false))
}

override fun getItemCount(): Int = groups.size

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
var group: Group = groups[position]

StatusUtils.setGroupsStatusIcon(group.status, holder.ivTypeIndicator, context)

holder.tvGroupIdentifier.text = group.identifier

val modifiedBy = context?.getString(R.string.last_modified_by) + context?.getString(R.string.colon) + group.lastModifiedBy
holder.tvLastModifiedBy.text = modifiedBy

val lastModifiedOn = context?.getString(R.string.last_modified_on) + context?.getString(R.string.colon) + DateUtils.getDate(group.lastModifiedOn,
DateUtils.INPUT_DATE_FORMAT, DateUtils.OUTPUT_DATE_FORMAT)
holder.tvLastModifiedOn.text = lastModifiedOn
}

fun setGroupList(groups: ArrayList<Group>) {
this.groups = groups
notifyDataSetChanged()
}

fun setItemClickListener(onItemClickListener: OnItemClickListener) {
this.onItemClickListener = onItemClickListener
}

inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView),
View.OnClickListener {
var llGroups: LinearLayout = itemView.ll_group
var ivTypeIndicator: ImageView = itemView.iv_type_indicator
var tvGroupIdentifier: TextView = itemView.tv_group_identifier
var tvLastModifiedBy: TextView = itemView.tv_last_modified_by
var tvLastModifiedOn: TextView = itemView.tv_last_modified_on

init {
llGroups.setOnClickListener(this)
}

override fun onClick(v: View?) {
if (onItemClickListener != null) {
onItemClickListener.onItemClick(v, adapterPosition)
}
}
}
}
Loading

0 comments on commit 592099e

Please sign in to comment.