Skip to content

Commit

Permalink
Merge pull request #7 from fieldsight/5/UI-attedance-dashboard
Browse files Browse the repository at this point in the history
5/ui attedance dashboard
  • Loading branch information
konishon authored Jul 2, 2019
2 parents f226cf5 + f3579e5 commit 236522e
Show file tree
Hide file tree
Showing 83 changed files with 2,247 additions and 259 deletions.
13 changes: 7 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ repositories {
}




android {
compileSdkVersion 28
defaultConfig {
Expand Down Expand Up @@ -61,12 +59,15 @@ dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.0.2'


//UI
implementation 'com.params.stepview:stepview:1.0.2'

//debug libs
implementation 'com.facebook.stetho:stetho:1.4.2'
implementation 'com.facebook.stetho:stetho-okhttp3:1.4.2'
implementation 'com.jakewharton.timber:timber:4.7.0'
debugImplementation 'com.readystatesoftware.chuck:library:1.1.0'
debugImplementation 'com.amitshekhar.android:debug-db:1.0.3'
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
releaseImplementation 'com.readystatesoftware.chuck:library-no-op:1.1.0'

//helper libs`
Expand All @@ -77,9 +78,9 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.3@aar') {
transitive = true;
transitive = true
}
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

}
implementation 'org.idpass.mobile.api:idpass-mobile-api:0.0.2'

}
22 changes: 14 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.NFC" />

<application
android:name=".application.StaffAttendance"
android:allowBackup="true"
Expand All @@ -12,23 +14,27 @@
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".login.LoginActivity"
android:exported="true">
<activity android:name=".settings.SettingsActivity"></activity>
<activity android:name=".splash.SplashScreenActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:windowSoftInputMode="adjustResize"
android:name=".newstaff.NewStaffActivity" />
android:name=".login.LoginActivity"
android:exported="true" />
<activity
android:name=".attendence.AttendanceViewPagerActivity"
/>
android:name=".newstaff.NewStaffActivity"
android:windowSoftInputMode="adjustResize" />
<activity android:name=".attendence.AttendanceViewPagerActivity" />
<activity android:name=".jobs.SyncHistoryActivity" />
<activity android:name=".attedancedashboard.AttedanceDashboardAcitivty" />
<activity
android:name=".attedancedashboard.AttendancesDashboardActivity"
android:exported="true" />
<activity android:name=".attendence.v2.AttedanceActivity" />
<activity android:name=".PreferencesActivity" />

<meta-data
android:name="io.fabric.ApiKey"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package np.com.naxa.staffattendance;


import android.app.Activity;
import android.content.ContentValues;
import android.content.DialogInterface;
import android.content.Intent;
import android.nfc.NfcAdapter;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
Expand All @@ -17,47 +21,56 @@
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import org.idpass.mobile.api.IDPassConstants;
import org.idpass.mobile.api.IDPassIntent;
import org.idpass.mobile.proto.SignedAction;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import np.com.naxa.staffattendance.application.StaffAttendance;
import np.com.naxa.staffattendance.attendence.AttendanceResponse;
import np.com.naxa.staffattendance.attendence.AttendanceViewPagerActivity;
import np.com.naxa.staffattendance.attendence.MyTeamRepository;
import np.com.naxa.staffattendance.attendence.TeamMemberResposne;
import np.com.naxa.staffattendance.database.AttendanceDao;
import np.com.naxa.staffattendance.database.DatabaseHelper;
import np.com.naxa.staffattendance.database.StaffDao;
import np.com.naxa.staffattendance.database.TeamDao;
import np.com.naxa.staffattendance.utlils.DateConvertor;
import np.com.naxa.staffattendance.utlils.DialogFactory;
import rx.Observable;
import timber.log.Timber;

