You are on page 1of 26

Basantika Institute of Engineering & Technology

(Polytechnic)

ANDROID APP DEVELOPMENT


NAME OF THE APP - EXAM PREP
A MAJOR PROJECT REPORT

Submitted in Partial fulfilment for the degree of Diploma in Computer


Science and Technology

Basantika Institute of Engineering


& Technology (Polytechnic)

PO. Ganpur PS Md. Bazar,


Dt. Birbhum West Bengal,India, PIN –
731216

Under the guidance of


Mr. Anirban Dutta
Submitted by
Md Shoaib Akhtar Ansari
Debaditya Shome
Milan Mondal
Subhadeep Mondal
Pritam Mondal
Souvik Ghosh
Puja Sharma
Masud Alam
Maklu Hembrom
Laxmishree Banerjee
Sanket Manna
Sadhan Kr Maiti
CERTIFICATE
This is to certify that the project work entitled “ANDROID APP
DEVELOPMENT BY USING JAVA” was submitted by students of C.S.T dept.
for the fulfillment of the course of Diploma in COMPUTER SCIENCE AND
TECHNOLOGY of BASANTIKA INSTITUTE OF ENGINEERING AND
TECHNOLOGY(POLYTECHNIC).

These candidates have completed the total parameters and requirements of


the entire project.

The work undertaken in this dissertation is a result of candidates own


effort.The result embodied in this dissertation has not been submitted for
any other degree and does not form a part of any other course undergone
by the candidate.

Signature of Project Supervisor Signature of HOD


Mr. Anirban Dutta MR. ARINDAM DUTTA
Department of Computer Science & technology
Acknowledgement

I would like to express my sincere gratitude to Mr. Anirban Dutta


as of the department of Computer Science and Technology whose
role as project guide was invaluable for the project. I am
extremely thankful for the keen interest he took in advising me,
for the books and reference materials provided for the moral
support extended to me.

Last but not the least I convey my gratitude to all the teachers for
providing me the technical skill that will always remain as my asset
and to all non- teaching staffs for the cordial support they offered.

Thank you
TABLE OF CONTENTS

1.Introduction

2.Basic function

3.Proposed system

a. Description

b. System requirements

4.System Design

5.Source code

6. Application.

7.Testing

8.Future scope of project


INTRODUCTION

Introducing "AndroidExamPrep” Your Comprehensive Android


Exam Preparation Companion"

Are you determined to excel in your upcoming Android exams


but find yourself in need of a reliable study partner? Look no
further! Welcome to AndroidExamPrep, the ultimate app
designed to optimize your Android exam preparation and help
you achieve outstanding results.

AndroidExamPrep is a powerful and comprehensive study


companion crafted specifically for individuals aspiring to master
Android development. Whether you're a student, a professional
seeking certification, or anyone passionate about Android, this
app is your key to unlocking success.
BASIC FUNCTIONS
Add exam item

For adding subject name or subject topic and number it.

Test Yourself

For showing which subject or subject topic is not complete.

More Button

For Showing more options in app.

Change exam date

For set or change exam date.

Number of Questions

For Adding number of subjects or questions.

Import Data Add Exam item


Change Exam date

For importing data.


Test Yourself

More Button

Number Of Questions

Import Data
PROPOSED SYSTEM
The following documentation is a project the “Name of the term paper allotted”. It is a detailed
summary of all the drawbacks of the old system and how the new proposed system overcomes these
shortcomings. The new system takes into account the various factors while designing a new system.
It keeps into the account the Economical bandwidth available for the new system. The foremost thing
that is taken care of is the Need and Requirements of the User.

DESCRIPTION

Before developing software we keep following things in mind that we can develop powerful and quality
software

PROBLEM STATEMENT

Problem statement was to design a module:

Which is user friendly


Which will restrict the user from accessing other user’s data.

Which will help user in viewing his data and privileges.


Which will help the administrator to handle all the changes.

FUNCTIONS TO BE PROVIDED:

The system will be user friendly and completely menu driven so that the users shall have no problem in
using all options.

The system will be efficient and fast in response.


The system will be customized according to needs.

SYSTEM REQUIRMENTS

Operating system: Android 9 pie

Language: Java

Software: Android Studio


