mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Merge remote-tracking branch 'refs/remotes/origin/2.7.x-release'
This commit is contained in:
commit
4285b5e77f
5 changed files with 41 additions and 20 deletions
|
|
@ -304,9 +304,10 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
||||||
coordinates.setOnClickListener(v -> openMap(media.getCoordinates()));
|
coordinates.setOnClickListener(v -> openMap(media.getCoordinates()));
|
||||||
}
|
}
|
||||||
if (delete.getVisibility() == View.VISIBLE) {
|
if (delete.getVisibility() == View.VISIBLE) {
|
||||||
|
enableDeleteButton(true);
|
||||||
|
|
||||||
delete.setOnClickListener(v -> {
|
delete.setOnClickListener(v -> {
|
||||||
delete.setEnabled(false);
|
|
||||||
delete.setTextColor(getResources().getColor(R.color.deleteButtonLight));
|
|
||||||
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
|
||||||
alert.setMessage("Why should this file be deleted?");
|
alert.setMessage("Why should this file be deleted?");
|
||||||
final EditText input = new EditText(getActivity());
|
final EditText input = new EditText(getActivity());
|
||||||
|
|
@ -317,6 +318,7 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
||||||
String reason = input.getText().toString();
|
String reason = input.getText().toString();
|
||||||
DeleteTask deleteTask = new DeleteTask(getActivity(), media, reason);
|
DeleteTask deleteTask = new DeleteTask(getActivity(), media, reason);
|
||||||
deleteTask.execute();
|
deleteTask.execute();
|
||||||
|
enableDeleteButton(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
|
|
@ -358,6 +360,15 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void enableDeleteButton(boolean visibility) {
|
||||||
|
delete.setEnabled(visibility);
|
||||||
|
if(visibility) {
|
||||||
|
delete.setTextColor(getResources().getColor(R.color.primaryTextColor));
|
||||||
|
} else {
|
||||||
|
delete.setTextColor(getResources().getColor(R.color.deleteButtonLight));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void rebuildCatList() {
|
private void rebuildCatList() {
|
||||||
categoryContainer.removeAllViews();
|
categoryContainer.removeAllViews();
|
||||||
// @fixme add the category items
|
// @fixme add the category items
|
||||||
|
|
|
||||||
|
|
@ -474,17 +474,17 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(this::populatePlaces);
|
.subscribe(this::populatePlaces);
|
||||||
nearbyMapFragment.setArguments(bundle);
|
nearbyMapFragment.setBundleForUpdtes(bundle);
|
||||||
nearbyMapFragment.updateMapSignificantly();
|
nearbyMapFragment.updateMapSignificantly();
|
||||||
updateListFragment();
|
updateListFragment();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSlightUpdate) {
|
if (isSlightUpdate) {
|
||||||
nearbyMapFragment.setArguments(bundle);
|
nearbyMapFragment.setBundleForUpdtes(bundle);
|
||||||
nearbyMapFragment.updateMapSlightly();
|
nearbyMapFragment.updateMapSlightly();
|
||||||
} else {
|
} else {
|
||||||
nearbyMapFragment.setArguments(bundle);
|
nearbyMapFragment.setBundleForUpdtes(bundle);
|
||||||
nearbyMapFragment.updateMapSignificantly();
|
nearbyMapFragment.updateMapSignificantly();
|
||||||
updateListFragment();
|
updateListFragment();
|
||||||
}
|
}
|
||||||
|
|
@ -498,7 +498,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateListFragment() {
|
private void updateListFragment() {
|
||||||
nearbyListFragment.setArguments(bundle);
|
nearbyListFragment.setBundleForUpdates(bundle);
|
||||||
nearbyListFragment.updateNearbyListSignificantly();
|
nearbyListFragment.updateNearbyListSignificantly();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ import static android.app.Activity.RESULT_OK;
|
||||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||||
|
|
||||||
public class NearbyListFragment extends DaggerFragment {
|
public class NearbyListFragment extends DaggerFragment {
|
||||||
|
private Bundle bundleForUpdates; // Carry information from activity about changed nearby places and current location
|
||||||
|
|
||||||
private static final Type LIST_TYPE = new TypeToken<List<Place>>() {
|
private static final Type LIST_TYPE = new TypeToken<List<Place>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
private static final Type CUR_LAT_LNG_TYPE = new TypeToken<LatLng>() {
|
private static final Type CUR_LAT_LNG_TYPE = new TypeToken<LatLng>() {
|
||||||
|
|
@ -80,8 +82,7 @@ public class NearbyListFragment extends DaggerFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateNearbyListSignificantly() {
|
public void updateNearbyListSignificantly() {
|
||||||
Bundle bundle = this.getArguments();
|
adapterFactory.updateAdapterData(getPlaceListFromBundle(bundleForUpdates),
|
||||||
adapterFactory.updateAdapterData(getPlaceListFromBundle(bundle),
|
|
||||||
(RVRendererAdapter<Place>) recyclerView.getAdapter());
|
(RVRendererAdapter<Place>) recyclerView.getAdapter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,4 +141,8 @@ public class NearbyListFragment extends DaggerFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBundleForUpdates(Bundle bundleForUpdates) {
|
||||||
|
this.bundleForUpdates = bundleForUpdates;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -111,6 +111,8 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
private final double CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT = 0.06;
|
private final double CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT = 0.06;
|
||||||
private final double CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE = 0.04;
|
private final double CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE = 0.04;
|
||||||
|
|
||||||
|
private Bundle bundleForUpdtes;// Carry information from activity about changed nearby places and current location
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named("prefs")
|
@Named("prefs")
|
||||||
SharedPreferences prefs;
|
SharedPreferences prefs;
|
||||||
|
|
@ -192,14 +194,12 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMapSlightly() {
|
public void updateMapSlightly() {
|
||||||
// Get arguments from bundle for new location
|
|
||||||
Bundle bundle = this.getArguments();
|
|
||||||
if (mapboxMap != null) {
|
if (mapboxMap != null) {
|
||||||
Gson gson = new GsonBuilder()
|
Gson gson = new GsonBuilder()
|
||||||
.registerTypeAdapter(Uri.class, new UriDeserializer())
|
.registerTypeAdapter(Uri.class, new UriDeserializer())
|
||||||
.create();
|
.create();
|
||||||
if (bundle != null) {
|
if (bundleForUpdtes != null) {
|
||||||
String gsonLatLng = bundle.getString("CurLatLng");
|
String gsonLatLng = bundleForUpdtes.getString("CurLatLng");
|
||||||
Type curLatLngType = new TypeToken<fr.free.nrw.commons.location.LatLng>() {}.getType();
|
Type curLatLngType = new TypeToken<fr.free.nrw.commons.location.LatLng>() {}.getType();
|
||||||
curLatLng = gson.fromJson(gsonLatLng, curLatLngType);
|
curLatLng = gson.fromJson(gsonLatLng, curLatLngType);
|
||||||
}
|
}
|
||||||
|
|
@ -209,17 +209,15 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMapSignificantly() {
|
public void updateMapSignificantly() {
|
||||||
|
|
||||||
Bundle bundle = this.getArguments();
|
|
||||||
if (mapboxMap != null) {
|
if (mapboxMap != null) {
|
||||||
if (bundle != null) {
|
if (bundleForUpdtes != null) {
|
||||||
Gson gson = new GsonBuilder()
|
Gson gson = new GsonBuilder()
|
||||||
.registerTypeAdapter(Uri.class, new UriDeserializer())
|
.registerTypeAdapter(Uri.class, new UriDeserializer())
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
String gsonPlaceList = bundle.getString("PlaceList");
|
String gsonPlaceList = bundleForUpdtes.getString("PlaceList");
|
||||||
String gsonLatLng = bundle.getString("CurLatLng");
|
String gsonLatLng = bundleForUpdtes.getString("CurLatLng");
|
||||||
String gsonBoundaryCoordinates = bundle.getString("BoundaryCoord");
|
String gsonBoundaryCoordinates = bundleForUpdtes.getString("BoundaryCoord");
|
||||||
Type listType = new TypeToken<List<Place>>() {}.getType();
|
Type listType = new TypeToken<List<Place>>() {}.getType();
|
||||||
List<Place> placeList = gson.fromJson(gsonPlaceList, listType);
|
List<Place> placeList = gson.fromJson(gsonPlaceList, listType);
|
||||||
Type curLatLngType = new TypeToken<fr.free.nrw.commons.location.LatLng>() {}.getType();
|
Type curLatLngType = new TypeToken<fr.free.nrw.commons.location.LatLng>() {}.getType();
|
||||||
|
|
@ -457,6 +455,8 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
|
|
||||||
private void setupMapView(Bundle savedInstanceState) {
|
private void setupMapView(Bundle savedInstanceState) {
|
||||||
MapboxMapOptions options = new MapboxMapOptions()
|
MapboxMapOptions options = new MapboxMapOptions()
|
||||||
|
.compassGravity(Gravity.BOTTOM | Gravity.LEFT)
|
||||||
|
.compassMargins(new int[]{12, 0, 0, 24})
|
||||||
.styleUrl(Style.OUTDOORS)
|
.styleUrl(Style.OUTDOORS)
|
||||||
.logoEnabled(false)
|
.logoEnabled(false)
|
||||||
.attributionEnabled(false)
|
.attributionEnabled(false)
|
||||||
|
|
@ -771,7 +771,7 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeFabs ( boolean isFabOpen){
|
private void closeFabs ( boolean isFabOpen){
|
||||||
if (isFabOpen) {
|
if (isFabOpen) {
|
||||||
fabPlus.startAnimation(rotate_backward);
|
fabPlus.startAnimation(rotate_backward);
|
||||||
fabCamera.startAnimation(fab_close);
|
fabCamera.startAnimation(fab_close);
|
||||||
|
|
@ -782,6 +782,11 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBundleForUpdtes(Bundle bundleForUpdtes) {
|
||||||
|
this.bundleForUpdtes = bundleForUpdtes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
if (mapView != null) {
|
if (mapView != null) {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ public class NetworkUtils {
|
||||||
|
|
||||||
public static boolean isInternetConnectionEstablished(Context context) {
|
public static boolean isInternetConnectionEstablished(Context context) {
|
||||||
ConnectivityManager cm =
|
ConnectivityManager cm =
|
||||||
(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
(ConnectivityManager)context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
|
||||||
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||||
return activeNetwork != null &&
|
return activeNetwork != null &&
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue