You are on page 1of 104

DESIGN AND DEVELOPMENT OF AN SMART ELECTRICITY BILL

PAYMENT MANAGEMENT SYSTEM

Submitted by

Guided by

in partial fulfillment for the award of the degree

of

BACHELOR OF COMPUTER APPLICATION


IN

DEPARTMENT OF COMPUTER SCIENCE AND APPLICATIONS

PERIYAR NAGAR, VALLAM-613 403, THANJAVUR.

APRIL,2021


DEPARTMENT OF COMPUTER
SCIENCE AND
APPLICATIONS
Periyar Nagar, Vallam Thanjavur - 613 403, Tamil Nadu, India
Phone: +91 - 4362 - 264600Fax: +91- 4362 - 264660
Email: headmca@pmu.edu Web: www. pmu.edu

BONAFIDE CERTIFICATE
Certified that this Project report “DESIGN AND DEVELOPMENT OF AN
SMART ELECTRICITY BILL PAYMENT MANAGEMENT SYSTEM” is
the bonafide work of “Name (Reg.No)” who carried out the Project work
under my supervision.

Signature :

Name :

Head of the Department supervisor

Date :

Submitted for Periyar Maniammai Institute of Science & Technology In-plant


Training Viva-voce Examination held on …………………….

Signature :

Name :

External Examiner Internal Examiner

Date :


ACKNOWLEDGEMENT

I acknowledgement with reverence and offer a thankfulness with profound


gratitude to the in valuable service rendered and kindness showed upon me by the way of
guidance to this dedicated luminaries whose service went all the way towards the
completion of the project.

My respectful thanks to Hon’ble Dr.K.VEERAMANI M.A.B.L.., Chancellor,


Periyar Maniammai Institute of Science & Technology, Vallam for this encouragement
and support to complete our course successful.

I take immense pleasure at this moment of acknowledge with infinite thanks to


Honable Prof.Dr.S.VELUSAMI, BE,ME,Ph.D., Vice chancellor, Periyar Maniyammai
Institute of Science & Technology. Vallam for the significant contribution bring my
project successful.

I take immense pleasure at this moment of acknowledge with infinite thanks to


Respected Prof. Dr. S.Devadoss Pro Vice Chancellor Ph.D., Periyar
Maniyammai Institute of Science & Technology. Vallam for the significant contribution
bring my project successful.

I take immense pleasure at this moment of acknowledge with infinite thanks to


Respected Dr. J. JEYACHIDRA M.C.A.,Ph.D., HOD, Dean i/c, FCSE for timely
advice and a kind co-operation in completing my project work. I extended my hearty
thanks to my internal guide Ms. P.RANJANI MCA, Assistant Professor., Department of
Computer Science and Applications, for his valuable suggestion and guidance to
complete my project successful.

I wish to express my thanks to our all Faculty Member of Department of


Computer Science and Applications, Periyar Maniyammai Institute of Science &
Technology. Vallam, Thanjavur


INDEX

CHAPTERS PARTICULARS PAGE.NO

ABSTRACT

CHAPTER INTRODUCTION 1
1 Existing System
Proposed System

CHAPTER SYSTEM CONFIGURATION 3-5


2 2.1 System Architecture

CHAPTER DIAGRAMATIC REPRESENTATION 7-13


3 UML Diagrams
ER Diagram
Data Flow Diagram
Database Structure

CHAPTER MODULES 14
4 Admin mode
User mode
Fingerprint sensing

CHAPTER DESIGN AND DEVELOPMENT 15-20


5 5.1 Data base Structure

CHAPTER IMPLEMENTATION AND TESTING 21-22


6

CHAPTER APPENDIX 23-80


7 Sample Code
Screen Shot

CHAPTER CONCLUSION AND FUTURE WORK 81-82


8 Conclusion
Future Work


22-12-2020

Acceptance Letter for Project

To

Name

Reg.No –

BCA

PMIST, Vallam.

Dear R.K.Manisha,

On behalf of the Scion Research and Development, we would like to notify you of this
opportunity for a project. On your acceptance of this offer, you can continue a project
(DESIGN AND DEVELOPMRNT OF AN SMART ELECTRICITY BILL
PAYMENT MANAGEMENT SYSTEM) with the company from January 2021 to
April 2021.

We assure you that the details of your particulars we have collected during your
program should be saved in our covert privately.

We appreciate your interest in our

company. Warm regards,

[K.SHANMUGARAJA M.Tech., MBA, MSY, (Ph.D)]

Director

NO.17/595, SAREFOJI NAGAR 2ND CROSS, OPP.RAMNATH HOTEL, NEAR


NEW BUS STAND, THANJAVUR-5. CONTACT – 9597754496, Email-
scionrd2009@gmail.com


ABSTRACT

The project is a web based application where users can get instant electricity bill and pay them

online via credit card. The system automates the conventional process of paying electricity bill by

visiting the place. Users have to stand in queue for paying bill and wait for their turn. The process is

tiresome and time consuming. They even have to wait for the bill being delivered to their place which

sometimes can be delivered late by the delivery boy. Hence the system is developed to automate the

electricity bill calculation and payment for user convenience.

The system would be having two logins admin and user login. Admin can view user account

details and can even add or updates things in their account. Admin has to feed the system with

electricity usage data into respective users account. The system then calculates the electricity bill for

every user and updates the information into their account every month. User can view their electricity

bill and then the user can get the information like how voltages are used in individual home appliances.

Then the system is used to calculate the voltage level of particular home appliance and how much of

cost is used in that particular appliance and also individually pay on the spot before month end. If user is

incapable of paying the bill before month end, it then calculates fine for each day.
INTRODUCTION

Electricity is one of the vital requirements for sustainment of comforts of life. IT should be used
very judiciously for its proper utilization. But in our country we have lot of localities where we have
surplus supply for the electricity while many areas do not even have access to it. Our policies of its
distribution are also partially responsible for this because we are still not able to correctly estimate our
exact requirements and still how much of power units are used at a particular home appliances is
prevailing.

On the other hand consumers are also not satisfied with the services of power companies. Most
of the time they have complaints regarding statistical errors in their monthly bills. Thus we are trying to
present an idea towards the minimization of technical errors and to reduce human dependency at the
same time. With the help of this project we are aiming to receive the monthly energy consumption from
a remote location directly to a centralized office. In this way we can reduce human efforts needed to
record the meter readings which are till now recorded by visiting every home individually. This results
in considerable loss of human hours and also provides considerable details regarding the average
consumption of a locality so that power supply can be made according to these data. This will help the
officials in deciding the specifications of transformers and other instruments required in power
transmission.

This idea is economically efficient as well because we can get the meter reading at a very low
cost. The implementation is done in such a way that a SMS is delivered to the Modem whose reading is
to be noted and then that meter replies to the server in the SMS format and it is known that SMS costs
are very low.The purpose of this project is to remote monitoring and control of the Domestic Energy
meter. This system enables the Electricity Department to read the meter readings regularly without the
person visiting each house. This can be achieved by the use of Microcontroller unit that continuously
monitors and records the Energy Meter readings in its permanent (non-volatile) memory location.
 This system is made to keep the records about the bills of the customers. The admin can manage
