0% found this document useful (0 votes)
7 views

fit tech app report

The document is a project report for the 'Fit Tech App' submitted by Muskan Yadav for the Master of Computer Applications degree at Gurugram University. It outlines the application's purpose, scope, objectives, and the technology used, including Android Studio and SQLite, to automate gym management processes. The report includes various chapters detailing system design, requirements, and functionalities aimed at improving user fitness tracking and management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

fit tech app report

The document is a project report for the 'Fit Tech App' submitted by Muskan Yadav for the Master of Computer Applications degree at Gurugram University. It outlines the application's purpose, scope, objectives, and the technology used, including Android Studio and SQLite, to automate gym management processes. The report includes various chapters detailing system design, requirements, and functionalities aimed at improving user fitness tracking and management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 80

FIT TECH APPLICATION

A project report submitted in the partial fulfillment of the


requirement for the award of degree of Master of
Computer Applications
(MCA)

( Academic Session: 2023 – 2025 )

Supervised By: Submitted By:


Ms. Rakhi Soni Muskan Yadav
Assistant Professor Uni. Roll No : 23128410049

Department of Computer Science Govt.


College Sector-9
Gurugram University, Gurugram
DECLARATION

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.

Date: Muskan Yadav


CERTIFICATE

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.

I wish him all success in his endeavours.

Ms. Rakhi Soni


ACKNOWLEDGEMENT

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.

Facilities and Services:-

Main workout Area:-


Most health clubs have a important workout area, which primarily consists of free
weights including dumbbells and barbells and the stands and benches used with these things
and exercise machines, which use gears, cables and other mechanisms to guide the user's
exercise. This area often add in mirrors so that exercisers can monitor and preserve correct
posture during their workout. A gym that predominantly or absolutely contains of free
weights (dumbbells and barbells), as opposed to exercise machines, is sometimes referred to
as a black- iron gym, after the traditional color of weight plates.

Cardio area/exercise classes:-


A cardio theater or cardio area contains many types of cardiovascular training-related utility
such as rowing machines, stationary exercise bikes, elliptical trainers and treadmills. These
areas frequently include a number of audio-visual displays, often TVs (either included into
the equipment or placed on walls around the area itself) in order to keep exercisers
entertained during long cardio workout sessions. Some gyms deliver newspapers and
magazines for users of the cardio theatre to read while working out.

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:-

 FIT-TECH is a professional application that individuals reach their fitness and


health goals.
 This application helps to empower people to create healthy training habits.
 To make best use of our equipment and resources through well-attended sessions.
 It allows you to create your custom workout plan.
 It provides a stopwatch to record the time you take for each exercise.

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 is purposeful to be used by development teams as small as one person or as


big as global teams. The Android Studio IDE can be connected to big teams with GIT or
same version control services for larger teams. Mature Android designer will find tools that
are essential for large teams to deliver solutions rapidly to their customers. Android mixture
can be develop using either Java or C++ in Android Studio. The workflow for Android Studio
is built around the concept of continuous integration. Continuous Integration agrees for teams
to test their code each and every time a developer checks in their work. Issues can be
apprehend and reported to the team immediately. The concept of repeatedly checking code
provides actionable feedback to the developers with the goal of releasing versions of a mobile
solution faster to the Google Play App Store. To finish this, there is rigorous support for
LINT tools, Pro-Guard and App Signing tools.

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.

Features of Android Studio:-

 Gradle-based build support


 Android-specific refactoring and quick fixes.
 Lint tools to catch performance, usability, version compatibility and other problems
 ProGuard integration and app-signing capabilities
 Template-based wizards to create common Android designs and components.

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

 More man power.


 Time consuming.
 Consumes large volume of pare work.
 Need manual calculations.
 No direct role for higher officials.

2.3 Proposed system of Gym 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

2.4.1 Software Requirement Specification


The software requirement specification is produced at the the culmination of the analysis
task. The functions and performance allocated to software as part of engineering system are
refined by establishing a complete information description, a detailed functional and
behavioral description, an indication of performance requirements and design constraints,
appropriate validation criteria, and the other data pertinent to requirements.

The proposed system has the following requirements:


 System needs to maintain quality record.
 System needs to keep the records of Employee.
 System needs to update and delete the record.
 System also needs a search area.
 System needs a security system to prevent data.

Name of component Specification

Operating system Andriod Version 4.0 and above

Language Java

Database SQLite

JSON
Database driver

13
2.4.2 Hardware Requirement Specification