SYSTEM DESIGN
Then we began with the design phase of the system. System design is a
solution, a “HOW TO” approach to the creation of a new system. It translates
system requirements into ways by which they can be made operational. It is
a translational from a user oriented document to a document oriented
programmers. For that, it provides the understanding and procedural details
necessary for the implementation. Here we use Flowchart to supplement the
working of the new system. The system thus made should be reliable,
durable and above all should have least possible maintenance costs. It
should overcome all the drawbacks of the Old existing system and most
important of all meet the user requirements.
CONTROL FLOW CHART OF THE EXAMPREP APP BY
USING ANROID STUDIO
DATA FLOW CHART OF THE EXAMPREP APP BY
USING ANROID STUDIO
SOURCE CODE:-
MainActivity.java
package remcv.com.github.examprep;

import android.app.DatePickerDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.DatePicker;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.google.gson.Gson;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.time.LocalDate;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import remcv.com.github.examprep.controller.DatabaseCrud;
import remcv.com.github.examprep.controller.DatabaseHandler;
import remcv.com.github.examprep.model.ExamItem;
import remcv.com.github.examprep.utils.TableConstants;
import remcv.com.github.examprep.utils.Utils;
import remcv.com.github.examprep.view.DialogNumberOfSubject;
import remcv.com.github.examprep.view.ExamItemAdapter;
import remcv.com.github.examprep.view.MyDialogDatePicker;

public class MainActivity extends AppCompatActivity implements TableConstants,


DialogNumberOfSubject.DialogNumberOfSubjectListener, DatePickerDialog.OnDateSetListener
{
// fields - data
private File sourceFile;
private DatabaseCrud<ExamItem> databaseHandler;
private ExamItemAdapter adapter;
private int numberOfSubjectsToTest;
private int solvedNumberOfSubjects;
private LocalDate examDate;

// fields - static final


private static final String TAG = "ExamPrep";
private static final int ADD_ITEM_REQUEST_CODE = 1;
private static final int UPDATE_DELETE_ITEM_REQUEST_CODE = 2;
private static final int UPLOAD_TSV_REQUEST_CODE = 3;
public static final String SHARED_PREFS = "mySharedPrefs";
public static final String NUMBER_OF_SUBJECTS = "numberOfSubjects";
public static final String EXAM_YEAR = "examYear";
public static final String EXAM_MONTH = "examMonth";
public static final String EXAM_DAY = "examDay";

// fields - layout
private TextView countdown_TV;
private TextView numberOfSubjects_TV;
private TextView totalNumberOfSubjects_TV;
private ListView problems_LV;

// methods - lifecycle
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// initialize data
initializeData();

// initiate layout
initializeLayout();

// ListView adapter
adapter = new ExamItemAdapter(databaseHandler.getList(), MainActivity.this);
problems_LV.setAdapter(adapter);

// handle events
problems_LV.setOnItemClickListener((parent, view, position, id) ->
onListViewItemClicked(position));
}

@Override
protected void onStop()
{
super.onStop();

// save database
databaseHandler.saveDb(sourceFile);
}

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

/*
1 - add item
2 - update OR delete
3 - import database from tsv file
*/

if (resultCode == RESULT_OK)
{
switch (requestCode)
{
case ADD_ITEM_REQUEST_CODE:
onAddItemReturn(data);
break;
case UPDATE_DELETE_ITEM_REQUEST_CODE:
onUpdateDeleteReturn(data);
break;
case UPLOAD_TSV_REQUEST_CODE:
onUploadReturn(data);
break;
}
}
Collections.sort(databaseHandler.getList());
adapter.notifyDataSetChanged();

updateData();
updateUI();
}

// methods - handle events


public void onListViewItemClicked(int position)
{
ExamItem examItem = databaseHandler.getList().get(position);

Intent intent = new Intent(MainActivity.this, UpdateDeleteItemActivity.class);


intent.putExtra(TableConstants.CATEGORY_NUMBER, examItem.getCategoryNumber());
intent.putExtra(TableConstants.PROBLEM, examItem.getProblem());
intent.putExtra(TableConstants.IS_DONE, examItem.getIsDone());
intent.putExtra(TableConstants.INDEX, position);

int requestCode = 2;
startActivityForResult(intent, requestCode);
}

@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item)
{
switch (item.getItemId())
{
case R.id.settingsMenu_itemAdd:
onAddButtonClicked();
break;
case R.id.settingsMenu_itemGenerateRandomList:
onGenerateRandomListOfSubjectsClicked();
break;
case R.id.settingsMenu_itemChangeExamDate:
onChangeExamDateMenuItemClicked();
break;
case R.id.settingsMenu_itemSetNoSubjectsInTest:
createAlertDialogNumberOfQuestions();
break;
case R.id.settingsMenu_itemImport:
onImportButtonClicked();
break;
}

return true;
}

public void onAddButtonClicked()


{
Intent addIntent = new Intent(MainActivity.this, AddExamItemActivity.class);
startActivityForResult(addIntent, ADD_ITEM_REQUEST_CODE);
}

public void onGenerateRandomListOfSubjectsClicked()


{
List<ExamItem> list = databaseHandler.getList().stream()
.filter(examItem -> !examItem.getIsDone())
.collect(Collectors.toList());

list = Utils.generateRandomSubjectList(numberOfSubjectsToTest, list);

if (list == null)
{
Toast.makeText(this, "Not enough subjects or categories in your list",
Toast.LENGTH_SHORT).show();
}
else
{
// send the list to TestSubjectsActivity
Gson gson = new Gson();
String listJson = gson.toJson(list);

Intent toTestSubjectsActivityIntent = new Intent(MainActivity.this,


TestSubjectsActivity.class);
toTestSubjectsActivityIntent.putExtra(TableConstants.RANDOM_LIST,
listJson);

startActivity(toTestSubjectsActivityIntent);
}
}

public void onImportButtonClicked()


{
// create Intent to open an external csv file
Intent getCsvIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
getCsvIntent.addCategory(Intent.CATEGORY_OPENABLE);
getCsvIntent.setType("text/tab-separated-values");

startActivityForResult(getCsvIntent, UPLOAD_TSV_REQUEST_CODE);
}

// methods - data
public void initializeData()
{
// instantiate a DatabaseCrud implementation
databaseHandler = new DatabaseHandler(MainActivity.this);

// instantiate the database File object by accessing the Android device app
storage
sourceFile = new File(getApplicationContext().getFilesDir(),
databaseHandler.getDatabasePath());

// create the .csv file if it doesn't exist (for first time users)
try
{
sourceFile.createNewFile();
}
catch (IOException e)
{
Log.e(TAG, "initializeData() " + e.getMessage());
}

// load the database from storage


databaseHandler.loadDb(sourceFile);
Collections.sort(databaseHandler.getList());

// calculate solvedNumberOfSubjects
solvedNumberOfSubjects = (int) databaseHandler.getList().stream()
.filter(ExamItem::getIsDone)
.count();

// load the number of subjects (default value is 5)


numberOfSubjectsToTest = getSharedPreferences(SHARED_PREFS,
MODE_PRIVATE).getInt(NUMBER_OF_SUBJECTS, 5);

// load exam date


int year = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE).getInt(EXAM_YEAR,
0);
int month = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE).getInt(EXAM_MONTH,
0);
int dayOfMonth = getSharedPreferences(SHARED_PREFS,
MODE_PRIVATE).getInt(EXAM_DAY, 0);
if (year == 0)
{
// default value of exam date is 30 days from the current day
examDate = LocalDate.now().plusDays(30);
}
else
{
examDate = LocalDate.of(year, month, dayOfMonth);
}
}

public void updateData()


{
solvedNumberOfSubjects = (int) databaseHandler.getList().stream()
.filter(ExamItem::getIsDone)
.count();
}

public void onAddItemReturn(Intent data)


{
int categoryNumber = data.getIntExtra(TableConstants.CATEGORY_NUMBER, 0);
String problem = data.getStringExtra(TableConstants.PROBLEM);
boolean isDone = data.getBooleanExtra(TableConstants.IS_DONE, false);

ExamItem newExamItem = new ExamItem(categoryNumber, problem, isDone);


databaseHandler.getList().add(newExamItem);

Toast.makeText(this, "Exam item added", Toast.LENGTH_SHORT).show();


}

public void onUpdateDeleteReturn(Intent data)


{
// get metadata
String buttonName = data.getStringExtra(TableConstants.BUTTON_NAME);
int index = data.getIntExtra(TableConstants.INDEX, 0);

if (buttonName.equals("deleteButton"))
{
onDeleteReturn(index);
}
else // buttonName.equals("updateButton")
{
onUpdateReturn(index, data);
}
}

public void onDeleteReturn(int index)


{
databaseHandler.getList().remove(index);
Toast.makeText(MainActivity.this, "Item deleted", Toast.LENGTH_SHORT).show();
}

public void onUpdateReturn(int index, Intent data)


{
// gather data
int categoryNumber = data.getIntExtra(TableConstants.CATEGORY_NUMBER, -1);
String problem = data.getStringExtra(TableConstants.PROBLEM);
boolean isDone = data.getBooleanExtra(TableConstants.IS_DONE, false);

// create ExamItem and update it in list


databaseHandler.getList().set(index, new ExamItem(categoryNumber, problem,
isDone));
}

