Skip to content

Commit

Permalink
Merge branch 'master' into l10n_master
Browse files Browse the repository at this point in the history
  • Loading branch information
flauschtrud committed May 7, 2024
2 parents dde0531 + f34a7b3 commit 72a72f0
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 20 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Available languages so far:
- Chinese (thanks a lot to [leongjs98](https://github.com/leongjs98) for your help!)
- Serbian (Latin) (thanks a lot to [dimipage](https://github.com/dimipage) for your help!)
- Turkish (thanks a lot to [mikropsoft](https://github.com/mikropsoft) for your help!)
- Hebrew (thanks a lot to Eldar for your help!)

### Seasonal Calendars
If you want to contribute by researching data for additional seasonal calendars please contact me.
16 changes: 8 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ android {
}
namespace 'com.flauschcode.broccoli'
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}

Expand All @@ -97,9 +97,9 @@ dependencies {

implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0'
runtimeOnly group: 'com.google.android.material', name: 'material', version: '1.11.0'
runtimeOnly group: 'com.google.android.material', name: 'material', version: '1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

def nav_version = "2.7.7"
Expand All @@ -115,7 +115,7 @@ dependencies {
annotationProcessor "androidx.room:room-compiler:$room_version"
testImplementation "androidx.room:room-testing:$room_version"

def fragment_version = "1.6.2"
def fragment_version = "1.7.0"
implementation "androidx.fragment:fragment:$fragment_version"
debugImplementation ("androidx.fragment:fragment-testing:$fragment_version"){
exclude group: 'androidx.test', module : 'core'
Expand Down Expand Up @@ -143,14 +143,14 @@ dependencies {

implementation "com.mikepenz:aboutlibraries:10.6.3"

def jackson_version = "2.10.1"
def jackson_version = "2.15.4"
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version"

implementation group: 'commons-io', name: 'commons-io', version: '2.11.0'
implementation group: 'commons-io', name: 'commons-io', version: '2.13.0'

def mockito_version = "5.3.1"
def mockito_version = "5.7.0"
testImplementation 'junit:junit:4.13.2'
testImplementation "org.mockito:mockito-core:$mockito_version"
testImplementation 'org.hamcrest:hamcrest:2.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public LiveData<List<Recipe>> find(SearchCriteria criteria) {
String searchTerm = criteria.getSearchTerm();

if (!criteria.getSeasonalTerms().isEmpty()) {
String wildcardQuery = String.format("%s*", searchTerm);
String wildcardQuery = getSanitizedWildcardQuery(searchTerm);
String seasonalTerm = buildQueryFor(criteria.getSeasonalTerms());
return "".equals(searchTerm)? recipeDAO.findSeasonal(seasonalTerm) : recipeDAO.searchForSeasonal(seasonalTerm, wildcardQuery);
}
Expand Down Expand Up @@ -70,12 +70,12 @@ private LiveData<List<Recipe>> filterBy(Category category) {
}

private LiveData<List<Recipe>> searchFor(String term, List<Boolean> favoritesList) {
String wildcardQuery = String.format("%s*", term);
String wildcardQuery = getSanitizedWildcardQuery(term);
return recipeDAO.searchFor(wildcardQuery, favoritesList);
}

private LiveData<List<Recipe>> filterByAndSearchFor(Category category, String term) {
String wildcardQuery = String.format("%s*", term);
String wildcardQuery = getSanitizedWildcardQuery(term);
return recipeDAO.filterByAndSearchFor(category.getCategoryId(), wildcardQuery);
}

Expand All @@ -84,7 +84,7 @@ private LiveData<List<Recipe>> findUnassigned() {
}

private LiveData<List<Recipe>> searchForUnassigned(String term) {
String wildcardQuery = String.format("%s*", term);
String wildcardQuery = getSanitizedWildcardQuery(term);
return recipeDAO.searchForUnassigned(wildcardQuery);
}

Expand All @@ -94,11 +94,17 @@ private LiveData<List<Recipe>> findSeasonal() {
}

private LiveData<List<Recipe>> searchForSeasonal(String term) {
String wildcardQuery = String.format("%s*", term);
String wildcardQuery = getSanitizedWildcardQuery(term);
String seasonalSearchTerm = getSeasonalSearchTerm();
return recipeDAO.searchForSeasonal(seasonalSearchTerm, wildcardQuery);
}

private static String getSanitizedWildcardQuery(String term) {
String trailingDashesRemoved = term.replaceFirst("^-+", "");
String quotesEscaped = trailingDashesRemoved.replace("\"", "");
return String.format("%s*", quotesEscaped);
}

private String getSeasonalSearchTerm() {
Optional<SeasonalCalendar> seasonalCalendarOptional = seasonalCalendarHolder.get();
if (seasonalCalendarOptional.isPresent()) {
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/res/raw/central_europe.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,22 @@
{
"name": "sweet_potato",
"months": [8,9]
},
{
"name": "blackberries",
"months": [6,7,8]
},
{
"name": "mirabelles",
"months": [6,7,8]
},
{
"name": "gooseberries",
"months": [5,6,7]
},
{
"name": "lambs_lettuce",
"months": [9,10,11,0,1,2]
}
]
}
8 changes: 8 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,12 @@
<string name="turkish">Türkisch</string>
<string name="serbian_latin">Serbisch (lateinisch)</string>
<string name="hebrew">Hebräisch</string>
<string name="blackberries">Brombeeren</string>
<string name="mirabelles">Mirabellen</string>
<string name="gooseberries">Stachelbeeren</string>
<string name="lambs_lettuce">Feldsalat</string>
<string name="blackberries_terms">Brombeeren</string>
<string name="mirabelles_terms">Mirabellen</string>
<string name="gooseberries_terms">Stachelbeeren</string>
<string name="lambs_lettuce_terms">Feldsalat</string>
</resources>
8 changes: 8 additions & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,12 @@
<string name="turkish">Turco</string>
<string name="serbian_latin">Serbio (latín)</string>
<string name="hebrew">Hebreo</string>
<string name="blackberries">Moras</string>
<string name="mirabelles">Mirabeles</string>
<string name="gooseberries">Grosellas</string>
<string name="lambs_lettuce">Hojas de canónigos</string>
<string name="blackberries_terms">moras</string>
<string name="mirabelles_terms">mirabeles</string>
<string name="gooseberries_terms">grosellas</string>
<string name="lambs_lettuce_terms">hojas de canónigos</string>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,4 @@
<string name="gooseberries_terms">groseilles à maquereau</string>
<string name="lambs_lettuce">Mâche</string>
<string name="lambs_lettuce_terms">mâche</string>
</resources>
</resources>
12 changes: 12 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,16 @@

<string name="raspberries">Raspberries</string>
<string name="raspberries_terms">raspberries</string>

<string name="blackberries">Blackberries</string>
<string name="blackberries_terms">blackberries</string>

<string name="mirabelles">Mirabelles</string>
<string name="mirabelles_terms">mirabelles</string>

<string name="gooseberries">Gooseberries</string>
<string name="gooseberries_terms">gooseberries</string>

<string name="lambs_lettuce">Lamb\'s lettuce</string>
<string name="lambs_lettuce_terms">lamb\'s lettuce</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.app.Application;
import android.icu.util.ULocale;

import androidx.lifecycle.LiveData;

import com.flauschcode.broccoli.R;
import com.flauschcode.broccoli.category.Category;
import com.flauschcode.broccoli.category.CategoryRepository;
import com.flauschcode.broccoli.recipe.images.RecipeImageService;
Expand Down Expand Up @@ -145,6 +141,21 @@ public void search_for() {
assertThat(result, is(recipes));
}

@Test
public void search_for_leading_hyphen() {
when(recipeDAO.searchFor(eq("bla blupp*"), favoriteStatesCaptor.capture())).thenReturn(recipes);

criteria.setSearchTerm("-bla \"blupp\"");

LiveData<List<Recipe>> result = recipeRepository.find(criteria);

List<Boolean> favoriteStates = favoriteStatesCaptor.getValue();
assertThat(favoriteStates.size(), is(2));
assertThat(favoriteStates, hasItem(Boolean.TRUE));
assertThat(favoriteStates, hasItem(Boolean.FALSE));
assertThat(result, is(recipes));
}

@Test
public void search_in_favorites() {
when(recipeDAO.searchFor(eq("bla*"), favoriteStatesCaptor.capture())).thenReturn(recipes);
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.4'
classpath 'com.android.tools.build:gradle:8.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Apr 25 17:06:41 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

0 comments on commit 72a72f0

Please sign in to comment.