fit tech app report
fit tech app report
I, Muskan Yadav, student of MCA 4th Semester in the department of Computer Science, Govt. college Sector 9
Gurugram, under University roll no. 23128410049, for the session 2023 - 2025, hereby declare that the project
report entitled “Fit Tech App” has been completed by me in 4th semester.
The matter embodied in this report has not been submitted earlier for the award of any degree or diploma to the
best of my knowledge and belief.
It is certified that Muskan Yadav student of MCA, under Gurugram University roll no. 23128410049
for the session 2023-2025, has completed the project report entitled “Fit Tech App” under my
supervision.
The project report is in my opinion worthy for the consideration for the award of Master in Computers
Applications in accordance with the rules and regulations of Gurugram University, Gurugram.
The satisfaction that accompanies the successful completion of any task would be incomplete without
mention of the people whose ceaseless cooperation made it possible, whose constant guidance and
encouragement crown all efforts with success. I own my regards to Ms. Venu, Head of Department -
Computer Science and the entire faculty of the department from where we have learnt the basics of
Computer Science and whose informal discussion and able guidance become light for us in the entire
duration of this work.
Next, I would like to express my profound sense of gratitude to Ms. Rakhi Soni Project Supervisor
for reviewing coding, advising suggestion, motivation and extended keen interest throughout my
project as well as report.
Muskan Yadav
TABLE OF CONTENTS
Chapter 1............................................................................................. .....................................6-10
Introduction of FIT-TECH....................................................................................................6
1.1 Purpose ......................................................................................................................... 8
1.2 Scope ............................................................................................................................ 9
1.3 Objective ....................................................................................................................... 10
Chapter 2 ............................................................................................................................ 11-14
Survey of technology............................................................................................................ 11
2.1 Android Studio .............................................................................................................. 11
2.1 Existing system of FIT-TECH ....................................................................................... 12
2.2 Proposed system of FIT-TECH ..................................................................................... 12
2.3 Requirement .................................................................................................................. 13-14
2.3.1 Software Requirement Specification ........................................................................... 13
2.3.2 Hardware Requirement Specification .......................................................................... 14
Chapter 3 ............................................................................................................................ 15-26
3.1 Working Module ........................................................................................................... 15
3.2 Data Dictionary ............................................................................................................. 16-17
3.3 Use case Diagram .......................................................................................................... 18-19
3.4 Class Diagram ............................................................................................................... 20-21
3.5 E-R diagram .................................................................................................................. 22-24
3.6 Activity Diagram ........................................................................................................... 25
3.7 Dataflow Diagram ........................................................................................................ 26
Chapter 4 ............................................................................................................................ 27-74
4.1 Phase Code .................................................................................................................... 27-70
4.2 Test Approach ............................................................................................................... 70-74
Chapter 5 ............................................................................................................................ 75-77
5.1 Result and Discussion .................................................................................................... 75-77
Chapter 6 ............................................................................................................................ 78-79
6.1 Conclusion and Future Work ......................................................................................... 78-79
Chapter 7 ............................................................................................................................ 80
7.1 Reference ...................................................................................................................... 80
5
Chapter 1 : Introduction
The main objective of the Gym Application is developed to override the problems prevailing in
the practicing manual system. This application is providing a system which is use to
maintaining their health care. It take care of all their fitness and also keeps the data of
everyday’s gym exercise. The purpose of the project is to build an application program to
reduce the time and money. We can easily get the list of all exercise and also we have complete
details for some particular fitness exercise. It can assist the user to concentrate on their fitness.
In Every corporation, whether it is big or small, has challenges to overcome and preside over
the information of trainer, gym, facility, time slot, fitness class. In all Gym Application
has different Gym needs, therefore we implement exclusive employee management
systems that are adapted to your managerial requirements
The project is completely built at administrative end and thus only the administrator is
guaranteed to access. The application is decreased as much as possible to escape errors while
entering the data. It also provide error message while entering worthless data.
To understanding the requirements and new generation capabilities we have chosen “Android
Studio” as front –end and “MYSQL lite” as back-end. Android Studio is the official combined
development environment for Google’s Android operating system, built on JetBrains IntelliJ
IDEA software and designed exactly for Android development. It is available for download on
Windows, macOS and Linux based operating systems.
MSQL- an Open-source relational database management system (RDBMS), also the most
popular one. SQLite: a relational database management system which is not client- server built.
It's doesn't need a server to setup and run.
Functionalities of GYM application are as follows:-
A Personalized experience:-When it’s about tracking the user activity and further assessing the
user’s fitness, the application needs to have user’s personal information like, age, height,
gender, and weight.
Integrate geolocation:-This characteristic allows the user to track his walking routes, and to
build them and record workouts.
6
Push notification system and reminder:-Anyone who is working out daily would never want
to miss a session. However, keeping up with the busy lives; sometimes it, does slips out of
our
mind. In such cases a push notification from the app can be very helpful to remind us of our
workout session.
Report generation :-
Balance Report
Trial Report
Upgrade Report
Access Control
Client Database Report
Calendar Report
7
1.2 Purpose
A health organization (also known as a fitness club, fitness center, health spa, and commonly
referred to as a gym) is a place that houses exercise equipment for the reason of physical
exercise.
8
1.2 SCOPE
It may help collect absolute executives in details. In a very small time, the collection will be
clear-cut, straightforward and accurate. It will help a person to know the management of
passed year effortlessly and vividly. It also helps in current all works relative to Gym
Website. It will be also make smaller the cost of collecting the management & collection
process will go on well.
Our project focus at business process automation, i.e. we have tried to computerize diverse
routes of Gym Website
In computer system the person has to fill the various forms & number forms
& number of copies of the forms can be easily generated at a time
In computer system, it is not necessary to create the manifest but we can directly
print it, which saves our time.
To help the staff in capturing the endeavour spent on their respective working areas.
To utilize resources in an efficient manner by increased their productivity through
automation.
The system produces types of information that can be used for various resolutions
It satisfy the user requirement
Be easy to understand by the user and Operator
Be easy to Operate
Have a good user interface
Be expandable
Delivered on schedule within the budget
9
1.3 OBJECTIVE:-
10
Chapter 2
Survey of Technology
2.1 Android Studio
The Android Studio IDE is able to download and use. It has a rich UI development
environment with templates to give new creator a opening pad into Android development.
Developers will find that Studio gives them the tools to build phone and tablet mixture as
well as arrival technology solution for Android.
Android Studio was stated on May 16, 2013 at the Google I/O conference. It was in early
approach preview stage starting from version 0.1 in May 2013, then entered beta stage
starting from version 0.8 which was released in June 2014. The first stable build was
launched in December 2014, starting from version 1.0. The current stable version is 3.2.1,
which was released in October 2018.
11
2.2 Existing system of Gym Application:
In the existing system the work are done manually but in proposed system we have to
computerize the work using this application
The aim of proposed system is to develop a system of improved facilities of the system. The
proposed system can overcome all the limitations of the existing system. The system provides
security and reduces the manual work.
1. Security of data.
2. Better service.
3. Proper control of the higher officials.
4. Minimize manual data entry.
5. Minimum time needed for the various processing.
6. Greater efficiency.
7. Ensure data accuracy’s.
8. Minimum time required.
9. User friendliness and interactive.
12
2.4 Requirement Analysis
Language Java
Database SQLite
JSON
Database driver
13
2.4.2 Hardware Requirement Specification
14
CHAPTER 3
System Design
The main purpose of developing this module is to manage the all enquiry will be managed by
admin and user be able to see the enquiry.
15
3.2 Data Dictionary
This is usually represented as the data about. It is also termed as metadata some times which
give the all data about the data stored in database .it defines each data term encountered
during the inspection and design of new system. Data elements can report all the files or the
operation.
=equivalent to
+ and
[] either/or
() optional entry
Following some vital symbols in the data dictionary which defines the construction of data
dictionary entries:
1. Words should be defined to understand for what they need and not the variable need
by which they may be report in the program.
2. Each word must be different but We cannot have two definition of the same client at
time
3. Aliases or synonyms are permit when two or more enters show the same meaning for
example a vendor number may also be called as customer number
4. A self-defining word should not be decay it means that the reduction of any
information in to subpart should not be decomposed it means that the reduction of any
information in to subpart should be done only if it is really required that it is not easy
to understand directly
5. Data dictionary comprise information such as the Number of records save in the file,
of the frequency of a process will run, security factor like pass word which user must
enter to get excess to in the information
16
TABLE 4.2. 1 - PROFILE DETAILS
17
3.3 Use case Diagram
A use case diagram at its simple to be a representation of a user's interaction with the all
system that shows the relationship between the user and the different use cases in which the
user is involved. A use case diagram can easy to identify the different types of users of in
system and the different use cases and will often be any other types of diagrams as well.
The use case model for any system consists of the “use case”. Use cases represents different
Ways in which the system can be used by the user.
Application
While a use case might drill into a lot of detail about every possibility in a use-case diagram
can help provide a higher-level of view of the system. It has been said before that the Use
case diagrams are for your system. They provide the simple and graphical representation of
what the system must be actually do something.
Due to their simplistic nature, use case diagrams can be a good communicating with each tool
for stakeholders. The drawing attempt to the real world and provide a view for
the stakeholder to understand the system is going to be designed. Siu and Lee conducted
research to determine if there was a valid and situation for use case diagrams at all or if they
were unnecessary What was found was that is the use case diagrams conveyed the intent of
the system in a more simple manner to stakeholders and that they were interpreted completely
than class diagram.
The need of the use case diagrams is simple they provide the low level of the vision of
system and convey the requirements in laypeople's terms for the stakeholders. Additional
diagrams and document can be used to be provided by a complete functional and technical
view of the system.
In the use case diagram each use case is represented by an ellipse with the name of use case
written inside the ellipse. The Different users of the system are represented by using stick
person icon.The stick person icon normally referred to as an Actor.The line connecting the
actor and the use cases is called the communication relationship. When a stick person icon
represents an external system it is annotated by the stereo type <<external system>>.
18
Use case diagram of Gym Application
19
3.4 Class Diagram
In software engineering, a class diagram is the Unified Modeling Language (UML) is a type
of static structure diagram that describes the structure of a system by showing the systems
classes and their attributes operations and the relationships among objects.
The class diagram is the main building block of object oriented model It is used for the
general concept of the modeling of the systematically application and for the detailed of
modeling &translating the models into program code to Class diagrams can also be used
for data modeling. The classes use in the diagram represent both the main elements,
interactions & the application classes to be program.
In this diagram the classes are represented with the help of the boxes that contain
three compartments:-
1. The upper level of the compartment contains the name of the class. It is printed in
bold and centre and the first letter is capital.
2. The middle of the compartment contains the various attributes of the class. They are
left aligned and the first letter in lowercase.
3. The lower compartment contains the operations of the class can execute and They are
also left-aligned in the first letter is lowercase
In the design of a system, the number of classes are identified in the grouped together in a
class diagram that helps to determine the static relations between each other. With detailed
the all modeling, the class of the concept to be design are often to split into a number of
subclasses.
In one manner to further describe the behavior of the systems, to be in the class diagrams can
be complemented by the state diagram or UML state machine.
20
Class diagram of Gym Application
21
3.5 E-R diagram
An entity relationship of the model is usually the result of systematic analysis to be define
and describe what is the important processes in the area of a business. It does not define the
business processes it only presents a business data schema in graphical form. It is usually
drawn in a graphically form as boxes that are connected by lines which express the
associations and dependencies between entities. An ER model can also be expressed in a
verbal form, one building may be divided into two or three apartments, but one apartment can
only be located in one building.
Entities may be in the character is not only the relationships but also it is also additional
properties which can be include identifiers it is called as primary keys Diagrams created to be
represent attributes as well as the entities &relationships may be it is called as entity attribute
relationship diagrams, rather than the entity relationship models.
There is a tradition for ER diagram data models to be built in two or three levels of
abstraction. Note that the conceptual logical-physical hierarchy below is used in other kinds
of specified and is different from of they are three schema approach to be in software
engineering.
22
Logical data model
A logical ER model does not require any type of the ER model is especially if the scope of
the logical Entity Relation model includes only the development of information system. The
logical ER model require more detail than the conceptual ER model. In adding to the master
data entities operations and transaction data entities are now defined its very well. The details
of each data entity are developed and the relationships between the data entities are The
logical ER model is however developed independent of the specific database management
system into which it can be implemented.
The physical data model is normally instead in the structure of a database management
system as a relational database management system in objects such as database tables,
database indexes, such as unique key indexes, and data base such as a foreign key constraint
or a commonly in . The ER model is also normally used in to the design modifications
implementation to the relational database objects and to maintain the structural of the
database.
23
Entity relationship Diagram of Gym Application
24
3.6 Activity Diagram
Activity diagrams are graphically represented of workflows of stepwise activities will be
performed and actions with support for choice, iteration and concurrency. In the Unified
Modeling Language, activity diagrams are intended to model both computational and
organizational processes as well as the data flows intersecting with the all related activities in
xml. Although activity diagrams primary shows the overall flow of control they can also
include elements showing the flow of data between activities through one or more data stores
Activity diagrams are constructed from a limited no of shapes and attribute which can be
connected with the arrows. The most important shape are given below:
25
3.7 Dataflow Diagram
A data flow diagram data flow diagram is a graphically represented of the flow of data
through the information of the system modeling it’s all process take a time in data flow
diagram A DFD is often used as a first step to create an overview of the system without going
into get all over detail which can later be. Use in Data flow diagram can also be
used for the visualization of data processing structured design
A data flow diagram shows what kind of information will be input and output given from the
system of the DFD. How can I the data will be advance through the system and whenever the
data will be stored. In any system of DFD. It does not show any information about process
timing or other processes will be operate in one manner in parallel or traditional structured of
a flowchart which focuses on control of flow in UML activity workflow diagram, which
presents the both of control data flows as a unified model.
26
Chapter 4
27
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import cn.pedant.SweetAlert.SweetAlertDialog;
public class ProfileFragment extends Fragment {
EditableInputView sizeEdit = null;
EditableInputView birthdayEdit = null;
EditableInputView nameEdit = null;
EditableInputView genderEdit = null;
28
public static ProfileFragment newInstance(String name, int id) {
ProfileFragment f = new ProfileFragment();
Bundle args = new Bundle();
args.putString("name", name);
args.putInt("id", id);
f.setArguments(args);
return f;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.tab_profile, container, false);
sizeEdit = view.findViewById(R.id.size);
birthdayEdit = view.findViewById(R.id.birthday);
nameEdit = view.findViewById(R.id.name);
genderEdit = view.findViewById(R.id.gender);
roundProfile = view.findViewById(R.id.photo);
photoButton = view.findViewById(R.id.actionCamera);
sizeEdit.setTextSuffix(" cm");
mDb = new DAOProfile(view.getContext());
mProfile = getProfil();
/* Initialisation des valeurs */
imgUtil = new ImageUtil(roundProfile);
genderEdit.setCustomDialogBuilder(view1 -> {
SweetAlertDialog dlg = new SweetAlertDialog(view1.getContext(),
SweetAlertDialog.NORMAL_TYPE)
.setTitleText(getContext().getString(R.string.edit_value))
.setNeutralText(getString(R.string.maleGender))
.setCancelText(getString(R.string.femaleGender))
29
.setConfirmText(getString(R.string.otherGender))
.setNeutralClickListener(sDialog -> {
String oldValue = genderEdit.getText();
if (!oldValue.equals(getString(R.string.maleGender))) {
genderEdit.setText(getString(R.string.maleGender));
requestForSave(genderEdit);
}
sDialog.dismissWithAnimation();
})
.setCancelClickListener(sDialog -> {
String oldValue = genderEdit.getText();
if (!oldValue.equals(getString(R.string.femaleGender))) {
genderEdit.setText(getString(R.string.femaleGender));
requestForSave(genderEdit);
}
sDialog.dismissWithAnimation();
})
.setConfirmClickListener(sDialog -> {
String oldValue = genderEdit.getText();
if (!oldValue.equals(getString(R.string.otherGender))) {
genderEdit.setText(getString(R.string.otherGender));
requestForSave(genderEdit);
}
sDialog.dismissWithAnimation();
});
dlg.setOnShowListener(sDialog -> {
SweetAlertDialog sweetDlg = (SweetAlertDialog) sDialog;
sweetDlg.getButton(SweetAlertDialog.BUTTON_CONFIRM).setBackgroundRe
source(R.color.record_background_odd);
30
sweetDlg.getButton(SweetAlertDialog.BUTTON_CONFIRM).setPadding(0, 0, 0,
0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
sweetDlg.getButton(SweetAlertDialog.BUTTON_CONFIRM).setAutoSizeTextT
ypeUniformWithConfiguration(8, 12, 1, TypedValue.COMPLEX_UNIT_SP);
}
sweetDlg.getButton(SweetAlertDialog.BUTTON_CANCEL).setBackgroundReso
urce(R.color.record_background_odd);
sweetDlg.getButton(SweetAlertDialog.BUTTON_CANCEL).setPadding(0, 0, 0,
0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
sweetDlg.getButton(SweetAlertDialog.BUTTON_CANCEL).setAutoSizeTextTy
peUniformWithConfiguration(8, 12, 1, TypedValue.COMPLEX_UNIT_SP);
}
sweetDlg.getButton(SweetAlertDialog.BUTTON_NEUTRAL).setBackgroundRe
source(R.color.record_background_odd);
sweetDlg.getButton(SweetAlertDialog.BUTTON_NEUTRAL).setPadding(0, 0, 0,
0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
sweetDlg.getButton(SweetAlertDialog.BUTTON_NEUTRAL).setAutoSizeTextT
ypeUniformWithConfiguration(8, 12, 1, TypedValue.COMPLEX_UNIT_SP);
}
});
31
return dlg;
});
photoButton.setOnClickListener(onClickMachinePhoto);
imgUtil.setOnDeleteImageListener(imgUtil -> {
imgUtil.getView().setImageDrawable(getActivity().getResources().getDrawable(
R.drawable.ic_person_black_24dp));
mCurrentPhotoPath = null;
requestForSave(imgUtil.getView());
});
profileViMo = new
ViewModelProvider(requireActivity()).get(ProfileViMo.class);
profileViMo.getProfile().observe(getViewLifecycleOwner(), profile ->
mProfile = profile;
refreshData();
});
return view;
}
@Override
public void onStart() {
super.onStart();
roundProfile.post(() -> {
refreshData();
sizeEdit.setOnTextChangeListener(itemOnTextChange);
birthdayEdit.setOnTextChangeListener(itemOnTextChange);
nameEdit.setOnTextChangeListener(itemOnTextChange);
genderEdit.setOnTextChangeListener(itemOnTextChange);
});
32
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
this.mActivity = (MainActivity) activity;
}
public String getName() {
return getArguments().getString("name");
}
private void refreshData() {
mProfile = getProfil();
if (mProfile.getSize() == 0) {
sizeEdit.setText("");
sizeEdit.setHint(getString(R.string.profileEnterYourSize));
} else {
sizeEdit.setText(String.valueOf(mProfile.getSize()));
}
switch (mProfile.getGender()) {
case Gender.MALE:
genderEdit.setText(getString(R.string.maleGender));
break;
case Gender.FEMALE:
genderEdit.setText(getString(R.string.femaleGender));
break;
case Gender.OTHER:
genderEdit.setText(getString(R.string.otherGender));
break;
default:
genderEdit.setText("");
genderEdit.setHint(getString(R.string.enter_gender_here));
}
33
if (mProfile.getBirthday().getTime() == 0) {
birthdayEdit.setText("");
birthdayEdit.setHint(getString(R.string.profileEnterYourBirthday));
} else {
birthdayEdit.setText(DateConverter.dateToLocalDateStr(mProfile.getBirthday(
), getContext()));
}
nameEdit.setText(mProfile.getName());
if (mProfile.getPhoto() != null) {
ImageUtil.setPic(roundProfile, mProfile.getPhoto());
roundProfile.invalidate();
} else
roundProfile.setImageDrawable(getActivity().getResources().getDrawable(R.dr
awable.profile));
}
private void requestForSave(View view) {
boolean profileToUpdate = false;
switch (view.getId()) {
case R.id.name:
mProfile.setName(nameEdit.getText());
profileToUpdate = true;
break;
case R.id.size:
try {
mProfile.setSize((int) Float.parseFloat(sizeEdit.getText()));
} catch (NumberFormatException e) {
mProfile.setSize(0);
}
profileToUpdate = true;
break;
34
case R.id.birthday:
mProfile.setBirthday(DateConverter.localDateStrToDate(birthdayEdit.getText(
), getContext()));
profileToUpdate = true;
break;
case R.id.photo:
mProfile.setPhoto(mCurrentPhotoPath);
profileToUpdate = true;
break;
case R.id.gender:
int lGender = Gender.UNKNOWN;
if (genderEdit.getText().equals(getString(R.string.maleGender))) {
lGender = Gender.MALE;
} else if
(genderEdit.getText().equals(getString(R.string.femaleGender))) {
lGender = Gender.FEMALE;
} else if (genderEdit.getText().equals(getString(R.string.otherGender)))
{
lGender = Gender.OTHER;
}
mProfile.setGender(lGender);
profileToUpdate = true;
break;
}
if (profileToUpdate) {
mDb.updateProfile(mProfile);
KToast.infoToast(getActivity(), mProfile.getName() + " updated",
Gravity.BOTTOM, KToast.LENGTH_SHORT);
profileViMo.setProfile(mProfile);
}
35
}
private Profile getProfil() {
return ((MainActivity) getActivity()).getCurrentProfile();
}
public Fragment getFragment() {
return this;
}
private boolean CreatePhotoSourceDialog() {
if (imgUtil == null)
imgUtil = new ImageUtil();
return imgUtil.CreatePhotoSourceDialog(this);
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case ImageUtil.REQUEST_TAKE_PHOTO:
if (resultCode == Activity.RESULT_OK) {
mCurrentPhotoPath = imgUtil.getFilePath();
ImageUtil.setPic(roundProfile, mCurrentPhotoPath);
ImageUtil.saveThumb(mCurrentPhotoPath);
imgUtil.galleryAddPic(this, mCurrentPhotoPath);
requestForSave(roundProfile);
}
break;
case ImageUtil.REQUEST_PICK_GALERY_PHOTO:
if (resultCode == Activity.RESULT_OK) {
String realPath;
realPath = RealPathUtil.getRealPath(this.getContext(),
data.getData());
ImageUtil.setPic(roundProfile, realPath);
ImageUtil.saveThumb(realPath);
36
mCurrentPhotoPath = realPath;
requestForSave(roundProfile);
}
break;
case CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE:
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == Activity.RESULT_OK) {
Uri resultUri = result.getUri();
String realPath;
realPath = RealPathUtil.getRealPath(this.getContext(), resultUri);
File SourceFile = new File(realPath);
37
realPath = DestinationFile.getPath();
} catch (IOException e) {
e.printStackTrace();
Log.v("Moving", "Moving file failed.");
}
ImageUtil.setPic(roundProfile, realPath);
ImageUtil.saveThumb(realPath);
mCurrentPhotoPath = realPath;
requestForSave(roundProfile);
} else if (resultCode ==
CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Exception error = result.getError();
}
break;
}
}
}
38
Main Activity Xml File
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:paddingLeft="0dp"
android:paddingTop="0dp"
android:paddingRight="0dp"
android:paddingBottom="0dp">
<androidx.appcompat.widget.Toolbar
android:id="@+id/actionToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/toolbar_background"
android:elevation="4dp"
android:minHeight="?attr/actionBarSize"
android:visibility="visible">
<com.mikhaellopez.circularimageview.CircularImageView
android:id="@+id/imageProfile"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_gravity="end"
android:src="@drawable/ic_person_black_24dp"
app:civ_border_color="#EEEEEE"
app:civ_border_width="0dp"
app:civ_shadow="false"
app:civ_shadow_color="#8BC34A"
app:civ_shadow_radius="0" />
</androidx.appcompat.widget.Toolbar>
<androidx.appcompat.widget.Toolbar
android:id="@+id/musicToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="0dp"
39
android:background="@color/toolbar_background"
android:elevation="4dp"
android:minHeight="?attr/actionBarSize"
android:padding="0dp"
app:contentInsetStart="0dp"
app:titleMargins="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:orientation="vertical"
android:padding="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/playerSongProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:maxLines="1"
tools:text="00:00" />
<TextView
android:id="@+id/playerSongTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
tools:text="musique_test.mp3" />
</LinearLayout>
<SeekBar
android:id="@+id/playerSeekBar"
40
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginLeft="0dp"
android:layout_marginTop="-4dp"
android:layout_marginEnd="0dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="-4dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="32dp"
android:orientation="horizontal">
<ImageButton
android:id="@+id/playerPrevious"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_vertical"
android:layout_weight="5"
android:adjustViewBounds="false"
android:background="@android:color/transparent"
android:baselineAlignBottom="false"
android:cropToPadding="false"
android:scaleType="fitCenter"
android:src="@drawable/ic_skip_previous_black_24dp" />
<ImageButton
android:id="@+id/playerStop"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_vertical"
android:layout_weight="5"
android:adjustViewBounds="false"
android:background="@android:color/transparent"
android:baselineAlignBottom="false"
android:cropToPadding="true"
android:scaleType="fitCenter"
android:src="@drawable/ic_stop_black_24dp" />
<ImageButton
android:id="@+id/playerPlay"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_vertical"
android:layout_weight="5"
android:adjustViewBounds="true"
41
android:background="@android:color/transparent"
android:baselineAlignBottom="false"
android:cropToPadding="false"
android:scaleType="fitCenter"
android:src="@drawable/ic_play_arrow_black_24dp" />
<ImageButton
android:id="@+id/playerNext"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_vertical"
android:layout_weight="5"
android:adjustViewBounds="false"
android:background="@android:color/transparent"
android:baselineAlignBottom="false"
android:cropToPadding="true"
android:scaleType="fitCenter"
android:src="@drawable/ic_skip_next_black_24dp" />
<ImageButton
android:id="@+id/playerLoop"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_vertical"
android:layout_weight="5"
android:adjustViewBounds="false"
android:background="@android:color/transparent"
android:baselineAlignBottom="false"
android:cropToPadding="false"
android:scaleType="fitCenter"
android:src="@drawable/ic_replay_blue_24dp" />
<ImageButton
android:id="@+id/playerList"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_vertical"
android:layout_weight="5"
android:adjustViewBounds="false"
android:background="@android:color/transparent"
android:baselineAlignBottom="false"
android:cropToPadding="false"
android:scaleType="fitCenter"
android:src="@drawable/ic_library_music_black_24dp" />
42
</LinearLayout>
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
<LinearLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/musicToolbar"
android:layout_below="@id/actionToolbar"
android:orientation="vertical" />
</RelativeLayout>
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111"
android:choiceMode="none"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</androidx.drawerlayout.widget.DrawerLayout>
43
Main Activity Java file
package com.easyfitness;
import android.Manifest;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Environment;
import androidx.lifecycle.ViewModelProvider;
import androidx.preference.PreferenceManager;
import android.text.format.DateUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.PopupMenu;
import android.widget.Toast;
import com.easyfitness.DAO.CVSManager;
import com.easyfitness.DAO.DAOMachine;
import com.easyfitness.DAO.DAOProfile;
import com.easyfitness.DAO.DatabaseHelper;
import com.easyfitness.DAO.Machine;
import com.easyfitness.DAO.Profile;
import com.easyfitness.DAO.cardio.DAOOldCardio;
import com.easyfitness.DAO.cardio.OldCardio;
import com.easyfitness.DAO.record.DAOCardio;
import com.easyfitness.DAO.record.DAOFonte;
import com.easyfitness.DAO.record.DAORecord;
import com.easyfitness.DAO.record.DAOStatic;
import com.easyfitness.DAO.record.Record;
import com.easyfitness.DAO.program.DAOProgram;
import com.easyfitness.bodymeasures.BodyPartListFragment;
import com.easyfitness.enums.DistanceUnit;
import com.easyfitness.enums.ExerciseType;
import com.easyfitness.enums.WeightUnit;
import com.easyfitness.fonte.FontesPagerFragment;
import com.easyfitness.intro.MainIntroActivity;
import com.easyfitness.machines.MachineFragment;
44
import com.easyfitness.utils.CustomExceptionHandler;
import com.easyfitness.utils.DateConverter;
import com.easyfitness.utils.FileChooserDialog;
import com.easyfitness.utils.ImageUtil;
import com.easyfitness.utils.MusicController;
import com.easyfitness.programs.ProgramListFragment;
import com.easyfitness.utils.UnitConverter;
import com.mikhaellopez.circularimageview.CircularImageView;
import com.onurkaganaldemir.ktoastlib.KToast;
import com.theartofdev.edmodo.cropper.CropImage;
import com.theartofdev.edmodo.cropper.CropImageView;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import cn.pedant.SweetAlert.SweetAlertDialog;
/* Navigation Drawer */
private DrawerLayout mDrawerLayout = null;
private ListView mDrawerList = null;
private ActionBarDrawerToggle mDrawerToggle = null;
private CharSequence mDrawerTitle;
private CharSequence mTitle;
private MusicController musicController = new
MusicController(this);
private CircularImageView roundProfile = null;
private String mCurrentMachine = "";
private boolean mIntro014Launched = false;
private boolean mMigrationBD15done = false;
private long mBackPressed;
private ProfileViMo profileViMo;
changeProfilbuilder.setTitle(getActivity().getResources().getTex
t(R.string.profil_select_profil))
.setItems(profilListArray, (dialog, which) -
> {
46
ListView lv = ((AlertDialog)
dialog).getListView();
Object checkedItem =
lv.getAdapter().getItem(which);
setCurrentProfil(checkedItem.toString());
KToast.infoToast(getActivity(),
getActivity().getResources().getText(R.string.profileSelected) +
" : " + checkedItem.toString(), Gravity.BOTTOM,
KToast.LENGTH_LONG);
//Toast.makeText(getApplicationContext(),
getActivity().getResources().getText(R.string.profileSelected) +
" : " + checkedItem.toString(), Toast.LENGTH_LONG).show();
});
changeProfilbuilder.show();
return true;
case R.id.delete_profil:
String[] profildeleteListArray =
getActivity().mDbProfils.getAllProfil();
deleteProfilbuilder.setTitle(getActivity().getResources().getTex
t(R.string.profil_select_profil_to_delete))
.setItems(profildeleteListArray, (dialog,
which) -> {
ListView lv = ((AlertDialog)
dialog).getListView();
Object checkedItem =
lv.getAdapter().getItem(which);
if
(getCurrentProfile().getName().equals(checkedItem.toString())) {
KToast.errorToast(getActivity(),
getActivity().getResources().getText(R.string.impossibleToDelete
Profile).toString(), Gravity.BOTTOM, KToast.LENGTH_LONG);
} else {
Profile profileToDelete =
mDbProfils.getProfil(checkedItem.toString());
mDbProfils.deleteProfil(profileToDelete);
KToast.infoToast(getActivity(),
getString(R.string.profileDeleted) + ":" +
checkedItem.toString(), Gravity.BOTTOM, KToast.LENGTH_LONG);
}
});
deleteProfilbuilder.show();
return true;
case R.id.rename_profil:
47
getActivity().renameProfil();
return true;
case R.id.param_profil:
showFragment(PROFILE);
return true;
default:
return false;
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
//Log.e("Starting MainActivity", "Starting
MainActivity");
SharedPreferences SP =
PreferenceManager.getDefaultSharedPreferences(getBaseContext());
String dayNightAuto = SP.getString("dayNightAuto", "2");
int dayNightAutoValue;
try {
dayNightAutoValue = Integer.parseInt(dayNightAuto);
}catch(NumberFormatException e) {
dayNightAutoValue = 2;
}
if(dayNightAutoValue ==
getResources().getInteger(R.integer.dark_mode_value)) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIG
HT_YES);
SweetAlertDialog.DARK_STYLE=true;
} else if (dayNightAutoValue ==
getResources().getInteger(R.integer.light_mode_value)) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIG
HT_NO);
SweetAlertDialog.DARK_STYLE=false;
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIG
HT_FOLLOW_SYSTEM);
int currentNightMode =
getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK;
switch (currentNightMode) {
case Configuration.UI_MODE_NIGHT_NO:
SweetAlertDialog.DARK_STYLE=false; break;
case Configuration.UI_MODE_NIGHT_YES:
SweetAlertDialog.DARK_STYLE=true; break;
default:
SweetAlertDialog.DARK_STYLE=false;
48
}
}
super.onCreate(savedInstanceState);
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_GRANTED) {
if (folder.exists()) {
if (!
(Thread.getDefaultUncaughtExceptionHandler() instanceof
CustomExceptionHandler)) {
Thread.setDefaultUncaughtExceptionHandler(new
CustomExceptionHandler(
Environment.getExternalStorageDirectory() +
"/FastnFitness/crashreport"));
}
}
}
setContentView(R.layout.activity_main);
top_toolbar = this.findViewById(R.id.actionToolbar);
setSupportActionBar(top_toolbar);
top_toolbar.setTitle(getResources().getText(R.string.app_name));
if (savedInstanceState == null) {
if (mpFontesPagerFrag == null) mpFontesPagerFrag =
FontesPagerFragment.newInstance(FONTESPAGER, 6);
if (mpWeightFrag == null) mpWeightFrag =
WeightFragment.newInstance(WEIGHT, 5);
if (mpProfileFrag == null) mpProfileFrag =
ProfileFragment.newInstance(PROFILE, 10);
49
if (mpSettingFrag == null) mpSettingFrag =
SettingsFragment.newInstance(SETTINGS, 8);
if (mpAboutFrag == null) mpAboutFrag =
AboutFragment.newInstance(ABOUT, 4);
if (mpMachineFrag == null) mpMachineFrag =
MachineFragment.newInstance(MACHINES, 7);
if (mpBodyPartListFrag == null) mpBodyPartListFrag =
BodyPartListFragment.newInstance(BODYTRACKING, 9);
if (mpWorkoutListFrag == null) mpWorkoutListFrag =
ProgramListFragment.newInstance(WORKOUTS, 11);
} else {
mpFontesPagerFrag = (FontesPagerFragment)
getSupportFragmentManager().getFragment(savedInstanceState,
FONTESPAGER);
mpWeightFrag = (WeightFragment)
getSupportFragmentManager().getFragment(savedInstanceState,
WEIGHT);
mpProfileFrag = (ProfileFragment)
getSupportFragmentManager().getFragment(savedInstanceState,
PROFILE);
mpSettingFrag = (SettingsFragment)
getSupportFragmentManager().getFragment(savedInstanceState,
SETTINGS);
mpAboutFrag = (AboutFragment)
getSupportFragmentManager().getFragment(savedInstanceState,
ABOUT);
mpMachineFrag = (MachineFragment)
getSupportFragmentManager().getFragment(savedInstanceState,
MACHINES);
mpBodyPartListFrag = (BodyPartListFragment)
getSupportFragmentManager().getFragment(savedInstanceState,
BODYTRACKING);
mpWorkoutListFrag = (ProgramListFragment)
getSupportFragmentManager().getFragment(savedInstanceState,
WORKOUTS);
}
loadPreferences();
profileViMo = new
ViewModelProvider(this).get(ProfileViMo.class);
profileViMo.getProfile().observe(this, profile -> {
// Update UI
setDrawerTitle(profile.getName());
setPhotoProfile(profile.getPhoto());
mCurrentProfilID = profile.getId();
savePreferences();
});
DatabaseHelper.renameOldDatabase(this);
50
if (DatabaseHelper.DATABASE_VERSION >= 15 && !
mMigrationBD15done) {
DAOOldCardio mDbOldCardio = new DAOOldCardio(this);
DAOMachine lDAOMachine = new DAOMachine(this);
if (mDbOldCardio.tableExists()) {
DAOCardio mDbCardio = new DAOCardio(this);
List<OldCardio> mList =
mDbOldCardio.getAllRecords();
for (OldCardio record : mList) {
String exerciseName = "";
Machine m =
lDAOMachine.getMachine(record.getExercice());
exerciseName = record.getExercice();
if (m != null) { // if a machine exists
if (m.getType() ==
ExerciseType.STRENGTH) { // if it is not a Cardio type
exerciseName = exerciseName + "-
Cardio"; // add a suffix to
}
}
mDbCardio.addCardioRecord(record.getDate(),
exerciseName, record.getDistance(), record.getDuration(),
record.getProfil().getId(), DistanceUnit.KM, -1);
}
mDbOldCardio.dropTable();
record.setExerciseType(ExerciseType.STRENGTH);
daoRecord.updateRecord(record); //
Automatically update record Type
}
ArrayList<Machine> machineList =
lDAOMachine.getAllMachinesArray();
for (Machine record : machineList) {
lDAOMachine.updateMachine(record); // Reset
all the fields on machines.
}
}
mMigrationBD15done = true;
savePreferences();
}
if (savedInstanceState == null) {
showFragment(FONTESPAGER, false); // Create
51
fragment, do not add to backstack
currentFragmentName = FONTESPAGER;
}
dataList.add(drawerTitleItem);
dataList.add(new
DrawerItem(this.getResources().getString(R.string.menu_Workout),
R.drawable.ic_fitness_center_white_24dp, true));
dataList.add(new
DrawerItem(this.getResources().getString(R.string.MachinesLabel)
, R.drawable.ic_gym_bench_50dp, true));
dataList.add(new DrawerItem("Programs List",
R.drawable.ic_exam, true));
dataList.add(new
DrawerItem(this.getResources().getString(R.string.weightMenuLabe
l), R.drawable.ic_bathroom_scale_white_50dp, true));
dataList.add(new
DrawerItem(this.getResources().getString(R.string.bodytracking),
R.drawable.ic_ruler_white_50dp, true));
dataList.add(new
DrawerItem(this.getResources().getString(R.string.SettingLabel),
R.drawable.ic_settings_white_24dp, true));
dataList.add(new
DrawerItem(this.getResources().getString(R.string.AboutLabel),
R.drawable.ic_info_outline_white_24dp, true));
mDrawerList.setAdapter(mDrawerAdapter);
roundProfile =
top_toolbar.findViewById(R.id.imageProfile);
52
// Set the list's click listener
mDrawerList.setOnItemClickListener(new
DrawerItemClickListener());
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
musicController.initView();
// Lance l'intro
// Tester si l'intro a déjà été lancé
if (!mIntro014Launched) {
Intent intent = new Intent(this,
MainIntroActivity.class);
startActivityForResult(intent, REQUEST_CODE_INTRO);
}
@Override
protected void onStart() {
super.onStart(); // Always call the superclass method
first
if (mIntro014Launched) {
initActivity();
initDEBUGdata();
}
SharedPreferences SP =
PreferenceManager.getDefaultSharedPreferences(getBaseContext());
boolean bShowMP3 = SP.getBoolean("prefShowMP3", false);
this.showMP3Toolbar(bShowMP3);
}
lDbFonte.addBodyBuildingRecord(DateConverter.dateToDate(2019,
07, 01, 12, 34, 56), "Example 1", 1, 10, 40, WeightUnit.KG, "",
this.getCurrentProfile().getId(), -1);
lDbFonte.addBodyBuildingRecord(DateConverter.dateToDate(2019,
06, 30, 12, 34, 56), "Example 2", 1, 10,
UnitConverter.LbstoKg(60), WeightUnit.LBS, "",
this.getCurrentProfile().getId(), -1);
53
}
DAOCardio lDbCardio = new DAOCardio(this);
if(lDbCardio.getCount()==0) {
lDbCardio.addCardioRecord(DateConverter.dateToDate(2019, 07,
01), "Running Example", 1, 10000,
this.getCurrentProfile().getId(), DistanceUnit.KM, -1);
lDbCardio.addCardioRecord(DateConverter.dateToDate(2019, 07,
31), "Cardio Example", UnitConverter.MilesToKm(2), 20000,
this.getCurrentProfile().getId(), DistanceUnit.MILES, -1);
}
DAOStatic lDbStatic = new DAOStatic(this);
if(lDbStatic.getCount()==0) {
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
54
PROFILE, mpProfileFrag);
if (getMachineFragment().isAdded())
getSupportFragmentManager().putFragment(outState,
MACHINES, mpMachineFrag);
if (getAboutFragment().isAdded())
getSupportFragmentManager().putFragment(outState,
ABOUT, mpAboutFrag);
if (getSettingsFragment().isAdded())
getSupportFragmentManager().putFragment(outState,
SETTINGS, mpSettingFrag);
if (getBodyPartFragment().isAdded())
getSupportFragmentManager().putFragment(outState,
BODYTRACKING, mpBodyPartListFrag);
if (getWorkoutListFragment().isAdded())
getSupportFragmentManager().putFragment(outState,
WORKOUTS, mpWorkoutListFrag);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_activity_actions, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
final MenuItem alertMenuItem =
menu.findItem(R.id.action_profil);
roundProfile.setOnClickListener(v -> {
PopupMenu popup = new PopupMenu(getActivity(), v);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.profile_actions,
popup.getMenu());
popup.setOnMenuItemClickListener(onMenuItemClick);
popup.show();
});
return super.onPrepareOptionsMenu(menu);
}
exportDbBuilder.setTitle(getActivity().getResources().getText(R.
string.export_database));
exportDbBuilder.setMessage(getActivity().getResources().getText(
R.string.export_question) + " " + getCurrentProfile().getName()
+ "?");
exportDbBuilder.setPositiveButton(getActivity().getResources().g
etText(R.string.global_yes), (dialog, which) -> {
CVSManager cvsMan = new
CVSManager(getActivity().getBaseContext());
if (cvsMan.exportDatabase(getCurrentProfile()))
{
KToast.successToast(getActivity(),
getCurrentProfile().getName() + ": " +
getActivity().getResources().getText(R.string.export_success),
Gravity.BOTTOM, KToast.LENGTH_LONG);
} else {
KToast.errorToast(getActivity(),
getCurrentProfile().getName() + ": " +
getActivity().getResources().getText(R.string.export_failed),
Gravity.BOTTOM, KToast.LENGTH_LONG);
}
exportDbBuilder.setNegativeButton(getActivity().getResources().g
etText(R.string.global_no), (dialog, which) -> {
// Do nothing
56
dialog.dismiss();
});
AlertDialog exportDbDialog =
exportDbBuilder.create();
exportDbDialog.show();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// The action bar home/up action should open or close
the drawer.
// ActionBarDrawerToggle will take care of this.
if (mDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
//Toast.makeText(getActivity().getBaseContext(), "Chosen
directory: " +
// chosenDir,
Toast.LENGTH_LONG).show();
new SweetAlertDialog(this,
SweetAlertDialog.WARNING_TYPE)
.setTitleText(this.getResources().ge
tString(R.string.global_confirm_question))
.setContentText(this.getResources().
getString(R.string.import_new_exercise_first))
.setConfirmText(this.getResources().
getString(R.string.global_yes))
.setConfirmClickListener(sDialog ->
{
sDialog.dismissWithAnimation();
CVSManager cvsMan = new
CVSManager(getActivity().getBaseContext());
if(cvsMan.importDatabase(m_importCVSchosenDir,
getCurrentProfile())) {
57
KToast.successToast(getActivity(), m_importCVSchosenDir + " " +
getActivity().getResources().getString(R.string.imported_success
fully), Gravity.BOTTOM, KToast.LENGTH_SHORT );
} else {
});
fileChooserDialog.setFileFilter("csv");
fileChooserDialog.chooseDirectory(Environment.getExternalStorage
Directory() + "/FastnFitness/export");
return true;
case R.id.action_deleteDB:
// Afficher une boite de dialogue pour confirmer
AlertDialog.Builder deleteDbBuilder = new
AlertDialog.Builder(this);
deleteDbBuilder.setTitle(getActivity().getResources().getText(R.
string.global_confirm));
deleteDbBuilder.setMessage(getActivity().getResources().getText(
R.string.deleteDB_warning));
deleteDbBuilder.setPositiveButton(getActivity().getResources().g
etText(R.string.global_yes), (dialog, which) -> {
// recupere le premier ID de la liste.
List<Profile> lList =
mDbProfils.getAllProfils();
for (int i = 0; i < lList.size(); i++) {
Profile mTempProfile = lList.get(i);
mDbProfils.deleteProfil(mTempProfile.getId());
}
DAOMachine mDbMachines = new
DAOMachine(getActivity());
58
// recupere le premier ID de la liste.
List<Machine> lList2 =
mDbMachines.getAllMachinesArray();
for (int i = 0; i < lList2.size(); i++) {
Machine mTemp = lList2.get(i);
mDbMachines.delete(mTemp.getId());
}
finish();
});
deleteDbBuilder.setNegativeButton(getActivity().getResources().g
etText(R.string.global_no), (dialog, which) -> {
// Do nothing
dialog.dismiss();
});
AlertDialog deleteDbDialog =
deleteDbBuilder.create();
deleteDbDialog.show();
return true;
case R.id.action_apropos:
// Display the fragment as the main content.
showFragment(ABOUT);
//getAboutFragment().setHasOptionsMenu(true);
return true;
//case android.R.id.home:
//onBackPressed();
// return true;
case R.id.action_chrono:
ChronoDialogbox cdd = new
ChronoDialogbox(MainActivity.this);
cdd.show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onRequestPermissionsResult(int requestCode,
String[] permissions,
59
int[] grantResults) {
// If request is cancelled, the result arrays are empty.
if (requestCode ==
MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE) {
if (grantResults.length > 0
&& grantResults[0] ==
PackageManager.PERMISSION_GRANTED) {
KToast.infoToast(this,
getString(R.string.access_granted), Gravity.BOTTOM,
KToast.LENGTH_SHORT);
exportDatabase();
} else {
KToast.infoToast(this,
getString(R.string.another_time_maybe), Gravity.BOTTOM,
KToast.LENGTH_SHORT);
}
}
}
newProfilBuilder.setTitle(getActivity().getResources().getText(R
.string.createProfilTitle));
newProfilBuilder.setMessage(getActivity().getResources().getText
(R.string.createProfilQuestion));
newProfilBuilder.setPositiveButton(getActivity().getResources().
getText(R.string.global_ok), (dialog, whichButton) -> {
String value = input.getText().toString();
if (value.isEmpty()) {
CreateNewProfil();
} else {
// Create the new profil
mDbProfils.addProfil(value);
// Make it the current.
setCurrentProfil(value);
}
});
60
newProfilBuilder.setNegativeButton(getActivity().getResources().
getText(R.string.global_cancel), (dialog, whichButton) -> {
if (getCurrentProfile() == null) {
CreateNewProfil();
}
});
newProfilBuilder.show();
return true;
}
newBuilder.setTitle(getActivity().getResources().getText(R.strin
g.renameProfilTitle));
newBuilder.setMessage(getActivity().getResources().getText(R.str
ing.renameProfilQuestion));
newBuilder.setPositiveButton(getActivity().getResources().getTex
t(R.string.global_ok), (dialog, whichButton) -> {
String value = input.getText().toString();
if (!value.isEmpty()) {
// Get current profil
Profile temp = getCurrentProfile();
// Rename it
temp.setName(value);
// Commit it
mDbProfils.updateProfile(temp);
// Make it the current.
setCurrentProfil(value);
}
});
newBuilder.setNegativeButton(getActivity().getResources().getTex
t(R.string.global_cancel), (dialog, whichButton) -> {
});
61
newBuilder.show();
return true;
}
/**
* Swaps fragments in the main content view
*/
private void selectItem(int position) {
// Highlight the selected item, update the title, and
close the drawer
mDrawerList.setItemChecked(position, true);
//setTitle(mPlanetTitles[position]);
mDrawerLayout.closeDrawer(mDrawerList);
}
@Override
public void setTitle(CharSequence title) {
getSupportActionBar().setTitle(title);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Sync the toggle state after onRestoreInstanceState
has occurred.
mDrawerToggle.syncState();
}
@Override
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
mDrawerToggle.onConfigurationChanged(newConfig);
}
if (currentFragmentName.equals(pFragmentName))
62
return; // If this is already the current fragment,
do no replace.
FragmentManager fragmentManager =
getSupportFragmentManager();
FragmentTransaction ft =
fragmentManager.beginTransaction();
@Override
protected void onStop() {
super.onStop();
savePreferences();
}
roundProfile.setImageDrawable(getActivity().getResources().getDr
awable(R.drawable.ic_person_black_24dp));
mDrawerAdapter.getItem(0).setImgResID(R.drawable.ic_person_black
_24dp);
mDrawerAdapter.getItem(0).setImg(null); // Img has
priority over Resource
mDrawerAdapter.notifyDataSetChanged();
mDrawerLayout.invalidate();
}
}
return mpFontesPagerFrag;
}
return mpWeightFrag;
}
return mpProfileFrag;
}
return mpAboutFrag;
}
return mpBodyPartListFrag;
}
return mpWorkoutListFrag;
}
66
private SettingsFragment getSettingsFragment() {
if (mpSettingFrag == null)
mpSettingFrag = (SettingsFragment)
getSupportFragmentManager().findFragmentByTag(SETTINGS);
if (mpSettingFrag == null) mpSettingFrag =
SettingsFragment.newInstance(SETTINGS, 8);
return mpSettingFrag;
}
@Override
protected void onActivityResult(int requestCode, int
resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE_INTRO) {
if (resultCode == RESULT_OK) {
initActivity();
mIntro014Launched = true;
initDEBUGdata();
this.savePreferences();
} else {
// Cancelled the intro. You can then e.g. finish
this activity too.
finish();
}
}
}
@Override
public void onBackPressed() {
int index =
67
getActivity().getSupportFragmentManager().getBackStackEntryCount
() - 1;
if (index >= 0) { // Si on est dans une sous activité
FragmentManager.BackStackEntry backEntry =
getSupportFragmentManager().getBackStackEntryAt(index);
String tag = backEntry.getName();
Fragment fragment =
getSupportFragmentManager().findFragmentByTag(tag);
super.onBackPressed();
getActivity().getSupportActionBar().show();
} else { // Si on est la racine, avec il faut cliquer
deux fois
if (mBackPressed + TIME_INTERVAL >
System.currentTimeMillis()) {
super.onBackPressed();
return;
} else {
Toast.makeText(getBaseContext(),
R.string.pressBackAgain, Toast.LENGTH_SHORT).show();
}
mBackPressed = System.currentTimeMillis();
}
}
if (mCurrentProfile != null)
setCurrentProfil(mCurrentProfile.getName());
68
private class DrawerItemClickListener implements
ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView parent, View view,
int position, long id) {
selectItem(position);
setTitle(getResources().getText(R.string.menu_Workout));
break;
case 2:
showFragment(MACHINES);
setTitle(getResources().getText(R.string.MachinesLabel));
break;
case 3:
showFragment(WORKOUTS);
setTitle(getString(R.string.workout_list_menu_item));
break;
case 4:
showFragment(WEIGHT);
setTitle(getResources().getText(R.string.weightMenuLabel));
break;
case 5:
showFragment(BODYTRACKING);
setTitle(getResources().getText(R.string.bodytracking));
break;
case 6:
showFragment(SETTINGS);
setTitle(getResources().getText(R.string.SettingLabel));
break;
case 7:
showFragment(ABOUT);
setTitle(getResources().getText(R.string.AboutLabel));
break;
default:
69
showFragment(FONTESPAGER);
setTitle(getResources().getText(R.string.FonteLabel));
}
}
}
}
The purpose of testing approach is to find code defects in functions or in a unit of work.
testing is the most efficient, effective, and inexpensive phase in terms of defect detection.
There are many different versions of browsers, so the browser’s compatibility must be
maintained to make sure the system is correctly displayed under different browsers. IE Tester
can be used to test various versions of IE browsers’ effects of the same system. Such
browsers as Firefox, Google and Opera are installed to test the system. Finally, the tests are
all passed.
The unit test technical approach is to validate the following: internal logic, error handling,
field processing, computations calculations, data handling access, range of possible
inputs/outputs, and cross-field edits. Using the application documentation as a guide, the
developer moves through the code he/she has written and ensures all the requirements and the
coding standards have been met. Best practices provide that the developer will engage peers
to review his/her code.
Unit test plans should cover the technical details of the program. Expected results focus on
internal code and the inputs and the outputs from the code. In-depth, high-quality unit testing
will shorten future testing phases by reducing the defect rate. The purpose is to validate that
each unit of the software performs as designed.
Unit testing is a method by which individual units of source code are tested to determine if
they are fit for use. A unit is the smallest testable part of an application like functions
procedures, classes, interfaces.
70
4.1.1 Unit Testing
Unit testing is a method by which individual units of source code are tested to determine if
they are fit for use. A unit is the smallest testable part of an application like functions
procedures, classes, interfaces.
Unit tests are typically written and run by software developers to ensure that code meets its
design and behaves as intended.
The goal of unit testing is to isolate each part of the program and show that the individual
parts are correct. Unit tests find problems early in the development cycle.
After the development of all modules, we first go for Unit testing. In Unit testing, we check
that all the modules are working properly as individual. If there is no any error in Unit testing
than we go for Integration Testing.
Unit testing is a level of the software testing process where individual unit/components of a
software/system are tested. The purpose is to validate that each unit of the software performs
as designed.
A unit is the smallest testable part of software. It usually has one or a few input and usually a
single output. In procedural programming a unit may be an individual program, function,
procedure etc. In object-oriented programming, the smallest unit is a method, which may
belong to a base/super class, abstract class or derived/child class.
object matches the technical design, properly handles the data and the available paths through
the software execute reliably. This testing is typically performed on the developers’
workstations, and then repeated on the server-based development environment. Limited
interfacing of components is likely to occur in this phase by a developer.
71
4.1.2 Integration Testing
Integration testing in the software testing model comes before system testing and after the
unit testing has been done.
The way that integration testing works is by, getting the individual modules that have been
through the unit testing phase and integrating each module into a group. The integration
testing phase will make sure when the modules are being integrated together that any
problems, for example errors or bugs, caused due to the integration of the modules are
eliminated. Integration testing does not deal with the integration of the whole system but
deals with the integration of process in the system.
In the integration testing stage there are three things that are created, to ensure that the
integration of the modules is successful and that it runs successfully as well, a test plan, test
cases and test data is produced to effectively test that the integration is successful. Test data is
normally used by test cases but I have mentioned each type below;
After the Unit testing, we integrate different-different modules together. Than we check that
integrated modules are working properly together. If after the integration, project work
properly than we goes for System Testing.
72
Enter the Height 160 Accept the As pass
4. (cm) height expected
73
Integration Test Cases: -
Test cases is created to make sure that the output, of the integrated modules are producing the
expected output and is working exactly how it is supposed to work. This is simply a way to
spot any errors or bugs that might have been made in the integration phase. The tester will
then work through the program and document all the data using the test case that was created,
the test case will test all inputs and outputs in the integrated modules.
Below is a simple test case, this was created by myself for a program that I created in collage,
I have also included some test data in the test case to show exactly how it works.
If you are dealing with a large application or program, then there may be various test cases
that might need to be created to test separate sections of the program. The various test cases
are normally gathered together and referred to as test suites, which is a set of test cases.
74
Chapter 5
Creating Profile
Stopwatch
75
Main Activity
Exercise List
76
BMI Activity
Body Measures
77
Chapter 6
Conclusion:-
I hope you have enjoyed learning about how to stay healthy and fit. There are many ways to
exercise along with many healthy foods you can eat to help stay fit. When exercising it is
good to make sure your pulse rate is good, and that you warm up your muscles before
exercising and to make sure you do a cool down to help your muscles cool down.
When making sure you are exercising right or eating right it is best to use an activity pyramid
to keep track of all the different kinds of activity you do. To make sure you eat right it is best
to check the nutrition label on the back of every food to make sure you are consuming the
right amount of calories.
Understanding the requirement of the user these statistics definitely scale the most accurate
measure of progress which always adds the craze to move forward with the desired results.
Therefore, if you ever wanted to manage and track your progress this app is here to assist
you.
78
Future Work
The future work of this application is to raise your awareness, as a fitness professional in his
personal Life, as to how people may select fitness exercise from the many activity that are out
there. If we know what people are looking for from a fitness app then we know what we are
competing with from a gym or online trainers point of view.
79
Chapter 7
References
Website:-
https://www.youtube.com/channel/UCgnv52hqclx0fTopBi9llDQ/featured
https://www.youtube.com/watch?v=zmjfAcnosS0
https://www.youtube.com/watch?v=lF5m4o_CuNg
https://www.youtube.com/watch?v=KySFSzm-qVg
https://www.youtube.com/watch?v=8vMVTeKrDFM
80