Mobile App Developer, Competitive Programmer, and Full-Stack Software Engineer
LinkedIn
Welcome to the Timely Fitness project!
Timely Fitness is an Android app that helps you keep good track of your fitness, and occasionally gives you somewhat functional reminders to get moving.
To create this project, I didn’t just need to learn Java
. I also had to use:
XML
Markdown
(this file that you’re reading right now is written in this scripting language,
which offers functionality similar to that of HTML
)Gradle
(a build tool that allows you to package runtime dependencies along with your
compiled Java bytecode into something called a “build”)The app works through a central file called MainActivity.java
.
It contains a crucial method in the code known as the “main” method, which the compiler looks for
when it tries to execute the app. Currently, the main function looks something like this:
@Override
public void onCreate(Bundle savedInstanceState) {
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_NIGHT_YES);
SweetAlertDialog.DARK_STYLE = true;
} else if (dayNightAutoValue == getResources().getInteger(R.integer.light_mode_value)) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
SweetAlertDialog.DARK_STYLE = false;
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
int currentNightMode = getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK;
switch (currentNightMode) {
case Configuration.UI_MODE_NIGHT_YES:
SweetAlertDialog.DARK_STYLE = true;
break;
case Configuration.UI_MODE_NIGHT_NO:
default:
SweetAlertDialog.DARK_STYLE = false;
}
}
super.onCreate(savedInstanceState);
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_GRANTED) {
File folder = new File(Environment.getExternalStorageDirectory() + "/FastnFitness");
boolean success = true;
if (!folder.exists()) {
success = folder.mkdir();
}
if (success) {
folder = new File(Environment.getExternalStorageDirectory() + "/FastnFitness/crashreport");
success = folder.mkdir();
}
if (folder.exists()) {
if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof CustomExceptionHandler)) {
Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(
Environment.getExternalStorageDirectory() + "/FastnFitness/crashreport"));
}
}
}
setContentView(R.layout.activity_main);
I’d agree with everyone’s thoughts right now; it looks messy. But the system has to check over a lot of things, like the display size, the status of the device, and some strange abomination that is the light mode/dark mode switcher thingy.
Parts of the library functions for this project were forked from other awesome creations, such as
a project by brodeurlv that is called
FastNFitness. I found his CSV
data parsing
functions extremely helpful, and included a folder of some of the functions that he wrote to parse
mine. I also used Google Code Snippets, which are folders of functions that the team behind the
Android mobile operating system wrote to help developers along, so I need to acknowledge that I
used their functional code to help me make this project possible.
CSV
parsing functions, which were super helpful to me
for data storage on one’s local device. If you are interested in helping him out on his project, check it out at: