diff --git a/.idea/ChatHistory_schema_v2.xml b/.idea/ChatHistory_schema_v2.xml index 3df4d03..97fbdf6 100644 --- a/.idea/ChatHistory_schema_v2.xml +++ b/.idea/ChatHistory_schema_v2.xml @@ -3,7 +3,12 @@ diff --git a/app/release/LorealBa-MNY-release.apk b/app/release/LorealBa-Mny-FixGeotag-release.apk similarity index 85% rename from app/release/LorealBa-MNY-release.apk rename to app/release/LorealBa-Mny-FixGeotag-release.apk index 94252b7..d412b04 100644 Binary files a/app/release/LorealBa-MNY-release.apk and b/app/release/LorealBa-Mny-FixGeotag-release.apk differ diff --git a/app/src/main/java/com/cpm/lorealbaMabeline/CounterLoginActivity.java b/app/src/main/java/com/cpm/lorealbaMabeline/CounterLoginActivity.java index e7de142..694eb82 100644 --- a/app/src/main/java/com/cpm/lorealbaMabeline/CounterLoginActivity.java +++ b/app/src/main/java/com/cpm/lorealbaMabeline/CounterLoginActivity.java @@ -29,6 +29,7 @@ import com.google.android.gms.location.FusedLocationProviderClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; import com.google.android.gms.location.LocationSettingsRequest; +import com.google.android.gms.location.Priority; import com.google.android.gms.location.SettingsClient; import com.cpm.lorealbaMabeline.delegates.PrefHelper; @@ -40,6 +41,7 @@ import androidx.recyclerview.widget.LinearLayoutManager; import android.os.Bundle; import android.text.InputFilter; +import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.view.Window; @@ -241,7 +243,6 @@ public class CounterLoginActivity extends AppCompatActivity implements View.OnCl } catch (Exception e) { e.fillInStackTrace(); //test("Location", "Lat: " + lat + ", Lng: " + lon);} } - } @Override protected void onResume() { @@ -265,11 +266,10 @@ public class CounterLoginActivity extends AppCompatActivity implements View.OnCl } } } - private void enableLocationSettings() { @SuppressLint("VisibleForTests") LocationRequest locationRequest = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) // new Priority constant - .setInterval(30 * 1000) + .setInterval(3 * 1000) .setFastestInterval(5 * 1000); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(locationRequest) @@ -327,7 +327,7 @@ public class CounterLoginActivity extends AppCompatActivity implements View.OnCl } String jsonString = jsonObject.toString(); - //test("jsondata",jsonString); + Log.d("Location",jsonString); try { OkHttpClient okHttpClient = new OkHttpClient.Builder().readTimeout(CommonString.TIMEOUT, TimeUnit.SECONDS).writeTimeout(CommonString.TIMEOUT, TimeUnit.SECONDS).connectTimeout(CommonString.TIMEOUT, TimeUnit.SECONDS).build(); diff --git a/app/src/main/java/com/cpm/lorealbaMabeline/constant/CommonString.java b/app/src/main/java/com/cpm/lorealbaMabeline/constant/CommonString.java index f0d3483..01925ad 100644 --- a/app/src/main/java/com/cpm/lorealbaMabeline/constant/CommonString.java +++ b/app/src/main/java/com/cpm/lorealbaMabeline/constant/CommonString.java @@ -8,11 +8,11 @@ import com.cpm.lorealbaMabeline.utils.AppUtils; * Created by jeevanp on 14-12-2017. */ public class CommonString { - public static final String BACKUP_FOLDER_NAME = "LorealBa_Backup"; - public static final String IMAGE_FOLDER_NAME = "LorealBa_Images"; - public static final String PROFILE_FOLDER_NAME = "LorealProfile"; - public static final String LorealPromo_Folder = "LorealPromoOffers"; - public static final String LorealBaApkFolder = "LorealBaApkFolder"; + public static final String BACKUP_FOLDER_NAME = "LorealBaMNY_Backup"; + public static final String IMAGE_FOLDER_NAME = "LorealBaMNY_Images"; + public static final String PROFILE_FOLDER_NAME = "LorealMNYProfile"; + public static final String LorealPromo_Folder = "LorealMNYPromoOffers"; + public static final String LorealBaApkFolder = "LorealBaMNYApkFolder"; public static String getLorealBaApkFolder(Context context) { return AppUtils.getInternalDirectory(context, LorealBaApkFolder).getAbsolutePath() + "/"; @@ -35,8 +35,8 @@ public class CommonString { } //preference - public static final String KEY_DB_NAME = "LorealBaNew"; - public static final int KEY_DB_NAME_iD = 2; + public static final String KEY_DB_NAME = "LorealBaMaybeDb"; + public static final int KEY_DB_NAME_iD = 3; public static final String KEY_LOGIN_DATA = "login_data"; public static final String TAG_FROM = "FROM"; public static final int TIMEOUT = 180; diff --git a/app/src/main/java/com/cpm/lorealbaMabeline/dailyactivity/StoreImageActivity.java b/app/src/main/java/com/cpm/lorealbaMabeline/dailyactivity/StoreImageActivity.java index 13e37e2..c927d94 100644 --- a/app/src/main/java/com/cpm/lorealbaMabeline/dailyactivity/StoreImageActivity.java +++ b/app/src/main/java/com/cpm/lorealbaMabeline/dailyactivity/StoreImageActivity.java @@ -12,7 +12,6 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentSender; -import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -20,6 +19,7 @@ import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.os.Environment; +import android.os.Looper; import androidx.annotation.NonNull; import androidx.core.app.ActivityCompat; @@ -95,6 +95,8 @@ import retrofit2.Response; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; +import android.content.SharedPreferences; + public class StoreImageActivity extends AppCompatActivity implements View.OnClickListener { private static final int PERMISSION_ALL = 99; private Button btn_save; @@ -102,6 +104,7 @@ public class StoreImageActivity extends AppCompatActivity implements View.OnClic private String _pathforcheck, _path, str, img_str, selfie_imge, visit_date, username, counter_id, userType; private Lorealba_Database db; private Runnable run; + private boolean isGeoTagAlertShown = false; private Toolbar toolbar; private ProgressDialog loading; private Retrofit adapter; @@ -114,6 +117,7 @@ public class StoreImageActivity extends AppCompatActivity implements View.OnClic private LocationCallback locationCallback = null; private SharedPreferences.Editor editor = null; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -205,7 +209,6 @@ public class StoreImageActivity extends AppCompatActivity implements View.OnClic @Override public void onClick(View v) { int id = v.getId(); - if (id == R.id.img_cam_selfie) { clickFlag = true; _pathforcheck = counter_id + "_Counter_Selfie_img_" + username + "_" + visit_date.replace("/", "") + "_" + getCurrentTime().replace(":", "") + ".jpg"; @@ -330,11 +333,9 @@ public class StoreImageActivity extends AppCompatActivity implements View.OnClic StoreImageActivity.this.finish(); } } - return super.onOptionsItemSelected(item); } - private void AttempBaCoverage(final ProgressDialog loading, Context context) { try { getMid(); @@ -546,7 +547,6 @@ public class StoreImageActivity extends AppCompatActivity implements View.OnClic } else { /// checking GeoFencing getLastLocation(); - checkingGeoFencing(getMid()); } } @@ -558,7 +558,6 @@ public class StoreImageActivity extends AppCompatActivity implements View.OnClic } if (!success_geoTag) { getLastLocation(); - checkingGeoFencing(getMid()); } checkgpsEnableDevice(); getMid(); @@ -579,28 +578,63 @@ public class StoreImageActivity extends AppCompatActivity implements View.OnClic } private void enableLocationSettings() { - LocationRequest locationRequest = new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, // priority - 5000 // intervalMillis: 5 seconds - ).setMinUpdateIntervalMillis(3000) // fastest interval + LocationRequest locationRequest = new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 5000) + .setMinUpdateIntervalMillis(3000) + .setMaxUpdateDelayMillis(6000) + .setMinUpdateDistanceMeters(0f)// Optional batching + .setWaitForAccurateLocation(true) // Optional, improves first fix .build(); - LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest).setAlwaysShow(true); // show dialog if GPS is off + + LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() + .addLocationRequest(locationRequest) + .setAlwaysShow(true); // Show dialog if GPS is off SettingsClient settingsClient = LocationServices.getSettingsClient(this); - settingsClient.checkLocationSettings(builder.build()).addOnSuccessListener(locationSettingsResponse -> { - // All location settings are satisfied. You can request location updates here. - }).addOnFailureListener(e -> { - if (e instanceof ResolvableApiException) { - try { - ResolvableApiException resolvable = (ResolvableApiException) e; - resolvable.startResolutionForResult((Activity) this, REQUEST_LOCATION); - } catch (IntentSender.SendIntentException sendEx) { - // Ignore the error. - sendEx.fillInStackTrace(); + settingsClient.checkLocationSettings(builder.build()) + .addOnSuccessListener(locationSettingsResponse -> { + // All location settings are satisfied, start updates + startLocationUpdates(locationRequest); + }) + .addOnFailureListener(e -> { + if (e instanceof ResolvableApiException) { + try { + ResolvableApiException resolvable = (ResolvableApiException) e; + resolvable.startResolutionForResult((Activity) this, REQUEST_LOCATION); + } catch (IntentSender.SendIntentException sendEx) { + sendEx.printStackTrace(); + } + } + }); + } + + private void startLocationUpdates(LocationRequest locationRequest) { + fusedLocationClient = LocationServices.getFusedLocationProviderClient(this); + + locationCallback = new LocationCallback() { + @Override + public void onLocationResult(@NonNull LocationResult locationResult) { + if (locationResult == null) return; + + for (Location location : locationResult.getLocations()) { + if (location != null) { + lat = location.getLatitude(); + lon = location.getLongitude(); + } } } - }); + }; + + // Don't forget permissions check + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) + != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + // Request permissions if not granted + return; + } + fusedLocationClient.requestLocationUpdates(locationRequest, locationCallback, Looper.getMainLooper()); } + + private boolean hasGPSDevice(Context context) { final LocationManager mgr = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); if (mgr == null) return false; @@ -643,7 +677,6 @@ public class StoreImageActivity extends AppCompatActivity implements View.OnClic if (jcpObject != null && db.insertJCPData(jcpObject)) { /// checking GeoFencing getLastLocation(); - checkingGeoFencing(getMid()); AlertandMessages.showToastMsg(context, "Journey Plan Download Successfully."); JourneyPlan jcp = db.getBIDfromJCP(username, counter_id); if (jcp != null && jcp.getCheckout() != null && !jcp.getCheckout().isEmpty() && jcp.getCheckout().equals("Y")) { @@ -829,8 +862,36 @@ public class StoreImageActivity extends AppCompatActivity implements View.OnClic if (fusedLocationClient == null) { fusedLocationClient = LocationServices.getFusedLocationProviderClient(this); } - // fastest interval - LocationRequest locationRequest = new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 5000).setMinUpdateIntervalMillis(3000) // fastest interval + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) + != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + // Request permissions if not granted + checkAndRequestPermissions(); + return; + } + // First, try to get the last known location + fusedLocationClient.getLastLocation() + .addOnSuccessListener(location -> { + if (location != null) { + lat = location.getLatitude(); + lon = location.getLongitude(); + checkingGeoFencing(getMid()); + } else { + // No last known location, request updates for a new one + requestNewLocation(); + } + }) + .addOnFailureListener(e -> { + // Fallback: explicit request for a new location + requestNewLocation(); + }); + } + + private void requestNewLocation() { + LocationRequest locationRequest = new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 5000) + .setMinUpdateIntervalMillis(3000) + .setMaxUpdateDelayMillis(6000) + .setMinUpdateDistanceMeters(0f) + .setWaitForAccurateLocation(true) .build(); locationCallback = new LocationCallback() { @Override @@ -839,7 +900,10 @@ public class StoreImageActivity extends AppCompatActivity implements View.OnClic if (location != null) { lat = location.getLatitude(); lon = location.getLongitude(); - Log.d("Location", "Lat: " + lat + ", Lng: " + lon); + Log.d("Location", "Lat: " + lat + ", Lng: " + lon + " (new)"); + checkingGeoFencing(getMid()); + stopLocationUpdates(); // Stop updates after first valid location + break; } } } @@ -847,6 +911,7 @@ public class StoreImageActivity extends AppCompatActivity implements View.OnClic if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Request permissions if not granted + checkAndRequestPermissions(); return; } fusedLocationClient.requestLocationUpdates(locationRequest, locationCallback, Looper.getMainLooper()); @@ -861,27 +926,37 @@ public class StoreImageActivity extends AppCompatActivity implements View.OnClic @Override public void onDestroy() { super.onDestroy(); - stopLocationUpdates(); + // stopLocationUpdates(); if (loading != null && loading.isShowing()) { loading.dismiss(); } } + @Override + protected void onPause() { + super.onPause(); + stopLocationUpdates(); + } + private void checkingGeoFencing(JourneyPlan jcp) { if (jcp != null && jcp.getBID() != null) { if (jcp.getGeoTag() != null && !jcp.getGeoTag().equalsIgnoreCase(CommonString.KEY_N) && jcp.getGeoFencingAllow() != null && jcp.getGeoFencingAllow() == 1) { int distance = jcp.getGeoFencingRadius() != null ? jcp.getGeoFencingRadius() : 0; int current_dist_from_store_using_lat = 0; + Log.d("latdata",lat + ","+lon + ","+jcp.getLatitude() + ","+jcp.getLongitude()); if (jcp.getLatitude() != 0.0 && jcp.getLongitude() != 0.0 && jcp.getGeoFencingRadius() != 0 && lat != 0.0 && lon != 0.0) { current_dist_from_store_using_lat = DistanceUtils.calculateDistanceInMeters(lat, lon, jcp.getLatitude(), jcp.getLongitude()); Log.d("TagLoc", "Radius " + distance + "\nCurrent dist " + current_dist_from_store_using_lat); if (current_dist_from_store_using_lat > distance) { String msg = getString(R.string.you_need_to_be_within) + " " + distance + " metres " + getString(R.string.you_need_to_be_in_the_store) + "\n\n" + getString(R.string.distance_from_the_store) + " " + current_dist_from_store_using_lat + " " + getString(R.string.meters); + if (isFinishing() || (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1 && isDestroyed())) { + return; + } AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getResources().getString(R.string.alert)); builder.setMessage(msg).setCancelable(false).setPositiveButton(getResources().getString(R.string.ok), (dialog1, id) -> { - dialog1.cancel(); + dialog1.dismiss(); finishAffinity(); }); AlertDialog alert = builder.create(); @@ -889,18 +964,30 @@ public class StoreImageActivity extends AppCompatActivity implements View.OnClic } } } else { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(getResources().getString(R.string.dialog_title)); - builder.setMessage(getString(R.string.first_geotag_the_store)).setCancelable(false).setPositiveButton(getResources().getString(R.string.ok), (dialog1, id) -> { - dialog1.cancel(); - success_geoTag = false; - Intent in = new Intent(this, GeoTaggingActivity.class); - startActivity(in); - }); - AlertDialog alert = builder.create(); - alert.show(); + if (isFinishing() || (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1 && isDestroyed())) { + return; + } + db.open(); + if (!isGeoTagAlertShown && db.getinsertGeotaggingData(storeId.toString(), counter_id, username, "Y").isEmpty()) { + isGeoTagAlertShown = true; + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(getResources().getString(R.string.dialog_title)); + builder.setMessage(getString(R.string.first_geotag_the_store)) + .setCancelable(false) + .setPositiveButton(getResources().getString(R.string.ok), (dialog1, id) -> { + dialog1.dismiss(); + success_geoTag = false; + isGeoTagAlertShown = false; // Reset the flag if needed for future + Intent in = new Intent(this, GeoTaggingActivity.class); + startActivity(in); + // Optionally start geo tagging activity here + }); + AlertDialog alert = builder.create(); + alert.show(); + } } } } + } diff --git a/app/src/main/java/com/cpm/lorealbaMabeline/dailyactivity/TabLoginActivity.java b/app/src/main/java/com/cpm/lorealbaMabeline/dailyactivity/TabLoginActivity.java index b3e37e4..6278732 100644 --- a/app/src/main/java/com/cpm/lorealbaMabeline/dailyactivity/TabLoginActivity.java +++ b/app/src/main/java/com/cpm/lorealbaMabeline/dailyactivity/TabLoginActivity.java @@ -169,9 +169,10 @@ public class TabLoginActivity extends AppCompatActivity implements View.OnClickL } private void enableLocationSettings() { - @SuppressLint("VisibleForTests") LocationRequest locationRequest = LocationRequest.create() + @SuppressLint("VisibleForTests") + LocationRequest locationRequest = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) // new Priority constant - .setInterval(30 * 1000) + .setInterval(3 * 1000) .setFastestInterval(5 * 1000); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(locationRequest) diff --git a/app/src/main/java/com/cpm/lorealbaMabeline/geotag/GeoTaggingActivity.java b/app/src/main/java/com/cpm/lorealbaMabeline/geotag/GeoTaggingActivity.java index 485f05b..e144250 100644 --- a/app/src/main/java/com/cpm/lorealbaMabeline/geotag/GeoTaggingActivity.java +++ b/app/src/main/java/com/cpm/lorealbaMabeline/geotag/GeoTaggingActivity.java @@ -122,7 +122,7 @@ public class GeoTaggingActivity extends AppCompatActivity implements OnMapReadyC AlertandMessages.showToastMsg(view.getContext(), getResources().getString(R.string.takeimage)); } } catch (Exception e) { - e.fillInStackTrace(); + e.printStackTrace(); } }); camera_fab.setOnClickListener(view -> { @@ -141,13 +141,14 @@ public class GeoTaggingActivity extends AppCompatActivity implements OnMapReadyC AlertandMessages.showToastMsg(context, getResources().getString(R.string.nonetwork)); } } catch (Exception e) { - e.fillInStackTrace(); + e.printStackTrace(); } }); - - if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION) - != PackageManager.PERMISSION_GRANTED) { - ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION); + if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED || + ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(this, new String[]{ + Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION + }, LOCATION_PERMISSION_REQUEST_CODE); } locationCallback = new LocationCallback() { @Override @@ -178,13 +179,27 @@ public class GeoTaggingActivity extends AppCompatActivity implements OnMapReadyC } private void startLocationUpdates() { - @SuppressLint("VisibleForTests") LocationRequest locationRequest = new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 5000) - .setMinUpdateIntervalMillis(1000) + LocationRequest locationRequest = new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 5000) + .setMinUpdateIntervalMillis(3000) + .setWaitForAccurateLocation(true) + .setMaxUpdateDelayMillis(6000) .build(); - if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || + ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { fusedLocationClient.requestLocationUpdates(locationRequest, locationCallback, Looper.getMainLooper()); + fusedLocationClient.getLastLocation().addOnSuccessListener(this, location -> { + if (location != null && (latitude == 0.0 && longitude == 0.0)) { + latitude = location.getLatitude(); + longitude = location.getLongitude(); + previousLatitude = latitude; + previousLongitude = longitude; + updateMapWithLocation(latitude, longitude); + } + }); } else { - ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1001); + ActivityCompat.requestPermissions(this, + new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, + LOCATION_PERMISSION_REQUEST_CODE); } } @@ -193,7 +208,6 @@ public class GeoTaggingActivity extends AppCompatActivity implements OnMapReadyC Log.e("jeevanp", "" + lat); String address = ""; try { - List
addressList = geocoder.getFromLocation(lat, lon, 1); if (addressList != null && !addressList.isEmpty()) { address = addressList.get(0).getAddressLine(0); @@ -236,31 +250,51 @@ public class GeoTaggingActivity extends AppCompatActivity implements OnMapReadyC mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); mMap.getUiSettings().setZoomControlsEnabled(true); mMap.getUiSettings().setCompassEnabled(true); - mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(22.5726, 88.3639), 15)); - // Enable My Location layer + mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude,longitude), 15)); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { - mMap.setMyLocationEnabled(true); // ✅ this shows blue dot - mMap.getUiSettings().setMyLocationButtonEnabled(true); // ✅ this shows the GPS icon + mMap.setMyLocationEnabled(true); + mMap.getUiSettings().setMyLocationButtonEnabled(true); startLocationUpdates(); } else { - // request permission ActivityCompat.requestPermissions(this, - new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, + new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, LOCATION_PERMISSION_REQUEST_CODE); } + fusedLocationClient.getLastLocation().addOnSuccessListener(location -> { + if (location != null && (latitude == 0.0 && longitude == 0.0)) { + latitude = location.getLatitude(); + longitude = location.getLongitude(); + previousLatitude = latitude; + previousLongitude = longitude; + updateMapWithLocation(latitude, longitude); + } + }); } @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); if (requestCode == LOCATION_PERMISSION_REQUEST_CODE) { - if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { - mMap.setMyLocationEnabled(true); - mMap.getUiSettings().setMyLocationButtonEnabled(true); + boolean locationGranted = false; + for (int i = 0; i < grantResults.length; i++) { + if (grantResults[i] == PackageManager.PERMISSION_GRANTED) { + locationGranted = true; + break; } } + if (locationGranted) { + if (mMap != null) { + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || + ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { + mMap.setMyLocationEnabled(true); + mMap.getUiSettings().setMyLocationButtonEnabled(true); + } + } + startLocationUpdates(); + } else { + Toast.makeText(this, "Location permissions are required for geotagging", Toast.LENGTH_LONG).show(); + } } } @@ -327,9 +361,6 @@ public class GeoTaggingActivity extends AppCompatActivity implements OnMapReadyC if (mapFragment != null) { mapFragment.getMapAsync(this); } - if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { - return; - } try { app_ver = String.valueOf(getPackageManager().getPackageInfo(getPackageName(), 0).versionName); } catch (PackageManager.NameNotFoundException ignored) { @@ -363,14 +394,12 @@ public class GeoTaggingActivity extends AppCompatActivity implements OnMapReadyC @Override protected String doInBackground(Void... params) { try { - // uploading Geotag - uploadflag = false; geotaglist = db.getinsertGeotaggingData(jcpGetset.getStoreId().toString(), counter_id, username, CommonString.KEY_N); if (!geotaglist.isEmpty()) { String jsonString2 = getString(); - Log.e("jsonString2", jsonString2); + // Log.e("jsonString2", jsonString2); String result = upload.downloadDataUniversal(jsonString2); - Log.e("jsonString2", result); + // Log.e("jsonString2", result); if (result.equalsIgnoreCase(CommonString.MESSAGE_NO_RESPONSE_SERVER)) { uploadflag = false; throw new SocketTimeoutException(); @@ -469,11 +498,10 @@ public class GeoTaggingActivity extends AppCompatActivity implements OnMapReadyC } private void enableLocationSettings() { - LocationRequest locationRequest = new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, // priority - 5000 // intervalMillis: 5 seconds - ).setMinUpdateIntervalMillis(3000) // fastest interval + LocationRequest locationRequest = new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 5000) + .setMinUpdateIntervalMillis(3000) .build(); - LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest).setAlwaysShow(true); // show dialog if GPS is off + LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest).setAlwaysShow(true); SettingsClient settingsClient = LocationServices.getSettingsClient(this); settingsClient.checkLocationSettings(builder.build()).addOnSuccessListener(locationSettingsResponse -> { diff --git a/library/build/intermediates/incremental/lintVitalAnalyzeRelease/module.xml b/library/build/intermediates/incremental/lintVitalAnalyzeRelease/module.xml index dbb7046..2c8815b 100644 --- a/library/build/intermediates/incremental/lintVitalAnalyzeRelease/module.xml +++ b/library/build/intermediates/incremental/lintVitalAnalyzeRelease/module.xml @@ -1,9 +1,9 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/library/build/intermediates/incremental/mergeReleaseShaders/merger.xml b/library/build/intermediates/incremental/mergeReleaseShaders/merger.xml index c891bae..ff3efc1 100644 --- a/library/build/intermediates/incremental/mergeReleaseShaders/merger.xml +++ b/library/build/intermediates/incremental/mergeReleaseShaders/merger.xml @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/library/build/intermediates/incremental/packageReleaseAssets/merger.xml b/library/build/intermediates/incremental/packageReleaseAssets/merger.xml index 49b4591..b4441fe 100644 --- a/library/build/intermediates/incremental/packageReleaseAssets/merger.xml +++ b/library/build/intermediates/incremental/packageReleaseAssets/merger.xml @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/library/build/intermediates/incremental/release/packageReleaseResources/compile-file-map.properties b/library/build/intermediates/incremental/release/packageReleaseResources/compile-file-map.properties index 9aed62e..a611284 100644 --- a/library/build/intermediates/incremental/release/packageReleaseResources/compile-file-map.properties +++ b/library/build/intermediates/incremental/release/packageReleaseResources/compile-file-map.properties @@ -1,6 +1,6 @@ -#Mon Aug 04 13:30:30 IST 2025 -com.androidbuts.multispinnerfilter.library-main-5\:/layout/textview_for_spinner.xml=D\:\\LorealBa-Latest-July-2025\\library\\build\\intermediates\\packaged_res\\release\\layout\\textview_for_spinner.xml -com.androidbuts.multispinnerfilter.library-main-5\:/layout/activity_main.xml=D\:\\LorealBa-Latest-July-2025\\library\\build\\intermediates\\packaged_res\\release\\layout\\activity_main.xml -com.androidbuts.multispinnerfilter.library-main-5\:/layout/alert_dialog_listview_search.xml=D\:\\LorealBa-Latest-July-2025\\library\\build\\intermediates\\packaged_res\\release\\layout\\alert_dialog_listview_search.xml -com.androidbuts.multispinnerfilter.library-main-5\:/layout/item_listview_single.xml=D\:\\LorealBa-Latest-July-2025\\library\\build\\intermediates\\packaged_res\\release\\layout\\item_listview_single.xml -com.androidbuts.multispinnerfilter.library-main-5\:/layout/item_listview_multiple.xml=D\:\\LorealBa-Latest-July-2025\\library\\build\\intermediates\\packaged_res\\release\\layout\\item_listview_multiple.xml +#Wed Aug 06 13:34:25 IST 2025 +com.androidbuts.multispinnerfilter.library-main-5\:/layout/textview_for_spinner.xml=D\:\\LorealBa-Latest-MNY-July-2025\\library\\build\\intermediates\\packaged_res\\release\\layout\\textview_for_spinner.xml +com.androidbuts.multispinnerfilter.library-main-5\:/layout/activity_main.xml=D\:\\LorealBa-Latest-MNY-July-2025\\library\\build\\intermediates\\packaged_res\\release\\layout\\activity_main.xml +com.androidbuts.multispinnerfilter.library-main-5\:/layout/alert_dialog_listview_search.xml=D\:\\LorealBa-Latest-MNY-July-2025\\library\\build\\intermediates\\packaged_res\\release\\layout\\alert_dialog_listview_search.xml +com.androidbuts.multispinnerfilter.library-main-5\:/layout/item_listview_single.xml=D\:\\LorealBa-Latest-MNY-July-2025\\library\\build\\intermediates\\packaged_res\\release\\layout\\item_listview_single.xml +com.androidbuts.multispinnerfilter.library-main-5\:/layout/item_listview_multiple.xml=D\:\\LorealBa-Latest-MNY-July-2025\\library\\build\\intermediates\\packaged_res\\release\\layout\\item_listview_multiple.xml diff --git a/library/build/intermediates/incremental/release/packageReleaseResources/merger.xml b/library/build/intermediates/incremental/release/packageReleaseResources/merger.xml index 2d3321b..f9d0f0e 100644 --- a/library/build/intermediates/incremental/release/packageReleaseResources/merger.xml +++ b/library/build/intermediates/incremental/release/packageReleaseResources/merger.xml @@ -1,5 +1,5 @@ -#29CA97#06ACE4#06ACE4#1589FF#FFFFFF#000000#D1D0CE#E1E2E2#3f51b5#E1E2E2#303f9f#F06292#FF0000#00FFFF#ADD8E6#686868#747474#AAAAAA#AAAAAA#E1E2E2#455FB6#99979C16dp16dpType to Search + - \ No newline at end of file + \ No newline at end of file diff --git a/library/build/intermediates/lint-cache/lintVitalAnalyzeRelease/maven.google/master-index.xml b/library/build/intermediates/lint-cache/lintVitalAnalyzeRelease/maven.google/master-index.xml index 0517ad1..1172485 100644 --- a/library/build/intermediates/lint-cache/lintVitalAnalyzeRelease/maven.google/master-index.xml +++ b/library/build/intermediates/lint-cache/lintVitalAnalyzeRelease/maven.google/master-index.xml @@ -169,6 +169,7 @@ + diff --git a/library/build/intermediates/lint-cache/lintVitalAnalyzeRelease/sdk_index/snapshot.gz b/library/build/intermediates/lint-cache/lintVitalAnalyzeRelease/sdk_index/snapshot.gz index 090834d..55a204c 100644 Binary files a/library/build/intermediates/lint-cache/lintVitalAnalyzeRelease/sdk_index/snapshot.gz and b/library/build/intermediates/lint-cache/lintVitalAnalyzeRelease/sdk_index/snapshot.gz differ diff --git a/library/build/intermediates/lint_model/release/module.xml b/library/build/intermediates/lint_model/release/module.xml index dbb7046..2c8815b 100644 --- a/library/build/intermediates/lint_model/release/module.xml +++ b/library/build/intermediates/lint_model/release/module.xml @@ -1,9 +1,9 @@ + simpleName="LorealBa-Latest-MNY-July-2025:library"/> @@ -174,7 +174,7 @@ roots=":@@:library::release,com.github.rey5137:material:1.2.2@aar,androidx.legacy:legacy-support-v4:1.0.0@aar,com.google.android.material:material:1.12.0@aar,androidx.viewpager2:viewpager2:1.0.0@aar,androidx.recyclerview:recyclerview:1.1.0@aar,androidx.constraintlayout:constraintlayout:2.0.1@aar,androidx.appcompat:appcompat-resources:1.6.1@aar,androidx.appcompat:appcompat:1.6.1@aar,androidx.cardview:cardview:1.0.0@aar,androidx.media:media:1.0.0@aar,androidx.legacy:legacy-support-core-ui:1.0.0@aar,androidx.transition:transition:1.5.0@aar,androidx.dynamicanimation:dynamicanimation:1.0.0@aar,androidx.legacy:legacy-support-core-utils:1.0.0@aar,androidx.fragment:fragment:1.3.6@aar,androidx.fragment:fragment:1.3.6@aar,androidx.activity:activity:1.8.0@aar,androidx.coordinatorlayout:coordinatorlayout:1.1.0@aar,androidx.drawerlayout:drawerlayout:1.1.1@aar,androidx.vectordrawable:vectordrawable-animated:1.1.0@aar,androidx.vectordrawable:vectordrawable:1.1.0@aar,androidx.loader:loader:1.0.0@aar,androidx.viewpager:viewpager:1.0.0@aar,androidx.slidingpanelayout:slidingpanelayout:1.0.0@aar,androidx.swiperefreshlayout:swiperefreshlayout:1.0.0@aar,androidx.asynclayoutinflater:asynclayoutinflater:1.0.0@aar,androidx.emoji2:emoji2-views-helper:1.2.0@aar,androidx.emoji2:emoji2:1.2.0@aar,androidx.customview:customview:1.1.0@aar,androidx.savedstate:savedstate:1.2.1@aar,androidx.lifecycle:lifecycle-viewmodel:2.6.2@aar,androidx.lifecycle:lifecycle-viewmodel:2.6.2@aar,androidx.lifecycle:lifecycle-process:2.6.2@aar,androidx.lifecycle:lifecycle-livedata-core:2.6.2@aar,androidx.lifecycle:lifecycle-livedata:2.6.2@aar,androidx.lifecycle:lifecycle-common:2.6.2@jar,androidx.lifecycle:lifecycle-runtime:2.6.2@aar,androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.2@aar,androidx.core:core-ktx:1.13.0@aar,androidx.core:core:1.13.0@aar,androidx.core:core:1.13.0@aar,com.google.errorprone:error_prone_annotations:2.15.0@jar,androidx.resourceinspection:resourceinspection-annotation:1.0.1@jar,androidx.documentfile:documentfile:1.0.0@aar,androidx.localbroadcastmanager:localbroadcastmanager:1.0.0@aar,androidx.print:print:1.0.0@aar,androidx.interpolator:interpolator:1.0.0@aar,androidx.cursoradapter:cursoradapter:1.0.0@aar,androidx.profileinstaller:profileinstaller:1.3.0@aar,androidx.startup:startup-runtime:1.1.1@aar,androidx.tracing:tracing:1.0.0@aar,androidx.versionedparcelable:versionedparcelable:1.1.1@aar,androidx.collection:collection:1.1.0@jar,androidx.concurrent:concurrent-futures:1.1.0@jar,androidx.arch.core:core-runtime:2.2.0@aar,androidx.arch.core:core-common:2.2.0@jar,androidx.annotation:annotation-experimental:1.4.0@aar,androidx.annotation:annotation-jvm:1.6.0@jar,org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4@jar,org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4@jar,org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22@jar,org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.22@jar,org.jetbrains.kotlin:kotlin-stdlib:1.8.22@jar,org.jetbrains.kotlin:kotlin-stdlib-common:1.8.22@jar,androidx.constraintlayout:constraintlayout-solver:2.0.1@jar,org.jetbrains:annotations:13.0@jar,com.google.guava:listenablefuture:1.0@jar"> + simpleName="LorealBa-Latest-MNY-July-2025:library"/> diff --git a/library/build/intermediates/lint_model/release/release-testArtifact-libraries.xml b/library/build/intermediates/lint_model/release/release-testArtifact-libraries.xml index 8be7e63..d318f59 100644 --- a/library/build/intermediates/lint_model/release/release-testArtifact-libraries.xml +++ b/library/build/intermediates/lint_model/release/release-testArtifact-libraries.xml @@ -689,9 +689,9 @@ resolved="com.google.guava:listenablefuture:1.0"/> 6 7 -7-->D:\LorealBa-Latest-July-2025\library\src\main\AndroidManifest.xml:5:5-7:19 -7-->D:\LorealBa-Latest-July-2025\library\src\main\AndroidManifest.xml:5:18-44 +7-->D:\LorealBa-Latest-MNY-July-2025\library\src\main\AndroidManifest.xml:5:5-7:19 +7-->D:\LorealBa-Latest-MNY-July-2025\library\src\main\AndroidManifest.xml:5:18-44 8 9 10 diff --git a/library/build/outputs/logs/manifest-merger-release-report.txt b/library/build/outputs/logs/manifest-merger-release-report.txt index 66ba12f..585e0f0 100644 --- a/library/build/outputs/logs/manifest-merger-release-report.txt +++ b/library/build/outputs/logs/manifest-merger-release-report.txt @@ -1,21 +1,21 @@ -- Merging decision tree log --- manifest -ADDED from D:\LorealBa-Latest-July-2025\library\src\main\AndroidManifest.xml:2:1-9:12 -INJECTED from D:\LorealBa-Latest-July-2025\library\src\main\AndroidManifest.xml:2:1-9:12 +ADDED from D:\LorealBa-Latest-MNY-July-2025\library\src\main\AndroidManifest.xml:2:1-9:12 +INJECTED from D:\LorealBa-Latest-MNY-July-2025\library\src\main\AndroidManifest.xml:2:1-9:12 package - ADDED from D:\LorealBa-Latest-July-2025\library\src\main\AndroidManifest.xml:3:5-49 - INJECTED from D:\LorealBa-Latest-July-2025\library\src\main\AndroidManifest.xml + ADDED from D:\LorealBa-Latest-MNY-July-2025\library\src\main\AndroidManifest.xml:3:5-49 + INJECTED from D:\LorealBa-Latest-MNY-July-2025\library\src\main\AndroidManifest.xml xmlns:android - ADDED from D:\LorealBa-Latest-July-2025\library\src\main\AndroidManifest.xml:2:11-69 + ADDED from D:\LorealBa-Latest-MNY-July-2025\library\src\main\AndroidManifest.xml:2:11-69 application -ADDED from D:\LorealBa-Latest-July-2025\library\src\main\AndroidManifest.xml:5:5-7:19 +ADDED from D:\LorealBa-Latest-MNY-July-2025\library\src\main\AndroidManifest.xml:5:5-7:19 android:allowBackup - ADDED from D:\LorealBa-Latest-July-2025\library\src\main\AndroidManifest.xml:5:18-44 + ADDED from D:\LorealBa-Latest-MNY-July-2025\library\src\main\AndroidManifest.xml:5:18-44 uses-sdk -INJECTED from D:\LorealBa-Latest-July-2025\library\src\main\AndroidManifest.xml reason: use-sdk injection requested -INJECTED from D:\LorealBa-Latest-July-2025\library\src\main\AndroidManifest.xml -INJECTED from D:\LorealBa-Latest-July-2025\library\src\main\AndroidManifest.xml +INJECTED from D:\LorealBa-Latest-MNY-July-2025\library\src\main\AndroidManifest.xml reason: use-sdk injection requested +INJECTED from D:\LorealBa-Latest-MNY-July-2025\library\src\main\AndroidManifest.xml +INJECTED from D:\LorealBa-Latest-MNY-July-2025\library\src\main\AndroidManifest.xml android:targetSdkVersion - INJECTED from D:\LorealBa-Latest-July-2025\library\src\main\AndroidManifest.xml + INJECTED from D:\LorealBa-Latest-MNY-July-2025\library\src\main\AndroidManifest.xml android:minSdkVersion - INJECTED from D:\LorealBa-Latest-July-2025\library\src\main\AndroidManifest.xml + INJECTED from D:\LorealBa-Latest-MNY-July-2025\library\src\main\AndroidManifest.xml