public class DailyAttendanceFragment extends Fragment implements StaffListAdapter.OnStaffItemClickListener {
private int IDENTIFY_RESULT_INTENT = 1;
private NfcAdapter nfcAdapter;


private RecyclerView recyclerView;
private StaffListAdapter stafflistAdapter;
private TeamDao teamDao;
private StaffDao staffDao;
private FloatingActionButton fabUploadAttedance;

private List<String> attedanceIds;
private MyTeamRepository myTeamRepository;
private boolean enablePersonSelection = false;
private List<String> attedanceToUpload;
private List<String> attendanceProofToUpload;
private RelativeLayout layoutNoData;
private boolean isAttedanceDateToday = false;


public DailyAttendanceFragment() {
myTeamRepository = new MyTeamRepository();
attedanceToUpload = new ArrayList<>();
}

public void setAttendanceIds(List<String> attendanceIds, String attendanceDate) {
this.attedanceIds = attendanceIds;


boolean isAttedanceEmpty = (attendanceIds == null) || attendanceIds.isEmpty();
boolean isAttedanceDateToday = DateConvertor.getCurrentDate().equalsIgnoreCase(attendanceDate);
isAttedanceDateToday = DateConvertor.getCurrentDate().equalsIgnoreCase(attendanceDate);

if (isAttedanceEmpty && isAttedanceDateToday) {
enablePersonSelection = true;
}
Expand All @@ -75,7 +88,9 @@ public void setAttendanceIds(List<String> attendanceIds, String attendanceDate)
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_daily_attendence, container, false);


myTeamRepository = new MyTeamRepository();
attedanceToUpload = new ArrayList<>();
attendanceProofToUpload = new ArrayList<>();
teamDao = new TeamDao();
staffDao = new StaffDao();

Expand All @@ -84,6 +99,7 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
setupRecyclerView();

setHasOptionsMenu(true);

fabUploadAttedance.hide();
fabUploadAttedance.setOnClickListener(new View.OnClickListener() {
@Override
Expand All @@ -98,16 +114,68 @@ public void run() {
msg = String.format(msg, peoplelist);


showMarkPresentDialog(title,msg);
showMarkPresentDialog(title, msg);
}
});
}
});

if (enablePersonSelection && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
nfcAdapter = NfcAdapter.getDefaultAdapter(getContext());
}

return rootView;
}

@Override
public void onResume() {
super.onResume();
if (enablePersonSelection && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
nfcAdapter.enableReaderMode(this.getActivity(), tag -> {
Intent intent = IDPassIntent.intentIdentify(
IDPassConstants.IDPASS_TYPE_MIFARE,
true,
true,
tag);
startActivityForResult(intent, IDENTIFY_RESULT_INTENT);
}
, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK,null);
}
}

@Override
public void onPause() {
super.onPause();
if (enablePersonSelection && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
nfcAdapter.disableReaderMode(this.getActivity());
}
}


@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (requestCode == IDENTIFY_RESULT_INTENT && resultCode == Activity.RESULT_OK) {
String signedActionBase64 = data.getStringExtra(IDPassConstants.IDPASS_SIGNED_ACTION_RESULT_EXTRA);

SignedAction signedAction = IDPassIntent.signedActionBuilder(signedActionBase64);

String idPassDID = signedAction.getAction().getPerson().getDid();

List<TeamMemberResposne> staffs = new StaffDao().getStaffByIdPassDID(idPassDID);
if (staffs.size() > 0) {
TeamMemberResposne staff = staffs.get(0);
if (!attedanceToUpload.contains(staff.getId())) {
this.stafflistAdapter.markPresent(staff.getId());
this.attedanceToUpload.add(staff.getId());
this.attendanceProofToUpload.add(signedActionBase64);
fabUploadAttedance.show();
}
}
}
}


private void showMarkPresentDialog(String title, String msg) {
getActivity().runOnUiThread(() -> {
Expand All @@ -124,6 +192,7 @@ public void onClick(DialogInterface dialogInterface, int i) {
AttendanceResponse attendanceResponse = new AttendanceResponse();
attendanceResponse.setAttendanceDate(DateConvertor.getCurrentDate());
attendanceResponse.setStaffs(attedanceToUpload);
attendanceResponse.setStaffProofs(attendanceProofToUpload);
attendanceResponse.setDataSyncStatus(AttendanceDao.SyncStatus.FINALIZED);

ContentValues contentValues = attedanceDao.getContentValuesForAttedance(attendanceResponse);
Expand Down Expand Up @@ -173,18 +242,20 @@ private void bindUI(View view) {

@Override
public void onStaffClick(int pos, TeamMemberResposne staff) {
stafflistAdapter.toggleSelection(pos);
if (!((StaffAttendance) Objects.requireNonNull(this.getContext()).getApplicationContext()).allowManualPresence) {
return;
}

if (attedanceToUpload.contains(staff.getId())) {
Timber.i("Removing %s / %s", staff.getId(), staff.getFirstName());
stafflistAdapter.toggleSelection(pos);
Timber.i("Removing %s / %s", staff.getIDPassDID(), staff.getFirstName());
attedanceToUpload.remove(staff.getId());
} else {
Timber.i("Adding %s / %s", staff.getId(), staff.getFirstName());
Timber.i("Adding %s / %s", staff.getIDPassDID(), staff.getFirstName());
stafflistAdapter.toggleSelection(pos);
attedanceToUpload.add(staff.getId());
}


Timber.i("Current array is %s", attedanceToUpload.toString());
if (stafflistAdapter.getSelected().size() > 0) {
fabUploadAttedance.show();
} else {
Expand Down
Loading

0 comments on commit 236522e

Please sign in to comment.