Skip to content

Commit

Permalink
v20 (#196)
Browse files Browse the repository at this point in the history
* Change TweakHistoryActivity to extend InfoActivity

* Delete the unused TweakLoadingActivity

* Change to show tweak name in TweakHistoryActivity

* Refactor to combine DailyDozenPagerAdapter and TweaksPagerAdapter into the single DatePagerAdapter

* Fix "Resource IDs will be non-final in Android Gradle Plugin version 7.0, avoid using them in switch case statements"

* Fix "Use 'app:drawableLeftCompat' instead of 'android:drawableLeft'"

* Update dependencies

* Add HistoryType

* Refactor to combine LoadServingsHistoryTask and LoadTweakServingsHistoryTask into LoadHistoryTask

* Refactor LoadWeightsHistoryTask to remove unused code

* Revert gson library update

* Refactor to combine FoodHistoryActivity and TweakHistoryActivity

* Refactor to combine CalculateStreakTask and CalculateTweakStreakTask

* Fix bug that causes incorrect month name to be displayed

* Add missing annotations

* Change to maintain user's date selection when changing app modes

* Reduce code duplication between pager adapters

* Use existing variable instead of calling function again

* Update dependencies

* Revert "Reduce code duplication between pager adapters"

This reverts commit 0c91bfc

* Update `versionCode` and `versionName`

* Add missing `formatted` tags

* Add missing `@NonNull` annotations to fix Android Studio warnings

* Remove check for condition that is always true

* Prevent NullPointerException

* Inline `initList` to fix warning

* Fix redundant boxing warning

* Replace three switch statements

* Fix warnings related to formatted strings

* Add path property to fix warning

* Replace fraction string with fraction character

* Update firebase dependencies

* Fix warnings

* versionCode 60

* Fix warnings

* Fix bug where jumping to date was not always reliable

* Undo change to filepaths.xml and increase versionCode
  • Loading branch information
slavick authored Oct 17, 2021
1 parent 8b5c3c9 commit 5280502
Show file tree
Hide file tree
Showing 54 changed files with 387 additions and 889 deletions.
18 changes: 9 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ configurations {

android {
compileSdkVersion 30
buildToolsVersion '29.0.3'
buildToolsVersion '30.0.2'

viewBinding.enabled = true
buildFeatures.viewBinding = true

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -39,8 +39,8 @@ android {
minSdkVersion 16
targetSdkVersion 30
vectorDrawables.useSupportLibrary = true
versionCode 58
versionName "19.1"
versionCode 61
versionName "20"
}
buildTypes {
debug {
Expand All @@ -66,17 +66,17 @@ android {
}

dependencies {
implementation 'com.google.firebase:firebase-analytics:19.0.0'
implementation 'com.google.firebase:firebase-crashlytics:18.0.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.firebase:firebase-analytics:19.0.2'
implementation 'com.google.firebase:firebase-crashlytics:18.2.3'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
implementation 'com.darwinsys:hirondelle-date4j:1.5.1'
implementation 'com.github.prolificinteractive:material-calendarview:2.0.1'
implementation('com.joanzapata.iconify:android-iconify-fontawesome:2.2.2') { exclude group: "com.android.support" }
implementation('com.github.PhilJay:MPAndroidChart:v2.2.5') { exclude group: "com.android.support" }
implementation('org.greenrobot:eventbus:3.2.0') { exclude group: "com.android.support" }
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.jakewharton.timber:timber:4.7.1'
}
12 changes: 1 addition & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
android:screenOrientation="portrait"/>

<activity
android:name=".activity.FoodHistoryActivity"
android:name=".activity.HistoryActivity"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:parentActivityName=".activity.MainActivity">
Expand Down Expand Up @@ -103,16 +103,6 @@
android:value=".activity.MainActivity"/>
</activity>

<activity
android:name=".activity.TweakHistoryActivity"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:parentActivityName=".activity.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.MainActivity"/>
</activity>

<activity
android:name=".activity.TweakInfoActivity"
android:screenOrientation="portrait"
Expand Down
14 changes: 6 additions & 8 deletions app/src/main/java/org/nutritionfacts/dailydozen/Common.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat;

import org.nutritionfacts.dailydozen.activity.FoodHistoryActivity;
import org.nutritionfacts.dailydozen.activity.FoodInfoActivity;
import org.nutritionfacts.dailydozen.activity.HistoryActivity;
import org.nutritionfacts.dailydozen.activity.ServingsHistoryActivity;
import org.nutritionfacts.dailydozen.activity.TweakHistoryActivity;
import org.nutritionfacts.dailydozen.activity.TweakInfoActivity;
import org.nutritionfacts.dailydozen.activity.TweakServingsHistoryActivity;
import org.nutritionfacts.dailydozen.activity.WeightHistoryActivity;
Expand All @@ -29,8 +28,7 @@
import org.nutritionfacts.dailydozen.model.Tweak;
import org.nutritionfacts.dailydozen.model.TweakServings;
import org.nutritionfacts.dailydozen.model.Weights;

import java.util.Date;
import org.nutritionfacts.dailydozen.util.DateUtil;

public class Common {
public static final String FILE_PROVIDER_AUTHORITY = "org.nutritionfacts.dailydozen.fileprovider";
Expand Down Expand Up @@ -137,9 +135,9 @@ private static Intent createTweakIntent(final Context context, final Class<? ext
return intent;
}

public static Intent createShowDateIntent(final Date date) {
public static Intent createShowDateIntent(final int year, final int month, final int day) {
final Intent showDateIntent = new Intent();
showDateIntent.putExtra(Args.DATE, date);
showDateIntent.putExtra(Args.DATE, DateUtil.getCalendarForYearMonthAndDay(year, month, day).getTime());
return showDateIntent;
}

Expand All @@ -160,11 +158,11 @@ public static boolean isSupplement(final Food food) {
}

public static void openFoodHistory(final Context context, final Food food) {
startSelectableDateActivity(context, createFoodIntent(context, FoodHistoryActivity.class, food));
startSelectableDateActivity(context, createFoodIntent(context, HistoryActivity.class, food));
}

public static void openTweakHistory(final Context context, final Tweak tweak) {
startSelectableDateActivity(context, createTweakIntent(context, TweakHistoryActivity.class, tweak));
startSelectableDateActivity(context, createTweakIntent(context, HistoryActivity.class, tweak));
}

public static void openServingsHistory(final Context context) {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/org/nutritionfacts/dailydozen/Servings.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

public interface Servings {
int getServings();
void recalculateStreak();
Long save();
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
default:
return super.onOptionsItemSelected(item);
if (item.getItemId() == android.R.id.home) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}

private void initActionBar() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import android.view.View;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import org.nutritionfacts.dailydozen.Common;
import org.nutritionfacts.dailydozen.R;
Expand Down Expand Up @@ -57,13 +56,11 @@ public boolean onCreateOptionsMenu(Menu menu) {

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.food_info_videos:
openVideosInBrowser();
return true;
default:
return super.onOptionsItemSelected(item);
if (item.getItemId() == R.id.food_info_videos) {
openVideosInBrowser();
return true;
}
return super.onOptionsItemSelected(item);
}

private void displayFoodInfo() {
Expand All @@ -85,10 +82,10 @@ private void initImage(String foodName) {
private void initServingTypes(final Food food) {
final List<String> servingSizes = FoodInfo.getServingSizes(food.getIdName(),
Prefs.getInstance(this).getUnitTypePref());
final FoodServingsAdapter adapter = new FoodServingsAdapter(servingSizes);

initChangeUnitsButton();
initList(binding.foodServingSizes, adapter);
binding.foodServingSizes.setAdapter(new FoodServingsAdapter(servingSizes));
binding.foodServingSizes.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
}

private void initChangeUnitsButton() {
Expand All @@ -99,14 +96,9 @@ private void initChangeUnitsButton() {
private void initFoodTypes(String foodName) {
final List<String> foods = FoodInfo.getTypesOfFood(foodName);
final List<String> videos = FoodInfo.getFoodVideosLink(foodName);
final RecyclerView.Adapter adapter = new FoodTypeAdapter(foods, videos);

initList(binding.foodTypes, adapter);
}

private void initList(final RecyclerView list, final RecyclerView.Adapter adapter) {
list.setAdapter(adapter);
list.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
binding.foodTypes.setAdapter(new FoodTypeAdapter(foods, videos));
binding.foodTypes.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
}

private void openVideosInBrowser() {
Expand Down
Loading

0 comments on commit 5280502

Please sign in to comment.