Name of component Specification

Sanpdragon 400 and above, Media tek


Processor P20 and above

RAM 1GB or more

Storage 2GB or more

Display Touch Screen

14
CHAPTER 3

System Design

3.1 Workout Module


The main need for the development this module is to manage of the all workout data. We
provide full workout module to help the user about fitness tips. So all excercise will be
managed by the developer and can see the list of data of all the exercise he/she as done at that
particular day & filter according to the His/Her satisfaction. All the details of each exercise
and how to perform the exercise is been provided by this module

Training Exercise Module for Beginners


 Hip-dominant (deadlifts, hinges, and swings)
 Knee-dominant (squats and lunges)
 Pushing movements (push, and presses)
 Pulling movement (rows and pullups)
 Gait pattern, such as walking and running

Admin Enquiry Module

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.

 Admin can manage the all enquiry


 Admin can edit and delete of the enquiry
 Admin can also see the all list of all enquiry
 Users can see enquiry on user side

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.

Following some major symbols in the data dictionary

=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

Data Type Null Primary Key Description


Name Varchar(20) Not Null Yes Unique name
Gender Varchar(30) Allow Null No Male , Female
Or Other

Date of Int Allow Null No To


Birth calculate
age

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

A class with three compartments.

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.

An ER model is typically implementing as a database. In the simple relational database


implement in each row of a table which are shows in one instance of an entity type and each
field in a table represents the attribute of this type. In a relational database in a relation
between entities is implemented by sort sing the first key of the one entity as a pointer or
"foreign key in the table of another entity model of relationship.

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.

Conceptual data model


This is the high level ER model in the contains of the least of granular detail but establishes
the overall scope of is to be included within the model. The ER model normally defines
master reference data entities that are commonly used by the any organization. of a ER
diagram model may be used as the foundation for one of The need of the concept of the ER
model is then to be structural commonly for the master of data entities between the set of
logical er models. The concept of the data model may be used to form common relation
between er models as well as a basis for data model.

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.

Physical data model


One or many physical Entity Relation models may be developed from each logical ER model.
The physical ER model is normally developed and instantiated as a database. Therefore, each
physical ER model must contain take a detail to produce a database and each physical ER
model is only for based on technology dependent model since each database management
system is any ware any time in different phase.

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:

 ellipses represent the various actions;


 diamonds represent the decisions of attributeC
 bars represent the start orend to join of concurrent activities
 a hole black circle represents the start initial position of the node of the workflow
 a circled black circle represents the end of final node of attribute

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.

Dataflow Diagram of Gym Application

26
Chapter 4

Implemetation and Testing Phase Code

Main intro Java File


package com.easyfitness;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import com.easyfitness.DAO.DAOProfile;
import com.easyfitness.DAO.Profile;
import com.easyfitness.utils.DateConverter;
import com.easyfitness.views.EditableInputView;
import com.easyfitness.utils.Gender;
import com.easyfitness.utils.ImageUtil;
import com.easyfitness.utils.RealPathUtil;
import com.mikhaellopez.circularimageview.CircularImageView;
import com.onurkaganaldemir.ktoastlib.KToast;
import com.theartofdev.edmodo.cropper.CropImage;

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;

CircularImageView roundProfile = null;


FloatingActionButton photoButton = null;
String mCurrentPhotoPath = null;

MainActivity mActivity = null;


private DAOProfile mDb = null;
private Profile mProfile = null;
private ImageUtil imgUtil = null;
private EditableInputView.OnTextChangedListener itemOnTextChange =
this::requestForSave;
private OnClickListener onClickMachinePhoto = v ->
CreatePhotoSourceDialog();
private ProfileViMo profileViMo;
public static ProfileFragment newInstance(String name, int id) {
ProfileFragment f = new ProfileFragment();

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);

File storageDir = null;


