Skip to content

Commit 11e193f

Browse files
committed
2 parents c6410c2 + e23f752 commit 11e193f

File tree

54 files changed

+590
-110
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+590
-110
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Wikimedia Commons for Android
22

3+
## v2.7.0
4+
- New Nearby Places UI with direct uploads (and associated category suggestions)
5+
- Added two-factor authentication login
6+
- Added Notifications activity to display user talk messages
7+
- Added real-time location tracking in Nearby
8+
- Added "rate us", "translate", and FB link in About
9+
- Improvements to UI of navigation drawer, tutorial, media details view, login activity and Settings
10+
- Added option to nominate picture for deletion in media details view
11+
- Too many bug and crash fixes to mention!
12+
313
## v2.6.7
414
- Added null checks to prevent frequent crashes in ModificationsSyncAdapter
515

app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ android {
9191

9292
defaultConfig {
9393
applicationId 'fr.free.nrw.commons'
94-
versionCode 82
95-
versionName '2.6.7'
94+
versionCode 83
95+
versionName '2.7.0'
9696
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
9797

9898
minSdkVersion project.minSdkVersion

app/src/main/java/fr/free/nrw/commons/AboutActivity.java

+25
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
import android.util.Log;
1313
import android.support.customtabs.CustomTabsIntent;
1414
import android.support.v4.content.ContextCompat;
15+
import android.view.Menu;
16+
import android.view.MenuInflater;
17+
import android.view.MenuItem;
1518
import android.view.View;
1619
import android.widget.ArrayAdapter;
1720
import android.widget.LinearLayout;
@@ -121,6 +124,28 @@ public void launchFrequentlyAskedQuesions(View view) {
121124
Utils.handleWebUrl(this,Uri.parse("https://github.com/commons-app/apps-android-commons/wiki/Frequently-Asked-Questions\\"));
122125
}
123126

127+
@Override
128+
public boolean onCreateOptionsMenu(Menu menu) {
129+
MenuInflater inflater = getMenuInflater();
130+
inflater.inflate(R.menu.menu_about, menu);
131+
return super.onCreateOptionsMenu(menu);
132+
}
133+
134+
@Override
135+
public boolean onOptionsItemSelected(MenuItem item) {
136+
switch (item.getItemId()) {
137+
case R.id.share_app_icon:
138+
Intent sendIntent = new Intent();
139+
sendIntent.setAction(Intent.ACTION_SEND);
140+
sendIntent.putExtra(Intent.EXTRA_TEXT, "http://play.google.com/store/apps/details?id=fr.free.nrw.commons");
141+
sendIntent.setType("text/plain");
142+
startActivity(Intent.createChooser(sendIntent, "Share app via..."));
143+
return true;
144+
default:
145+
return super.onOptionsItemSelected(item);
146+
}
147+
}
148+
124149
@OnClick(R.id.about_translate)
125150
public void launchTranslate(View view) {
126151
final ArrayAdapter<String> languageAdapter = new ArrayAdapter<String>(AboutActivity.this,

app/src/main/java/fr/free/nrw/commons/nearby/NearbyActivity.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,6 @@ protected void onStart() {
262262
@Override
263263
protected void onStop() {
264264
super.onStop();
265-
locationManager.removeLocationListener(this);
266-
locationManager.unregisterLocationManager();
267265
}
268266

269267
@Override
@@ -292,8 +290,13 @@ public void onPause() {
292290
// to the retained fragment object to perform its own cleanup.
293291
removeMapFragment();
294292
removeListFragment();
295-
unregisterReceiver(broadcastReceiver);
293+
296294
}
295+
unregisterReceiver(broadcastReceiver);
296+
broadcastReceiver = null;
297+
locationManager.removeLocationListener(this);
298+
locationManager.unregisterLocationManager();
299+
297300
}
298301

299302
private void addNetworkBroadcastReceiver() {
@@ -422,6 +425,7 @@ private void removeMapFragment() {
422425
if (nearbyMapFragment != null) {
423426
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
424427
fm.beginTransaction().remove(nearbyMapFragment).commit();
428+
nearbyMapFragment = null;
425429
}
426430
}
427431

@@ -433,6 +437,7 @@ private void removeListFragment() {
433437
if (nearbyListFragment != null) {
434438
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
435439
fm.beginTransaction().remove(nearbyListFragment).commit();
440+
nearbyListFragment = null;
436441
}
437442
}
438443

app/src/main/java/fr/free/nrw/commons/nearby/NearbyMapFragment.java

+71-21
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@
5353

5454
import dagger.android.support.DaggerFragment;
5555
import fr.free.nrw.commons.R;
56+
import fr.free.nrw.commons.Utils;
5657
import fr.free.nrw.commons.contributions.ContributionController;
5758
import fr.free.nrw.commons.utils.UriDeserializer;
59+
import fr.free.nrw.commons.utils.ViewUtil;
5860
import timber.log.Timber;
5961

6062
import static android.app.Activity.RESULT_OK;
@@ -105,7 +107,8 @@ public class NearbyMapFragment extends DaggerFragment {
105107
private PolygonOptions currentLocationPolygonOptions;
106108

107109
private boolean isBottomListSheetExpanded;
108-
private final double CAMERA_TARGET_SHIFT_FACTOR = 0.06;
110+
private final double CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT = 0.06;
111+
private final double CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE = 0.04;
109112

110113
@Inject
111114
@Named("prefs")
@@ -253,13 +256,28 @@ private void updateMapToTrackPosition() {
253256
}
254257

255258
// Make camera to follow user on location change
256-
CameraPosition position = new CameraPosition.Builder()
257-
.target(isBottomListSheetExpanded ?
258-
new LatLng(curMapBoxLatLng.getLatitude()- CAMERA_TARGET_SHIFT_FACTOR,
259-
curMapBoxLatLng.getLongitude())
260-
: curMapBoxLatLng ) // Sets the new camera position
261-
.zoom(mapboxMap.getCameraPosition().zoom) // Same zoom level
262-
.build();
259+
CameraPosition position ;
260+
if(ViewUtil.isPortrait(getActivity())){
261+
position = new CameraPosition.Builder()
262+
.target(isBottomListSheetExpanded ?
263+
new LatLng(curMapBoxLatLng.getLatitude()- CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT,
264+
curMapBoxLatLng.getLongitude())
265+
: curMapBoxLatLng ) // Sets the new camera position
266+
.zoom(isBottomListSheetExpanded ?
267+
11 // zoom level is fixed to 11 when bottom sheet is expanded
268+
:mapboxMap.getCameraPosition().zoom) // Same zoom level
269+
.build();
270+
}else {
271+
position = new CameraPosition.Builder()
272+
.target(isBottomListSheetExpanded ?
273+
new LatLng(curMapBoxLatLng.getLatitude()- CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE,
274+
curMapBoxLatLng.getLongitude())
275+
: curMapBoxLatLng ) // Sets the new camera position
276+
.zoom(isBottomListSheetExpanded ?
277+
11 // zoom level is fixed to 11 when bottom sheet is expanded
278+
:mapboxMap.getCameraPosition().zoom) // Same zoom level
279+
.build();
280+
}
263281

264282
mapboxMap.animateCamera(CameraUpdateFactory
265283
.newCameraPosition(position), 1000);
@@ -273,12 +291,21 @@ private void updateMapCameraAccordingToBottomSheet(boolean isBottomListSheetExpa
273291
if (mapboxMap != null && curLatLng != null) {
274292
if (isBottomListSheetExpanded) {
275293
// Make camera to follow user on location change
276-
position = new CameraPosition.Builder()
277-
.target(new LatLng(curLatLng.getLatitude() - CAMERA_TARGET_SHIFT_FACTOR,
278-
curLatLng.getLongitude())) // Sets the new camera target above
279-
// current to make it visible when sheet is expanded
280-
.zoom(11) // Same zoom level
281-
.build();
294+
if(ViewUtil.isPortrait(getActivity())) {
295+
position = new CameraPosition.Builder()
296+
.target(new LatLng(curLatLng.getLatitude() - CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT,
297+
curLatLng.getLongitude())) // Sets the new camera target above
298+
// current to make it visible when sheet is expanded
299+
.zoom(11) // Fixed zoom level
300+
.build();
301+
} else {
302+
position = new CameraPosition.Builder()
303+
.target(new LatLng(curLatLng.getLatitude() - CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE,
304+
curLatLng.getLongitude())) // Sets the new camera target above
305+
// current to make it visible when sheet is expanded
306+
.zoom(11) // Fixed zoom level
307+
.build();
308+
}
282309

283310
} else {
284311
// Make camera to follow user on location change
@@ -344,10 +371,29 @@ private void setListeners() {
344371
fabRecenter.setOnClickListener(view -> {
345372
if (curLatLng != null) {
346373
mapView.getMapAsync(mapboxMap -> {
347-
CameraPosition position = new CameraPosition.Builder()
348-
.target(new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude())) // Sets the new camera position
349-
.zoom(11) // Sets the zoom
350-
.build(); // Creates a CameraPosition from the builder
374+
CameraPosition position;
375+
376+
if(ViewUtil.isPortrait(getActivity())){
377+
position = new CameraPosition.Builder()
378+
.target(isBottomListSheetExpanded ?
379+
new LatLng(curLatLng.getLatitude()- CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT,
380+
curLatLng.getLongitude())
381+
: new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude(), 0)) // Sets the new camera position
382+
.zoom(isBottomListSheetExpanded ?
383+
11 // zoom level is fixed to 11 when bottom sheet is expanded
384+
:mapboxMap.getCameraPosition().zoom) // Same zoom level
385+
.build();
386+
}else {
387+
position = new CameraPosition.Builder()
388+
.target(isBottomListSheetExpanded ?
389+
new LatLng(curLatLng.getLatitude()- CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE,
390+
curLatLng.getLongitude())
391+
: new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude(), 0)) // Sets the new camera position
392+
.zoom(isBottomListSheetExpanded ?
393+
11 // zoom level is fixed to 11 when bottom sheet is expanded
394+
:mapboxMap.getCameraPosition().zoom) // Same zoom level
395+
.build();
396+
}
351397

352398
mapboxMap.animateCamera(CameraUpdateFactory
353399
.newCameraPosition(position), 1000);
@@ -534,7 +580,9 @@ public void prepareViewsForSheetPosition(int bottomSheetState) {
534580
transparentView.setAlpha(0);
535581
closeFabs(isFabOpen);
536582
hideFAB();
537-
this.getView().requestFocus();
583+
if (this.getView() != null) {
584+
this.getView().requestFocus();
585+
}
538586
break;
539587
}
540588
}
@@ -700,8 +748,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
700748
}
701749

702750
private void openWebView(Uri link) {
703-
Intent browserIntent = new Intent(Intent.ACTION_VIEW, link);
704-
startActivity(browserIntent);
751+
Utils.handleWebUrl(getContext(), link);
705752
}
706753

707754
private void animateFAB(boolean isFabOpen) {
@@ -776,6 +823,9 @@ public void onDestroyView() {
776823
if (mapView != null) {
777824
mapView.onDestroy();
778825
}
826+
selected = null;
827+
currentLocationMarker = null;
828+
779829
super.onDestroyView();
780830
}
781831

app/src/main/java/fr/free/nrw/commons/nearby/PlaceRenderer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import butterknife.ButterKnife;
2828
import fr.free.nrw.commons.CommonsApplication;
2929
import fr.free.nrw.commons.R;
30+
import fr.free.nrw.commons.Utils;
3031
import fr.free.nrw.commons.contributions.ContributionController;
3132
import fr.free.nrw.commons.di.ApplicationlessInjection;
3233
import timber.log.Timber;
@@ -200,8 +201,7 @@ private void popupMenuListener() {
200201
}
201202

202203
private void openWebView(Uri link) {
203-
Intent browserIntent = new Intent(Intent.ACTION_VIEW, link);
204-
view.getContext().startActivity(browserIntent);
204+
Utils.handleWebUrl(getContext(), link);
205205
}
206206

207207
private boolean showMenu() {

app/src/main/java/fr/free/nrw/commons/notification/NotificationActivity.java

+19-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.content.Intent;
77
import android.net.Uri;
88
import android.os.Bundle;
9+
import android.support.design.widget.Snackbar;
910
import android.support.v7.widget.DividerItemDecoration;
1011
import android.support.v7.widget.LinearLayoutManager;
1112
import android.support.v7.widget.RecyclerView;
@@ -15,6 +16,7 @@
1516

1617
import com.pedrogomez.renderers.RVRendererAdapter;
1718

19+
import java.lang.ref.WeakReference;
1820
import java.util.Collections;
1921
import java.util.List;
2022

@@ -25,6 +27,7 @@
2527
import fr.free.nrw.commons.R;
2628
import fr.free.nrw.commons.Utils;
2729
import fr.free.nrw.commons.theme.NavigationBaseActivity;
30+
import fr.free.nrw.commons.utils.NetworkUtils;
2831
import fr.free.nrw.commons.utils.ViewUtil;
2932
import io.reactivex.Observable;
3033
import io.reactivex.android.schedulers.AndroidSchedulers;
@@ -62,9 +65,23 @@ private void initListView() {
6265
recyclerView.setLayoutManager(new LinearLayoutManager(this));
6366
DividerItemDecoration itemDecor = new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.VERTICAL);
6467
recyclerView.addItemDecoration(itemDecor);
65-
addNotifications();
68+
refresh();
6669
}
6770

71+
private void refresh() {
72+
if (!NetworkUtils.isInternetConnectionEstablished(this)) {
73+
progressBar.setVisibility(View.GONE);
74+
Snackbar.make(relativeLayout , R.string.no_internet, Snackbar.LENGTH_INDEFINITE)
75+
.setAction(R.string.retry, view -> {
76+
refresh();
77+
}).show();
78+
}else {
79+
progressBar.setVisibility(View.VISIBLE);
80+
addNotifications();
81+
}
82+
}
83+
84+
6885
@SuppressLint("CheckResult")
6986
private void addNotifications() {
7087
Timber.d("Add notifications");
@@ -124,4 +141,4 @@ private void initializeAndSetNotificationList(List<Notification> notificationLis
124141
.commit();
125142
mNotificationWorkerFragment.setNotificationList(notificationList);
126143
}
127-
}
144+
}

app/src/main/java/fr/free/nrw/commons/notification/NotificationRenderer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ protected View inflate(LayoutInflater layoutInflater, ViewGroup viewGroup) {
4747
@Override
4848
public void render() {
4949
Notification notification = getContent();
50-
StringBuilder str = new StringBuilder(notification.notificationText.trim());
51-
str.append(" ");
50+
String str = notification.notificationText.trim();
51+
str = str.concat(" ");
5252
title.setText(str);
5353
time.setText(notification.date);
5454
switch (notification.notificationType) {

0 commit comments

Comments
 (0)