Merge v3.0.1 into master (#4446)

* Versioning and changelog for v3.0.0 (#4152)

* Versioning for v3.0.0

* Update changelog.md

* Handled migration 8-9-10 in BookmarksLocationDao (#4154)

* #Fixes #4141
- Handled migrations for BookmarkLocationsDao from 8-9-10

* #Fixes #4141
- Handled migrations for BookmarkLocationsDao from 8-9-10

* Fixes #4179 (#4180)

* Handled null pointer exception in MainActivity->ContributionsFragment#backButtonClicked()
* Updated >ContributionsFragment#backButtonClicked() to handle back press properly

* Fixes #4179 (#4181)

* Handled possible null check on MediaDetails in BookmarkListRootFragment#backPressed()

* Cherrypick for hotfix3.1 (#4205)

* Fixes #4159 On Explore Tab, All Available Options on toolbar in media detail view are only targeting the first media in the list.

Fixes #4159 On Explore Tab, All Available Options on toolbar in media detail view are only targeting the first media in the list.

* fixed bug: App crashes on viewing review in Review Fragment #4132 (#4146)

* fixed bug:app crashes on viewing review in Review Fragment #4135

* Fixed the issue with back button in contribution tab. (#4177)

Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com>

* Fixed the issue with back navigation button on toolbar in explore tab. (#4175)

* Fix (#4148) Issues on theme change

* fixed themeChange crashes

* fixed comments

* Overlooked the title bar

Co-authored-by: Pratham Pahariya <54663429+Pratham2305@users.noreply.github.com>
Co-authored-by: Shabir Ahmad <56585337+shabar-shab@users.noreply.github.com>
Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com>
Co-authored-by: Aditya-Srivastav <54016427+4D17Y4@users.noreply.github.com>

* Fixes #4173 (#4396)

* Fix #4147  Pre-fill desc in Nearby uploads with Wikidata item's label + description (#4390)

* Update query to fetch descriptions

* Make description added to NearbyResultItem

* Make string operations to display description and label in a combined way

* Fix reviews, remove long description from list and swap label and description texts

* Fix repeated information issue

* Fix double information issue

* fix style issues

* Remove douplicated information

* Changes made (#4354)

* Remove nonexistent method

* Fix #4283 IllegalStateException (#4440)

* Fix #4283 IllegalStateException

* Fix flickering issue

* Versioning for v3.0.1

* Update changelog.md

Co-authored-by: Ashish <ashishkumar468@gmail.com>
Co-authored-by: neslihanturan <tur.neslihan@gmail.com>
Co-authored-by: Pratham Pahariya <54663429+Pratham2305@users.noreply.github.com>
Co-authored-by: Shabir Ahmad <56585337+shabar-shab@users.noreply.github.com>
Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com>
Co-authored-by: Aditya-Srivastav <54016427+4D17Y4@users.noreply.github.com>
Co-authored-by: Madhur Gupta <30932899+madhurgupta10@users.noreply.github.com>
Co-authored-by: Vinayak Aggarwal <56196007+vinayak0505@users.noreply.github.com>
This commit is contained in:
Josephine Lim 2021-06-09 20:19:24 +10:00 committed by GitHub
parent 7823b18db9
commit ca75f616d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 115 additions and 71 deletions

View file

@ -1,5 +1,10 @@
# Wikimedia Commons for Android
## v3.0.1
- Pre-fill desc in Nearby uploads with Wikidata item's label + description
- Improved ACRA crash reporting
- Fixed various crashes
## v3.0.0
- Added Structured Data to upload workflow, users can now add depicts
- Added Leaderboard in Achievements screen

View file

@ -58,8 +58,8 @@ dependencies {
implementation "com.squareup.okhttp3:okhttp-ws:$OKHTTP_VERSION"
// Logging
implementation 'ch.acra:acra-dialog:5.3.0'
implementation 'ch.acra:acra-mail:5.3.0'
implementation 'ch.acra:acra-dialog:5.8.1-beta11'
implementation 'ch.acra:acra-mail:5.8.1-beta11'
implementation 'org.slf4j:slf4j-api:1.7.25'
api('com.github.tony19:logback-android-classic:1.1.1-6') {
exclude group: 'com.google.android', module: 'android'
@ -149,8 +149,9 @@ android {
defaultConfig {
//applicationId 'fr.free.nrw.commons'
versionCode 876
versionName '3.0.0'
versionCode 1016
versionName '3.0.1'
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
minSdkVersion 19

View file

@ -70,7 +70,8 @@ import timber.log.Timber;
)
@AcraMailSender(
mailTo = "commons-app-android-private@googlegroups.com"
mailTo = "commons-app-android-private@googlegroups.com",
reportAsFile = false
)
@AcraDialog(

View file

@ -196,38 +196,16 @@ public class BookmarkListRootFragment extends CommonsDaggerSupportFragment imple
}
}
public boolean backPressed() {
//check mediaDetailPage fragment is not null then we check mediaDetail.is Visible or not to avoid NullPointerException
if(mediaDetails!=null) {
if (mediaDetails.isVisible()) {
if(mediaDetails.backButtonClicked()) {
// mediaDetails handled the back clicked , no further action required.
return true;
}
public void backPressed() {
if (null != mediaDetails && mediaDetails.isVisible()) {
// todo add get list fragment
((BookmarkFragment) getParentFragment()).setupTabLayout();
ArrayList<Integer> removed=mediaDetails.getRemovedItems();
((BookmarkFragment) getParentFragment()).tabLayout.setVisibility(View.VISIBLE);
removeFragment(mediaDetails);
((BookmarkFragment) getParentFragment()).setScroll(true);
setFragment(listFragment, mediaDetails);
} else {
((MainActivity) getActivity()).setSelectedItemId(NavTab.CONTRIBUTIONS.code());
}
((MainActivity) getActivity()).showTabs();
if(listFragment instanceof BookmarkPicturesFragment){
GridViewAdapter adapter=((GridViewAdapter)((BookmarkPicturesFragment)listFragment).getAdapter());
Iterator i = removed.iterator();
while (i.hasNext()) {
adapter.remove(adapter.getItem((int)i.next()));
}
mediaDetails.clearRemoved();
}
} else {
moveToContributionsFragment();
}
} else {
moveToContributionsFragment();
}
// notify mediaDetails did not handled the backPressed further actions required.
return false;
}
void moveToContributionsFragment(){

View file

@ -269,7 +269,7 @@ public class BookmarkLocationsDao {
onUpdate(db, from, to);
return;
}
if (from == 8) {
if (from < 10) {
from++;
onUpdate(db, from, to);
return;

View file

@ -6,6 +6,7 @@ import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.ComponentName;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
@ -24,6 +25,14 @@ import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager.OnBackStackChangedListener;
import androidx.fragment.app.FragmentTransaction;
import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.auth.SessionManager;
import fr.free.nrw.commons.notification.Notification;
import fr.free.nrw.commons.notification.NotificationController;
import fr.free.nrw.commons.theme.BaseActivity;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import fr.free.nrw.commons.CommonsApplication;
@ -330,6 +339,12 @@ public class ContributionsFragment
getChildFragmentManager().executePendingTransactions();
}
public Intent getUploadServiceIntent(){
Intent intent = new Intent(getActivity(), UploadService.class);
intent.setAction(UploadService.ACTION_START_SERVICE);
return intent;
}
@SuppressWarnings("ConstantConditions")
private void setUploadCount() {
compositeDisposable.add(okHttpJsonApiClient
@ -531,6 +546,13 @@ public class ContributionsFragment
presenter.onDetachView();
}
@Override
public void notifyDataSetChanged() {
if (mediaDetailPagerFragment != null) {
mediaDetailPagerFragment.notifyDataSetChanged();
}
}
/**
* Retry upload when it is failed
*
@ -604,12 +626,8 @@ public class ContributionsFragment
return contributionsListFragment.getContributionStateAt(position);
}
public void backButtonClicked() {
if (mediaDetailPagerFragment.isVisible()) {
if(mediaDetailPagerFragment.backButtonClicked()) {
// MediaDetailed handled the backPressed no further action required.
return;
}
public boolean backButtonClicked() {
if (null != mediaDetailPagerFragment && mediaDetailPagerFragment.isVisible()) {
if (store.getBoolean("displayNearbyCardView", true)) {
if (nearbyNotificationCardView.cardViewVisibilityState == NearbyNotificationCardView.CardViewVisibilityState.READY) {
nearbyNotificationCardView.setVisibility(View.VISIBLE);
@ -622,7 +640,9 @@ public class ContributionsFragment
((BaseActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
((MainActivity)getActivity()).showTabs();
fetchCampaigns();
return true;
}
return false;
}
// Getter for mediaDetailPagerFragment

View file

@ -95,6 +95,8 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
private final int SPAN_COUNT_LANDSCAPE = 3;
private final int SPAN_COUNT_PORTRAIT = 1;
private int contributionsSize;
@Override
public View onCreateView(
@ -145,7 +147,11 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
}
contributionsListPresenter.setup();
contributionsListPresenter.contributionList.observe(this.getViewLifecycleOwner(), adapter::submitList);
contributionsListPresenter.contributionList.observe(this.getViewLifecycleOwner(), list -> {
contributionsSize = list.size();
adapter.submitList(list);
callback.notifyDataSetChanged();
});
rvContributionsList.setAdapter(adapter);
adapter.registerAdapterDataObserver(new AdapterDataObserver() {
@Override
@ -387,10 +393,7 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
}
public int getTotalMediaCount() {
if(adapter != null) {
return adapter.getItemCount();
}
return 0;
return contributionsSize;
}
/**
@ -417,6 +420,8 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
public interface Callback {
void notifyDataSetChanged();
void retryUpload(Contribution contribution);
void showDetail(int position, boolean isWikipediaButtonDisplayed);

View file

@ -99,7 +99,9 @@ public class MainActivity extends BaseActivity
@Override
public boolean onSupportNavigateUp() {
if (activeFragment == ActiveFragment.CONTRIBUTIONS) {
contributionsFragment.backButtonClicked();
if (!contributionsFragment.backButtonClicked()) {
return false;
}
} else {
onBackPressed();
showTabs();
@ -264,16 +266,10 @@ public class MainActivity extends BaseActivity
@Override
public void onBackPressed() {
if (contributionsFragment != null && activeFragment == ActiveFragment.CONTRIBUTIONS) {
// Meas that contribution fragment is visible
mediaDetailPagerFragment=contributionsFragment.getMediaDetailPagerFragment();
if (mediaDetailPagerFragment ==null) { //means you open the app currently and not open mediaDetailPage fragment
// Means that contribution fragment is visible
if (!contributionsFragment.backButtonClicked()) {//If this one does not wan't to handle
// the back press, let the activity do so
super.onBackPressed();
} else if (mediaDetailPagerFragment!=null) {
if(!mediaDetailPagerFragment.isVisible()){ //means you are at contributions fragement
super.onBackPressed();
} else { //mean you are at mediaDetailPager Fragment
contributionsFragment.backButtonClicked();
}
}
} else if (nearbyParentFragment != null && activeFragment == ActiveFragment.NEARBY) {
// Means that nearby fragment is visible

View file

@ -13,7 +13,7 @@ import fr.free.nrw.commons.explore.recentsearches.RecentSearchesDao;
public class DBOpenHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "commons.db";
private static final int DATABASE_VERSION = 15;
private static final int DATABASE_VERSION = 14;
public static final String CONTRIBUTIONS_TABLE = "contributions";
private final String DROP_TABLE_STATEMENT="DROP TABLE IF EXISTS %s";

View file

@ -112,7 +112,6 @@ public class ExploreListRootFragment extends CommonsDaggerSupportFragment implem
container.setVisibility(View.VISIBLE);
((ExploreFragment)getParentFragment()).tabLayout.setVisibility(View.GONE);
mediaDetails = new MediaDetailPagerFragment(false, true);
((ExploreFragment) getParentFragment()).setScroll(false);
setFragment(mediaDetails, listFragment);
mediaDetails.showImage(position);
}

View file

@ -2,12 +2,16 @@ package fr.free.nrw.commons.logging;
import android.content.Context;
import android.os.Bundle;
import javax.inject.Inject;
import javax.inject.Singleton;
import fr.free.nrw.commons.auth.SessionManager;
import fr.free.nrw.commons.utils.ConfigUtils;
import fr.free.nrw.commons.utils.DeviceInfoUtil;
import org.acra.data.CrashReportData;
import org.acra.sender.ReportSenderException;
import org.jetbrains.annotations.NotNull;
/**
* Class responsible for sending logs to developers
@ -87,4 +91,15 @@ public class CommonsLogSender extends LogsSender {
return builder.toString();
}
@Override
public boolean requiresForeground() {
return false;
}
@Override
public void send(@NotNull Context context, @NotNull CrashReportData crashReportData,
@NotNull Bundle bundle) throws ReportSenderException {
}
}

View file

@ -6,7 +6,6 @@ import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@ -101,19 +100,13 @@ public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment imple
pager.addOnPageChangeListener(this);
adapter = new MediaDetailAdapter(getChildFragmentManager());
if (((BaseActivity) getActivity()).getSupportActionBar() != null) {
((BaseActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
pager.setAdapter(adapter);
if (savedInstanceState != null) {
final int pageNumber = savedInstanceState.getInt("current-page");
pager.setCurrentItem(pageNumber, false);
getActivity().invalidateOptionsMenu();
adapter.notifyDataSetChanged();
}
adapter.notifyDataSetChanged();
if (getActivity() instanceof MainActivity) {
((MainActivity)getActivity()).hideTabs();
}

View file

@ -63,11 +63,27 @@ public class Place implements Parcelable {
if(!StringUtils.isBlank(itemClass)) {
classEntityId = itemClass.replace("http://www.wikidata.org/entity/", "");
}
// Set description when not null and not empty
String description = (item.getDescription().getValue() != null && !item.getDescription().getValue().isEmpty()) ? item.getDescription().getValue() : "";
// When description is "?" but we have a valid label, just use the label. So replace "?" by "" in description
description = (description.equals("?")
&& (item.getLabel().getValue() != null
&& !item.getLabel().getValue().isEmpty()) ? "" : description);
/*
* If we have a valid label
* - If have a valid label add the description at the end of the string with parenthesis
* - If we don't have a valid label, string will include only the description. So add it without paranthesis
*/
description = ((item.getLabel().getValue() != null && !item.getLabel().getValue().isEmpty())
? item.getLabel().getValue()
+ ((description != null && !description.isEmpty())
? " (" + description + ")" : "")
: description);
return new Place(
item.getLabel().getLanguage(),
item.getLabel().getValue(),
Label.fromText(classEntityId), // list
item.getClassLabel().getValue(), // details
description, // description and label of Wikidata item
PlaceUtils.latLngFromPointString(item.getLocation().getValue()),
item.getCommonsCategory().getValue(),
new Sitelinks.Builder()

View file

@ -51,7 +51,8 @@ fun placeAdapterDelegate(
tvDesc.setText(R.string.no_description_found)
tvDesc.visibility = INVISIBLE
} else {
tvDesc.text = descriptionText
// Remove the label and display only texts inside pharentheses (description) since too long
tvDesc.text = descriptionText.substringAfter(tvName.text.toString() + " (").substringBeforeLast(")");
}
distance.text = item.distance
icon.setImageResource(item.label.icon)

View file

@ -1521,7 +1521,12 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
title.setText(selectedPlace.name);
distance.setText(selectedPlace.distance);
description.setText(selectedPlace.getLongDescription());
// Remove label since it is double information
String descriptionText = selectedPlace.getLongDescription()
.replace(selectedPlace.getName() + " (","");
descriptionText = (descriptionText.equals(selectedPlace.getLongDescription()) ? descriptionText : descriptionText.replaceFirst(".$",""));
// Set the short description after we remove place name from long description
description.setText(descriptionText);
fabCamera.setOnClickListener(view -> {
if (fabCamera.isShown()) {

View file

@ -12,6 +12,7 @@ class NearbyResultItem(private val item: ResultTuple?,
@field:SerializedName("commonsCategory") private val commonsCategory: ResultTuple?,
@field:SerializedName("pic") private val pic: ResultTuple?,
@field:SerializedName("destroyed") private val destroyed: ResultTuple?,
@field:SerializedName("description") private val description: ResultTuple?,
@field:SerializedName("endTime") private val endTime: ResultTuple?) {
fun getItem(): ResultTuple {
@ -58,6 +59,9 @@ class NearbyResultItem(private val item: ResultTuple?,
return destroyed ?: ResultTuple()
}
fun getDescription(): ResultTuple {
return description ?: ResultTuple()
fun getEndTime(): ResultTuple {
return endTime ?: ResultTuple()
}

View file

@ -2,6 +2,7 @@ SELECT
(SAMPLE(?location) as ?location)
?item
(SAMPLE(COALESCE(?itemLabelPreferredLanguage, ?itemLabelAnyLanguage)) as ?label)
(SAMPLE(COALESCE(?itemDescriptionPreferredLanguage, ?itemDescriptionAnyLanguage, "?")) as ?description)
(SAMPLE(?classId) as ?class)
(SAMPLE(COALESCE(?classLabelPreferredLanguage, ?classLabelAnyLanguage, "?")) as ?classLabel)
(SAMPLE(COALESCE(?icon0, ?icon1)) as ?icon)
@ -23,6 +24,10 @@ SELECT
OPTIONAL {?item rdfs:label ?itemLabelPreferredLanguage. FILTER (lang(?itemLabelPreferredLanguage) = "${LANG}")}
OPTIONAL {?item rdfs:label ?itemLabelAnyLanguage}
# Get the description in the preferred language of the user, or any other language if no description is available in that language.
OPTIONAL {?item schema:description ?itemDescriptionPreferredLanguage. FILTER (lang(?itemDescriptionPreferredLanguage) = "${LANG}")}
OPTIONAL {?item schema:description ?itemDescriptionAnyLanguage }
# Get Commons category (P373)
OPTIONAL { ?item wdt:P373 ?commonsCategory. }