String timeStamp = new
SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + ".jpg";
String state = Environment.getExternalStorageState();
if (!Environment.MEDIA_MOUNTED.equals(state)) {
return;
} else {
storageDir =
Environment.getExternalStoragePublicDirectory("/FastnFitness/Camera/");
if (!storageDir.exists()) {
storageDir.mkdirs();
}
}
new File(storageDir.getPath() + imageFileName);
File DestinationFile;
try {
DestinationFile = imgUtil.moveFile(SourceFile, storageDir);

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>

<!-- The navigation drawer -->

<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;

public class MainActivity extends AppCompatActivity {

private static final int TIME_INTERVAL = 2000; // #


milliseconds, desired time passed between two back presses.
public static String FONTESPAGER = "FontePager";
public static String WEIGHT = "Weight";
public static String PROFILE = "Profile";
public static String BODYTRACKING = "BodyTracking";
public static String BODYTRACKINGDETAILS =
"BodyTrackingDetail";
public static String ABOUT = "About";
public static String SETTINGS = "Settings";
public static String MACHINES = "Machines";
public static String MACHINESDETAILS = "MachinesDetails";
public static String WORKOUTS = "Workouts";
public static String WORKOUTPAGER = "WorkoutPager";
public static String PREFS_NAME = "prefsfile";
private final int REQUEST_CODE_INTRO = 111;
private final int
MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1001;
CustomDrawerAdapter mDrawerAdapter;
List<DrawerItem> dataList;
45
/* Fragments */
private FontesPagerFragment mpFontesPagerFrag = null;
private WeightFragment mpWeightFrag = null;
private ProfileFragment mpProfileFrag = null;
private MachineFragment mpMachineFrag = null;
private SettingsFragment mpSettingFrag = null;
private AboutFragment mpAboutFrag = null;
private BodyPartListFragment mpBodyPartListFrag = null;
private ProgramListFragment mpWorkoutListFrag;

private String currentFragmentName = "";


private DAOProfile mDbProfils = null;
private Profile mCurrentProfile = null;
private long mCurrentProfilID = -1;
private String m_importCVSchosenDir = "";
private Toolbar top_toolbar = null;

/* 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;

private PopupMenu.OnMenuItemClickListener onMenuItemClick =


item -> {
switch (item.getItemId()) {
case R.id.create_newprofil:
getActivity().CreateNewProfil();
return true;
case R.id.change_profil:
String[] profilListArray =
getActivity().mDbProfils.getAllProfil();

AlertDialog.Builder changeProfilbuilder = new


AlertDialog.Builder(getActivity());

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();

AlertDialog.Builder deleteProfilbuilder = new


AlertDialog.Builder(getActivity());

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) {

/* creation de l'arborescence de l'application */


File folder = new
File(Environment.getExternalStorageDirectory() +
boolean success = true;
if (!folder.exists()) {
success = folder.mkdir();
}
if (success) {
folder = new
File(Environment.getExternalStorageDirectory() +
success = folder.mkdir();
}

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();

DAORecord daoRecord = new DAORecord(this);


List<Record> mFonteList =
daoRecord.getAllRecords();
for (Record record : mFonteList) {

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 = new ArrayList<>();


mDrawerLayout = findViewById(R.id.drawer_layout);
mDrawerList = findViewById(R.id.left_drawer);

DrawerItem drawerTitleItem = new DrawerItem("TITLE",


R.drawable.ic_person_black_24dp, true);

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));

mDrawerAdapter = new CustomDrawerAdapter(this,


R.layout.custom_drawer_item,
dataList);

mDrawerList.setAdapter(mDrawerAdapter);

roundProfile =
top_toolbar.findViewById(R.id.imageProfile);

mDrawerToggle = new ActionBarDrawerToggle(


this, /* host Activity */
mDrawerLayout, /* DrawerLayout object */
top_toolbar, /* nav drawer icon to replace 'Up'
caret */
R.string.drawer_open, R.string.drawer_close
);

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);
}

private void initDEBUGdata() {


if (BuildConfig.DEBUG_MODE) {
// do something for a debug build
DAOFonte lDbFonte = new DAOFonte(this);
if(lDbFonte.getCount()==0) {

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) {

lDbStatic.addStaticRecord(DateConverter.dateToDate(2019, 07, 01,


12, 34, 56), "Exercise ISO 1", 1, 50, 40,
this.getCurrentProfile().getId(), WeightUnit.KG, "", -1);

lDbStatic.addStaticRecord(DateConverter.dateToDate(2019, 07, 31,


12, 34, 56), "Exercise ISO 2", 1, 60, UnitConverter.LbstoKg(40),
this.getCurrentProfile().getId(), WeightUnit.LBS, "", -1);
}
DAOProgram lDbWorkout = new DAOProgram(this);
if(lDbWorkout.getCount()==0) {
lDbWorkout.populate();
}
}
}

public void onRestoreInstanceState(Bundle


savedInstanceState) {
// Always call the superclass so it can restore the view
hierarchy
super.onRestoreInstanceState(savedInstanceState);
}

@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);

//Save the fragment's instance