all the accounts and the registered users like employees and customers can only manage their own
accounts. This system helps in maintaining the bills and the payments. A different module is there for
employees to check the customer’s details if their job requires. Admin, employees, and customers all
have a different interface and different privileges according to their need. Like a customer can only
manage his account and cannot see any details of other customers, employees can see the details of all
the customer’s accounts and admin can manage all the accounts including the customers and employees
account. This system also has the option for customers to pay their electricity bills by online mode.
Either through internet banking or by debit card.
This system also has the feature to add and delete customer and employee’s accounts in case a
customer wants to cut the connection or an employee wants to leave the job. All the employees are
divided into different departments according to their job profile and the customers are divided according
to their wards. The rest of the modules are explained in the further sections with the detailed
explanation.

This application is used to continuously record the readings and the live meter reading can be
send to the Electricity department on request. This system also can be used to disconnect the power
supply to the house in case of non-payment of electricity bills. Then this system is used to pay the
electricity charge through the online payment. Then this system is also used to find calculation of how
much of units and amount are used at a particular home appliance at the month usage

2
SYSTEM ANALYSIS

Existing System

In the presented system all the jobs of the electricity board is prepared by hand, it is very
complicated to the operators and needs to keep the objects records of the office and a separate record for
the billing and customer details. Many irregularities exist in the present system, which is manually
maintained. It requires high processing time.
Errors may also occur in this system. These details are all stored in special records. Though all the most
importance, tedious a care needed job is the bill calculation. Any one of mistakes may cause severe
consequence. The firm handles all of the work manually, which is very tedious and mismanaged.

DISADVANTAGE:
 That is not user friendly.

 The retrieval and storing of data is slow.

 Data is not maintained efficiently.

 Existing system requires lot of paper work and even a small transaction require many papers fill.

3
Proposed System

All these factors are verified for the authentication purpose of the user along with
ATM scanning and biometric verification. If any of the above said, parameter are
differing and then the link is generated to the User’s Mobile number for further more
secure authentication system. In the modification phase, an automation user Internet

(Bank server) recognition model using mobile is designed to enhance the user
comfort and detection of the time span spend by the user in the ATM machine. The
system improves the security of ATM’s. Use of Biometric and link provides second level
of security. The system is cost effective and cheaper than usual ATM systems.

Advantage

1. The system improves the security of ATM’s.


2. Use of Biometric and link provides second level of security. The system is
cost effective and cheaper than usual ATM systems.

4
SYSTEM REQUIREMENTS

Hardware Requirement

Hard disk : 1 TB
RAM : 4 GB
Processor : Core i3
Monitor : 15’’Color Monitor

Software Requirement

Front-End : Java
Back end : Fire Base DB
Operating System : Windows 10
IDE : Android
Studio

5
CHAPTER 2
SYSTEM CONFIGURATION
2.1 System Architecture

6
CHAPTER 3
DIAGRAMATIC REPRESENTATION
UML Diagrams

Use Case

Diagram

7
Class Diagram

8
Sequence Diagram

9
Activity diagram

10
ER Diagram

11
Data Flow Diagram

12
Database Structure

TBL_USER="user";

String id;

String
account;

String name;

String mobile;

String password;

int amount;

String otp;

int status;

long createdTime;

long modifedTime;

TBL_TRANSACTION="transaction";

int type;

int amount;

13
CHAPTER

4 MODULES
4 Module

Admin mode: In this mode the user finger print and mobile number are collected and
saved at the time of opening the account.
User mode: In this mode, the user fingerprint is validated with saved fingerprint for
the identification, which is required to perform transactions. This software system is
designed as follows In next step, the system is initialized to check specific task, such
as checking ATM terminal, GSM module and so on, and then each module is reset
for ready to run commands. Before accessing ATM system, the mobile number and
fingerprint of the customer are needed to be authenticated.
Fingerprint sensing, in which the fingerprint of an individual is acquired by a
fingerprint scanner to produce a raw digital representation
4..4 Pre-processing, in which the input fingerprint is enhanced and adapted to simplify
the task of feature extraction
4..5 Feature extraction, in which the fingerprint is further processed to generate
discriminative properties, also called feature vectors
4.6 Matching, in which the feature vector of the input fingerprint is compared against one
or more existing templates.
The first step is to the user enters finger in fingerprint sensor and the sensor verify the
currently entered finger print with registered finger print that already registered in bank
database at the time of account opening. If the two fingerprints get matched, then
SESSION LINK will send to respective mobile number that we have registered in the
bank. After getting SESSION LINK, we have to enter in ATM and we can draw the
money. And the SESSION LINK used only once at a time. From this we can give more
security to the cash holder’s.
CHAPTER 5
DESIGN AND DEVELOPMENT
SYSTEM TESTING

The purpose of testing is to discover errors. Testing is the process of trying to


discover every conceivable fault or weakness in a work product. It provides a way to
check the functionality of components, sub assemblies, assemblies and/or a finished
product It is the process of exercising software with the intent of ensuring that the
Software system meets its requirements and user expectations and does not fail in an
unacceptable manner. There are various types of test. Each test type addresses a specific
testing requirement.

Type of Testing

Testing is the process of trying to discover every conceivable fault or weakness in a work
product. The different type of testing is given below:

Unit Testing:

Unit testing involves the design of test cases that validate that the internal program
logic is functioning properly, and that program inputs produce valid outputs. All decision
branches and internal code flow should be validated. It is the testing of individual
software units of the application .it is done after the completion of an individual unit
before integration.

This is a structural testing, that relies on knowledge of its construction and is invasive.
Unit tests perform basic tests at component level and test a specific business process,
application, and/or system configuration. Unit tests ensure that each unique path of a
business process performs accurately to the documented specifications and contains
clearly defined inputs and expected results.

Integration Testing:

Integration tests are designed to test integrated software components to determine


if they actually run as one program. Testing is event driven and is more concerned with
the basic outcome of screens or fields. Integration tests demonstrate that although the

15
components were individually satisfaction, as shown by successfully unit testing, the
combination of components is correct and consistent. Integration testing is specifically
aimed at exposing the problems that arise from the combination of components.

Functional Test:

Functional tests provide systematic demonstrations that functions tested are available
as specified by the business and technical requirements, system documentation, and user
manuals.

Functional testing is centered on the following items:

Valid Input : identified classes of valid input must be accepted.

Invalid Input : identified classes of invalid input must be rejected.

Functions : identified functions must be exercised.

Output : identified classes of application outputs must be


exercised.

Systems/ Procedures: interfacing systems or procedures must be invoked.

Organization and preparation of functional tests is focused on requirements, key


functions, or special test cases. In addition, systematic coverage pertaining to identify
Business process flows; data fields, predefined processes, and successive processes must
be considered for testing. Before functional testing is complete, additional tests are
identified and the effective value of current tests is determined.

Performance Testing:

System testing ensures that the entire integrated software system meets requirements.
It tests a configuration to ensure known and predictable results. An example of system
testing is the configuration oriented system integration test. System testing is based on

16
process descriptions and flows, emphasizing pre-driven process links and integration
points.