public void onDeleteItem(int index)


{
databaseHandler.getList().remove(index);
Toast.makeText(this, "Exam item deleted", Toast.LENGTH_SHORT).show();
}

public void onUploadReturn(Intent data)


{
Uri csvUri = data.getData();
InputStream inputStream = null;

try
{
inputStream = getContentResolver().openInputStream(csvUri);
BufferedReader reader = new BufferedReader(new
InputStreamReader(inputStream));

// if no exception was thrown until here, then clear the old list
databaseHandler.getList().clear();

String line;
String[] lineArray;

while ((line = reader.readLine()) != null)


{
lineArray = line.split("\t", 3);
int categoryNumber = Integer.parseInt(lineArray[0]);
String problem = lineArray[1];
boolean isDone = Boolean.parseBoolean(lineArray[2]);

ExamItem item = new ExamItem(categoryNumber, problem, isDone);


databaseHandler.getList().add(item);
}

reader.close();
inputStream.close();

// update data and UI


solvedNumberOfSubjects = (int) databaseHandler.getList().stream()
.filter(ExamItem::getIsDone)
.count();
totalNumberOfSubjects_TV.setText(String.format("Subjects (%d)",
databaseHandler.getList().size()));
}
catch (Exception e)
{
Log.d(TAG, "onUploadReturn: exception " + e.getMessage());
Toast.makeText(this, "File loading failed", Toast.LENGTH_SHORT).show();
}
}

// methods layout
public void initializeLayout()
{
countdown_TV = findViewById(R.id.countdownTextView_AM);
numberOfSubjects_TV = findViewById(R.id.numberOfSubjects_AM);
problems_LV = findViewById(R.id.problemsListView_AM);
totalNumberOfSubjects_TV = findViewById(R.id.totalNumberOfSubjects_AM);

// put data in layout


updateUI();
}

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.settings_menu, menu);
return true;
}
public void updateUI()
{
numberOfSubjects_TV.setText(String.valueOf(numberOfSubjectsToTest));
totalNumberOfSubjects_TV.setText(String.format("Subjects (%d solved / %d)",
solvedNumberOfSubjects, databaseHandler.getList().size()));
countdown_TV.setText(Utils.calculateDaysLeft(examDate));
}

// methods - alert dialog


public void createAlertDialogNumberOfQuestions()
{
DialogNumberOfSubject dialog = new DialogNumberOfSubject();
dialog.show(getSupportFragmentManager(), "DialogNumberOfSubject");
}

public void onChangeExamDateMenuItemClicked()


{
MyDialogDatePicker dp = new MyDialogDatePicker();
dp.show(getSupportFragmentManager(), "MyDialogDatePicker");
}

@Override
public void getNumber(int number)
{
numberOfSubjectsToTest = number;

// save the new value to SharedPreferences


SharedPreferences sp = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.putInt(NUMBER_OF_SUBJECTS, numberOfSubjectsToTest);
editor.apply();

// update UI
numberOfSubjects_TV.setText(String.valueOf(numberOfSubjectsToTest));
}

@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth)
{
examDate = LocalDate.of(year, month + 1, dayOfMonth);

// save new values to shared preferences


SharedPreferences sp = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.putInt(EXAM_YEAR, year);
editor.putInt(EXAM_MONTH, month + 1);
editor.putInt(EXAM_DAY, dayOfMonth);
editor.apply();

// update UI
updateUI();
}
}
DialogNumberOfSubject.java
package remcv.com.github.examprep.view;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatDialogFragment;

import java.text.BreakIterator;

import remcv.com.github.examprep.R;

public class DialogNumberOfSubject extends AppCompatDialogFragment


{
// fields
private DialogNumberOfSubjectListener dnoq;
private BreakIterator numberOfSubject_ET;
private int numberOfSubject;

// nested interface
public interface DialogNumberOfSubjectListener
{
void getNumber(int number);
}

// constructor
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState)
{
//

//
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

LayoutInflater inflater = getActivity().getLayoutInflater();


View view = inflater.inflate(R.layout.dialog_number_of_questions, null);
EditText numberOfQuestions_ET =
view.findViewById(R.id.numberOfQuestions_ET_DNQ);

builder.setView(view)
.setTitle("Number of Subject for Exam")
.setNegativeButton("cancel", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
dismiss();
}
})
.setPositiveButton("save", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
int numberOfQuestions =
Integer.parseInt(numberOfSubject_ET.getText().toString());
dnoq.getNumber(numberOfSubject);
}
});