if (getFontesPagerFragment().isAdded())
getSupportFragmentManager().putFragment(outState,
FONTESPAGER, mpFontesPagerFrag);
if (getWeightFragment().isAdded())
getSupportFragmentManager().putFragment(outState,
WEIGHT, mpWeightFrag);
if (getProfileFragment().isAdded())
getSupportFragmentManager().putFragment(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);

// restore the profile picture in case it was


overwritten during the menu inflate
if (mCurrentProfile != null)
setPhotoProfile(mCurrentProfile.getPhoto());

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);
}

private void exportDatabase() {


55
// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
// No explanation needed; request the permission
ActivityCompat.requestPermissions(this,
new String[]
{Manifest.permission.WRITE_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
} else {
// Afficher une boite de dialogue pour confirmer
AlertDialog.Builder exportDbBuilder = new
AlertDialog.Builder(this);

exportDbBuilder.setTitle(getActivity().getResources().getText(R.
string.export_database));

exportDbBuilder.setMessage(getActivity().getResources().getText(
R.string.export_question) + " " + getCurrentProfile().getName()
+ "?");

// Si oui, supprimer la base de donnee et refaire un


Start.

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);
}

// Do nothing but close the dialog


dialog.dismiss();
});

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;
}

// Handle presses on the action bar items


switch (item.getItemId()) {
case R.id.export_database:
exportDatabase();
return true;
case R.id.import_database:
// Create DirectoryChooserDialog and register a
callback
FileChooserDialog fileChooserDialog =
new FileChooserDialog(this, chosenDir -> {
m_importCVSchosenDir = chosenDir;

//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 {

KToast.errorToast(getActivity(), m_importCVSchosenDir + " " +


getActivity().getResources().getString(R.string.import_failed),
Gravity.BOTTOM, KToast.LENGTH_SHORT );
}

setCurrentProfil(getCurrentProfile()); // Refresh profile


})
.setCancelText(this.getResources().g
etString(R.string.global_no))
.show();

});

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));

// Si oui, supprimer la base de donnee et


refaire un Start.

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());
}

// redisplay the intro


mIntro014Launched=false;

// Do nothing but close the dialog


dialog.dismiss();

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);

}
}
}

public boolean CreateNewProfil() {


AlertDialog.Builder newProfilBuilder = new
AlertDialog.Builder(this);

newProfilBuilder.setTitle(getActivity().getResources().getText(R
.string.createProfilTitle));

newProfilBuilder.setMessage(getActivity().getResources().getText
(R.string.createProfilQuestion));

// Set an EditText view to get user input


final EditText input = new EditText(this);
newProfilBuilder.setView(input);

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;
}

public boolean renameProfil() {


AlertDialog.Builder newBuilder = new
AlertDialog.Builder(this);

newBuilder.setTitle(getActivity().getResources().getText(R.strin
g.renameProfilTitle));

newBuilder.setMessage(getActivity().getResources().getText(R.str
ing.renameProfilQuestion));

// Set an EditText view to get user input


final EditText input = new EditText(this);
input.setText(getCurrentProfile().getName());
newBuilder.setView(input);

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;
}

private void setDrawerTitle(String pProfilName) {


mDrawerAdapter.getItem(0).setTitle(pProfilName);
mDrawerAdapter.notifyDataSetChanged();
mDrawerLayout.invalidate();
}