White Box Testing:

White Box Testing is a testing in which in which the software tester has knowledge
of the inner workings, structure and language of the software, or at least its purpose. It is
purpose. It is used to test areas that cannot be reached from a black box level.

Black Box Testing:

Black Box Testing is testing the software without any knowledge of the inner
workings, structure or language of the module being tested. Black box tests, as most other
kinds of tests, must be written from a definitive source document, such as specification or
requirements document, such as specification or requirements document. It is a testing in
which the software under test is treated, as a black box .you cannot “see” into it. The test
provides inputs and responds to outputs without considering how the software works.

Acceptance Testing:

User Acceptance Testing is a critical phase of any project and requires significant
participation by the end user. It also ensures that the system meets the functional
requirements.

Test Results: All the test cases mentioned above passed successfully. No
defects encountered

Validation Testing

Validation testing is the process of ensuring if the tested and developed software
satisfies the client /user needs. The business requirement logic or scenarios have to be
tested in detail. All the critical functionalities of an application must be tested here.

17
As a tester, it is always important to know how to verify the business logic or scenarios
that are given to you. One such method that helps in detail evaluation of the
functionalities is the Validation Process.

Whenever you are asked to perform a validation test, it takes a great responsibility as you
need to test all the critical business requirements based on the user needs. There should
not be even a single miss on the requirements asked by the user. Hence a keen knowledge
on validation testing is much important.

As a tester, you need to evaluate if the test execution results comply with that mentioned
in the requirements document. Any deviation should be reported immediately and that
deviation is thus called a bug.

From a company perspective, the validation test in simple is carried out by the
following steps:

 You gather the business requirements for validation testing from the end user.
 Prepare the business plan and send it for the approval to the
onsite/stakeholders involved.
 On approval of the plan, you begin to write the necessary test cases and send
them for approval.
 Once approved you begin to complete testing with the required
software, environment and send the deliverables as requested by the
client.
 Upon approval of the deliverables, UAT testing is done by the client.
 After that, the software goes for production.

18
Fields Testing

This testing is done in the last phase when the regression is done for the
application and the application is called stable by the ‘Team’ before the release. There
may or may not be a requirement given for this from the customer. The type of testing
mainly include the functional and usability of the application. This is strictly done on
Mobile Networks. QA's need to step out and test while walking around or at home or
driving. Testing is done only on real devices.

19
CHAPTER

7 APPENDIX
APPENDIX

Sample Code

package com.example.secureatm.ui.activity;

import android.app.Dialog;

import android.content.Context;

import android.content.Intent;

import android.content.SharedPreferences;

import android.content.pm.PackageManager;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import android.graphics.Color;

import android.graphics.Paint;

import android.net.Uri;

import android.os.Bundle;

import android.os.Handler;

import android.provider.MediaStore;

import android.support.design.widget.TextInputLayout;

import android.support.v7.app.AppCompatActivity;

import android.view.View;

import android.widget.Button;
import android.widget.EditText;

import android.widget.ImageView;

import android.widget.LinearLayout;

import android.widget.TextView;

import com.example.secureatm.R;

import com.example.secureatm.model.UserData;

import com.example.secureatm.utils.CommonUtils;

import com.example.secureatm.utils.DatabaseUtils;

import com.example.secureatm.utils.FilePathUtils;

import com.example.secureatm.utils.LogUtils;

import

com.example.secureatm.utils.PreferenceUtils;

import com.example.secureatm.utils.SMSUtils;

import com.example.secureatm.utils.WebFramework;

import com.google.android.gms.tasks.OnSuccessListener;

import com.google.firebase.database.DataSnapshot;

import com.google.firebase.database.DatabaseError;

import com.google.firebase.database.DatabaseReference;

import com.google.firebase.database.FirebaseDatabase;

import com.google.firebase.database.Query;
import com.google.firebase.database.ValueEventListener;
import android.widget.EditText;

import android.widget.ImageView;

import android.widget.LinearLayout;

import android.widget.TextView;

import com.example.secureatm.R;

import com.example.secureatm.model.UserData;

import com.example.secureatm.utils.CommonUtils;

import com.example.secureatm.utils.DatabaseUtils;

import com.example.secureatm.utils.FilePathUtils;

import com.example.secureatm.utils.LogUtils;

import

com.example.secureatm.utils.PreferenceUtils;

import com.example.secureatm.utils.SMSUtils;

import com.example.secureatm.utils.WebFramework;

import com.google.android.gms.tasks.OnSuccessListener;

import com.google.firebase.database.DataSnapshot;

import com.google.firebase.database.DatabaseError;

import com.google.firebase.database.DatabaseReference;

import com.google.firebase.database.FirebaseDatabase;

import com.google.firebase.database.Query;

24
import com.google.firebase.database.ValueEventListener;

25
import com.google.firebase.storage.FirebaseStorage;

import java.io.File;

import java.net.URL;

import java.util.HashMap;

import java.util.Map;

import butterknife.BindView;

import butterknife.ButterKnife;

public class LoginScreen extends AppCompatActivity {

@BindView(R.id.til_username)

TextInputLayout til_username;

@BindView(R.id.til_password)

TextInputLayout til_password;

@BindView(R.id.ed_username)

EditText ed_user_name;

@BindView(R.id.ed_password)

EditText ed_password;

@BindView(R.id.btn_login)

Button btn_login;

@BindView(R.id.llay_forget_password)

LinearLayout llay_forget_password;

26
@BindView(R.id.llay_register)

LinearLayout llay_register;

@BindView(R.id.tv_new_user)

TextView tv_new_user;

@BindView(R.id.tv_admin)

TextView tv_admin;

@BindView(R.id.iv_sign)

ImageView iv_sign;

@BindView(R.id.tv_logo_instruction)

TextView tv_logo_instruction;

@BindView(R.id.llay_admin)

LinearLayout llay_admin;

Dialog dialog;

FirebaseStorage storage;

Uri selectedUri;

boolean isUploading=false;

int REQUEST_ID_STORAGE_PERMISSIONS=1;

public static final int PICK_IMAGE = 1;

Context context;

SharedPreferences prefs;

27
FirebaseDatabase database;

Bitmap bmSelected;

private static final int USER_LOGIN=1,ADMIN_LOGIN=2;

int LOGIN_TYPE=USER_LOGIN;

Handler hh=new

Handler(); String

strErrorMsg="";

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_login_screen);