return builder.create();
}

// methods
@Override
public void onAttach(@NonNull Context context)
{
super.onAttach(context);

try
{
dnoq = (DialogNumberOfSubjectListener) context;
}
catch (ClassCastException e)
{
throw new ClassCastException(context.toString() + " must implement
DialogNumberOfSubjectListener");
}
}
}

AddExamItemActivity.java
package remcv.com.github.examprep;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Button;
import android.widget.CheckBox;

import com.google.android.material.textfield.TextInputLayout;

import remcv.com.github.examprep.utils.TableConstants;
import remcv.com.github.examprep.utils.Utils;

public class AddExamItemActivity extends AppCompatActivity


{
// fields - data
public static final String TAG = "ExamPrep";

// fields - layout
private TextInputLayout categoryNumber_TIL;
private TextInputLayout problem_TIL;
private Button addItem_Button;
private CheckBox subjectIsSolved_CB;

// methods - lifecycle
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_exam_item);

// initialize data

// initialize layout
initializeLayout();

// handle button events


addItem_Button.setOnClickListener((v) -> onAddItemButtonClicked());
}

// methods - handle button clicks


public void onAddItemButtonClicked()
{
// check input data validity
if (Utils.isNumberValid(categoryNumber_TIL) &
Utils.isStringInputValid(problem_TIL))
{
int categoryNumber =
Integer.parseInt(categoryNumber_TIL.getEditText().getText().toString());
String problem = problem_TIL.getEditText().getText().toString();
boolean isDone = subjectIsSolved_CB.isChecked();

Log.d(TAG, "onAddItemButtonClicked: isDone before - " + isDone);

Intent intent = new Intent(AddExamItemActivity.this, MainActivity.class);


intent.putExtra(TableConstants.CATEGORY_NUMBER, categoryNumber);
intent.putExtra(TableConstants.PROBLEM, problem);
intent.putExtra(TableConstants.IS_DONE, isDone);

// set result to pass to MainActivity


setResult(RESULT_OK, intent);

// finish current activity without starting a new MainActivity


finish();
}
}

// methods - data
public void initializeData()
{
// TODO
}

// methods layout
public void initializeLayout()
{
categoryNumber_TIL = findViewById(R.id.categoryNumberTextInputLayout_AAEI);
problem_TIL = findViewById(R.id.problemTextInputLayout_AAEI);
addItem_Button = findViewById(R.id.addItemButton_AAEI);
subjectIsSolved_CB = findViewById(R.id.subjectSolvedCheckBox_AAEI);
}
}
TestSubjectsActivity.java
package remcv.com.github.examprep;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.TextView;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

import remcv.com.github.examprep.model.ExamItem;
import remcv.com.github.examprep.utils.TableConstants;
import remcv.com.github.examprep.utils.Utils;
import remcv.com.github.examprep.view.ExamItemAdapter;

public class TestSubjectsActivity extends AppCompatActivity implements TableConstants


{
// fields - layout
private TextView minutes_TV;
private ListView subjects_LV;

// fields - data
private List<ExamItem> examItems;
private ExamItemAdapter adapter;

// methods - life cycle


@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_subjects);

// initialize layout
initializeLayout();

// initialize data
initialDataSetup();

// update layout
updateLayout();
}

// methods - data
public void initialDataSetup()
{
// get list of Exam items
Intent getListIntent = getIntent();
String listStringJson =
getListIntent.getStringExtra(TableConstants.RANDOM_LIST);

Gson gson = new Gson();


Type type = new TypeToken<ArrayList<ExamItem>>() {}.getType();

examItems = gson.fromJson(listStringJson, type);

// set adapter
adapter = new ExamItemAdapter(examItems, TestSubjectsActivity.this);
}

// methods - layout
public void initializeLayout()
{
minutes_TV = findViewById(R.id.minutesTextView_ATS);
subjects_LV = findViewById(R.id.problemsListView_ATS);
}

public void updateLayout()


{
// minutes
String minutes = Utils.calculateMinutes(examItems.size());
minutes_TV.setText(minutes);

// put items in listView


subjects_LV.setAdapter(adapter);
}
}

UpdateDeleteItemActivity.java
package remcv.com.github.examprep;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.CheckBox;

import com.google.android.material.textfield.TextInputLayout;

