Skip to content

Commit

Permalink
v22 (#218)
Browse files Browse the repository at this point in the history
* Translation addition (cs) and updates. Includes translation contributor list. (#211)

* translation changes: adds (cs), updates (he, iw, it), serving_sizes_cruciferous adds item (all languages)

* add `about_translators` string

* Uses ISO 639-1 code in (zh) contributors list to match other translatation useage.
See nutritionfactsorg/daily-dozen-localization#16 (comment)

* Replace fractional measurements with unicode characters

* Add translation contributor list to About activity

* Update versionCode and versionName

* Ignore annoying files

* Update targetSdkVersion to 31

* Set exported="true" where necessary

* Add FLAG_IMMUTABLE to PendingIntents

* Change all alarms to be inexact to remove the need to ask user for permission

* Czech update (including 21 Tweaks), removed unneeded ".csv", contributors update. (#212)

* Update versionCode and versionName

* Czech minor update (2022.11.24) (#213)

* Czech minor update (2022.11.24)

* Czech: O autorovi --> O aplikaci

* Update to com.android.tools.build:gradle:7.3.1 and remove com.jakewharton.hugo

* Update compileSdkVersion and targetSdkVersion to 33. Update other dependencies to latest versions.

* Update versionCode and versionName

* Enable multidex as the build failed with "Cannot fit requested classes in a single dex file"

* Declare AD_ID permission due to use of firebase

* Update versionCode

* Add catch for SecurityException

* Adds Slovak (sk). updates contributor lists. (#217)

* Adds Slovak (sk)

* updates translation contributor list (all languages)

* removed staging files which were not intented to be part of the pull request.

* adds *_LOCAL to .gitignore.

* Update versionCode and versionName

* Update permissions request for recent Android releases

* Update versionCode and versionName; reformat file

* Update versionCode and versionName

* Change versionName to 22

Co-authored-by: --marc <[email protected]>
  • Loading branch information
slavick and marc-medley authored Dec 23, 2022
1 parent 979e897 commit e8cd1de
Show file tree
Hide file tree
Showing 32 changed files with 1,759 additions and 618 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@
/captures
fabric.properties
DailyDozenDB*
ajcore*
output-metadata.json

## place for local-only items.
*_LOCAL
35 changes: 15 additions & 20 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ buildscript {
mavenCentral()
google()
}

dependencies {
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.hugo'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

Expand All @@ -25,30 +20,30 @@ configurations {
}

android {
compileSdkVersion 30
buildToolsVersion '30.0.2'
compileSdkVersion 33

buildFeatures.viewBinding = true

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "org.nutritionfacts.dailydozen"
minSdkVersion 16
targetSdkVersion 30
minSdkVersion 19
multiDexEnabled true
targetSdkVersion 33
vectorDrawables.useSupportLibrary = true
versionCode 73
versionName "21.3"
versionCode 82
versionName "22"
}
buildTypes {
debug {
manifestPlaceholders = [crashlyticsCollectionEnabled:"false"]
ext.enableCrashlytics=false
manifestPlaceholders = [crashlyticsCollectionEnabled: "false"]
ext.enableCrashlytics = false
}
release {
manifestPlaceholders = [crashlyticsCollectionEnabled:"true"]
manifestPlaceholders = [crashlyticsCollectionEnabled: "true"]
// minifyEnabled true
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Expand All @@ -66,11 +61,11 @@ android {
}

dependencies {
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 'com.google.firebase:firebase-analytics:21.2.0'
implementation 'com.google.firebase:firebase-crashlytics:18.3.2'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.google.android.material:material:1.7.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'
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<manifest package="org.nutritionfacts.dailydozen"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" tools:ignore="ScopedStorage"/>
<uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>

<application
android:name=".DailyDozenApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
Expand All @@ -24,6 +27,7 @@

<activity
android:name=".activity.MainActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden">
Expand Down Expand Up @@ -138,7 +142,7 @@
android:name=".receiver.AlarmReceiver"
android:process=":remote"/>

<receiver android:name=".receiver.DeviceBootReceiver">
<receiver android:name=".receiver.DeviceBootReceiver" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ public class PermissionController {
private static final int WRITE_EXTERNAL_STORAGE_REQUEST = 1;

public static boolean canWriteExternalStorage(final Activity activity) {
final int permissionStatus = ContextCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
return Build.VERSION.SDK_INT < 23 || permissionStatus == PackageManager.PERMISSION_GRANTED;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
return ContextCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
}
return true;
}

public static void askForWriteExternalStorage(final Activity activity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.nutritionfacts.dailydozen.model.enums.Units;
import org.nutritionfacts.dailydozen.model.pref.UpdateReminderPref;

import hugo.weaving.DebugLog;
import timber.log.Timber;

public class Prefs {
Expand Down Expand Up @@ -81,12 +80,10 @@ public void setUserHasSeenFirstStarExplosion() {
setBooleanPref(USER_HAS_SEEN_FIRST_STAR_EXPLOSION, true);
}

@DebugLog
public void setUpdateReminderPref(UpdateReminderPref pref) {
setStringPref(PREF_UPDATE_REMINDER, new Gson().toJson(pref));
}

@DebugLog
public UpdateReminderPref getUpdateReminderPref() {
return new Gson().fromJson(getStringPref(PREF_UPDATE_REMINDER), UpdateReminderPref.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import java.util.List;

import hugo.weaving.DebugLog;
import timber.log.Timber;

@Table(name = "foods")
Expand Down Expand Up @@ -63,7 +62,6 @@ public String toString() {
return name;
}

@DebugLog
public static void ensureAllFoodsExistInDatabase(final String[] foodNames,
final String[] foodIdNames,
final int[] recommendedServings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import java.util.List;

import hugo.weaving.DebugLog;
import timber.log.Timber;

@Table(name = "tweaks")
public class Tweak extends TruncatableModel implements RDA {
Expand Down Expand Up @@ -61,7 +61,6 @@ public String toString() {
return name;
}

@DebugLog
public static void ensureAllTweaksExistInDatabase(final String[] tweakNames,
final String[] tweakIdNames,
final int[] recommendedAmounts) {
Expand Down Expand Up @@ -110,7 +109,11 @@ private static void createTweakIfDoesNotExist(final String tweakName,
}

if (needToSave) {
tweak.save();
try {
tweak.save();
} catch (java.lang.SecurityException e) {
Timber.e(e, "Caught SecurityException in createTweakIfDoesNotExist");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.Map;
import java.util.Set;

import hugo.weaving.DebugLog;
import timber.log.Timber;

public class BackupTask extends BaseTask<Boolean> {
Expand Down Expand Up @@ -86,7 +85,6 @@ public void setDataAfterLoading(Boolean success) {
Bus.backupCompleteEvent(success);
}

@DebugLog
private String getDayJsonLine(Day day) {
final DayEntries dayEntries = new DayEntries();
dayEntries.setDate(day.getDateString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.TimeZone;

import hirondelle.date4j.DateTime;
import hugo.weaving.DebugLog;

public class GenerateDataTask extends BaseTask<Boolean> {
private final ProgressListener progressListener;
Expand Down Expand Up @@ -77,7 +76,6 @@ public void setDataAfterLoading(Boolean success) {
}
}

@DebugLog
private void createUserDataForDay(List<Food> allFoods, List<Tweak> allTweaks, DateTime current) {
ActiveAndroid.beginTransaction();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.io.LineNumberReader;
import java.util.Map;

import hugo.weaving.DebugLog;
import timber.log.Timber;

public class RestoreTask extends BaseTask<Boolean> {
Expand Down Expand Up @@ -118,12 +117,10 @@ public void setDataAfterLoading(Boolean success) {
Bus.restoreCompleteEvent(success);
}

@DebugLog
private void deleteAllExistingData() {
Common.truncateAllDatabaseTables();
}

@DebugLog
private void restoreLineCSV(final String[] headers, final String line) {
if (TextUtils.isEmpty(line)) {
return;
Expand Down Expand Up @@ -157,7 +154,6 @@ private void restoreLineCSV(final String[] headers, final String line) {
}
}

@DebugLog
private void restoreLineJSON(final String line) {
if (TextUtils.isEmpty(line)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static NotificationManager getNotificationManager(final Context context)
private static PendingIntent getUpdateReminderClickedIntent(final Context context) {
return TaskStackBuilder.create(context)
.addNextIntent(new Intent(context, MainActivity.class))
.getPendingIntent(UPDATE_REMINDER_ID, PendingIntent.FLAG_UPDATE_CURRENT);
.getPendingIntent(UPDATE_REMINDER_ID, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}

private static PendingIntent getNotificationSettingsClickedIntent(final Context context) {
Expand All @@ -79,7 +79,7 @@ private static PendingIntent getNotificationSettingsClickedIntent(final Context

return TaskStackBuilder.create(context)
.addNextIntent(openNotificationSettingsIntent)
.getPendingIntent(NOTIFICATION_SETTINGS_ID, PendingIntent.FLAG_UPDATE_CURRENT);
.getPendingIntent(NOTIFICATION_SETTINGS_ID, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}

public static void setAlarmForUpdateReminderNotification(final Context context, final UpdateReminderPref pref) {
Expand All @@ -93,16 +93,6 @@ public static void setAlarmForUpdateReminderNotification(final Context context,
final long alarmTimeInMillis = pref.getNextAlarmTimeInMillis(context);
Timber.d("setAlarmForUpdateReminderNotification: %s", alarmTimeInMillis);

setAlarm(alarmManager, alarmPendingIntent, alarmTimeInMillis);
}
}

private static void setAlarm(AlarmManager alarmManager, PendingIntent alarmPendingIntent, long alarmTimeInMillis) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, alarmTimeInMillis, alarmPendingIntent);
} else {
// Note: Beginning in API 19, the trigger time passed to this method is treated as inexact: the alarm
// will not be delivered before this time, but may be deferred and delivered some time later
alarmManager.set(AlarmManager.RTC_WAKEUP, alarmTimeInMillis, alarmPendingIntent);
}
}
Expand All @@ -119,7 +109,7 @@ private static PendingIntent getAlarmPendingIntent(Context context, UpdateRemind
intent.putExtra(Args.UPDATE_REMINDER_PREF, new Gson().toJson(pref));
}

return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}

public static void init(final Context context) {
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<TextView
android:text="@string/about_translators"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

</LinearLayout>

</androidx.cardview.widget.CardView>
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/res/values-bg/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<string name="moving_average">плъзгаща се средна</string>
<string name="about">Относно</string>
<string name="about_this_app">Информация за приложението</string>
<string name="about_translators">Специални благодарности на нашите преводачи доброволци: Ricard Soler Roger (ca), Luděk Bouška (cs,sk), Lenka Lukacová (cs), Anke Schliessmann (de), Ángela Graña (es), Doron Barak (he), Ruth Levy (he), Joanna Klopotek (pl), Tania Bassi (pt-BR), João Madureira (pt-PT), Evgeniya Lyakh (ru), Katarína Mocáková (sk).</string>
<string name="latest_videos">Най-новите видео клипове</string>
<string name="donate">Направете дарение</string>
<string name="subscribe">Абонирай се</string>
Expand Down Expand Up @@ -53,7 +54,7 @@
<string name="dialog_streaks_title">Нова функция: Линии!</string>
<string name="dialog_streaks_message">Вашата база данни ще бъде обновена, за да поддържа новата функция „линии“.</string>
<string name="dialog_no_email_apps_title">Няма намерени имейл приложения</string>
<string name="dialog_no_email_apps_message">Архивирането на данни изисква да имате инсталирано приложение за имейл, за да можете да изпратите csv файл по пощата. Моля инсталирайте имейл клиент и опитайте отново.</string>
<string name="dialog_no_email_apps_message">Архивирането на данни изисква да имате инсталирано приложение за имейл, за да можете да изпратите файл по пощата. Моля инсталирайте имейл клиент и опитайте отново.</string>
<string name="debug_generate_random_data">Генериране на случайни данни</string>
<string name="debug_generate_full_data">Генериране на пълна информация</string>
<string name="debug_generate_data_message">Всички съществуващи данни ще бъдат заменени. Желаете ли да продължите?</string>
Expand Down Expand Up @@ -466,12 +467,14 @@
</string-array>
<string-array name="food_info_serving_sizes_cruciferous_vegetables_imperial">
<item>½ чаша нарязани цветнолистни</item>
<item>¼ чаша брюкселско зеле или броколи</item>
<item>½ чаша брюкселско зеле</item>
<item>¼ чаша кълнове от броколи</item>
<item>1 супена лъжица хрян</item>
</string-array>
<string-array name="food_info_serving_sizes_cruciferous_vegetables_metric">
<item>30–80 грам нарязани цветнолистни</item>
<item>12 грам брюкселско зеле или броколи</item>
<item>78 грам брюкселско зеле</item>
<item>14 грам кълнове от броколи</item>
<item>1 супена лъжица хрян</item>
</string-array>
<string-array name="food_info_serving_sizes_greens_imperial">
Expand Down
Loading

0 comments on commit e8cd1de

Please sign in to comment.