try{

getSupportActionBar().hide();

ButterKnife.bind(this);

context = this;

prefs = getSharedPreferences(PreferenceUtils.PREF_NAME,

MODE_PRIVATE); database = FirebaseDatabase.getInstance();

storage=FirebaseStorage.getInstance();

LogUtils.i("Intent","Intent Action Login : "+getIntent().getAction()+" category :


"+getIntent().getCategories()+"data : "+getIntent().getData());

tv_new_user.setPaintFlags(tv_new_user.getPaintFlags() |
Paint.UNDERLINE_TEXT_FLAG);
28
tv_admin.setPaintFlags(tv_admin.getPaintFlags() |
Paint.UNDERLINE_TEXT_FLAG);

btn_login.setOnClickListener(new View.OnClickListener()

{ @Override

public void onClick(View view)

{ try{

if(LOGIN_TYPE==USER_LOGIN){

String strUserName =

ed_user_name.getText().toString().trim(); String strPassword =

ed_password.getText().toString().trim();

if (selectedUri!=null&&strUserName.length() == 10 ) {

loginRequest(strUserName, strPassword);

} else {

if(selectedUri==null){

tv_logo_instruction.setVisibility(View.VISIBLE);

tv_logo_instruction.setText("Select Finger Print.");

tv_logo_instruction.setTextColor(Color.RED);

if (strUserName.length() !=10) {

til_username.setError(getResources().getString(R.string.valid_mobile));

// if (strPassword.length() == 0) {

29
// til_password.setError( getResources().getString(R.string.empty_validation_field));

30
}

}else{

String strUserName =

ed_user_name.getText().toString().trim(); String strPassword =

ed_password.getText().toString().trim();

if (strUserName.length() == 10&& strPassword.length()==6)

{ loginTransactionRequest(strUserName, strPassword);

} else {

if (strUserName.length() !=10) {

til_username.setError(getResources().getString(R.string.valid_mobile));

if (strPassword.length() != 6) {

til_password.setError("Enter 6 digit OTP");

}catch (Exception e){

LogUtils.printException(e);

iv_sign.setOnClickListener(new View.OnClickListener()

{ @Override

31
public void onClick(View view) {

32
try{

boolean isGranted =
CommonUtils.isStoragePermissionGranted(context,
REQUEST_ID_STORAGE_PERMISSIONS);

if (isGranted) {

Intent intent = new Intent();

intent.setType("image/*");

intent.setAction(Intent.ACTION_GET_CONTENT);

startActivityForResult(Intent.createChooser(intent, "Select
Finger Print"), PICK_IMAGE);

}catch (Exception e){

LogUtils.printException(e);

llay_admin.setOnClickListener(new View.OnClickListener()

{ @Override

public void onClick(View view)

{ try{

LOGIN_TYPE=ADMIN_LOGIN;

iv_sign.setVisibility(View.GONE);

tv_logo_instruction.setVisibility(View.GONE);

til_password.setVisibility(View.VISIBLE);

// til_username.setHint("User name");
33
ed_user_name.setHint("User name");

btn_login.setText("Submit");

}catch (Exception e){

LogUtils.printException(e);

// llay_forget_password.setOnClickListener(new View.OnClickListener() {

// @Override

// public void onClick(View view) {

// try{

// CommonUtils.goNextScreen(LoginScreen.this, ForgetPasswordScreen.class);

// }catch (Exception e){

// LogUtils.printException(e);

llay_register.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view)

{ try{

Intent i=new Intent(LoginScreen.this,RegistrationScreen.class);

startActivity(i);

}catch (Exception e){

LogUtils.printException(e);

29
// boolean isLogin=prefs.getBoolean(PreferenceUtils.LOGIN_STATUS,false);

// if(isLogin){

// String nUserType=prefs.getString(PreferenceUtils.USER_TYPE,null);

// CommonUtils.goNextScreen(LoginScreen.this,HomeScreen.class);

// finish();

}catch (Exception e){

LogUtils.printException(e);

} }

/**

* This method is used to send login request

* @param strUsername User name

* @param strPassword Password

*/

private void loginRequest(final String strUsername, final String strPassword){

try{

final DatabaseReference myRef =


database.getReference(DatabaseUtils.TBL_USER);

CommonUtils.showProgress(context);

Query query=myRef.orderByChild("mobile").equalTo(strUsername);

30
query.addListenerForSingleValueEvent(new ValueEventListener()

{ @Override

public void onDataChange(DataSnapshot dataSnapshot) {

CommonUtils.hideProgress();

if (dataSnapshot.exists()) {

// dataSnapshot is the "issue" node with all children with id

0 for (DataSnapshot issue : dataSnapshot.getChildren()) {

final UserData bd = issue.getValue(UserData.class);

if(bd!=null){

if(bd.getMobile().equals(strUsername)){

try {

CommonUtils.showProgress(context);

new Thread(new Runnable() {

@Override

public void run()

{ try{

String strOriginalFinger=bd.getImage();

31
URL urlFinger = new URL(strOriginalFinger);

Bitmap imageFinger =
BitmapFactory.decodeStream(urlFinger.openConnection().getInputStream());

final boolean
isFingerValid=CommonUtils.compareImages(imageFinger,bmSelected);

LogUtils.i("LoginValidation","LoginValidation :
"+isFingerValid);

try {

if (isFingerValid) {

final String pwd=CommonUtils.random();

String strMobile=bd.getMobile();

String strContent="Hi,\n"+"Your OTP is "+pwd;

LogUtils.i("MsgLength",strMobile+" MsgLength
"+strContent.length());

sendSMSMessage("91",strMobile,strContent,null);

myRef.child(bd.getId()).child("otp").setValue(pwd).addOnSuccessListener(new
OnSuccessListener<Void>() {

32
@Override

public void onSuccess(Void aVoid) {

PreferenceUtils.saveBoolean(PreferenceUtils.LOGIN_STATUS,true,prefs);

PreferenceUtils.saveText(PreferenceUtils.USER_ID,bd.getId(),prefs);

PreferenceUtils.saveText(PreferenceUtils.USER_CODE,strUsername,prefs);

PreferenceUtils.saveText(PreferenceUtils.USER_NAME,bd.getName(),prefs);

PreferenceUtils.saveText(PreferenceUtils.ACCOUNT, bd.getAccount(),prefs);

if(!bd.getId().equals("admin")){

String
strFcmToken=prefs.getString(PreferenceUtils.FCM_TOKEN,null);

sendFCMToken(strFcmToken,bd.getId());

hh.postDelayed(new Runnable()

{ @Override

public void run() {

CommonUtils.hideProgress();

33
finish();

},100);

} else {

strErrorMsg = "Select valid finger print.";

hh.postDelayed(new Runnable()

{ @Override

public void run() {

CommonUtils.hideProgress();

CommonUtils.showErrorToast(strErrorMsg,
context);

},100);

}catch (Exception e){

LogUtils.printException(e);

} catch(Exception e) {

LogUtils.printException(e);

34
}

}).start();

} catch(Exception e) {

LogUtils.printException(e);

}else{

CommonUtils.showErrorToast(getResources().getString(R.string.invalidCredentials),cont
ext);

}else{

CommonUtils.showErrorToast(getResources().getString(R.string.invalidCredentials),cont
ext);

}else{

CommonUtils.showErrorToast(getResources().getString(R.string.invalidCredentials),cont
ext);

@Override

public void onCancelled(DatabaseError databaseError) {

// Firebase ref = myRef.child(Firebas.CHILD_FLIGHTS);

35
// Query queryRef = ref.orderByChild("arrivalDate_code").equalTo("2016-
06- 21_GOT");

// queryRef.addListenerForSingleValueEvent(new ValueEventListener() {

// @Override

// public void onDataChange(DataSnapshot dataSnapshot) {

//// myRef.addValueEventListener(new ValueEventListener() {

// @Override

// public void onDataChange(DataSnapshot dataSnapshot) {

// CommonUtils.hideProgress();

// UserData bd = dataSnapshot.getValue(UserData.class);

//// @Override

// public void onCancelled(DatabaseError error) {

// CommonUtils.hideProgress();

// // Failed to read value

// LogUtils.e("DBError", "Error....");

// }

// });

}catch (Exception e){

LogUtils.printException(e);

36
private void sendSMSMessage(final String countryCode,final String mobile,final
String messag,final String from) {

try {

new Thread(new Runnable()

{ @Override

public void run()

{ try{

WebFramework objWebFramework = new WebFramework();

Map<String, String> mapParameters = new HashMap<String,

String>(); mapParameters.put("country", countryCode); if(from!

=null&&from.length()>0){

mapParameters.put("sender", from);

}else{

mapParameters.put("sender", SMSUtils.SENDER);

mapParameters.put("route", ""+SMSUtils.ROUTE);

mapParameters.put("mobiles", mobile);

mapParameters.put("authkey", SMSUtils.AUTH_KEY);

mapParameters.put("message", message);

String authStringEnc="";

Map<String, String> mapHeaders = new HashMap<String, String>();

37
mapHeaders.put("Authorization", "Basic " + authStringEnc);

String strResponse =
objWebFramework.doHttpRequest(SMSUtils.URL, WebFramework.HttpMethod.GET,
mapParameters, mapHeaders);

System.out.println("SMS Response : "+strResponse);

LogUtils.e("sendWhatsAppMessage","onCompleted Response :
"+strResponse);

}catch (Exception e){

LogUtils.printException(e);

}).start();

} catch (Exception e)

{ e.printStackTrace(

);

private void loginTransactionRequest(final String strUsername, final


String strPassword){

try{

final DatabaseReference myRef =


database.getReference(DatabaseUtils.TBL_USER);

CommonUtils.showProgress(context);

Query query=myRef.orderByChild("mobile").equalTo(strUsername);

query.addListenerForSingleValueEvent(new ValueEventListener() {

38
@Override

39
public void onDataChange(DataSnapshot dataSnapshot) {

CommonUtils.hideProgress();

if (dataSnapshot.exists()) {

// dataSnapshot is the "issue" node with all children with id

0 for (DataSnapshot issue : dataSnapshot.getChildren()) {

final UserData bd =

issue.getValue(UserData.class); if(bd!=null){

if(bd.getMobile().equals(strUsername)&&bd.getOtp().equals(strPassword)&&bd.getStatu
s()==1){

myRef.child(bd.getId()).child("otp").setValue("").addOnSuccessListener(new
OnSuccessListener<Void>() {

@Override

public void onSuccess(Void aVoid) {

PreferenceUtils.saveBoolean(PreferenceUtils.LOGIN_STATUS,true,prefs);

PreferenceUtils.saveText(PreferenceUtils.USER_ID,bd.getId(),prefs);

PreferenceUtils.saveText(PreferenceUtils.USER_CODE,strUsername,prefs);

PreferenceUtils.saveText(PreferenceUtils.USER_NAME,bd.getName(),prefs);

40
PreferenceUtils.saveText(PreferenceUtils.ACCOUNT, bd.getAccount(),prefs);

CommonUtils.goNextScreen(LoginScreen.this,
TransactionScreen.class);

finish();

}else{

CommonUtils.showErrorToast(getResources().getString(R.string.invalidCredentials),cont
ext);

}else{

CommonUtils.showErrorToast(getResources().getString(R.string.invalidCredentials),cont
ext);

}else{

CommonUtils.showErrorToast(getResources().getString(R.string.invalidCredentials),cont
ext);

@Override

public void onCancelled(DatabaseError databaseError) {

41
}

LogUtils.printException(e);

} private void sendFCMToken(String fcmtoken, String userId)

{ try {

FirebaseDatabase database= FirebaseDatabase.getInstance();

final DatabaseReference myRef =


database.getReference(DatabaseUtils.TBL_USER).child(userId);

myRef.child("fcmToken").setValue(fcmtoken);

}catch (Exception e){

LogUtils.printException(e);

@Override

public void onRequestPermissionsResult(int requestCode, String[] permissions, int[]


grantResults) {

super.onRequestPermissionsResult(requestCode, permissions,

grantResults); try{

_ID_STORAGE_PERMISSIONS&&grantResults[0]==
PackageManager.PERMISSION_GRANTED){

42
LogUtils.i("permission","onRequestPermissionsResult permisssion
granted... permission : "+permissions.toString()+" result :
"+grantResults.toString());

Intent intent = new Intent();

intent.setType("image/*");

intent.setAction(Intent.ACTION_GET_CONTENT);

startActivityForResult(Intent.createChooser(intent, "Select Finger Print"),


PICK_IMAGE);

}catch (Exception e){

LogUtils.printException(e);

@Override

public void onActivityResult(int requestCode, int resultCode, Intent data)

try {

if (requestCode == PICK_IMAGE && resultCode == RESULT_OK && data !


= null && data.getData() != null) {

Uri uri = data.getData();

String path= FilePathUtils.getPath(context,uri);

43
LogUtils.i("Logo","Logo Uri : "+path);

File file=new

File(path);

if(file.exists()){

LogUtils.i("Logo","Logo : "+file.getAbsolutePath());

long length=file.length();

LogUtils.i("Logo","Logo Length : "+length);

if(length<=CommonUtils.MAX_LOGO_SIZE){

selectedUri=uri;

tv_logo_instruction.setText("Select Finger Print.");

tv_logo_instruction.setTextColor(Color.BLACK);

tv_logo_instruction.setVisibility(View.GONE);

try {

Bitmap bitmap =
MediaStore.Images.Media.getBitmap(getContentResolver(), uri);

44
// Log.d(TAG, String.valueOf(bitmap));

45
bmSelected=bitmap;

iv_sign.setImageBitmap(bitmap);

} catch (Exception e) {

LogUtils.printException(e);

}else{

CommonUtils.showErrorToast(getResources().getString(R.string.select5mb),context);

} catch (Exception e) {

LogUtils.printException(e);

package com.example.secureatm.ui.activity;

import android.content.Context;

import android.content.Intent;

import android.content.SharedPreferences;

import android.content.pm.PackageManager;

import android.graphics.Bitmap;

import android.graphics.Color;

import android.net.Uri;

import android.os.Bundle;

import android.os.Handler;

46
import android.provider.MediaStore;

import android.support.annotation.NonNull;

import android.support.design.widget.TextInputLayout;

import android.support.v7.app.AppCompatActivity;

import android.text.Editable;

import android.text.TextWatcher;

import android.view.KeyEvent;

import android.view.MenuItem;

import android.view.View;

import android.widget.Button;

import android.widget.EditText;

import android.widget.ImageView;

import android.widget.TextView;

import com.example.secureatm.R;

import com.example.secureatm.model.UserData;

import com.example.secureatm.utils.CommonUtils;

import com.example.secureatm.utils.DatabaseUtils;

import com.example.secureatm.utils.FilePathUtils;

import com.example.secureatm.utils.LogUtils;

import com.example.secureatm.utils.PreferenceUtils;

47
import com.google.android.gms.tasks.OnFailureListener;

import com.google.android.gms.tasks.OnSuccessListener;

import com.google.firebase.database.DataSnapshot;

import com.google.firebase.database.DatabaseError;

import com.google.firebase.database.DatabaseReference;

import com.google.firebase.database.FirebaseDatabase;

import com.google.firebase.database.Query;

import com.google.firebase.database.ValueEventListener;

import com.google.firebase.storage.FirebaseStorage;

import com.google.firebase.storage.StorageReference;

import com.google.firebase.storage.UploadTask;

import java.io.File;

import butterknife.BindView;

import butterknife.ButterKnife;

public class RegistrationScreen extends AppCompatActivity

{ Context context;

SharedPreferences prefs;

@BindView(R.id.til_name)

TextInputLayout til_name;

@BindView(R.id.ed_name)

48
EditText ed_name;

@BindView(R.id.til_mobile)

TextInputLayout til_mobile;

@BindView(R.id.ed_mobile)

EditText ed_mobile;

@BindView(R.id.til_password)

TextInputLayout til_password;

@BindView(R.id.ed_password)

EditText ed_password;

@BindView(R.id.til_id)

TextInputLayout til_id;

@BindView(R.id.ed_id)

EditText ed_id;

@BindView(R.id.btn_register)

Button btnRegister;

@BindView(R.id.iv_sign)

ImageView iv_sign;

@BindView(R.id.tv_logo_instruction)

TextView tv_logo_instruction;

49
FirebaseDatabase database;

int isMobileNumberAvailable=0;

int isAccountAvailable=0;

Handler handler=new Handler();

long createdTime=0;

FirebaseStorage storage;

Uri selectedUri;

boolean isUploading=false;

int REQUEST_ID_STORAGE_PERMISSIONS=1;

public static final int PICK_IMAGE = 1;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_registration_screen);

try{

ButterKnife.bind(this);

getSupportActionBar().setDisplayHomeAsUpEnabled(true);

context=this;

prefs=getSharedPreferences(PreferenceUtils.PREF_NAME,MODE_PRIVATE);

database = FirebaseDatabase.getInstance();

50
storage= FirebaseStorage.getInstance();

getSupportActionBar().setTitle(getResources().getString(R.string.sign_up));

btnRegister.setText(getResources().getString(R.string.sign_up));

btnRegister.setOnClickListener(new View.OnClickListener()

{ @Override

public void onClick(View view)

{ try{

String strId = ed_id.getText().toString().trim();

String strName = ed_name.getText().toString().trim();

// String strCountryCode =

ed_countrycode.getText().toString().trim(); String strMobile =

ed_mobile.getText().toString().trim();

String strPassword = ed_password.getText().toString().trim();

if (selectedUri!
=null&&strId.length()==10&&isAccountAvailable==0&&strName.length()
> 0 && strMobile.length() > 0&&isMobileNumberAvailable==0 &&
strMobile.length()==10
&&strPassword.length()>0&&CommonUtils.isValidPassword(strPassword)) {

uploadSign(strId,strName,strMobile,strPassword);

} else {

if(selectedUri==null){

49
tv_logo_instruction.setVisibility(View.VISIBLE);

tv_logo_instruction.setText("Select Finger Print.");

tv_logo_instruction.setTextColor(Color.RED);

if (strName.length() == 0) {

til_name.setError(getResources().getString(R.string.empty_validation_field));

if (strId.length() != 10) {

til_id.setError(getResources().getString(R.string.id_validation_field));

}else if(isAccountAvailable==1){

til_id.setError(getResources().getString(R.string.alreadyExist));

if (strMobile.length() == 0) {

il_mobile.setError(getResources().getString(R.string.empty_validation_field));

}else if(strMobile.length()!=10 ){

til_mobile.setError(getResources().getString(R.string.valid_mobile));

}else if(isMobileNumberAvailable==1){

til_mobile.setError(getResources().getString(R.string.mobile_already_exist));

if (strPassword.length() == 0) {
til_password.setError(getResources().getString(R.string.empty_validation_field));

50
}else if(!CommonUtils.isValidPassword(strPassword)){

til_password.setError(getResources().getString(R.string.valid_password_error));

}catch (Exception e){

LogUtils.printException(e);

iv_sign.setOnClickListener(new View.OnClickListener()

{ @Override

public void onClick(View view) {

try{

boolean isGranted =
CommonUtils.isStoragePermissionGranted(context,
REQUEST_ID_STORAGE_PERMISSIONS);

if (isGranted) {

Intent intent = new Intent();

intent.setType("image/*");

intent.setAction(Intent.ACTION_GET_CONTENT);

startActivityForResult(Intent.createChooser(intent, "Select Finger


Print"), PICK_IMAGE);

}catch (Exception e){

51
LogUtils.printException(e);

ed_mobile.addTextChangedListener(new TextWatcher()

@Override

public void beforeTextChanged(CharSequence charSequence, int i, int i1, int


i2) {

@Override

public void onTextChanged(CharSequence charSequence, int i, int i1, int i2)

{ if(CommonUtils.isValid(ed_mobile)){

til_mobile.setError(null);

handler.removeCallbacks(runnableMobile);

handler.postDelayed(runnableMobile,CommonUtils.EDITBOX_DELAY);

@Override

public void afterTextChanged(Editable editable) {

});

ed_id.addTextChangedListener(new TextWatcher() {

@Override

public void beforeTextChanged(CharSequence charSequence, int i, int i1, int


i2) {

52
@Override

public void onTextChanged(CharSequence charSequence, int i, int i1, int i2)

{ if(CommonUtils.isValid(ed_id)){

til_id.setError(null);

handler.removeCallbacks(runnableAccountId);

handler.postDelayed(runnableAccountId,CommonUtils.EDITBOX_DELAY);

@Override

public void afterTextChanged(Editable editable) {

CommonUtils.initTextChangeEvent(ed_name,til_name);

// CommonUtils.initTextChangeEvent(ed_countrycode,til_countrycode);

CommonUtils.initTextChangeEvent(ed_password,til_password);

}catch (Exception e){

LogUtils.printException(e);

Runnable runnableMobile=new Runnable()

{ @Override

public void run()

{ try{

String strMobile=ed_mobile.getText().toString().trim();

if(CommonUtils.isValidMobile(strMobile)){

53
checkMobileNumberExist();

}else{

til_mobile.setError(getResources().getString(R.string.valid_mobile));

}catch (Exception e){

LogUtils.printException(e);

Runnable runnableAccountId=new Runnable()

{ @Override

public void run()

{ try{

String strId=ed_id.getText().toString().trim();

if(strId.length()==10){

checkAccountIdExist();

}else{

til_id.setError(getResources().getString(R.string.id_validation_field));

}catch (Exception e){

54
LogUtils.printException(e);

private void checkMobileNumberExist(){

try {

final String strMobile=ed_mobile.getText().toString().trim();

DatabaseReference myRef = database.getReference(DatabaseUtils.TBL_USER);

isMobileNumberAvailable=0;

Query query=myRef.orderByChild("mobile").equalTo(strMobile);

query.addListenerForSingleValueEvent(new ValueEventListener()

@Override

public void onDataChange(DataSnapshot dataSnapshot) {

// CommonUtils.hideProgress();

if (dataSnapshot.exists()) {

// dataSnapshot is the "issue" node with all children with id

0 for (DataSnapshot issue : dataSnapshot.getChildren()) {

UserData bd = issue.getValue(UserData.class);

if(bd!=null){

55
if(bd.getMobile()!=null&&bd.getMobile().equals(strMobile)){

56
isMobileNumberAvailable=1;

il_mobile.setError(getResources().getString(R.string.mobile_already_exist));

}else{

}else{

}else{ @

Override

public void onCancelled(DatabaseError databaseError) {

});

} catch (Exception e) {

LogUtils.printException(e);

private void checkAccountIdExist()

{ try {

final String strAccountId=ed_id.getText().toString().trim();

DatabaseReference myRef = database.getReference(DatabaseUtils.TBL_USER);

56
isAccountAvailable=0;

Query query=myRef.orderByChild("account").equalTo(strAccountId);

query.addListenerForSingleValueEvent(new ValueEventListener() {

@Override

public void onDataChange(DataSnapshot dataSnapshot) {

// CommonUtils.hideProgress();

if (dataSnapshot.exists()) {

// dataSnapshot is the "issue" node with all children with id

0 for (DataSnapshot issue : dataSnapshot.getChildren()) {

UserData bd = issue.getValue(UserData.class);

if(bd!=null){ if(bd.getAccount()!

=null&&bd.getAccount().equals(strAccountId)){

isAccountAvailable=1;

til_id.setError(getResources().getString(R.string.alreadyExist));

}else{

}else{

}else{

57
@Override

public void onCancelled(DatabaseError databaseError) {

} catch (Exception e) {

LogUtils.printException(e);

@Override

public boolean onOptionsItemSelected(MenuItem item)

{ switch (item.getItemId()) {

// Respond to the action bar's Up/Home button

case android.R.id.home:

goBack();

return true;

return super.onOptionsItemSelected(item);

/**

* To handle back event

*/

private void goBack()

{ try{

58
finish();

}catch (Exception e){

LogUtils.printException(e);

@Override

public boolean onKeyDown(int keyCode, KeyEvent event)

{ try{

if (keyCode == KeyEvent.KEYCODE_BACK)

{ goBack();

return true;

}catch (Exception e){

LogUtils.printException(e);

return super.onKeyDown(keyCode, event);

@Override

protected void onPause()

{ super.onPause();

59
@Override

protected void onResume()

{ super.onResume();

@Override

public void onRequestPermissionsResult(int requestCode, String[] permissions, int[]


grantResults) {

super.onRequestPermissionsResult(requestCode, permissions,

grantResults); try{

if(requestCode==REQUEST_ID_STORAGE_PERMISSIONS&&grantResults[0]==
PackageManager.PERMISSION_GRANTED){

LogUtils.i("permission","onRequestPermissionsResult permisssion
granted... permission : "+permissions.toString()+" result : "+grantResults.toString());

Intent intent = new Intent();

intent.setType("image/*");

intent.setAction(Intent.ACTION_GET_CONTENT);

startActivityForResult(Intent.createChooser(intent, "Select Finger Print"),


PICK_IMAGE);

}catch (Exception e){

LogUtils.printException(e);

private void uploadSign(final String strId, final String strName, final String strMobile,
final String strPwd){

60
try{

// Uri file = Uri.fromFile(new

File("path/to/images/rivers.jpg")); isUploading=true;

CommonUtils.showProgress(context);

StorageReference ref=storage.getReference();

StorageReference riversRef =
ref.child("FingerPrint/"+strMobile+"/images/"+selectedUri.getLastPathSegment());

UploadTask uploadTask = riversRef.putFile(selectedUri);

uploadTask.addOnFailureListener(new OnFailureListener() {

@Override

public void onFailure(@NonNull Exception exception) {

// Handle unsuccessful

uploads isUploading=false;

CommonUtils.hideProgress();

LogUtils.i("Upload","Upload COmpany Logo Eception :


"+exception.getMessage());

}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>()
{

@Override

public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {

isUploading=false;
61
CommonUtils.hideProgress();

LogUtils.i("Upload","Upload COmpany Logo :


"+taskSnapshot.getDownloadUrl());

registerRequest(strId,strName,strMobile,
strPwd,taskSnapshot.getDownloadUrl().toString());

// taskSnapshot.getMetadata() contains file metadata such as size, content-


type, etc.

// ...

});

}catch (Exception e){

LogUtils.printException(e);

/**

* This method is used to send user registration request

*/

private void registerRequest(final String strId, String strName, final String strMobile,
String strPwd, String fingerPath){

try {

62
DatabaseReference myRef =

database.getReference(DatabaseUtils.TBL_USER); String

id=myRef.push().getKey();

final long modifiedTime= System.currentTimeMillis();

if(createdTime==0){

createdTime=modifiedTime;

String strFCMToken=prefs.getString(PreferenceUtils.FCM_TOKEN,null);

UserData bd=new
UserData(id,strId,strName,strMobile,strPwd,fingerPath,strFCMToken,0,"",createdTime,
modifiedTime);

CommonUtils.showProgress(context);

myRef.child(id).setValue(bd).addOnSuccessListener(new
OnSuccessListener<Void>() {

@Override

public void onSuccess(Void aVoid) {

CommonUtils.hideProgress();

CommonUtils.showSuccessToast(getResources().getString(R.string.saveSuccess),context
);

goBack();
63
}).addOnFailureListener(new OnFailureListener()

{ @Override

public void onFailure(@NonNull Exception e)

{ CommonUtils.hideProgress();

}catch (Exception e){

LogUtils.printException(e);

@Override

public void onActivityResult(int requestCode, int resultCode, Intent

data) try {

if (requestCode == PICK_IMAGE && resultCode == RESULT_OK && data !


= null && data.getData() != null) {

Uri uri = data.getData();

String path= FilePathUtils.getPath(context,uri);

LogUtils.i("Logo","Logo Uri : "+path);

File file=new

File(path);

if(file.exists()){

64
LogUtils.i("Logo","Logo : "+file.getAbsolutePath());

long length=file.length();

LogUtils.i("Logo","Logo Length : "+length);

if(length<=CommonUtils.MAX_LOGO_SIZE){

selectedUri=uri;

tv_logo_instruction.setText("Select Finger Print.");

tv_logo_instruction.setTextColor(Color.BLACK);

tv_logo_instruction.setVisibility(View.GONE);

try {

Bitmap bitmap =
MediaStore.Images.Media.getBitmap(getContentResolver(), uri);

// Log.d(TAG,

String.valueOf(bitmap));

iv_sign.setImageBitmap(bitmap);

} catch (Exception e) {

LogUtils.printException(e);

}else{ CommonUtils.showErrorToast(getResources().getString(R.string.select5mb),con
text);
65
} catch (Exception e) {

LogUtils.printException(e);

package com.example.secureatm.ui.activity;

import android.content.Context;

import android.content.Intent;

import android.content.SharedPreferences;

import android.os.Handler;

import android.support.annotation.NonNull;

import android.support.design.widget.TextInputEditText;

import android.support.design.widget.TextInputLayout;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.view.MenuItem;

import android.view.View;

import android.widget.Button;

import android.widget.TextView;

import com.example.secureatm.R;

66
import com.example.secureatm.model.TransactionData;

import com.example.secureatm.model.UserData;

import com.example.secureatm.utils.CommonUtils;

import com.example.secureatm.utils.DatabaseUtils;

import com.example.secureatm.utils.LogUtils;

import com.example.secureatm.utils.PreferenceUtils;

import com.google.android.gms.tasks.OnFailureListener;

import com.google.android.gms.tasks.OnSuccessListener;

import com.google.firebase.database.DataSnapshot;

import com.google.firebase.database.DatabaseError;

import com.google.firebase.database.DatabaseReference;

import com.google.firebase.database.FirebaseDatabase;

import com.google.firebase.database.ValueEventListener;

import butterknife.BindView;

import butterknife.ButterKnife;

public class TransactionScreen extends AppCompatActivity

{ Context context;

SharedPreferences prefs;

@BindView(R.id.tv_amount)

TextView tv_amount;

67
@BindView(R.id.til_amount)

TextInputLayout til_amount;

@BindView(R.id.ed_amount)

TextInputEditText ed_amount;

@BindView(R.id.btn_deposit)

Button btn_deposit;

@BindView(R.id.btn_withdraw)

Button btn_withdraw;

FirebaseDatabase database;

Handler handler=new Handler();

long createdTime=0;

String strUserId;

int nAmount=0;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_transaction_screen);

try{

ButterKnife.bind(this);

getSupportActionBar().setTitle("Account");

68
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

context=this;

prefs=getSharedPreferences(PreferenceUtils.PREF_NAME,MODE_PRIVATE);

strUserId=prefs.getString(PreferenceUtils.USER_ID,null);

database = FirebaseDatabase.getInstance();

getEditDetails(strUserId);

btn_deposit.setOnClickListener(new View.OnClickListener()

{ @Override

public void onClick(View view) {

String strAmount=ed_amount.getText().toString().trim();

int nVal=0;

if(strAmount.length()>0){

nVal= Integer.parseInt(strAmount);

if(nVal>0){

TransactionData td=new TransactionData(1,nVal);

updateTransactionData(td);

}else{

til_amount.setError("Enter valid amount.");

btn_withdraw.setOnClickListener(new View.OnClickListener()

69
{

70
@Override

public void onClick(View view) {

String strAmount=ed_amount.getText().toString().trim();

int nVal=0;

if(strAmount.length()>0){

nVal= Integer.parseInt(strAmount);

if(nVal>0){

TransactionData td=new

TransactionData(2,nVal);

updateTransactionData(td);

}else{

til_amount.setError("Enter valid amount.");

}catch (Exception e){

LogUtils.printException(e);

private void updateTransactionData(TransactionData data)

{ try {

DatabaseReference myRef =
database.getReference(DatabaseUtils.TBL_TRANSACTION);

CommonUtils.showProgress(context);

myRef.child(strUserId).setValue(data).addOnSuccessListener(new
OnSuccessListener<Void>() {
71
@Override

public void onSuccess(Void aVoid)

{ try{

CommonUtils.hideProgress();

CommonUtils.showSuccessToast("Check Transaction Status


on ATM!",context);

handler.postDelayed(new Runnable()

{ @Override

public void run()

{ goBack();

},2000);

}catch (Exception e){

LogUtils.printException(e);

}).addOnFailureListener(new OnFailureListener()

{ @Override

public void onFailure(@NonNull Exception e)

{ CommonUtils.hideProgress();

}catch (Exception e){

LogUtils.printException(e);

private void getEditDetails(String strUserID){

72
myRef =

database.getReference(DatabaseUtils.TBL_USER).child(strUserID);

CommonUtils.showProgress(context);

myRef.addValueEventListener(new ValueEventListener() {

boolean isFirst=true;

@Override

public void onDataChange(DataSnapshot dataSnapshot) {

try {

CommonUtils.hideProgress();

UserData data = dataSnapshot.getValue(UserData.class);

if (data != null)

{ if (isFirst) {

tv_amount.setText("Rs." + data.getAmount());

nAmount = data.getAmount();

} else {

if (data.getStatus() == 0) {

CommonUtils.showErrorToast("Session Closed!",

context); goBack();

if (isFirst) {

73
isFirst =

false;

74
handler.postDelayed(runnableBack, 60000 * 3);

}catch (Exception e){

LogUtils.printException(e);

@Override

public void onCancelled(DatabaseError error)

{ CommonUtils.hideProgress();

// Failed to read value

LogUtils.e("DBError", "Error.

....................................................")

}catch (Exception e){

LogUtils.printException(e);

Runnable runnableBack =new Runnable()

{ @Override

public void run()

{ goBack();

@Override

public boolean onOptionsItemSelected(MenuItem item)

{ switch (item.getItemId()) {

75
// Respond to the action bar's Up/Home button

case android.R.id.home:

76
goBack();

return true;

return super.onOptionsItemSelected(item);

@Override

protected void onDestroy()

{ super.onDestroy();

try{

handler.removeCallbacks(runnableBack);

}catch (Exception e){

LogUtils.printException(e);

/**

* To handle back event

*/

private void goBack()

{ try{

CommonUtils.goNextScreen(TransactionScreen.this,LoginScreen.class);

finish();

}catch (Exception e){

LogUtils.printException(e);

74
Screen Shot

75
76
77
78
79
80
CHAPTER 8
CONCLUSION AND FUTURE
WORK
CONCLUSION AND FUTURE WORK

Conclusion

The system also contains the original verifying methods which was inputting
owner's password which is send by the controller. The security features were enhanced
largely for the stability and reliability of owner recognition. The whole system was built
on the fingerprint technology which makes the system more safe, reliable and easy to use.
As we know that fingerprint are the most acceptable biometrics all over the world in
identifying a person. Some government in the world are still implementing fingerprints
technique to identify their citizens and the criminal from the scene of crimes in forensic
work.

81
Future Work

The future of ATM transformation is rooted in creating smarter ATMs that


offer application-rich functionality designed around the customer and his/her
needs. Polish bank Idea Bank recently introduced a literally “mobile
ATM” – a car with a built-in cash deposit machine that can come to you
within 30 minutes. Within the ATM platform itself, banks are starting to
explore integrating video teller functionality where customers can stand at a
kiosk and speak with a financial rep at a call centre via video conference.
Biometric scanning will allow for better security. Tablet-enabled ATMs will
allow untethered tellers to roam the branch to interact with customers freely
and directly. In an increasingly inter-connected environment, ATMs will
also become more internet-enabled and app-oriented, opening up a vast array
of potential new services. For example, consumers may soon be able to walk
up to an ATM and instantly get a loan or overdrafts based on their credit
scores. A more app-oriented interface will allow banks to not only offer
banking services to their clients via the ATM but also to purchase airline
tickets, pay bills, and more.

82

You might also like