import remcv.com.github.examprep.utils.TableConstants;
import remcv.com.github.examprep.utils.Utils;

public class UpdateDeleteItemActivity extends AppCompatActivity implements


TableConstants
{
// fields - data
private int indexOfItemInList;

// fields - layout
private TextInputLayout categoryNumber_til;
private TextInputLayout problem_til;
private Button updateButton;
private Button deleteButton;
private CheckBox subjectIsSolved_CB;

@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_update_delete_item);

// initialize layout
initializeLayout();

// initialize data
initializeData();

// handle events
deleteButton.setOnClickListener(v -> onDeleteButtonClicked());
updateButton.setOnClickListener(v -> onUpdateButtonClicked());
}

// methods - handle events


public void onDeleteButtonClicked()
{
// create intent
Intent intent = new Intent(UpdateDeleteItemActivity.this, MainActivity.class);
intent.putExtra(TableConstants.INDEX, indexOfItemInList);
intent.putExtra(TableConstants.BUTTON_NAME, "deleteButton");

// set the result code


setResult(RESULT_OK, intent);

// close activity
finish();
}

public void onUpdateButtonClicked()


{
// validate user input
if (Utils.isNumberValid(categoryNumber_til) &
Utils.isStringInputValid(problem_til))
{
// gather data
int categoryNumber =
Integer.parseInt(categoryNumber_til.getEditText().getText().toString());
String problem = problem_til.getEditText().getText().toString();
boolean isDone = subjectIsSolved_CB.isChecked();

// make Intent and put the data in extras


Intent intent = new Intent(UpdateDeleteItemActivity.this,
MainActivity.class);
intent.putExtra(TableConstants.CATEGORY_NUMBER, categoryNumber);
intent.putExtra(TableConstants.PROBLEM, problem);
intent.putExtra(TableConstants.IS_DONE, isDone);
intent.putExtra(TableConstants.INDEX, indexOfItemInList);
intent.putExtra(TableConstants.BUTTON_NAME, "updateButton");

// set result to pass to MainActivity


setResult(RESULT_OK, intent);

// finish current activity without starting a new MainActivity


finish();
}
}

// methods - data
public void initializeData()
{
Intent intent = getIntent();

int categoryNumber = intent.getIntExtra(TableConstants.CATEGORY_NUMBER, 0);


String problem = intent.getStringExtra(TableConstants.PROBLEM);
boolean isDone = intent.getBooleanExtra(TableConstants.IS_DONE, false);
indexOfItemInList = intent.getIntExtra(TableConstants.INDEX, 0);

categoryNumber_til.getEditText().setText(String.valueOf(categoryNumber));
problem_til.getEditText().setText(problem);
subjectIsSolved_CB.setChecked(isDone);
}

// methods - layout
public void initializeLayout()
{
categoryNumber_til = findViewById(R.id.categoryNumberTextInputLayout_AUDI);
problem_til = findViewById(R.id.problemTextInputLayout_AUDI);
updateButton = findViewById(R.id.updateItemButton_AUDI);
deleteButton = findViewById(R.id.deleteItemButton_AUDI);
subjectIsSolved_CB = findViewById(R.id.subjectSolvedCheckBox_AUDI);
}
}
APPLICATIONS
Early exam preparation provides several benefits as
it enables students to cover the syllabus on time, identify
their strengths and weaknesses, and practice efficiently. It
reduces stress and improves retention by allowing a better
pace of learning, and assists in managing time during the
actual exam .Exam prep apps can also help for easy
completion of syllabus without any hassle of completing it
within a very short time by alotting fixed time for each
subject .It also stops the stagnation of subjects with a lot of
syllabus left.
TESTING

Testing is the major control measure used during software development. Its
basic function is to detect errors in the software. During requirement analysis
and design, the output is a document that is usually textual and non- executable.
After the coding phase, computer programs are available that can be executed
for testing purpose. This implies that testing not only has to uncover errors
introduced during coding, but also errors introduced during previous phase.
Thus the goal of testing is to uncover the requirements, design and coding
errors in the programs. The Source code declared above for the program of
Scientific Calculator has been tested and it has been found that the above
source code is valid .The program involves many type of conversions. These
conversions has to be done carefully.

FUTURE SCOPE OF THE PROJECT

Our project will be able to implement in future after making some changes
and modifications as we make our project at a very low level. So the
modifications that can be done in our project are:
To make it screen touch so no need to touch key buttons and one more
change which can we made is to add snaps of the person who use it.We shall
further update the software with better features from time to time.

You might also like