diff --git a/app/build.gradle b/app/build.gradle
index 980493b..c47f9d4 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -18,8 +18,6 @@ repositories {
}
-
-
android {
compileSdkVersion 28
defaultConfig {
@@ -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`
@@ -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'
+}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 2e9e980..0258b90 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -4,6 +4,8 @@
+
+
-
+
+
@@ -22,13 +23,18 @@
+ android:name=".login.LoginActivity"
+ android:exported="true" />
+ android:name=".newstaff.NewStaffActivity"
+ android:windowSoftInputMode="adjustResize" />
+
-
+
+
+
{
-
- private List staffList;
-
- public class MyViewHolder extends RecyclerView.ViewHolder {
- CheckBox staffName ;
-
- public MyViewHolder(View view) {
- super(view);
- staffName = (CheckBox) view.findViewById(R.id.staff_recycler_list_item_check_box);
- }
- }
-
-
- public AttandanceStaffRecyclerAdapter(List staffList) {
- this.staffList = staffList;
- }
-
- @Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- View itemView = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.recyclerview_staff_list_item, parent, false);
-
- return new MyViewHolder(itemView);
- }
-
-
-
- @Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
- AttendancePojo attendancePOJO = staffList.get(position);
- holder.staffName.setText(attendancePOJO.getStaffName());
- }
-
- @Override
- public int getItemCount() {
- return staffList.size();
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/DailyAttendanceFragment.java b/app/src/main/java/np/com/naxa/staffattendance/DailyAttendanceFragment.java
index 428dc1c..9699149 100644
--- a/app/src/main/java/np/com/naxa/staffattendance/DailyAttendanceFragment.java
+++ b/app/src/main/java/np/com/naxa/staffattendance/DailyAttendanceFragment.java
@@ -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;
@@ -17,39 +21,47 @@
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 attedanceIds;
private MyTeamRepository myTeamRepository;
private boolean enablePersonSelection = false;
private List attedanceToUpload;
+ private List attendanceProofToUpload;
private RelativeLayout layoutNoData;
+ private boolean isAttedanceDateToday = false;
public DailyAttendanceFragment() {
- myTeamRepository = new MyTeamRepository();
- attedanceToUpload = new ArrayList<>();
}
public void setAttendanceIds(List attendanceIds, String attendanceDate) {
@@ -57,7 +69,8 @@ public void setAttendanceIds(List attendanceIds, String attendanceDate)
boolean isAttedanceEmpty = (attendanceIds == null) || attendanceIds.isEmpty();
- boolean isAttedanceDateToday = DateConvertor.getCurrentDate().equalsIgnoreCase(attendanceDate);
+ isAttedanceDateToday = DateConvertor.getCurrentDate().equalsIgnoreCase(attendanceDate);
+
if (isAttedanceEmpty && isAttedanceDateToday) {
enablePersonSelection = true;
}
@@ -75,7 +88,9 @@ public void setAttendanceIds(List 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();
@@ -84,6 +99,7 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
setupRecyclerView();
setHasOptionsMenu(true);
+
fabUploadAttedance.hide();
fabUploadAttedance.setOnClickListener(new View.OnClickListener() {
@Override
@@ -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 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(() -> {
@@ -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);
@@ -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 {
diff --git a/app/src/main/java/np/com/naxa/staffattendance/StaffListAdapter.java b/app/src/main/java/np/com/naxa/staffattendance/StaffListAdapter.java
index b62cda8..fe2e2f6 100644
--- a/app/src/main/java/np/com/naxa/staffattendance/StaffListAdapter.java
+++ b/app/src/main/java/np/com/naxa/staffattendance/StaffListAdapter.java
@@ -19,6 +19,7 @@
import np.com.naxa.staffattendance.attendence.TeamMemberResposne;
import np.com.naxa.staffattendance.utlils.FlipAnimator;
+import timber.log.Timber;
public class StaffListAdapter extends RecyclerView.Adapter {
private Context mContext;
@@ -37,7 +38,7 @@ public class StaffListAdapter extends RecyclerView.Adapter selectedStaffHashMap = new HashMap<>();
- StaffListAdapter(Context mContext, List staffList, boolean enablePersonSelection, List attedanceIds, OnStaffItemClickListener listener) {
+ public StaffListAdapter(Context mContext, List staffList, boolean enablePersonSelection, List attedanceIds, OnStaffItemClickListener listener) {
this.mContext = mContext;
this.staffList = staffList;
this.filetredsitelist = staffList;
@@ -67,7 +68,8 @@ public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int pos
staffVH.rootLayout.setEnabled(enablePersonSelection);
staffVH.staffName.setText(staff.getFirstName());
- staffVH.staffType.setText(staff.getTeamName());
+ staffVH.staffPost.setText(staff.getDesignationLabel());
+
staffVH.iconText.setVisibility(View.VISIBLE);
staffVH.imgProfile.setImageResource(R.drawable.circle_blue);
staffVH.iconText.setText(staff.getFirstName().substring(0, 1));
@@ -105,6 +107,17 @@ public int getItemCount() {
return staffList.size();
}
+ public void markPresent(String staffId) {
+ for (int i = 0; i < staffList.size(); i++) {
+ if(staffList.get(i).getId().equals(staffId)) {
+ Timber.i("Found staff %s / %s", staffId, i);
+ toggleSelection(i);
+ return;
+ }
+ }
+ Timber.i("Not Found staff: %s", staffId);
+ }
+
public void toggleSelection(int pos) {
currentSelectedIndex = pos;
@@ -168,6 +181,7 @@ private void applyIconAnimation(StaffVH holder, int position, boolean shouldHigh
holder.staffStatus.setText(holder.rootLayout.getContext().getString(R.string.attedance_absent));
+
holder.rootLayout.setActivated(!shouldHightlight);
holder.iconBack.setVisibility(View.GONE);
resetIconYAxis(holder.iconFront);
@@ -226,12 +240,13 @@ public ArrayList getSelectedStaffID() {
public class StaffVH extends RecyclerView.ViewHolder {
- private TextView staffName, staffStatus, siteAddress, sitePhone, staffType, sitePendingFormsNumber, site, iconText, timestamp, tvTagOfflineSite;
+ private TextView staffName, staffStatus, siteAddress, sitePhone, staffType, sitePendingFormsNumber, site, iconText, timestamp, tvTagOfflineSite,staffPost;
private ImageView iconImp, imgProfile;
private RelativeLayout iconContainer, iconBack, iconFront;
private RelativeLayout rootLayout;
private CardView card;
+
public StaffVH(View view) {
super(view);
card = view.findViewById(R.id.card_site_lst_row);
@@ -242,6 +257,7 @@ public StaffVH(View view) {
staffStatus = view.findViewById(R.id.staff_list_row_status);
staffName = view.findViewById(R.id.staff_list_row_name);
+ staffPost = view.findViewById(R.id.staff_list_row_post);
siteAddress = view.findViewById(R.id.staff_list_row_email);
sitePhone = view.findViewById(R.id.staff_list_row_phone);
staffType = view.findViewById(R.id.staff_list_row_type);
diff --git a/app/src/main/java/np/com/naxa/staffattendance/application/StaffAttendance.java b/app/src/main/java/np/com/naxa/staffattendance/application/StaffAttendance.java
index 1d43ed8..3860ec6 100644
--- a/app/src/main/java/np/com/naxa/staffattendance/application/StaffAttendance.java
+++ b/app/src/main/java/np/com/naxa/staffattendance/application/StaffAttendance.java
@@ -16,6 +16,7 @@
public class StaffAttendance extends Application {
public static StaffAttendance staffAttendance;
+ public Boolean allowManualPresence = false;
@Override
public void onCreate() {
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AddItemButton.kt b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AddItemButton.kt
new file mode 100644
index 0000000..9e77972
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AddItemButton.kt
@@ -0,0 +1,5 @@
+package np.com.naxa.staffattendance.attedancedashboard
+
+import np.com.naxa.staffattendance.attedancedashboard.base.IRow
+
+data class AddItemButton(val uuid: String) : IRow
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AttedanceBottomFragment.kt b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AttedanceBottomFragment.kt
new file mode 100644
index 0000000..db85460
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AttedanceBottomFragment.kt
@@ -0,0 +1,111 @@
+package np.com.naxa.staffattendance.attedancedashboard
+
+import android.content.Context
+import android.os.Bundle
+import android.support.annotation.Nullable
+import android.view.ViewGroup
+import android.view.LayoutInflater
+import android.support.design.widget.BottomSheetDialogFragment
+import android.view.View
+import kotlinx.android.synthetic.main.fragment_take_attedance_dialog.view.*
+import np.com.naxa.staffattendance.R
+import np.com.naxa.staffattendance.attendence.AttendanceResponse
+import np.com.naxa.staffattendance.attendence.TeamMemberResposne
+import np.com.naxa.staffattendance.common.IntentConstants
+import np.com.naxa.staffattendance.database.AttendanceDao
+import java.util.*
+import kotlin.concurrent.fixedRateTimer
+
+
+class AttedanceBottomFragment : BottomSheetDialogFragment() {
+
+ private lateinit var demoTimer: Timer
+ var staff: TeamMemberResposne? = null
+ var statusDesc: Array? = null
+ var loadedDate: String? = null
+ lateinit var listener: OnAttedanceTakenListener
+
+ interface OnAttedanceTakenListener {
+ fun onAttedanceTaken(position: Int)
+ }
+
+
+ fun onClickListener(listener: OnAttedanceTakenListener){
+ this.listener = listener
+ }
+
+ override fun onAttach(context: Context?) {
+ super.onAttach(context)
+ arguments?.getSerializable(IntentConstants.EXTRA_OBJECT)?.let {
+ staff = it as TeamMemberResposne
+ }
+ arguments?.getString(IntentConstants.ATTENDANCE_DATE)?.let {
+ loadedDate = it;
+ }
+
+ }
+
+ @Nullable
+ override fun onCreateView(inflater: LayoutInflater,
+ @Nullable container: ViewGroup?,
+ @Nullable savedInstanceState: Bundle?): View? {
+
+
+ val view = inflater.inflate(R.layout.fragment_take_attedance_dialog, container,
+ false)
+
+ view.tv_take_attedance_frag_staff_name.text = staff?.firstName
+ demoTimer = fixedRateTimer("timer", false, 1000, 1000) {
+ requireActivity().runOnUiThread {
+ goToNextStep(view)
+ }
+ }
+ statusDesc = resources.getStringArray(R.array.attedance_status_desc);
+ loadFirstMessage(view)
+ return view;
+ }
+
+ override fun onDestroy() {
+ super.onDestroy()
+ demoTimer.cancel()
+ }
+
+ private fun goToNextStep(view: View) {
+ val currentCount: Int = view.statusViewScroller.statusView.currentCount
+ if (currentCount < 4) {
+ setMessage(currentCount - 1, view)
+ view.statusViewScroller.statusView.currentCount = currentCount + 1
+
+ } else {
+ saveAttedance()
+ dismiss()
+ listener.onAttedanceTaken(1)
+ }
+
+ }
+
+ fun saveAttedance() {
+ val attendanceResponse = AttendanceResponse()
+ attendanceResponse.setAttendanceDate(loadedDate)
+ attendanceResponse.setStaffs(listOf(staff?.id))
+ attendanceResponse.setStaffProofs(listOf("demo-attedance-proof"))//todo: add attendanceProofToUpload
+ attendanceResponse.dataSyncStatus = AttendanceDao.SyncStatus.FINALIZED
+ AttedanceLocalSource.instance.updateAttendance(loadedDate, attendanceResponse, staff?.teamID)
+
+ }
+
+ private fun loadFirstMessage(view: View) {
+ setMessage(0, view)
+ }
+
+ private fun setMessage(currentCount: Int, view: View) {
+ view.tv_take_attedance_frag_desc.text = statusDesc?.get(currentCount)
+ }
+
+ companion object {
+
+ fun newInstance(): AttedanceBottomFragment {
+ return AttedanceBottomFragment()
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AttedanceDashboardAcitivty.kt b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AttedanceDashboardAcitivty.kt
deleted file mode 100644
index 5c08d79..0000000
--- a/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AttedanceDashboardAcitivty.kt
+++ /dev/null
@@ -1,13 +0,0 @@
-package np.com.naxa.staffattendance.attedancedashboard
-
-import android.os.Bundle
-import android.support.v7.app.AppCompatActivity
-import np.com.naxa.staffattendance.R
-
-class AttedanceDashboardAcitivty : AppCompatActivity() {
-
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- setContentView(R.layout.activity_dashboard_attedance);
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AttedanceLocalSource.kt b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AttedanceLocalSource.kt
new file mode 100644
index 0000000..efb54ee
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AttedanceLocalSource.kt
@@ -0,0 +1,31 @@
+package np.com.naxa.staffattendance.attedancedashboard
+
+import np.com.naxa.staffattendance.attendence.AttendanceResponse
+import np.com.naxa.staffattendance.database.AttendanceDao
+
+class AttedanceLocalSource {
+
+ val attedanceDao = AttendanceDao()
+
+ companion object {
+ val instance = AttedanceLocalSource()
+ }
+
+
+ fun getAttendanceForDate(date: String?, new_attendance: AttendanceResponse, team_id: String?): AttendanceResponse? {
+ val oldAttendance = attedanceDao.getAttedanceByDate(team_id, date)
+ if (oldAttendance.presentStaffIds != null && oldAttendance.presentStaffIds.size > 0) {
+ oldAttendance.setStaffs(oldAttendance.presentStaffIds + new_attendance.presentStaffIds)
+ return oldAttendance
+ }
+
+ return new_attendance
+ }
+
+ fun updateAttendance(date: String?, new_attendance: AttendanceResponse, team_id: String?) {
+ val attendanceResponse = getAttendanceForDate(date, new_attendance, team_id)
+ val contentValues = attedanceDao.getContentValuesForAttedance(attendanceResponse)
+ attedanceDao.saveAttedance(contentValues)
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AttendanceDay.kt b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AttendanceDay.kt
new file mode 100644
index 0000000..7eec6f6
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AttendanceDay.kt
@@ -0,0 +1,12 @@
+package np.com.naxa.staffattendance.attedancedashboard
+
+import np.com.naxa.staffattendance.attedancedashboard.base.IRow
+
+data class AttendanceDay(val dayOfWeek: String,
+ val dayOfMonth: String,
+ val date: String,
+ val absentNoOfStaff: String,
+ val presentNoOfStaff: String,
+ val teamId: String,
+ val teamName: String,
+ val fullDate: String) : IRow
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AttendancesDashboardActivity.kt b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AttendancesDashboardActivity.kt
new file mode 100644
index 0000000..e0cc599
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/AttendancesDashboardActivity.kt
@@ -0,0 +1,197 @@
+package np.com.naxa.staffattendance.attedancedashboard
+
+import android.app.ProgressDialog
+import android.content.Context
+import android.content.Intent
+import android.os.Bundle
+import android.os.Handler
+import android.support.v7.app.AppCompatActivity
+import android.support.v7.widget.DefaultItemAnimator
+import android.support.v7.widget.GridLayoutManager
+import android.support.v7.widget.LinearLayoutManager
+import android.view.Menu
+import android.view.MenuItem
+import kotlinx.android.synthetic.main.activity_dashboard_attedance.*
+import np.com.naxa.staffattendance.R
+import np.com.naxa.staffattendance.TeamRemoteSource
+import np.com.naxa.staffattendance.attendence.AttendanceViewPagerActivity
+import np.com.naxa.staffattendance.common.UIConstants
+import np.com.naxa.staffattendance.database.StaffDao
+import np.com.naxa.staffattendance.database.TeamDao
+import np.com.naxa.staffattendance.settings.SettingsActivity
+import np.com.naxa.staffattendance.utlils.DateConvertor
+import np.com.naxa.staffattendance.utlils.DialogFactory
+import np.com.naxa.staffattendance.utlils.NetworkUtils
+import np.com.naxa.staffattendance.utlils.ToastUtils
+import retrofit2.adapter.rxjava.HttpException
+import rx.Observer
+import rx.android.schedulers.AndroidSchedulers
+import rx.functions.Action0
+import rx.schedulers.Schedulers
+import timber.log.Timber
+import java.io.IOException
+import java.net.SocketTimeoutException
+import java.util.concurrent.TimeUnit
+
+
+class AttendancesDashboardActivity : AppCompatActivity() {
+
+ private var exitOnBackPress: Boolean = false;
+ private val backPressHandler = Handler()
+ private val runnable = { exitOnBackPress = false }
+
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_dashboard_attedance);
+ DialogFactory.createProgressDialogHorizontal(this@AttendancesDashboardActivity, "Please Wait")
+ setSupportActionBar(toolbar)
+ supportActionBar?.title = ""
+ setupListAdapter(generateGridItems())
+ setupSwipeToRefresh()
+
+
+ }
+
+ private fun setupSwipeToRefresh() {
+ swiperefresh.setOnRefreshListener {
+ if (NetworkUtils.isInternetAvailable()) {
+ TeamRemoteSource.getInstance()
+ .syncAll()
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .doOnSubscribe(Action0 { this.showPleaseWaitDialog() })
+ .subscribe(object : Observer {
+ override fun onCompleted() {
+ closePleaseWaitDialog()
+ showMessage("Everything is Up-to-date")
+ Timber.i("onCompleted")
+ }
+
+ override fun onError(e: Throwable) {
+ closePleaseWaitDialog()
+ if (e is HttpException) {
+ try {
+ val responseBody = e.response().errorBody()
+ showMessage(responseBody!!.string())
+ } catch (e1: NullPointerException) {
+ showMessage("")
+ e1.printStackTrace()
+ } catch (e1: IOException) {
+ showMessage("")
+ e1.printStackTrace()
+ }
+
+ } else if (e is SocketTimeoutException) {
+ showMessage("Server took too long to respond")
+ } else if (e is IOException) {
+ showMessage(e.message.toString())
+ } else {
+ showMessage(e.message.toString())
+ }
+ }
+
+ override fun onNext(o: Any) {
+
+ }
+ })
+
+ } else {
+ ToastUtils.showLong(getString(R.string.no_internet))
+ }
+ }
+ }
+
+ private fun showPleaseWaitDialog() {
+ swiperefresh.isRefreshing = true;
+ }
+
+ private fun showMessage(message: String) {
+ ToastUtils.showLong(message)
+ swiperefresh.isRefreshing = false;
+ }
+
+ private fun closePleaseWaitDialog() {
+ swiperefresh.isRefreshing = false;
+ }
+
+ private fun generateGridItems(): ArrayList {
+ val teamId = TeamDao().oneTeamIdForDemo
+ val list = arrayListOf()
+ var teamName: String = ""
+ val staffs = StaffDao().getStaffByTeamId(teamId)
+ list.add(getString(R.string.title_team))
+ list.add("")
+ if (staffs.size > 0) {
+ teamName = staffs[0].teamName
+ val teamMembersCount = staffs.count().toString()
+ list.add(TeamStats(teamName, teamMembersCount))
+ }
+ list.add(AddItemButton(UIConstants.UUID_GRID_ITEM_TEAM_MEMBER))
+ list.add(getString(R.string.title_attedance))
+ list.add("")
+
+
+ for (x in 1 downTo -6 step 1) {
+ val date = DateConvertor.getPastDate(x)
+ val yearMonthDay = DateConvertor.getYearMonthDay(date);
+ list.add(element = AttendanceDay(dayOfWeek = yearMonthDay[2],
+ dayOfMonth = yearMonthDay[1],
+ date = yearMonthDay[0],
+ absentNoOfStaff = "",
+ presentNoOfStaff = "",
+ teamId = teamId,
+ teamName = teamName,
+ fullDate = DateConvertor.formatDate(DateConvertor.getDateForPosition(x))));
+ }
+
+ return list;
+ }
+
+ override fun onCreateOptionsMenu(menu: Menu?): Boolean {
+ menuInflater.inflate(R.menu.menu_dashboard, menu);
+ return super.onCreateOptionsMenu(menu)
+ }
+
+ override fun onOptionsItemSelected(item: MenuItem?): Boolean {
+ when (item?.itemId) {
+ R.id.main_dashboard_setting -> {
+ val toSettings = SettingsActivity.newIntent(this@AttendancesDashboardActivity)
+ startActivity(toSettings)
+ }
+ }
+ return super.onOptionsItemSelected(item)
+ }
+
+
+ override fun onBackPressed() {
+ if (exitOnBackPress) {
+ finish()
+ return
+ }
+
+ exitOnBackPress = true
+ ToastUtils.showShort(getString(R.string.msg_backpress_to_exit))
+ backPressHandler.postDelayed(runnable, TimeUnit.SECONDS.toMillis(2))
+ }
+
+ private fun setupListAdapter(days: List) {
+
+ val manager = LinearLayoutManager(this)
+ recycler_view.setLayoutManager(manager)
+ recycler_view.setItemAnimator(DefaultItemAnimator())
+ recycler_view.apply {
+ layoutManager = GridLayoutManager(this@AttendancesDashboardActivity, 2)
+ adapter = ListAdapter(days)
+ }
+ recycler_view.addItemDecoration(ItemOffsetDecoration(this, R.dimen.spacing_small))
+
+ }
+
+ companion object {
+ fun newIntent(context: Context): Intent {
+ val intent = Intent(context, AttendancesDashboardActivity::class.java)
+ return intent
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/BaseRecyclerViewAdapter.java b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/BaseRecyclerViewAdapter.java
new file mode 100644
index 0000000..97a55da
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/BaseRecyclerViewAdapter.java
@@ -0,0 +1,54 @@
+package np.com.naxa.staffattendance.attedancedashboard;
+
+import android.support.annotation.NonNull;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import java.util.List;
+
+import np.com.naxa.staffattendance.application.StaffAttendance;
+import timber.log.Timber;
+
+
+//import com.rillmark.royalworldcup.MainApplication;
+
+public abstract class BaseRecyclerViewAdapter extends RecyclerView.Adapter {
+ private List l;
+ private int layout;
+
+ protected BaseRecyclerViewAdapter(List l, int layout) {
+ this.l = l;
+ this.layout = layout;
+ Timber.d("listSize = %s", l.size());
+ }
+
+ @NonNull
+ @Override
+ public VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ View view = LayoutInflater.from(StaffAttendance.getStaffAttendance()).inflate(layout, parent, false);
+ return attachViewHolder(view);
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull VH holder, int position) {
+ viewBinded(holder, l.get(position));
+ }
+
+ public List getData() {
+ return this.l;
+ }
+
+ @Override
+ public int getItemCount() {
+ return l.size();
+ }
+
+ public abstract void viewBinded(VH vh, L l);
+
+ public abstract VH attachViewHolder(View view);
+
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/CalendraVH.kt b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/CalendraVH.kt
new file mode 100644
index 0000000..013f86d
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/CalendraVH.kt
@@ -0,0 +1,55 @@
+package np.com.naxa.staffattendance.attedancedashboard
+
+import android.support.v7.widget.RecyclerView
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.TextView
+import np.com.naxa.staffattendance.R
+import np.com.naxa.staffattendance.attendence.v2.AttedanceActivity
+import np.com.naxa.staffattendance.database.TeamDao
+
+
+class CalendarVH(inflater: LayoutInflater, parent: ViewGroup) :
+ RecyclerView.ViewHolder(inflater.inflate(R.layout.grid_item_calendra, parent, false)) {
+ private var tvDay: TextView? = null
+ private var tvDate: TextView? = null
+ private var tvMonthYear: TextView? = null
+ private var tvAbsentMessage: TextView? = null
+ private var tvPresentMessage: TextView? = null
+ private var rootLayout: View? = null
+
+
+ init {
+ tvDay = itemView.findViewById(R.id.tv_day)
+ tvDate = itemView.findViewById(R.id.tv_date)
+ tvMonthYear = itemView.findViewById(R.id.tv_month_year)
+ tvAbsentMessage = itemView.findViewById(R.id.tv_absent_message)
+ tvPresentMessage = itemView.findViewById(R.id.tv_present_message)
+ rootLayout = itemView.findViewById(R.id.root_layout)
+ }
+
+ fun bind(day: AttendanceDay) {
+ tvDay?.text = day.dayOfWeek
+ tvDate?.text = day.dayOfMonth
+ tvMonthYear?.text = day.date
+ rootLayout?.setOnClickListener {
+ var intent = AttedanceActivity.newIntent(itemView.context, date = day.fullDate, teamId = day.teamId, teamName = day.teamName)
+ itemView.context.startActivity(intent);
+ }
+
+ }
+
+ fun setAbsentPresentMessage(day: AttendanceDay) {
+ if (isNullOrEmpty(day.absentNoOfStaff)) {
+
+ }
+ }
+
+
+ fun isNullOrEmpty(str: String?): Boolean {
+ if (str != null && !str.isEmpty())
+ return false
+ return true
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/HeaderVH.kt b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/HeaderVH.kt
new file mode 100644
index 0000000..c93f699
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/HeaderVH.kt
@@ -0,0 +1,24 @@
+package np.com.naxa.staffattendance.attedancedashboard
+
+
+
+import android.support.v7.widget.RecyclerView
+import android.view.LayoutInflater
+import android.view.ViewGroup
+import android.widget.TextView
+import np.com.naxa.staffattendance.R
+
+
+class HeaderVH(inflater: LayoutInflater, parent: ViewGroup) :
+ RecyclerView.ViewHolder(inflater.inflate(R.layout.header, parent, false)) {
+ private var tvHeaderTitle: TextView? = null
+
+ init {
+ tvHeaderTitle = itemView.findViewById(R.id.tv_header_title)
+ }
+
+ fun bind(title: String) {
+ tvHeaderTitle?.text = title
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/ItemOffsetDecoration.kt b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/ItemOffsetDecoration.kt
new file mode 100644
index 0000000..2f891af
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/ItemOffsetDecoration.kt
@@ -0,0 +1,19 @@
+package np.com.naxa.staffattendance.attedancedashboard
+
+import android.content.Context
+import android.graphics.Rect
+import android.support.annotation.DimenRes
+import android.support.v7.widget.RecyclerView
+import android.view.View
+
+
+class ItemOffsetDecoration(private val mItemOffset: Int) : RecyclerView.ItemDecoration() {
+
+ constructor(context: Context, @DimenRes itemOffsetId: Int) : this(context.getResources().getDimensionPixelSize(itemOffsetId)) {}
+
+ override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView,
+ state: RecyclerView.State) {
+ super.getItemOffsets(outRect, view, parent, state)
+ outRect.set(mItemOffset, mItemOffset, mItemOffset, mItemOffset)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/ListAdapter.kt b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/ListAdapter.kt
new file mode 100644
index 0000000..73baf9c
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/ListAdapter.kt
@@ -0,0 +1,77 @@
+package np.com.naxa.staffattendance.attedancedashboard
+
+import android.support.v7.widget.RecyclerView
+import android.view.LayoutInflater
+import android.view.ViewGroup
+import np.com.naxa.staffattendance.attedancedashboard.base.AddItemVH
+
+
+class ListAdapter(private val list: List)
+ : RecyclerView.Adapter() {
+
+ private val TYPE_CONTENT = 0
+ private val TYPE_ADD_CONTENT = 1
+ private val TYPE_HEADER = 2
+ private val TYPE_STATS = 3
+
+
+ override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
+ when (holder.itemViewType) {
+ TYPE_ADD_CONTENT -> onBindAddItem(holder as AddItemVH, list[position] as AddItemButton)
+ TYPE_CONTENT -> onBindContent(holder as CalendarVH, list[position] as AttendanceDay)
+ TYPE_HEADER -> onBindHeader(holder as HeaderVH, list[position] as String)
+ TYPE_STATS -> onBindTeamStats(holder as TeamStatsVH, list[position] as TeamStats)
+
+ else -> throw IllegalArgumentException()
+ }
+ }
+
+ private fun onBindTeamStats(teamStatsVH: TeamStatsVH, teamStats: TeamStats) {
+ teamStatsVH.bind(teamStats)
+ }
+
+
+ private fun onBindHeader(headerVH: HeaderVH, s: String) {
+ headerVH.bind(s);
+ }
+
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
+ val inflater = LayoutInflater.from(parent.context)
+ when (viewType) {
+ TYPE_ADD_CONTENT -> return AddItemVH(inflater, parent)
+ TYPE_CONTENT -> return CalendarVH(inflater, parent)
+ TYPE_HEADER -> return HeaderVH(inflater, parent)
+ TYPE_STATS -> return TeamStatsVH(inflater, parent)
+ else -> throw IllegalArgumentException()
+ }
+
+ }
+
+
+ private fun onBindAddItem(holder: AddItemVH, row: AddItemButton) {
+ holder.bind(row);
+ }
+
+ private fun onBindContent(holder: CalendarVH, row: AttendanceDay) {
+ holder.bind(row);
+ }
+
+ override fun getItemViewType(position: Int): Int {
+ return when (list[position]) {
+ is AttendanceDay -> TYPE_CONTENT
+ is AddItemButton -> TYPE_ADD_CONTENT
+ is String -> TYPE_HEADER
+ is TeamStats -> TYPE_STATS
+
+ else -> throw IllegalArgumentException()
+ }
+ }
+
+ override fun getItemCount(): Int = list.size
+}
+
+
+
+
+
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/TeamStats.kt b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/TeamStats.kt
new file mode 100644
index 0000000..dd03e0d
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/TeamStats.kt
@@ -0,0 +1,3 @@
+package np.com.naxa.staffattendance.attedancedashboard
+
+data class TeamStats(val teamName: String, val teamMembersCount: String)
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/TeamStatsVH.kt b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/TeamStatsVH.kt
new file mode 100644
index 0000000..b7933ef
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/TeamStatsVH.kt
@@ -0,0 +1,30 @@
+package np.com.naxa.staffattendance.attedancedashboard
+
+import android.support.v7.widget.RecyclerView
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.TextView
+import np.com.naxa.staffattendance.R
+
+
+class TeamStatsVH(inflater: LayoutInflater, parent: ViewGroup) :
+ RecyclerView.ViewHolder(inflater.inflate(R.layout.grid_item_stats, parent, false)) {
+
+ private var tvTeamName: TextView? = null
+ private var tvTeamMemberCount: TextView? = null
+
+
+ init {
+ tvTeamName = itemView.findViewById(R.id.tv_team_name)
+ tvTeamMemberCount = itemView.findViewById(R.id.tv_members_count)
+
+ }
+
+ fun bind(day: TeamStats) {
+ tvTeamName?.text = day.teamName
+ tvTeamMemberCount?.text = day.teamMembersCount
+
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/base/AddItemVH.kt b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/base/AddItemVH.kt
new file mode 100644
index 0000000..3ec80d2
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/base/AddItemVH.kt
@@ -0,0 +1,34 @@
+package np.com.naxa.staffattendance.attedancedashboard.base
+
+
+import android.support.v7.widget.RecyclerView
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.TextView
+import np.com.naxa.staffattendance.R
+import np.com.naxa.staffattendance.attedancedashboard.AddItemButton
+import np.com.naxa.staffattendance.attedancedashboard.AttendanceDay
+import np.com.naxa.staffattendance.common.UIConstants
+import np.com.naxa.staffattendance.newstaff.NewStaffActivity
+import np.com.naxa.staffattendance.utlils.ToastUtils
+
+
+class AddItemVH(inflater: LayoutInflater, parent: ViewGroup) :
+ RecyclerView.ViewHolder(inflater.inflate(R.layout.grid_item_add, parent, false)) {
+
+
+
+ fun bind(addItem: AddItemButton) {
+
+ itemView.setOnClickListener {
+ when(addItem.uuid){
+ UIConstants.UUID_GRID_ITEM_TEAM_MEMBER ->{
+ NewStaffActivity.start(itemView.context,true);
+ }
+ }
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/base/base.kt b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/base/base.kt
new file mode 100644
index 0000000..a84baa7
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/attedancedashboard/base/base.kt
@@ -0,0 +1,9 @@
+package np.com.naxa.staffattendance.attedancedashboard.base
+
+import android.support.v7.widget.RecyclerView
+import android.view.View
+import android.widget.TextView
+import np.com.naxa.staffattendance.R
+
+interface IRow
+
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attendence/AttendanceResponse.java b/app/src/main/java/np/com/naxa/staffattendance/attendence/AttendanceResponse.java
index 2a1ae80..b99d186 100644
--- a/app/src/main/java/np/com/naxa/staffattendance/attendence/AttendanceResponse.java
+++ b/app/src/main/java/np/com/naxa/staffattendance/attendence/AttendanceResponse.java
@@ -1,6 +1,5 @@
package np.com.naxa.staffattendance.attendence;
-import java.util.Date;
import java.util.List;
import com.google.gson.annotations.Expose;
@@ -24,6 +23,9 @@ public class AttendanceResponse {
@SerializedName("staffs")
@Expose
private List staffs = null;
+ @SerializedName("staff_proofs")
+ @Expose
+ private List staffProofs = null;
private String teamId;
@@ -96,6 +98,10 @@ public void setStaffs(List staffs) {
this.staffs = staffs;
}
+ public void setStaffProofs(List staffs) {
+ this.staffProofs = staffs;
+ }
+
public List getTeamMemberResposnes() {
return teamMemberResposnes;
}
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attendence/TeamMemberResposne.java b/app/src/main/java/np/com/naxa/staffattendance/attendence/TeamMemberResposne.java
index 5aa6fd2..e250a3b 100644
--- a/app/src/main/java/np/com/naxa/staffattendance/attendence/TeamMemberResposne.java
+++ b/app/src/main/java/np/com/naxa/staffattendance/attendence/TeamMemberResposne.java
@@ -3,10 +3,14 @@
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
-public class TeamMemberResposne {
+import java.io.Serializable;
+
+public class TeamMemberResposne implements Serializable {
private String teamID;
private String teamName;
+
+ @SerializedName("IdPassDID")
private String IDPassDID;
@SerializedName("id")
@@ -58,6 +62,10 @@ public class TeamMemberResposne {
@Expose
private Object bank;
+ @SerializedName("designation_label")
+ private String designationLabel;
+
+
public String getId() {
return id;
}
@@ -75,7 +83,10 @@ public String getTeamID() {
}
- public TeamMemberResposne(String teamID, String teamName, String id, String firstName, String lastName, Object email, Integer gender, String ethnicity, String address, String phoneNumber, String bankName, String accountNumber, String photo, Integer designation, Object dateOfBirth, Object contractStart, Object contractEnd, Object bank, String IDPassDID) {
+ public TeamMemberResposne(String teamID, String teamName, String id, String firstName, String lastName,
+ Object email, Integer gender, String ethnicity, String address, String phoneNumber,
+ String bankName, String accountNumber, String photo, Integer designation, Object dateOfBirth,
+ Object contractStart, Object contractEnd, Object bank, String IDPassDID, String designationLabel) {
this.teamID = teamID;
this.teamName = teamName;
this.id = id;
@@ -94,6 +105,12 @@ public TeamMemberResposne(String teamID, String teamName, String id, String firs
this.contractStart = contractStart;
this.contractEnd = contractEnd;
this.bank = bank;
+ this.designationLabel = designationLabel;
+ this.IDPassDID = IDPassDID;
+ }
+
+ public String getDesignationLabel() {
+ return designationLabel;
}
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attendence/TeamMemberResposneBuilder.java b/app/src/main/java/np/com/naxa/staffattendance/attendence/TeamMemberResposneBuilder.java
index 25471a8..3e84776 100644
--- a/app/src/main/java/np/com/naxa/staffattendance/attendence/TeamMemberResposneBuilder.java
+++ b/app/src/main/java/np/com/naxa/staffattendance/attendence/TeamMemberResposneBuilder.java
@@ -20,6 +20,7 @@ public class TeamMemberResposneBuilder {
private Object contractEnd;
private Object bank;
private String IDPassDID;
+ private String designationLabel;
public TeamMemberResposneBuilder setTeamID(String teamID) {
this.teamID = teamID;
@@ -116,7 +117,12 @@ public TeamMemberResposneBuilder setIDPassDID(String IDPassDID) {
return this;
}
+ public TeamMemberResposneBuilder setDesignationLabel(String designationLabel) {
+ this.designationLabel = designationLabel;
+ return this;
+ }
+
public TeamMemberResposne createTeamMemberResposne() {
- return new TeamMemberResposne(teamID, teamName, id, firstName, lastName, email, gender, ethnicity, address, phoneNumber, bankName, accountNumber, photo, designation, dateOfBirth, contractStart, contractEnd, bank,IDPassDID);
+ return new TeamMemberResposne(teamID, teamName, id, firstName, lastName, email, gender, ethnicity, address, phoneNumber, bankName, accountNumber, photo, designation, dateOfBirth, contractStart, contractEnd, bank,IDPassDID,designationLabel);
}
}
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/attendence/v2/AttedanceActivity.kt b/app/src/main/java/np/com/naxa/staffattendance/attendence/v2/AttedanceActivity.kt
new file mode 100644
index 0000000..adc9c99
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/attendence/v2/AttedanceActivity.kt
@@ -0,0 +1,126 @@
+package np.com.naxa.staffattendance.attendence.v2
+
+import android.app.AlertDialog
+import android.content.Context
+import android.content.DialogInterface
+import android.content.Intent
+import android.os.Bundle
+import android.support.v7.widget.DefaultItemAnimator
+import android.support.v7.widget.LinearLayoutManager
+import android.view.MenuItem
+import kotlinx.android.synthetic.main.activity_dashboard_attedance.*
+import np.com.naxa.staffattendance.R
+import np.com.naxa.staffattendance.StaffListAdapter
+import np.com.naxa.staffattendance.attedancedashboard.AttedanceBottomFragment
+import np.com.naxa.staffattendance.attedancedashboard.ItemOffsetDecoration
+
+import np.com.naxa.staffattendance.attendence.TeamMemberResposne
+import np.com.naxa.staffattendance.common.BaseActivity
+import np.com.naxa.staffattendance.common.IntentConstants
+import np.com.naxa.staffattendance.database.AttendanceDao
+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.ToastUtils
+
+
+class AttedanceActivity : BaseActivity(), StaffListAdapter.OnStaffItemClickListener {
+ override fun onStaffClick(pos: Int, staff: TeamMemberResposne?) {
+ val attedanceBottomFragment = AttedanceBottomFragment.newInstance()
+ attedanceBottomFragment.arguments = Bundle().apply {
+ putSerializable(IntentConstants.EXTRA_OBJECT, staff)
+ putString(IntentConstants.ATTENDANCE_DATE, loadedDate)
+
+ }
+
+ attedanceBottomFragment.onClickListener(object : AttedanceBottomFragment.OnAttedanceTakenListener {
+ override fun onAttedanceTaken(position: Int) {
+ setupRecyclerView()//todo: use diff utils or something better
+ }
+ })
+ attedanceBottomFragment.show(supportFragmentManager,
+ "add_photo_dialog_fragment")
+
+ }
+
+ override fun onStaffLongClick(pos: Int) {
+ }
+
+ private var loadedDate: String? = null;
+ private lateinit var stafflistAdapter: StaffListAdapter
+ private var teamDao: TeamDao? = null
+ private var enablePersonSelection = true;
+ private var attedanceIds: List? = emptyList()
+ private lateinit var teamId: String
+ private lateinit var teamName: String
+
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_dashboard_attedance)
+ loadedDate = intent.getStringExtra(IntentConstants.ATTENDANCE_DATE);
+ teamId = intent.getStringExtra(IntentConstants.TEAM_ID);
+ teamName = intent.getStringExtra(IntentConstants.TEAM_NAME);
+
+// val dailyAttendance = AttendanceDao().getAttedanceByDate(teamId, loadedDate)
+// setAttendanceIds(dailyAttendance.presentStaffIds,dailyAttendance.getAttendanceDate(false))
+
+ setupToolbar(title = teamName)
+ setupRecyclerView()
+ swiperefresh.isEnabled = false
+
+ }
+
+
+ override fun onOptionsItemSelected(item: MenuItem?): Boolean {
+ when (item?.itemId) {
+ android.R.id.home -> onBackPressed();
+ }
+ return super.onOptionsItemSelected(item)
+ }
+
+
+ private fun setupRecyclerView() {
+ val teamDao = TeamDao()
+ val mLayoutManager = LinearLayoutManager(applicationContext)
+ val teamId = teamDao.oneTeamIdForDemo
+ attedanceIds = AttendanceDao().getAttedanceByDate(teamId, loadedDate).presentStaffIds
+
+ val staffs = StaffDao().getStaffByTeamId(teamId)
+ stafflistAdapter = StaffListAdapter(this, staffs, enablePersonSelection, attedanceIds, this)
+ recycler_view.layoutManager = mLayoutManager
+ recycler_view.itemAnimator = DefaultItemAnimator()
+ recycler_view.adapter = stafflistAdapter
+ var count = recycler_view.itemDecorationCount
+ if (count == 0) {
+ recycler_view.addItemDecoration(ItemOffsetDecoration(this, R.dimen.spacing_small))
+ }
+ }
+
+ fun setAttendanceIds(attendanceIds: List?, attendanceDate: String) {
+ this.attedanceIds = attendanceIds
+ val isAttedanceEmpty = attendanceIds?.isEmpty()
+ val isAttedanceDateToday = DateConvertor.getCurrentDate().equals(attendanceDate, ignoreCase = true)
+ if (isAttedanceEmpty!! && isAttedanceDateToday) {
+ enablePersonSelection = true
+ }
+
+ val isAttendenceNotEmpty = !isAttedanceEmpty
+
+ if (isAttedanceDateToday && isAttendenceNotEmpty) {
+ enablePersonSelection = false
+ }
+ }
+
+
+ companion object {
+ fun newIntent(context: Context, date: String, teamId: String, teamName: String): Intent {
+ val intent = Intent(context, AttedanceActivity::class.java)
+ intent.putExtra(IntentConstants.ATTENDANCE_DATE, date);
+ intent.putExtra(IntentConstants.TEAM_ID, teamId);
+ intent.putExtra(IntentConstants.TEAM_NAME, teamName);
+ return intent
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/common/BaseActivity.kt b/app/src/main/java/np/com/naxa/staffattendance/common/BaseActivity.kt
new file mode 100644
index 0000000..5cab93c
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/common/BaseActivity.kt
@@ -0,0 +1,34 @@
+package np.com.naxa.staffattendance.common
+
+import android.os.Bundle
+import android.support.v7.app.AppCompatActivity
+import android.view.MenuItem
+import kotlinx.android.synthetic.main.activity_dashboard_attedance.*
+import np.com.naxa.staffattendance.R
+
+open class BaseActivity : AppCompatActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ }
+
+ protected fun setupToolbar(title: String) {
+ setSupportActionBar(toolbar)
+ supportActionBar?.setDisplayHomeAsUpEnabled(true)
+ supportActionBar?.setDisplayShowTitleEnabled(false)
+ supportActionBar?.title = ""
+ supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_toolbar_back)
+ tv_screen_name.text = title
+
+ }
+
+ override fun onOptionsItemSelected(item: MenuItem?): Boolean {
+ when (item?.itemId) {
+ android.R.id.home -> onBackPressed();
+ }
+ return super.onOptionsItemSelected(item)
+ }
+
+
+
+}
diff --git a/app/src/main/java/np/com/naxa/staffattendance/common/Constant.kt b/app/src/main/java/np/com/naxa/staffattendance/common/Constant.kt
new file mode 100644
index 0000000..32d8ddc
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/common/Constant.kt
@@ -0,0 +1,18 @@
+package np.com.naxa.staffattendance.common
+
+object UIConstants {
+ const val UUID_GRID_ITEM_TEAM_MEMBER = "add_team_member"
+}
+
+
+object IntentConstants {
+
+ const val ATTENDANCE_DATE = "attendance_date"
+ const val EXTRA_OBJECT = "extra_object"
+ const val TEAM_ID = "team_id"
+ const val TEAM_NAME = "team_name"
+}
+
+
+val KEY_LOGOUT = "logout"
+val KEY_APP_UPDATE = "app_update"
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/data/ApiInterface.java b/app/src/main/java/np/com/naxa/staffattendance/data/ApiInterface.java
index 78acb0a..f1e604a 100644
--- a/app/src/main/java/np/com/naxa/staffattendance/data/ApiInterface.java
+++ b/app/src/main/java/np/com/naxa/staffattendance/data/ApiInterface.java
@@ -62,6 +62,7 @@ Observable uploadNewStaff(
@Part("address") RequestBody address,
@Part("contract_start") RequestBody contractStartDate,
@Part("contract_end") RequestBody contractEndDate,
+ @Part("IdPassDID") RequestBody idPassDID,
@Part MultipartBody.Part photo
);
diff --git a/app/src/main/java/np/com/naxa/staffattendance/database/DatabaseHelper.java b/app/src/main/java/np/com/naxa/staffattendance/database/DatabaseHelper.java
index 8af24ff..a326217 100644
--- a/app/src/main/java/np/com/naxa/staffattendance/database/DatabaseHelper.java
+++ b/app/src/main/java/np/com/naxa/staffattendance/database/DatabaseHelper.java
@@ -19,7 +19,9 @@ public class DatabaseHelper extends SQLiteOpenHelper {
public static final String LOG = "DatabaseHelper";
// Database Version
- public static final int DATABASE_VERSION = 6;
+
+ public static final int DATABASE_VERSION = 7;
+
// Database Name
public static final String DATABASE_NAME = "staffManager2";
@@ -43,6 +45,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
//New Staff Column names
public static final String KEY_STAFF_DESIGNATION = "designation";
+ public static final String KEY_STAFF_DESIGNATION_LABEL = "designation_label";
public static final String KEY_STAFF_FIRST_NAME = "first_name";
public static final String KEY_STAFF_LAST_NAME = "last_name";
public static final String KEY_STAFF_DOB = "dob";
@@ -73,10 +76,11 @@ public class DatabaseHelper extends SQLiteOpenHelper {
TABLE_STAFF +
"(" +
KEY_ID + " INTEGER PRIMARY KEY," +
+ KEY_ID_PASS + " TEXT ," +
KEY_STAFF_TEAM_ID + " TEXT," +//todo if team will have more attr than name and id, make new team table
KEY_STAFF_TEAM_NAME + " TEXT," +
KEY_STAFF_FULL_NAME + " TEXT," +
- KEY_ID_PASS + " TEXT," +
+ KEY_STAFF_DESIGNATION_LABEL + " TEXT," +
KEY_STAFF_TYPE + " INTEGER," +
KEY_CREATED_BY + " INTEGER," +
KEY_CREATED_AT + " DATETIME," +
@@ -88,7 +92,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
TABLE_ATTENDANCE +
"(" +
KEY_ID + " INTEGER ," +
- KEY_ID_PASS + " TEXT," +
+ KEY_ID_PASS + " TEXT ," +
KEY_STAFFS_IDS + " TEXT," +
KEY_ATTENDACE_DATE + " DATETIME PRIMARY KEY, " +
KEY_STAFF_TEAM_ID + " TEXT," +
@@ -103,8 +107,9 @@ public class DatabaseHelper extends SQLiteOpenHelper {
TABLE_NEW_STAFF +
"(" +
KEY_ID + " INTEGER PRIMARY KEY," +
- KEY_ID_PASS + " TEXT," +
+ KEY_ID_PASS + " TEXT ," +
KEY_STAFF_DESIGNATION + " INTEGER," +
+ KEY_STAFF_DESIGNATION_LABEL + " TEXT," +
KEY_STAFF_FIRST_NAME + " TEXT," +
KEY_STAFF_LAST_NAME + " TEXT," +
KEY_STAFF_DOB + " TEXT," +
diff --git a/app/src/main/java/np/com/naxa/staffattendance/database/NewStaffDao.java b/app/src/main/java/np/com/naxa/staffattendance/database/NewStaffDao.java
index 582a08d..46bc875 100644
--- a/app/src/main/java/np/com/naxa/staffattendance/database/NewStaffDao.java
+++ b/app/src/main/java/np/com/naxa/staffattendance/database/NewStaffDao.java
@@ -8,6 +8,7 @@
import np.com.naxa.staffattendance.pojo.NewStaffPojo;
import np.com.naxa.staffattendance.pojo.NewStaffPojoBuilder;
+import timber.log.Timber;
public class NewStaffDao {
@@ -27,6 +28,7 @@ public static NewStaffDao getInstance() {
}
public void saveNewStaff(NewStaffPojo newStaffPojo) {
+ Timber.d("saveNewStaff: did: " + newStaffPojo.getIdPassDID());
DatabaseHelper.getDatabaseHelper()
.getWritableDatabase()
.insert(DatabaseHelper.TABLE_NEW_STAFF,
@@ -54,10 +56,12 @@ public void deleteStaffById(String staffId) {
}
private NewStaffPojo mapCursorToPojo(Cursor cursor) {
+ Timber.i("mapCursorToPojo" + cursor);
return new NewStaffPojoBuilder()
.setDesignation(Integer.valueOf(DatabaseHelper.getStringFromCursor(cursor, DatabaseHelper.KEY_STAFF_DESIGNATION)))
+ .setDesignationLabel(DatabaseHelper.getStringFromCursor(cursor, DatabaseHelper.KEY_STAFF_DESIGNATION_LABEL))
.setFirstName(DatabaseHelper.getStringFromCursor(cursor, DatabaseHelper.KEY_STAFF_FIRST_NAME))
.setLastName(DatabaseHelper.getStringFromCursor(cursor, DatabaseHelper.KEY_STAFF_LAST_NAME))
.setDateOfBirth(DatabaseHelper.getStringFromCursor(cursor, DatabaseHelper.KEY_STAFF_DOB))
@@ -74,6 +78,7 @@ private NewStaffPojo mapCursorToPojo(Cursor cursor) {
.setPhoto(DatabaseHelper.getStringFromCursor(cursor, DatabaseHelper.KEY_STAFF_PHOTO))
.setStatus(DatabaseHelper.getStringFromCursor(cursor, DatabaseHelper.KEY_STAFF_DETAIL_STATUS))
.setID(DatabaseHelper.getStringFromCursor(cursor, DatabaseHelper.KEY_ID))
+ .setIDPass(DatabaseHelper.getStringFromCursor(cursor, DatabaseHelper.KEY_ID_PASS))
.createNewStaffPojo();
}
@@ -96,6 +101,7 @@ private ContentValues getContentValues(NewStaffPojo pojo) {
values.put(DatabaseHelper.KEY_STAFF_CONTRACT_END_DATE, pojo.getContractEnd());
values.put(DatabaseHelper.KEY_STAFF_PHOTO, pojo.getPhoto());
values.put(DatabaseHelper.KEY_STAFF_DETAIL_STATUS, pojo.getStatus());
+ values.put(DatabaseHelper.KEY_ID_PASS, pojo.getIdPassDID());
return values;
}
diff --git a/app/src/main/java/np/com/naxa/staffattendance/database/StaffDao.java b/app/src/main/java/np/com/naxa/staffattendance/database/StaffDao.java
index b233912..f92df61 100644
--- a/app/src/main/java/np/com/naxa/staffattendance/database/StaffDao.java
+++ b/app/src/main/java/np/com/naxa/staffattendance/database/StaffDao.java
@@ -70,11 +70,11 @@ public void saveStafflist(final List staffs) {
private ContentValues getContentValuesFronSaff(TeamMemberResposne staff) {
ContentValues contentValues = new ContentValues();
contentValues.put(DatabaseHelper.KEY_STAFF_FULL_NAME, staff.getFirstName().concat(" ").concat(staff.getLastName()));
- contentValues.put(DatabaseHelper.KEY_STAFF_TYPE, StaffAttendance.getStaffAttendance().getString(R.string.not_avaliable, "Staff type"));
contentValues.put(DatabaseHelper.KEY_ID, staff.getId());
contentValues.put(DatabaseHelper.KEY_STAFF_TEAM_ID, staff.getTeamID());
contentValues.put(DatabaseHelper.KEY_STAFF_TEAM_NAME, staff.getTeamName());
contentValues.put(DatabaseHelper.KEY_ID_PASS, staff.getIDPassDID());
+ contentValues.put(DatabaseHelper.KEY_STAFF_DESIGNATION_LABEL, staff.getDesignationLabel());
return contentValues;
}
@@ -84,6 +84,11 @@ public List getStaffByTeamId(String staffID) {
return getStaffFromCursor(cursor);
}
+ public List getStaffByIdPassDID(String did) {
+ Cursor cursor = getCursor(DatabaseHelper.KEY_ID_PASS + "=?", new String[]{did});
+ return getStaffFromCursor(cursor);
+ }
+
public List getStaffByTeamAndStaffId(String teamId, String staffID) {
Cursor cursor = getCursor(DatabaseHelper.KEY_ID + "=?", new String[]{staffID});
return getStaffFromCursor(cursor);
@@ -108,6 +113,7 @@ public ArrayList getStaffFromCursor(Cursor cursor) {
String staffId = DatabaseHelper.getStringFromCursor(cursor, DatabaseHelper.KEY_ID);
String staffName = DatabaseHelper.getStringFromCursor(cursor, DatabaseHelper.KEY_STAFF_FULL_NAME);
String IDPassDID = DatabaseHelper.getStringFromCursor(cursor, DatabaseHelper.KEY_ID_PASS);
+ String designationLabel = DatabaseHelper.getStringFromCursor(cursor, DatabaseHelper.KEY_STAFF_DESIGNATION_LABEL);
TeamMemberResposne staff = new TeamMemberResposneBuilder()
.setTeamID(teamID)
@@ -115,6 +121,7 @@ public ArrayList getStaffFromCursor(Cursor cursor) {
.setId(staffId)
.setIDPassDID(IDPassDID)
.setFirstName(staffName)
+ .setDesignationLabel(designationLabel)
.createTeamMemberResposne();
staffs.add(staff);
diff --git a/app/src/main/java/np/com/naxa/staffattendance/database/TeamDao.java b/app/src/main/java/np/com/naxa/staffattendance/database/TeamDao.java
index beb93dd..8701288 100644
--- a/app/src/main/java/np/com/naxa/staffattendance/database/TeamDao.java
+++ b/app/src/main/java/np/com/naxa/staffattendance/database/TeamDao.java
@@ -33,6 +33,7 @@ public Cursor getCursor(String selection, String[] selectionArgs) {
return getCursor(false, selection, selectionArgs);
}
+
public String getTeamNameById(String id) {
String teamName = "";
Cursor cursor = null;
diff --git a/app/src/main/java/np/com/naxa/staffattendance/login/LoginActivity.java b/app/src/main/java/np/com/naxa/staffattendance/login/LoginActivity.java
index 9d5959e..63d3aa9 100644
--- a/app/src/main/java/np/com/naxa/staffattendance/login/LoginActivity.java
+++ b/app/src/main/java/np/com/naxa/staffattendance/login/LoginActivity.java
@@ -4,6 +4,7 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.WindowManager;
@@ -21,6 +22,7 @@
import np.com.naxa.staffattendance.FormCall;
import np.com.naxa.staffattendance.R;
import np.com.naxa.staffattendance.SharedPreferenceUtils;
+import np.com.naxa.staffattendance.attedancedashboard.AttendancesDashboardActivity;
import np.com.naxa.staffattendance.attendence.AttendanceViewPagerActivity;
import np.com.naxa.staffattendance.attendence.MyTeamRepository;
import np.com.naxa.staffattendance.data.APIClient;
@@ -41,7 +43,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
private static final String TAG = "LoginActivity";
- private EditText tvUserName, tvPassword;
+ private TextInputLayout tvUserName, tvPassword;
private Button btnLogin;
private TokenMananger tokenMananger;
private MyTeamRepository myTeamRepository;
@@ -52,7 +54,6 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login_page);
- getWindow().setBackgroundDrawableResource(R.drawable.login_background);
if (TokenMananger.doesTokenExist()) {
AttendanceViewPagerActivity.start(this, false);
finish();
@@ -82,7 +83,7 @@ public void onClick(View view) {
case R.id.btn_login:
dialog = DialogFactory.createProgressDialogHorizontal(this, getString(R.string.msg_please_wait));
if (validate()) {
- loginToServer(tvUserName.getText().toString(), tvPassword.getText().toString());
+ loginToServer(tvUserName.getEditText().getText().toString(), tvPassword.getEditText().getText().toString());
} else {
ToastUtils.showShort("Enter valid credentials..");
}
@@ -218,11 +219,8 @@ private void fetchMyTeam() {
@Override
public void onCompleted() {
dialog.dismiss();
-
- AttendanceViewPagerActivity.start(LoginActivity.this, false);
- finish();
-
-
+ Intent intent = AttendancesDashboardActivity.Companion.newIntent(LoginActivity.this);
+ startActivity(intent);
}
@Override
@@ -275,8 +273,8 @@ private boolean validate() {
boolean valid = true;
boolean ck = false;
- String email = tvUserName.getText().toString();
- String password = tvPassword.getText().toString();
+ String email = tvUserName.getEditText().getText().toString();
+ String password = tvPassword.getEditText().getText().toString();
if (email.isEmpty()) {
tvUserName.requestFocus();
@@ -286,7 +284,7 @@ private boolean validate() {
ck = true;
}
- if (password.isEmpty() || password.length() < 4) {
+ if (password.isEmpty() ) {
if (ck) {
tvPassword.requestFocus();
}
diff --git a/app/src/main/java/np/com/naxa/staffattendance/newstaff/NewStaffActivity.java b/app/src/main/java/np/com/naxa/staffattendance/newstaff/NewStaffActivity.java
index 1b2548f..accfd42 100644
--- a/app/src/main/java/np/com/naxa/staffattendance/newstaff/NewStaffActivity.java
+++ b/app/src/main/java/np/com/naxa/staffattendance/newstaff/NewStaffActivity.java
@@ -8,13 +8,16 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
+import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.BottomNavigationView;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
+import android.text.Editable;
import android.text.TextUtils;
+import android.text.TextWatcher;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
@@ -24,19 +27,25 @@
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
+import android.widget.ScrollView;
import android.widget.Spinner;
+import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
+import org.idpass.mobile.api.IDPassConstants;
+import org.idpass.mobile.api.IDPassIntent;
+import org.idpass.mobile.proto.SignedAction;
+
import java.io.File;
import java.lang.reflect.Type;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
-import java.util.Date;
import java.util.List;
import java.util.Locale;
+import java.util.Objects;
import java.util.Random;
import np.com.naxa.staffattendance.FormCall;
@@ -45,6 +54,7 @@
import np.com.naxa.staffattendance.attendence.AttendanceViewPagerActivity;
import np.com.naxa.staffattendance.attendence.TeamMemberResposne;
import np.com.naxa.staffattendance.attendence.TeamMemberResposneBuilder;
+import np.com.naxa.staffattendance.common.BaseActivity;
import np.com.naxa.staffattendance.database.NewStaffDao;
import np.com.naxa.staffattendance.database.StaffDao;
import np.com.naxa.staffattendance.database.TeamDao;
@@ -56,14 +66,15 @@
import pl.aprilapps.easyphotopicker.DefaultCallback;
import pl.aprilapps.easyphotopicker.EasyImage;
import rx.Observer;
+import timber.log.Timber;
-public class NewStaffActivity extends AppCompatActivity implements View.OnClickListener, BottomNavigationView.OnNavigationItemSelectedListener {
-
+public class NewStaffActivity extends BaseActivity implements View.OnClickListener, BottomNavigationView.OnNavigationItemSelectedListener {
+ private int IDENTIFY_RESULT_INTENT = 1;
private Spinner bank, designation;
private TextInputLayout firstName, lastName, ethinicity, contactNumber, email, address, accountNumber;
private EditText dob, contractStartDate, contractEndDate, bankNameOther;
- private Button photo, save, create;
+ private Button photo, idpassIdentify, idpassEnroll, save, create;
private List designationList = new ArrayList<>();
private List bankList = new ArrayList<>();
private RadioGroup gender;
@@ -72,11 +83,15 @@ public class NewStaffActivity extends AppCompatActivity implements View.OnClickL
private DatePickerDialog.OnDateSetListener date;
private ArrayAdapter spinnerAdapter;
private File photoFileToUpload;
- private BottomNavigationView bottomNavigationView;
+
private Gson gson;
private Dialog msgDialog;
+ private TextView idpassValue;
DatePickerDialog datePickerDialog;
+ private String idPassDID;
+ private ScrollView scrollView;
+
public static void start(Context context, boolean disableTrasition) {
Intent intent = new Intent(context, NewStaffActivity.class);
context.startActivity(intent);
@@ -99,10 +114,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
initSpinners();
- bottomNavigationView.setSelectedItemId(R.id.action_add_staff);
- bottomNavigationView.setOnNavigationItemSelectedListener(this);
-
-
+ setupToolbar("Add Staff");
}
private void setFakeData() {
@@ -277,10 +289,13 @@ private void initUI() {
contractStartDate = findViewById(R.id.staff_contract_start_date_date);
contractEndDate = findViewById(R.id.staff_contract_end_date_date);
photo = findViewById(R.id.staff_photo);
+ idpassIdentify = findViewById(R.id.idpass_identify);
+ idpassValue = findViewById(R.id.idpass_value);
+ idpassEnroll = findViewById(R.id.idpass_enroll);
save = findViewById(R.id.staff_save);
create = findViewById(R.id.staff_send);
- bottomNavigationView = (BottomNavigationView)
- findViewById(R.id.bottom_navigation);
+ scrollView = findViewById(R.id.scrollView);
+
}
private void initListeners() {
@@ -288,6 +303,8 @@ private void initListeners() {
contractStartDate.setOnClickListener(this);
contractEndDate.setOnClickListener(this);
photo.setOnClickListener(this);
+ idpassIdentify.setOnClickListener(this);
+ idpassEnroll.setOnClickListener(this);
save.setOnClickListener(this);
create.setOnClickListener(this);
}
@@ -315,9 +332,19 @@ public void onClick(View view) {
showImageOptionsDialog();
break;
+ case R.id.idpass_identify:
+ idpassIdentify();
+ break;
+
+ case R.id.idpass_enroll:
+ idpassEnroll();
+ break;
+
case R.id.staff_save:
if (validate()) {
- new NewStaffDao().saveNewStaff(getNewStaffDetail());
+ NewStaffPojo staff = getNewStaffDetail();
+ NewStaffDao.getInstance().saveNewStaff(staff);
+ putDataInStafftable(staff);
finish();
startActivity(getIntent());
ToastUtils.showShort("New staff detail saved.");
@@ -365,6 +392,7 @@ private void putDataInStafftable(NewStaffPojo newStaffDetail) {
.setLastName(newStaffDetail.getLastName())
.setDesignation(newStaffDetail.getDesignation())
.setTeamID(id)
+ .setIDPassDID(idPassDID)
.setTeamName(new TeamDao().getTeamNameById(id))
.setId(newStaffDetail.getId())
.createTeamMemberResposne();
@@ -376,37 +404,100 @@ private boolean validate() {
boolean validation = false;
if (designation.getSelectedItem().equals(getResources().getString(R.string.default_option))) {
- ToastUtils.showShort("Select a designation");
+ showErrorMessage(designation, "Select a designation");
} else if (firstName.getEditText().getText().toString().isEmpty()) {
- ToastUtils.showShort("Enter first name");
+ showErrorMessage(firstName, "Enter first name");
} else if (lastName.getEditText().getText().toString().isEmpty()) {
- ToastUtils.showShort("Enter last name");
+ showErrorMessage(lastName, "Enter last name");
} else if (dob.getText().toString().isEmpty()) {
- ToastUtils.showShort("Choose date of birth");
+ showErrorMessage(dob, "Choose date of birth");
} else if (gender.getCheckedRadioButtonId() == -1) {
- ToastUtils.showShort("Select gender");
+ showErrorMessage(gender, "Select Gender");
} else if (ethinicity.getEditText().getText().toString().isEmpty()) {
- ToastUtils.showShort("Enter ethnicity");
+ showErrorMessage(ethinicity, "Enter ethnicity");
} else if (bank.getSelectedItem().toString().equals(getResources().getString(R.string.default_option))) {
- ToastUtils.showShort("Choose a option");
+ showErrorMessage(bank, "Choose a bank");
} else if (bank.getSelectedItem().toString().equals(getResources().getString(R.string.bank_other)) && bankNameOther.getText().toString().isEmpty()) {
- ToastUtils.showShort("Enter bank name");
+ showErrorMessage(bankNameOther, "Enter Bank name");
} else if (!bank.getSelectedItem().toString().equals(getResources().getString(R.string.default_option)) && accountNumber.getEditText().getText().toString().isEmpty()) {
- ToastUtils.showShort("Enter account number");
+ showErrorMessage(accountNumber, "Enter Account number");
} else if (contactNumber.getEditText().getText().toString().isEmpty()) {
- ToastUtils.showShort("Enter contact number");
+ showErrorMessage(contactNumber, "Enter contact number");
} else if (address.getEditText().getText().toString().isEmpty()) {
- ToastUtils.showShort("Enter address");
+ showErrorMessage(address, "Enter address");
+
} else if (contractStartDate.getText().toString().isEmpty()) {
- ToastUtils.showShort("Choose contract start date");
+
+ showErrorMessage(contractEndDate, "Choose contract start date");
} else if (contractEndDate.getText().toString().isEmpty()) {
- ToastUtils.showShort("Choose contract end date");
+
+ showErrorMessage(contractEndDate, "Choose contract end date");
+
} else {
validation = true;
}
return validation;
}
+ private void focusOnView(final ScrollView scroll, final View view) {
+ new Handler().post(new Runnable() {
+ @Override
+ public void run() {
+ int vLeft = view.getLeft();
+ int vRight = view.getRight();
+ int sWidth = scroll.getWidth();
+ scroll.smoothScrollTo(((vLeft + vRight - sWidth) / 2), 0);
+ }
+ });
+ }
+
+ private void showErrorMessage(View view, String errorMessage) {
+
+ if (view instanceof EditText) {
+ ((EditText) view).setError(errorMessage);
+ Objects.requireNonNull(((EditText) view)).addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ ((TextInputLayout) view).setError(null);
+ }
+ });
+
+ } else if (view instanceof TextInputLayout) {
+ ((TextInputLayout) view).setError(errorMessage);
+ Objects.requireNonNull(((TextInputLayout) view).getEditText()).addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ ((TextInputLayout) view).setError(null);
+ }
+ });
+ } else {
+ ToastUtils.showShort(errorMessage);
+ }
+
+ focusOnView(scrollView, view);
+
+ }
+
private void getDatePicker(final EditText view) {
new DatePickerDialog(this, (view1, year, month, dayOfMonth) -> {
@@ -421,7 +512,7 @@ private void getDatePicker(final EditText view) {
public NewStaffPojo getNewStaffDetail() {
-
+ Timber.d("ID PASS: " + idPassDID);
return new NewStaffPojoBuilder()
.setID(String.valueOf(System.currentTimeMillis()))
@@ -440,7 +531,9 @@ public NewStaffPojo getNewStaffDetail() {
.setContractStart(contractStartDate.getText().toString())
.setContractEnd(contractEndDate.getText().toString())
.setPhoto(getPhotoLocation())
+ .setIDPass(idPassDID)
.setStatus(NewStaffDao.SAVED)
+ .setDesignationLabel(designation.getSelectedItem().toString())
.createNewStaffPojo();
}
@@ -469,6 +562,23 @@ private Integer getBankId() {
}
+ private void idpassIdentify() {
+ Intent intent = IDPassIntent.intentIdentify(
+ IDPassConstants.IDPASS_TYPE_MIFARE,
+ true,
+ true,
+ null);
+ startActivityForResult(intent, IDENTIFY_RESULT_INTENT);
+ }
+
+ private void idpassEnroll() {
+ String name = firstName.getEditText().getText().toString() + " " + lastName.getEditText().getText().toString();
+
+ Intent intent = IDPassIntent.intentEnroll("L1", name, true, true, true);
+ startActivityForResult(intent, IDENTIFY_RESULT_INTENT);
+ }
+
+
private void showImageOptionsDialog() {
final CharSequence[] options = {"Take Photo", "Choose from Gallery", "Dismiss"};
@@ -493,24 +603,34 @@ public void onClick(DialogInterface dialog, int itemId) {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
- EasyImage.handleActivityResult(requestCode, resultCode, data, this, new DefaultCallback() {
- @Override
- public void onImagePickerError(Exception e, EasyImage.ImageSource source, int type) {
- photo.setError("");
- }
+ if (requestCode == IDENTIFY_RESULT_INTENT && resultCode == Activity.RESULT_OK) {
+ String signedActionBase64 = data.getStringExtra(IDPassConstants.IDPASS_SIGNED_ACTION_RESULT_EXTRA);
- @Override
- public void onImagePicked(File photoFileToUpload, EasyImage.ImageSource source, int type) {
- NewStaffActivity.this.photoFileToUpload = photoFileToUpload;
- photo.setText("Change Photo");
- }
- });
+ SignedAction signedAction = IDPassIntent.signedActionBuilder(signedActionBase64);
+
+ idPassDID = signedAction.getAction().getPerson().getDid();
+ String name = signedAction.getAction().getPerson().getName();
+ idpassValue.setText(name + " - " + idPassDID);
+ } else {
+
+ EasyImage.handleActivityResult(requestCode, resultCode, data, this, new DefaultCallback() {
+ @Override
+ public void onImagePickerError(Exception e, EasyImage.ImageSource source, int type) {
+ photo.setError("");
+ }
+
+ @Override
+ public void onImagePicked(File photoFileToUpload, EasyImage.ImageSource source, int type) {
+ NewStaffActivity.this.photoFileToUpload = photoFileToUpload;
+ photo.setText("Change Photo");
+ }
+ });
+ }
}
@Override
public void onBackPressed() {
- AttendanceViewPagerActivity.start(this, false);
finish();
}
diff --git a/app/src/main/java/np/com/naxa/staffattendance/newstaff/NewStaffCall.java b/app/src/main/java/np/com/naxa/staffattendance/newstaff/NewStaffCall.java
index ada7cc0..22cffcc 100644
--- a/app/src/main/java/np/com/naxa/staffattendance/newstaff/NewStaffCall.java
+++ b/app/src/main/java/np/com/naxa/staffattendance/newstaff/NewStaffCall.java
@@ -64,6 +64,7 @@ public Observable newStaffObservable(NewStaffPojo pojo, File photo
RequestBody.create(MediaType.parse("text/plain"), pojo.getAddress()),
RequestBody.create(MediaType.parse("text/plain"), pojo.getContractStart()),
RequestBody.create(MediaType.parse("text/plain"), pojo.getContractEnd()),
+ RequestBody.create(MediaType.parse("text/plain"), pojo.getIdPassDID()),
getImageFile(photoFileToUpload)
);
}
diff --git a/app/src/main/java/np/com/naxa/staffattendance/pojo/NewStaffPojo.java b/app/src/main/java/np/com/naxa/staffattendance/pojo/NewStaffPojo.java
index bbdefcd..5e01069 100644
--- a/app/src/main/java/np/com/naxa/staffattendance/pojo/NewStaffPojo.java
+++ b/app/src/main/java/np/com/naxa/staffattendance/pojo/NewStaffPojo.java
@@ -55,10 +55,20 @@ public class NewStaffPojo {
@Expose
private Integer bank;
+ @Expose
+ private String idPassDID;
+
private String status;
+ @SerializedName("designation_label")
+ private String designationLabel;
+
+
+ public NewStaffPojo(String id, Integer designation, String firstName, String lastName, String dateOfBirth, Integer gender,
+ String ethnicity, Integer bank, String bankName, String accountNumber, String phoneNumber, String email,
+ String address, String contractStart, String contractEnd, String photo, String status, String designationLabel,
+ String idPassDID) {
- public NewStaffPojo(String id, Integer designation, String firstName, String lastName, String dateOfBirth, Integer gender, String ethnicity, Integer bank, String bankName, String accountNumber, String phoneNumber, String email, String address, String contractStart, String contractEnd, String photo, String status) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
@@ -76,8 +86,12 @@ public NewStaffPojo(String id, Integer designation, String firstName, String las
this.contractEnd = contractEnd;
this.bank = bank;
this.status = status;
+ this.designationLabel = designationLabel;
+ this.idPassDID = idPassDID;
+
}
+
public String getId() {
return id;
}
@@ -214,4 +228,11 @@ public void setStatus(String status) {
this.status = status;
}
+ public String getIdPassDID() {
+ return idPassDID;
+ }
+
+ public void setIdPassDID(String idPassDID) {
+ this.idPassDID = idPassDID;
+ }
}
diff --git a/app/src/main/java/np/com/naxa/staffattendance/pojo/NewStaffPojoBuilder.java b/app/src/main/java/np/com/naxa/staffattendance/pojo/NewStaffPojoBuilder.java
index 9751c1f..7faf96f 100644
--- a/app/src/main/java/np/com/naxa/staffattendance/pojo/NewStaffPojoBuilder.java
+++ b/app/src/main/java/np/com/naxa/staffattendance/pojo/NewStaffPojoBuilder.java
@@ -19,6 +19,11 @@ public class NewStaffPojoBuilder {
private String status;
private String id;
+ private String designationLabel;
+
+ private String idPassDID;
+
+
public NewStaffPojoBuilder setDesignation(Integer designation) {
this.designation = designation;
return this;
@@ -105,8 +110,21 @@ public NewStaffPojoBuilder setStatus(String status) {
return this;
}
+
+ public NewStaffPojoBuilder setDesignationLabel(String designationLabel) {
+ this.designationLabel = designationLabel;
+ return this;
+ }
+
public NewStaffPojo createNewStaffPojo() {
- return new NewStaffPojo(id, designation, firstName, lastName, dateOfBirth, gender, ethnicity, bank, bankName, accountNumber, phoneNumber, email, address, contractStart, contractEnd, photo, status);
+ return new NewStaffPojo(id, designation, firstName, lastName, dateOfBirth, gender, ethnicity, bank, bankName, accountNumber, phoneNumber, email, address, contractStart, contractEnd, photo, status, designationLabel, idPassDID);
+ }
+
+ public NewStaffPojoBuilder setIDPass(String idPassDID) {
+ this.idPassDID = idPassDID;
+ return this;
+
}
+
}
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/settings/AppInfoFragment.kt b/app/src/main/java/np/com/naxa/staffattendance/settings/AppInfoFragment.kt
new file mode 100644
index 0000000..ef8b155
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/settings/AppInfoFragment.kt
@@ -0,0 +1,96 @@
+package np.com.naxa.staffattendance.settings
+
+
+import android.content.Intent
+import android.net.Uri
+import android.os.Bundle
+import android.preference.Preference
+import android.preference.PreferenceFragment
+import np.com.naxa.staffattendance.BuildConfig
+import np.com.naxa.staffattendance.R
+import np.com.naxa.staffattendance.SharedPreferenceUtils
+import np.com.naxa.staffattendance.common.KEY_APP_UPDATE
+import np.com.naxa.staffattendance.common.KEY_LOGOUT
+import np.com.naxa.staffattendance.data.TokenMananger
+import np.com.naxa.staffattendance.database.DatabaseHelper
+import np.com.naxa.staffattendance.login.LoginActivity
+import np.com.naxa.staffattendance.utlils.DialogFactory
+import java.util.*
+
+
+class SettingsFragment : PreferenceFragment(), Preference.OnPreferenceClickListener {
+
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ init()
+ initNavigationPrefs()
+ }
+
+ private fun initNavigationPrefs() {
+
+
+ }
+
+ private fun init() {
+ addPreferencesFromResource(R.xml.staff_attendance_preferences)
+ val formattedAppName = getString(R.string.app_name) + " " + BuildConfig.VERSION_NAME
+ findPreference(KEY_APP_UPDATE).title = formattedAppName
+
+ findPreference(KEY_APP_UPDATE).onPreferenceClickListener = this
+ findPreference(KEY_LOGOUT).onPreferenceClickListener = this
+ }
+
+
+ override fun onPreferenceClick(preference: Preference): Boolean {
+ when (preference.key) {
+ KEY_APP_UPDATE -> {
+ try {
+ val intent = Intent(Intent.ACTION_VIEW)
+ intent.data = Uri.parse("market://details?id" + BuildConfig.APPLICATION_ID)
+ startActivity(intent)
+ } catch (anfe: android.content.ActivityNotFoundException) {
+ startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=${BuildConfig.APPLICATION_ID}")))
+ }
+ }
+ KEY_LOGOUT -> logoutConfirmDialog()
+ }
+ return false
+ }
+
+ private fun logoutConfirmDialog() {
+ val a = DatabaseHelper.getDatabaseHelper().getNewStaffCount(DatabaseHelper.getDatabaseHelper().writableDatabase)
+ val b = DatabaseHelper.getDatabaseHelper().getFinalizedCount(DatabaseHelper.getDatabaseHelper().writableDatabase)
+
+ if (a + b > 0) run {
+ var msg = "If you logout all your account data including"
+ if (a > 0) msg += String.format(Locale.US, "%d un-synced staff(s)", a)
+ if (b > 0) msg += String.format(Locale.US, "\n %d finalized attendance(s)", b)
+ msg += "\nwill be deleted."
+ val btnText = "Delete and logout";
+
+ DialogFactory.createActionDialog(activity, "Caution", msg)
+ .setPositiveButton(btnText) { dialogInterface, i ->
+ dialogInterface.dismiss()
+ clearCache()
+ }
+ .setNegativeButton("Dismiss") { dialogInterface, i -> dialogInterface.dismiss() }
+ .create()
+ .show()
+ } else {
+ clearCache()
+ }
+
+
+ }
+
+ fun clearCache() {
+
+ TokenMananger.clearToken()
+ SharedPreferenceUtils.purge(activity)
+ DatabaseHelper.getDatabaseHelper().delteAllRows(DatabaseHelper.getDatabaseHelper().writableDatabase)
+ LoginActivity.start(activity)
+ activity.finish()
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/np/com/naxa/staffattendance/settings/SettingsActivity.kt b/app/src/main/java/np/com/naxa/staffattendance/settings/SettingsActivity.kt
new file mode 100644
index 0000000..3b5bf9a
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/settings/SettingsActivity.kt
@@ -0,0 +1,46 @@
+package np.com.naxa.staffattendance.settings
+
+import android.content.Context
+import android.content.Intent
+import android.support.v7.app.AppCompatActivity
+import android.os.Bundle
+import android.view.MenuItem
+import kotlinx.android.synthetic.main.activity_dashboard_attedance.*
+import np.com.naxa.staffattendance.R
+import np.com.naxa.staffattendance.attedancedashboard.AttendancesDashboardActivity
+
+class SettingsActivity : AppCompatActivity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_settings)
+
+ setupToolbar(title = getString(R.string.title_activity_settings))
+ }
+
+
+ override fun onOptionsItemSelected(item: MenuItem?): Boolean {
+ when (item?.itemId) {
+ android.R.id.home -> onBackPressed();
+ }
+ return super.onOptionsItemSelected(item)
+ }
+
+ private fun setupToolbar(title: String) {
+ setSupportActionBar(toolbar)
+ supportActionBar?.setDisplayHomeAsUpEnabled(true)
+ supportActionBar?.setDisplayShowTitleEnabled(false)
+ supportActionBar?.title = ""
+ supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_toolbar_back)
+ tv_screen_name.text = title
+
+ }
+
+
+ companion object {
+ fun newIntent(context: Context): Intent {
+ val intent = Intent(context, SettingsActivity::class.java)
+ return intent
+ }
+ }
+}
diff --git a/app/src/main/java/np/com/naxa/staffattendance/splash/SplashScreenActivity.kt b/app/src/main/java/np/com/naxa/staffattendance/splash/SplashScreenActivity.kt
new file mode 100644
index 0000000..20f695e
--- /dev/null
+++ b/app/src/main/java/np/com/naxa/staffattendance/splash/SplashScreenActivity.kt
@@ -0,0 +1,79 @@
+package np.com.naxa.staffattendance.splash
+
+import android.animation.Animator
+import android.animation.AnimatorListenerAdapter
+import android.os.Build
+import android.os.Bundle
+import android.os.Handler
+import android.support.v7.app.AppCompatActivity
+import android.transition.Fade
+import android.view.View
+import android.view.Window
+import android.view.WindowManager
+import kotlinx.android.synthetic.main.activity_splash_screen2.*
+import np.com.naxa.staffattendance.attedancedashboard.AttendancesDashboardActivity
+import np.com.naxa.staffattendance.data.TokenMananger
+import np.com.naxa.staffattendance.login.LoginActivity
+
+
+class SplashScreenActivity : AppCompatActivity() {
+
+
+ private var hanlder = Handler();
+ private var runnable = Runnable {
+ startActivity(AttendancesDashboardActivity.newIntent(this))
+
+ }
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ makeActivityFullScreen()
+ with(window) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ requestFeature(Window.FEATURE_CONTENT_TRANSITIONS)
+ exitTransition = Fade()
+ }
+ }
+
+ setContentView(np.com.naxa.staffattendance.R.layout.activity_splash_screen2)
+ crossfade();
+
+ }
+
+ private fun crossfade() {
+
+
+ splash_logo.alpha = 1f
+ splash_logo.visibility = View.VISIBLE
+ splash_logo.animate()
+ .alpha(0f)
+ .setStartDelay(1000L)
+ .setDuration(500L)
+ .setListener(object : AnimatorListenerAdapter() {
+ override fun onAnimationEnd(animation: Animator) {
+
+ if (TokenMananger.doesTokenExist()) {
+ startActivity(AttendancesDashboardActivity.newIntent(this@SplashScreenActivity))
+ }else{
+ LoginActivity.start(this@SplashScreenActivity)
+ }
+ overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out)
+ finish()
+
+ }
+ })
+ }
+
+
+ override fun onPause() {
+ super.onPause()
+ hanlder.removeCallbacks(runnable);
+ }
+
+ private fun makeActivityFullScreen() {
+ requestWindowFeature(Window.FEATURE_NO_TITLE)
+ window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN)
+ }
+
+}
diff --git a/app/src/main/java/np/com/naxa/staffattendance/utlils/DateConvertor.java b/app/src/main/java/np/com/naxa/staffattendance/utlils/DateConvertor.java
index 76eef2d..8130ab6 100644
--- a/app/src/main/java/np/com/naxa/staffattendance/utlils/DateConvertor.java
+++ b/app/src/main/java/np/com/naxa/staffattendance/utlils/DateConvertor.java
@@ -1,19 +1,42 @@
package np.com.naxa.staffattendance.utlils;
+import android.annotation.SuppressLint;
+
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
+import java.util.HashMap;
import java.util.Locale;
+import java.util.TimeZone;
public class DateConvertor {
+ @SuppressLint("UseSparseArrays")
+ private static HashMap month = new HashMap<>();
+
public static String getCurrentDate() {
Date cDate = new Date();
return formatDate(cDate);
}
+
+ static {
+ month.put(0, "January");
+ month.put(1, "February");
+ month.put(2, "March");
+ month.put(3, "April");
+ month.put(4, "May");
+ month.put(5, "June");
+ month.put(6, "July");
+ month.put(7, "August");
+ month.put(8, "September");
+ month.put(9, "October");
+ month.put(10, "November");
+ month.put(11, "December");
+ }
+
public static String formatDate(Date date) {
return new SimpleDateFormat("yyyy-MM-dd", Locale.US).format(date);
}
@@ -48,4 +71,82 @@ public static Date getPastDate(int days) {
Date pastDate = cal.getTime();
return pastDate;
}
+
+ public static String[] getYearMonthDay(Date date) {
+
+ Calendar cal = Calendar.getInstance(TimeZone.getDefault());
+ cal.setTime(date);
+ int year = cal.get(Calendar.YEAR);
+ int month = cal.get(Calendar.MONTH);
+ int day = cal.get(Calendar.DAY_OF_MONTH);
+
+ return new String[]{
+ getDayOfMonth(month) + ", " + year, String.valueOf(day), getDayOfWeek(cal.get(Calendar.DAY_OF_WEEK))
+ };
+ }
+
+
+ private static String getDayOfMonth(int value) {
+ return month.get(value);
+ }
+
+ private static String getDayOfWeek(int value) {
+ String day = "";
+ switch (value) {
+ case 1:
+ day = "Sunday";
+ break;
+ case 2:
+ day = "Monday";
+ break;
+ case 3:
+ day = "Tuesday";
+ break;
+ case 4:
+ day = "Wednesday";
+ break;
+ case 5:
+ day = "Thursday";
+ break;
+ case 6:
+ day = "Friday";
+ break;
+ case 7:
+ day = "Saturday";
+ break;
+ }
+ return day;
+ }
+
+
+ public static Date getDateForPosition(int pos) {
+ Date date;
+
+ switch (pos) {
+ case 0:
+ date = DateConvertor.getPastDate(-6);
+ break;
+ case 1:
+ date = DateConvertor.getPastDate(-5);
+ break;
+ case 2:
+ date = DateConvertor.getPastDate(-4);
+ break;
+ case 3:
+ date = DateConvertor.getPastDate(-3);
+ break;
+ case 4:
+ date = DateConvertor.getPastDate(-2);
+ break;
+ case 5:
+ date = DateConvertor.getPastDate(-1);
+ break;
+ default:
+ date = new Date();
+ break;
+ }
+
+
+ return date;
+ }
}
diff --git a/app/src/main/res/drawable/bg_progress.xml b/app/src/main/res/drawable/bg_progress.xml
new file mode 100644
index 0000000..b02e6fe
--- /dev/null
+++ b/app/src/main/res/drawable/bg_progress.xml
@@ -0,0 +1,30 @@
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/border.xml b/app/src/main/res/drawable/border.xml
new file mode 100644
index 0000000..a347198
--- /dev/null
+++ b/app/src/main/res/drawable/border.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_add_24dp.xml b/app/src/main/res/drawable/ic_add_24dp.xml
new file mode 100644
index 0000000..d669972
--- /dev/null
+++ b/app/src/main/res/drawable/ic_add_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_arrow_24dp.xml b/app/src/main/res/drawable/ic_arrow_24dp.xml
new file mode 100644
index 0000000..6400429
--- /dev/null
+++ b/app/src/main/res/drawable/ic_arrow_24dp.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_idpass_square.xml b/app/src/main/res/drawable/ic_idpass_square.xml
new file mode 100644
index 0000000..9398956
--- /dev/null
+++ b/app/src/main/res/drawable/ic_idpass_square.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_settings_24dp.xml b/app/src/main/res/drawable/ic_settings_24dp.xml
new file mode 100644
index 0000000..1397d37
--- /dev/null
+++ b/app/src/main/res/drawable/ic_settings_24dp.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_toolbar_back.xml b/app/src/main/res/drawable/ic_toolbar_back.xml
new file mode 100644
index 0000000..b79d00f
--- /dev/null
+++ b/app/src/main/res/drawable/ic_toolbar_back.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/app/src/main/res/drawable/logo.png b/app/src/main/res/drawable/logo.png
new file mode 100644
index 0000000..c8f8021
Binary files /dev/null and b/app/src/main/res/drawable/logo.png differ
diff --git a/app/src/main/res/drawable/toolbar_gradient.xml b/app/src/main/res/drawable/toolbar_gradient.xml
index 7ae76f6..cc24ab9 100644
--- a/app/src/main/res/drawable/toolbar_gradient.xml
+++ b/app/src/main/res/drawable/toolbar_gradient.xml
@@ -2,7 +2,7 @@
android:shape="rectangle">
diff --git a/app/src/main/res/layout/activity_attedance.xml b/app/src/main/res/layout/activity_attedance.xml
new file mode 100644
index 0000000..d8fb324
--- /dev/null
+++ b/app/src/main/res/layout/activity_attedance.xml
@@ -0,0 +1,6 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_attendance_form_edit.xml b/app/src/main/res/layout/activity_attendance_form_edit.xml
index abec59d..20413ac 100644
--- a/app/src/main/res/layout/activity_attendance_form_edit.xml
+++ b/app/src/main/res/layout/activity_attendance_form_edit.xml
@@ -50,7 +50,7 @@
android:layout_height="wrap_content"
android:layout_marginRight="32dp"
android:elevation="8dp"
- app:srcCompat="@drawable/ic_check_blue_24dp"
+ app:srcCompat="@drawable/ic_idpass_square"
app:layout_anchor="@id/card_staff_edit_form"
app:layout_anchorGravity="top|right|end"
tools:ignore="RtlHardcoded" />
diff --git a/app/src/main/res/layout/activity_dashboard_attedance.xml b/app/src/main/res/layout/activity_dashboard_attedance.xml
index 37fbcaf..ddce794 100644
--- a/app/src/main/res/layout/activity_dashboard_attedance.xml
+++ b/app/src/main/res/layout/activity_dashboard_attedance.xml
@@ -1,9 +1,51 @@
-
+
+
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_login_page.xml b/app/src/main/res/layout/activity_login_page.xml
index 26f6a39..320697f 100644
--- a/app/src/main/res/layout/activity_login_page.xml
+++ b/app/src/main/res/layout/activity_login_page.xml
@@ -1,9 +1,10 @@
+
+ android:layout_height="match_parent">
+ android:layout_marginTop="230dp"
+ android:layout_marginBottom="8dp">
+ app:passwordToggleEnabled="true">
-
diff --git a/app/src/main/res/layout/activity_new_staff.xml b/app/src/main/res/layout/activity_new_staff.xml
index 7647111..f149039 100644
--- a/app/src/main/res/layout/activity_new_staff.xml
+++ b/app/src/main/res/layout/activity_new_staff.xml
@@ -1,23 +1,45 @@
-
+ android:layout_height="match_parent">
-
+
+
+
+
+
+
+
-
+
+
+
+
+ app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior">
-
+
-
-
+
+
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
new file mode 100644
index 0000000..8b59782
--- /dev/null
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_splash_screen2.xml b/app/src/main/res/layout/activity_splash_screen2.xml
new file mode 100644
index 0000000..d01fab0
--- /dev/null
+++ b/app/src/main/res/layout/activity_splash_screen2.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/flexible_toolbar.xml b/app/src/main/res/layout/flexible_toolbar.xml
index 3800dc5..2233d50 100644
--- a/app/src/main/res/layout/flexible_toolbar.xml
+++ b/app/src/main/res/layout/flexible_toolbar.xml
@@ -9,7 +9,7 @@
+ />
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_take_attedance_dialog.xml b/app/src/main/res/layout/fragment_take_attedance_dialog.xml
new file mode 100644
index 0000000..c5e78ef
--- /dev/null
+++ b/app/src/main/res/layout/fragment_take_attedance_dialog.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/grid_item_add.xml b/app/src/main/res/layout/grid_item_add.xml
new file mode 100644
index 0000000..d0a94e8
--- /dev/null
+++ b/app/src/main/res/layout/grid_item_add.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/grid_item_calendra.xml b/app/src/main/res/layout/grid_item_calendra.xml
index 99662e4..033b588 100644
--- a/app/src/main/res/layout/grid_item_calendra.xml
+++ b/app/src/main/res/layout/grid_item_calendra.xml
@@ -1,26 +1,88 @@
-
+ android:layout_width="match_parent"
+ android:clickable="true"
+ android:focusable="true"
+ android:layout_height="wrap_content"
+ app:cardCornerRadius="@dimen/card_recycler_corner_radius"
+ app:cardElevation="0dp">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
- tools:text="Sunday" />
-
+
-
\ No newline at end of file
+
+
diff --git a/app/src/main/res/layout/grid_item_stats.xml b/app/src/main/res/layout/grid_item_stats.xml
new file mode 100644
index 0000000..4d5f404
--- /dev/null
+++ b/app/src/main/res/layout/grid_item_stats.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/header.xml b/app/src/main/res/layout/header.xml
new file mode 100644
index 0000000..c08bfd1
--- /dev/null
+++ b/app/src/main/res/layout/header.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/staff_data_edit_form.xml b/app/src/main/res/layout/staff_data_edit_form.xml
index 2bb6535..bd951b5 100644
--- a/app/src/main/res/layout/staff_data_edit_form.xml
+++ b/app/src/main/res/layout/staff_data_edit_form.xml
@@ -1,4 +1,5 @@
@@ -357,6 +358,61 @@
android:drawableStart="@android:drawable/ic_menu_camera"
android:text="Take Photo" />
+
+
+
+
+
+
+
+
+
+
+
-
+ android:layout_gravity="end"
+ android:layout_marginTop="@dimen/spacing_large"
+ android:layout_marginBottom="@dimen/spacing_xxlarge"
+ android:padding="12dp"
+ android:text="Save"
+ android:textSize="@dimen/material_text_button" />
diff --git a/app/src/main/res/layout/staff_list_row.xml b/app/src/main/res/layout/staff_list_row.xml
index 986f6d0..c58e548 100644
--- a/app/src/main/res/layout/staff_list_row.xml
+++ b/app/src/main/res/layout/staff_list_row.xml
@@ -1,14 +1,15 @@
-
+ app:cardElevation="1dp"
+>
-
-
+ android:text="Manager"
+ />
+ android:ellipsize="end"
+ android:maxLines="2"
+ android:minLines="1"
+ android:text="Nishon Tandukar"
+ />
+
+
+ android:text="9:00" />
+
+
+
+ android:layout_below="@id/staff_list_row_name"
+ android:layout_toEndOf="@id/seperator"
+ android:layout_toRightOf="@id/seperator"
+ android:text="16:00" />
+
+
+ style="@style/TextAppearance.AppCompat.Caption"
+ android:layout_marginEnd="@dimen/spacing_medium" />
-
+
diff --git a/app/src/main/res/menu/menu_dashboard.xml b/app/src/main/res/menu/menu_dashboard.xml
new file mode 100644
index 0000000..a00ecdc
--- /dev/null
+++ b/app/src/main/res/menu/menu_dashboard.xml
@@ -0,0 +1,12 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
index 0e29dba..14fd04d 100644
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
index c1e2141..f95d137 100644
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
index 11d6ff5..cb05f91 100644
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
index 976c1c9..1fd199d 100644
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
index ddacc56..fb6618e 100644
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..14fd04d
Binary files /dev/null and b/app/src/main/res/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/app/src/main/res/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..f95d137
Binary files /dev/null and b/app/src/main/res/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/app/src/main/res/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..cb05f91
Binary files /dev/null and b/app/src/main/res/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..1fd199d
Binary files /dev/null and b/app/src/main/res/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..fb6618e
Binary files /dev/null and b/app/src/main/res/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
new file mode 100644
index 0000000..0c8052f
--- /dev/null
+++ b/app/src/main/res/values/arrays.xml
@@ -0,0 +1,14 @@
+
+
+
+ - Scan Card
+ - Fingerprint
+ - Success
+
+
+
+ - We are ready to scan your card.
+ - Card verified! Verify your fingerprint.
+ - Attendance recorded successfully!
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 917a1a0..e7a3667 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -28,7 +28,7 @@
32dp
64dp
5dp
- 5dp
+ 20dp
40dp
22sp
48dp
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b54fadb..7570e2d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,5 +1,5 @@
- FS Staff Attendance
+ Attendance
Select an option
@@ -89,6 +89,14 @@
Vibrate
Device is offline
+ Dashboard
+ Members
+ Press back button again to exit
+ Team
+ Attendance
+ Cancel
+ NEXT
+ Dismiss
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 1e4e82d..693a1ba 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -13,7 +13,7 @@
-
@@ -26,4 +26,5 @@
+
diff --git a/app/src/main/res/web_hi_res_512.png b/app/src/main/res/web_hi_res_512.png
new file mode 100644
index 0000000..4a525ba
Binary files /dev/null and b/app/src/main/res/web_hi_res_512.png differ
diff --git a/app/src/main/res/xml/staff_attendance_preferences.xml b/app/src/main/res/xml/staff_attendance_preferences.xml
new file mode 100644
index 0000000..2a3e2f7
--- /dev/null
+++ b/app/src/main/res/xml/staff_attendance_preferences.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 94fdc3e..1764705 100644
--- a/build.gradle
+++ b/build.gradle
@@ -21,7 +21,8 @@ allprojects {
repositories {
google()
jcenter()
- maven { url 'https://jitpack.io' }
+ maven { url 'https://jitpack.io' }
+ maven { url 'https://dl.bintray.com/idpass/idpass-maven' }
}
}