initial_commit
This commit is contained in:
@@ -225,6 +225,7 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
|
||||
db.execSQL(TableBean.getTable_ORDER_RECEIVED_STATUS());//--Added 08.12.2022
|
||||
db.execSQL(TableBean.getAdhocJourneyplanAdditional());//--Added 7.10.2019
|
||||
db.execSQL(CommonString.CREATE_TABLE_IRPD);
|
||||
db.execSQL(CommonString.CREATE_TABLE_IRPD_POG);
|
||||
db.execSQL(CommonString.CREATE_TABLE_IRPD_VISIBILITY);
|
||||
db.execSQL(CommonString.CREATE_TABLE_INSERT_STOCK_DATA);
|
||||
} catch (SQLException e) {
|
||||
@@ -290,6 +291,7 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
|
||||
db.delete(CommonString.TABLE_INSERT_COMPETIOTIONN_PROMO_EXISTS, "STORE_ID" + "='" + storeid + "'", null);
|
||||
db.delete(CommonString.TABLE_INSERT_COMPETIOTIONN_PROMO, "STORE_ID" + "='" + storeid + "'", null);
|
||||
db.delete(CommonString.TABLE_IRPD, CommonString.KEY_STORE_ID + "='" + storeid + "'", null);
|
||||
db.delete(CommonString.TABLE_IRPD_POG, CommonString.KEY_STORE_ID + "='" + storeid + "'", null);
|
||||
db.delete(CommonString.TABLE_IRPD_VISIBILITY, CommonString.KEY_STORE_ID + "='" + storeid + "'", null);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -337,11 +339,11 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
|
||||
db.delete(CommonString.TABLE_INSERT_ORDER_TAKING_DATA, null, null);
|
||||
db.delete(CommonString.TABLE_INSERT_STOCK, null, null);
|
||||
db.delete(CommonString.TABLE_IRPD, null, null);
|
||||
db.delete(CommonString.TABLE_IRPD_POG, null, null);
|
||||
db.delete(CommonString.TABLE_IRPD_VISIBILITY, null, null);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void InsertJCP(JourneyPlanGetterSetter data) {
|
||||
@@ -1745,7 +1747,6 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
|
||||
values.put(CommonString.KEY_GEO_TAG, data.getGEO_TAG());
|
||||
values.put(CommonString.KEY_CHECKOUT_IMAGE, data.getCheckOut_Image());
|
||||
values.put(CommonString.KEY_STORE_FLAG, data.getFlag_from());
|
||||
|
||||
values.put(CommonString.KEY_KEYACCOUNT_ID, data.getKeyAccountId());
|
||||
values.put(CommonString.KEY_CLASS_ID, data.getClassId());
|
||||
values.put(CommonString.KEY_STORETYPE_ID, data.getStoreTypeId());
|
||||
@@ -4755,11 +4756,6 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
|
||||
CPGS.setSUB_CATEGORY_ID(dbcursor.getString(dbcursor.getColumnIndexOrThrow("SUB_CATEGORY_ID")));
|
||||
CPGS.setImage_allow(dbcursor.getString(dbcursor.getColumnIndexOrThrow("IMAGE_ALLOW")));
|
||||
CPGS.setSubCatCode(dbcursor.getString(dbcursor.getColumnIndexOrThrow("PD_SUB_CATEGORY_CODE")));
|
||||
/* String imgs = dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_IRPD_IMAGES));
|
||||
// String imgs_modify = dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_IRPD_MODIFY_IMAGES));
|
||||
CPGS.setImageUris(imgs != null && !imgs.isEmpty() ? (ArrayList<ImageUri>) Arrays.stream(imgs.split(", "))
|
||||
.map(img -> new ImageUri(img, new File(img).getName())) // Extract file name as second parameter
|
||||
.collect(Collectors.toList()) : new ArrayList<>());*/
|
||||
|
||||
// Retrieve image URIs from database
|
||||
String imgs = dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_IRPD_IMAGES));
|
||||
@@ -4798,6 +4794,83 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
// get CATEGORY PICTURE data
|
||||
public ArrayList<CategoryPictureGetterSetter> getCategoryPicturePogdata(String visit_date, String categoryId, String key_account_id, String store_type_id, String class_id, String store_id, String tableName) {
|
||||
ArrayList<CategoryPictureGetterSetter> list = new ArrayList<>();
|
||||
Cursor dbcursor = null;
|
||||
try {
|
||||
if (key_account_id != null) {
|
||||
dbcursor = db.rawQuery("SELECT DISTINCT ifnull(T.IRPD_IMAGES,'')as IRPD_IMAGES,ifnull(T.IRPD_IMAGES_MODIFY,'')as IRPD_IMAGES_MODIFY, ifnull(SB.PD_SUB_CATEGORY_CODE,'')AS PD_SUB_CATEGORY_CODE,SB.SUB_CATEGORY_ID, MIA.IMAGE_ALLOW,SB.SUB_CATEGORY FROM "
|
||||
+ tableName + " M INNER JOIN SKU_MASTER SK ON M.SKU_ID = SK.SKU_ID" +
|
||||
" INNER JOIN BRAND_MASTER BR ON SK.BRAND_ID = BR.BRAND_ID" +
|
||||
" INNER JOIN SUB_CATEGORY_MASTER SB ON BR.SUB_CATEGORY_ID = SB.SUB_CATEGORY_ID" +
|
||||
" INNER JOIN CATEGORY_MASTER CA ON SB.CATEGORY_ID = CA.CATEGORY_ID" +
|
||||
" INNER JOIN MAPPING_SUB_CATEGORY_IMAGE_ALLOW MIA ON SB.SUB_CATEGORY_ID=MIA.SUB_CATEGORY_ID " +
|
||||
" LEFT JOIN (SELECT * FROM " + CommonString.TABLE_IRPD_POG + " WHERE " + CommonString.KEY_STORE_ID + "=" + store_id +
|
||||
" AND " + CommonString.KEY_CATEGORY_ID + "=" + categoryId + " AND " + CommonString.KEY_VISIT_DATE + "='" + visit_date +
|
||||
"')AS T ON T.CATEGORY_ID=CA.CATEGORY_ID AND T.SUB_CATEGORY_ID=SB.SUB_CATEGORY_ID " +
|
||||
"WHERE M.KEYACCOUNT_ID = '" + key_account_id + " ' AND M.STORETYPE_ID = '" + store_type_id +
|
||||
"' AND M.CLASS_ID = '" + class_id + "' AND CA.CATEGORY_ID = '" + categoryId + "'", null);
|
||||
|
||||
} else {
|
||||
dbcursor = db.rawQuery("SELECT DISTINCT ifnull(T.IRPD_IMAGES,'')as IRPD_IMAGES,ifnull(T.IRPD_IMAGES_MODIFY,'')as IRPD_IMAGES_MODIFY,ifnull(SB.PD_SUB_CATEGORY_CODE,'')AS PD_SUB_CATEGORY_CODE,SB.SUB_CATEGORY_ID, MIA.IMAGE_ALLOW,SB.SUB_CATEGORY FROM MAPPING_STOCK_STOREWISE M INNER JOIN SKU_MASTER SK ON M.SKU_ID = SK.SKU_ID" +
|
||||
" INNER JOIN BRAND_MASTER BR ON SK.BRAND_ID = BR.BRAND_ID" +
|
||||
" INNER JOIN SUB_CATEGORY_MASTER SB ON BR.SUB_CATEGORY_ID = SB.SUB_CATEGORY_ID" +
|
||||
" INNER JOIN CATEGORY_MASTER CA ON SB.CATEGORY_ID = CA.CATEGORY_ID" +
|
||||
" INNER JOIN MAPPING_SUB_CATEGORY_IMAGE_ALLOW MIA ON SB.SUB_CATEGORY_ID=MIA.SUB_CATEGORY_ID " +
|
||||
" LEFT JOIN (SELECT * FROM " + CommonString.TABLE_IRPD_POG + " WHERE " + CommonString.KEY_STORE_ID + "=" + store_id +
|
||||
" AND " + CommonString.KEY_CATEGORY_ID + "=" + categoryId + " AND " + CommonString.KEY_VISIT_DATE + "='" + visit_date +
|
||||
"') AS T ON T.CATEGORY_ID=CA.CATEGORY_ID AND T.SUB_CATEGORY_ID=SB.SUB_CATEGORY_ID " +
|
||||
"WHERE M.STORE_ID = '" + store_id + "' AND CA.CATEGORY_ID = '" + categoryId + "'", null);
|
||||
}
|
||||
if (dbcursor != null) {
|
||||
dbcursor.moveToFirst();
|
||||
while (!dbcursor.isAfterLast()) {
|
||||
CategoryPictureGetterSetter CPGS = new CategoryPictureGetterSetter();
|
||||
CPGS.setSUB_CATEGORY(dbcursor.getString(dbcursor.getColumnIndexOrThrow("SUB_CATEGORY")));
|
||||
CPGS.setSUB_CATEGORY_ID(dbcursor.getString(dbcursor.getColumnIndexOrThrow("SUB_CATEGORY_ID")));
|
||||
CPGS.setImage_allow(dbcursor.getString(dbcursor.getColumnIndexOrThrow("IMAGE_ALLOW")));
|
||||
CPGS.setSubCatCode(dbcursor.getString(dbcursor.getColumnIndexOrThrow("PD_SUB_CATEGORY_CODE")));
|
||||
|
||||
// Retrieve image URIs from database
|
||||
String imgs = dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_IRPD_IMAGES));
|
||||
String imgs_modify = dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_IRPD_MODIFY_IMAGES));
|
||||
|
||||
// Split and map URIs and Modify URIs separately
|
||||
List<String> imageUris = imgs != null && !imgs.isEmpty()
|
||||
? Arrays.stream(imgs.split(", ")).collect(Collectors.toList())
|
||||
: new ArrayList<>();
|
||||
List<String> modifyUris = imgs_modify != null && !imgs_modify.isEmpty()
|
||||
? Arrays.stream(imgs_modify.split(", ")).collect(Collectors.toList())
|
||||
: new ArrayList<>();
|
||||
|
||||
// Create ImageUri objects with original URI and Modify URI
|
||||
ArrayList<ImageUri> imageUriList = new ArrayList<>();
|
||||
for (int i = 0; i < imageUris.size(); i++) {
|
||||
String uri = imageUris.get(i);
|
||||
String modifyUri = (i < modifyUris.size()) ? modifyUris.get(i) : uri; // Fallback to original if no modify URI
|
||||
imageUriList.add(new ImageUri(uri, modifyUri));
|
||||
}
|
||||
|
||||
CPGS.setImageUris(imageUriList);
|
||||
|
||||
CPGS.setSubCategoryCamera1("");
|
||||
CPGS.setSubCategoryCamera2("");
|
||||
list.add(CPGS);
|
||||
dbcursor.moveToNext();
|
||||
}
|
||||
dbcursor.close();
|
||||
return list;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.d("Exception ", "get Planogram Shelf Header After Save !" + e.toString());
|
||||
// return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<StockFacing_PlanogramTrackerDataGetterSetter> getPlanogramAddShelfHeaderAfterSaveData(
|
||||
String store_id, String category_id) {
|
||||
|
||||
@@ -7837,24 +7910,22 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
try {
|
||||
|
||||
for (int l = 0; l < headerDataList.size(); l++) {
|
||||
List<POGGetterSetter> childList = hashMapListChildData.get(headerDataList.get(l));
|
||||
for (int i = 0; i < childList.size(); i++) {
|
||||
POGGetterSetter data = childList.get(i);
|
||||
|
||||
values.put("STORE_CD", store_cd);
|
||||
values.put("QUESTION_ID", data.getQUESTION_ID());
|
||||
values.put("QUESTION", data.getQUESTION());
|
||||
values.put("ANSWER_ID", data.getANSWER_ID());
|
||||
values.put("ANSWER", data.getANSWER());
|
||||
values.put("SUB_CATEGORY_ID", headerDataList.get(l).getSub_category_id());
|
||||
values.put("SUB_CATEGORY", headerDataList.get(l).getSub_category());
|
||||
values.put("QTYPE", data.getQTYPE());
|
||||
values.put("CATEGORY_ID", category_cd);
|
||||
|
||||
db.insert(CommonString.TABLE_POG_DATA_SAVE, null, values);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
Log.d("Database ", "Exception while Insert Audit Data " + ex.toString());
|
||||
}
|
||||
@@ -9393,7 +9464,6 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
|
||||
Log.d("Exception ", "when fetching Records!!!!!!!!!!!!!!!!!!!!!" + e.toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
Log.d("MSL_Availability_StockFacing ", "midday---------------------->Stop<-----------");
|
||||
return false;
|
||||
}
|
||||
@@ -10672,6 +10742,37 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
|
||||
return l;
|
||||
}
|
||||
|
||||
public long InsertPdPogImageData(
|
||||
String visit_date, String storeId, String categoryId, List<CategoryPictureGetterSetter> _list,String savemode) {
|
||||
ContentValues values = new ContentValues();
|
||||
long l = 0;
|
||||
try {
|
||||
db.delete(CommonString.TABLE_IRPD_POG,
|
||||
CommonString.KEY_STORE_ID + "=" + storeId + " AND " + CommonString.KEY_VISIT_DATE + "='" + visit_date + "' AND " +
|
||||
CommonString.KEY_CATEGORY_ID + "=" + categoryId, null);
|
||||
|
||||
db.beginTransaction();
|
||||
for (int i = 0; i < _list.size(); i++) {
|
||||
values.put(CommonString.KEY_SAVE_MODE, savemode);
|
||||
values.put(CommonString.KEY_STORE_ID, storeId);
|
||||
values.put(CommonString.KEY_VISIT_DATE, visit_date);
|
||||
values.put(CommonString.KEY_CATEGORY_ID, categoryId);
|
||||
values.put(CommonString.KEY_SUB_CATEGORY_ID, _list.get(i).getSUB_CATEGORY_ID());
|
||||
values.put(CommonString.KEY_SUB_CATEGORY_CODE, _list.get(i).getSubCatCode());
|
||||
List<String> info = _list.get(i).getImageUris().stream().map(ImageUri::getModify_uri).collect(Collectors.toList());
|
||||
values.put(CommonString.KEY_IRPD_IMAGES, _list.get(i).getImageUris().stream().map(ImageUri::getUri).collect(Collectors.toList()).stream().collect(Collectors.joining(", ")));
|
||||
values.put(CommonString.KEY_IRPD_MODIFY_IMAGES, _list.get(i).getImageUris().stream().map(ImageUri::getModify_uri).collect(Collectors.toList()).stream().collect(Collectors.joining(", ")));
|
||||
l = db.insert(CommonString.TABLE_IRPD_POG, null, values);
|
||||
Log.e("data_d", info.toString() + ","+_list.get(i).getImageUris().size());
|
||||
}
|
||||
db.setTransactionSuccessful();
|
||||
db.endTransaction();
|
||||
} catch (Exception ex) {
|
||||
Log.d("data_d ", " in Insert TABLE_IRPD " + ex);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
public long InsertPdImageVisibilityData(
|
||||
String visit_date, String storeId, String categoryId, List<CategoryPictureGetterSetter> _list,String savemode) {
|
||||
ContentValues values = new ContentValues();
|
||||
@@ -10779,6 +10880,44 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
|
||||
return filled;
|
||||
}
|
||||
|
||||
public boolean isSOSPogCategory(String store_id, String date, String mode, String categoryId) {
|
||||
boolean filled = false;
|
||||
Cursor dbcursor = null;
|
||||
try {
|
||||
String query = "";
|
||||
if (mode != null) {
|
||||
query = "SELECT * FROM " + CommonString.TABLE_IRPD_POG + " WHERE "
|
||||
+ CommonString.KEY_STORE_ID + " =" + store_id + " AND "
|
||||
+ CommonString.KEY_CATEGORY_ID + " =" + categoryId + " AND "
|
||||
+ CommonString.KEY_VISIT_DATE + " ='" + date + "'";
|
||||
} else {
|
||||
|
||||
}
|
||||
dbcursor = db.rawQuery(query, null);
|
||||
|
||||
if (dbcursor != null) {
|
||||
dbcursor.moveToFirst();
|
||||
while (!dbcursor.isAfterLast()) {
|
||||
String common_status = dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_SAVE_MODE));
|
||||
if (mode != null) {
|
||||
if (common_status != null && !common_status.equals("") && common_status.equalsIgnoreCase(CommonString.KEY_COMPELETE)) {
|
||||
filled = true;
|
||||
} else {
|
||||
filled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
dbcursor.moveToNext();
|
||||
}
|
||||
dbcursor.close();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
return filled;
|
||||
}
|
||||
return filled;
|
||||
}
|
||||
|
||||
public boolean isPdVisibility(String store_id, String date, String mode, String categoryId) {
|
||||
boolean filled = false;
|
||||
Cursor dbcursor = null;
|
||||
@@ -10817,6 +10956,44 @@ public class GSKOrangeDB extends SQLiteOpenHelper {
|
||||
return filled;
|
||||
}
|
||||
|
||||
public boolean isPdPogImages(String store_id, String date, String mode, String categoryId) {
|
||||
boolean filled = false;
|
||||
Cursor dbcursor = null;
|
||||
try {
|
||||
String query = "";
|
||||
if (mode != null) {
|
||||
query = "SELECT * FROM " + CommonString.TABLE_IRPD_POG + " WHERE "
|
||||
+ CommonString.KEY_STORE_ID + " =" + store_id + " AND "
|
||||
+ CommonString.KEY_CATEGORY_ID + " =" + categoryId + " AND "
|
||||
+ CommonString.KEY_VISIT_DATE + " ='" + date + "'";
|
||||
} else {
|
||||
|
||||
}
|
||||
dbcursor = db.rawQuery(query, null);
|
||||
|
||||
if (dbcursor != null) {
|
||||
dbcursor.moveToFirst();
|
||||
while (!dbcursor.isAfterLast()) {
|
||||
String common_status = dbcursor.getString(dbcursor.getColumnIndexOrThrow(CommonString.KEY_SAVE_MODE));
|
||||
if (mode != null) {
|
||||
if (common_status != null && !common_status.equals("") && common_status.equalsIgnoreCase(CommonString.KEY_COMPELETE)) {
|
||||
filled = true;
|
||||
} else {
|
||||
filled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
dbcursor.moveToNext();
|
||||
}
|
||||
dbcursor.close();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
return filled;
|
||||
}
|
||||
return filled;
|
||||
}
|
||||
|
||||
public ArrayList<CategoryPictureGetterSetter> getIrPDforUpload(String store_id, String visit_date) {
|
||||
ArrayList<CategoryPictureGetterSetter> list = new ArrayList<>();
|
||||
Cursor dbcursor = null;
|
||||
|
||||
@@ -95,7 +95,6 @@ import cpm.com.gskmtorange.xmlHandlers.XMLHandlers;
|
||||
import static android.Manifest.permission.READ_CONTACTS;
|
||||
import static com.google.android.gms.location.LocationRequest.Builder.IMPLICIT_MIN_UPDATE_INTERVAL;
|
||||
|
||||
|
||||
public class LoginActivity extends AppCompatActivity implements GoogleApiClient.ConnectionCallbacks,
|
||||
GoogleApiClient.OnConnectionFailedListener, LocationListener {
|
||||
private static final int MY_PERMISSIONS_REQUEST_CAMERA = 10;
|
||||
@@ -161,7 +160,7 @@ public class LoginActivity extends AppCompatActivity implements GoogleApiClient.
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
tv_version.setText("Version/Versiyon - " + app_ver);
|
||||
tv_version.setText("Version/Versiyon - " + app_ver + "-T5");
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
editor = preferences.edit();
|
||||
// Set up the login form.
|
||||
@@ -518,39 +517,6 @@ public class LoginActivity extends AppCompatActivity implements GoogleApiClient.
|
||||
}
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
|
||||
return new CursorLoader(this,
|
||||
// Retrieve data rows for the device user's 'profile' contact.
|
||||
Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
|
||||
ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,
|
||||
|
||||
// Select only userid addresses.
|
||||
ContactsContract.Contacts.Data.MIMETYPE +
|
||||
" = ?", new String[]{ContactsContract.CommonDataKinds.userid
|
||||
.CONTENT_ITEM_TYPE},
|
||||
|
||||
// Show primary userid addresses first. Note that there won't be
|
||||
// a primary userid address if the user hasn't specified one.
|
||||
ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
|
||||
List<String> userids = new ArrayList<>();
|
||||
cursor.moveToFirst();
|
||||
while (!cursor.isAfterLast()) {
|
||||
userids.add(cursor.getString(ProfileQuery.ADDRESS));
|
||||
cursor.moveToNext();
|
||||
}
|
||||
|
||||
adduseridsToAutoComplete(userids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Cursor> cursorLoader) {
|
||||
|
||||
}*/
|
||||
|
||||
private void adduseridsToAutoComplete(List<String> useridAddressCollection) {
|
||||
//Create adapter to tell the AutoCompleteTextView what to show in its dropdown list.
|
||||
@@ -562,21 +528,6 @@ public class LoginActivity extends AppCompatActivity implements GoogleApiClient.
|
||||
}
|
||||
|
||||
|
||||
/* private interface ProfileQuery {
|
||||
String[] PROJECTION = {
|
||||
ContactsContract.CommonDataKinds.userid.ADDRESS,
|
||||
ContactsContract.CommonDataKinds.userid.IS_PRIMARY,
|
||||
};
|
||||
|
||||
int ADDRESS = 0;
|
||||
int IS_PRIMARY = 1;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Represents an asynchronous login/registration task used to authenticate
|
||||
* the user.
|
||||
*/
|
||||
|
||||
private class AuthenticateTask extends AsyncTask<Void, Void, String> {
|
||||
private ProgressDialog dialog = null;
|
||||
|
||||
@@ -600,7 +551,7 @@ public class LoginActivity extends AppCompatActivity implements GoogleApiClient.
|
||||
+ "[/PASSWORD]" + "[IN_TIME]" + CommonFunctions.getCurrentTimeWithLanguage(context)
|
||||
+ "[/IN_TIME]" + "[LATITUDE]" + lat
|
||||
+ "[/LATITUDE]" + "[LONGITUDE]" + lon
|
||||
+ "[/LONGITUDE]" + "[APP_VERSION]" + app_ver
|
||||
+ "[/LONGITUDE]" + "[APP_VERSION]" + app_ver + "-T5"
|
||||
+ "[/APP_VERSION]" + "[ATT_MODE]OnLine[/ATT_MODE]"
|
||||
+ "[NETWORK_STATUS]" + "LoginStatus"
|
||||
+ "[/NETWORK_STATUS]" + "[/USER_DATA][/DATA]";
|
||||
@@ -654,7 +605,6 @@ public class LoginActivity extends AppCompatActivity implements GoogleApiClient.
|
||||
});
|
||||
} else {
|
||||
|
||||
|
||||
// For String source
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
xpp.next();
|
||||
@@ -794,9 +744,6 @@ public class LoginActivity extends AppCompatActivity implements GoogleApiClient.
|
||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
/* Intent i = new Intent(activity, StorelistActivity.class);
|
||||
activity.startActivity(i);
|
||||
activity.finish();*/
|
||||
|
||||
}
|
||||
});
|
||||
@@ -977,29 +924,6 @@ public class LoginActivity extends AppCompatActivity implements GoogleApiClient.
|
||||
fusedLocationProviderClient.requestLocationUpdates(locationRequest, locationCallback, Looper.getMainLooper());
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
checkAppPermission(Manifest.permission.CAMERA, MY_PERMISSIONS_REQUEST_CAMERA);
|
||||
|
||||
if (checkPlayServices()) {
|
||||
// Building the GoogleApi client
|
||||
buildGoogleApiClient();
|
||||
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() {
|
||||
int resultCode = GooglePlayServicesUtil
|
||||
.isGooglePlayServicesAvailable(this);
|
||||
|
||||
@@ -66,6 +66,7 @@ public class MainActivity extends AppCompatActivity
|
||||
WebView webView;
|
||||
ImageView imageView;
|
||||
String date;
|
||||
String app_ver;
|
||||
private SharedPreferences preferences = null;
|
||||
GSKOrangeDB db;
|
||||
String user_name, country_id;
|
||||
@@ -130,6 +131,13 @@ public class MainActivity extends AppCompatActivity
|
||||
db.open();
|
||||
//usk
|
||||
navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
try {
|
||||
app_ver = String.valueOf(getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
|
||||
// login_version.setText("Parinaam Version " + app_ver);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
// get menu from navigationView
|
||||
Menu menu = navigationView.getMenu();
|
||||
// find MenuItem you want to change
|
||||
@@ -163,6 +171,9 @@ public class MainActivity extends AppCompatActivity
|
||||
nav_route_plan13.setTitle(getResources().getString(R.string.menu_setting));
|
||||
MenuItem nav_route_plan14 = menu.findItem(R.id.nav_services);
|
||||
nav_route_plan14.setTitle(getResources().getString(R.string.menu_services));
|
||||
|
||||
MenuItem nav_route_plan15 = menu.findItem(R.id.nav_version);
|
||||
nav_route_plan15.setTitle("Version/Versiyon - " + app_ver + "-T5");
|
||||
//Enable disable According to Configuration
|
||||
ArrayList<ConfigurationMasterGetterSetter> configurationData = db.getConfigurationMasterData(country_id);
|
||||
if (!configurationData.isEmpty()) {
|
||||
|
||||
@@ -1,30 +1,16 @@
|
||||
package cpm.com.gskmtorange;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.password.MPinActivity;
|
||||
|
||||
@@ -35,11 +21,11 @@ public class SplashScreenActivity extends AppCompatActivity {
|
||||
private Context context;
|
||||
private SharedPreferences preferences = null;
|
||||
|
||||
public void onAttachedToWindow() {
|
||||
/* public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
Window window = getWindow();
|
||||
window.setFormat(PixelFormat.RGBA_8888);
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Called when the activity is first created.
|
||||
@@ -47,103 +33,50 @@ public class SplashScreenActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_splash_main_layout);
|
||||
|
||||
linearLayout = findViewById(R.id.lin_lay);
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
context = this;
|
||||
//StartAnimations();
|
||||
|
||||
sendToLogin();
|
||||
|
||||
/* File f = new File(CommonString.getImagesFolder(context)_OLD);
|
||||
if(f!=null){
|
||||
File file[] = f.listFiles();
|
||||
if(file!=null){
|
||||
|
||||
for (int i=0;i<file.length;i++){
|
||||
Date lastModDate = new Date(file[0].lastModified());
|
||||
String day = lastModDate.toString();
|
||||
|
||||
*//*SimpleDateFormat spf= new SimpleDateFormat("MM/dd/yyyy");
|
||||
date = spf.format(newDate);
|
||||
System.out.println(date);*//*
|
||||
}
|
||||
*//* if(file.length>0){
|
||||
UploadImageWithRetrofit.uploadedFiles = 0;
|
||||
UploadImageWithRetrofit.totalFiles = file.length;
|
||||
UploadImageWithRetrofit uploadImg = new UploadImageWithRetrofit( SplashScreenActivity.this);
|
||||
uploadImg.UploadImageRecursive(SplashScreenActivity.this);
|
||||
}
|
||||
else {
|
||||
sendToLogin();
|
||||
}*//*
|
||||
}else {
|
||||
sendToLogin();
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
sendToLogin();
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
/* private void StartAnimations() {
|
||||
Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
|
||||
anim.reset();
|
||||
LinearLayout l=(LinearLayout) findViewById(R.id.lin_lay);
|
||||
l.clearAnimation();
|
||||
l.startAnimation(anim);
|
||||
|
||||
anim = AnimationUtils.loadAnimation(this, R.anim.translate);
|
||||
anim.reset();
|
||||
ImageView iv = (ImageView) findViewById(R.id.logo);
|
||||
iv.clearAnimation();
|
||||
iv.startAnimation(anim);
|
||||
|
||||
}*/
|
||||
|
||||
public void sendToLogin() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
|
||||
/*
|
||||
* Showing splash screen with a timer. This will be useful when you
|
||||
* want to show case your app logo / company
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//after Mpin
|
||||
String mpin = preferences.getString(CommonString.MPIN, null);
|
||||
if (mpin != null) {
|
||||
Intent in = new Intent(context, MPinActivity.class);
|
||||
in.putExtra(CommonString.IS_PASSWORD_CHECK, true);
|
||||
startActivity(in);
|
||||
finish();
|
||||
} else {
|
||||
Intent i = new Intent(context, LoginActivity.class);
|
||||
startActivity(i);
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
}, SPLASH_TIME_OUT);
|
||||
}
|
||||
|
||||
public static String getCalculatedDate(String date, String dateFormat, int days) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
@SuppressLint("SimpleDateFormat") SimpleDateFormat s = new SimpleDateFormat(dateFormat);
|
||||
cal.add(Calendar.DAY_OF_YEAR, days);
|
||||
try {
|
||||
return s.format(new Date(s.parse(date).getTime()));
|
||||
} catch (ParseException e) {
|
||||
// TODO Auto-generated catch block
|
||||
Log.e("TAG", "Error in Parsing Date : " + e.getMessage());
|
||||
// Optional: hide the status bar safely
|
||||
getWindow().getDecorView().setSystemUiVisibility(
|
||||
View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
);
|
||||
}catch (Exception ignored){}
|
||||
setContentView(R.layout.activity_splash_main_layout);
|
||||
linearLayout = findViewById(R.id.lin_lay);
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
startSplashTimer();
|
||||
}
|
||||
|
||||
|
||||
private void sendToLogin() {
|
||||
try {
|
||||
String mpin = preferences.getString(CommonString.MPIN, null);
|
||||
Intent intent;
|
||||
if (mpin != null) {
|
||||
intent = new Intent(this, MPinActivity.class);
|
||||
intent.putExtra(CommonString.IS_PASSWORD_CHECK, true);
|
||||
} else {
|
||||
intent = new Intent(this, LoginActivity.class);
|
||||
}
|
||||
startActivity(intent);
|
||||
finish();
|
||||
} catch (Exception ignored) {} finally {
|
||||
String mpin = preferences.getString(CommonString.MPIN, null);
|
||||
Intent intent;
|
||||
if (mpin != null) {
|
||||
intent = new Intent(this, MPinActivity.class);
|
||||
intent.putExtra(CommonString.IS_PASSWORD_CHECK, true);
|
||||
} else {
|
||||
intent = new Intent(this, LoginActivity.class);
|
||||
}
|
||||
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private void startSplashTimer() {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(this::sendToLogin, 3000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package cpm.com.gskmtorange.adapter
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import cpm.com.gskmtorange.GetterSetter.CategoryPictureGetterSetter
|
||||
import cpm.com.gskmtorange.R
|
||||
import cpm.com.gskmtorange.adapter.data.ImageUri
|
||||
import cpm.com.gskmtorange.databinding.ItemRealtimePdBinding
|
||||
|
||||
class RealtimeAdapter(
|
||||
val category: String?,
|
||||
var context: Context,
|
||||
private var subcates: ArrayList<CategoryPictureGetterSetter>?,
|
||||
private val btnlistener: BtnClickListener,
|
||||
) : RecyclerView.Adapter<RealtimeAdapter.CustomViewHolder>() {
|
||||
class CustomViewHolder(view: View) : RecyclerView.ViewHolder(view)
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = CustomViewHolder(
|
||||
ItemRealtimePdBinding.inflate(LayoutInflater.from(context), parent, false).root
|
||||
)
|
||||
|
||||
@SuppressLint(
|
||||
"NotifyDataSetChanged", "ClickableViewAccessibility",
|
||||
"UseCompatLoadingForDrawables", "SetTextI18n"
|
||||
)
|
||||
override fun onBindViewHolder(holder: CustomViewHolder, position: Int) {
|
||||
ItemRealtimePdBinding.bind(holder.itemView).apply {
|
||||
val subcat = subcates!![position]
|
||||
tvSubCategory.text = "$category-${subcat.suB_CATEGORY}"
|
||||
analyticBT.text = context.getString(R.string.view_report_pd)
|
||||
analyticBT.setOnClickListener {
|
||||
btnlistener.onStartSessionClick(position, subcat)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return subcates!!.size
|
||||
}
|
||||
|
||||
interface BtnClickListener {
|
||||
fun onStartSessionClick(_pos: Int, data: CategoryPictureGetterSetter)
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun addsubCatItems(langList: ArrayList<CategoryPictureGetterSetter>?) {
|
||||
subcates = langList
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun updateItem(position: Int, uris: List<ImageUri>) {
|
||||
subcates!![position].imageUris = (subcates!![position].imageUris
|
||||
?: ArrayList()).apply { addAll(uris as ArrayList<ImageUri>) }
|
||||
notifyItemChanged(position)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package cpm.com.gskmtorange.adapter
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import cpm.com.gskmtorange.dailyentry.WebViewActivity
|
||||
import cpm.com.gskmtorange.databinding.ItemCategoryScoreBinding
|
||||
import cpm.com.gskmtorange.databinding.ItemOverallScoreBinding
|
||||
import cpm.com.gskmtorange.databinding.ItemPdImageBinding
|
||||
import cpm.com.gskmtorange.utils.ScoreItem
|
||||
|
||||
class ScoreAdapter(private val items: List<ScoreItem>) :
|
||||
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
|
||||
private val TYPE_OVERALL = 0
|
||||
private val TYPE_CATEGORY = 1
|
||||
private val TYPE_IMAGE = 2
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return when (items[position]) {
|
||||
is ScoreItem.OverallScore -> TYPE_OVERALL
|
||||
is ScoreItem.CategoryScore -> TYPE_CATEGORY
|
||||
is ScoreItem.ImageItem -> TYPE_IMAGE
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
val inflater = LayoutInflater.from(parent.context)
|
||||
return when (viewType) {
|
||||
TYPE_OVERALL -> {
|
||||
val binding = ItemOverallScoreBinding.inflate(inflater, parent, false)
|
||||
OverallViewHolder(binding)
|
||||
}
|
||||
TYPE_CATEGORY -> {
|
||||
val binding = ItemCategoryScoreBinding.inflate(inflater, parent, false)
|
||||
CategoryViewHolder(binding)
|
||||
}
|
||||
TYPE_IMAGE -> {
|
||||
val binding = ItemPdImageBinding.inflate(inflater, parent, false)
|
||||
ImageViewHolder(binding)
|
||||
}
|
||||
else -> throw IllegalArgumentException("Invalid view type")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
when (val item = items[position]) {
|
||||
is ScoreItem.OverallScore -> (holder as OverallViewHolder).bind(item)
|
||||
is ScoreItem.CategoryScore -> (holder as CategoryViewHolder).bind(item)
|
||||
is ScoreItem.ImageItem -> (holder as ImageViewHolder).bind(item)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = items.size
|
||||
|
||||
class OverallViewHolder(private val binding: ItemOverallScoreBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
fun bind(item: ScoreItem.OverallScore) {
|
||||
binding.tvOsa.text = "OSA: ${item.osa}"
|
||||
binding.tvMsl.text = "MSL: ${item.msl}"
|
||||
binding.tvPosm.text = "POSM: ${item.posm}"
|
||||
binding.tvSosSku.text = "SOS (SKU): ${item.sosSku}"
|
||||
binding.tvSosBrand.text = "SOS (Brand): ${item.sosBrand}"
|
||||
}
|
||||
}
|
||||
|
||||
class CategoryViewHolder(private val binding: ItemCategoryScoreBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
fun bind(item: ScoreItem.CategoryScore) {
|
||||
binding.tvCategory.text = item.categoryName
|
||||
binding.tvMsl.text = "MSL: ${item.msl}"
|
||||
binding.tvPosm.text = "POSM: ${item.posm}"
|
||||
binding.tvSosSku.text = "SOS (SKU): ${item.sosSku}"
|
||||
binding.tvSosBrand.text = "SOS (Brand): ${item.sosBrand}"
|
||||
|
||||
binding.layoutBrands.removeAllViews()
|
||||
for (brand in item.brandDetails) {
|
||||
val tv = TextView(binding.root.context)
|
||||
tv.text = "${brand.first}: ${brand.second}"
|
||||
binding.layoutBrands.addView(tv)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ImageViewHolder(private val binding: ItemPdImageBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
fun bind(item: ScoreItem.ImageItem) {
|
||||
Log.d("itemuri",item.url)
|
||||
/* binding.btnViewImage.setOnClickListener {
|
||||
val context = binding.root.context
|
||||
val intent = Intent(context, WebViewActivity::class.java)
|
||||
intent.putExtra("url", item.url)
|
||||
context.startActivity(intent)
|
||||
}*/
|
||||
val actualUrl = if (item.url.contains("?url=")) {
|
||||
item.url.substringAfter("?url=") // extract the real image link
|
||||
} else item.url
|
||||
|
||||
Glide.with(binding.ivRawImage.context)
|
||||
.load(actualUrl)
|
||||
//.placeholder(R.drawable.ic_placeholder) // optional
|
||||
// .error(R.drawable.ic_broken_image) // fallback if fail
|
||||
.into(binding.ivRawImage)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,4 +210,5 @@ public class CommonFunctions {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -151,16 +151,14 @@ public class CommonString {
|
||||
public static final int UNIT_VERTICAL = 50;
|
||||
public static final int UNIT_HORIZONTAL = 200;
|
||||
|
||||
// public static String URL = "http://gskme.parinaam.in/Gskwebservice.asmx";
|
||||
public static String URL = "http://gskmeIR.parinaam.in/Gskwebservice.asmx";
|
||||
// public static String URL = "https://gskme1.parinaam.in/Gskwebservice.asmx";
|
||||
// public static String URL = "http://gskme.parinaam.in/Gskwebservice.asmx";
|
||||
// public static String URL = "http://gskmeIR.parinaam.in/Gskwebservice.asmx";
|
||||
// public static String URL = "https://gskme2.parinaam.in/Gskwebservice.asmx";
|
||||
//Added new Test url for Turkey
|
||||
// public static String URL = "http://gskmetest.parinaam.in/Gskwebservice.asmx";
|
||||
|
||||
// public static String URL = "https://haleonme.parinaam.in/Gskwebservice.asmx";
|
||||
//public static String URL = " https://gskme1.parinaam.in/Gskwebservice.asmx";
|
||||
//public static String URL = "https://gskme-test.parinaam.in/Gskwebservice.asmx";
|
||||
|
||||
public static String URL = "https://haleonme.parinaam.in/Gskwebservice.asmx";
|
||||
// public static String URL = "https://gskme2.parinaam.in/Gskwebservice.asmx";
|
||||
public static final String NAMESPACE = "http://tempuri.org/";
|
||||
public static final String METHOD_LOGIN = "UserLoginDetail";
|
||||
public static final String SOAP_ACTION_LOGIN = "http://tempuri.org/"
|
||||
@@ -1138,6 +1136,12 @@ public class CommonString {
|
||||
+ "QTYPE"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "SUB_CATEGORY"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "ANSWER"
|
||||
+ " VARCHAR,"
|
||||
|
||||
+ "ANSWER_ID"
|
||||
+ " INTEGER,"
|
||||
|
||||
@@ -1574,6 +1578,30 @@ public class CommonString {
|
||||
+ KEY_IRPD_IMAGES
|
||||
+ " VARCHAR)";
|
||||
|
||||
|
||||
public static final String TABLE_IRPD_POG = "DR_IRPD_POG";
|
||||
public static final String CREATE_TABLE_IRPD_POG = "CREATE TABLE IF NOT EXISTS "
|
||||
+ TABLE_IRPD_POG
|
||||
+ " ("
|
||||
+ "KEY_ID"
|
||||
+ " INTEGER PRIMARY KEY AUTOINCREMENT ,"
|
||||
+ KEY_STORE_ID
|
||||
+ " INTEGER,"
|
||||
+ KEY_VISIT_DATE
|
||||
+ " VARCHAR,"
|
||||
+ KEY_SAVE_MODE
|
||||
+ " VARCHAR,"
|
||||
+ KEY_CATEGORY_ID
|
||||
+ " INTEGER,"
|
||||
+ KEY_SUB_CATEGORY_ID
|
||||
+ " INTEGER,"
|
||||
+ KEY_SUB_CATEGORY_CODE
|
||||
+ " VARCHAR,"
|
||||
+ KEY_IRPD_MODIFY_IMAGES
|
||||
+ " VARCHAR,"
|
||||
+ KEY_IRPD_IMAGES
|
||||
+ " VARCHAR)";
|
||||
|
||||
public static final String KEY_IRPD_VISIBILITY_IMAGES = "IRPD_VISIBILITY_IMAGES";
|
||||
public static final String KEY_IRPD_VISIBILITY_MODIFY_IMAGES = "IRPD_VISIBILITY_IMAGES_MODIFY";
|
||||
public static final String TABLE_IRPD_VISIBILITY = "DR_IRPD_VISIBILITY";
|
||||
|
||||
@@ -235,7 +235,6 @@ public class AdditionalVisibility extends AppCompatActivity implements View.OnCl
|
||||
img_planogram.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
@@ -694,7 +693,7 @@ public class AdditionalVisibility extends AppCompatActivity implements View.OnCl
|
||||
defdata.clear();
|
||||
btnsku.setBackgroundResource(R.color.colorPrimary);
|
||||
if (camera_allow.equals("1")) {
|
||||
btnimage.setBackgroundResource(country_id.equals("6") ? R.mipmap.camera_orange : R.drawable.camera_orange_star_green);
|
||||
btnimage.setBackgroundResource(country_id.equals("6") ? R.mipmap.camera_orange_star_green : R.mipmap.camera_orange);
|
||||
btnimage1.setBackgroundResource(R.mipmap.camera_orange);
|
||||
btnimage2.setBackgroundResource(R.mipmap.camera_orange);
|
||||
} else {
|
||||
|
||||
@@ -167,68 +167,32 @@ public class CategoryPicture extends AppCompatActivity {
|
||||
db.InsertCategoryPictureData(CP, listdat, categoryId);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
|
||||
/* AlertDialog.Builder builder = new AlertDialog.Builder(CategoryPicture.this);
|
||||
builder.setMessage(getResources().getString(R.string.check_save_message))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
db.open();
|
||||
|
||||
db.InsertCategoryPictureData(CP, listdat, categoryId);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();*/
|
||||
|
||||
|
||||
} else {
|
||||
Snackbar.make(view, R.string.title_activity_take_image, Snackbar.LENGTH_LONG).setAction("Action", null).show();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
im1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
|
||||
_pathforcheck1 = store_id + "CategoryPicture1" + categoryId + date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck1;
|
||||
intime = CommonFunctions.getCurrentTimeWithLanguage(context);
|
||||
startCameraActivity();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
im2.setOnClickListener(view -> {
|
||||
|
||||
_pathforcheck2 = store_id + "CategoryPicture2" + categoryId + date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck2;
|
||||
intime = CommonFunctions.getCurrentTimeWithLanguage(context);
|
||||
startCameraActivity();
|
||||
});
|
||||
im3.setOnClickListener(view -> {
|
||||
|
||||
_pathforcheck3 = store_id + "CategoryPicture3" + categoryId + date.replace("/", "") + CommonFunctions.getCurrentTimeWithLanguage(context).replace(":", "") + ".jpg";
|
||||
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck3;
|
||||
intime = CommonFunctions.getCurrentTimeWithLanguage(context);
|
||||
startCameraActivity();
|
||||
|
||||
|
||||
});
|
||||
im4.setOnClickListener(view -> {
|
||||
|
||||
@@ -237,8 +201,6 @@ public class CategoryPicture extends AppCompatActivity {
|
||||
_path = CommonString.getImagesFolder(context) + _pathforcheck4;
|
||||
intime = CommonFunctions.getCurrentTimeWithLanguage(context);
|
||||
startCameraActivity();
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ public class CheckoutActivity extends AppCompatActivity {
|
||||
lat = getIntent().getStringExtra(CommonString.KEY_LATITUDE);
|
||||
lon = getIntent().getStringExtra(CommonString.KEY_LONGITUDE);
|
||||
coverageBean = db.getCoverageSpecificData(visit_date, store_id);
|
||||
|
||||
new BackgroundTask(CheckoutActivity.this).execute();
|
||||
}
|
||||
|
||||
@@ -167,7 +168,6 @@ public class CheckoutActivity extends AppCompatActivity {
|
||||
table = CommonString.KEY_ADHOC_JOURNEY_PLAN;
|
||||
break;
|
||||
}
|
||||
|
||||
db.updateCheckoutStatus(store_id, CommonString.KEY_Y, table);
|
||||
} else {
|
||||
if (result.toString().equalsIgnoreCase(CommonString.KEY_FALSE)) {
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
package cpm.com.gskmtorange.dailyentry
|
||||
|
||||
import android.Manifest
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.SharedPreferences
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.NetworkCapabilities
|
||||
import android.os.Bundle
|
||||
import android.preference.PreferenceManager
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.net.toUri
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
@@ -35,7 +32,6 @@ import cpm.com.gskmtorange.constant.CommonFunctions
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions.savefile
|
||||
import cpm.com.gskmtorange.constant.CommonString
|
||||
import cpm.com.gskmtorange.constant.CommonUtils
|
||||
import cpm.com.gskmtorange.databinding.ActivityPdimageBinding
|
||||
import cpm.com.gskmtorange.databinding.ActivityPdvisibilityBinding
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -47,6 +43,7 @@ class PDVisibilityActivity : AppCompatActivity() {
|
||||
var categoryName: String? = null
|
||||
var categoryId: String? = null
|
||||
var store_id: String? = null;
|
||||
var lang: String? = null;
|
||||
var date: String? = null;
|
||||
var store_type_id: String? = null
|
||||
var class_id: String? = null
|
||||
@@ -62,6 +59,8 @@ class PDVisibilityActivity : AppCompatActivity() {
|
||||
private var adapter: SubCatPdAdapter? = null
|
||||
val PERMISSION_ALL: Int = 99
|
||||
private var _pos = -1;
|
||||
var devicename : String? = ""
|
||||
var store_name : String? = ""
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -73,7 +72,9 @@ class PDVisibilityActivity : AppCompatActivity() {
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
db?.open()
|
||||
preferences?.let {
|
||||
lang = it.getString(CommonString.KEY_LANGUAGE, "")
|
||||
store_id = it.getString(CommonString.KEY_STORE_ID, "")
|
||||
store_name = it.getString(CommonString.KEY_STORE_NAME, "")
|
||||
username = it.getString(CommonString.KEY_USERNAME, "")
|
||||
store_type_id = it.getString(CommonString.KEY_STORETYPE_ID, "")
|
||||
class_id = it.getString(CommonString.KEY_CLASS_ID, "")
|
||||
@@ -81,7 +82,9 @@ class PDVisibilityActivity : AppCompatActivity() {
|
||||
country_id = it.getString(CommonString.KEY_COUNTRY_ID, "")
|
||||
store_flag_str = it.getString(CommonString.KEY_STORE_FLAG, "")
|
||||
date = it.getString(CommonString.KEY_DATE, "")
|
||||
//Log.d("languagedata", lang.toString());
|
||||
}
|
||||
devicename = android.os.Build.MANUFACTURER
|
||||
|
||||
CommonFunctions.updateLangResources(
|
||||
context, preferences?.getString(CommonString.KEY_LANGUAGE, "")
|
||||
@@ -158,7 +161,7 @@ class PDVisibilityActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
callAdapter()
|
||||
checkAndRequestPermissions()
|
||||
// checkAndRequestPermissions()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
@@ -196,7 +199,6 @@ class PDVisibilityActivity : AppCompatActivity() {
|
||||
if (id == R.id.action_settings) {
|
||||
return true
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
@@ -255,12 +257,15 @@ class PDVisibilityActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun launchCamera(subCat_code: String) {
|
||||
private fun launchCamera(subCat_code: String, subCategory: String, subCategoryId: String) {
|
||||
val uploadFrom = "TestApp"
|
||||
var shelftype = "posm_$subCategory" +"_"+subCategoryId
|
||||
shelftype = shelftype.lowercase().replace("[^a-z0-9_]".toRegex(), "")
|
||||
val uploadParams = JSONObject(
|
||||
"""
|
||||
{
|
||||
"shop_id": 62475,
|
||||
"store_name": "abc",
|
||||
"project_id": "4f57635b-6b07-45bf-bfba-c61c2826b6db",
|
||||
"td_version_id": 178,
|
||||
"shelf_image_id": null,
|
||||
@@ -275,32 +280,56 @@ class PDVisibilityActivity : AppCompatActivity() {
|
||||
"level": 1,
|
||||
"uploadOnlyOnWifi": 0,
|
||||
"app_session_id": "8e2faa6b-d6fe-413a-a693-76a0cbe0ce71",
|
||||
"metadata": { "Device_Name": "Samsung" }
|
||||
"metadata": { "Device_Name": $devicename,"User_name": $username }
|
||||
}
|
||||
"""
|
||||
)
|
||||
uploadParams.put("shelf_type", shelftype)
|
||||
uploadParams.put("store_name", store_name)
|
||||
uploadParams.put("shop_id", store_id)
|
||||
uploadParams.put("user_id", username)
|
||||
uploadParams.put("category_id", subCat_code)
|
||||
uploadParams.put("project_id", preferences?.getString(CommonString.KEY_PD_PROJECT_Id, ""))
|
||||
Log.d("uploadparams",uploadParams.toString());
|
||||
|
||||
CameraSDK.startCamera(
|
||||
context = this,
|
||||
orientation = "",
|
||||
widthPercentage = 20,
|
||||
uploadParams = uploadParams,
|
||||
resolution = 3000,
|
||||
referenceUrl = "",
|
||||
allowBlurCheck = true,
|
||||
allowCrop = true,
|
||||
uploadFrom = uploadFrom,
|
||||
isRetake = false,
|
||||
showOverlapToggleButton = false,
|
||||
showGridLines = true,
|
||||
zoomLevel = 1.0,
|
||||
language_code = "en",
|
||||
isLambda = false
|
||||
)
|
||||
if(!lang.equals("ENGLISH",ignoreCase = true)){
|
||||
CameraSDK.startCamera(
|
||||
context = this,
|
||||
orientation = "",
|
||||
widthPercentage = 20,
|
||||
uploadParams = uploadParams,
|
||||
resolution = 3000,
|
||||
referenceUrl = "",
|
||||
allowBlurCheck = true,
|
||||
allowCrop = true,
|
||||
uploadFrom = uploadFrom,
|
||||
isRetake = false,
|
||||
showOverlapToggleButton = false,
|
||||
showGridLines = true,
|
||||
zoomLevel = 1.0,
|
||||
language_code = "ar",
|
||||
isLambda = false
|
||||
)
|
||||
}
|
||||
else{
|
||||
CameraSDK.startCamera(
|
||||
context = this,
|
||||
orientation = "",
|
||||
widthPercentage = 20,
|
||||
uploadParams = uploadParams,
|
||||
resolution = 3000,
|
||||
referenceUrl = "",
|
||||
allowBlurCheck = true,
|
||||
allowCrop = true,
|
||||
uploadFrom = uploadFrom,
|
||||
isRetake = false,
|
||||
showOverlapToggleButton = false,
|
||||
showGridLines = true,
|
||||
zoomLevel = 1.0,
|
||||
language_code = "en",
|
||||
isLambda = false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun callAdapter() {
|
||||
@@ -315,9 +344,13 @@ class PDVisibilityActivity : AppCompatActivity() {
|
||||
btnlistener = object : SubCatPdAdapter.BtnClickListener {
|
||||
override fun onStartSessionClick(_pos: Int, data: CategoryPictureGetterSetter) {
|
||||
this@PDVisibilityActivity._pos = _pos
|
||||
launchCamera(data.subCatCode)
|
||||
Log.d("subCatCode", data.subCatCode)
|
||||
|
||||
/* if (isNetworkAvailable(this@PDVisibilityActivity)) {
|
||||
launchCamera(data.subCatCode,data.suB_CATEGORY,data.suB_CATEGORY_ID)
|
||||
Log.d("subCatCode", data.subCatCode)
|
||||
} else {
|
||||
Toast.makeText(context, "No internet connection", Toast.LENGTH_SHORT).show()
|
||||
}*/
|
||||
launchCamera(data.subCatCode,data.suB_CATEGORY,data.suB_CATEGORY_ID)
|
||||
}
|
||||
})
|
||||
binding.rlContent.apply {
|
||||
@@ -333,98 +366,18 @@ class PDVisibilityActivity : AppCompatActivity() {
|
||||
db?.InsertPdImageVisibilityData(date, store_id, categoryId, listdat, CommonString.KEY_DRAFT)
|
||||
}
|
||||
}
|
||||
fun isNetworkAvailable(context: Context): Boolean {
|
||||
val connectivityManager =
|
||||
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
|
||||
private fun checkAndRequestPermissions() {
|
||||
var read_phone_state = 0
|
||||
var write_storage = 0
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
write_storage =
|
||||
ContextCompat.checkSelfPermission(this, Manifest.permission.READ_MEDIA_IMAGES)
|
||||
} else {
|
||||
read_phone_state =
|
||||
ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE)
|
||||
write_storage =
|
||||
ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
val network = connectivityManager.activeNetwork ?: return false
|
||||
val activeNetwork = connectivityManager.getNetworkCapabilities(network) ?: return false
|
||||
|
||||
return when {
|
||||
activeNetwork.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true
|
||||
activeNetwork.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true
|
||||
activeNetwork.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
val listPermissionsNeeded: MutableList<String> = java.util.ArrayList()
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
if (write_storage != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.READ_MEDIA_IMAGES)
|
||||
}
|
||||
} else {
|
||||
if (write_storage != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
}
|
||||
}
|
||||
|
||||
if (listPermissionsNeeded.isNotEmpty()) {
|
||||
ActivityCompat.requestPermissions(
|
||||
this,
|
||||
listPermissionsNeeded.toTypedArray<String>(),
|
||||
PERMISSION_ALL
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRequestPermissionsResult(
|
||||
requestCode: Int,
|
||||
permissions: Array<String>,
|
||||
grantResults: IntArray
|
||||
) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
if (requestCode == PERMISSION_ALL) {
|
||||
val perms: MutableMap<String, Int> = HashMap()
|
||||
// Initialize the map with both permissions
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
perms[Manifest.permission.READ_MEDIA_IMAGES] = PackageManager.PERMISSION_GRANTED
|
||||
} else {
|
||||
perms[Manifest.permission.WRITE_EXTERNAL_STORAGE] =
|
||||
PackageManager.PERMISSION_GRANTED
|
||||
}
|
||||
// Fill with actual results from user
|
||||
if (grantResults.isNotEmpty()) {
|
||||
for (i in permissions.indices) perms[permissions[i]] = grantResults[i]
|
||||
// Check for both permissions//
|
||||
if (perms[Manifest.permission.READ_MEDIA_IMAGES] == PackageManager.PERMISSION_GRANTED &&
|
||||
perms[Manifest.permission.WRITE_EXTERNAL_STORAGE] == PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
Log.d("", "sms & location services permission granted")
|
||||
} else {
|
||||
Log.d("", "Some permissions are not granted ask again ")
|
||||
if (ActivityCompat.shouldShowRequestPermissionRationale(
|
||||
this,
|
||||
Manifest.permission.READ_MEDIA_IMAGES
|
||||
) ||
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(
|
||||
this,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
) {
|
||||
showDialogOK(
|
||||
"Photos or media Service Permission required for this app"
|
||||
) { _: DialogInterface?, which: Int ->
|
||||
when (which) {
|
||||
DialogInterface.BUTTON_POSITIVE -> checkAndRequestPermissions()
|
||||
DialogInterface.BUTTON_NEGATIVE -> {
|
||||
// proceed with logic by disabling the related features or quit the app.
|
||||
val startMain =
|
||||
Intent(Intent.ACTION_MAIN)
|
||||
startMain.addCategory(Intent.CATEGORY_HOME)
|
||||
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(startMain)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showDialogOK(message: String, okListener: DialogInterface.OnClickListener) {
|
||||
AlertDialog.Builder(this).setMessage(message).setPositiveButton("OK", okListener)
|
||||
.setNegativeButton("Cancel", okListener).create().show()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,465 @@
|
||||
package cpm.com.gskmtorange.dailyentry
|
||||
|
||||
import android.Manifest
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.SharedPreferences
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.preference.PreferenceManager
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.net.toUri
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.sj.camera_lib_android.Database.ReactPendingData
|
||||
import com.sj.camera_lib_android.Database.ReactSingleImage
|
||||
import com.sj.camera_lib_android.models.ImageUploadModel
|
||||
import com.sj.camera_lib_android.utils.CameraSDK
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB
|
||||
import cpm.com.gskmtorange.GetterSetter.CategoryPictureGetterSetter
|
||||
import cpm.com.gskmtorange.R
|
||||
import cpm.com.gskmtorange.adapter.SubCatPdAdapter
|
||||
import cpm.com.gskmtorange.adapter.data.ImageUri
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions.savefile
|
||||
import cpm.com.gskmtorange.constant.CommonString
|
||||
import cpm.com.gskmtorange.constant.CommonUtils
|
||||
import cpm.com.gskmtorange.databinding.ActivityPdPogBinding
|
||||
import cpm.com.gskmtorange.databinding.ActivityPdimageBinding
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
|
||||
class PD_Pog_Activity : AppCompatActivity() {
|
||||
private var context: Context? = null
|
||||
var categoryName: String? = null
|
||||
var categoryId: String? = null
|
||||
var store_id: String? = null;
|
||||
var date: String? = null;
|
||||
var store_type_id: String? = null
|
||||
var class_id: String? = null
|
||||
var key_account_id: String? = null
|
||||
var country_id: String? = null
|
||||
var store_flag_str: String? = null
|
||||
private var preferences: SharedPreferences? = null
|
||||
var db: GSKOrangeDB? = null
|
||||
var listdat: ArrayList<CategoryPictureGetterSetter>? = ArrayList()
|
||||
var username: String? = ""
|
||||
private var kpi_name: String? = ""
|
||||
private lateinit var binding: ActivityPdPogBinding
|
||||
private var adapter: SubCatPdAdapter? = null
|
||||
val PERMISSION_ALL: Int = 99
|
||||
private var _pos = -1;
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityPdPogBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
setSupportActionBar(binding.toolbar)
|
||||
context = this
|
||||
|
||||
db = GSKOrangeDB(context)
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
db?.open()
|
||||
preferences?.let {
|
||||
store_id = it.getString(CommonString.KEY_STORE_ID, "")
|
||||
username = it.getString(CommonString.KEY_USERNAME, "")
|
||||
store_type_id = it.getString(CommonString.KEY_STORETYPE_ID, "")
|
||||
class_id = it.getString(CommonString.KEY_CLASS_ID, "")
|
||||
key_account_id = it.getString(CommonString.KEY_KEYACCOUNT_ID, "")
|
||||
country_id = it.getString(CommonString.KEY_COUNTRY_ID, "")
|
||||
store_flag_str = it.getString(CommonString.KEY_STORE_FLAG, "")
|
||||
date = it.getString(CommonString.KEY_DATE, "")
|
||||
}
|
||||
|
||||
CommonFunctions.updateLangResources(
|
||||
context, preferences?.getString(CommonString.KEY_LANGUAGE, "")
|
||||
)
|
||||
intent?.let {
|
||||
categoryName = it.getStringExtra("categoryName")
|
||||
categoryId = it.getStringExtra("categoryId")
|
||||
kpi_name = it.getStringExtra("kpi_name")
|
||||
}
|
||||
supportActionBar?.apply {
|
||||
setHomeButtonEnabled(true)
|
||||
setDisplayHomeAsUpEnabled(true)
|
||||
title = kpi_name
|
||||
}
|
||||
preferences?.getString(CommonString.KEY_PD_PROJECT_Id, "")?.let { projectId ->
|
||||
val userId = preferences?.getString(CommonString.KEY_PD_USER_Id, "")
|
||||
.takeIf { !it.isNullOrBlank() } ?: username
|
||||
Log.d("pd_user_id",userId.toString());
|
||||
|
||||
CommonUtils.initializePDSDK(
|
||||
this@PD_Pog_Activity,
|
||||
projectId = projectId,
|
||||
_userId = userId
|
||||
)
|
||||
}
|
||||
|
||||
registerIntentFilter(
|
||||
listOf(
|
||||
"DataSaved", "did-receive-queue-data", "did-receive-image-upload-status"
|
||||
)
|
||||
)
|
||||
|
||||
binding.apply {
|
||||
fab.setOnClickListener {
|
||||
if (validate()) {
|
||||
val builder = AlertDialog.Builder(this@PD_Pog_Activity)
|
||||
builder.setMessage(getString(R.string.check_save_message)).setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.yes)) { dialog, _ ->
|
||||
// Handle Yes button click
|
||||
db?.open()
|
||||
db?.InsertPdPogImageData(
|
||||
date,
|
||||
store_id,
|
||||
categoryId,
|
||||
listdat,
|
||||
CommonString.KEY_COMPELETE
|
||||
)?.let {
|
||||
if (it > 0) {
|
||||
Snackbar.make(
|
||||
binding.fab,
|
||||
resources.getString(R.string.save_message),
|
||||
Snackbar.LENGTH_LONG
|
||||
).setAction("Action", null).show()
|
||||
lifecycleScope.launch {
|
||||
delay(3000) // 3 seconds delay
|
||||
finish()
|
||||
}
|
||||
} else {
|
||||
Snackbar.make(
|
||||
binding.fab,
|
||||
resources.getString(R.string.save_message),
|
||||
Snackbar.LENGTH_LONG
|
||||
).setAction("Action", null).show()
|
||||
}
|
||||
}
|
||||
dialog.dismiss()
|
||||
}.setNegativeButton(getString(R.string.no)) { dialog, _ ->
|
||||
dialog.cancel()
|
||||
}
|
||||
val alert = builder.create()
|
||||
alert.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
callAdapter()
|
||||
checkAndRequestPermissions()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
db?.open()
|
||||
}
|
||||
|
||||
private fun validate(): Boolean {
|
||||
var checkFlag = true // Use local variable to avoid issues
|
||||
if (!listdat.isNullOrEmpty()) {
|
||||
for (data in listdat!!) { // Use standard loop for better control
|
||||
if (data.imageUris.isNullOrEmpty()) {
|
||||
checkFlag = false // Set false if validation fails
|
||||
Snackbar.make(
|
||||
binding.fab,
|
||||
"Please capture IR images of ${data.suB_CATEGORY}",
|
||||
Snackbar.LENGTH_SHORT
|
||||
).show()
|
||||
break // Stop further checks once an issue is found
|
||||
}
|
||||
}
|
||||
}
|
||||
return checkFlag // Correctly return validation result
|
||||
}
|
||||
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
val id = item.itemId
|
||||
if (id == android.R.id.home) {
|
||||
//showDataLossAlert();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out)
|
||||
finish()
|
||||
}
|
||||
if (id == R.id.action_settings) {
|
||||
return true
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
LocalBroadcastManager.getInstance(this@PD_Pog_Activity)
|
||||
.unregisterReceiver(myBroadcastReceiver) // onDestroy
|
||||
}
|
||||
|
||||
private fun registerIntentFilter(filters: List<String> = listOf()) {
|
||||
filters.forEach { filter ->
|
||||
LocalBroadcastManager.getInstance(this@PD_Pog_Activity)
|
||||
.registerReceiver(myBroadcastReceiver, IntentFilter(filter))
|
||||
}
|
||||
}
|
||||
|
||||
private val savedImages = mutableListOf<ImageUri>()
|
||||
private var myBroadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
when (intent?.action) {
|
||||
"did-receive-queue-data" -> {
|
||||
val receivedList =
|
||||
intent.getParcelableArrayListExtra<ReactPendingData>("imageList")
|
||||
Log.d("DEBUG-LOG did-receive-queue-data", "$receivedList")
|
||||
if (receivedList.isNullOrEmpty()) {
|
||||
CameraSDK.uploadFailedImage(this@PD_Pog_Activity)
|
||||
}
|
||||
}
|
||||
|
||||
"did-receive-image-upload-status" -> {
|
||||
val receivedImage = intent.getParcelableExtra<ReactSingleImage>("image")
|
||||
Log.d("DEBUG-LOG did-receive-image-upload-status", "$receivedImage")
|
||||
}
|
||||
|
||||
"DataSaved" -> {
|
||||
val receivedList =
|
||||
intent.getParcelableArrayListExtra<ImageUploadModel>("imageListSaved")
|
||||
Log.d("DEBUG-LOG DataSaved", "$receivedList")
|
||||
receivedList?.let {
|
||||
savedImages.clear()
|
||||
it.forEach { item ->
|
||||
val dir = CommonString.getImagesFolder(context)
|
||||
val setName =
|
||||
store_id + "_" + username?.replace(".", "") + "_IRPDIMG-" + File(
|
||||
item.uri
|
||||
).getName()
|
||||
savedImages.add(ImageUri(uri = item.uri, modify_uri = setName))
|
||||
savefile(item.uri.toUri(), "$dir $setName")
|
||||
}
|
||||
adapter?.updateItem(position = _pos, savedImages)
|
||||
Log.e("savedImages", savedImages.toString())
|
||||
_pos = -1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun launchCamera(subCat_code: String) {
|
||||
val uploadFrom = "TestApp"
|
||||
val uploadParams = JSONObject(
|
||||
"""
|
||||
{
|
||||
"shop_id": 62475,
|
||||
"project_id": "4f57635b-6b07-45bf-bfba-c61c2826b6db",
|
||||
"td_version_id": 178,
|
||||
"shelf_image_id": null,
|
||||
"asset_image_id": null,
|
||||
"shelf_type": "Primary Shelf",
|
||||
"category_id": 123,
|
||||
"user_id": 133,
|
||||
"isConnected": true,
|
||||
"sn_image_type": "skus",
|
||||
"image_type": "multiple",
|
||||
"seq_no": 1,
|
||||
"level": 1,
|
||||
"uploadOnlyOnWifi": 0,
|
||||
"app_session_id": "8e2faa6b-d6fe-413a-a693-76a0cbe0ce71",
|
||||
"metadata": { "Device_Name": "Samsung" }
|
||||
}
|
||||
"""
|
||||
)
|
||||
uploadParams.put("shop_id", store_id)
|
||||
uploadParams.put("user_id", username)
|
||||
uploadParams.put("category_id", subCat_code)
|
||||
uploadParams.put("project_id", preferences?.getString(CommonString.KEY_PD_PROJECT_Id, ""))
|
||||
Log.d("uploadparamdata",uploadParams.toString());
|
||||
|
||||
CameraSDK.startCamera(
|
||||
context = this,
|
||||
orientation = "",
|
||||
widthPercentage = 20,
|
||||
uploadParams = uploadParams,
|
||||
resolution = 3000,
|
||||
referenceUrl = "",
|
||||
allowBlurCheck = true,
|
||||
allowCrop = true,
|
||||
uploadFrom = uploadFrom,
|
||||
isRetake = false,
|
||||
showOverlapToggleButton = false,
|
||||
showGridLines = true,
|
||||
zoomLevel = 1.0,
|
||||
language_code = "en",
|
||||
isLambda = false
|
||||
)
|
||||
}
|
||||
|
||||
private fun callAdapter() {
|
||||
if (country_id == "8") {
|
||||
db?.open()
|
||||
listdat = db?.getCategoryPicturePogdata(
|
||||
date,
|
||||
categoryId,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
store_id,
|
||||
CommonString.TABLE_MAPPING_STOCK_STOREWISE
|
||||
)
|
||||
} else if (store_flag_str.equals(CommonString.FROM_DEVIATION, ignoreCase = true)) {
|
||||
db?.open()
|
||||
listdat = db?.getCategoryPicturePogdata(
|
||||
date,
|
||||
categoryId,
|
||||
key_account_id,
|
||||
store_type_id,
|
||||
class_id,
|
||||
store_id,
|
||||
CommonString.TABLE_MAPPING_STOCK_ADHOC
|
||||
)
|
||||
} else {
|
||||
db?.open()
|
||||
listdat = db?.getCategoryPicturePogdata(
|
||||
date,
|
||||
categoryId,
|
||||
key_account_id,
|
||||
store_type_id,
|
||||
class_id,
|
||||
store_id,
|
||||
CommonString.TABLE_MAPPING_STOCK
|
||||
)
|
||||
}
|
||||
|
||||
Log.d("listdatsize", listdat?.size.toString())
|
||||
adapter = SubCatPdAdapter(
|
||||
category = categoryName,
|
||||
context = this,
|
||||
subcates = ArrayList(),
|
||||
btnlistener = object : SubCatPdAdapter.BtnClickListener {
|
||||
override fun onStartSessionClick(_pos: Int, data: CategoryPictureGetterSetter) {
|
||||
this@PD_Pog_Activity._pos = _pos
|
||||
launchCamera(data.subCatCode)
|
||||
Log.d("subCatCode", data.subCatCode)
|
||||
}
|
||||
})
|
||||
binding.rlContent.apply {
|
||||
recyclerViewSubCat.adapter = adapter
|
||||
recyclerViewSubCat.layoutManager = LinearLayoutManager(this@PD_Pog_Activity)
|
||||
adapter?.addsubCatItems(listdat)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
db?.open()
|
||||
if (!db!!.isSOSPogCategory(store_id, date, CommonString.KEY_COMPELETE, categoryId)) {
|
||||
db?.InsertPdPogImageData(date, store_id, categoryId, listdat, CommonString.KEY_DRAFT)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkAndRequestPermissions() {
|
||||
var read_phone_state = 0
|
||||
var write_storage = 0
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
write_storage =
|
||||
ContextCompat.checkSelfPermission(this, Manifest.permission.READ_MEDIA_IMAGES)
|
||||
} else {
|
||||
read_phone_state =
|
||||
ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE)
|
||||
write_storage =
|
||||
ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
}
|
||||
|
||||
val listPermissionsNeeded: MutableList<String> = java.util.ArrayList()
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
if (write_storage != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.READ_MEDIA_IMAGES)
|
||||
}
|
||||
} else {
|
||||
if (write_storage != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
}
|
||||
}
|
||||
|
||||
if (listPermissionsNeeded.isNotEmpty()) {
|
||||
ActivityCompat.requestPermissions(
|
||||
this,
|
||||
listPermissionsNeeded.toTypedArray<String>(),
|
||||
PERMISSION_ALL
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onRequestPermissionsResult(
|
||||
requestCode: Int,
|
||||
permissions: Array<String>,
|
||||
grantResults: IntArray
|
||||
) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
if (requestCode == PERMISSION_ALL) {
|
||||
val perms: MutableMap<String, Int> = HashMap()
|
||||
// Initialize the map with both permissions
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
perms[Manifest.permission.READ_MEDIA_IMAGES] = PackageManager.PERMISSION_GRANTED
|
||||
} else {
|
||||
perms[Manifest.permission.WRITE_EXTERNAL_STORAGE] =
|
||||
PackageManager.PERMISSION_GRANTED
|
||||
}
|
||||
// Fill with actual results from user
|
||||
if (grantResults.isNotEmpty()) {
|
||||
for (i in permissions.indices) perms[permissions[i]] = grantResults[i]
|
||||
// Check for both permissions//
|
||||
if (perms[Manifest.permission.READ_MEDIA_IMAGES] == PackageManager.PERMISSION_GRANTED &&
|
||||
perms[Manifest.permission.WRITE_EXTERNAL_STORAGE] == PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
Log.d("", "sms & location services permission granted")
|
||||
} else {
|
||||
Log.d("", "Some permissions are not granted ask again ")
|
||||
if (ActivityCompat.shouldShowRequestPermissionRationale(
|
||||
this,
|
||||
Manifest.permission.READ_MEDIA_IMAGES
|
||||
) ||
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(
|
||||
this,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
) {
|
||||
showDialogOK(
|
||||
"Photos or media Service Permission required for this app"
|
||||
) { _: DialogInterface?, which: Int ->
|
||||
when (which) {
|
||||
DialogInterface.BUTTON_POSITIVE -> checkAndRequestPermissions()
|
||||
DialogInterface.BUTTON_NEGATIVE -> {
|
||||
// proceed with logic by disabling the related features or quit the app.
|
||||
val startMain =
|
||||
Intent(Intent.ACTION_MAIN)
|
||||
startMain.addCategory(Intent.CATEGORY_HOME)
|
||||
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(startMain)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showDialogOK(message: String, okListener: DialogInterface.OnClickListener) {
|
||||
AlertDialog.Builder(this).setMessage(message).setPositiveButton("OK", okListener)
|
||||
.setNegativeButton("Cancel", okListener).create().show()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,331 @@
|
||||
package cpm.com.gskmtorange.dailyentry
|
||||
|
||||
import android.Manifest
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.SharedPreferences
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.preference.PreferenceManager
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.net.toUri
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.sj.camera_lib_android.Database.ReactPendingData
|
||||
import com.sj.camera_lib_android.Database.ReactSingleImage
|
||||
import com.sj.camera_lib_android.models.ImageUploadModel
|
||||
import com.sj.camera_lib_android.utils.CameraSDK
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB
|
||||
import cpm.com.gskmtorange.GetterSetter.CategoryPictureGetterSetter
|
||||
import cpm.com.gskmtorange.R
|
||||
import cpm.com.gskmtorange.adapter.RealtimeAdapter
|
||||
import cpm.com.gskmtorange.adapter.SubCatPdAdapter
|
||||
import cpm.com.gskmtorange.adapter.data.ImageUri
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions.savefile
|
||||
import cpm.com.gskmtorange.constant.CommonString
|
||||
import cpm.com.gskmtorange.constant.CommonUtils
|
||||
import cpm.com.gskmtorange.databinding.ActivityPdRealtimeReportBinding
|
||||
import cpm.com.gskmtorange.databinding.ActivityPdimageBinding
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
|
||||
class PD_Realtime_Report : AppCompatActivity() {
|
||||
private var context: Context? = null
|
||||
var categoryName: String? = null
|
||||
var categoryId: String? = null
|
||||
var store_id: String? = null;
|
||||
var date: String? = null;
|
||||
var lang: String? = null;
|
||||
var store_type_id: String? = null
|
||||
var class_id: String? = null
|
||||
var key_account_id: String? = null
|
||||
var country_id: String? = null
|
||||
var store_flag_str: String? = null
|
||||
private var preferences: SharedPreferences? = null
|
||||
var db: GSKOrangeDB? = null
|
||||
var listdat: ArrayList<CategoryPictureGetterSetter>? = ArrayList()
|
||||
var username: String? = ""
|
||||
private var kpi_name: String? = ""
|
||||
private lateinit var binding: ActivityPdRealtimeReportBinding
|
||||
private var adapter: RealtimeAdapter? = null
|
||||
val PERMISSION_ALL: Int = 99
|
||||
private var _pos = -1;
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityPdRealtimeReportBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
setSupportActionBar(binding.toolbar)
|
||||
context = this
|
||||
db = GSKOrangeDB(context)
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
db?.open()
|
||||
preferences?.let {
|
||||
lang = it.getString(CommonString.KEY_LANGUAGE, "")
|
||||
store_id = it.getString(CommonString.KEY_STORE_ID, "")
|
||||
username = it.getString(CommonString.KEY_USERNAME, "")
|
||||
store_type_id = it.getString(CommonString.KEY_STORETYPE_ID, "")
|
||||
class_id = it.getString(CommonString.KEY_CLASS_ID, "")
|
||||
key_account_id = it.getString(CommonString.KEY_KEYACCOUNT_ID, "")
|
||||
country_id = it.getString(CommonString.KEY_COUNTRY_ID, "")
|
||||
store_flag_str = it.getString(CommonString.KEY_STORE_FLAG, "")
|
||||
date = it.getString(CommonString.KEY_DATE, "")
|
||||
}
|
||||
|
||||
CommonFunctions.updateLangResources(
|
||||
context, preferences?.getString(CommonString.KEY_LANGUAGE, "")
|
||||
)
|
||||
intent?.let {
|
||||
categoryName = it.getStringExtra("categoryName")
|
||||
categoryId = it.getStringExtra("categoryId")
|
||||
kpi_name = it.getStringExtra("kpi_name")
|
||||
}
|
||||
supportActionBar?.apply {
|
||||
setHomeButtonEnabled(true)
|
||||
setDisplayHomeAsUpEnabled(true)
|
||||
title = kpi_name
|
||||
}
|
||||
preferences?.getString(CommonString.KEY_PD_PROJECT_Id, "")?.let { projectId ->
|
||||
val userId = preferences?.getString(CommonString.KEY_PD_USER_Id, "")
|
||||
.takeIf { !it.isNullOrBlank() } ?: username
|
||||
Log.d("pd_user_id",userId.toString());
|
||||
|
||||
CommonUtils.initializePDSDK(
|
||||
this@PD_Realtime_Report,
|
||||
projectId = projectId,
|
||||
_userId = userId
|
||||
)
|
||||
}
|
||||
|
||||
registerIntentFilter(
|
||||
listOf(
|
||||
"DataSaved", "did-receive-queue-data", "did-receive-image-upload-status"
|
||||
)
|
||||
)
|
||||
callAdapter()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
db?.open()
|
||||
}
|
||||
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
val id = item.itemId
|
||||
if (id == android.R.id.home) {
|
||||
//showDataLossAlert();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out)
|
||||
finish()
|
||||
}
|
||||
if (id == R.id.action_settings) {
|
||||
return true
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
LocalBroadcastManager.getInstance(this@PD_Realtime_Report)
|
||||
.unregisterReceiver(myBroadcastReceiver) // onDestroy
|
||||
}
|
||||
|
||||
private fun registerIntentFilter(filters: List<String> = listOf()) {
|
||||
filters.forEach { filter ->
|
||||
LocalBroadcastManager.getInstance(this@PD_Realtime_Report)
|
||||
.registerReceiver(myBroadcastReceiver, IntentFilter(filter))
|
||||
}
|
||||
}
|
||||
|
||||
private val savedImages = mutableListOf<ImageUri>()
|
||||
private var myBroadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
when (intent?.action) {
|
||||
"did-receive-queue-data" -> {
|
||||
val receivedList =
|
||||
intent.getParcelableArrayListExtra<ReactPendingData>("imageList")
|
||||
Log.d("DEBUG-LOG did-receive-queue-data", "$receivedList")
|
||||
if (receivedList.isNullOrEmpty()) {
|
||||
CameraSDK.uploadFailedImage(this@PD_Realtime_Report)
|
||||
}
|
||||
}
|
||||
|
||||
"did-receive-image-upload-status" -> {
|
||||
val receivedImage = intent.getParcelableExtra<ReactSingleImage>("image")
|
||||
Log.d("DEBUG-LOG did-receive-image-upload-status", "$receivedImage")
|
||||
}
|
||||
|
||||
"DataSaved" -> {
|
||||
val receivedList =
|
||||
intent.getParcelableArrayListExtra<ImageUploadModel>("imageListSaved")
|
||||
Log.d("DEBUG-LOG DataSaved", "$receivedList")
|
||||
receivedList?.let {
|
||||
savedImages.clear()
|
||||
it.forEach { item ->
|
||||
val dir = CommonString.getImagesFolder(context)
|
||||
val setName =
|
||||
store_id + "_" + username?.replace(".", "") + "_IRPDIMG-" + File(
|
||||
item.uri
|
||||
).getName()
|
||||
savedImages.add(ImageUri(uri = item.uri, modify_uri = setName))
|
||||
savefile(item.uri.toUri(), "$dir $setName")
|
||||
}
|
||||
adapter?.updateItem(position = _pos, savedImages)
|
||||
Log.e("savedImages", savedImages.toString())
|
||||
_pos = -1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun launchCamera(subCat_code: String) {
|
||||
val uploadFrom = "TestApp"
|
||||
val uploadParams = JSONObject(
|
||||
"""
|
||||
{
|
||||
"shop_id": 62475,
|
||||
"project_id": "4f57635b-6b07-45bf-bfba-c61c2826b6db",
|
||||
"td_version_id": 178,
|
||||
"shelf_image_id": null,
|
||||
"asset_image_id": null,
|
||||
"shelf_type": "Primary Shelf",
|
||||
"category_id": 123,
|
||||
"user_id": 133,
|
||||
"isConnected": true,
|
||||
"sn_image_type": "skus",
|
||||
"image_type": "multiple",
|
||||
"seq_no": 1,
|
||||
"level": 1,
|
||||
"uploadOnlyOnWifi": 0,
|
||||
"app_session_id": "8e2faa6b-d6fe-413a-a693-76a0cbe0ce71",
|
||||
"metadata": { "Device_Name": "Samsung" }
|
||||
}
|
||||
"""
|
||||
)
|
||||
uploadParams.put("shop_id", store_id)
|
||||
uploadParams.put("user_id", username)
|
||||
uploadParams.put("category_id", subCat_code)
|
||||
uploadParams.put("project_id", preferences?.getString(CommonString.KEY_PD_PROJECT_Id, ""))
|
||||
Log.d("uploadparamdata",uploadParams.toString());
|
||||
|
||||
|
||||
if(!lang.equals("ENGLISH",ignoreCase = true)){
|
||||
CameraSDK.startCamera(
|
||||
context = this,
|
||||
orientation = "",
|
||||
widthPercentage = 20,
|
||||
uploadParams = uploadParams,
|
||||
resolution = 3000,
|
||||
referenceUrl = "",
|
||||
allowBlurCheck = true,
|
||||
allowCrop = true,
|
||||
uploadFrom = uploadFrom,
|
||||
isRetake = false,
|
||||
showOverlapToggleButton = false,
|
||||
showGridLines = true,
|
||||
zoomLevel = 1.0,
|
||||
language_code = "ar",
|
||||
isLambda = false
|
||||
)
|
||||
}
|
||||
else{
|
||||
CameraSDK.startCamera(
|
||||
context = this,
|
||||
orientation = "",
|
||||
widthPercentage = 20,
|
||||
uploadParams = uploadParams,
|
||||
resolution = 3000,
|
||||
referenceUrl = "",
|
||||
allowBlurCheck = true,
|
||||
allowCrop = true,
|
||||
uploadFrom = uploadFrom,
|
||||
isRetake = false,
|
||||
showOverlapToggleButton = false,
|
||||
showGridLines = true,
|
||||
zoomLevel = 1.0,
|
||||
language_code = "en",
|
||||
isLambda = false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun callAdapter() {
|
||||
if (country_id == "8") {
|
||||
db?.open()
|
||||
listdat = db?.getCategoryPicturedata(
|
||||
date,
|
||||
categoryId,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
store_id,
|
||||
CommonString.TABLE_MAPPING_STOCK_STOREWISE
|
||||
)
|
||||
} else if (store_flag_str.equals(CommonString.FROM_DEVIATION, ignoreCase = true)) {
|
||||
db?.open()
|
||||
listdat = db?.getCategoryPicturedata(
|
||||
date,
|
||||
categoryId,
|
||||
key_account_id,
|
||||
store_type_id,
|
||||
class_id,
|
||||
store_id,
|
||||
CommonString.TABLE_MAPPING_STOCK_ADHOC
|
||||
)
|
||||
} else {
|
||||
db?.open()
|
||||
listdat = db?.getCategoryPicturedata(
|
||||
date,
|
||||
categoryId,
|
||||
key_account_id,
|
||||
store_type_id,
|
||||
class_id,
|
||||
store_id,
|
||||
CommonString.TABLE_MAPPING_STOCK
|
||||
)
|
||||
}
|
||||
adapter = RealtimeAdapter(
|
||||
category = categoryName,
|
||||
context = this,
|
||||
subcates = ArrayList(),
|
||||
btnlistener = object : RealtimeAdapter.BtnClickListener {
|
||||
override fun onStartSessionClick(_pos: Int, data: CategoryPictureGetterSetter) {
|
||||
this@PD_Realtime_Report._pos = _pos
|
||||
val intent = Intent(this@PD_Realtime_Report, PD_Realtime_Report_Detail::class.java)
|
||||
intent.putExtra("categoryName", categoryName)
|
||||
intent.putExtra("categoryId", categoryId)
|
||||
intent.putExtra("pd_subcat_code", data.subCatCode)
|
||||
intent.putExtra("subcat_name", data.suB_CATEGORY)
|
||||
intent.putExtra("kpi_name", "IR Realtime Report")
|
||||
startActivity(intent)
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out)
|
||||
// launchCamera(data.subCatCode)
|
||||
// Log.d("subCatCode", data.subCatCode)
|
||||
}
|
||||
})
|
||||
binding.rlContent.apply {
|
||||
recyclerViewSubCat.adapter = adapter
|
||||
recyclerViewSubCat.layoutManager = LinearLayoutManager(this@PD_Realtime_Report)
|
||||
adapter?.addsubCatItems(listdat)
|
||||
}
|
||||
}
|
||||
}
|
||||
+281
@@ -0,0 +1,281 @@
|
||||
package cpm.com.gskmtorange.dailyentry
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.NetworkCapabilities
|
||||
import android.os.Bundle
|
||||
import android.preference.PreferenceManager
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.squareup.okhttp.Callback
|
||||
import com.squareup.okhttp.HttpUrl
|
||||
import com.squareup.okhttp.OkHttpClient
|
||||
import com.squareup.okhttp.Request
|
||||
import com.squareup.okhttp.Response
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB
|
||||
import cpm.com.gskmtorange.GetterSetter.CategoryPictureGetterSetter
|
||||
import cpm.com.gskmtorange.adapter.ScoreAdapter
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions
|
||||
import cpm.com.gskmtorange.constant.CommonString
|
||||
import cpm.com.gskmtorange.databinding.ActivityPdRealtimeReportDetailBinding
|
||||
import cpm.com.gskmtorange.utils.ScoreItem
|
||||
import org.json.JSONObject
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
class PD_Realtime_Report_Detail : AppCompatActivity() {
|
||||
private var context: Context? = null
|
||||
var categoryName: String? = null
|
||||
var categoryId: String? = null
|
||||
var store_id: String? = null;
|
||||
var date: String? = null;
|
||||
var lang: String? = null;
|
||||
var store_type_id: String? = null
|
||||
var class_id: String? = null
|
||||
var key_account_id: String? = null
|
||||
var country_id: String? = null
|
||||
var pd_categoryId: String? = null
|
||||
var subcat_name: String? = null
|
||||
var store_flag_str: String? = null
|
||||
private var preferences: SharedPreferences? = null
|
||||
var db: GSKOrangeDB? = null
|
||||
var listdat: ArrayList<CategoryPictureGetterSetter>? = ArrayList()
|
||||
var username: String? = ""
|
||||
private var kpi_name: String? = ""
|
||||
private lateinit var binding: ActivityPdRealtimeReportDetailBinding
|
||||
val PERMISSION_ALL: Int = 99
|
||||
private var _pos = -1;
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityPdRealtimeReportDetailBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
setSupportActionBar(binding.toolbar)
|
||||
context = this
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
preferences?.let {
|
||||
lang = it.getString(CommonString.KEY_LANGUAGE, "")
|
||||
store_id = it.getString(CommonString.KEY_STORE_ID, "")
|
||||
username = it.getString(CommonString.KEY_USERNAME, "")
|
||||
store_type_id = it.getString(CommonString.KEY_STORETYPE_ID, "")
|
||||
class_id = it.getString(CommonString.KEY_CLASS_ID, "")
|
||||
key_account_id = it.getString(CommonString.KEY_KEYACCOUNT_ID, "")
|
||||
country_id = it.getString(CommonString.KEY_COUNTRY_ID, "")
|
||||
store_flag_str = it.getString(CommonString.KEY_STORE_FLAG, "")
|
||||
date = it.getString(CommonString.KEY_DATE, "")
|
||||
}
|
||||
CommonFunctions.updateLangResources(
|
||||
context, preferences?.getString(CommonString.KEY_LANGUAGE, "")
|
||||
)
|
||||
intent?.let {
|
||||
categoryName = it.getStringExtra("categoryName")
|
||||
categoryId = it.getStringExtra("categoryId")
|
||||
kpi_name = it.getStringExtra("kpi_name")
|
||||
pd_categoryId = it.getStringExtra("pd_subcat_code")
|
||||
subcat_name = it.getStringExtra("subcat_name")
|
||||
Log.d("pdcode",pd_categoryId.toString())
|
||||
}
|
||||
supportActionBar?.apply {
|
||||
setHomeButtonEnabled(true)
|
||||
setDisplayHomeAsUpEnabled(true)
|
||||
title = kpi_name
|
||||
}
|
||||
preferences?.getString(CommonString.KEY_PD_PROJECT_Id, "")?.let { projectId ->
|
||||
val userId = preferences?.getString(CommonString.KEY_PD_USER_Id, "")
|
||||
.takeIf { !it.isNullOrBlank() } ?: username
|
||||
Log.d("pd_user_id", userId.toString());
|
||||
|
||||
}
|
||||
if (isNetworkAvailable(this@PD_Realtime_Report_Detail)) {
|
||||
fetchlivedata()
|
||||
} else {
|
||||
Toast.makeText(this, "No internet connection", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun fetchlivedata() {
|
||||
Log.d("apidata",date +","+store_id+","+pd_categoryId+","+preferences?.getString(CommonString.KEY_PD_PROJECT_Id, ""))
|
||||
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
binding.progressBar.visibility = View.VISIBLE
|
||||
binding.recyclerView.visibility = View.GONE
|
||||
}
|
||||
|
||||
val client = OkHttpClient()
|
||||
val formattedDate = formatDate(date)
|
||||
val urlBuilder = HttpUrl.Builder()
|
||||
.scheme("https")
|
||||
.host("apis.shelfwatch.io")
|
||||
.addPathSegment("get_haleon_insights")
|
||||
.addQueryParameter("visit_date", formattedDate)
|
||||
.addQueryParameter("store_id", store_id)
|
||||
.addQueryParameter("category_id", pd_categoryId)
|
||||
.addQueryParameter("project_id", preferences?.getString(CommonString.KEY_PD_PROJECT_Id, ""))
|
||||
|
||||
val request = Request.Builder()
|
||||
.url(urlBuilder.build())
|
||||
.build()
|
||||
Log.d("apiparams",request.toString() + ","+urlBuilder)
|
||||
|
||||
client.newCall(request).enqueue(object : Callback {
|
||||
override fun onFailure(request: Request?, e: java.io.IOException?) {
|
||||
Log.e("RealtimeReport", "API call failed", e)
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
binding.progressBar.visibility = View.GONE
|
||||
binding.recyclerView.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResponse(response: Response?) {
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
binding.progressBar.visibility = View.GONE
|
||||
binding.recyclerView.visibility = View.VISIBLE
|
||||
}
|
||||
val responseData = response?.body()?.string()
|
||||
Log.d("responsedata", responseData.toString())
|
||||
|
||||
responseData?.let { jsonStr ->
|
||||
try {
|
||||
val json = JSONObject(jsonStr)
|
||||
val output = json.getJSONObject("output")
|
||||
val report = output.getJSONObject("report")
|
||||
val overallArray = report.getJSONArray("overall")
|
||||
val imagelist = output.getJSONArray("images")
|
||||
|
||||
var osa = "0%"
|
||||
var msl = "0%"
|
||||
var posm = "0%"
|
||||
var sosSku = "0%"
|
||||
var sosBrand = "0%"
|
||||
|
||||
for (i in 0 until overallArray.length()) {
|
||||
val obj = overallArray.getJSONObject(i)
|
||||
when (obj.getString("kpi_name")) {
|
||||
"OSA" -> osa = obj.getString("value")
|
||||
"MSL OSA" -> msl = obj.getString("value")
|
||||
"POSM" -> posm = obj.getString("value")
|
||||
"SOS - SKU Level" -> sosSku = obj.getString("value")
|
||||
"SOS - Brand Level" -> sosBrand = obj.getString("value")
|
||||
}
|
||||
}
|
||||
|
||||
// Build OverallScore
|
||||
val scoreItems = mutableListOf<ScoreItem>()
|
||||
scoreItems.add(
|
||||
ScoreItem.OverallScore(
|
||||
osa = osa,
|
||||
msl = msl,
|
||||
posm = posm,
|
||||
sosSku = sosSku,
|
||||
sosBrand = sosBrand
|
||||
)
|
||||
)
|
||||
|
||||
// ===== Brand Details for "Toothpaste" =====
|
||||
val detailedArray = report.getJSONArray("detailed")
|
||||
var brandDetails: List<Pair<String, String>> = emptyList()
|
||||
|
||||
for (i in 0 until detailedArray.length()) {
|
||||
val detail = detailedArray.getJSONObject(i)
|
||||
if (detail.getString("kpi_name") == "SOS - Brand Level") {
|
||||
val dataArray = detail.getJSONArray("data")
|
||||
val brands = mutableListOf<Pair<String, String>>()
|
||||
for (j in 0 until dataArray.length()) {
|
||||
val brandObj = dataArray.getJSONObject(j)
|
||||
val brandName = brandObj.optString("brand_name", "Unknown")
|
||||
val value = brandObj.getString("value")
|
||||
if (brandName.isNotEmpty() && brandName != "null") {
|
||||
brands.add(brandName to value)
|
||||
}
|
||||
}
|
||||
brandDetails = brands
|
||||
}
|
||||
}
|
||||
|
||||
scoreItems.add(
|
||||
ScoreItem.CategoryScore(
|
||||
categoryName = subcat_name.toString(),
|
||||
msl = msl,
|
||||
posm = posm,
|
||||
sosSku = sosSku,
|
||||
sosBrand = sosBrand,
|
||||
brandDetails = brandDetails
|
||||
)
|
||||
)
|
||||
|
||||
// ===== IMAGE ITEMS =====
|
||||
if (imagelist.length()>0) {
|
||||
for (i in 0 until imagelist.length()) {
|
||||
val imgObj = imagelist.getJSONObject(i)
|
||||
val rawImages = imgObj.getJSONArray("raw_images")
|
||||
for (j in 0 until rawImages.length()) {
|
||||
val imgObjnew = rawImages.getJSONObject(j)
|
||||
val url = imgObjnew.getString("url")
|
||||
Log.d("imgurl",url);
|
||||
scoreItems.add(ScoreItem.ImageItem(url))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update UI on main thread
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
binding.recyclerView.layoutManager = LinearLayoutManager(context)
|
||||
binding.recyclerView.adapter = ScoreAdapter(scoreItems)
|
||||
}
|
||||
|
||||
} catch (e: Exception) {
|
||||
Log.e("RealtimeReport", "Parse error", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun formatDate(inputDate: String?): String {
|
||||
return try {
|
||||
// Parse input date (from "MM/dd/yyyy")
|
||||
val inputFormat = SimpleDateFormat("MM/dd/yyyy", Locale.US)
|
||||
val date = inputFormat.parse(inputDate ?: "")
|
||||
|
||||
// Format to "yyyy-MM-dd" for API, using Locale.US to avoid locale-specific digits
|
||||
val outputFormat = SimpleDateFormat("yyyy-MM-dd", Locale.US)
|
||||
if (date != null) outputFormat.format(date) else ""
|
||||
} catch (e: Exception) {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
// Finish the current activity and go back
|
||||
finish()
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
fun isNetworkAvailable(context: Context): Boolean {
|
||||
val connectivityManager =
|
||||
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
|
||||
val network = connectivityManager.activeNetwork ?: return false
|
||||
val activeNetwork = connectivityManager.getNetworkCapabilities(network) ?: return false
|
||||
|
||||
return when {
|
||||
activeNetwork.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true
|
||||
activeNetwork.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true
|
||||
activeNetwork.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +1,19 @@
|
||||
package cpm.com.gskmtorange.dailyentry
|
||||
|
||||
import android.Manifest
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.SharedPreferences
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.NetworkCapabilities
|
||||
import android.os.Bundle
|
||||
import android.preference.PreferenceManager
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.net.toUri
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
@@ -47,6 +44,7 @@ class PDimageActivity : AppCompatActivity() {
|
||||
var categoryId: String? = null
|
||||
var store_id: String? = null;
|
||||
var date: String? = null;
|
||||
var lang: String? = null;
|
||||
var store_type_id: String? = null
|
||||
var class_id: String? = null
|
||||
var key_account_id: String? = null
|
||||
@@ -61,6 +59,8 @@ class PDimageActivity : AppCompatActivity() {
|
||||
private var adapter: SubCatPdAdapter? = null
|
||||
val PERMISSION_ALL: Int = 99
|
||||
private var _pos = -1;
|
||||
var devicename : String? = ""
|
||||
var store_name : String? = ""
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -72,7 +72,9 @@ class PDimageActivity : AppCompatActivity() {
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
db?.open()
|
||||
preferences?.let {
|
||||
lang = it.getString(CommonString.KEY_LANGUAGE, "")
|
||||
store_id = it.getString(CommonString.KEY_STORE_ID, "")
|
||||
store_name = it.getString(CommonString.KEY_STORE_NAME, "")
|
||||
username = it.getString(CommonString.KEY_USERNAME, "")
|
||||
store_type_id = it.getString(CommonString.KEY_STORETYPE_ID, "")
|
||||
class_id = it.getString(CommonString.KEY_CLASS_ID, "")
|
||||
@@ -81,6 +83,8 @@ class PDimageActivity : AppCompatActivity() {
|
||||
store_flag_str = it.getString(CommonString.KEY_STORE_FLAG, "")
|
||||
date = it.getString(CommonString.KEY_DATE, "")
|
||||
}
|
||||
devicename = android.os.Build.MANUFACTURER
|
||||
Log.d("device_name",devicename.toString())
|
||||
|
||||
CommonFunctions.updateLangResources(
|
||||
context, preferences?.getString(CommonString.KEY_LANGUAGE, "")
|
||||
@@ -98,6 +102,7 @@ class PDimageActivity : AppCompatActivity() {
|
||||
preferences?.getString(CommonString.KEY_PD_PROJECT_Id, "")?.let { projectId ->
|
||||
val userId = preferences?.getString(CommonString.KEY_PD_USER_Id, "")
|
||||
.takeIf { !it.isNullOrBlank() } ?: username
|
||||
Log.d("pd_user_id",userId.toString());
|
||||
|
||||
CommonUtils.initializePDSDK(
|
||||
this@PDimageActivity,
|
||||
@@ -135,6 +140,12 @@ class PDimageActivity : AppCompatActivity() {
|
||||
).setAction("Action", null).show()
|
||||
lifecycleScope.launch {
|
||||
delay(3000) // 3 seconds delay
|
||||
val intent = Intent(this@PDimageActivity, PD_Realtime_Report::class.java)
|
||||
intent.putExtra("categoryName", categoryName)
|
||||
intent.putExtra("categoryId", categoryId)
|
||||
intent.putExtra("kpi_name", "IR Realtime Analytics")
|
||||
startActivity(intent)
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out)
|
||||
finish()
|
||||
}
|
||||
} else {
|
||||
@@ -154,9 +165,8 @@ class PDimageActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
callAdapter()
|
||||
checkAndRequestPermissions()
|
||||
// checkAndRequestPermissions()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
@@ -182,7 +192,6 @@ class PDimageActivity : AppCompatActivity() {
|
||||
return checkFlag // Correctly return validation result
|
||||
}
|
||||
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
val id = item.itemId
|
||||
@@ -194,7 +203,6 @@ class PDimageActivity : AppCompatActivity() {
|
||||
if (id == R.id.action_settings) {
|
||||
return true
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
@@ -259,6 +267,7 @@ class PDimageActivity : AppCompatActivity() {
|
||||
"""
|
||||
{
|
||||
"shop_id": 62475,
|
||||
"store_name": "abc",
|
||||
"project_id": "4f57635b-6b07-45bf-bfba-c61c2826b6db",
|
||||
"td_version_id": 178,
|
||||
"shelf_image_id": null,
|
||||
@@ -273,32 +282,56 @@ class PDimageActivity : AppCompatActivity() {
|
||||
"level": 1,
|
||||
"uploadOnlyOnWifi": 0,
|
||||
"app_session_id": "8e2faa6b-d6fe-413a-a693-76a0cbe0ce71",
|
||||
"metadata": { "Device_Name": "Samsung" }
|
||||
"metadata": { "Device_Name": $devicename,"User_name": $username }
|
||||
}
|
||||
"""
|
||||
)
|
||||
// "metadata": { "Device_Name": $devicename,"Username": $username }
|
||||
uploadParams.put("store_name", store_name)
|
||||
uploadParams.put("shop_id", store_id)
|
||||
uploadParams.put("user_id", username)
|
||||
uploadParams.put("category_id", subCat_code)
|
||||
uploadParams.put("project_id", preferences?.getString(CommonString.KEY_PD_PROJECT_Id, ""))
|
||||
Log.d("uploadparamdata",uploadParams.toString());
|
||||
|
||||
CameraSDK.startCamera(
|
||||
context = this,
|
||||
orientation = "",
|
||||
widthPercentage = 20,
|
||||
uploadParams = uploadParams,
|
||||
resolution = 3000,
|
||||
referenceUrl = "",
|
||||
allowBlurCheck = true,
|
||||
allowCrop = true,
|
||||
uploadFrom = uploadFrom,
|
||||
isRetake = false,
|
||||
showOverlapToggleButton = false,
|
||||
showGridLines = true,
|
||||
zoomLevel = 1.0,
|
||||
language_code = "en",
|
||||
isLambda = false
|
||||
)
|
||||
if(!lang.equals("ENGLISH",ignoreCase = true)){
|
||||
CameraSDK.startCamera(
|
||||
context = this,
|
||||
orientation = "",
|
||||
widthPercentage = 20,
|
||||
uploadParams = uploadParams,
|
||||
resolution = 3000,
|
||||
referenceUrl = "",
|
||||
allowBlurCheck = true,
|
||||
allowCrop = true,
|
||||
uploadFrom = uploadFrom,
|
||||
isRetake = false,
|
||||
showOverlapToggleButton = false,
|
||||
showGridLines = true,
|
||||
zoomLevel = 1.0,
|
||||
language_code = "ar",
|
||||
isLambda = false
|
||||
)
|
||||
}
|
||||
else{
|
||||
CameraSDK.startCamera(
|
||||
context = this,
|
||||
orientation = "",
|
||||
widthPercentage = 20,
|
||||
uploadParams = uploadParams,
|
||||
resolution = 3000,
|
||||
referenceUrl = "",
|
||||
allowBlurCheck = true,
|
||||
allowCrop = true,
|
||||
uploadFrom = uploadFrom,
|
||||
isRetake = false,
|
||||
showOverlapToggleButton = false,
|
||||
showGridLines = true,
|
||||
zoomLevel = 1.0,
|
||||
language_code = "en",
|
||||
isLambda = false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun callAdapter() {
|
||||
@@ -337,7 +370,7 @@ class PDimageActivity : AppCompatActivity() {
|
||||
)
|
||||
}
|
||||
|
||||
Log.d("listdatsize", listdat?.size.toString())
|
||||
// Log.d("listdatsize", listdat?.size.toString())
|
||||
adapter = SubCatPdAdapter(
|
||||
category = categoryName,
|
||||
context = this,
|
||||
@@ -345,8 +378,23 @@ class PDimageActivity : AppCompatActivity() {
|
||||
btnlistener = object : SubCatPdAdapter.BtnClickListener {
|
||||
override fun onStartSessionClick(_pos: Int, data: CategoryPictureGetterSetter) {
|
||||
this@PDimageActivity._pos = _pos
|
||||
/* val intent = Intent(this@PDimageActivity, PD_Realtime_Report::class.java)
|
||||
intent.putExtra("categoryName", categoryName)
|
||||
intent.putExtra("categoryId", categoryId)
|
||||
intent.putExtra("kpi_name", "IR Realtime Analytics")
|
||||
startActivity(intent)
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out)*/
|
||||
|
||||
// launchCamera(data.subCatCode)
|
||||
/* if (isNetworkAvailable(this@PDimageActivity)) {
|
||||
launchCamera(data.subCatCode)
|
||||
}
|
||||
else {
|
||||
Toast.makeText(context, "No internet connection", Toast.LENGTH_SHORT).show()
|
||||
}*/
|
||||
launchCamera(data.subCatCode)
|
||||
Log.d("subCatCode", data.subCatCode)
|
||||
|
||||
// Log.d("subCatCode", data.subCatCode)
|
||||
}
|
||||
})
|
||||
binding.rlContent.apply {
|
||||
@@ -364,98 +412,18 @@ class PDimageActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkAndRequestPermissions() {
|
||||
var read_phone_state = 0
|
||||
var write_storage = 0
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
write_storage =
|
||||
ContextCompat.checkSelfPermission(this, Manifest.permission.READ_MEDIA_IMAGES)
|
||||
} else {
|
||||
read_phone_state =
|
||||
ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE)
|
||||
write_storage =
|
||||
ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
fun isNetworkAvailable(context: Context): Boolean {
|
||||
val connectivityManager =
|
||||
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
|
||||
val network = connectivityManager.activeNetwork ?: return false
|
||||
val activeNetwork = connectivityManager.getNetworkCapabilities(network) ?: return false
|
||||
|
||||
return when {
|
||||
activeNetwork.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true
|
||||
activeNetwork.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true
|
||||
activeNetwork.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
val listPermissionsNeeded: MutableList<String> = java.util.ArrayList()
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
if (write_storage != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.READ_MEDIA_IMAGES)
|
||||
}
|
||||
} else {
|
||||
if (write_storage != PackageManager.PERMISSION_GRANTED) {
|
||||
listPermissionsNeeded.add(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
}
|
||||
}
|
||||
|
||||
if (listPermissionsNeeded.isNotEmpty()) {
|
||||
ActivityCompat.requestPermissions(
|
||||
this,
|
||||
listPermissionsNeeded.toTypedArray<String>(),
|
||||
PERMISSION_ALL
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onRequestPermissionsResult(
|
||||
requestCode: Int,
|
||||
permissions: Array<String>,
|
||||
grantResults: IntArray
|
||||
) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
if (requestCode == PERMISSION_ALL) {
|
||||
val perms: MutableMap<String, Int> = HashMap()
|
||||
// Initialize the map with both permissions
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
perms[Manifest.permission.READ_MEDIA_IMAGES] = PackageManager.PERMISSION_GRANTED
|
||||
} else {
|
||||
perms[Manifest.permission.WRITE_EXTERNAL_STORAGE] =
|
||||
PackageManager.PERMISSION_GRANTED
|
||||
}
|
||||
// Fill with actual results from user
|
||||
if (grantResults.isNotEmpty()) {
|
||||
for (i in permissions.indices) perms[permissions[i]] = grantResults[i]
|
||||
// Check for both permissions//
|
||||
if (perms[Manifest.permission.READ_MEDIA_IMAGES] == PackageManager.PERMISSION_GRANTED &&
|
||||
perms[Manifest.permission.WRITE_EXTERNAL_STORAGE] == PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
Log.d("", "sms & location services permission granted")
|
||||
} else {
|
||||
Log.d("", "Some permissions are not granted ask again ")
|
||||
if (ActivityCompat.shouldShowRequestPermissionRationale(
|
||||
this,
|
||||
Manifest.permission.READ_MEDIA_IMAGES
|
||||
) ||
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(
|
||||
this,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
) {
|
||||
showDialogOK(
|
||||
"Photos or media Service Permission required for this app"
|
||||
) { _: DialogInterface?, which: Int ->
|
||||
when (which) {
|
||||
DialogInterface.BUTTON_POSITIVE -> checkAndRequestPermissions()
|
||||
DialogInterface.BUTTON_NEGATIVE -> {
|
||||
// proceed with logic by disabling the related features or quit the app.
|
||||
val startMain =
|
||||
Intent(Intent.ACTION_MAIN)
|
||||
startMain.addCategory(Intent.CATEGORY_HOME)
|
||||
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(startMain)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showDialogOK(message: String, okListener: DialogInterface.OnClickListener) {
|
||||
AlertDialog.Builder(this).setMessage(message).setPositiveButton("OK", okListener)
|
||||
.setNegativeButton("Cancel", okListener).create().show()
|
||||
}
|
||||
}
|
||||
@@ -118,32 +118,10 @@ public class POGQuestionsActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (validateData()) {
|
||||
|
||||
db.savePOGQuestionAnswerData(hashMapListChildData, headerDataList, store_id, categoryId);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
|
||||
/* AlertDialog.Builder builder = new AlertDialog.Builder(POGQuestionsActivity.this);
|
||||
builder.setMessage(R.string.title_activity_Want_save)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
db.savePOGQuestionAnswerData(hashMapListChildData, headerDataList,store_id, categoryId);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();*/
|
||||
|
||||
} else {
|
||||
|
||||
if(adapter!=null){
|
||||
adapter.notifyDataSetChanged();
|
||||
expandableListView.invalidateViews();
|
||||
|
||||
@@ -500,7 +500,7 @@ public class StoreListActivity extends AppCompatActivity implements GoogleApiCli
|
||||
for (Location location : locationResult.getLocations()) {
|
||||
lat = location.getLatitude();
|
||||
lon = location.getLongitude();
|
||||
// Log.e("latitude_inside",location.getLatitude() + "," +location.getLongitude());
|
||||
Log.e("latitude_inside",location.getLatitude() + "," +location.getLongitude());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -597,6 +597,7 @@ public class StoreListActivity extends AppCompatActivity implements GoogleApiCli
|
||||
|
||||
} else if (id == R.id.iconMap) {
|
||||
|
||||
Log.d("Mapdata", "latitude is :" +" " +lat + "," + lon);
|
||||
Intent in = new Intent(context, StoreListRouteActivity.class);
|
||||
in.putExtra(CommonString.KEY_STORE_LIST, storelist);
|
||||
startActivity(in);
|
||||
@@ -899,6 +900,7 @@ public class StoreListActivity extends AppCompatActivity implements GoogleApiCli
|
||||
viewHolder.imgview_navigation.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Log.e("mapdata",lat + ","+lon);
|
||||
Intent in = new Intent(context, StoreRouteActivity.class);
|
||||
in.putExtra(CommonString.KEY_STORE_LIST, current);
|
||||
startActivity(in);
|
||||
@@ -1466,7 +1468,6 @@ public class StoreListActivity extends AppCompatActivity implements GoogleApiCli
|
||||
} else {
|
||||
// return "MAPPING_STOCK";
|
||||
}
|
||||
|
||||
}
|
||||
publishProgress(data);
|
||||
|
||||
|
||||
@@ -303,33 +303,6 @@ public class StoreimageActivity extends AppCompatActivity implements View.OnClic
|
||||
@Override
|
||||
public void onConnected(Bundle bundle) {
|
||||
|
||||
/*if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
// TODO: Consider calling
|
||||
// ActivityCompat#requestPermissions
|
||||
// here to request the missing permissions, and then overriding
|
||||
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
|
||||
// int[] grantResults)
|
||||
// to handle the case where the user grants the permission. See the documentation
|
||||
// for ActivityCompat#requestPermissions for more details.
|
||||
return;
|
||||
}
|
||||
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
|
||||
@@ -359,10 +332,11 @@ public class StoreimageActivity extends AppCompatActivity implements View.OnClic
|
||||
|
||||
@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.
|
||||
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()) {
|
||||
/* if (mGoogleApiClient.isConnected()) {
|
||||
mGoogleApiClient.disconnect();
|
||||
}*/
|
||||
// ATTENTION: This was auto-generated to implement the App Indexing API.
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
package cpm.com.gskmtorange.dailyentry
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.os.Message
|
||||
import android.util.Log
|
||||
import android.view.ViewGroup
|
||||
import android.webkit.*
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import cpm.com.gskmtorange.databinding.ActivityWebviewBinding
|
||||
class WebViewActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityWebviewBinding
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityWebviewBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
val url = intent.getStringExtra("url") ?: ""
|
||||
// Configure WebView settings
|
||||
with(binding.webView.settings) {
|
||||
javaScriptEnabled = true
|
||||
domStorageEnabled = true
|
||||
javaScriptCanOpenWindowsAutomatically = true
|
||||
setSupportMultipleWindows(true)
|
||||
loadWithOverviewMode = true
|
||||
useWideViewPort = true
|
||||
mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
|
||||
// ✅ Force desktop mode by dynamically modifying user-agent
|
||||
val defaultUA = WebSettings.getDefaultUserAgent(this@WebViewActivity)
|
||||
val desktopUA = defaultUA.replace("Mobile", "").replace("Android", "").trim()
|
||||
userAgentString = desktopUA
|
||||
Log.d("UserAgent", "Final User-Agent: $desktopUA")
|
||||
}
|
||||
|
||||
// Keep navigation inside WebView
|
||||
binding.webView.webViewClient = object : WebViewClient() {
|
||||
override fun shouldOverrideUrlLoading(
|
||||
view: WebView?,
|
||||
request: WebResourceRequest?
|
||||
): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onPageFinished(view: WebView?, url: String?) {
|
||||
super.onPageFinished(view, url)
|
||||
// Inject JS to simulate mouseover/mouseenter on tap
|
||||
view?.evaluateJavascript(
|
||||
"""
|
||||
(function() {
|
||||
function findAncestorWithAttr(el, attr) {
|
||||
while (el && el !== document.body) {
|
||||
if (el.hasAttribute && el.hasAttribute(attr)) {
|
||||
return el;
|
||||
}
|
||||
el = el.parentElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
document.addEventListener('touchend', function(e) {
|
||||
var point = e.changedTouches[0];
|
||||
var el = document.elementFromPoint(point.clientX, point.clientY);
|
||||
var target = findAncestorWithAttr(el, 'data-annotation-id') || el;
|
||||
|
||||
console.log('Touch at element:', target.getAttribute('data-annotation-id') || target.className);
|
||||
|
||||
function dispatchMouseEvent(type) {
|
||||
var event = new MouseEvent(type, {
|
||||
view: window,
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
clientX: point.clientX,
|
||||
clientY: point.clientY
|
||||
});
|
||||
target.dispatchEvent(event);
|
||||
}
|
||||
|
||||
dispatchMouseEvent('mouseover');
|
||||
dispatchMouseEvent('mouseenter');
|
||||
dispatchMouseEvent('mousemove');
|
||||
target.click();
|
||||
});
|
||||
})();
|
||||
""".trimIndent(), null
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Handle JS dialogs, popups, and log console messages
|
||||
binding.webView.webChromeClient = object : WebChromeClient() {
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
override fun onCreateWindow(
|
||||
view: WebView?,
|
||||
isDialog: Boolean,
|
||||
isUserGesture: Boolean,
|
||||
resultMsg: Message?
|
||||
): Boolean {
|
||||
val popupWebView = WebView(this@WebViewActivity)
|
||||
popupWebView.settings.javaScriptEnabled = true
|
||||
popupWebView.settings.domStorageEnabled = true
|
||||
|
||||
val dialog = Dialog(this@WebViewActivity)
|
||||
dialog.setContentView(popupWebView)
|
||||
dialog.window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
||||
dialog.show()
|
||||
|
||||
popupWebView.webViewClient = object : WebViewClient() {
|
||||
override fun onPageFinished(view: WebView?, url: String?) {
|
||||
super.onPageFinished(view, url)
|
||||
}
|
||||
}
|
||||
|
||||
val transport = resultMsg?.obj as WebView.WebViewTransport
|
||||
transport.webView = popupWebView
|
||||
resultMsg.sendToTarget()
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Load URL
|
||||
binding.webView.loadUrl(url)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
@@ -14,9 +13,9 @@ import android.util.Log;
|
||||
import android.view.Window;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import org.ksoap2.SoapEnvelope;
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||
@@ -24,7 +23,6 @@ import org.ksoap2.transport.HttpTransportSE;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -36,11 +34,11 @@ import java.net.MalformedURLException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import cpm.com.gskmtorange.Database.GSKOrangeDB;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonFunctions;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
import cpm.com.gskmtorange.utils.TLSSocketFactory;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.ADDITIONAL_DISPLAY_MASTERGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.AdditionalQuestiongetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.BrandMasterGetterSetter;
|
||||
@@ -83,6 +81,11 @@ import cpm.com.gskmtorange.xmlGetterSetter.SupervisorListGetterSetter;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.TableBean;
|
||||
import cpm.com.gskmtorange.xmlGetterSetter.Visit_Type_Master_GetterSetter;
|
||||
import cpm.com.gskmtorange.xmlHandlers.XMLHandlers;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
||||
public class DownloadActivity extends AppCompatActivity {
|
||||
private Context context;
|
||||
@@ -136,7 +139,6 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
Order_Received_Status_GetterSetter order_received_status_getterSetter;
|
||||
Visit_Type_Master_GetterSetter visit_type_master_getterSetter;
|
||||
|
||||
|
||||
private Dialog dialog;
|
||||
private ProgressBar pb;
|
||||
private TextView percentage, message;
|
||||
@@ -149,22 +151,51 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_download);
|
||||
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
db = new GSKOrangeDB(this);
|
||||
context = this;
|
||||
// ✅ Enable old TLS versions for SOAP
|
||||
//enableOldTLS();
|
||||
// checkTLSVersion();
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
|
||||
userId = preferences.getString(CommonString.KEY_USERNAME, null);
|
||||
culture_id = preferences.getString(CommonString.KEY_CULTURE_ID, "");
|
||||
country_id = preferences.getString(CommonString.KEY_COUNTRY_ID, null);
|
||||
|
||||
new UploadTask(DownloadActivity.this).execute();
|
||||
}
|
||||
|
||||
private void checkTLSVersion() {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
String host = "gskme2.parinaam.in";
|
||||
int port = 443;
|
||||
|
||||
// Create SSL context with default settings
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, null, null);
|
||||
|
||||
SSLSocketFactory factory = sslContext.getSocketFactory();
|
||||
|
||||
try (SSLSocket sslSocket = (SSLSocket) factory.createSocket(host, port)) {
|
||||
sslSocket.startHandshake(); // do handshake
|
||||
|
||||
SSLSession session = sslSocket.getSession();
|
||||
Log.d("TLS_CHECK", "Protocol: " + session.getProtocol());
|
||||
runOnUiThread(() ->
|
||||
Toast.makeText(this, "protocol: " + session.getProtocol(), Toast.LENGTH_SHORT).show()
|
||||
);
|
||||
Log.d("TLS_CHECK", "CipherSuite: " + session.getCipherSuite());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e("TLS_CHECK", "Error checking TLS", e);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
class Data {
|
||||
int value;
|
||||
@@ -194,6 +225,7 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(Void... voids) {
|
||||
try {
|
||||
@@ -221,23 +253,21 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
HttpTransportSE androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
// HttpTransportSE androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
Log.d("requestdata",request.toString());
|
||||
|
||||
Object result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
/* if (androidHttpTransport.responseDump != null) {
|
||||
Log.e("SOAP_RESPONSE", androidHttpTransport.responseDump);
|
||||
} else {
|
||||
Log.e("SOAP_RESPONSE", "No response received");
|
||||
}*/
|
||||
Object 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();
|
||||
|
||||
jcpgettersetter = XMLHandlers.JCPXMLHandler(xpp, eventType);
|
||||
|
||||
String jcpTable = jcpgettersetter.getTable_journey_plan();
|
||||
if (jcpTable != null)
|
||||
TableBean.setJourneyPlan(jcpTable);
|
||||
@@ -248,7 +278,6 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
//return "JOURNEY_PLAN";
|
||||
no_jcp_flag = true;
|
||||
}
|
||||
|
||||
data.value = 10;
|
||||
data.name = "JCP " + getResources().getString(R.string.download_data);
|
||||
}
|
||||
@@ -267,13 +296,9 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
Log.d("resultdata",result.toString());
|
||||
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();
|
||||
|
||||
@@ -291,9 +316,6 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
data.name = "ADHOC JOURNEYPLAN " + getResources().getString(R.string.download_data);
|
||||
} else {
|
||||
no_adhoc_flag = true;
|
||||
/*if (no_jcp_flag) {
|
||||
return "JOURNEY_PLAN";
|
||||
}*/
|
||||
}
|
||||
}
|
||||
publishProgress(data);
|
||||
@@ -307,12 +329,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
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();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
xpp.next();
|
||||
@@ -322,51 +343,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
if (additionalJcpGetterSetter.getSTORE_ID().size() > 0) {
|
||||
resultHttp = CommonString.KEY_SUCCESS;
|
||||
} else {
|
||||
|
||||
no_addtional_jcp_flag = true;
|
||||
|
||||
}
|
||||
|
||||
String additional_jcpTable = additionalJcpGetterSetter.getTable_journey_plan();
|
||||
TableBean.setAdditionalJourneyPlan(additional_jcpTable);
|
||||
}
|
||||
|
||||
//SUPERVISOR_LIST
|
||||
request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD);
|
||||
request.addProperty("UserName", userId);
|
||||
request.addProperty("Type", "SUPERVISOR_LIST");
|
||||
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();
|
||||
Log.d("resultdata",result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
xpp.next();
|
||||
eventType = xpp.getEventType();
|
||||
supervisorListGetterSetter = XMLHandlers.supervisorListXMLHandler(xpp, eventType);
|
||||
|
||||
String table_sup_list = supervisorListGetterSetter.getTable_SUPERVISOR_LIST();
|
||||
if (table_sup_list != null) {
|
||||
resultHttp = CommonString.KEY_SUCCESS;
|
||||
TableBean.setTable_SUPERVISOR_LIST(table_sup_list);
|
||||
}
|
||||
|
||||
if (supervisorListGetterSetter.getEMP_ID().size() > 0) {
|
||||
data.value = 97;
|
||||
data.name = "SUPERVISOR LIST DATA" + getResources().getString(R.string.download_data);
|
||||
}
|
||||
}
|
||||
publishProgress(data);
|
||||
|
||||
|
||||
//ADHOC_JOURNEYPLAN_ADDITIONAL
|
||||
request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD);
|
||||
request.addProperty("UserName", userId);
|
||||
@@ -378,10 +359,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -397,7 +379,6 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
return "JOURNEY_PLAN";
|
||||
}
|
||||
}
|
||||
|
||||
String additional_jcpTable = additionalAdhocJcpGetterSetter.getTable_journey_plan();
|
||||
TableBean.setAdhocJourneyplanAdditional(additional_jcpTable);
|
||||
}
|
||||
@@ -413,10 +394,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -450,10 +432,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -487,10 +470,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -524,10 +508,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -560,10 +545,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -596,10 +582,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -633,8 +620,8 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -660,7 +647,7 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
|
||||
//Added on 04/12/2018
|
||||
// MAPPING_STOCK_STOREWISE
|
||||
if (country_id.equals("7")||country_id.equals("8") || country_id.equals("17")) {
|
||||
if (country_id.equals("7") || country_id.equals("8") || country_id.equals("17")) {
|
||||
request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD);
|
||||
request.addProperty("UserName", userId);
|
||||
request.addProperty("Type", "MAPPING_STOCK_STOREWISE");
|
||||
@@ -671,10 +658,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -711,10 +699,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -749,11 +738,12 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.dotNet = true;
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);;
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -780,16 +770,17 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
request.addProperty("Type", "MAPPING_DISPLAY_CHECKLIST");
|
||||
request.addProperty("cultureid", culture_id);
|
||||
|
||||
Log.d("requestdata",request.toString());
|
||||
Log.d("requestdata", request.toString());
|
||||
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();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -824,10 +815,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -859,10 +851,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -897,10 +890,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -934,10 +928,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -973,8 +968,8 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -998,6 +993,44 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
}
|
||||
publishProgress(data);
|
||||
|
||||
request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD);
|
||||
request.addProperty("UserName", userId);
|
||||
request.addProperty("Type", "CATEGORYWISE_SOS_TARGET");
|
||||
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();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
xpp.next();
|
||||
eventType = xpp.getEventType();
|
||||
store_category_wiseGetterSetter = XMLHandlers.CATEGORYWISE_SOS_TARGETXMLHandler(xpp, eventType);
|
||||
|
||||
String table_store_performace = store_category_wiseGetterSetter.getTable_CATEGORYWISE_SOS_TARGET();
|
||||
if (table_store_performace != null) {
|
||||
resultHttp = CommonString.KEY_SUCCESS;
|
||||
TableBean.setCategoryWiseSos(table_store_performace);
|
||||
}
|
||||
|
||||
if (store_category_wiseGetterSetter.getSTORE_ID().size() > 0) {
|
||||
data.value = 85;
|
||||
data.name = "CATEGORYWISE_SOS_TARGET Data Download";
|
||||
} else {
|
||||
//return "CATEGORYWISE_SOS_TARGET";
|
||||
}
|
||||
|
||||
}
|
||||
publishProgress(data);
|
||||
|
||||
|
||||
//ADDITIONAL_DISPLAY_MASTER
|
||||
request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD);
|
||||
@@ -1010,10 +1043,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1047,10 +1081,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1083,10 +1118,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1120,10 +1156,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1146,43 +1183,6 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
publishProgress(data);
|
||||
|
||||
//CATEGORYWISE_SOS_TARGET
|
||||
request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD);
|
||||
request.addProperty("UserName", userId);
|
||||
request.addProperty("Type", "CATEGORYWISE_SOS_TARGET");
|
||||
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();
|
||||
Log.d("resultdata",result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
xpp.next();
|
||||
eventType = xpp.getEventType();
|
||||
store_category_wiseGetterSetter = XMLHandlers.CATEGORYWISE_SOS_TARGETXMLHandler(xpp, eventType);
|
||||
|
||||
String table_store_performace = store_category_wiseGetterSetter.getTable_CATEGORYWISE_SOS_TARGET();
|
||||
if (table_store_performace != null) {
|
||||
resultHttp = CommonString.KEY_SUCCESS;
|
||||
TableBean.setCategoryWiseSos(table_store_performace);
|
||||
}
|
||||
|
||||
if (store_category_wiseGetterSetter.getSTORE_ID().size() > 0) {
|
||||
data.value = 85;
|
||||
data.name = "CATEGORYWISE_SOS_TARGET Data Download";
|
||||
} else {
|
||||
//return "CATEGORYWISE_SOS_TARGET";
|
||||
}
|
||||
|
||||
}
|
||||
publishProgress(data);
|
||||
|
||||
|
||||
//SHELF_MASTER
|
||||
request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD);
|
||||
@@ -1195,10 +1195,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1231,10 +1232,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1267,10 +1269,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1291,6 +1294,42 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
}
|
||||
publishProgress(data);
|
||||
|
||||
|
||||
//SUPERVISOR_LIST
|
||||
request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD);
|
||||
request.addProperty("UserName", userId);
|
||||
request.addProperty("Type", "SUPERVISOR_LIST");
|
||||
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.next();
|
||||
eventType = xpp.getEventType();
|
||||
supervisorListGetterSetter = XMLHandlers.supervisorListXMLHandler(xpp, eventType);
|
||||
|
||||
String table_sup_list = supervisorListGetterSetter.getTable_SUPERVISOR_LIST();
|
||||
if (table_sup_list != null) {
|
||||
resultHttp = CommonString.KEY_SUCCESS;
|
||||
TableBean.setTable_SUPERVISOR_LIST(table_sup_list);
|
||||
}
|
||||
|
||||
if (supervisorListGetterSetter.getEMP_ID().size() > 0) {
|
||||
data.value = 97;
|
||||
data.name = "SUPERVISOR LIST DATA" + getResources().getString(R.string.download_data);
|
||||
}
|
||||
}
|
||||
publishProgress(data);
|
||||
|
||||
//MAPPING_CATEGORY_IMAGE_ALLOW
|
||||
request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD);
|
||||
request.addProperty("UserName", userId);
|
||||
@@ -1302,10 +1341,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1337,10 +1377,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1374,10 +1415,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1409,10 +1451,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1444,10 +1487,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1479,10 +1523,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1514,10 +1559,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
// Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1550,10 +1596,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1588,10 +1635,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1618,10 +1666,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1650,8 +1699,8 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1687,10 +1736,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1727,10 +1777,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1764,10 +1815,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1791,7 +1843,7 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
publishProgress(data);
|
||||
|
||||
|
||||
//VISIT_TYPE_MASTER
|
||||
//VISIT_TYPE_MASTER
|
||||
request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD);
|
||||
request.addProperty("UserName", userId);
|
||||
request.addProperty("Type", "VISIT_TYPE_MASTER");
|
||||
@@ -1802,10 +1854,11 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
envelope.setOutputSoapObject(request);
|
||||
|
||||
androidHttpTransport = new HttpTransportSE(CommonString.URL);
|
||||
;
|
||||
androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope);
|
||||
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata",result.toString());
|
||||
result = envelope.getResponse();
|
||||
Log.d("resultdata", result.toString());
|
||||
|
||||
if (result.toString() != null) {
|
||||
xpp.setInput(new StringReader(result.toString()));
|
||||
@@ -1829,8 +1882,6 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
publishProgress(data);
|
||||
|
||||
|
||||
|
||||
|
||||
//Images DownLoads
|
||||
|
||||
//MAPPING_PLANOGRAM Image save into folder
|
||||
@@ -1852,7 +1903,7 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
file.mkdir();
|
||||
}
|
||||
|
||||
if (!new File(PATH + image_name).exists()) {
|
||||
if (!new File(PATH + image_name).exists()) {
|
||||
if (!image_name.equalsIgnoreCase("NA") && !image_name.equalsIgnoreCase("")) {
|
||||
URL url = new URL(path + "/" + image_name);
|
||||
HttpURLConnection c = (HttpURLConnection) url.openConnection();
|
||||
@@ -2066,34 +2117,35 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
db.InsertPROMOTION_TYPE_MASTER(promotion_type_masterGetterSetter);
|
||||
db.InsertCATEGORYWISE_SOS_TARGET(store_category_wiseGetterSetter);
|
||||
db.InsertMAPPING_SKU_PRICING_ENABLE(mapping_sku_pricing_enableGetterSetter);
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
} catch (MalformedURLException e) {
|
||||
ResultFlag = false;
|
||||
str = CommonString.MESSAGE_EXCEPTION;
|
||||
Log.d("exceptiondata", e.getMessage());
|
||||
return CommonString.MESSAGE_EXCEPTION;
|
||||
} catch (SocketTimeoutException e) {
|
||||
ResultFlag = false;
|
||||
str = CommonString.MESSAGE_SOCKETEXCEPTION;
|
||||
Log.d("exceptiondata1", e.getMessage());
|
||||
return CommonString.MESSAGE_SOCKETEXCEPTION;
|
||||
} catch (InterruptedIOException e) {
|
||||
ResultFlag = false;
|
||||
str = CommonString.MESSAGE_EXCEPTION;
|
||||
Log.d("exceptiondata2", e.getMessage());
|
||||
return CommonString.MESSAGE_EXCEPTION;
|
||||
} catch (IOException e) {
|
||||
ResultFlag = false;
|
||||
str = CommonString.MESSAGE_SOCKETEXCEPTION;
|
||||
Log.d("exceptiondata3", e.getMessage());
|
||||
return CommonString.MESSAGE_SOCKETEXCEPTION;
|
||||
} catch (XmlPullParserException e) {
|
||||
ResultFlag = false;
|
||||
Log.d("exceptiondata",e.getMessage() + ","+data.name );
|
||||
Log.d("exceptiondata4", e.getMessage() + "," + data.name);
|
||||
str = CommonString.MESSAGE_XmlPull;
|
||||
return CommonString.MESSAGE_XmlPull;
|
||||
} catch (Exception e) {
|
||||
// Crashlytics.log(7, CommonString.MESSAGE_EXCEPTION, e.toString());
|
||||
// Crashlytics.logException(e.getCause());
|
||||
// Crashlytics.logException(new Exception(e.getCause()));
|
||||
ResultFlag = false;
|
||||
str = CommonString.MESSAGE_EXCEPTION;
|
||||
Log.d("exceptiondata5", e.getMessage());
|
||||
return CommonString.MESSAGE_EXCEPTION;
|
||||
}
|
||||
|
||||
@@ -2153,4 +2205,13 @@ public class DownloadActivity extends AppCompatActivity {
|
||||
CommonFunctions.updateLangResources(context, preferences.getString(CommonString.KEY_LANGUAGE, ""));
|
||||
}
|
||||
|
||||
|
||||
private void enableOldTLS() {
|
||||
try {
|
||||
SSLSocketFactory tlsSocketFactory = new TLSSocketFactory();
|
||||
HttpsURLConnection.setDefaultSSLSocketFactory(tlsSocketFactory);
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+74
-8
@@ -51,6 +51,7 @@ import cpm.com.gskmtorange.dailyentry.CreateSelfActivity;
|
||||
import cpm.com.gskmtorange.dailyentry.NewStockDataActivity;
|
||||
import cpm.com.gskmtorange.dailyentry.OrderTakingActivity;
|
||||
import cpm.com.gskmtorange.dailyentry.PDVisibilityActivity;
|
||||
import cpm.com.gskmtorange.dailyentry.PD_Pog_Activity;
|
||||
import cpm.com.gskmtorange.dailyentry.PDimageActivity;
|
||||
import cpm.com.gskmtorange.dailyentry.POGQuestionsActivity;
|
||||
import cpm.com.gskmtorange.dailyentry.StockActivity;
|
||||
@@ -113,7 +114,7 @@ public class DailyDataMenuActivity extends AppCompatActivity {
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
db.open();
|
||||
// deleteIRURl(context);
|
||||
// deleteIRURl(context);
|
||||
visittypelist = db.getInsertedVisitType(store_id, visit_date, "3");
|
||||
if (visittypelist.size() > 0) {
|
||||
if (visittypelist.get(0).getVISIT_TYPE_ID().equals("3")) {
|
||||
@@ -134,7 +135,7 @@ public class DailyDataMenuActivity extends AppCompatActivity {
|
||||
ArrayList<ImageUri> uris = irList.get(i).getImageUris();
|
||||
if (uris != null && !uris.isEmpty()) {
|
||||
for (int k = 0; k < uris.size(); k++) {
|
||||
// CommonUtils.INSTANCE.deleteSpecificImage(this,uris.get(k).getUri());
|
||||
// CommonUtils.INSTANCE.deleteSpecificImage(this,uris.get(k).getUri());
|
||||
deleteSpecificImage(context,uris.get(k).getUri());
|
||||
}
|
||||
}
|
||||
@@ -522,12 +523,25 @@ public class DailyDataMenuActivity extends AppCompatActivity {
|
||||
} else {
|
||||
data.setCategory_img(R.mipmap.picturecatogory_grey);
|
||||
}
|
||||
|
||||
}
|
||||
data.setCategory_name(getResources()
|
||||
.getString(R.string.title_activity_ir_visibility));
|
||||
data.setCategory_name(getResources().getString(R.string.title_activity_ir_visibility));
|
||||
categoryList.add(data);
|
||||
|
||||
//IR POG
|
||||
/*data = new DailyDataMenuGetterSetter();
|
||||
ArrayList<CategoryPictureGetterSetter> ir_pog = isPdPogIRMapping();
|
||||
if (ir_pog != null && !ir_pog.isEmpty() && camera_allow.equals("1")) {
|
||||
data.setCategory_img(R.mipmap.picturecatogory);
|
||||
db.open();
|
||||
if (db.isPdPogImages(store_id, visit_date, CommonString.KEY_COMPELETE, categoryId)) {
|
||||
data.setCategory_img(R.mipmap.picturecatogory_done);
|
||||
}
|
||||
} else {
|
||||
data.setCategory_img(R.mipmap.picturecatogory_grey);
|
||||
}
|
||||
data.setCategory_name(getResources().getString(R.string.title_activity_ir_pog));
|
||||
categoryList.add(data);*/
|
||||
}
|
||||
|
||||
adapter = new DailyDataMenuAdapter(DailyDataMenuActivity.this, categoryList);
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(context, 2));
|
||||
@@ -738,6 +752,10 @@ public class DailyDataMenuActivity extends AppCompatActivity {
|
||||
holder.categoryName.setTextColor(isPdVisibiltyMapping() != null && !isPdVisibiltyMapping().isEmpty() && camera_allow.equals("1")
|
||||
? ContextCompat.getColor(context, R.color.black) : ContextCompat.getColor(context, R.color.grey_background));
|
||||
}
|
||||
/*else if (dailyData.getCategory_name().equalsIgnoreCase(getString(R.string.title_activity_ir_pog))) {
|
||||
holder.categoryName.setTextColor(isPdPogIRMapping() != null && !isPdPogIRMapping().isEmpty() && camera_allow.equals("1")
|
||||
? ContextCompat.getColor(context, R.color.black) : ContextCompat.getColor(context, R.color.grey_background));
|
||||
}*/
|
||||
else{
|
||||
holder.irview.setVisibility(View.GONE);
|
||||
}
|
||||
@@ -807,7 +825,8 @@ public class DailyDataMenuActivity extends AppCompatActivity {
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
}
|
||||
} else if (dailyData.getCategory_name().equalsIgnoreCase(getResources().getString(R.string.title_activity_ir_image))) {
|
||||
}
|
||||
else if (dailyData.getCategory_name().equalsIgnoreCase(getResources().getString(R.string.title_activity_ir_image))) {
|
||||
if (isPdIRMapping() != null && !isPdIRMapping().isEmpty() && camera_allow.equals("1")) {
|
||||
Intent intent = new Intent(DailyDataMenuActivity.this, PDimageActivity.class);
|
||||
intent.putExtra("kpi_name", dailyData.getCategory_name());
|
||||
@@ -817,8 +836,18 @@ public class DailyDataMenuActivity extends AppCompatActivity {
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
}
|
||||
}
|
||||
/*else if (dailyData.getCategory_name().equalsIgnoreCase(getResources().getString(R.string.title_activity_ir_pog))) {
|
||||
if (isPdPogIRMapping() != null && !isPdPogIRMapping().isEmpty() && camera_allow.equals("1")) {
|
||||
Intent intent = new Intent(DailyDataMenuActivity.this, PD_Pog_Activity.class);
|
||||
intent.putExtra("kpi_name", dailyData.getCategory_name());
|
||||
intent.putExtra("categoryName", categoryName);
|
||||
intent.putExtra("categoryId", categoryId);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
|
||||
}
|
||||
}*/
|
||||
else if (dailyData.getCategory_name().equalsIgnoreCase(getResources().getString(R.string.title_activity_ir_visibility))) {
|
||||
if (isPdIRMapping() != null && !isPdIRMapping().isEmpty() && camera_allow.equals("1")) {
|
||||
if (isPdVisibiltyMapping() != null && !isPdVisibiltyMapping().isEmpty() && camera_allow.equals("1")) {
|
||||
Intent intent = new Intent(DailyDataMenuActivity.this, PDVisibilityActivity.class);
|
||||
intent.putExtra("kpi_name", dailyData.getCategory_name());
|
||||
intent.putExtra("categoryName", categoryName);
|
||||
@@ -1009,6 +1038,43 @@ public class DailyDataMenuActivity extends AppCompatActivity {
|
||||
return ir_list;
|
||||
}
|
||||
|
||||
private ArrayList<CategoryPictureGetterSetter> isPdPogIRMapping() {
|
||||
ArrayList<CategoryPictureGetterSetter> ir_list;
|
||||
if (country_id.equals("8")) {
|
||||
ir_list = db.getCategoryPicturePogdata(
|
||||
date,
|
||||
categoryId,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
store_id,
|
||||
CommonString.TABLE_MAPPING_STOCK_STOREWISE
|
||||
);
|
||||
} else if (store_flag_str != null && store_flag_str.equalsIgnoreCase(CommonString.FROM_DEVIATION)) {
|
||||
ir_list = db.getCategoryPicturePogdata(
|
||||
date,
|
||||
categoryId,
|
||||
keyAccount_id,
|
||||
storeType_id,
|
||||
class_id,
|
||||
store_id,
|
||||
CommonString.TABLE_MAPPING_STOCK_ADHOC
|
||||
);
|
||||
} else {
|
||||
ir_list = db.getCategoryPicturePogdata(
|
||||
date,
|
||||
categoryId,
|
||||
keyAccount_id,
|
||||
storeType_id,
|
||||
class_id,
|
||||
store_id,
|
||||
CommonString.TABLE_MAPPING_STOCK
|
||||
);
|
||||
}
|
||||
|
||||
return ir_list;
|
||||
}
|
||||
|
||||
private ArrayList<CategoryPictureGetterSetter> isPdVisibiltyMapping() {
|
||||
ArrayList<CategoryPictureGetterSetter> ir_list;
|
||||
if (country_id.equals("6")) {
|
||||
|
||||
@@ -474,7 +474,7 @@ public class MPinActivity extends AppCompatActivity implements BlurLockView.OnPa
|
||||
protected String doInBackground(Void... params) {
|
||||
try {
|
||||
versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
|
||||
String userauth_xml = "[DATA]" + "[USER_DATA][USER_ID]" + userId + "[/USER_ID]" + "[PASSWORD]" + password + "[/PASSWORD]" + "[IN_TIME]" + CommonFunctions.getCurrentTimeWithLanguage(context) + "[/IN_TIME]" + "[LATITUDE]" + lat + "[/LATITUDE]" + "[LONGITUDE]" + lon + "[/LONGITUDE]" + "[APP_VERSION]" + app_ver + "[/APP_VERSION]" + "[ATT_MODE]OnLine[/ATT_MODE]" + "[NETWORK_STATUS]" + "LoginStatus" + "[/NETWORK_STATUS]" + "[/USER_DATA][/DATA]";
|
||||
String userauth_xml = "[DATA]" + "[USER_DATA][USER_ID]" + userId + "[/USER_ID]" + "[PASSWORD]" + password + "[/PASSWORD]" + "[IN_TIME]" + CommonFunctions.getCurrentTimeWithLanguage(context) + "[/IN_TIME]" + "[LATITUDE]" + lat + "[/LATITUDE]" + "[LONGITUDE]" + lon + "[/LONGITUDE]" + "[APP_VERSION]" + app_ver+"-T5" + "[/APP_VERSION]" + "[ATT_MODE]OnLine[/ATT_MODE]" + "[NETWORK_STATUS]" + "LoginStatus" + "[/NETWORK_STATUS]" + "[/USER_DATA][/DATA]";
|
||||
SoapObject request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_LOGIN);
|
||||
request.addProperty("onXML", userauth_xml);
|
||||
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
|
||||
|
||||
+10
-14
@@ -1,5 +1,7 @@
|
||||
package cpm.com.gskmtorange.storeinmap;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.location.Location;
|
||||
@@ -10,6 +12,7 @@ import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||
@@ -56,34 +59,23 @@ public class StoreListRouteActivity extends FragmentActivity implements OnMapRea
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_store_list_route);
|
||||
storelist = (ArrayList<StoreBean>)getIntent().getSerializableExtra(CommonString.KEY_STORE_LIST);
|
||||
|
||||
|
||||
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
|
||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
||||
.findFragmentById(R.id.map);
|
||||
mapFragment.getMapAsync(this);
|
||||
|
||||
mapFragment.getMapAsync(this);
|
||||
color_list.add("#f44336");
|
||||
color_list.add("#1e88e5");
|
||||
color_list.add("#2e7d32");
|
||||
color_list.add("#ab47bc");
|
||||
color_list.add("#ffcc80");
|
||||
color_list.add("#fdd835");
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Manipulates the map once available.
|
||||
* This callback is triggered when the map is ready to be used.
|
||||
* This is where we can add markers or lines, add listeners or move the camera. In this case,
|
||||
* we just add a marker near Sydney, Australia.
|
||||
* If Google Play services is not installed on the device, the user will be prompted to install
|
||||
* it inside the SupportMapFragment. This method will only be triggered once the user has
|
||||
* installed Google Play services and returned to the app.
|
||||
*/
|
||||
@Override
|
||||
public void onMapReady(GoogleMap googleMap) {
|
||||
mMap = googleMap;
|
||||
|
||||
showRoute(global_index);
|
||||
}
|
||||
|
||||
@@ -102,6 +94,10 @@ public class StoreListRouteActivity extends FragmentActivity implements OnMapRea
|
||||
Bitmap bm = tv.getDrawingCache();
|
||||
lat = Double.parseDouble(storelist.get(index).getLATITUDE());
|
||||
lon = Double.parseDouble(storelist.get(index).getLONGITUDE());
|
||||
/*lat = 28.5275;
|
||||
lon = 77.2781;*/
|
||||
|
||||
Log.e("directiondata",lat +","+lon);
|
||||
LatLng loc = new LatLng(lat, lon);
|
||||
|
||||
mMap.addMarker(new MarkerOptions().position(loc).anchor(0.5f, 0.5f).icon(BitmapDescriptorFactory.fromBitmap(bm)));
|
||||
|
||||
+147
-322
@@ -6,7 +6,6 @@ import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.location.Location;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@@ -24,11 +23,10 @@ import androidx.fragment.app.FragmentActivity;
|
||||
import com.google.android.gms.appindexing.Action;
|
||||
import com.google.android.gms.appindexing.AppIndex;
|
||||
import com.google.android.gms.appindexing.Thing;
|
||||
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.location.LocationListener;
|
||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||
import com.google.android.gms.location.LocationCallback;
|
||||
import com.google.android.gms.location.LocationRequest;
|
||||
import com.google.android.gms.location.LocationResult;
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
@@ -40,9 +38,7 @@ import com.google.android.gms.maps.model.LatLngBounds;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
import com.google.android.gms.maps.model.PolylineOptions;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -57,122 +53,136 @@ import cpm.com.gskmtorange.GetterSetter.StoreBean;
|
||||
import cpm.com.gskmtorange.R;
|
||||
import cpm.com.gskmtorange.constant.CommonString;
|
||||
|
||||
public class StoreRouteActivity extends FragmentActivity implements OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener {
|
||||
public class StoreRouteActivity extends FragmentActivity implements OnMapReadyCallback {
|
||||
|
||||
private Context context;
|
||||
private GoogleMap mMap;
|
||||
StoreBean store;
|
||||
LatLng origin, destination;
|
||||
private final static int PLAY_SERVICES_RESOLUTION_REQUEST = 1000;
|
||||
private GoogleApiClient mGoogleApiClient;
|
||||
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 Location mLastLocation;
|
||||
double latitude = 0.0;
|
||||
double longitude = 0.0;
|
||||
Boolean markerflag = true;
|
||||
private StoreBean store;
|
||||
private LatLng origin, destination;
|
||||
|
||||
private FusedLocationProviderClient fusedLocationClient;
|
||||
private LocationRequest locationRequest;
|
||||
private LocationCallback locationCallback;
|
||||
|
||||
private static final int LOCATION_PERMISSION_REQUEST = 1001;
|
||||
|
||||
FloatingActionButton fab_cancel;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_store_route);
|
||||
fab_cancel = (FloatingActionButton) findViewById(R.id.fab_cancel);
|
||||
context = this;
|
||||
fab_cancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
}
|
||||
|
||||
fab_cancel = findViewById(R.id.fab_cancel);
|
||||
fab_cancel.setOnClickListener(v -> {
|
||||
finish();
|
||||
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
|
||||
});
|
||||
|
||||
store = (StoreBean) getIntent().getSerializableExtra(CommonString.KEY_STORE_LIST);
|
||||
/*store.setLATITUDE("28.5420901");
|
||||
store.setLONGITUDE("77.2430997");*/
|
||||
/*store.setLATITUDE("28.544055");
|
||||
store.setLONGITUDE("77.264060");*/
|
||||
|
||||
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
|
||||
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
|
||||
|
||||
locationRequest = LocationRequest.create()
|
||||
.setInterval(2000) // 2 sec
|
||||
.setFastestInterval(1000) // 1 sec
|
||||
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
|
||||
|
||||
locationCallback = new LocationCallback() {
|
||||
@Override
|
||||
public void onLocationResult(@NonNull LocationResult locationResult) {
|
||||
if (locationResult.getLastLocation() != null) {
|
||||
Location loc = locationResult.getLastLocation();
|
||||
updateMapWithCurrentLocation(loc);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
||||
.findFragmentById(R.id.map);
|
||||
mapFragment.getMapAsync(this);
|
||||
|
||||
if (checkPlayServices()) {
|
||||
|
||||
// Building the GoogleApi client
|
||||
buildGoogleApiClient();
|
||||
|
||||
createLocationRequest();
|
||||
if (mapFragment != null) {
|
||||
mapFragment.getMapAsync(this);
|
||||
}
|
||||
}
|
||||
|
||||
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(context, getResources().getString(R.string.notsuppoted)
|
||||
, Toast.LENGTH_LONG)
|
||||
.show();
|
||||
finish();
|
||||
}
|
||||
@Override
|
||||
public void onMapReady(GoogleMap googleMap) {
|
||||
mMap = googleMap;
|
||||
|
||||
// Enable zoom controls for user
|
||||
mMap.getUiSettings().setZoomControlsEnabled(true);
|
||||
|
||||
// Request permissions
|
||||
if (checkLocationPermission()) {
|
||||
startLocationUpdates();
|
||||
fusedLocationClient.getLastLocation()
|
||||
.addOnSuccessListener(this, location -> {
|
||||
if (location != null) {
|
||||
updateMapWithCurrentLocation(location); // show instantly with last known location
|
||||
} else {
|
||||
Toast.makeText(this, "Waiting for current location...", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
/* if (store != null) {
|
||||
LatLng storeLoc = new LatLng(Double.parseDouble(store.getLATITUDE()), Double.parseDouble(store.getLONGITUDE()));
|
||||
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(storeLoc, 15));
|
||||
}*/
|
||||
}
|
||||
|
||||
private boolean checkLocationPermission() {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(
|
||||
this,
|
||||
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
|
||||
LOCATION_PERMISSION_REQUEST
|
||||
);
|
||||
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);
|
||||
|
||||
private void startLocationUpdates() {
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
|
||||
fusedLocationClient.requestLocationUpdates(locationRequest, locationCallback, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Manipulates the map once available.
|
||||
* This callback is triggered when the map is ready to be used.
|
||||
* This is where we can add markers or lines, add listeners or move the camera. In this case,
|
||||
* we just add a marker near Sydney, Australia.
|
||||
* If Google Play services is not installed on the device, the user will be prompted to install
|
||||
* it inside the SupportMapFragment. This method will only be triggered once the user has
|
||||
* installed Google Play services and returned to the app.
|
||||
*/
|
||||
@Override
|
||||
public void onMapReady(GoogleMap googleMap) {
|
||||
mMap = googleMap;
|
||||
private void updateMapWithCurrentLocation(Location location) {
|
||||
double latitude = location.getLatitude();
|
||||
double longitude = location.getLongitude();
|
||||
|
||||
origin = new LatLng(latitude, longitude);
|
||||
destination = new LatLng(Double.parseDouble(store.getLATITUDE()), Double.parseDouble(store.getLONGITUDE()));
|
||||
|
||||
// Show markers
|
||||
StoreBean currentStore = new StoreBean();
|
||||
currentStore.setLATITUDE(latitude + "");
|
||||
currentStore.setLONGITUDE(longitude + "");
|
||||
currentStore.setSTORE_NAME("Current Location");
|
||||
showMarker(currentStore, R.layout.current_marker_view);
|
||||
|
||||
showMarker(store, R.layout.marker_view);
|
||||
|
||||
// Move camera to fit both points
|
||||
LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
builder.include(origin);
|
||||
builder.include(destination);
|
||||
mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 100));
|
||||
|
||||
// Fetch and draw route
|
||||
String url = getUrl(origin, destination);
|
||||
new FetchUrl().execute(url);
|
||||
|
||||
// Stop updates once we get location
|
||||
fusedLocationClient.removeLocationUpdates(locationCallback);
|
||||
}
|
||||
|
||||
public void showMarker(double lat, double lon) {
|
||||
// Add a marker and move the camera
|
||||
LinearLayout tv = (LinearLayout) this.getLayoutInflater().inflate(R.layout.marker_view, null, false);
|
||||
|
||||
TextView desc = (TextView) tv.findViewById(R.id.tv_desc);
|
||||
public void showMarker(StoreBean store, int layout_resource) {
|
||||
LinearLayout tv = (LinearLayout) this.getLayoutInflater().inflate(layout_resource, null, false);
|
||||
TextView desc = tv.findViewById(R.id.tv_desc);
|
||||
desc.setText(store.getSTORE_NAME());
|
||||
|
||||
tv.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
|
||||
@@ -180,302 +190,117 @@ public class StoreRouteActivity extends FragmentActivity implements OnMapReadyCa
|
||||
tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight());
|
||||
|
||||
tv.setDrawingCacheEnabled(true);
|
||||
tv.buildDrawingCache();
|
||||
Bitmap bm = tv.getDrawingCache();
|
||||
|
||||
LatLng loc = new LatLng(Double.parseDouble(store.getLATITUDE()), Double.parseDouble(store.getLONGITUDE()));
|
||||
mMap.addMarker(new MarkerOptions().position(loc).anchor(0.5f, 0.5f).icon(BitmapDescriptorFactory.fromBitmap(bm)));
|
||||
mMap.addMarker(new MarkerOptions()
|
||||
.position(loc)
|
||||
.anchor(0.5f, 0.5f)
|
||||
.icon(BitmapDescriptorFactory.fromBitmap(bm)));
|
||||
}
|
||||
|
||||
private String getUrl(LatLng origin, LatLng dest) {
|
||||
|
||||
// Origin of route
|
||||
String str_origin = "origin=" + origin.latitude + "," + origin.longitude;
|
||||
|
||||
// Destination of route
|
||||
String str_dest = "destination=" + dest.latitude + "," + dest.longitude;
|
||||
|
||||
|
||||
// Sensor enabled
|
||||
String sensor = "sensor=false";
|
||||
|
||||
// Building the parameters to the web service
|
||||
String parameters = str_origin + "&" + str_dest + "&" + sensor;
|
||||
|
||||
// Output format
|
||||
String parameters = str_origin + "&" + str_dest + "&sensor=false";
|
||||
String output = "json";
|
||||
|
||||
// Building the url to the web service
|
||||
String url = "https://maps.googleapis.com/maps/api/directions/" + output + "?" + parameters+"&key=AIzaSyCPo-giwVv5h8AzsbE1IDRsFsPHjVlCm5A";
|
||||
|
||||
|
||||
return url;
|
||||
return "https://maps.googleapis.com/maps/api/directions/" + output + "?" + parameters + "&key=AIzaSyCPo-giwVv5h8AzsbE1IDRsFsPHjVlCm5A";
|
||||
}
|
||||
|
||||
/**
|
||||
* A method to download json data from url
|
||||
*/
|
||||
private String downloadUrl(String strUrl) throws IOException {
|
||||
String data = "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
InputStream iStream = null;
|
||||
HttpURLConnection urlConnection = null;
|
||||
try {
|
||||
URL url = new URL(strUrl);
|
||||
|
||||
// Creating an http connection to communicate with url
|
||||
urlConnection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
// Connecting to url
|
||||
urlConnection.connect();
|
||||
|
||||
// Reading data from url
|
||||
iStream = urlConnection.getInputStream();
|
||||
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(iStream));
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
String line = "";
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
sb.append(line);
|
||||
}
|
||||
|
||||
data = sb.toString();
|
||||
Log.d("downloadUrl", data.toString());
|
||||
br.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.d("Exception", e.toString());
|
||||
Log.e("Exception", e.toString());
|
||||
} finally {
|
||||
iStream.close();
|
||||
urlConnection.disconnect();
|
||||
if (iStream != null) iStream.close();
|
||||
if (urlConnection != null) urlConnection.disconnect();
|
||||
}
|
||||
return data;
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(@Nullable Bundle bundle) {
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
// TODO: Consider calling
|
||||
// ActivityCompat#requestPermissions
|
||||
// here to request the missing permissions, and then overriding
|
||||
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
|
||||
// int[] grantResults)
|
||||
// to handle the case where the user grants the permission. See the documentation
|
||||
// for ActivityCompat#requestPermissions for more details.
|
||||
return;
|
||||
}
|
||||
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) {
|
||||
latitude = mLastLocation.getLatitude();
|
||||
longitude = mLastLocation.getLongitude();
|
||||
|
||||
mMap.setMyLocationEnabled(true);
|
||||
|
||||
origin = new LatLng(latitude, longitude);
|
||||
destination = new LatLng(Double.parseDouble(store.getLATITUDE()), Double.parseDouble(store.getLONGITUDE()));
|
||||
|
||||
StoreBean store1 = new StoreBean();
|
||||
store1.setLATITUDE(latitude+"");
|
||||
store1.setLONGITUDE(longitude+"");
|
||||
store1.setSTORE_NAME("Current Location");
|
||||
showMarker(store1, R.layout.current_marker_view);
|
||||
|
||||
showMarker(store, R.layout.marker_view);
|
||||
|
||||
LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
builder.include(new LatLng(Double.parseDouble(store.getLATITUDE()), Double.parseDouble(store.getLONGITUDE())));
|
||||
builder.include(new LatLng(latitude, longitude));
|
||||
//mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 48));
|
||||
mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 48));
|
||||
|
||||
//destination = new LatLng(mapLat[1], mapLon[1]);
|
||||
/*mMap.moveCamera(CameraUpdateFactory.newLatLng(origin));
|
||||
mMap.animateCamera(CameraUpdateFactory.zoomTo(17));*/
|
||||
|
||||
//new GetDirection().execute();
|
||||
// Getting URL to the Google Directions API
|
||||
String url = getUrl(origin, destination);
|
||||
Log.d("onMapClick", url.toString());
|
||||
FetchUrl FetchUrl = new FetchUrl();
|
||||
|
||||
// Start downloading json data from Google Directions API
|
||||
FetchUrl.execute(url);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if (mRequestingLocationUpdates) {
|
||||
startLocationUpdates();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionSuspended(int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
|
||||
}
|
||||
|
||||
public void showMarker(StoreBean store, int layout_resource){
|
||||
// Add a marker of latest location and move the camera
|
||||
LinearLayout tv = (LinearLayout) this.getLayoutInflater().inflate(layout_resource, null, false);
|
||||
|
||||
TextView desc = (TextView) tv.findViewById(R.id.tv_desc);
|
||||
desc.setText(store.getSTORE_NAME());
|
||||
|
||||
tv.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
|
||||
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
|
||||
tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight());
|
||||
|
||||
tv.setDrawingCacheEnabled(true);
|
||||
tv.buildDrawingCache();
|
||||
Bitmap bm = tv.getDrawingCache();
|
||||
LatLng loc = new LatLng(Double.parseDouble(store.getLATITUDE()), Double.parseDouble(store.getLONGITUDE()));
|
||||
mMap.addMarker(new MarkerOptions().position(loc).anchor(0.5f, 0.5f).icon(BitmapDescriptorFactory.fromBitmap(bm)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
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.
|
||||
mGoogleApiClient.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(mGoogleApiClient, getIndexApiAction());
|
||||
}
|
||||
|
||||
/**
|
||||
* ATTENTION: This was auto-generated to implement the App Indexing API.
|
||||
* See https://g.co/AppIndexing/AndroidStudio for more information.
|
||||
*/
|
||||
public Action getIndexApiAction() {
|
||||
Thing object = new Thing.Builder()
|
||||
.setName("GeoTag Page") // TODO: Define a title for the content shown.
|
||||
// TODO: Make sure this auto-generated URL is correct.
|
||||
.setUrl(Uri.parse("http://[ENTER-YOUR-URL-HERE]"))
|
||||
.build();
|
||||
return new Action.Builder(Action.TYPE_VIEW)
|
||||
.setObject(object)
|
||||
.setActionStatus(Action.STATUS_TYPE_COMPLETED)
|
||||
.build();
|
||||
}
|
||||
|
||||
// Fetches data from url passed
|
||||
// AsyncTask to fetch directions
|
||||
private class FetchUrl extends AsyncTask<String, Void, String> {
|
||||
|
||||
@Override
|
||||
protected String doInBackground(String... url) {
|
||||
|
||||
// For storing data from web service
|
||||
String data = "";
|
||||
|
||||
try {
|
||||
// Fetching the data from web service
|
||||
data = downloadUrl(url[0]);
|
||||
Log.d("Background Task data", data.toString());
|
||||
} catch (Exception e) {
|
||||
Log.d("Background Task", e.toString());
|
||||
return downloadUrl(url[0]);
|
||||
} catch (IOException e) {
|
||||
Log.e("Background Task", e.toString());
|
||||
return "";
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String result) {
|
||||
super.onPostExecute(result);
|
||||
|
||||
ParserTask parserTask = new ParserTask();
|
||||
|
||||
// Invokes the thread for parsing the JSON data
|
||||
parserTask.execute(result);
|
||||
|
||||
Log.d("DirectionsResponse", result);
|
||||
new ParserTask().execute(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A class to parse the Google Places in JSON format
|
||||
*/
|
||||
private class ParserTask extends AsyncTask<String, Integer, List<List<HashMap<String, String>>>> {
|
||||
|
||||
// Parsing the data in non-ui thread
|
||||
@Override
|
||||
protected List<List<HashMap<String, String>>> doInBackground(String... jsonData) {
|
||||
|
||||
JSONObject jObject;
|
||||
List<List<HashMap<String, String>>> routes = null;
|
||||
|
||||
try {
|
||||
jObject = new JSONObject(jsonData[0]);
|
||||
Log.d("ParserTask",jsonData[0].toString());
|
||||
JSONObject jObject = new JSONObject(jsonData[0]);
|
||||
DataParser parser = new DataParser();
|
||||
Log.d("ParserTask", parser.toString());
|
||||
|
||||
// Starts parsing data
|
||||
routes = parser.parse(jObject);
|
||||
Log.d("ParserTask","Executing routes");
|
||||
Log.d("ParserTask",routes.toString());
|
||||
|
||||
return parser.parse(jObject);
|
||||
} catch (Exception e) {
|
||||
Log.d("ParserTask",e.toString());
|
||||
e.printStackTrace();
|
||||
Log.e("ParserTask", e.toString());
|
||||
return null;
|
||||
}
|
||||
return routes;
|
||||
}
|
||||
|
||||
// Executes in UI thread, after the parsing process
|
||||
@Override
|
||||
protected void onPostExecute(List<List<HashMap<String, String>>> result) {
|
||||
if (result == null) return;
|
||||
|
||||
ArrayList<LatLng> points;
|
||||
PolylineOptions lineOptions = null;
|
||||
|
||||
// Traversing through all the routes
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
for (List<HashMap<String, String>> path : result) {
|
||||
points = new ArrayList<>();
|
||||
lineOptions = new PolylineOptions();
|
||||
|
||||
// Fetching i-th route
|
||||
List<HashMap<String, String>> path = result.get(i);
|
||||
|
||||
// Fetching all the points in i-th route
|
||||
for (int j = 0; j < path.size(); j++) {
|
||||
HashMap<String, String> point = path.get(j);
|
||||
|
||||
for (HashMap<String, String> point : path) {
|
||||
double lat = Double.parseDouble(point.get("lat"));
|
||||
double lng = Double.parseDouble(point.get("lng"));
|
||||
LatLng position = new LatLng(lat, lng);
|
||||
|
||||
points.add(position);
|
||||
points.add(new LatLng(lat, lng));
|
||||
}
|
||||
|
||||
// Adding all the points in the route to LineOptions
|
||||
lineOptions.addAll(points);
|
||||
lineOptions.width(12);
|
||||
lineOptions.color(Color.parseColor("#5ac614"));
|
||||
|
||||
Log.d("onPostExecute","onPostExecute lineoptions decoded");
|
||||
|
||||
}
|
||||
|
||||
// Drawing polyline in the Google Map for the i-th route
|
||||
if(lineOptions != null) {
|
||||
if (lineOptions != null) {
|
||||
mMap.addPolyline(lineOptions);
|
||||
}
|
||||
else {
|
||||
Log.d("onPostExecute","without Polylines drawn");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == LOCATION_PERMISSION_REQUEST) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
startLocationUpdates();
|
||||
} else {
|
||||
Toast.makeText(this, "Location permission required", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,13 @@ import android.util.Log;
|
||||
|
||||
//import com.crashlytics.android.Crashlytics;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.squareup.okhttp.ConnectionSpec;
|
||||
import com.squareup.okhttp.MediaType;
|
||||
import com.squareup.okhttp.MultipartBuilder;
|
||||
import com.squareup.okhttp.OkHttpClient;
|
||||
import com.squareup.okhttp.Protocol;
|
||||
import com.squareup.okhttp.RequestBody;
|
||||
import com.squareup.okhttp.TlsVersion;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.ksoap2.SoapEnvelope;
|
||||
@@ -144,9 +146,8 @@ public class UploadImageWithRetrofit {
|
||||
if (finalFile == null) {
|
||||
finalFile = originalFile;
|
||||
}
|
||||
|
||||
OkHttpClient okHttpClient = new OkHttpClient();
|
||||
// okHttpClient.setProtocols(Arrays.asList(Protocol.HTTP_1_1));
|
||||
// okHttpClient.setProtocols(Arrays.asList(Protocol.));
|
||||
okHttpClient.setConnectTimeout(20, TimeUnit.SECONDS);
|
||||
okHttpClient.setWriteTimeout(20, TimeUnit.SECONDS);
|
||||
okHttpClient.setReadTimeout(20, TimeUnit.SECONDS);
|
||||
@@ -177,7 +178,6 @@ public class UploadImageWithRetrofit {
|
||||
uploadedFiles++;
|
||||
} else {
|
||||
status = 0;
|
||||
//uploadedFiles = 0;
|
||||
}
|
||||
if (status == 0) {
|
||||
pd.dismiss();
|
||||
@@ -202,13 +202,11 @@ public class UploadImageWithRetrofit {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
if (totalFiles == uploadedFiles) {
|
||||
//region Coverage upload status Data
|
||||
new StatusUpload().execute();
|
||||
}
|
||||
|
||||
}
|
||||
} catch (JsonSyntaxException e) {
|
||||
e.fillInStackTrace();
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
package cpm.com.gskmtorange.utils;
|
||||
import com.squareup.okhttp.ConnectionSpec;
|
||||
import com.squareup.okhttp.MediaType;
|
||||
import com.squareup.okhttp.OkHttpClient;
|
||||
import com.squareup.okhttp.Request;
|
||||
import com.squareup.okhttp.RequestBody;
|
||||
import com.squareup.okhttp.Response;
|
||||
import com.squareup.okhttp.TlsVersion;
|
||||
import org.ksoap2.HeaderProperty;
|
||||
import org.ksoap2.SoapEnvelope;
|
||||
import org.ksoap2.transport.ServiceConnection;
|
||||
import org.ksoap2.transport.Transport;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class OkHttpTransportSE extends Transport {
|
||||
|
||||
private final String url;
|
||||
private final OkHttpClient client;
|
||||
|
||||
public OkHttpTransportSE(String url) {
|
||||
this(url, 60000); // default 60s timeout
|
||||
}
|
||||
|
||||
public OkHttpTransportSE(String url, int timeout) {
|
||||
super(url, timeout);
|
||||
this.url = url;
|
||||
|
||||
client = new OkHttpClient();
|
||||
|
||||
// Force TLS 1.2
|
||||
ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
|
||||
.tlsVersions(TlsVersion.TLS_1_2,
|
||||
TlsVersion.TLS_1_1,
|
||||
TlsVersion.TLS_1_0)
|
||||
.build();
|
||||
|
||||
client.setConnectionSpecs(Collections.singletonList(spec));
|
||||
client.setConnectTimeout(timeout, TimeUnit.MILLISECONDS);
|
||||
client.setReadTimeout(timeout, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List call(String soapAction, SoapEnvelope envelope, List headers)
|
||||
throws IOException, XmlPullParserException {
|
||||
return call(soapAction, envelope, headers, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ServiceConnection getServiceConnection() throws IOException {
|
||||
return null; // not used with OkHttp
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HeaderProperty> call(String soapAction, SoapEnvelope envelope, List headers, File outputFile)
|
||||
throws IOException, XmlPullParserException {
|
||||
|
||||
if (soapAction == null) {
|
||||
soapAction = "";
|
||||
}
|
||||
|
||||
byte[] requestData = this.createRequestData(envelope, "UTF-8");
|
||||
this.requestDump = this.debug ? new String(requestData) : null;
|
||||
this.responseDump = null;
|
||||
|
||||
// Build request
|
||||
Request.Builder builder = new Request.Builder()
|
||||
.url(url)
|
||||
.addHeader("User-Agent", "ksoap2-android/2.6.0+");
|
||||
|
||||
if (envelope.version == SoapEnvelope.VER12) {
|
||||
builder.addHeader("Content-Type", "application/soap+xml;charset=utf-8");
|
||||
} else {
|
||||
builder.addHeader("Content-Type", "text/xml;charset=utf-8");
|
||||
builder.addHeader("SOAPAction", soapAction); // Match HttpTransportSE
|
||||
}
|
||||
|
||||
// Add custom headers if any
|
||||
if (headers != null) {
|
||||
for (Object h : headers) {
|
||||
HeaderProperty hp = (HeaderProperty) h;
|
||||
if (hp.getKey() != null && hp.getValue() != null) {
|
||||
builder.addHeader(hp.getKey(), hp.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
builder.post(RequestBody.create(MediaType.parse("text/xml; charset=utf-8"), requestData));
|
||||
|
||||
// Execute request
|
||||
Response response = client.newCall(builder.build()).execute();
|
||||
|
||||
if (!response.isSuccessful()) {
|
||||
throw new IOException("HTTP request failed, code: " + response.code());
|
||||
}
|
||||
|
||||
// Collect response headers
|
||||
List<HeaderProperty> retHeaders = new ArrayList<>();
|
||||
for (String name : response.headers().names()) {
|
||||
retHeaders.add(new HeaderProperty(name, response.header(name)));
|
||||
}
|
||||
// Parse SOAP response
|
||||
parseResponse(envelope, response.body().byteStream());
|
||||
return retHeaders;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cpm.com.gskmtorange.utils
|
||||
|
||||
// ScoreItem.kt
|
||||
sealed class ScoreItem {
|
||||
data class OverallScore(
|
||||
val osa: String,
|
||||
val msl: String,
|
||||
val posm: String,
|
||||
val sosSku: String,
|
||||
val sosBrand: String
|
||||
) : ScoreItem()
|
||||
|
||||
data class CategoryScore(
|
||||
val categoryName: String,
|
||||
val msl: String,
|
||||
val posm: String,
|
||||
val sosSku: String,
|
||||
val sosBrand: String,
|
||||
val brandDetails: List<Pair<String, String>> // BrandName to Value
|
||||
) : ScoreItem()
|
||||
|
||||
data class ImageItem(
|
||||
val url: String
|
||||
) : ScoreItem()
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package cpm.com.gskmtorange.utils;
|
||||
|
||||
import javax.net.ssl.SSLSocket;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class TLSSocketFactory extends SSLSocketFactory {
|
||||
private final SSLSocketFactory delegate;
|
||||
|
||||
public TLSSocketFactory() {
|
||||
this.delegate = (SSLSocketFactory) SSLSocketFactory.getDefault();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getDefaultCipherSuites() {
|
||||
return delegate.getDefaultCipherSuites();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedCipherSuites() {
|
||||
return delegate.getSupportedCipherSuites();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException {
|
||||
return enableModernTLS(delegate.createSocket(s, host, port, autoClose));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Socket createSocket(String host, int port) throws IOException {
|
||||
return enableModernTLS(delegate.createSocket(host, port));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException {
|
||||
return enableModernTLS(delegate.createSocket(host, port, localHost, localPort));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Socket createSocket(InetAddress host, int port) throws IOException {
|
||||
return enableModernTLS(delegate.createSocket(host, port));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException {
|
||||
return enableModernTLS(delegate.createSocket(address, port, localAddress, localPort));
|
||||
}
|
||||
|
||||
private Socket enableModernTLS(Socket socket) {
|
||||
if (socket instanceof SSLSocket) {
|
||||
SSLSocket sslSocket = (SSLSocket) socket;
|
||||
|
||||
// Supported protocols on this device
|
||||
String[] supported = sslSocket.getSupportedProtocols();
|
||||
|
||||
// Collect TLSv1.2 and TLSv1.3 if available
|
||||
List<String> enabled = new ArrayList<>();
|
||||
for (String proto : supported) {
|
||||
if ("TLSv1.2".equals(proto) || "TLSv1.3".equals(proto)) {
|
||||
enabled.add(proto);
|
||||
}
|
||||
}
|
||||
|
||||
if (!enabled.isEmpty()) {
|
||||
sslSocket.setEnabledProtocols(enabled.toArray(new String[0]));
|
||||
}
|
||||
|
||||
// Debug log
|
||||
System.out.println("Enabled protocols: " + Arrays.toString(sslSocket.getEnabledProtocols()));
|
||||
}
|
||||
return socket;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user