Skip to content

Commit

Permalink
v27 (#256)
Browse files Browse the repository at this point in the history
* Fix issue with app mode toggle not updating

* Fix `NonConstantResourceld` warning advising to avoid using non-final resource ids in switch statements; switch converted to ifs

* Add activeandroid-3.1.0-SNAPSHOT.jar to the project directly

* Update to latest gradle

* Update to latest firebase

* Fix deprecation warning

* Enable code minification and fix java heap space errors when building apk

* Allow horizontal screen rotation

* Update to latest timber to fix build warning

* Fix "Wrong locale name" inspection

* Remove unnecessary properties

* No longer need API check

* Merge API 17 specific files

* Merge API 21 specific files

* Refactor to simplify line separator retrieval

* Combine identical exception handlers

* Refactor backup to not hold lines in memory

* Add landscape layouts for viewing history

* Enable and update proguard rules to fix minifyEnabled causing crash on app start

* Update to use recommended proguard file (https://developer.android.com/build/shrink-code#configuration-files)

* Improve restore performance by 4x

* Fix code inspection warnings

* Remove debug logging

* Improve performance of GenerateDataTask

* Fix bug where restoring from json would lose the first day's entries

* Update to latest gradle

* Update to latest crashlytics

* Update versionCode and versionName
  • Loading branch information
slavick authored Oct 5, 2024
1 parent 1f74138 commit d70853e
Show file tree
Hide file tree
Showing 36 changed files with 292 additions and 979 deletions.
22 changes: 12 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ configurations {
}

android {
buildFeatures.viewBinding = true

buildFeatures {
buildConfig = true
viewBinding = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand All @@ -33,8 +35,8 @@ android {
compileSdk 34
targetSdkVersion 34
vectorDrawables.useSupportLibrary = true
versionCode 90
versionName "26"
versionCode 91
versionName "27"
}
buildTypes {
debug {
Expand All @@ -43,8 +45,8 @@ android {
}
release {
manifestPlaceholders = [crashlyticsCollectionEnabled: "true"]
// minifyEnabled true
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

Expand All @@ -61,18 +63,18 @@ android {
}

dependencies {
implementation 'com.google.firebase:firebase-analytics:22.0.2'
implementation 'com.google.firebase:firebase-crashlytics:19.0.3'
implementation 'com.google.firebase:firebase-analytics:22.1.0'
implementation 'com.google.firebase:firebase-crashlytics:19.1.0'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
implementation fileTree(include: ['*.jar'], dir: 'libs')
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.3.1') { exclude group: "com.android.support" }
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.jakewharton.timber:timber:5.0.1'
implementation "io.noties.markwon:core:4.6.2"
}
Binary file added app/libs/activeandroid-3.1.0-SNAPSHOT.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
# ActiveAndroid
-keep class com.activeandroid.** { *; }

-keep class org.nutritionfacts.dailydozen.model.** { *; }

# MPAndroidChart
-keep class com.github.mikephil.charting.** { *; }
-dontwarn io.realm.**
Expand Down
13 changes: 1 addition & 12 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
android:name=".activity.MainActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden">

<intent-filter>
Expand All @@ -55,14 +54,12 @@

<activity
android:name=".activity.AboutActivity"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:label="@string/about_this_app"/>

<activity
android:name=".activity.DailyReminderSettingsActivity"
android:label="@string/daily_reminder_settings"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:parentActivityName=".activity.MainActivity">
<meta-data
Expand All @@ -72,12 +69,10 @@

<activity
android:name=".activity.DebugActivity"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait"/>
android:configChanges="orientation|keyboardHidden"/>

<activity
android:name=".activity.HistoryActivity"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:parentActivityName=".activity.MainActivity">
<meta-data
Expand All @@ -87,7 +82,6 @@

<activity
android:name=".activity.FoodInfoActivity"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:parentActivityName=".activity.MainActivity">
<meta-data
Expand All @@ -98,7 +92,6 @@
<activity
android:name=".activity.ServingsHistoryActivity"
android:label="@string/daily_servings_history"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:parentActivityName=".activity.MainActivity">
<meta-data
Expand All @@ -108,7 +101,6 @@

<activity
android:name=".activity.TweakInfoActivity"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:parentActivityName=".activity.MainActivity">
<meta-data
Expand All @@ -119,7 +111,6 @@
<activity
android:name=".activity.TweakServingsHistoryActivity"
android:label="@string/daily_tweaks_history"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:parentActivityName=".activity.MainActivity">
<meta-data
Expand All @@ -130,7 +121,6 @@
<activity
android:name=".activity.WeightHistoryActivity"
android:label="@string/weight_history"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:parentActivityName=".activity.MainActivity">
<meta-data
Expand All @@ -140,7 +130,6 @@

<activity android:name=".activity.FaqActivity"
android:label="@string/faq_title"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:parentActivityName=".activity.MainActivity">
<meta-data
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/java/likeanimation/LikeButtonView.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
Expand Down Expand Up @@ -47,7 +45,6 @@ public LikeButtonView(Context context, AttributeSet attrs, int defStyleAttr) {
init();
}

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public LikeButtonView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init();
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/java/org/nutritionfacts/dailydozen/Common.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ public static void showToast(final Context context, final int stringId) {
showToast(context, context.getString(stringId));
}

public static String getLineSeparator() {
return System.getProperty("line.separator");
}

public static void openUrlInExternalBrowser(final Context context, final int urlId) {
openUrlInExternalBrowser(context, context.getString(urlId));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private void initLinksInWelcome() {
}

private void initLinksInText() {
final String aboutText = TextUtils.join(Common.getLineSeparator(),
final String aboutText = TextUtils.join(System.lineSeparator(),
getResources().getStringArray(R.array.about_text_lines));
final SpannableStringBuilder ssb = new SpannableStringBuilder(aboutText);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.nutritionfacts.dailydozen.activity;

import android.content.res.Configuration;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Menu;
Expand Down Expand Up @@ -69,7 +70,12 @@ private void displayFoodInfo() {
if (food != null && !TextUtils.isEmpty(food.getName())) {
final String foodName = food.getName();

initImage(foodName);
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
initImage(foodName);
binding.foodInfoImage.setVisibility(View.VISIBLE);
} else {
binding.foodInfoImage.setVisibility(View.GONE);
}
initServingTypes(food);
initFoodTypes(foodName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,20 @@ public boolean onCreateOptionsMenu(Menu menu) {
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
toggleTweaksMenuItemVisibility();
updateAppModeToggle();
return super.onPrepareOptionsMenu(menu);
}

private void updateAppModeToggle() {
if (inDailyDozenMode) {
setTitle(R.string.app_name);
menuToggleModes.setTitle(R.string.twenty_one_tweaks);
} else {
setTitle(R.string.twenty_one_tweaks);
menuToggleModes.setTitle(R.string.app_name);
}
}

private void toggleTweaksMenuItemVisibility() {
if (menuToggleModes != null) {
menuToggleModes.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
Expand All @@ -188,57 +199,50 @@ private void toggleTweaksMenuItemVisibility() {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
switch (itemId) {
case R.id.menu_toggle_modes:
inDailyDozenMode = !inDailyDozenMode;
if (inDailyDozenMode) {
setTitle(R.string.app_name);
item.setTitle(R.string.twenty_one_tweaks);
} else {
setTitle(R.string.twenty_one_tweaks);
item.setTitle(R.string.app_name);
}
initDatePager();
return true;
case R.id.menu_latest_videos:
Common.openUrlInExternalBrowser(this, R.string.url_latest_videos);
return true;
case R.id.menu_how_not_to_die:
Common.openUrlInExternalBrowser(this, R.string.url_how_not_to_die);
return true;
case R.id.menu_cookbook:
Common.openUrlInExternalBrowser(this, R.string.url_cookbook);
return true;
case R.id.menu_how_not_to_diet:
Common.openUrlInExternalBrowser(this, R.string.url_how_not_to_diet);
return true;
case R.id.menu_daily_dozen_challenge:
Common.openUrlInExternalBrowser(this, R.string.url_daily_dozen_challenge);
return true;
case R.id.menu_faq:
startActivity(new Intent(this, FaqActivity.class));
return true;
case R.id.menu_donate:
Common.openUrlInExternalBrowser(this, R.string.url_donate);
return true;
case R.id.menu_subscribe:
Common.openUrlInExternalBrowser(this, R.string.url_subscribe);
return true;
case R.id.menu_open_source:
Common.openUrlInExternalBrowser(this, R.string.url_open_source);
return true;
case R.id.menu_daily_reminder_settings:
startActivity(new Intent(this, DailyReminderSettingsActivity.class));
return true;
case R.id.menu_backup:
backup();
return true;
case R.id.menu_about:
startActivity(new Intent(this, AboutActivity.class));
return true;
case R.id.menu_debug:
startActivityForResult(new Intent(this, DebugActivity.class), Args.DEBUG_SETTINGS_REQUEST);
return true;
if (itemId == R.id.menu_toggle_modes) {
inDailyDozenMode = !inDailyDozenMode;
updateAppModeToggle();
initDatePager();
return true;
} else if (itemId == R.id.menu_latest_videos) {
Common.openUrlInExternalBrowser(this, R.string.url_latest_videos);
return true;
} else if (itemId == R.id.menu_how_not_to_die) {
Common.openUrlInExternalBrowser(this, R.string.url_how_not_to_die);
return true;
} else if (itemId == R.id.menu_cookbook) {
Common.openUrlInExternalBrowser(this, R.string.url_cookbook);
return true;
} else if (itemId == R.id.menu_how_not_to_diet) {
Common.openUrlInExternalBrowser(this, R.string.url_how_not_to_diet);
return true;
} else if (itemId == R.id.menu_daily_dozen_challenge) {
Common.openUrlInExternalBrowser(this, R.string.url_daily_dozen_challenge);
return true;
} else if (itemId == R.id.menu_faq) {
startActivity(new Intent(this, FaqActivity.class));
return true;
} else if (itemId == R.id.menu_donate) {
Common.openUrlInExternalBrowser(this, R.string.url_donate);
return true;
} else if (itemId == R.id.menu_subscribe) {
Common.openUrlInExternalBrowser(this, R.string.url_subscribe);
return true;
} else if (itemId == R.id.menu_open_source) {
Common.openUrlInExternalBrowser(this, R.string.url_open_source);
return true;
} else if (itemId == R.id.menu_daily_reminder_settings) {
startActivity(new Intent(this, DailyReminderSettingsActivity.class));
return true;
} else if (itemId == R.id.menu_backup) {
backup();
return true;
} else if (itemId == R.id.menu_about) {
startActivity(new Intent(this, AboutActivity.class));
return true;
} else if (itemId == R.id.menu_debug) {
startActivityForResult(new Intent(this, DebugActivity.class), Args.DEBUG_SETTINGS_REQUEST);
return true;
}
return super.onOptionsItemSelected(item);
}
Expand Down Expand Up @@ -343,7 +347,7 @@ public File getBackupFile() {

private void shareBackupFile() {
final File backupFile = getBackupFile();
final String backupInstructions = TextUtils.join(Common.getLineSeparator(),
final String backupInstructions = TextUtils.join(System.lineSeparator(),
getResources().getStringArray(R.array.backup_instructions_lines));
final Uri backupFileUri = FileProvider.getUriForFile(this, Common.FILE_PROVIDER_AUTHORITY, backupFile);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void onEvent(LoadHistoryCompleteEvent event) {
CombinedChart.DrawOrder.BAR, CombinedChart.DrawOrder.LINE
});

binding.dailyServingsChart.setVisibleXRange(5, 5);
binding.dailyServingsChart.setVisibleXRange(5, 10);

binding.dailyServingsChart.getXAxis().setDrawLabels(true);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.nutritionfacts.dailydozen.activity;

import android.content.res.Configuration;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import org.nutritionfacts.dailydozen.Common;
import org.nutritionfacts.dailydozen.R;
Expand Down Expand Up @@ -36,7 +38,12 @@ private void displayTweakInfo() {
final Tweak tweak = getTweak();

if (tweak != null && !TextUtils.isEmpty(tweak.getName())) {
initImage(tweak.getName());
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
initImage(tweak.getName());
binding.tweakInfoImage.setVisibility(View.VISIBLE);
} else {
binding.tweakInfoImage.setVisibility(View.GONE);
}
initTweakShort(tweak.getName());
initTweakText(tweak.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void onEvent(LoadHistoryCompleteEvent event) {
CombinedChart.DrawOrder.BAR, CombinedChart.DrawOrder.LINE
});

binding.dailyServingsChart.setVisibleXRange(5, 5);
binding.dailyServingsChart.setVisibleXRange(5, 10);

binding.dailyServingsChart.getXAxis().setDrawLabels(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void onEvent(LoadHistoryCompleteEvent event) {
CombinedChart.DrawOrder.BAR, CombinedChart.DrawOrder.LINE
});

binding.dailyServingsChart.setVisibleXRange(5, 5);
binding.dailyServingsChart.setVisibleXRange(5, 10);

binding.dailyServingsChart.getXAxis().setDrawLabels(true);

Expand Down
Loading

0 comments on commit d70853e

Please sign in to comment.