Goals and Settings

Josh Miller

This was our second week of production and we were finally able to begin designing the app's layout and functionality. I was again responsible for several tasks this week, including the primary goal view, implementing some functionality into settings, and starting on routines.

The first portion I began developing was implementing the goal screen. The purpose of this fragment is to display a list of the user's goals in an easily understandable visual manner. This was accomplished by using a ListView with a custom .xml file for each list entry and pairing that with a custom built adapter to allow the app to programmatically modify the data for each entry. I then added a floating action button (FAB) to allow the user to add new goals over time.
Goal fragment filled with placeholder data

Goal detailed view

Goal editing (1)

Goal editing (2)
Next, I worked on making our settings fragment more usable. This involved editing the app's root_preferences file and adding functionality in the fragment's associated java file. This resulted in usable popups with which the user can enter data, as well as a setting to enable a dark theme.
<PreferenceCategory app:title="Appearance">
<SwitchPreferenceCompat
android:defaultValue="false"
app:key="theme"
app:summary="Enable dark theme on supported versions of Android"
app:title="Dark mode" />

<ListPreference
android:entries="@array/day_entries"
android:entryValues="@array/day_values"
app:key="calendar"
app:title="Calendar Start Day"
app:useSimpleSummaryProvider="true" />
</PreferenceCategory>

setPreferencesFromResource(R.xml.root_preferences, rootKey);

SwitchPreferenceCompat appTheme = findPreference("theme");
appTheme.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
@Override
public boolean onPreferenceChange(Preference preference, Object newValue)
{
if ((boolean) newValue)
{
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else
{
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}

return true;
}
});

Settings fragment

Dark mode enabled
Next, I started work on a method that will read data from a local .json file to create a usable list of exercise data for the rest of the app to use. This data was originally pulled from a publicly available database under a creative commons license, which means that our team is free to edit and redistribute its information.
static String getJsonFromAssets(Context context, String fileName)
{
String jsonString;
try
{
InputStream is = context.getAssets().open(fileName);

int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();

jsonString = new String(buffer, "UTF-8");
} catch (IOException e)
{
e.printStackTrace();
return null;
}

return jsonString;
}
public static ArrayList<CExercise> loadExercises(Context context, String fileName)
{
ArrayList<CExercise> exercises = new ArrayList<CExercise>();

Gson gson = new Gson();
String json = getJsonFromAssets(context, fileName);
Type type = new TypeToken<ArrayList<CExercise>>()
{
}.getType();

exercises = gson.fromJson(json, type);

return exercises;
}

The last portion I was able to work on this week was adding animation to the FAB from earlier. I did so by adding an external library to the project's dependency and changed the old action button to use the updated library in the layout's xml.

New animated FAB