Skip to content

Merge 4.0-release into master #5028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8b75c41
Fix string for custom selector
misaochan Apr 29, 2022
9880d7e
Fix bug #4950 back arrow still present on top-level activity (#4952)
madhurgupta10 May 2, 2022
4edabed
Fix bug #4949 by correctly setting previous db version number (#4956)
madhurgupta10 May 18, 2022
f4414b1
Fix bug #4959 by correctly setting previous db version number and upd…
madhurgupta10 May 20, 2022
9654a8e
Fix bug #4957 (#4961)
madhurgupta10 May 20, 2022
05895c5
Update library to new version that handles older Java VMs
nicolas-raoul May 25, 2022
50b3d2c
Versioning for v4.0.0
misaochan May 28, 2022
e27f5d4
Changelog for v4.0.0
misaochan May 28, 2022
3533b81
Fix bug #4984 Added queries for package name for Android API 30+ (#4987)
madhurgupta10 Jun 3, 2022
18fa717
Update mapbox sdk version (#4989)
madhurgupta10 Jun 8, 2022
66f8f97
Versioning for v4.0.1
misaochan Jun 9, 2022
e5e5a8d
Changelog for v4.0.1
misaochan Jun 9, 2022
d45123d
Remove network type information from NetworkUtils (#4996)
madhurgupta10 Jun 28, 2022
d8e4c03
Fix #4992 invert the equals condition to be null safe (#4995)
madhurgupta10 Jun 28, 2022
5fe1ad8
Fix java.lang.NullPointerException for username in ContributionBounda…
madhurgupta10 Jul 5, 2022
8eb6681
Fix failing tests for PR #5003 (#5004)
madhurgupta10 Jul 6, 2022
bec2680
Update Room DB Version (#5011)
madhurgupta10 Jul 12, 2022
c520024
Fix #5001 (#5010)
madhurgupta10 Jul 12, 2022
cb3094b
Fix DB update issue (#5016)
neslihanturan Jul 18, 2022
98143aa
[WIP] Fix both timezone problem and saved date problem (#5019)
neslihanturan Aug 3, 2022
02df655
Versioning for v4.0.2
misaochan Aug 4, 2022
3f759a8
Changelog for v4.0.2
misaochan Aug 4, 2022
c53befc
Add "Report Violation" menu option (#5025)
madhurgupta10 Aug 5, 2022
23c474b
Versioning for v4.0.3
misaochan Aug 5, 2022
308cce4
Changelog for v4.0.3
misaochan Aug 5, 2022
67eb203
Merge branch 'master' into 4.0-release-copy
madhurgupta10 Aug 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Wikimedia Commons for Android

## v4.0.3
- Added "Report" button for Google UGC policy

## v4.0.2
- Fixed bug with wrong dates taken from EXIF
- Fixed various crashes

## v4.0.1
- Fixed bug with no browser found
- Updated Mapbox SDK to fix hamburger crash

## v4.0.0
- Added map showing nearby Commons pictures
- Added custom SPARQL queries
- Added user profiles
- Added custom picture selector
- Various bugfixes
- Updated target SDK to 30

## v3.1.1
- Optimized Nearby query
- Added Sweden's property for WLM 2021
Expand Down
12 changes: 6 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ dependencies {
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
implementation 'com.github.chrisbanes:PhotoView:2.0.0'
implementation 'com.github.pedrovgs:renderers:3.3.3'
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.1.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v8:0.11.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-scalebar-v9:0.4.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-telemetry:6.1.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.2.1'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v9:0.12.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-scalebar-v9:0.5.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-telemetry:7.0.0'
implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0'
implementation 'com.dinuscxj:circleprogressbar:1.1.1'
implementation 'com.karumi:dexter:5.0.0'
Expand Down Expand Up @@ -173,8 +173,8 @@ android {
defaultConfig {
//applicationId 'fr.free.nrw.commons'

versionCode 1025
versionName '3.1.1'
versionCode 1029
versionName '4.0.3'
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())

minSdkVersion 19
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<queries>
<!-- Browser -->
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
</intent>
<!-- Google Maps -->
<package android:name="com.google.android.apps.maps" />
</queries>


<!-- Needed only if your app targets Android 5.0 (API level 21) or higher. -->
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/fr/free/nrw/commons/CommonsApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public class CommonsApplication extends MultiDexApplication {

public static final String FEEDBACK_EMAIL_SUBJECT = "Commons Android App Feedback";

public static final String REPORT_EMAIL = "commons-app-android-private@googlegroups.com";

public static final String REPORT_EMAIL_SUBJECT = "Report a violation";

public static final String NOTIFICATION_CHANNEL_ID_ALL = "CommonsNotificationAll";

public static final String FEEDBACK_EMAIL_TEMPLATE_HEADER = "-- Technical information --";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ protected void onCreate(@Nullable final Bundle savedInstanceState) {
addCredits();
getToolbarUI();

if (activity.equals("UploadActivity")) {
if ("UploadActivity".equals(activity)) {
placeSelectedButton.setVisibility(View.GONE);
modifyLocationButton.setVisibility(View.VISIBLE);
showInMapButton.setVisibility(View.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,22 +309,18 @@ public static void onUpdate(final SQLiteDatabase db, int from, final int to) {
if (from == to) {
return;
}
if (from < 7) {
if (from < 18) {
// doesn't exist yet
from++;
onUpdate(db, from, to);
return;
}

if (from == 7) {
if (from == 18) {
// table added in version 19
onCreate(db);
from++;
onUpdate(db, from, to);
return;
}

if (from == 8) {
from++;
onUpdate(db, from, to);
}
}
}
Expand Down
15 changes: 12 additions & 3 deletions app/src/main/java/fr/free/nrw/commons/category/CategoryDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ List<CategoryItem> recentCategories(int limit) {
// fixme add a limit on the original query instead of falling out of the loop?
while (cursor != null && cursor.moveToNext()
&& cursor.getPosition() < limit) {
items.add(new CategoryItem(fromCursor(cursor).getName(),
fromCursor(cursor).getDescription(), fromCursor(cursor).getThumbnail(),
false));
if (fromCursor(cursor).getName() != null ) {
items.add(new CategoryItem(fromCursor(cursor).getName(),
fromCursor(cursor).getDescription(), fromCursor(cursor).getThumbnail(),
false));
}
}
} catch (RemoteException e) {
throw new RuntimeException(e);
Expand Down Expand Up @@ -193,6 +195,13 @@ public static void onUpdate(SQLiteDatabase db, int from, int to) {
onUpdate(db, from, to);
return;
}
if (from == 17) {
db.execSQL("ALTER TABLE categories ADD COLUMN description STRING;");
db.execSQL("ALTER TABLE categories ADD COLUMN thumbnail STRING;");
from++;
onUpdate(db, from, to);
return;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import android.os.Parcelable
import kotlinx.android.parcel.Parcelize

@Parcelize
data class CategoryItem(val name: String, val description: String,
val thumbnail: String, var isSelected: Boolean) : Parcelable {
data class CategoryItem(val name: String, val description: String?,
val thumbnail: String?, var isSelected: Boolean) : Parcelable {

override fun toString(): String {
return "CategoryItem: '$name'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ data class Contribution constructor(
val localUri: Uri? = null,
var dataLength: Long = 0,
var dateCreated: Date? = null,
var dateCreatedString: String? = null,
var dateModified: Date? = null,
var hasInvalidLocation : Int = 0,
var contentUri: Uri? = null,
Expand Down Expand Up @@ -70,6 +71,7 @@ data class Contribution constructor(
depictedItems = depictedItems,
wikidataPlace = from(item.place),
contentUri = item.contentUri,
dateCreatedString = item.fileCreatedDateString,
imageSHA1 = imageSHA1
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ContributionBoundaryCallback @Inject constructor(
@param:Named(CommonsApplicationModule.IO_THREAD) private val ioThreadScheduler: Scheduler
) : BoundaryCallback<Contribution>() {
private val compositeDisposable: CompositeDisposable = CompositeDisposable()
lateinit var userName: String
var userName: String? = null


/**
Expand Down Expand Up @@ -53,13 +53,13 @@ class ContributionBoundaryCallback @Inject constructor(
/**
* Fetches contributions using the MediaWiki API
*/
fun fetchContributions() {
private fun fetchContributions() {
if (sessionManager.userName != null) {
compositeDisposable.add(
mediaClient.getMediaListForUser(userName!!)
userName?.let { userName ->
mediaClient.getMediaListForUser(userName)
.map { mediaList ->
mediaList.map {
Contribution(media = it, state = Contribution.STATE_COMPLETED)
mediaList.map { media ->
Contribution(media = media, state = Contribution.STATE_COMPLETED)
}
}
.subscribeOn(ioThreadScheduler)
Expand All @@ -69,11 +69,13 @@ class ContributionBoundaryCallback @Inject constructor(
error.message
)
}
)
}else {
if (compositeDisposable != null){
compositeDisposable.clear()
}?.let {
compositeDisposable.add(
it
)
}
}else {
compositeDisposable.clear()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ public Integer getContributionStateAt(int position) {
}

public boolean backButtonClicked() {
if (null != mediaDetailPagerFragment && mediaDetailPagerFragment.isVisible()) {
if (mediaDetailPagerFragment != null && mediaDetailPagerFragment.isVisible()) {
if (store.getBoolean("displayNearbyCardView", true) && !isUserProfile) {
if (nearbyNotificationCardView.cardViewVisibilityState == NearbyNotificationCardView.CardViewVisibilityState.READY) {
nearbyNotificationCardView.setVisibility(View.VISIBLE);
Expand All @@ -678,9 +678,10 @@ public boolean backButtonClicked() {
}else {
fetchCampaigns();
}
if(getActivity() instanceof MainActivity) {
if (getActivity() instanceof MainActivity) {
// Fragment is associated with MainActivity
((MainActivity)getActivity()).showTabs();
((BaseActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
((MainActivity) getActivity()).showTabs();
}
return true;
}
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/fr/free/nrw/commons/data/DBOpenHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;

import fr.free.nrw.commons.bookmarks.items.BookmarkItemsDao;
import fr.free.nrw.commons.bookmarks.items.BookmarkItemsDao.Table;
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
import fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesDao;
import fr.free.nrw.commons.category.CategoryDao;
Expand All @@ -16,7 +14,7 @@
public class DBOpenHelper extends SQLiteOpenHelper {

private static final String DATABASE_NAME = "commons.db";
private static final int DATABASE_VERSION = 19;
private static final int DATABASE_VERSION = 20;
public static final String CONTRIBUTIONS_TABLE = "contributions";
private final String DROP_TABLE_STATEMENT="DROP TABLE IF EXISTS %s";

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/fr/free/nrw/commons/db/AppDatabase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import fr.free.nrw.commons.upload.depicts.DepictsDao
* The database for accessing the respective DAOs
*
*/
@Database(entities = [Contribution::class, Depicts::class, UploadedStatus::class], version = 12, exportSchema = false)
@Database(entities = [Contribution::class, Depicts::class, UploadedStatus::class], version = 13, exportSchema = false)
@TypeConverters(Converters::class)
abstract class AppDatabase : RoomDatabase() {
abstract fun contributionDao(): ContributionDao
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ class DescriptionEditActivity : BaseActivity(), UploadMediaDetailAdapter.EventLi
buffer.append("}}, ")
}
}
buffer.deleteCharAt(buffer.length - 1)
buffer.deleteCharAt(buffer.length - 1)
buffer.replace(", $".toRegex(), "")
buffer.append(descriptionEnd)
}
val returningIntent = Intent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import fr.free.nrw.commons.upload.FileUtils;
Expand Down Expand Up @@ -124,13 +126,30 @@ private DateTimeWithSource getFileCreatedDateFromCP(Context context) {
private DateTimeWithSource getDateTimeFromExif() {
try {
ExifInterface exif = new ExifInterface(file.getAbsolutePath());
@SuppressLint("RestrictedApi") Long dateTime = exif.getDateTime();
if(dateTime != null){
Date date = new Date(dateTime);
return new DateTimeWithSource(date, DateTimeWithSource.EXIF_SOURCE);
// TAG_DATETIME returns the last edited date, we need TAG_DATETIME_ORIGINAL for creation date
// See issue https://github.com/commons-app/apps-android-commons/issues/1971
String dateTimeSubString = exif.getAttribute(ExifInterface.TAG_DATETIME_ORIGINAL);
if (dateTimeSubString!=null) { //getAttribute may return null
String year = dateTimeSubString.substring(0,4);
String month = dateTimeSubString.substring(5,7);
String day = dateTimeSubString.substring(8,10);
// This date is stored as a string (not as a date), the rason is we don't want to include timezones
String dateCreatedString = String.format("%04d-%02d-%02d", Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day));
if (dateCreatedString.length() == 10) { //yyyy-MM-dd format of date is expected
@SuppressLint("RestrictedApi") Long dateTime = exif.getDateTimeOriginal();
if(dateTime != null){
Date date = new Date(dateTime);
return new DateTimeWithSource(date, dateCreatedString, DateTimeWithSource.EXIF_SOURCE);
}
}
}

} catch (IOException e) {
e.printStackTrace();
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
}
return null;
}
Expand All @@ -149,6 +168,7 @@ public class DateTimeWithSource {
public static final String EXIF_SOURCE = "exif";

private final long epochDate;
private String dateString; // this does not includes timezone information
private final String source;

public DateTimeWithSource(long epochDate, String source) {
Expand All @@ -161,10 +181,20 @@ public DateTimeWithSource(Date date, String source) {
this.source = source;
}

public DateTimeWithSource(Date date, String dateString, String source) {
this.epochDate = date.getTime();
this.dateString = dateString;
this.source = source;
}

public long getEpochDate() {
return epochDate;
}

public String getDateString() {
return dateString;
}

public String getSource() {
return source;
}
Expand Down
Loading