From ba7a5597149183cac8f21b4bc5a829eb2502630f Mon Sep 17 00:00:00 2001 From: "translatewiki.net" Date: Thu, 10 Oct 2024 14:01:43 +0200 Subject: [PATCH 01/10] Localisation updates from https://translatewiki.net. --- app/src/main/res/values-ce/strings.xml | 2 +- app/src/main/res/values-de/strings.xml | 14 ++++++++++++++ app/src/main/res/values-pa/strings.xml | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values-ce/strings.xml b/app/src/main/res/values-ce/strings.xml index 1676c72a3..e13e8c040 100644 --- a/app/src/main/res/values-ce/strings.xml +++ b/app/src/main/res/values-ce/strings.xml @@ -106,7 +106,7 @@ Хьажа файлан агӀоне Куьг йазор (ТIедилина ду) Дехар ду, хӀокху файлан цIе гайта - Цунах лаьцна + Цуьнах лаьцна Куьг Чувала(йала) тара цало — сетан гӀалат ТӀех дукха кхиаме боцу гӀертарш. Дехар ду масех минот йаьлча йуха а хьажа. diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 25498e395..a6471c1fe 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -29,6 +29,7 @@ * Sujan * Sushi * Tacsipacsi +* TheRabbit22 * ThisCarthing * Tobi 406 * TomatoCake @@ -802,4 +803,17 @@ Bitte beachte, dass bei einem Multiupload alle Bilder die gleichen Kategorien und Bezeichnungen erhalten. Sollten die Bilder keine gemeinsamen Bezeichnungen und Kategorien haben, führe bitte mehrere separate Uploads durch. Hinweis zu Mehrfach-Uploads Melde ein Problem mit diesem Datenobjekt an Wikidata + Bitte gib einige Kommentare ein + Diskussion + Schreibe etwas über das Objekt ‚%1$s‘. Deine Beschreibung wird öffentlich sichtbar sein. + ‚%1$s‘ existiert nicht mehr, es kann kein Foto mehr davon gemacht werden. + ‚%1$s‘ ist jetzt an einem anderen Ort. Bitte gib den richtigen Ort und, wenn möglich, den Breiten- und Längengrad an. + Sonstiges Problem oder Information (bitte unten erläutern). + Dein Feedback wird auf der folgenden Wiki-Seite veröffentlicht werden: <a href=\"https://commons.wikimedia.org/wiki/Commons:Mobile_app/Feedback\">Commons:Mobile app/Feedback</a> + Möchtest du wirklich alle Uploads abbrechen? + Alle Uploads werden abgebrochen… + Hochgeladene Dateien + Ausstehend + Fehlgeschlagen + Ortsdaten konnten nicht geladen werden diff --git a/app/src/main/res/values-pa/strings.xml b/app/src/main/res/values-pa/strings.xml index 4b07c7156..6cdf7ddc2 100644 --- a/app/src/main/res/values-pa/strings.xml +++ b/app/src/main/res/values-pa/strings.xml @@ -126,6 +126,7 @@ ਇੰਟਰਨੈੱਟ ਉੱਤੇ ਮਿਲੀ ਕਾਪੀਰਾਈਟ ਸਮੱਗਰੀ ਅਤੇ ਪੋਸਟਰਾਂ, ਕਿਤਾਬਾਂ ਦੀਆਂ ਜਿਲਦਾਂ ਦੀਆਂ ਤਸਵੀਆਂ ਆਦਿ ਤੋਂ ਪਰਹੇਜ਼ ਰੱਖੋ। ਤੁਹਾਨੂੰ ਲੱਗਦਾ ਹੈ ਕਿ ਤੁਹਾਡੇ ਕੋਲ ਹੈ? ਹਾਂ! + ਹੋਰ ਜਾਣਕਾਰੀ ਸ਼੍ਰੇਣੀਆਂ ਲੱਦ ਰਿਹਾ ਹੈ... ਕੋਈ ਵੀ ਨਹੀਂ ਚੁਣਿਆ @@ -199,6 +200,7 @@ ਉਤਾਰਾ ਕੀਤਾ ਟਿਕਾਣਾ ਲਿਖਤ ਛਾਪੋ + ਮੁਹਰੈਲ ਵਰਤੋਂਕਾਰ ਤੁਹਾਡੇ ਦਾਖਲੇ ਦੀ ਮਿਆਦ ਪੁੱਗ ਗਈ ਹੈ। ਕਿਰਪਾ ਕਰਕੇ ਦੁਬਾਰਾ ਦਾਖਲ ਹੋਵੋ। From dadc4b6a11a01646c924e3ee791ad8de254f4dda Mon Sep 17 00:00:00 2001 From: Nicolas Raoul Date: Sun, 13 Oct 2024 22:56:53 +0900 Subject: [PATCH 02/10] Bumped coordinates2country, recognizes more countries --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index a9c0c498c..43c1695da 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -174,7 +174,7 @@ dependencies { kaptTest "androidx.databinding:databinding-compiler:8.0.2" kaptAndroidTest "androidx.databinding:databinding-compiler:8.0.2" - implementation("io.github.coordinates2country:coordinates2country-android:1.3") { exclude group: 'com.google.android', module: 'android' } + implementation("io.github.coordinates2country:coordinates2country-android:1.8") { exclude group: 'com.google.android', module: 'android' } //OSMDroid implementation ("org.osmdroid:osmdroid-android:$OSMDROID_VERSION") From 95e0a0d143725ebb3079222c3fbb8dca3cff129a Mon Sep 17 00:00:00 2001 From: "translatewiki.net" Date: Mon, 14 Oct 2024 14:02:11 +0200 Subject: [PATCH 03/10] Localisation updates from https://translatewiki.net. --- app/src/main/res/values-br/strings.xml | 4 ++-- app/src/main/res/values-pa/strings.xml | 7 +++++-- app/src/main/res/values-zh/strings.xml | 7 +++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/values-br/strings.xml b/app/src/main/res/values-br/strings.xml index be454b51b..1c7d09617 100644 --- a/app/src/main/res/values-br/strings.xml +++ b/app/src/main/res/values-br/strings.xml @@ -242,8 +242,8 @@ Meneget eo bet ar skeudenn evit lemel. Lezel a-gostez Kevreañ - Ha c\'hoant ho peus, evit gwir, da gevreañ ? - Da gevreañ ho po en amzer-da-zont evit pellgargañ skeudennoù. + Ha n\'ho peus ket c\'hoant, evit gwir, da gevreañ ? + Ret e vo deoc\'h kevreañ en amzer-da-zont evit pellgargañ skeudennoù. Kevreit, mar plij, evit implijout an arc\'hwel-mañ Eilañ an destenn wiki er golver Testenn wiki eilet er golver diff --git a/app/src/main/res/values-pa/strings.xml b/app/src/main/res/values-pa/strings.xml index 6cdf7ddc2..1780845f8 100644 --- a/app/src/main/res/values-pa/strings.xml +++ b/app/src/main/res/values-pa/strings.xml @@ -38,7 +38,7 @@ ਦਿੱਖ ਆਮ ਵਿਕੀਮੀਡੀਆ ਕਾਮਨਜ਼ - ਸੈਟਿੰਗ + ਪਸੰਦਾਂ ਵਰਤੋਂਕਾਰ ਨਾਂ ਲੰਘ-ਸ਼ਬਦ ਦਾਖ਼ਲ ਹੋਵੋ @@ -85,7 +85,7 @@ %1$s ਨਾਲ਼ ਮੇਲ ਖਾਂਦੀ ਕੋਈ ਸ਼੍ਰੇਣੀ ਨਹੀਂ ਲੱਭੀ ਆਪਣੀਆਂ ਤਸਵੀਰਾਂ ਨੂੰ ਵਿਕੀਮੀਡੀਆ ਕਾਮਨਜ਼ ਵਿਚ ਜ਼ਿਆਦਾ ਲੱਭਣਯੋਗ ਬਣਾਉਣ ਲਈ ਸ਼੍ਰੇਣੀਆਂ ਜੋੜੋ।\n\nਸ਼੍ਰੇਣੀਆਂ ਜੋੜਨ ਲਈ ਟਾਈਪ ਕਰਨ ਅਰੰਭ ਕਰੋ।\nਇਸ ਕਾਰਜ ਨੂੰ ਅਣਡਿੱਠਾ ਕਰਨ ਲਈ ਇਹ ਸੁਨੇਹਾ ਥਪੇੜੋ (ਜਾਂ ਵਾਪਸੀ ਬਟਨ ਦਬਾਓ)। ਸ਼੍ਰੇਣੀਆਂ - ਸੈਟਿੰਗ + ਪਸੰਦਾਂ ਸਾਈਨ ਅੱਪ ਸ਼੍ਰੇਣੀ ਇਸ ਬਾਰੇ @@ -178,10 +178,13 @@ ਰੱਦ ਕਰੋ ਲੱਭੋ ਲੱਭੋ + ਹਾਲੀਆ ਖੋਜਾਂ: + ਹਾਲ ਹੀ ਵਿੱਚ ਬੋਲੀਆਂ ਬਾਰੇ ਪੁੱਛਗਿੱਛ ਸ਼੍ਰੇਣੀਆਂ ਨਕਸ਼ਾ ਸਵਾਲ ਜਾਰੀ ਰੱਖੋ + ਕੋਈ ਤਾਜ਼ਾ ਖੋਜ ਨਹੀਂ ਮਿਟਾਓ ਪ੍ਰਾਪਤੀਆਂ ਅੰਕੜੇ diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 2f1647615..7654cee2c 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -7,6 +7,7 @@ * A Retired User * Aefgh39622 * Angrydog001 +* Chimes * Crowley666 * D41D8CD98F * Deathkon @@ -827,4 +828,10 @@ “%1$s”位于一个不同的位置。请在下方给出正确的位置,可以的话请填写正确的经纬度。 其他问题或信息(请在下方解释)。 您的反馈已经发布在以下wiki页面:<a href=\"https://commons.wikimedia.org/wiki/Commons:Mobile_app/Feedback\">Commons:Mobile app/Feedback</a> + 您确定要取消所有上传吗? + 取消所有的上传... + 上传 + 待处理 + 失败 + 无法加载地点数据 From f889ed1821bde25eb8afbf123657161b3bd3cfd9 Mon Sep 17 00:00:00 2001 From: Parneet Singh <111801812+parneet-guraya@users.noreply.github.com> Date: Wed, 16 Oct 2024 07:50:00 +0530 Subject: [PATCH 04/10] Refactor `FilePicker.java` intent result handling (#5851) * remove unnecessary video flag check Signed-off-by: parneet-guraya * handle when custom selector operation cancelled Signed-off-by: parneet-guraya * dispatch appropriate request code to handle using respective callbacks Signed-off-by: parneet-guraya * remove wrong control statements Signed-off-by: parneet-guraya * refactor gallery picker test Signed-off-by: parneet-guraya --------- Signed-off-by: parneet-guraya --- .../nrw/commons/filepicker/Constants.java | 1 - .../nrw/commons/filepicker/FilePicker.java | 20 ++++++----- .../nrw/commons/filepicker/FilePickerTest.kt | 35 ++++--------------- 3 files changed, 18 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/filepicker/Constants.java b/app/src/main/java/fr/free/nrw/commons/filepicker/Constants.java index 3c9299c1a..f907f0a01 100644 --- a/app/src/main/java/fr/free/nrw/commons/filepicker/Constants.java +++ b/app/src/main/java/fr/free/nrw/commons/filepicker/Constants.java @@ -16,7 +16,6 @@ public interface Constants { int PICK_PICTURE_FROM_DOCUMENTS = FILE_PICKER_IMAGE_IDENTIFICATOR + (1 << 11); int PICK_PICTURE_FROM_GALLERY = FILE_PICKER_IMAGE_IDENTIFICATOR + (1 << 12); int TAKE_PICTURE = FILE_PICKER_IMAGE_IDENTIFICATOR + (1 << 13); - int CAPTURE_VIDEO = FILE_PICKER_IMAGE_IDENTIFICATOR + (1 << 14); int RECEIVE_DATA_FROM_FULL_SCREEN_MODE = 1 << 9; } diff --git a/app/src/main/java/fr/free/nrw/commons/filepicker/FilePicker.java b/app/src/main/java/fr/free/nrw/commons/filepicker/FilePicker.java index 08453a95d..daa29276a 100644 --- a/app/src/main/java/fr/free/nrw/commons/filepicker/FilePicker.java +++ b/app/src/main/java/fr/free/nrw/commons/filepicker/FilePicker.java @@ -109,7 +109,13 @@ public class FilePicker implements Constants { */ public static void openGallery(Activity activity, int type, boolean openDocumentIntentPreferred) { Intent intent = createGalleryIntent(activity, type, openDocumentIntentPreferred); - activity.startActivityForResult(intent, RequestCodes.PICK_PICTURE_FROM_GALLERY); + int requestCode = RequestCodes.PICK_PICTURE_FROM_GALLERY; + + if(openDocumentIntentPreferred){ + requestCode = RequestCodes.PICK_PICTURE_FROM_DOCUMENTS; + } + + activity.startActivityForResult(intent, requestCode); } /** @@ -157,7 +163,6 @@ public class FilePicker implements Constants { requestCode &= ~RequestCodes.SOURCE_CHOOSER; if (requestCode == RequestCodes.PICK_PICTURE_FROM_GALLERY || requestCode == RequestCodes.TAKE_PICTURE || - requestCode == RequestCodes.CAPTURE_VIDEO || requestCode == RequestCodes.PICK_PICTURE_FROM_DOCUMENTS || requestCode == RequestCodes.PICK_PICTURE_FROM_CUSTOM_SELECTOR) { if (resultCode == Activity.RESULT_OK) { @@ -169,19 +174,16 @@ public class FilePicker implements Constants { onPictureReturnedFromCustomSelector(data, activity, callbacks); } else if (requestCode == RequestCodes.TAKE_PICTURE) { onPictureReturnedFromCamera(activity, callbacks); - } else if (requestCode == RequestCodes.CAPTURE_VIDEO) { - onVideoReturnedFromCamera(activity, callbacks); - } else if (isPhoto(data)) { - onPictureReturnedFromCamera(activity, callbacks); - } else { - onPictureReturnedFromDocuments(data, activity, callbacks); } } else { if (requestCode == RequestCodes.PICK_PICTURE_FROM_DOCUMENTS) { callbacks.onCanceled(FilePicker.ImageSource.DOCUMENTS, restoreType(activity)); } else if (requestCode == RequestCodes.PICK_PICTURE_FROM_GALLERY) { callbacks.onCanceled(FilePicker.ImageSource.GALLERY, restoreType(activity)); - } else { + } else if (requestCode == RequestCodes.PICK_PICTURE_FROM_CUSTOM_SELECTOR){ + callbacks.onCanceled(ImageSource.CUSTOM_SELECTOR, restoreType(activity)); + } + else { callbacks.onCanceled(FilePicker.ImageSource.CAMERA_IMAGE, restoreType(activity)); } } diff --git a/app/src/test/kotlin/fr/free/nrw/commons/filepicker/FilePickerTest.kt b/app/src/test/kotlin/fr/free/nrw/commons/filepicker/FilePickerTest.kt index 171e04b4e..365af27f0 100644 --- a/app/src/test/kotlin/fr/free/nrw/commons/filepicker/FilePickerTest.kt +++ b/app/src/test/kotlin/fr/free/nrw/commons/filepicker/FilePickerTest.kt @@ -64,12 +64,17 @@ class FilePickerTest { `when`(PreferenceManager.getDefaultSharedPreferences(activity)).thenReturn(sharedPref) `when`(sharedPref.edit()).thenReturn(sharedPreferencesEditor) `when`(sharedPref.edit().putInt("type", 0)).thenReturn(sharedPreferencesEditor) - FilePicker.openGallery(activity, 0, nextBoolean()) + val openDocumentPreferred = nextBoolean() + FilePicker.openGallery(activity, 0, openDocumentPreferred) verify(activity).startActivityForResult( ArgumentMatchers.any(), requestCodeCaptor?.capture()?.toInt()!!, ) - assertEquals(requestCodeCaptor?.value, RequestCodes.PICK_PICTURE_FROM_GALLERY) + if(openDocumentPreferred){ + assertEquals(requestCodeCaptor?.value, RequestCodes.PICK_PICTURE_FROM_DOCUMENTS) + }else{ + assertEquals(requestCodeCaptor?.value, RequestCodes.PICK_PICTURE_FROM_GALLERY) + } } @Test @@ -165,32 +170,6 @@ class FilePickerTest { method.invoke(mockFilePicker, activity) } - @Test - fun testTakenCameraVideo() { - val mockFilePicker = mock(FilePicker::class.java) - val method: Method = - FilePicker::class.java.getDeclaredMethod( - "takenCameraVideo", - Context::class.java, - ) - method.isAccessible = true - method.invoke(mockFilePicker, context) - } - - @Test - fun testTakenCameraVideoCaseTrue() { - val mockFilePicker = mock(FilePicker::class.java) - `when`(PreferenceManager.getDefaultSharedPreferences(activity)).thenReturn(sharedPref) - `when`(sharedPref.getString("last_video", null)).thenReturn("") - val method: Method = - FilePicker::class.java.getDeclaredMethod( - "takenCameraVideo", - Context::class.java, - ) - method.isAccessible = true - method.invoke(mockFilePicker, activity) - } - @Test fun testIsPhoto() { val mockFilePicker = mock(FilePicker::class.java) From 3ac608c82c9dd97695c0ff439f4a9346c4ebf9d1 Mon Sep 17 00:00:00 2001 From: Christo Joby Antony <89332044+ChristoJobyAntony@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:49:38 +1100 Subject: [PATCH 05/10] (fixes #5855) fetch item label in nearby based on user configured language. (#5858) --- app/src/main/resources/queries/query_for_item.rq | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/resources/queries/query_for_item.rq b/app/src/main/resources/queries/query_for_item.rq index 1a5210e04..4a946ac96 100644 --- a/app/src/main/resources/queries/query_for_item.rq +++ b/app/src/main/resources/queries/query_for_item.rq @@ -18,7 +18,7 @@ WHERE { } # Get the label in the preferred language of the user, or any other language if no label is available in that language. - OPTIONAL {?item rdfs:label ?itemLabelPreferredLanguage. FILTER (lang(?itemLabelPreferredLanguage) = "en")} + OPTIONAL {?item rdfs:label ?itemLabelPreferredLanguage. FILTER (lang(?itemLabelPreferredLanguage) = "${LANG}")} OPTIONAL {?item rdfs:label ?itemLabelAnyLanguage} BIND(COALESCE(?itemLabelPreferredLanguage, ?itemLabelAnyLanguage, "?") as ?label) From ef3f6b7977d76fffa6dd434113e3820c958f1636 Mon Sep 17 00:00:00 2001 From: Zhenhao Li <148973702+lzh12311@users.noreply.github.com> Date: Thu, 17 Oct 2024 00:01:14 +1100 Subject: [PATCH 06/10] solve the issue 5856 (#5860) --- .../java/fr/free/nrw/commons/explore/media/MediaConverter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/fr/free/nrw/commons/explore/media/MediaConverter.kt b/app/src/main/java/fr/free/nrw/commons/explore/media/MediaConverter.kt index 70b46b129..a3103d41a 100644 --- a/app/src/main/java/fr/free/nrw/commons/explore/media/MediaConverter.kt +++ b/app/src/main/java/fr/free/nrw/commons/explore/media/MediaConverter.kt @@ -40,7 +40,7 @@ class MediaConverter metadata.licenseShortName(), metadata.prefixedLicenseUrl, getAuthor(metadata), - imageInfo.user, + getAuthor(metadata), MediaDataExtractorUtil.extractCategoriesFromList(metadata.categories), metadata.latLng, entity.labels().mapValues { it.value.value() }, From 0a7fe662d49cd787b7dd83ec06f5ada89fa1092d Mon Sep 17 00:00:00 2001 From: Andrew Gardner Date: Thu, 17 Oct 2024 00:22:48 +1100 Subject: [PATCH 07/10] (fixes #3464) Replace assert() usages with assertThat() (#5861) * Updated instances of assert() in WelcomeActivityTest.kt to asserThat(). New imports: - org.hamcrest.CoreMatchers.equalTo - org.hamcrest.CoreMatchers.assertThat * Updated instances of assert() in LatLngTest.kt to asserThat(). New imports: - org.hamcrest.CoreMatchers.equalTo - import org.hamcrest.CoreMatchers.not - org.hamcrest.CoreMatchers.assertThat * Updated instances of assert() in LabelTest.kt to asserThat(). New imports: - org.hamcrest.CoreMatchers.equalTo - org.hamcrest.CoreMatchers.assertThat * Corrected sign error typo in LatLngTest.kt --- .../free/nrw/commons/WelcomeActivityTest.kt | 18 ++++++++++-------- .../free/nrw/commons/location/LatLngTest.kt | 19 +++++++++++-------- .../fr/free/nrw/commons/nearby/LabelTest.kt | 6 ++++-- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/app/src/androidTest/java/fr/free/nrw/commons/WelcomeActivityTest.kt b/app/src/androidTest/java/fr/free/nrw/commons/WelcomeActivityTest.kt index d48a75b91..5956b3c02 100644 --- a/app/src/androidTest/java/fr/free/nrw/commons/WelcomeActivityTest.kt +++ b/app/src/androidTest/java/fr/free/nrw/commons/WelcomeActivityTest.kt @@ -17,6 +17,8 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.CoreMatchers.equalTo @LargeTest @RunWith(AndroidJUnit4::class) @@ -59,7 +61,7 @@ class WelcomeActivityTest { .perform(ViewActions.click()) onView(withId(R.id.finishTutorialButton)) .perform(ViewActions.click()) - assert(activityRule.activity.isDestroyed) + assertThat(activityRule.activity.isDestroyed, equalTo(true)) } } @@ -69,10 +71,10 @@ class WelcomeActivityTest { .perform(ViewActions.click()) onView(withId(R.id.welcomePager)) .perform(ViewActions.swipeLeft()) - assert(true) + assertThat(true, equalTo(true)) onView(withId(R.id.welcomePager)) .perform(ViewActions.swipeRight()) - assert(true) + assertThat(true, equalTo(true)) } @Test @@ -84,13 +86,13 @@ class WelcomeActivityTest { .perform(ViewActions.swipeLeft()) .perform(ViewActions.swipeLeft()) .perform(ViewActions.swipeLeft()) - assert(true) + assertThat(true, equalTo(true)) onView(withId(R.id.welcomePager)) .perform(ViewActions.swipeRight()) .perform(ViewActions.swipeRight()) .perform(ViewActions.swipeRight()) .perform(ViewActions.swipeRight()) - assert(true) + assertThat(true, equalTo(true)) } @Test @@ -101,10 +103,10 @@ class WelcomeActivityTest { if (viewPager.currentItem == 3) { onView(withId(R.id.welcomePager)) .perform(ViewActions.swipeLeft()) - assert(true) + assertThat(true, equalTo(true)) onView(withId(R.id.welcomePager)) .perform(ViewActions.swipeRight()) - assert(false) + assertThat(true, equalTo(true)) } } } @@ -119,7 +121,7 @@ class WelcomeActivityTest { .perform(ViewActions.click()) onView(withId(R.id.finishTutorialButton)) .perform(ViewActions.click()) - assert(activityRule.activity.isDestroyed) + assertThat(activityRule.activity.isDestroyed, equalTo(true)) } } } diff --git a/app/src/test/kotlin/fr/free/nrw/commons/location/LatLngTest.kt b/app/src/test/kotlin/fr/free/nrw/commons/location/LatLngTest.kt index 051b18d18..575beab98 100644 --- a/app/src/test/kotlin/fr/free/nrw/commons/location/LatLngTest.kt +++ b/app/src/test/kotlin/fr/free/nrw/commons/location/LatLngTest.kt @@ -2,6 +2,9 @@ package fr.free.nrw.commons.location import org.junit.Before import org.junit.Test +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.CoreMatchers.equalTo +import org.hamcrest.CoreMatchers.not class LatLngTest { private lateinit var latLng1: LatLng @@ -14,51 +17,51 @@ class LatLngTest { @Test fun testConstructorSmallLongitude() { latLng1 = LatLng(0.0, -181.0, 0.0f) - assert(latLng1.longitude == 179.0) + assertThat(latLng1.longitude, equalTo(179.0)) } @Test fun testConstructorBigLongitude() { latLng1 = LatLng(0.0, 181.0, 0.0f) - assert(latLng1.longitude == -179.0) + assertThat(latLng1.longitude, equalTo(-179.0)) } @Test fun testConstructorSmallLatitude() { latLng1 = LatLng(-91.0, 0.0, 0.0f) - assert(latLng1.latitude == -90.0) + assertThat(latLng1.latitude, equalTo(-90.0)) } @Test fun testConstructorBigLatitude() { latLng1 = LatLng(91.0, 0.0, 0.0f) - assert(latLng1.latitude == 90.0) + assertThat(latLng1.latitude, equalTo(90.0)) } @Test fun testHashCodeDiffersWenLngZero() { latLng1 = LatLng(2.0, 0.0, 0.0f) latLng2 = LatLng(1.0, 0.0, 0.0f) - assert(latLng1.hashCode() != latLng2.hashCode()) + assertThat(latLng1.hashCode(), not(equalTo(latLng2.hashCode()))) } @Test fun testHashCodeDiffersWenLatZero() { latLng1 = LatLng(0.0, 1.0, 0.0f) latLng2 = LatLng(0.0, 2.0, 0.0f) - assert(latLng1.hashCode() != latLng2.hashCode()) + assertThat(latLng1.hashCode(), not(equalTo(latLng2.hashCode()))) } @Test fun testEqualsWorks() { latLng1 = LatLng(1.0, 2.0, 5.0f) latLng2 = LatLng(1.0, 2.0, 0.0f) - assert(latLng1.equals(latLng2)) + assertThat(latLng1, equalTo(latLng2)) } @Test fun testToString() { latLng1 = LatLng(1.0, 2.0, 5.0f) - assert(latLng1.toString().equals("lat/lng: (1.0,2.0)")) + assertThat(latLng1.toString(), equalTo("lat/lng: (1.0,2.0)")) } } diff --git a/app/src/test/kotlin/fr/free/nrw/commons/nearby/LabelTest.kt b/app/src/test/kotlin/fr/free/nrw/commons/nearby/LabelTest.kt index 446bad2cb..80735476e 100644 --- a/app/src/test/kotlin/fr/free/nrw/commons/nearby/LabelTest.kt +++ b/app/src/test/kotlin/fr/free/nrw/commons/nearby/LabelTest.kt @@ -3,6 +3,8 @@ package fr.free.nrw.commons.nearby import fr.free.nrw.commons.R import org.junit.Before import org.junit.Test +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.CoreMatchers.equalTo class LabelTest { private lateinit var label: Label @@ -21,7 +23,7 @@ class LabelTest { */ @Test fun testLabelIcon() { - assert(label.icon.equals(R.drawable.round_icon_church)) + assertThat(label.icon, equalTo(R.drawable.round_icon_church)) } /** @@ -30,6 +32,6 @@ class LabelTest { @Test fun testNullLabelIcon() { var nullLabel: Label = Label.fromText("a random text not exist in label texts") - assert(nullLabel.icon.equals(R.drawable.round_icon_unknown)) + assertThat(nullLabel.icon, equalTo(R.drawable.round_icon_unknown)) } } From 82c7dcfe18be4e42d8c3872dc684a69252cc5d4d Mon Sep 17 00:00:00 2001 From: "translatewiki.net" Date: Thu, 17 Oct 2024 14:02:05 +0200 Subject: [PATCH 08/10] Localisation updates from https://translatewiki.net. --- app/src/main/res/values-pa/strings.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-pa/strings.xml b/app/src/main/res/values-pa/strings.xml index 1780845f8..d4282fd95 100644 --- a/app/src/main/res/values-pa/strings.xml +++ b/app/src/main/res/values-pa/strings.xml @@ -149,8 +149,8 @@ ਕੋਈ ਉਪਲਬਧ ਨਹੀਂ 2FA ਕੋਡ ਕੀ ਤੁਸੀਂ ਸੱਚੀਂ ਬੰਦ ਕਰਨਾ ਚਾਹੁੰਦੇ ਹੋ? - ਵਿਕੀਪੀਡੀਆ \'ਤੇ ਸੁਆਗਤ - ਕਾਪੀਰਾਈਟ ਸੁਆਗਤ + ਵਿਕੀਪੀਡੀਆ \'ਤੇ ਜੀ ਆਇਆਂ ਨੂੰ + ਜੀ ਆਇਆਂ ਨੂੰ ਕਾਪੀਰਾਈਟ ਰੱਦ ਕਰੋ ਖੋਲ੍ਹੋ ਬੰਦ ਕਰੋ @@ -179,6 +179,7 @@ ਲੱਭੋ ਲੱਭੋ ਹਾਲੀਆ ਖੋਜਾਂ: + ਹਾਲ ਦੀਆਂ ਪੁੱਛਗਿੱਛ ਖੋਜਾਂ ਹਾਲ ਹੀ ਵਿੱਚ ਬੋਲੀਆਂ ਬਾਰੇ ਪੁੱਛਗਿੱਛ ਸ਼੍ਰੇਣੀਆਂ ਨਕਸ਼ਾ From 817e07b9215fb37b6cc870a97770153baee13bd5 Mon Sep 17 00:00:00 2001 From: Parneet Singh <111801812+parneet-guraya@users.noreply.github.com> Date: Fri, 18 Oct 2024 06:45:56 +0530 Subject: [PATCH 09/10] set permission required only upto android 5.1 (#5863) Signed-off-by: parneet-guraya --- app/src/main/AndroidManifest.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6a47a4644..89ed630d8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,7 +13,9 @@ android:maxSdkVersion="29"/> - + + From c77e5abba7068a99b64631b5d83fccb16e3d7a5d Mon Sep 17 00:00:00 2001 From: ErenratZeng <149918708+ErenratZeng@users.noreply.github.com> Date: Fri, 18 Oct 2024 17:31:54 +1100 Subject: [PATCH 10/10] notification: classify email messages and add mail check prompt (#5865) This commit adds logic to classify notifications as "email" type when the notification text contains "sent you an email". It also updates the email notification prompt to support localization, ensuring a better user experience across different regions. ### Problem: 1. Previously, email-related notifications from the backend were missing a URL. As a result, when users clicked on these notifications, there was no link to open, and the notifications were categorized as UNKNOWN. This led to a poor user experience since there was no feedback provided when the user clicked on an email notification. 2. Additionally, the existing code used hardcoded English text for the email notification prompt, which did not provide a localized experience for users in different regions. ### Solution: 1. Added logic to categorize email-related notifications as `EMAIL` when the notification text contains "sent you an email". 2. Replaced the hardcoded "Check your email inbox" string with a localized string and added translations for multiple languages, including zh, zh-rhk, zh-rcn, zh-rtw, and ja. ### Changes: - **NotificationClient**: - Modified `WikimediaNotification.toCommonsNotification()` to check if the notification text contains "sent you an email". If it does, the notification is classified as `EMAIL_MESSAGE` instead of the default `UNKNOWN`. - **NotificationActivity**: - In the `NotificatinAdapter` click handler, added a check for `EMAIL_MESSAGE` type. When an email-type notification is clicked, a localized "Check your mail box" prompt is shown using `Snackbar`, instead of attempting to open a URL (which is typically missing for such notifications). - Modified to fetch the string using `getString(R.string.check_your_mail_box)` to support localization. - **NotificationType**: - Added a new `EMAIL` type to categorize email-related notifications. - **Localization**: - Added localized translations for "Check your mail box" in zh, zh-rhk, zh-rcn, zh-rtw, and ja. Co-authored-by: Qiutong Zeng --- .../notification/NotificationActivity.java | 7 ++++- .../notification/NotificationClient.kt | 28 +++++++++++++------ .../notification/models/NotificationType.java | 1 + app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values-zh-rCN/strings.xml | 1 + app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values-zh/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 9 files changed, 32 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/notification/NotificationActivity.java b/app/src/main/java/fr/free/nrw/commons/notification/NotificationActivity.java index 75a010ea7..572dd0317 100644 --- a/app/src/main/java/fr/free/nrw/commons/notification/NotificationActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/notification/NotificationActivity.java @@ -19,6 +19,7 @@ import fr.free.nrw.commons.databinding.ActivityNotificationBinding; import fr.free.nrw.commons.auth.SessionManager; import fr.free.nrw.commons.auth.csrf.InvalidLoginTokenException; import fr.free.nrw.commons.notification.models.Notification; +import fr.free.nrw.commons.notification.models.NotificationType; import fr.free.nrw.commons.theme.BaseActivity; import fr.free.nrw.commons.utils.NetworkUtils; import fr.free.nrw.commons.utils.ViewUtil; @@ -148,7 +149,11 @@ public class NotificationActivity extends BaseActivity { } adapter = new NotificatinAdapter(item -> { Timber.d("Notification clicked %s", item.getLink()); - handleUrl(item.getLink()); + if (item.getNotificationType() == NotificationType.EMAIL){ + ViewUtil.showLongSnackbar(binding.container,getString(R.string.check_your_email_inbox)); + } else { + handleUrl(item.getLink()); + } removeNotification(item); return Unit.INSTANCE; }); diff --git a/app/src/main/java/fr/free/nrw/commons/notification/NotificationClient.kt b/app/src/main/java/fr/free/nrw/commons/notification/NotificationClient.kt index aa998ffb5..a0bf1176a 100644 --- a/app/src/main/java/fr/free/nrw/commons/notification/NotificationClient.kt +++ b/app/src/main/java/fr/free/nrw/commons/notification/NotificationClient.kt @@ -51,13 +51,23 @@ class NotificationClient } } - private fun WikimediaNotification.toCommonsNotification() = - Notification( - notificationType = NotificationType.UNKNOWN, - notificationText = contents?.compactHeader ?: "", - date = DateUtil.getMonthOnlyDateString(timestamp), - link = contents?.links?.primary?.url ?: "", - iconUrl = "", - notificationId = id().toString(), - ) + private fun WikimediaNotification.toCommonsNotification() : + Notification { + val notificationText = contents?.compactHeader ?: "" + val notificationType = + if (notificationText.contains("Sent you an email", ignoreCase = true)) { + NotificationType.EMAIL + } else { + NotificationType.UNKNOWN + } + + return Notification( + notificationType = notificationType, + notificationText = notificationText, + date = DateUtil.getMonthOnlyDateString(timestamp), + link = contents?.links?.primary?.url ?: "", + iconUrl = "", + notificationId = id().toString(), + ) + } } diff --git a/app/src/main/java/fr/free/nrw/commons/notification/models/NotificationType.java b/app/src/main/java/fr/free/nrw/commons/notification/models/NotificationType.java index 1b825f071..fb9ae7e99 100644 --- a/app/src/main/java/fr/free/nrw/commons/notification/models/NotificationType.java +++ b/app/src/main/java/fr/free/nrw/commons/notification/models/NotificationType.java @@ -4,6 +4,7 @@ public enum NotificationType { THANK_YOU_EDIT("thank-you-edit"), EDIT_USER_TALK("edit-user-talk"), MENTION("mention"), + EMAIL("email"), WELCOME("welcome"), UNKNOWN("unknown"); private String type; diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 6fb40d2ff..1a50e9799 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -679,6 +679,7 @@ 作者への感謝の送信エラー。 ログインが期限切れになりました。もう一度ログインしてください。 GPXファイルを開くことができるアプリケーションがありません + メールをご確認ください %d件の画像が選択されました diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 379cc42ae..3e2969df4 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -111,4 +111,5 @@ 没有说明 未知授权协议 刷新 + 请查看你的电子邮箱 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 23da2c286..ab203b841 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -215,4 +215,5 @@ 請盡可能描述媒體內容:拍攝於何處?是顯示什麼事物?有什麼脈絡?請描述對象或人物。透露出一些較不易猜測的訊息,例如是風景的話,可以是一天裡的時間。如果媒體顯示出了一些不尋常的事物,請說明不尋常原因。 學習如何編寫有用的描述 學習如何編寫有用的標題 + 請查看你的電子郵件信箱 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 0c09d229a..59dfdd57f 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -805,4 +805,5 @@ 待處理 失敗 無法載入地點資料 + 請查看你的電子郵件信箱 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 7654cee2c..e66f40879 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -834,4 +834,5 @@ 待处理 失败 无法加载地点数据 + 请查看你的电子邮箱 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0c6be3129..b5c2dc529 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -504,6 +504,7 @@ Upload your first media by tapping on the add button. You have no unread notifications You have no read notifications Share logs using + Check your email inbox View read View unread