/**
* 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);
}

private void showFragment(String pFragmentName) {


showFragment(pFragmentName, true);
}

private void showFragment(String pFragmentName, boolean


addToBackStack) {

if (currentFragmentName.equals(pFragmentName))
62
return; // If this is already the current fragment,
do no replace.

FragmentManager fragmentManager =
getSupportFragmentManager();
FragmentTransaction ft =
fragmentManager.beginTransaction();

// Then show the fragments


if (pFragmentName.equals(FONTESPAGER)) {
ft.replace(R.id.fragment_container,
getFontesPagerFragment(), FONTESPAGER);
} else if (pFragmentName.equals(WEIGHT)) {
ft.replace(R.id.fragment_container,
getWeightFragment(), WEIGHT);
} else if (pFragmentName.equals(SETTINGS)) {
ft.replace(R.id.fragment_container,
getSettingsFragment(), SETTINGS);
} else if (pFragmentName.equals(MACHINES)) {
ft.replace(R.id.fragment_container,
getMachineFragment(), MACHINES);
} else if (pFragmentName.equals(WORKOUTS)) {
ft.replace(R.id.fragment_container,
getWorkoutListFragment(), WORKOUTS);
} else if (pFragmentName.equals(ABOUT)) {
ft.replace(R.id.fragment_container,
getAboutFragment(), ABOUT);
} else if (pFragmentName.equals(BODYTRACKING)) {
ft.replace(R.id.fragment_container,
getBodyPartFragment(), BODYTRACKING);
} else if (pFragmentName.equals(PROFILE)) {
ft.replace(R.id.fragment_container,
getProfileFragment(), PROFILE);
}
currentFragmentName = pFragmentName;
ft.commit();

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

public Profile getCurrentProfile() {


return profileViMo.getProfile().getValue();
}

public void setCurrentProfil(String newProfilName) {


63
Profile newProfil =
this.mDbProfils.getProfil(newProfilName);
setCurrentProfil(newProfil);
}

public void setCurrentProfil(Profile newProfil) {


profileViMo.setProfile(newProfil);
}

private void setPhotoProfile(String path) {


ImageUtil imgUtil = new ImageUtil();

// Check if path is pointing to a thumb else create it


and use it.
String thumbPath = imgUtil.getThumbPath(path);
if (thumbPath != null) {
ImageUtil.setPic(roundProfile, thumbPath);
mDrawerAdapter.getItem(0).setImg(thumbPath);
mDrawerAdapter.notifyDataSetChanged();
mDrawerLayout.invalidate();
} else {

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();
}
}

private void savePhotoProfile(String path) {


mCurrentProfile.setPhoto(path);// Enregistrer sur le
profile le path de la photo.
mDbProfils.updateProfile(mCurrentProfile);
}

public String getCurrentMachine() {


return mCurrentMachine;
}

public void setCurrentMachine(String newMachine) {


mCurrentMachine = newMachine;
}

public MainActivity getActivity() {


return this;
64
}

private void loadPreferences() {


// Restore preferences
SharedPreferences settings =
getSharedPreferences(PREFS_NAME, 0);
mCurrentProfilID = settings.getLong("currentProfil", -
1); // return -1 if it doesn't exist
mIntro014Launched =
settings.getBoolean("intro014Launched", false);
mMigrationBD15done =
settings.getBoolean("migrationBD15done", false);
}

private void savePreferences() {


// Restore preferences
SharedPreferences settings =
getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putLong("currentProfil", mCurrentProfilID);
editor.putBoolean("intro014Launched",
mIntro014Launched);
editor.putBoolean("migrationBD15done",
mMigrationBD15done);
editor.apply();
}

private FontesPagerFragment getFontesPagerFragment() {


if (mpFontesPagerFrag == null)
mpFontesPagerFrag = (FontesPagerFragment)
getSupportFragmentManager().findFragmentByTag(FONTESPAGER);
if (mpFontesPagerFrag == null)
mpFontesPagerFrag =
FontesPagerFragment.newInstance(FONTESPAGER, 6);

return mpFontesPagerFrag;
}

private WeightFragment getWeightFragment() {


if (mpWeightFrag == null)
mpWeightFrag = (WeightFragment)
getSupportFragmentManager().findFragmentByTag(WEIGHT);
if (mpWeightFrag == null) mpWeightFrag =
WeightFragment.newInstance(WEIGHT, 5);

return mpWeightFrag;
}

private ProfileFragment getProfileFragment() {


if (mpProfileFrag == null)
65
mpProfileFrag = (ProfileFragment)
getSupportFragmentManager().findFragmentByTag(PROFILE);
if (mpProfileFrag == null) mpProfileFrag =
ProfileFragment.newInstance(PROFILE, 10);

return mpProfileFrag;
}

private MachineFragment getMachineFragment() {


if (mpMachineFrag == null)
mpMachineFrag = (MachineFragment)
getSupportFragmentManager().findFragmentByTag(MACHINES);
if (mpMachineFrag == null) mpMachineFrag =
MachineFragment.newInstance(MACHINES, 7);
return mpMachineFrag;
}

private AboutFragment getAboutFragment() {


if (mpAboutFrag == null)
mpAboutFrag = (AboutFragment)
getSupportFragmentManager().findFragmentByTag(ABOUT);
if (mpAboutFrag == null) mpAboutFrag =
AboutFragment.newInstance(ABOUT, 6);

return mpAboutFrag;
}

private BodyPartListFragment getBodyPartFragment() {


if (mpBodyPartListFrag == null)
mpBodyPartListFrag = (BodyPartListFragment)
getSupportFragmentManager().findFragmentByTag(BODYTRACKING);
if (mpBodyPartListFrag == null)
mpBodyPartListFrag =
BodyPartListFragment.newInstance(BODYTRACKING, 9);

return mpBodyPartListFrag;
}

private ProgramListFragment getWorkoutListFragment() {


if (mpWorkoutListFrag == null)
mpWorkoutListFrag = (ProgramListFragment)
getSupportFragmentManager().findFragmentByTag(WORKOUTS);
if (mpWorkoutListFrag == null)
mpWorkoutListFrag =
ProgramListFragment.newInstance(WORKOUTS, 10);

return mpWorkoutListFrag;
}

66
private SettingsFragment getSettingsFragment() {
if (mpSettingFrag == null)
mpSettingFrag = (SettingsFragment)
getSupportFragmentManager().findFragmentByTag(SETTINGS);
if (mpSettingFrag == null) mpSettingFrag =
SettingsFragment.newInstance(SETTINGS, 8);

return mpSettingFrag;
}

public Toolbar getActivityToolbar() {


return top_toolbar;
}

public void restoreToolbar() {


if (top_toolbar != null)
setSupportActionBar(top_toolbar);
}

public void showMP3Toolbar(boolean show) {


Toolbar mp3toolbar =
this.findViewById(R.id.musicToolbar);
if (!show) {
mp3toolbar.setVisibility(View.GONE);
} else {
mp3toolbar.setVisibility(View.VISIBLE);
}
}

@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();
}
}

public void initActivity() {


// Initialisation des objets DB
mDbProfils = new
DAOProfile(this.getApplicationContext());

// Pour la base de donnee profil, il faut toujours qu'il


y ai au moins un profil
mCurrentProfile =
mDbProfils.getProfil(mCurrentProfilID);
if (mCurrentProfile == null) { // au cas ou il y aurait
un probleme de synchro
try {
List<Profile> lList =
mDbProfils.getAllProfils();
mCurrentProfile = lList.get(0);
} catch (IndexOutOfBoundsException e) {
this.CreateNewProfil();
}
}

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);

// Insert the fragment by replacing any existing


fragment
switch (position) {
case 0:
showFragment(PROFILE);
setTitle(getString(R.string.ProfileLabel));
break;
case 1:
showFragment(FONTESPAGER);

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));
}
}
}
}

4.1 Testing Approach

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.

Unit testing is the process of testing an individual, low-level program in an isolated


environment before testing its integration with other units. Unit testing verifies the code

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;

Integration Test Plan: -


Integration testing tests integration or interfaces between components, interactions to
different parts of the system such as an operating system, file system and hardware or
interfaces between systems.

Integration testing is done by a specific integration tester or test team.

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.

Sr no. Test Steps Test Data Expected Actual Status


Result Result

Open application - Profile creation As expected pass


1. and create a profile form should
appear
Enter the name Om Shinde Accept name As expected pass
2.

Select the gender Male Accept Gender As pass


3. expected

72
Enter the Height 160 Accept the As pass
4. (cm) height expected

Press the create - Profile should As pass


5. button be created Expected

Click the Watch icon - Stopwatch As pass


6. on app home page should be Expected
started

Click reset button - Stopwatch As pass


7. after stopwatch timer should Expected
started restart
8. Click the exit button - Stopwatch As pass
after stopwatch is should be Expected
started closed
9. On app’s home Bench press Exercise Name As pass
page enter should be Expected
Exercise name accepted
10. Enter set and reps 1,10 It should be As pass
accepted Expected

11. Enter rest 60 It should be As pass


time(secs) accepted Expected

12. Click ADD button to - Exercise should As pass


add your completed be added to Expected
exercise record and rest
time should
pop up.
13. Click the History tab - Your workout As pass
history should Expected
appear
14. Open Exercise tab - Exercise tab As pass
by clicking on 3 line should be Expected
on top left corner opened
15. Go to weight Track 60 Weight should As pass
and Press Plus icon be accept Expected
Enter the weight

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

Results and Discussion

Creating Profile

Stopwatch

75
Main Activity

Exercise List

76
BMI Activity

Body Measures

77
Chapter 6

Conclusion and Future work

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.

In Future we will Import:-

1. Progress Bar – which will show the progress of user.


2. Navigation Drawer – for better performance.
3. New Stages – new exercise stages will be added.
4. Calendar – which will show on which date the exercise is done by the user.

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

You might also like