mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Merge remote-tracking branch 'refs/remotes/origin/2.7.x-release'
This commit is contained in:
commit
8a4871fda2
4 changed files with 64 additions and 2 deletions
|
|
@ -1,6 +1,9 @@
|
|||
package fr.free.nrw.commons.nearby;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
|
@ -10,6 +13,7 @@ import android.support.design.widget.BottomSheetBehavior;
|
|||
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
|
@ -33,6 +37,7 @@ import fr.free.nrw.commons.location.LatLng;
|
|||
import fr.free.nrw.commons.location.LocationServiceManager;
|
||||
import fr.free.nrw.commons.location.LocationUpdateListener;
|
||||
import fr.free.nrw.commons.theme.NavigationBaseActivity;
|
||||
import fr.free.nrw.commons.utils.NetworkUtils;
|
||||
import fr.free.nrw.commons.utils.UriSerializer;
|
||||
|
||||
import fr.free.nrw.commons.utils.ViewUtil;
|
||||
|
|
@ -69,11 +74,14 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
|||
private boolean lockNearbyView; //Determines if the nearby places needs to be refreshed
|
||||
private BottomSheetBehavior bottomSheetBehavior; // Behavior for list bottom sheet
|
||||
private BottomSheetBehavior bottomSheetBehaviorForDetails; // Behavior for details bottom sheet
|
||||
private NearbyMapFragment nearbyMapFragment;
|
||||
public NearbyMapFragment nearbyMapFragment;
|
||||
private NearbyListFragment nearbyListFragment;
|
||||
private static final String TAG_RETAINED_MAP_FRAGMENT = NearbyMapFragment.class.getSimpleName();
|
||||
private static final String TAG_RETAINED_LIST_FRAGMENT = NearbyListFragment.class.getSimpleName();
|
||||
|
||||
private final String NETWORK_INTENT_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";
|
||||
private BroadcastReceiver broadcastReceiver;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
@ -271,6 +279,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
|||
super.onResume();
|
||||
lockNearbyView = false;
|
||||
checkGps();
|
||||
addNetworkBroadcastReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -283,9 +292,28 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
|||
// to the retained fragment object to perform its own cleanup.
|
||||
removeMapFragment();
|
||||
removeListFragment();
|
||||
unregisterReceiver(broadcastReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
private void addNetworkBroadcastReceiver() {
|
||||
IntentFilter intentFilter = new IntentFilter(NETWORK_INTENT_ACTION);
|
||||
|
||||
broadcastReceiver = new BroadcastReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (NetworkUtils.isInternetConnectionEstablished(NearbyActivity.this)) {
|
||||
refreshView(LocationServiceManager
|
||||
.LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED);
|
||||
} else {
|
||||
ViewUtil.showLongToast(NearbyActivity.this, getString(R.string.no_internet));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.registerReceiver(broadcastReceiver, intentFilter);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -297,6 +325,12 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
|||
if (lockNearbyView) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!NetworkUtils.isInternetConnectionEstablished(this)) {
|
||||
hideProgressBar();
|
||||
return;
|
||||
}
|
||||
|
||||
locationManager.registerLocationManager();
|
||||
LatLng lastLocation = locationManager.getLastLocation();
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package fr.free.nrw.commons.utils;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
|
||||
public class NetworkUtils {
|
||||
|
||||
public static boolean isInternetConnectionEstablished(Context context) {
|
||||
ConnectivityManager cm =
|
||||
(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
|
||||
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||
return activeNetwork != null &&
|
||||
activeNetwork.isConnectedOrConnecting();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
package fr.free.nrw.commons.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class ViewUtil {
|
||||
|
||||
|
|
@ -9,4 +11,9 @@ public class ViewUtil {
|
|||
Snackbar.make(view, messageResourceId, Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public static void showLongToast(Context context, String text) {
|
||||
Toast.makeText(context, text,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,9 +253,12 @@
|
|||
<string name="about_rate_us"><u>Rate Us</u></string>
|
||||
<string name="about_faq">Frequently Asked Questions</string>
|
||||
<string name="welcome_skip_button">Skip Tutorial</string>
|
||||
|
||||
|
||||
<string name="no_internet">Internet unavailable</string>
|
||||
<string name="internet_established">Internet available</string>
|
||||
<string name="error_notifications">Error fetching notifications</string>
|
||||
<string name="no_notifications">No notifications found</string>
|
||||
|
||||
<string name="about_translate"><u>Translate</u></string>
|
||||
<string name="about_translate_title">Languages</string>
|
||||
<string name="about_translate_message">Select the langauge you want translations for ?</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue