YSY commit

This commit is contained in:
yadavendras
2018-10-26 18:59:48 +05:30
parent d2cb476988
commit c0757192b9
14 changed files with 507 additions and 57 deletions
+6 -6
View File
@@ -21,20 +21,20 @@ android {
targetSdkVersion 22 targetSdkVersion 22
//For Egypt //For Egypt
/*versionCode 20 /*versionCode 20
versionName "3.2"*/ versionName "3.2"*/
//For UAE //For UAE
/*versionCode 18 /*versionCode 18
versionName "3.0"*/ versionName "3.0"*/
//For Turkey //For Turkey
versionCode 19 /*versionCode 19
versionName "3.1" versionName "3.1"*/
//For KSA //For KSA
/*versionCode 21 versionCode 21
versionName "3.3"*/ versionName "3.3"
multiDexEnabled true multiDexEnabled true
+1
View File
@@ -237,6 +237,7 @@
<activity <activity
android:name=".dailyentry.AuditActivity" android:name=".dailyentry.AuditActivity"
android:label="@string/audit" android:label="@string/audit"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.NoActionBar" />
<service <service
@@ -83,7 +83,7 @@ import cpm.com.gskmtorange.xmlGetterSetter.TableBean;
*/ */
public class GSKOrangeDB extends SQLiteOpenHelper { public class GSKOrangeDB extends SQLiteOpenHelper {
public static final String DATABASE_NAME = "GSK_ORANGE_DB39"; public static final String DATABASE_NAME = "GSK_ORANGE_DB40";
public static final int DATABASE_VERSION = 15; public static final int DATABASE_VERSION = 15;
TableBean tableBean; TableBean tableBean;
private SQLiteDatabase db; private SQLiteDatabase db;
@@ -5654,7 +5654,7 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
values.put("CAMERA_ALLOW", data.getCAMERA_ALLOW().get(i)); values.put("CAMERA_ALLOW", data.getCAMERA_ALLOW().get(i));
values.put("KEYACCOUNT_ID", data.getKEYACCOUNT_ID().get(i)); values.put("KEYACCOUNT_ID", data.getKEYACCOUNT_ID().get(i));
values.put("NO_OF_CAMERA", data.getNO_OF_CAMERA().get(i)); values.put("NO_OF_CAMERA", data.getNO_OF_CAMERA().get(i));
values.put("TYPE", data.getTYPE().get(i)); values.put("QTYPE", data.getTYPE().get(i));
db.insert("ADDITIONAL_QUESTION", null, values); db.insert("ADDITIONAL_QUESTION", null, values);
} }
@@ -5670,7 +5670,7 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
try { try {
cursordata = db.rawQuery("Select DISTINCT QUESTION ,QUESTION_ID, ANSWER_TYPE, KEYACCOUNT_ID from ADDITIONAL_QUESTION " + "where CATEGORY_ID ='" + categoryId + "' AND STORETYPE_ID='" + store_type_id + "'", null); cursordata = db.rawQuery("Select DISTINCT QUESTION ,QUESTION_ID, ANSWER_TYPE, KEYACCOUNT_ID, QTYPE from ADDITIONAL_QUESTION " + "where CATEGORY_ID ='" + categoryId + "' AND STORETYPE_ID='" + store_type_id + "'", null);
if (cursordata != null) { if (cursordata != null) {
cursordata.moveToFirst(); cursordata.moveToFirst();
@@ -5686,7 +5686,7 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
sb.setKEYACCOUNT_ID(cursordata.getString(cursordata sb.setKEYACCOUNT_ID(cursordata.getString(cursordata
.getColumnIndexOrThrow("KEYACCOUNT_ID"))); .getColumnIndexOrThrow("KEYACCOUNT_ID")));
sb.setCHECK_TYPE(cursordata.getString(cursordata sb.setCHECK_TYPE(cursordata.getString(cursordata
.getColumnIndexOrThrow("TYPE"))); .getColumnIndexOrThrow("QTYPE")));
auditData.add(sb); auditData.add(sb);
cursordata.moveToNext(); cursordata.moveToNext();
@@ -6712,6 +6712,8 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
values.put(CommonString.KEY_UPLOAD_STATUS, data.getUPLOAD_STATUS()); values.put(CommonString.KEY_UPLOAD_STATUS, data.getUPLOAD_STATUS());
values.put(CommonString.KEY_VISIT_DATE, data.getVISIT_DATE()); values.put(CommonString.KEY_VISIT_DATE, data.getVISIT_DATE());
values.put(CommonString.KEY_IN_TIME, data.getIn_time()); values.put(CommonString.KEY_IN_TIME, data.getIn_time());
values.put(CommonString.KEY_LATITUDE, data.getLATITUDE());
values.put(CommonString.KEY_LONGITUDE, data.getLONGITUDE());
db.insert("DELIVERY_CALLS", null, values); db.insert("DELIVERY_CALLS", null, values);
@@ -6767,6 +6769,8 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
msg.setIn_time(dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_IN_TIME))); msg.setIn_time(dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_IN_TIME)));
msg.setOut_time(dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_OUT_TIME))); msg.setOut_time(dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_OUT_TIME)));
msg.setVISIT_DATE(dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_VISIT_DATE))); msg.setVISIT_DATE(dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_VISIT_DATE)));
msg.setLATITUDE(Double.parseDouble(dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_LATITUDE))));
msg.setLONGITUDE(Double.parseDouble(dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_LONGITUDE))));
list.add(msg); list.add(msg);
dbcursor.moveToNext(); dbcursor.moveToNext();
@@ -208,6 +208,7 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCallb
// Write your code here to invoke NO event // Write your code here to invoke NO event
dialog.cancel(); dialog.cancel();
finish();
} }
}); });
@@ -233,7 +233,7 @@ public class CommonString {
public static final String KEY_ADDRESS = "ADDRESS"; public static final String KEY_ADDRESS = "ADDRESS";
public static final String CREATE_TABLE_DELIVERY_CALLS= "CREATE TABLE IF NOT EXISTS " + TABLE_DELIVERY_CALLS public static final String CREATE_TABLE_DELIVERY_CALLS= "CREATE TABLE IF NOT EXISTS " + TABLE_DELIVERY_CALLS
+ " (" + " ("
+ KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT ," + KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT ,"
+ KEY_STORE_NAME+ " VARCHAR," + KEY_STORE_NAME+ " VARCHAR,"
@@ -243,6 +243,8 @@ public class CommonString {
+ KEY_IN_TIME + " VARCHAR," + KEY_IN_TIME + " VARCHAR,"
+ KEY_OUT_TIME + " VARCHAR," + KEY_OUT_TIME + " VARCHAR,"
+ KEY_UPLOAD_STATUS + " VARCHAR," + KEY_UPLOAD_STATUS + " VARCHAR,"
+ KEY_LATITUDE + " VARCHAR,"
+ KEY_LONGITUDE + " VARCHAR,"
+ KEY_VISIT_DATE + " VARCHAR)"; + KEY_VISIT_DATE + " VARCHAR)";
public static final String CREATE_TABLE_STORE_GEOTAGGING = "CREATE TABLE IF NOT EXISTS " public static final String CREATE_TABLE_STORE_GEOTAGGING = "CREATE TABLE IF NOT EXISTS "
@@ -31,6 +31,7 @@ import android.widget.ArrayAdapter;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ExpandableListView; import android.widget.ExpandableListView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
@@ -66,6 +67,7 @@ public class AuditActivity extends AppCompatActivity {
int child_position = -1; int child_position = -1;
String error_msg = ""; String error_msg = "";
Toolbar toolbar; Toolbar toolbar;
LinearLayout no_data_lay;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@@ -76,6 +78,9 @@ public class AuditActivity extends AppCompatActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
no_data_lay = (LinearLayout) findViewById(R.id.no_data_lay);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
preferences = PreferenceManager.getDefaultSharedPreferences(this); preferences = PreferenceManager.getDefaultSharedPreferences(this);
CommonFunctions.updateLangResources(getApplicationContext(), preferences.getString(CommonString.KEY_LANGUAGE, "")); CommonFunctions.updateLangResources(getApplicationContext(), preferences.getString(CommonString.KEY_LANGUAGE, ""));
store_id = preferences.getString(CommonString.KEY_STORE_ID, null); store_id = preferences.getString(CommonString.KEY_STORE_ID, null);
@@ -111,6 +116,11 @@ public class AuditActivity extends AppCompatActivity {
// Check condition // Check condition
if (!item.getKEYACCOUNT_ID().equals("0") && !item.getKEYACCOUNT_ID().equals(keyAccount_id)) { if (!item.getKEYACCOUNT_ID().equals("0") && !item.getKEYACCOUNT_ID().equals(keyAccount_id)) {
iterator.remove(); iterator.remove();
} else if (!item.getCHECK_TYPE().equals("NA") && item.getCHECK_TYPE().equals("T2P")) {
if (!db.isMappingT2PData(store_id, categoryId)) {
iterator.remove();
}
} }
} }
} }
@@ -130,41 +140,52 @@ public class AuditActivity extends AppCompatActivity {
hashMapAnsListChildData.put(question_list.get(i), answerList); // Header, Child data hashMapAnsListChildData.put(question_list.get(i), answerList); // Header, Child data
} }
questionAdapter = new AnswerAdapter(question_list, hashMapAnsListChildData);
recyclerView.setAdapter(questionAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
} else {
no_data_lay.setVisibility(View.VISIBLE);
fab.setVisibility(View.GONE);
recyclerView.setVisibility(View.GONE);
} }
questionAdapter = new AnswerAdapter(question_list, hashMapAnsListChildData);
recyclerView.setAdapter(questionAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() { fab.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (validateData(question_list)) {
AlertDialog.Builder builder = new AlertDialog.Builder(AuditActivity.this); if (question_list.size() > 0) {
builder.setMessage(R.string.title_activity_Want_save) if (validateData(question_list)) {
.setCancelable(false)
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
db.saveAuditQuestionAnswerData(question_list, store_id, categoryId); AlertDialog.Builder builder = new AlertDialog.Builder(AuditActivity.this);
finish(); builder.setMessage(R.string.title_activity_Want_save)
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out); .setCancelable(false)
} .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
}) public void onClick(DialogInterface dialog, int id) {
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { db.saveAuditQuestionAnswerData(question_list, store_id, categoryId);
dialog.cancel(); finish();
} overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
}); }
AlertDialog alert = builder.create(); })
alert.show(); .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
} else { public void onClick(DialogInterface dialog, int id) {
questionAdapter.notifyDataSetChanged(); dialog.cancel();
Snackbar.make(recyclerView, error_msg, Snackbar.LENGTH_SHORT).show(); }
});
AlertDialog alert = builder.create();
alert.show();
} else {
questionAdapter.notifyDataSetChanged();
Snackbar.make(recyclerView, error_msg, Snackbar.LENGTH_SHORT).show();
}
} }
else {
Snackbar.make(recyclerView, getString(R.string.NodataAvailable), Snackbar.LENGTH_SHORT).show();
}
} }
}); });
} }
@@ -472,7 +493,7 @@ public class AuditActivity extends AppCompatActivity {
} else if (data.get(i).getCAMERA_ALLOW().equals("1") && data.get(i).getNO_OF_CAMERA().equals("2") && data.get(i).getCAM_IMAGE2().equals("")) { } else if (data.get(i).getCAMERA_ALLOW().equals("1") && data.get(i).getNO_OF_CAMERA().equals("2") && data.get(i).getCAM_IMAGE2().equals("")) {
error_msg = getString(R.string.click_image); error_msg = getString(R.string.click_image);
checkflag = false; checkflag = false;
}else { } else {
checkflag = true; checkflag = true;
} }
@@ -273,6 +273,8 @@ public class DeliveryCallActivity extends AppCompatActivity implements View.OnCl
+ "[OUT_TIME]" + _deliveryCallsList.get(i).getOut_time() + "[/OUT_TIME]" + "[OUT_TIME]" + _deliveryCallsList.get(i).getOut_time() + "[/OUT_TIME]"
+ "[IN_TIME_IMAGE]" + _deliveryCallsList.get(i).getIN_TIME_IMAGE() + "[/IN_TIME_IMAGE]" + "[IN_TIME_IMAGE]" + _deliveryCallsList.get(i).getIN_TIME_IMAGE() + "[/IN_TIME_IMAGE]"
+ "[OUT_TIME_IMAGE]" + _deliveryCallsList.get(i).getOUT_TIME_IMAGE()+ "[/OUT_TIME_IMAGE]" + "[OUT_TIME_IMAGE]" + _deliveryCallsList.get(i).getOUT_TIME_IMAGE()+ "[/OUT_TIME_IMAGE]"
+ "[LATITUDE]" + _deliveryCallsList.get(i).getLATITUDE()+ "[/LATITUDE]"
+ "[LONGITUDE]" + _deliveryCallsList.get(i).getLONGITUDE()+ "[/LONGITUDE]"
+ "[/DELIVERY_CALLS_DATA]"; + "[/DELIVERY_CALLS_DATA]";
final String delivery_xml = "[DATA]" + onXML + "[/DATA]"; final String delivery_xml = "[DATA]" + onXML + "[/DATA]";
@@ -1,26 +1,49 @@
package cpm.com.gskmtorange.dailyentry; package cpm.com.gskmtorange.dailyentry;
import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentSender;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationManager;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.provider.Settings;
import android.support.design.widget.BaseTransientBottomBar; import android.support.design.widget.BaseTransientBottomBar;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.Toast;
import com.crashlytics.android.Crashlytics; import com.crashlytics.android.Crashlytics;
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 java.io.File; import java.io.File;
import java.util.List; import java.util.List;
@@ -31,7 +54,7 @@ import cpm.com.gskmtorange.constant.CommonFunctions;
import cpm.com.gskmtorange.constant.CommonString; import cpm.com.gskmtorange.constant.CommonString;
import cpm.com.gskmtorange.xmlGetterSetter.DeliveryCallsGetterSetter; import cpm.com.gskmtorange.xmlGetterSetter.DeliveryCallsGetterSetter;
public class DeliveryCallAddStoreActivity extends AppCompatActivity implements View.OnClickListener{ public class DeliveryCallAddStoreActivity extends AppCompatActivity implements View.OnClickListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener {
EditText et_customer, et_address; EditText et_customer, et_address;
ImageView img_checkin, img_checkout; ImageView img_checkin, img_checkout;
@@ -44,6 +67,22 @@ public class DeliveryCallAddStoreActivity extends AppCompatActivity implements V
private GSKOrangeDB database; private GSKOrangeDB database;
DeliveryCallsGetterSetter deliveryCallsData; DeliveryCallsGetterSetter deliveryCallsData;
LocationManager locationManager;
boolean enabled;
private final static int PLAY_SERVICES_RESOLUTION_REQUEST = 1000;
private LocationRequest mLocationRequest;
private static int UPDATE_INTERVAL = 500; // 5 sec
private static int FATEST_INTERVAL = 100; // 1 sec
private static int DISPLACEMENT = 5; // 10 meters
private static final int REQUEST_LOCATION = 1;
private Location mLastLocation;
double lat = 0.0, lon = 0.0;
GoogleApiClient mGoogleApiClient;
private static final String TAG = DeliveryCallAddStoreActivity.class.getSimpleName();
Context context;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -54,6 +93,8 @@ public class DeliveryCallAddStoreActivity extends AppCompatActivity implements V
database = new GSKOrangeDB(this); database = new GSKOrangeDB(this);
database.open(); database.open();
context = this;
et_customer = findViewById(R.id.et_customer_name); et_customer = findViewById(R.id.et_customer_name);
et_address = findViewById(R.id.et_address); et_address = findViewById(R.id.et_address);
img_checkin = findViewById(R.id.img_checkin); img_checkin = findViewById(R.id.img_checkin);
@@ -87,16 +128,23 @@ public class DeliveryCallAddStoreActivity extends AppCompatActivity implements V
if(checkin_flag){ if(checkin_flag){
DeliveryCallsGetterSetter deliveryCallsGetterSetter = new DeliveryCallsGetterSetter(); if(lat == 0.0 || lon == 0.0){
deliveryCallsGetterSetter.setSTORE_NAME(name);
deliveryCallsGetterSetter.setADDRESS(address);
deliveryCallsGetterSetter.setIN_TIME_IMAGE(img_checkin_path);
deliveryCallsGetterSetter.setOUT_TIME_IMAGE(img_checkout_path);
deliveryCallsGetterSetter.setUPLOAD_STATUS(CommonString.KEY_CHECK_IN);
deliveryCallsGetterSetter.setVISIT_DATE(visit_date);
deliveryCallsGetterSetter.setIn_time(in_time);
database.InsertDeliveryCalls(deliveryCallsGetterSetter); }
else {
DeliveryCallsGetterSetter deliveryCallsGetterSetter = new DeliveryCallsGetterSetter();
deliveryCallsGetterSetter.setSTORE_NAME(name);
deliveryCallsGetterSetter.setADDRESS(address);
deliveryCallsGetterSetter.setIN_TIME_IMAGE(img_checkin_path);
deliveryCallsGetterSetter.setOUT_TIME_IMAGE(img_checkout_path);
deliveryCallsGetterSetter.setUPLOAD_STATUS(CommonString.KEY_CHECK_IN);
deliveryCallsGetterSetter.setVISIT_DATE(visit_date);
deliveryCallsGetterSetter.setIn_time(in_time);
deliveryCallsGetterSetter.setLATITUDE(lat);
deliveryCallsGetterSetter.setLONGITUDE(lon);
database.InsertDeliveryCalls(deliveryCallsGetterSetter);
}
} }
else { else {
@@ -114,6 +162,128 @@ public class DeliveryCallAddStoreActivity extends AppCompatActivity implements V
}); });
str = CommonString.FILE_PATH; str = CommonString.FILE_PATH;
if (checkPlayServices()) {
// Building the GoogleApi client
buildGoogleApiClient();
createLocationRequest();
}
/* locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
enabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
if (!enabled) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(
DeliveryCallAddStoreActivity.this);
// Setting Dialog Title
alertDialog.setTitle(getResources().getString(R.string.gps));
// Setting Dialog Message
alertDialog.setMessage(getResources().getString(R.string.gpsebale));
// Setting Positive "Yes" Button
alertDialog.setPositiveButton(getResources().getString(R.string.yes),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(
Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
}
});
// Setting Negative "NO" Button
alertDialog.setNegativeButton(getResources().getString(R.string.no),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Write your code here to invoke NO event
dialog.cancel();
}
});
// Showing Alert Message
alertDialog.show();
}*/
// Create an instance of GoogleAPIClient.
if (mGoogleApiClient == null) {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
}
}
@Override
protected void onResume() {
super.onResume();
checkgpsEnableDevice();
// Resuming the periodic location updates
if (mGoogleApiClient.isConnected()) {
startLocationUpdates();
}
}
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;
}
}
});
}
} }
protected boolean isValid(){ protected boolean isValid(){
@@ -137,7 +307,7 @@ public class DeliveryCallAddStoreActivity extends AppCompatActivity implements V
} }
} }
else if(img_checkout_path.equals("")){ else if(img_checkout_path.equals("")){
error_msg = getString(R.string.please_click) + " "+ getString(R.string.intime_image).toLowerCase(); error_msg = getString(R.string.please_click) + " "+ getString(R.string.outtime_image).toLowerCase();
flag = false; flag = false;
} }
@@ -261,4 +431,128 @@ public class DeliveryCallAddStoreActivity extends AppCompatActivity implements V
} }
} }
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() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.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);
}
protected void startLocationUpdates() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
|| ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
}
}
/**
* Stopping location updates
*/
protected void stopLocationUpdates() {
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
}
@Override
public void onConnected(Bundle bundle) {
mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
|| ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
if (mLastLocation != null) {
lat = mLastLocation.getLatitude();
lon = mLastLocation.getLongitude();
}
}
// if (mRequestingLocationUpdates) {
startLocationUpdates();
// }
// startLocationUpdates();
}
@Override
public void onConnectionSuspended(int i) {
mGoogleApiClient.connect();
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.i(TAG, "Connection failed: ConnectionResult.getErrorCode() = " + connectionResult.getErrorCode());
}
protected void onStart() {
super.onStart();// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
//client.connect();
if (mGoogleApiClient != null) {
mGoogleApiClient.connect();
}
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
// AppIndex.AppIndexApi.start(client, getIndexApiAction());
}
@Override
protected void onStop() {
super.onStop();// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
// AppIndex.AppIndexApi.end(client, getIndexApiAction());
/* if (mGoogleApiClient.isConnected()) {
mGoogleApiClient.disconnect();
}*/
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
//client.disconnect();
}
@Override
protected void onPause() {
super.onPause();
//stopLocationUpdates();
}
@Override
public void onLocationChanged(Location location) {
}
} }
@@ -171,6 +171,15 @@ public class StoreListActivity extends AppCompatActivity implements GoogleApiCli
createLocationRequest(); createLocationRequest();
} }
// Create an instance of GoogleAPIClient.
if (mGoogleApiClient == null) {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
}
} }
private boolean checkPlayServices() { private boolean checkPlayServices() {
@@ -196,6 +196,7 @@ public class StoreimageActivity extends AppCompatActivity implements View.OnClic
// Write your code here to invoke NO event // Write your code here to invoke NO event
dialog.cancel(); dialog.cancel();
finish();
} }
}); });
@@ -24,6 +24,7 @@ import android.widget.TextView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@@ -31,6 +32,8 @@ import cpm.com.gskmtorange.Database.GSKOrangeDB;
import cpm.com.gskmtorange.R; import cpm.com.gskmtorange.R;
import cpm.com.gskmtorange.constant.CommonFunctions; import cpm.com.gskmtorange.constant.CommonFunctions;
import cpm.com.gskmtorange.constant.CommonString; import cpm.com.gskmtorange.constant.CommonString;
import cpm.com.gskmtorange.xmlGetterSetter.AdditionalQuestiongetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.AuditDataGetterSetter;
import cpm.com.gskmtorange.xmlGetterSetter.CategoryGetterSetter; import cpm.com.gskmtorange.xmlGetterSetter.CategoryGetterSetter;
public class CategoryListActivity extends AppCompatActivity { public class CategoryListActivity extends AppCompatActivity {
@@ -158,12 +161,17 @@ public class CategoryListActivity extends AppCompatActivity {
} }
} }
if (flag) if (flag){
if(db.getAuditCategoryWise(category_id,storeType_id).size()>0){
if(db.getAfterSaveAuditQuestionAnswerData(store_id, category_id).size() == 0){ //changed on 23.10.2018
flag = false; ArrayList<AuditDataGetterSetter> question_list = getAuditAfterDeletion(category_id);
if(question_list.size()>0){
if(db.getAfterSaveAuditQuestionAnswerData(store_id, category_id).size() == 0){
flag = false;
}
} }
} }
@@ -198,6 +206,26 @@ public class CategoryListActivity extends AppCompatActivity {
} }
ArrayList<AuditDataGetterSetter> getAuditAfterDeletion(String category_id){
ArrayList<AuditDataGetterSetter> question_list = db.getAuditCategoryWise(category_id,storeType_id);
Iterator<AuditDataGetterSetter> iterator = question_list.iterator();
while (iterator.hasNext()) {
AuditDataGetterSetter item = iterator.next(); // must be called before you can call iterator.remove()
// Check condition
if (!item.getKEYACCOUNT_ID().equals("0") && !item.getKEYACCOUNT_ID().equals(keyAccount_id)) {
iterator.remove();
} else if (!item.getCHECK_TYPE().equals("NA") && item.getCHECK_TYPE().equals("T2P")) {
if (!db.isMappingT2PData(store_id, category_id)) {
iterator.remove();
}
}
}
return question_list;
}
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present. // Inflate the menu; this adds items to the action bar if it is present.
@@ -358,7 +386,7 @@ public class CategoryListActivity extends AppCompatActivity {
} }
} }
if(db.getAuditCategoryWise(category_id, storeType_id).size()>0){ if(getAuditAfterDeletion(category_id).size()>0){
if(db.getAfterSaveAuditQuestionAnswerData(store_id, category_id).size() == 0){ if(db.getAfterSaveAuditQuestionAnswerData(store_id, category_id).size() == 0){
flag_filled = false; flag_filled = false;
@@ -5,6 +5,7 @@ import java.io.Serializable;
public class DeliveryCallsGetterSetter implements Serializable{ public class DeliveryCallsGetterSetter implements Serializable{
String STORE_NAME, ADDRESS, IN_TIME_IMAGE, OUT_TIME_IMAGE, UPLOAD_STATUS, VISIT_DATE, id, in_time, out_time; String STORE_NAME, ADDRESS, IN_TIME_IMAGE, OUT_TIME_IMAGE, UPLOAD_STATUS, VISIT_DATE, id, in_time, out_time;
double LATITUDE, LONGITUDE;
public String getSTORE_NAME() { public String getSTORE_NAME() {
return STORE_NAME; return STORE_NAME;
@@ -77,4 +78,20 @@ public class DeliveryCallsGetterSetter implements Serializable{
public void setOut_time(String out_time) { public void setOut_time(String out_time) {
this.out_time = out_time; this.out_time = out_time;
} }
public double getLATITUDE() {
return LATITUDE;
}
public void setLATITUDE(double LATITUDE) {
this.LATITUDE = LATITUDE;
}
public double getLONGITUDE() {
return LONGITUDE;
}
public void setLONGITUDE(double LONGITUDE) {
this.LONGITUDE = LONGITUDE;
}
} }
@@ -1051,7 +1051,7 @@ public class XMLHandlers {
if (xpp.getName().equals("NO_OF_CAMERA")) { if (xpp.getName().equals("NO_OF_CAMERA")) {
st.setNO_OF_CAMERA(xpp.nextText()); st.setNO_OF_CAMERA(xpp.nextText());
} }
if (xpp.getName().equals("TYPE")) { if (xpp.getName().equals("QTYPE")) {
st.setTYPE(xpp.nextText()); st.setTYPE(xpp.nextText());
} }
} }
@@ -26,11 +26,81 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" android:layout_marginRight="5dp" />
/>
<LinearLayout
android:id="@+id/no_data_lay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grey_background"
android:orientation="vertical"
android:visibility="gone"
android:weightSum="10">
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
card_view:cardBackgroundColor="@color/white"
card_view:cardCornerRadius="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/NodataAvailable"
android:textSize="25sp"
android:textStyle="bold" />
</android.support.v7.widget.CardView>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_centerInParent="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="4"
android:background="@drawable/sad_cloud" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:visibility="gone"
card_view:cardBackgroundColor="@color/white"
card_view:cardCornerRadius="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/Pleasedownaloaddata"
android:textSize="25sp"
android:textStyle="bold" />
</android.support.v7.widget.CardView>
</LinearLayout>
</LinearLayout> </LinearLayout>
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>