Deepak_commit_31_05_2018

This commit is contained in:
yadavendras
2018-09-21 18:15:36 +05:30
parent 8f7a7008e8
commit 0a8d38e16e
19 changed files with 571 additions and 69 deletions
@@ -37,6 +37,7 @@ import cpm.com.gskmtorange.xmlGetterSetter.ConfigurationContrywiseGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.DisplayChecklistMasterGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.DisplayMasterGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.GapsChecklistGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.GeoFencingGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.JourneyPlanGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.MAPPINGT2PGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.MAPPING_ADDITIONAL_PROMOTION_MasterGetterSetter;
@@ -77,7 +78,7 @@ import cpm.com.gskmtorange.xmlGetterSetter.TableBean;
*/
public class GSKOrangeDB extends SQLiteOpenHelper {
public static final String DATABASE_NAME = "GSK_ORANGE_DB31";
public static final String DATABASE_NAME = "GSK_ORANGE_DB32";
public static final int DATABASE_VERSION = 15;
TableBean tableBean;
private SQLiteDatabase db;
@@ -174,6 +175,7 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
db.execSQL(TableBean.getTable_NON_T2P_REASON());
db.execSQL(TableBean.getTable_CONFIGURATION_COUNTRY_WISE());
db.execSQL(TableBean.getTable_NO_CAMERA_LAST_VISIT_DATA());
db.execSQL(TableBean.getTable_GEO_FENCING());
//15-03-2017
db.execSQL(CommonString.CREATE_TABLE_INSERT_MSL_AVAILABILITY_STOCK_FACING);
@@ -6281,6 +6283,7 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
values.put("COUNTRY_ID", data.getCOUNTRY_ID().get(i));
values.put("ADHOC_REPORTING", data.getADHOC_REPORTING().get(i));
values.put("PDF_ALLOW", data.getPDF_ALLOW().get(i));
db.insert("CONFIGURATION_COUNTRY_WISE", null, values);
}
@@ -6383,4 +6386,61 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
return list;
}
//GEO_FENCING
public void InsertGeoTag_DATA(GeoFencingGetterSetter data) {
db.delete("GEO_FENCING", null, null);
ContentValues values = new ContentValues();
try {
for (int i = 0; i < data.getCOUNTRY_ID().size(); i++) {
values.put("COUNTRY_ID", data.getCOUNTRY_ID().get(i));
values.put("DISTANCE_MTR", data.getDISTANCE_MTR().get(i));
values.put("GEO_FENCING", data.getGEO_FENCING().get(i));
db.insert("GEO_FENCING", null, values);
}
} catch (Exception ex) {
Log.d("Exception ", " in GEO_FENCING " + ex.toString());
}
}
//get Geo Fencing
public ArrayList<GeoFencingGetterSetter> getGeoFencing(String country_id) {
ArrayList<GeoFencingGetterSetter> list = new ArrayList<>();
Cursor dbcursor = null;
try {
dbcursor = db.rawQuery("SELECT * from GEO_FENCING where COUNTRY_ID ='" + country_id + "'", null);
if (dbcursor != null) {
dbcursor.moveToFirst();
while (!dbcursor.isAfterLast()) {
GeoFencingGetterSetter sb = new GeoFencingGetterSetter();
sb.setCOUNTRY_ID(dbcursor.getString(dbcursor
.getColumnIndexOrThrow("COUNTRY_ID")));
sb.setDISTANCE_MTR((dbcursor.getString(dbcursor
.getColumnIndexOrThrow("DISTANCE_MTR"))));
sb.setGEO_FENCING(dbcursor.getString(dbcursor
.getColumnIndexOrThrow("GEO_FENCING")));
list.add(sb);
dbcursor.moveToNext();
}
dbcursor.close();
return list;
}
} catch (Exception e) {
Log.d("Excep get geofencing!", e.toString());
return list;
}
return list;
}
}
@@ -702,7 +702,7 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCallb
if (result.toString().equalsIgnoreCase(
CommonString.KEY_FALSE)) {
return CommonString.METHOD_UPLOAD_ASSET;
return CommonString.METHOD_UPLOAD_STOCK_XML_DATA;
}
// for failure
@@ -719,7 +719,7 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCallb
if (failureGetterSetter.getStatus().equalsIgnoreCase(
CommonString.KEY_FAILURE)) {
return CommonString.METHOD_UPLOAD_ASSET + ","
return CommonString.METHOD_UPLOAD_STOCK_XML_DATA + ","
+ failureGetterSetter.getErrorMsg();
} else {
@@ -862,7 +862,7 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCallb
&& !geotaglistImage.get(i).getUrl1()
.equalsIgnoreCase("")) {
if (new File(Environment.getExternalStorageDirectory() + "/GSK_MT_ORANGE_IMAGES/"
if (new File(CommonString.FILE_PATH
+ geotaglistImage.get(i).getUrl1()).exists()) {
result = UploadGeoImage(geotaglistImage.get(i).getUrl1(), "GeotagImages");
@@ -952,7 +952,6 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCallb
db.deleteGeoTagData(geotaglistImage.get(i).getStoreid());
}
@@ -1005,7 +1004,7 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCallb
errormsg = "";
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/GSK_MT_ORANGE_IMAGES/" + path, o);
BitmapFactory.decodeFile(CommonString.FILE_PATH + path, o);
// The new size we want to scale to
final int REQUIRED_SIZE = 1024;
@@ -1025,7 +1024,7 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCallb
// Decode with inSampleSize
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize = scale;
Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/GSK_MT_ORANGE_IMAGES/" + path, o2);
Bitmap bitmap = BitmapFactory.decodeFile(CommonString.FILE_PATH + path, o2);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, bao);
@@ -1051,7 +1050,7 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCallb
if (result.toString().equalsIgnoreCase(CommonString.KEY_SUCCESS)) {
new File(Environment.getExternalStorageDirectory() + "/GSK_MT_ORANGE_IMAGES/" + path).delete();
new File(CommonString.FILE_PATH + path).delete();
@@ -192,9 +192,9 @@ public class LoginActivity extends AppCompatActivity {
if (!file.isDirectory()) {
file.mkdir();
}
File fileold = new File(Environment.getExternalStorageDirectory(), "GSK_MT_ORANGE_IMAGES");
if (!fileold.isDirectory()) {
fileold.mkdir();
File file_planogram = new File(Environment.getExternalStorageDirectory(), "GSK_MT_ORANGE_Planogram_Images");
if (!file_planogram.isDirectory()) {
file_planogram.mkdir();
}
}
@@ -788,7 +788,7 @@ public class LoginActivity extends AppCompatActivity {
UploadImageWithRetrofit.uploadedFiles = 0;
UploadImageWithRetrofit.totalFiles = file.length;
UploadImageWithRetrofit uploadImg = new UploadImageWithRetrofit( "", userid,LoginActivity.this);
uploadImg.UploadImageRecursive(LoginActivity.this);
//uploadImg.UploadImageRecursive(LoginActivity.this);
}
else {
sendToMain();
@@ -153,6 +153,11 @@ public class MainActivity extends AppCompatActivity
Menu nav_Menu = navigationView.getMenu();
nav_Menu.findItem(R.id.nav_deviation).setVisible(true);
}
if(configuration_data.get(0).getPDF_ALLOW().get(0).equals("1")){
Menu nav_Menu = navigationView.getMenu();
nav_Menu.findItem(R.id.nav_planogram).setVisible(true);
}
}
coverageList = db.getCoverageData(date, null);
@@ -238,6 +238,7 @@ public class CommonString {
//File Path
public static final String FILE_PATH = Environment.getExternalStorageDirectory() + "/.GSK_MT_ORANGE_IMAGES/";
public static final String FILE_PATH_PLANOGRAM = Environment.getExternalStorageDirectory() + "/GSK_MT_ORANGE_Planogram_Images/";
public static final String FILE_PATH_OLD = Environment.getExternalStorageDirectory() + "/GSK_MT_ORANGE_IMAGES/";
public static final String FILE_PATH_PDF = Environment.getExternalStorageDirectory() + "/GSK_MT_ORANGE_Planogram/";
@@ -1038,13 +1038,13 @@ public class NoCameraActivity extends AppCompatActivity implements Listener {
planogram_image = mappingPlanogramList.get(0).getPLANOGRAM_IMAGE();
}
if (!planogram_image.equals("")) {
if (new File(str + planogram_image).exists()) {
Bitmap bmp = BitmapFactory.decodeFile(str + planogram_image);
if (new File(CommonString.FILE_PATH_PLANOGRAM + planogram_image).exists()) {
Bitmap bmp = BitmapFactory.decodeFile(CommonString.FILE_PATH_PLANOGRAM + planogram_image);
// img_planogram.setRotation(90);
//img_planogram.setImageBitmap(bmp);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
String imagePath = "file://" + CommonString.FILE_PATH + "/" + planogram_image;
String imagePath = "file://" + CommonString.FILE_PATH_PLANOGRAM + "/" + planogram_image;
String html = "<html><head></head><body><img src=\"" + imagePath + "\"></body></html>";
webView.loadDataWithBaseURL("", html, "text/html", "utf-8", "");
@@ -1,19 +1,28 @@
package cpm.com.gskmtorange.dailyentry;
import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
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.content.res.Configuration;
import android.content.res.Resources;
import android.location.Location;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
@@ -32,6 +41,21 @@ import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.LocationListener;
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.LocationSettingsResult;
import com.google.android.gms.location.LocationSettingsStatusCodes;
import com.google.android.gms.maps.model.LatLng;
import java.util.ArrayList;
import java.util.Collections;
@@ -40,6 +64,7 @@ import java.util.Locale;
import cpm.com.gskmtorange.Database.GSKOrangeDB;
import cpm.com.gskmtorange.GetterSetter.CoverageBean;
import cpm.com.gskmtorange.GetterSetter.GeotaggingBeans;
import cpm.com.gskmtorange.GetterSetter.StoreBean;
import cpm.com.gskmtorange.R;
import cpm.com.gskmtorange.constant.CommonFunctions;
@@ -49,12 +74,13 @@ import cpm.com.gskmtorange.gsk_dailyentry.StoreWisePerformanceActivity;
import cpm.com.gskmtorange.storeinmap.StoreListMapActivity;
import cpm.com.gskmtorange.storeinmap.StoreListRouteActivity;
import cpm.com.gskmtorange.storeinmap.StoreRouteActivity;
import cpm.com.gskmtorange.xmlGetterSetter.GeoFencingGetterSetter;
/**
* Created by ashishc on 29-12-2016.
*/
public class StoreListActivity extends AppCompatActivity {
public class StoreListActivity extends AppCompatActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener {
ArrayList<CoverageBean> coverage = new ArrayList<CoverageBean>();
ArrayList<StoreBean> storelist = new ArrayList<StoreBean>();
//ListView list;
@@ -71,9 +97,27 @@ public class StoreListActivity extends AppCompatActivity {
FloatingActionButton fab;
//String storeid;
Toolbar toolbar;
String language;
String language, country_id;
String store_flag_str;
Context context;
boolean enabled = true;
GoogleApiClient mGoogleApiClient;
double lat = 0.0, lon = 0.0;
private LocationManager locmanager = null;
ArrayList<GeotaggingBeans> geolist;
//ArrayList<GeoPhencingGetterSetter> geoPhenceGetSet;
int distanceGeoPhence = 500;
private static int UPDATE_INTERVAL = 200; // 5 sec
private static int FATEST_INTERVAL = 100; // 1 sec
private static int DISPLACEMENT = 1; // 10 meters
private static final int REQUEST_LOCATION = 1;
private final static int PLAY_SERVICES_RESOLUTION_REQUEST = 1000;
private Location mLastLocation;
private LocationRequest mLocationRequest;
ArrayList<GeoFencingGetterSetter> geoFencingGetterSetters;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -84,6 +128,8 @@ public class StoreListActivity extends AppCompatActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
preferences = PreferenceManager.getDefaultSharedPreferences(this);
context = this;
CommonFunctions.updateLangResources(getApplicationContext(), preferences.getString(CommonString.KEY_LANGUAGE, ""));
store_flag_str = getIntent().getStringExtra(CommonString.KEY_STORE_FLAG);
@@ -91,6 +137,7 @@ public class StoreListActivity extends AppCompatActivity {
date = preferences.getString(CommonString.KEY_DATE, null);
visit_status = preferences.getString(CommonString.KEY_STOREVISITED_STATUS, "");
language = preferences.getString(CommonString.KEY_LANGUAGE, "");
country_id = preferences.getString(CommonString.KEY_COUNTRY_ID, "");
db = new GSKOrangeDB(StoreListActivity.this);
db.open();
@@ -110,6 +157,197 @@ public class StoreListActivity extends AppCompatActivity {
}
});
if (Build.VERSION.SDK_INT >= 23 && ContextCompat.checkSelfPermission(getApplicationContext(),
android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
ContextCompat.checkSelfPermission(getApplicationContext(),
android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
if (checkPlayServices()) {
// Building the GoogleApi client
buildGoogleApiClient();
createLocationRequest();
}
}
private boolean checkPlayServices() {
int resultCode = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, this,
PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Toast.makeText(getApplicationContext(), getResources().getString(R.string.notsuppoted)
, Toast.LENGTH_LONG)
.show();
finish();
}
return false;
}
return true;
}
protected synchronized void buildGoogleApiClient() {
if (mGoogleApiClient == null) {
mGoogleApiClient = new GoogleApiClient.Builder(context)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
}
}
protected void createLocationRequest() {
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(UPDATE_INTERVAL);
mLocationRequest.setFastestInterval(FATEST_INTERVAL);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setSmallestDisplacement(DISPLACEMENT);
}
@Override
public void onConnectionSuspended(int i) {
mGoogleApiClient.connect();
}
@Override
public void onLocationChanged(Location location) {
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
// Toast.makeText(this, " WORKS_lat_lon " + latLng, Toast.LENGTH_LONG).show();
// updateLocation(latLng);
if (mGoogleApiClient != null) {
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
}
}
protected void startLocationUpdates() {
if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
|| ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
if (mGoogleApiClient != null) {
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
// Toast.makeText(getApplicationContext(), "startLocation - Lat" + lat + "Long" + lon, Toast.LENGTH_LONG).show();
}
}
}
public static int distFrom(double lat1, double lng1, double lat2, double lng2) {
double earthRadius = 6371000; //meters
double dLat = Math.toRadians(lat2 - lat1);
double dLng = Math.toRadians(lng2 - lng1);
double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) *
Math.sin(dLng / 2) * Math.sin(dLng / 2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
int dist = (int) (earthRadius * c);
return dist;
}
@Override
public void onConnected(Bundle bundle) {
mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
|| ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
if (mLastLocation != null) {
lat = mLastLocation.getLatitude();
lon = mLastLocation.getLongitude();
// Toast.makeText(getApplicationContext(), "onconnected lat-" + lat + " Long-" + lon, Toast.LENGTH_SHORT).show();
}
startLocationUpdates();
}
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
if (mGoogleApiClient != null) {
mGoogleApiClient.connect();
}
}
protected void onStart() {
super.onStart();
if (mGoogleApiClient != null) {
mGoogleApiClient.connect();
}
}
private boolean checkgpsEnableDevice() {
boolean flag = true;
if (!hasGPSDevice(context)) {
Toast.makeText(context, "Gps not Supported",Toast.LENGTH_SHORT).show();
}
final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER) && hasGPSDevice(context)) {
enableLoc();
flag = false;
} else if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER) && hasGPSDevice(context)) {
flag = true;
}
return flag;
}
private boolean hasGPSDevice(Context context) {
final LocationManager mgr = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
if (mgr == null)
return false;
final List<String> providers = mgr.getAllProviders();
if (providers == null)
return false;
return providers.contains(LocationManager.GPS_PROVIDER);
}
private void enableLoc() {
LocationRequest locationRequest = LocationRequest.create();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setInterval(30 * 1000);
locationRequest.setFastestInterval(5 * 1000);
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
builder.setAlwaysShow(true);
if (mGoogleApiClient != null) {
PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
result.setResultCallback(new ResultCallback<LocationSettingsResult>() {
@Override
public void onResult(LocationSettingsResult result) {
final Status status = result.getStatus();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
try {
// Show the dialog by calling startResolutionForResult(),
// and check the result in onActivityResult().
status.startResolutionForResult((Activity) context, REQUEST_LOCATION);
} catch (IntentSender.SendIntentException e) {
// Ignore the error.
}
break;
}
}
});
}
}
public void GPSAlert() {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
alertDialog.setTitle("GPS IS DISABLED...");
alertDialog.setMessage("Click ok to enable GPS.");
alertDialog.setCancelable(false);
alertDialog.setPositiveButton("YES",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
dialog.dismiss();
}
});
alertDialog.show();
}
@@ -117,6 +355,12 @@ public class StoreListActivity extends AppCompatActivity {
// TODO Auto-generated method stub
super.onResume();
if (mGoogleApiClient != null) {
mGoogleApiClient.connect();
}
checkgpsEnableDevice();
CommonFunctions.updateLangResources(getApplicationContext(), preferences.getString(CommonString.KEY_LANGUAGE, ""));
//toolbar.setTitle(getString(R.string.title_activity_store_list));
db.open();
@@ -132,6 +376,8 @@ public class StoreListActivity extends AppCompatActivity {
coverage = db.getCoverageData(date, store_flag_str);
geoFencingGetterSetters = db.getGeoFencing(country_id);
if (storelist.size() > 0) {
//list.setAdapter(new MyAdaptor());
@@ -580,6 +826,42 @@ public class StoreListActivity extends AppCompatActivity {
if (!GeotagStatus.equalsIgnoreCase("N")) {
boolean flag = true;
if (coverage.size() > 0) {
for (int i = 0; i < coverage.size(); i++) {
if (store_id.equals(coverage.get(i).getStoreId())) {
flag = false;
break;
}
}
}
boolean flag_entry = true;
int distance = 0;
//geo fencing enabled only if GEO_FENCING equals 1 for COUNTRY_ID
if(flag && geoFencingGetterSetters.size()>0 && geoFencingGetterSetters.get(0).getGEO_FENCING().get(0).equals("1")){
distanceGeoPhence = Integer.parseInt(geoFencingGetterSetters.get(0).getDISTANCE_MTR().get(0));
double store_lat = Double.parseDouble(current.getLATITUDE());
double store_lon = Double.parseDouble(current.getLONGITUDE());
if(store_lat!=0.0 && store_lon!=0.0){
distance = distFrom(store_lat, store_lon, lat, lon);
if (/*true*/distance > distanceGeoPhence) {
flag_entry = false;
}
}
}
if(flag_entry){
String msg = getString(R.string.distance_from_the_store) + " " + distance + " meters";
Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
editor = preferences.edit();
editor.putString(CommonString.KEY_STORE_ID, current.getSTORE_ID());
editor.putString(CommonString.KEY_STORE_NAME, current.getSTORE_NAME());
@@ -596,15 +878,6 @@ public class StoreListActivity extends AppCompatActivity {
editor.commit();
boolean flag = true;
if (coverage.size() > 0) {
for (int i = 0; i < coverage.size(); i++) {
if (store_id.equals(coverage.get(i).getStoreId())) {
flag = false;
break;
}
}
}
if (flag == true) {
Intent in = new Intent(StoreListActivity.this, StoreimageActivity.class);
@@ -620,6 +893,27 @@ public class StoreListActivity extends AppCompatActivity {
dialog.cancel();
}
}else{
String msg = getString(R.string.you_need_to_be_in_the_store) + " " +distance + " meters";
dialog.cancel();
AlertDialog.Builder builder = new AlertDialog.Builder(StoreListActivity.this);
builder.setTitle(getResources().getString(R.string.dialog_title));
builder.setMessage(msg).setCancelable(false)
.setPositiveButton(getResources().getString(R.string.ok),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog1,
int id) {
dialog1.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
} else {
dialog.cancel();
AlertDialog.Builder builder = new AlertDialog.Builder(StoreListActivity.this);
@@ -634,7 +928,6 @@ public class StoreListActivity extends AppCompatActivity {
}
});
AlertDialog alert = builder.create();
alert.show();
@@ -1540,9 +1540,9 @@ public class T2PComplianceActivity extends AppCompatActivity {
webView.getSettings().setBuiltInZoomControls(true);
//String planogram_image = mp.get(0).getPLANOGRAM_IMAGE();
if (new File(str + planogram_image).exists()) {
if (new File(CommonString.FILE_PATH_PLANOGRAM + planogram_image).exists()) {
String imagePath = "file://" + CommonString.FILE_PATH + "/" + planogram_image;
String imagePath = "file://" + CommonString.FILE_PATH_PLANOGRAM + "/" + planogram_image;
//String imagePath = "file://" + CommonString.FILE_PATH + "/" + "image_ref.png";
String html = "<html><head></head><body><img src=\"" + imagePath + "\"></body></html>";
webView.loadDataWithBaseURL("", html, "text/html", "utf-8", "");
@@ -48,6 +48,7 @@ import cpm.com.gskmtorange.xmlGetterSetter.CategoryMasterGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.ConfigurationContrywiseGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.DisplayChecklistMasterGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.DisplayMasterGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.GeoFencingGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.JourneyPlanGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.MAPPINGT2PGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.MAPPING_ADDITIONAL_PROMOTION_MasterGetterSetter;
@@ -105,6 +106,7 @@ public class DownloadActivity extends AppCompatActivity {
NonT2pReasonGetterSetter nonT2pReasonGetterSetter;
ConfigurationContrywiseGetterSetter configurationContrywiseGetterSetter;
NoCameraLastVisitGetterSetter noCameraLastVisitGetterSetter;
GeoFencingGetterSetter geoFencingGetterSetter;
private Dialog dialog;
private ProgressBar pb;
@@ -262,6 +264,41 @@ public class DownloadActivity extends AppCompatActivity {
}
publishProgress(data);
//GEO_FENCING
request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD);
request.addProperty("UserName", userId);
request.addProperty("Type", "GEO_FENCING");
request.addProperty("cultureid", culture_id);
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
androidHttpTransport = new HttpTransportSE(CommonString.URL);
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
result = envelope.getResponse();
if (result.toString() != null) {
xpp.setInput(new StringReader(result.toString()));
// xpp.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
// xpp.setInput(stream,"UTF-8");
xpp.next();
eventType = xpp.getEventType();
geoFencingGetterSetter = XMLHandlers.geoFencingXMLHandler(xpp, eventType);
String geofencingTable = geoFencingGetterSetter.getTable_GEO_FENCING();
TableBean.setTable_GEO_FENCING(geofencingTable);
if (geoFencingGetterSetter.getGEO_FENCING().size() > 0) {
data.value = 17;
data.name = "GEO FENCING" + getResources().getString(R.string.download_data);
}
}
publishProgress(data);
// Store List Master
request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD);
@@ -1217,7 +1254,7 @@ public class DownloadActivity extends AppCompatActivity {
String size = new DecimalFormat("##.##").format((double) length / 1024) + " KB";
//String PATH = Environment.getExternalStorageDirectory() + "/Download/GT_GSK_Images/";
String PATH = CommonString.FILE_PATH;
String PATH = CommonString.FILE_PATH_PLANOGRAM;
File file = new File(PATH);
if (!file.isDirectory()) {
file.mkdir();
@@ -1276,7 +1313,7 @@ public class DownloadActivity extends AppCompatActivity {
String size = new DecimalFormat("##.##").format((double) length / 1024) + " KB";
//String PATH = Environment.getExternalStorageDirectory() + "/Download/GT_GSK_Images/";
String PATH = CommonString.FILE_PATH;
String PATH = CommonString.FILE_PATH_PLANOGRAM;
File file = new File(PATH);
if (!file.isDirectory()) {
file.mkdir();
@@ -1306,7 +1343,7 @@ public class DownloadActivity extends AppCompatActivity {
}
}
//MAPPING_PLANOGRAM Image save into folder
/* //MAPPING_PLANOGRAM Image save into folder
if (mapping_planogram_masterGetterSetter != null) {
for (int i = 0; i < mapping_planogram_masterGetterSetter.getIMAGE_PATH().size(); i++) {
@@ -1333,7 +1370,7 @@ public class DownloadActivity extends AppCompatActivity {
String size = new DecimalFormat("##.##").format((double) length / 1024) + " KB";
//String PATH = Environment.getExternalStorageDirectory() + "/Download/GT_GSK_Images/";
String PATH = CommonString.FILE_PATH;
String PATH = CommonString.FILE_PATH_PLANOGRAM;
File file = new File(PATH);
if (!file.isDirectory()) {
file.mkdir();
@@ -1361,7 +1398,7 @@ public class DownloadActivity extends AppCompatActivity {
}
}
}
}
}*/
//MAPPING_COUNTRYWISE_PLANOGRAM file save into folder
/*if (mappingPlanogramCountrywiseGetterSetter != null) {
@@ -1452,6 +1489,7 @@ public class DownloadActivity extends AppCompatActivity {
db.InsertNON_T2P_REASON(nonT2pReasonGetterSetter);
db.InsertCONFIGURATION_COUNTRY_WISE(configurationContrywiseGetterSetter);
db.InsertNO_CAMERA_LAST_VISIT_DATA(noCameraLastVisitGetterSetter);
db.InsertGeoTag_DATA(geoFencingGetterSetter);
} catch (MalformedURLException e) {
@@ -85,7 +85,7 @@ public class MSL_Availability_StockFacingActivity extends AppCompatActivity {
private SharedPreferences preferences;
int scrollPosition = 0;
String str = "", _pathforcheck = "";
String str_planogram= "", _pathforcheck = "";
ArrayList<StockFacing_PlanogramTrackerDataGetterSetter> planogramShelfHeaderDataList = new ArrayList<>();
ArrayList<StockFacing_PlanogramTrackerDataGetterSetter> planogramSkuChildDataList;
@@ -140,7 +140,7 @@ public class MSL_Availability_StockFacingActivity extends AppCompatActivity {
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
str = CommonString.FILE_PATH;
str_planogram= CommonString.FILE_PATH_PLANOGRAM;
prepareList();
@@ -345,13 +345,13 @@ public class MSL_Availability_StockFacingActivity extends AppCompatActivity {
planogram_image = mappingPlanogramList.get(0).getPLANOGRAM_IMAGE();
}
if (!planogram_image.equals("")) {
if (new File(str + planogram_image).exists()) {
Bitmap bmp = BitmapFactory.decodeFile(str + planogram_image);
if (new File(str_planogram+ planogram_image).exists()) {
Bitmap bmp = BitmapFactory.decodeFile(str_planogram+ planogram_image);
// img_planogram.setRotation(90);
//img_planogram.setImageBitmap(bmp);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
String imagePath = "file://" + CommonString.FILE_PATH + "/" + planogram_image;
String imagePath = "file://" + CommonString.FILE_PATH_PLANOGRAM + "/" + planogram_image;
String html = "<html><head></head><body><img src=\"" + imagePath + "\"></body></html>";
webView.loadDataWithBaseURL("", html, "text/html", "utf-8", "");
@@ -451,7 +451,7 @@ public class MSL_Availability_StockFacingActivity extends AppCompatActivity {
public void onClick(View view) {
_pathforcheck = "Stock_Camera1_" + store_id + "_" + categoryId
+ "_" + visit_date.replace("/", "") + "_" + CommonFunctions.getCurrentTimeWithLanguage(getApplicationContext()).replace(":", "") + ".jpg";
path = str + _pathforcheck;
path = str_planogram+ _pathforcheck;
startCameraActivity(3);
}
@@ -462,7 +462,7 @@ public class MSL_Availability_StockFacingActivity extends AppCompatActivity {
public void onClick(View view) {
_pathforcheck = "Stock_Camera2_" + store_id + "_" + categoryId
+ "_" + visit_date.replace("/", "") + "_" + CommonFunctions.getCurrentTimeWithLanguage(getApplicationContext()).replace(":", "") + ".jpg";
path = str + _pathforcheck;
path = str_planogram+ _pathforcheck;
startCameraActivity(4);
}
@@ -473,7 +473,7 @@ public class MSL_Availability_StockFacingActivity extends AppCompatActivity {
public void onClick(View view) {
_pathforcheck = "Stock_Camera3_" + store_id + "_" + categoryId
+ "_" + visit_date.replace("/", "") + "_" + CommonFunctions.getCurrentTimeWithLanguage(getApplicationContext()).replace(":", "") + ".jpg";
path = str + _pathforcheck;
path = str_planogram+ _pathforcheck;
startCameraActivity(5);
}
@@ -484,7 +484,7 @@ public class MSL_Availability_StockFacingActivity extends AppCompatActivity {
public void onClick(View view) {
_pathforcheck = "Stock_Camera4_" + store_id + "_" + categoryId
+ "_" + visit_date.replace("/", "") + "_" + CommonFunctions.getCurrentTimeWithLanguage(getApplicationContext()).replace(":", "") + ".jpg";
path = str + _pathforcheck;
path = str_planogram+ _pathforcheck;
startCameraActivity(6);
}
@@ -1292,7 +1292,7 @@ public class MSL_Availability_StockFacingActivity extends AppCompatActivity {
}
public String PerfectDecimal(String str, int MAX_BEFORE_POINT, int MAX_DECIMAL) {
if (str.charAt(0) == '.') str = "0" + str;
if (str.charAt(0) == '.') str= "0" + str;
int max = str.length();
String rFinal = "";
@@ -1186,13 +1186,13 @@ public class Stock_FacingActivity extends AppCompatActivity {
planogram_image = mappingPlanogramList.get(0).getPLANOGRAM_IMAGE();
}
if (!planogram_image.equals("")) {
if (new File(str + planogram_image).exists()) {
Bitmap bmp = BitmapFactory.decodeFile(str + planogram_image);
if (new File(CommonString.FILE_PATH_PLANOGRAM + planogram_image).exists()) {
Bitmap bmp = BitmapFactory.decodeFile(CommonString.FILE_PATH_PLANOGRAM + planogram_image);
// img_planogram.setRotation(90);
//img_planogram.setImageBitmap(bmp);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
String imagePath = "file://" + CommonString.FILE_PATH + "/" + planogram_image;
String imagePath = "file://" + CommonString.FILE_PATH_PLANOGRAM + "/" + planogram_image;
String html = "<html><head></head><body><img src=\"" + imagePath + "\"></body></html>";
webView.loadDataWithBaseURL("", html, "text/html", "utf-8", "");
@@ -80,7 +80,7 @@ public class UploadImageWithRetrofit {
pd.show();
}
public void UploadImageRecursive(final Context context) {
/*public void UploadImageRecursive(final Context context) {
try {
status = 0;
@@ -199,7 +199,7 @@ public class UploadImageWithRetrofit {
}
}
}
}*/
public void UploadImageRecursiveNew(final Context context) {
try {
@@ -224,6 +224,8 @@ public class UploadImageWithRetrofit {
foldername = "T2PImages";
} else if (file[i].getName().contains("AddPromo_Image")) {
foldername = "AdditionalPromotionImages";
}else if (file[i].getName().contains("AdditionalImage")) {
foldername = "AdditionalVisibilityImages";
} else if (file[i].getName().contains("Promo_Image")) {
foldername = "PromotionImages";
} else if (file[i].getName().contains("CategoryPicture")) {
@@ -8,6 +8,7 @@ public class ConfigurationContrywiseGetterSetter {
ArrayList<String> COUNTRY_ID = new ArrayList<>();
ArrayList<String> ADHOC_REPORTING = new ArrayList<>();
ArrayList<String> PDF_ALLOW = new ArrayList<>();
public String getTable_CONFIGURATION_COUNTRY_WISE() {
return table_CONFIGURATION_COUNTRY_WISE;
@@ -32,4 +33,12 @@ public class ConfigurationContrywiseGetterSetter {
public void setADHOC_REPORTING(String ADHOC_REPORTING) {
this.ADHOC_REPORTING.add(ADHOC_REPORTING);
}
public ArrayList<String> getPDF_ALLOW() {
return PDF_ALLOW;
}
public void setPDF_ALLOW(String PDF_ALLOW) {
this.PDF_ALLOW.add(PDF_ALLOW);
}
}
@@ -0,0 +1,44 @@
package cpm.com.gskmtorange.xmlGetterSetter;
import java.util.ArrayList;
public class GeoFencingGetterSetter {
String table_GEO_FENCING;
ArrayList<String> COUNTRY_ID = new ArrayList<>();
ArrayList<String> DISTANCE_MTR = new ArrayList<>();
ArrayList<String> GEO_FENCING = new ArrayList<>();
public String getTable_GEO_FENCING() {
return table_GEO_FENCING;
}
public void setTable_GEO_FENCING(String table_GEO_FENCING) {
this.table_GEO_FENCING = table_GEO_FENCING;
}
public ArrayList<String> getCOUNTRY_ID() {
return COUNTRY_ID;
}
public void setCOUNTRY_ID(String COUNTRY_ID) {
this.COUNTRY_ID.add(COUNTRY_ID);
}
public ArrayList<String> getDISTANCE_MTR() {
return DISTANCE_MTR;
}
public void setDISTANCE_MTR(String DISTANCE_MTR) {
this.DISTANCE_MTR.add(DISTANCE_MTR);
}
public ArrayList<String> getGEO_FENCING() {
return GEO_FENCING;
}
public void setGEO_FENCING(String GEO_FENCING) {
this.GEO_FENCING.add(GEO_FENCING);
}
}
@@ -4,7 +4,7 @@ import java.util.ArrayList;
public class POGGetterSetter {
String QUESTION_ID, CULTURE_ID, SUB_CATEGORY_ID, QUESTION, ANSWER_TYPE, ANSWER_ID, ANSWER, CAM_IMAGE="", CAMERA_ALLOW="0",QTYPE_ID,QTYPE, CATEGORY_ID;
String QUESTION_ID, CULTURE_ID, SUB_CATEGORY_ID, QUESTION, ANSWER_TYPE, ANSWER_ID = "0", ANSWER, CAM_IMAGE="", CAMERA_ALLOW="0",QTYPE_ID,QTYPE, CATEGORY_ID;
ArrayList<POGGetterSetter> answerList = new ArrayList<>();
@@ -37,6 +37,7 @@ public class TableBean {
public static String Table_NON_T2P_REASON;
public static String Table_CONFIGURATION_COUNTRY_WISE;
public static String Table_NO_CAMERA_LAST_VISIT_DATA;
public static String Table_GEO_FENCING;
public static String getAdditionalDisplay() {
@@ -271,4 +272,12 @@ public class TableBean {
public static void setTable_NO_CAMERA_LAST_VISIT_DATA(String table_NO_CAMERA_LAST_VISIT_DATA) {
Table_NO_CAMERA_LAST_VISIT_DATA = table_NO_CAMERA_LAST_VISIT_DATA;
}
public static String getTable_GEO_FENCING() {
return Table_GEO_FENCING;
}
public static void setTable_GEO_FENCING(String table_GEO_FENCING) {
Table_GEO_FENCING = table_GEO_FENCING;
}
}
@@ -14,6 +14,7 @@ import cpm.com.gskmtorange.xmlGetterSetter.ConfigurationContrywiseGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.DisplayChecklistMasterGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.DisplayMasterGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.FailureGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.GeoFencingGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.JourneyPlanGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.LoginGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.MAPPINGT2PGetterSetter;
@@ -1200,6 +1201,10 @@ public class XMLHandlers {
if (xpp.getName().equals("ADHOC_REPORTING")) {
st.setADHOC_REPORTING(xpp.nextText());
}
if (xpp.getName().equals("PDF_ALLOW")) {
st.setPDF_ALLOW(xpp.nextText());
}
}
xpp.next();
}
@@ -1263,4 +1268,36 @@ public class XMLHandlers {
}
return st;
}
//GEO_FENCING
public static GeoFencingGetterSetter geoFencingXMLHandler(XmlPullParser xpp, int eventType) {
GeoFencingGetterSetter st = new GeoFencingGetterSetter();
try {
while (xpp.getEventType() != XmlPullParser.END_DOCUMENT) {
if (xpp.getEventType() == XmlPullParser.START_TAG) {
if (xpp.getName().equals("META_DATA")) {
st.setTable_GEO_FENCING(xpp.nextText());
}
if (xpp.getName().equals("COUNTRY_ID")) {
st.setCOUNTRY_ID(xpp.nextText());
}
if (xpp.getName().equals("DISTANCE_MTR")) {
st.setDISTANCE_MTR(xpp.nextText());
}
if (xpp.getName().equals("GEO_FENCING")) {
st.setGEO_FENCING(xpp.nextText());
}
}
xpp.next();
}
} catch (XmlPullParserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return st;
}
}
@@ -36,7 +36,8 @@
<item
android:id="@+id/nav_planogram"
android:icon="@mipmap/ic_view_quilt_black_48dp"
android:title="@string/category_performance_PLANOGRAM" />
android:title="@string/category_performance_PLANOGRAM"
android:visible="false"/>
<item
android:id="@+id/nav_exit"
@@ -368,4 +368,8 @@
<string name="adhoc">Ad hoc</string>
<string name="hint_reply">Type response</string>
<!--Geofencing-->
<string name="you_need_to_be_in_the_store">You need to be in the store to Checkin/Checkout\n Distance from Store - </string>
<string name="distance_from_the_store">Distance from Store - </string>
</resources>