...
 
Commits (15)
......@@ -7,8 +7,8 @@ android {
applicationId "fr.mobdev.blooddonation"
minSdkVersion 17
targetSdkVersion 26
versionCode = "8"
versionName = "3.0"
versionCode = 13
versionName = "3.4"
}
buildTypes {
release {
......@@ -20,10 +20,8 @@ android {
dependencies {
compile 'com.google.android.gms:play-services-ads:11.0.4'
compile 'com.github.car2go.AnyMaps:anymaps-base:6.0.0'
compile 'com.github.car2go.AnyMaps:anymaps-osm:6.0.0'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
compile 'com.android.support:support-v4:26.0.0-alpha1'
......
......@@ -151,6 +151,8 @@ public class Database extends SQLiteOpenHelper {
}
public void addSitesToDb(List<BloodSite> sites) {
if(sites == null)
return;
//remove existing site in the list
List<BloodSite> oldList = getBloodSites(-1);
List<BloodSite> removeList = new ArrayList<>();
......@@ -477,8 +479,9 @@ public class Database extends SQLiteOpenHelper {
columns[0] = "latitude";
columns[1] = "longitude";
Cursor cursor = getReadableDatabase().query("user",columns,null,null,null,null,null);
cursor.moveToFirst();
LatLng loc = new LatLng(cursor.getDouble(0),cursor.getDouble(1));
LatLng loc = new LatLng(0,0);
if(cursor.moveToFirst())
loc = new LatLng(cursor.getDouble(0),cursor.getDouble(1));
cursor.close();
return loc;
}
......@@ -521,7 +524,6 @@ public class Database extends SQLiteOpenHelper {
for(Long id : newNotifications)
{
if(!ids.contains(id)) {
System.out.println("Db add notif "+id);
ContentValues values = new ContentValues();
values.put("siteId", id);
values.put("skip", 0);
......
......@@ -110,7 +110,6 @@ public class NetworkManager {
+"&swlat="+sWCorner.latitude
+"&swlon="+sWCorner.longitude
+"&marker=2&fb=facebook&t1=0&t2=10";
Log.v("Url",urlstr);
//getData
URL url = null;
try {
......
......@@ -149,16 +149,14 @@ public class InformationFragment extends Fragment {
majCView.isChecked(), majEView.isChecked(),
minCView.isChecked(), minEView.isChecked(),
kView.isChecked());
informationListener.onValidate();
informationListener.onValidate(!modify);
}
});
// TODO HIDE keyboard
// getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
return view;
}
public interface InformationListener {
void onValidate();
void onValidate(boolean isFirstTime);
}
}
......@@ -29,7 +29,6 @@ import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.util.LongSparseArray;
......@@ -149,6 +148,7 @@ public class MapsFragment extends Fragment implements OnMapReadyCallback {
postCode = savedInstanceState.getInt("posteCode");
previousLocation = new LatLng(latitude,longitude);
previousZoom = zoom;
myLocation = savedInstanceState.getParcelable("myLocation");
} else {
isFirstLocation = true;
postCode = -1;
......@@ -160,6 +160,8 @@ public class MapsFragment extends Fragment implements OnMapReadyCallback {
locationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
if(location == null)
return;
myLocation = location;
myLocationBt.setVisibility(View.VISIBLE);
if(map != null) {
......@@ -167,7 +169,7 @@ public class MapsFragment extends Fragment implements OnMapReadyCallback {
userCenter.remove();
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(location.getLatitude(),location.getLongitude()))
.icon(BitmapDescriptorFactory.getInstance().fromResource(R.drawable.userlocation));
.icon(BitmapDescriptorFactory.getInstance().fromResource(R.drawable.userlocation)).anchor(0.5f,0.5f);
userCenter = map.addMarker(markerOptions);
}
Database.getInstance(getActivity()).updateUserLoc(location.getLatitude(), location.getLongitude());
......@@ -175,7 +177,12 @@ public class MapsFragment extends Fragment implements OnMapReadyCallback {
List<Address> addrList = coder.getFromLocation(location.getLatitude(), location.getLongitude(), 5);
for (Address addr : addrList) {
if (addr != null && addr.getPostalCode() != null) {
Integer code = Integer.valueOf(addr.getPostalCode());
Integer code;
try {
code = Integer.valueOf(addr.getPostalCode());
} catch (NumberFormatException e) {
continue;
}
int original = (code - (code % 1000)) / 1000;
if (original == 97) {
postCode = (code - (code % 100)) / 100;
......@@ -271,14 +278,6 @@ public class MapsFragment extends Fragment implements OnMapReadyCallback {
map = null;
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if(grantResults[0] == PackageManager.PERMISSION_GRANTED || grantResults[1] == PackageManager.PERMISSION_GRANTED) {
startUpdateLocations();
}
}
public void startUpdateLocations() {
if(getActivity() == null)
return;
......@@ -290,9 +289,11 @@ public class MapsFragment extends Fragment implements OnMapReadyCallback {
stopUpdateLocations();
return;
}
locationListener.onLocationChanged(myLocation);
LocationManager manager = (LocationManager) getActivity().getSystemService(LOCATION_SERVICE);
if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED ||
ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
String[] permissions = {Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.ACCESS_COARSE_LOCATION};
ActivityCompat.requestPermissions(getActivity(),permissions,1);
} else {
......@@ -337,15 +338,31 @@ public class MapsFragment extends Fragment implements OnMapReadyCallback {
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if(mapView != null) {
mapView.onSaveInstanceState(outState);
outState.putBoolean("isFirstLocation",isFirstLocation);
outState.putDouble("locationLatitude",previousLocation.latitude);
outState.putDouble("locationLongitude",previousLocation.longitude);
outState.putFloat("locationZoom",previousZoom);
outState.putInt("posteCode",postCode);
outState.putParcelable("myLocation",myLocation);
}
super.onSaveInstanceState(outState);
}
public void askWritePermission() {
if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED ||
ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE};
ActivityCompat.requestPermissions(getActivity(),permissions,2);
}
}
@Override
public void onMapReady(AnyMap anyMap) {
map = anyMap;
askWritePermission();
map.animateCamera(CameraUpdateFactory.getInstance().newLatLngZoom(previousLocation,previousZoom));
startUpdateLocations();
country = Country.FRANCE;
......@@ -373,6 +390,8 @@ public class MapsFragment extends Fragment implements OnMapReadyCallback {
int idx = markerList.indexOfValue(marker);
if(idx < 0 || idx >= markerList.size())
return false;
long id = markerList.keyAt(idx);
selectedSite = id;
BloodSite infoSite = null;
......@@ -410,13 +429,14 @@ public class MapsFragment extends Fragment implements OnMapReadyCallback {
selectedSite = -1;
}
});
startUpdateLocations();
initPosition();
BootReceiver.startNextChecking(getActivity(), false);
}
private LatLng getCorner(CORNER corner) {
if(map == null)
return new LatLng(0,0);
com.car2go.maps.Projection pr = map.getProjection();
LatLngBounds bounds = pr.getVisibleRegion().latLngBounds;
if(corner == CORNER.TOP_RIGHT)
......@@ -497,6 +517,7 @@ public class MapsFragment extends Fragment implements OnMapReadyCallback {
else
res = R.drawable.mixed;
options.icon(BitmapDescriptorFactory.getInstance().fromResource(res));
options.anchor(0.5f,0.5f);
}
markerList.put(site.getDbId(),map.addMarker(options));
}
......
......@@ -9,6 +9,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<TextView
android:text="@string/osm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
/>
<ImageButton
android:id="@+id/move_to_user_location"
android:contentDescription="@string/my_location"
......
......@@ -27,7 +27,7 @@
<string name="action_del">Supprimer</string>
<string name="action_help">Aide</string>
<string name="donation_type">Type de don</string>
<string name="delete_donation_message">Voulez vous supprimer les dons séléctionnés?</string>
<string name="delete_donation_message">Voulez vous supprimer les dons séléctionnés ?</string>
<string name="legend_efs">Site fixe (ouvert toute l\'année)</string>
<string name="legend_blood">Collecte de sang total</string>
<string name="legend_plasma">Collecte de plasma</string>
......@@ -48,12 +48,12 @@
<string name="help2">Pour saisir les informations D C E c e K, il suffit d\'appuyer sur </string>
<string name="help3">ou sur </string>
<string name="help4">pour changer le signe correspondant à la lettre associée. Le symbôle affiché correspond à votre sélection.</string>
<string name="rhesus_checked">Image correspondant à la sélection du + pour les informations de rhesus</string>
<string name="rhesus_checked">Image correspondant à la sélection du + pour les informations de rhésus</string>
<string name="rhesus_unchecked">Image correspondant à la sélection du - pour les informations de rhésus</string>
<string name="help_title">Aide</string>
<string name="confirm">Vous avez précédement fait part de votre intention de vous rendre à la donation du </string>
<string name="confirm2">dans la ville de</string>
<string name="confirm3">Vous y êtes vous rendu? En confirmant nous ajouterons votre don à la liste de vos dons.</string>
<string name="confirm3">Vous y êtes vous rendu⋅e ? En confirmant nous ajouterons votre don à la liste de vos dons.</string>
<string name="confirm_donation">Confirmer</string>
<string name="confirm_title">Confirmation de don</string>
<string name="go_iti">Itinéraire</string>
......@@ -62,11 +62,11 @@
<string name="address">Adresse</string>
<string name="info_title">Vos informations</string>
<string name="info_change">Modifier vos informations</string>
<string name="info_change_sum">Modifier vos informations de ville, groupe sanguin, nom,...</string>
<string name="info_change_sum">Modifier vos informations de ville, groupe sanguin, nom,</string>
<string name="wifi_only">Localisation réseau uniquement</string>
<string name="wifi_only_sum">Ne pas utiliser le gps pour la localisation</string>
<string name="notif_activ">Activer les notifications</string>
<string name="notif_activ_sum">Les notifications sont actives si la case est coché</string>
<string name="notif_activ_sum">Les notifications sont actives si la case est cochée</string>
<string name="distance_to">Distance maximum de notification</string>
<string name="distance_to_sum">Distance maximum entre l\'utilisateur et le centre de don utilisé pour la notification</string>
<string name="service_activ">Activer le service</string>
......@@ -89,6 +89,9 @@
<string name="anymaps_licence">Copyright 2017 car2go group GmbH\nReleased under the MIT license.\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</string>
<string name="blood_donation_licence">Copyright © 2017 Anthony Chomienne, anthony@mob–dev.fr\n\nThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110–1301, USA.</string>
<string name="my_location">Centrer sur ma position</string>
<string name="osm">Données © OpenStreetMap</string>
<string name="need_write">La Carte à besoin des droits en écriture/lecture sur le stockage externe</string>
<string name="retry">Réessayer</string>
<string-array name="gender_array">
......
include ':app'
include ':app', ':anymaps-base', ':anymaps-osm'