diff --git a/GSKMTOrange/build.gradle b/GSKMTOrange/build.gradle index cabd1b3..a379ea0 100644 --- a/GSKMTOrange/build.gradle +++ b/GSKMTOrange/build.gradle @@ -39,4 +39,5 @@ dependencies { compile 'com.google.android.gms:play-services-location:9.0.2' compile 'com.google.android.gms:play-services-maps:9.0.2' compile 'com.android.support:cardview-v7:24.2.1' + compile 'com.google.android.gms:play-services-appindexing:9.0.2' } diff --git a/GSKMTOrange/src/main/AndroidManifest.xml b/GSKMTOrange/src/main/AndroidManifest.xml index 5dad14a..66efe35 100644 --- a/GSKMTOrange/src/main/AndroidManifest.xml +++ b/GSKMTOrange/src/main/AndroidManifest.xml @@ -18,6 +18,7 @@ android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> + + + - + + + android:name=".gsk_dailyentry.CategoryListActivity" + android:configChanges="screenSize|orientation|keyboardHidden" + android:theme="@style/AppTheme.NoActionBar" + android:windowSoftInputMode="adjustPan" /> + + + + + + + + + + + + + + + @@ -66,7 +106,12 @@ android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> + + - \ No newline at end of file diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/Database/GSKOrangeDB.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/Database/GSKOrangeDB.java index e7fff1a..3ced97d 100644 --- a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/Database/GSKOrangeDB.java +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/Database/GSKOrangeDB.java @@ -1,4 +1,4 @@ -package cpm.com.gskmtorange.database; +package cpm.com.gskmtorange.Database; import android.content.ContentValues; import android.content.Context; @@ -9,32 +9,40 @@ import android.util.Log; import java.util.ArrayList; -import cpm.com.gskmtorange.gettersetter.StoreBean; + +import cpm.com.gskmtorange.GetterSetter.CoverageBean; +import cpm.com.gskmtorange.GetterSetter.GeotaggingBeans; +import cpm.com.gskmtorange.GetterSetter.StoreBean; import cpm.com.gskmtorange.xmlGetterSetter.JourneyPlanGetterSetter; import cpm.com.gskmtorange.xmlGetterSetter.TableBean; +import cpm.com.gskmtorange.constant.CommonString; +import cpm.com.gskmtorange.xmlGetterSetter.BrandMasterGetterSetter; +import cpm.com.gskmtorange.xmlGetterSetter.CategoryMasterGetterSetter; +import cpm.com.gskmtorange.xmlGetterSetter.DisplayMasterGetterSetter; +import cpm.com.gskmtorange.xmlGetterSetter.MAPPINGT2PGetterSetter; +import cpm.com.gskmtorange.xmlGetterSetter.MappingStockGetterSetter; +import cpm.com.gskmtorange.xmlGetterSetter.SkuMasterGetterSetter; +import cpm.com.gskmtorange.xmlGetterSetter.SubCategoryMasterGetterSetter; + + /** * Created by ashishc on 29-12-2016. */ -public class GSKOrangeDB extends SQLiteOpenHelper{ - - - public static final String DATABASE_NAME = "GSK_ORANGE"; - public static final int DATABASE_VERSION = 13; - private SQLiteDatabase db; - TableBean tableBean; - +public class GSKOrangeDB extends SQLiteOpenHelper { + public static final String DATABASE_NAME = "GSK_ORANGE"; + public static final int DATABASE_VERSION = 13; + private SQLiteDatabase db; + TableBean tableBean; public GSKOrangeDB(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); - } public void open() { try { - db = this.getWritableDatabase(); } catch (Exception e) { e.printStackTrace(); @@ -45,37 +53,37 @@ public class GSKOrangeDB extends SQLiteOpenHelper{ public void onCreate(SQLiteDatabase db) { db.execSQL(TableBean.getJourneyPlan()); + db.execSQL(TableBean.getBrandMaster()); + db.execSQL(TableBean.getSkuMaster()); + db.execSQL(TableBean.getCategoryMaster()); + db.execSQL(TableBean.getSubCategoryMaster()); + db.execSQL(TableBean.getDisplayMaster()); + db.execSQL(TableBean.getMappingStock()); + db.execSQL(TableBean.getMappingT2p()); + db.execSQL(CommonString.CREATE_TABLE_STORE_GEOTAGGING); + db.execSQL(CommonString.CREATE_TABLE_COVERAGE_DATA); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - db.execSQL("DROP TABLE IF EXISTS " + TableBean.getJourneyPlan()); - } - public void deleteTableWithStoreID(String storeid, String process_id){ - + public void deleteTableWithStoreID(String storeid, String process_id) { } - public void deleteAllTables(){ + public void deleteAllTables() { } - - - - public void InsertJCP(JourneyPlanGetterSetter data) { - db.delete("JOURNEY_PLAN", null, null); ContentValues values = new ContentValues(); - try { for (int i = 0; i < data.getSTORE_ID().size(); i++) { @@ -115,21 +123,11 @@ public class GSKOrangeDB extends SQLiteOpenHelper{ } - } - catch (Exception ex) { + } catch (Exception ex) { Log.d("Exception in JCP", ex.toString()); } } - - - - - - - - - public ArrayList getStoreData(String date) { @@ -208,6 +206,196 @@ public class GSKOrangeDB extends SQLiteOpenHelper{ return list; } + //Gagan Goel + public void InsertCategory(CategoryMasterGetterSetter data) { + db.delete("CATEGORY_MASTER", null, null); + + ContentValues values = new ContentValues(); + try { + for (int i = 0; i < data.getCATEGORY_ID().size(); i++) { + + values.put("CATEGORY_ID", data.getCATEGORY_ID().get(i)); + values.put("CATEGORY", data.getCATEGORY().get(i)); + values.put("CATEGORY_SEQUENCE", data.getCATEGORY_SEQUENCE().get(i)); + + db.insert("CATEGORY_MASTER", null, values); + } + } catch (Exception ex) { + Log.d("Exception ", " in CATEGORY_MASTER " + ex.toString()); + } + } + + public void InsertMappingStock(MappingStockGetterSetter data) { + db.delete("MAPPING_STOCK", null, null); + + ContentValues values = new ContentValues(); + try { + for (int i = 0; i < data.getKEYACCOUNT_ID().size(); i++) { + + values.put("KEYACCOUNT_ID", data.getKEYACCOUNT_ID().get(i)); + values.put("STORETYPE_ID", data.getSTORETYPE_ID().get(i)); + values.put("CLASS_ID", data.getCLASS_ID().get(i)); + values.put("SKU_ID", data.getSKU_ID().get(i)); + values.put("MUST_HAVE", data.getMUST_HAVE().get(i)); + values.put("MBQ", data.getMBQ().get(i)); + + db.insert("MAPPING_STOCK", null, values); + } + } catch (Exception ex) { + Log.d("Exception ", " in MAPPING_STOCK " + ex.toString()); + } + } + + public void InsertSubCategoryMaster(SubCategoryMasterGetterSetter data) { + db.delete("SUB_CATEGORY_MASTER", null, null); + + ContentValues values = new ContentValues(); + try { + for (int i = 0; i < data.getSUB_CATEGORY_ID().size(); i++) { + + values.put("SUB_CATEGORY_ID", data.getSUB_CATEGORY_ID().get(i)); + values.put("SUB_CATEGORY", data.getSUB_CATEGORY().get(i)); + values.put("CATEGORY_ID", data.getCATEGORY_ID().get(i)); + values.put("SUB_CATEGORY_SEQUENCE", data.getSUB_CATEGORY_SEQUENCE().get(i)); + + db.insert("SUB_CATEGORY_MASTER", null, values); + } + } catch (Exception ex) { + Log.d("Exception ", " in MAPPING_STOCK " + ex.toString()); + } + } + + public void InsertBrandMaster(BrandMasterGetterSetter data) { + db.delete("BRAND_MASTER", null, null); + + ContentValues values = new ContentValues(); + try { + for (int i = 0; i < data.getBRAND_ID().size(); i++) { + + values.put("BRAND_ID", data.getBRAND_ID().get(i)); + values.put("BRAND", data.getBRAND().get(i)); + values.put("SUB_CATEGORY_ID", data.getSUB_CATEGORY_ID().get(i)); + values.put("COMPANY_ID", data.getCOMPANY_ID().get(i)); + values.put("BRAND_SEQUENCE", data.getBRAND_SEQUENCE().get(i)); + + db.insert("BRAND_MASTER", null, values); + } + } catch (Exception ex) { + Log.d("Exception ", " in BRAND_MASTER " + ex.toString()); + } + } + + public void InsertSkuMaster(SkuMasterGetterSetter data) { + db.delete("SKU_MASTER", null, null); + + ContentValues values = new ContentValues(); + try { + for (int i = 0; i < data.getSKU_ID().size(); i++) { + + values.put("SKU_ID", data.getSKU_ID().get(i)); + values.put("SKU", data.getSKU().get(i)); + values.put("BRAND_ID", data.getBRAND_ID().get(i)); + values.put("MRP", data.getMRP().get(i)); + values.put("SKU_SEQUENCE", data.getSKU_SEQUENCE().get(i)); + + db.insert("SKU_MASTER", null, values); + } + } catch (Exception ex) { + Log.d("Exception ", " in SKU_MASTER " + ex.toString()); + } + } + + public void InsertDisplayMaster(DisplayMasterGetterSetter data) { + db.delete("DISPLAY_MASTER", null, null); + + ContentValues values = new ContentValues(); + try { + for (int i = 0; i < data.getDISPLAY_ID().size(); i++) { + + values.put("DISPLAY_ID", data.getDISPLAY_ID().get(i)); + values.put("DISPLAY", data.getDISPLAY().get(i)); + values.put("IMAGE_URL", data.getIMAGE_URL().get(i)); + + db.insert("DISPLAY_MASTER", null, values); + } + } catch (Exception ex) { + Log.d("Exception ", " in DISPLAY_MASTER " + ex.toString()); + } + } + + public void InsertMAPPING_T2P(MAPPINGT2PGetterSetter data) { + db.delete("MAPPING_T2P", null, null); + + ContentValues values = new ContentValues(); + try { + for (int i = 0; i < data.getSTORE_ID().size(); i++) { + + values.put("STORE_ID", data.getSTORE_ID().get(i)); + values.put("BRAND_ID", data.getBRAND_ID().get(i)); + values.put("DISPLAY_ID", data.getDISPLAY_ID().get(i)); + + db.insert("MAPPING_T2P", null, values); + } + } catch (Exception ex) { + Log.d("Exception ", " in MAPPING_T2P " + ex.toString()); + } + } + + public void InsertSTOREgeotag(String storeid, double lat, double longitude, String path,String status) { + + ContentValues values = new ContentValues(); + + try { + + values.put("STORE_ID", storeid); + values.put("LATITUDE", Double.toString(lat)); + values.put("LONGITUDE", Double.toString(longitude)); + values.put("FRONT_IMAGE", path); + values.put("GEO_TAG", status); + values.put("STATUS", status); + + db.insert(CommonString.TABLE_STORE_GEOTAGGING, null, values); + + } catch (Exception ex) { + Log.d("Database Exception ", ex.toString()); + } + + } + + public void updateStatus(String id, String status, double lat, double longtitude) { + + ContentValues values = new ContentValues(); + + try { + + values.put("GEO_TAG", status); + + db.update(CommonString.KEY_JOURNEY_PLAN, values, CommonString.KEY_STORE_ID + "='" + id + "'", null); + + } catch (Exception ex) { + + } + + } + + + + + public void updateCheckoutStatus(String id, String status) { + + ContentValues values = new ContentValues(); + + try { + + values.put("CHECKOUT_STATUS", status); + + db.update(CommonString.KEY_JOURNEY_PLAN, values, CommonString.KEY_STORE_ID + "='" + id + "'", null); + + } catch (Exception ex) { + + } + + } @@ -217,4 +405,194 @@ public class GSKOrangeDB extends SQLiteOpenHelper{ + + public ArrayList getinsertGeotaggingData(String status) { + + + ArrayList geodata = new ArrayList(); + + Cursor dbcursor = null; + + try { + dbcursor = db.rawQuery("SELECT * from " + CommonString.TABLE_STORE_GEOTAGGING + " WHERE GEO_TAG = '" + status + "'", null); + + if (dbcursor != null) { + int numrows = dbcursor.getCount(); + + dbcursor.moveToFirst(); + for (int i = 1; i <= numrows; ++i) { + + GeotaggingBeans data = new GeotaggingBeans(); + + data.setStoreid(dbcursor.getString(dbcursor.getColumnIndexOrThrow("STORE_ID"))); + data.setLatitude(Double.parseDouble(dbcursor.getString(dbcursor.getColumnIndexOrThrow("LATITUDE")))); + data.setLongitude(Double.parseDouble(dbcursor.getString(dbcursor.getColumnIndexOrThrow("LONGITUDE")))); + data.setUrl1(dbcursor.getString(dbcursor.getColumnIndexOrThrow("FRONT_IMAGE"))); + + geodata.add(data); + dbcursor.moveToNext(); + } + + dbcursor.close(); + + } + + } catch (Exception e) { + + } + finally { + if (dbcursor != null && !dbcursor.isClosed()) { + dbcursor.close(); + } + } + + + return geodata; + + } + + + public void updateGeoTagData(String storeid,String status) { + + try { + + ContentValues values = new ContentValues(); + values.put("GEO_TAG", status); + + int l = db.update(CommonString.TABLE_STORE_GEOTAGGING, values, + CommonString.KEY_STORE_ID + "=?", new String[] { storeid }); + System.out.println("update : " + l); + } catch (Exception e) { + Log.d("Database Data ", e.toString()); + + } + } + + public void updateDataStatus(String id,String status) { + + ContentValues values = new ContentValues(); + + try { + + values.put("GEO_TAG", status); + + db.update(CommonString.KEY_JOURNEY_PLAN, values, + CommonString.KEY_STORE_ID + "='" + id + "'", null); + + } catch (Exception ex) { + + } + + } + + + public void deleteGeoTagData(String storeid) { + + try { + db.delete(CommonString.TABLE_STORE_GEOTAGGING, CommonString.KEY_STORE_ID + "='" + storeid + "'", null); + } catch (Exception e) { + + } + } + + public ArrayList getCoverageData(String visitdate) { + + ArrayList list = new ArrayList(); + Cursor dbcursor = null; + + try { + + dbcursor = db.rawQuery("SELECT * from " + CommonString.TABLE_COVERAGE_DATA + " where " + + CommonString.KEY_VISIT_DATE + "='" + visitdate + "'", + null); + + + if (dbcursor != null) { + + dbcursor.moveToFirst(); + while (!dbcursor.isAfterLast()) { + CoverageBean sb = new CoverageBean(); + + sb.setStoreId(dbcursor.getString(dbcursor + .getColumnIndexOrThrow(CommonString.KEY_STORE_ID))); + sb.setUserId((dbcursor.getString(dbcursor + .getColumnIndexOrThrow(CommonString.KEY_USER_ID)))); + sb.setInTime(((dbcursor.getString(dbcursor + .getColumnIndexOrThrow(CommonString.KEY_IN_TIME))))); + sb.setOutTime(((dbcursor.getString(dbcursor + .getColumnIndexOrThrow(CommonString.KEY_OUT_TIME))))); + sb.setVisitDate((((dbcursor.getString(dbcursor + .getColumnIndexOrThrow(CommonString.KEY_VISIT_DATE)))))); + sb.setLatitude(((dbcursor.getString(dbcursor + .getColumnIndexOrThrow(CommonString.KEY_LATITUDE))))); + sb.setLongitude(((dbcursor.getString(dbcursor + .getColumnIndexOrThrow(CommonString.KEY_LONGITUDE))))); + sb.setStatus((((dbcursor.getString(dbcursor + .getColumnIndexOrThrow(CommonString.KEY_COVERAGE_STATUS)))))); + sb.setImage((((dbcursor.getString(dbcursor + .getColumnIndexOrThrow(CommonString.KEY_IMAGE)))))); + sb.setReason((((dbcursor.getString(dbcursor + .getColumnIndexOrThrow(CommonString.KEY_REASON)))))); + sb.setReasonid((((dbcursor.getString(dbcursor + .getColumnIndexOrThrow(CommonString.KEY_REASON_ID)))))); + sb.setMID(Integer.parseInt(((dbcursor.getString(dbcursor + .getColumnIndexOrThrow(CommonString.KEY_ID)))))); + if(dbcursor.getString(dbcursor + .getColumnIndexOrThrow(CommonString.KEY_COVERAGE_REMARK))==null){ + sb.setRemark(""); + } + else{ + sb.setRemark((((dbcursor.getString(dbcursor + .getColumnIndexOrThrow(CommonString.KEY_COVERAGE_REMARK)))))); + } + + list.add(sb); + dbcursor.moveToNext(); + } + dbcursor.close(); + return list; + } + + } catch (Exception e) { + Log.d("Exception ", e.toString()); + + } + + return list; + + } + + public long InsertCoverageData(CoverageBean data) { + + //db.delete(CommonString1.TABLE_COVERAGE_DATA, "STORE_ID" + "='" + data.getStoreId() + "'", null); + + ContentValues values = new ContentValues(); + + try { + + values.put(CommonString.KEY_STORE_ID, data.getStoreId()); + values.put(CommonString.KEY_USER_ID, data.getUserId()); + values.put(CommonString.KEY_IN_TIME, data.getInTime()); + values.put(CommonString.KEY_OUT_TIME, data.getOutTime()); + values.put(CommonString.KEY_VISIT_DATE, data.getVisitDate()); + values.put(CommonString.KEY_LATITUDE, data.getLatitude()); + values.put(CommonString.KEY_LONGITUDE, data.getLongitude()); + values.put(CommonString.KEY_REASON_ID, data.getReasonid()); + values.put(CommonString.KEY_REASON, data.getReason()); + values.put(CommonString.KEY_COVERAGE_STATUS, data.getStatus()); + values.put(CommonString.KEY_IMAGE, data.getImage()); + values.put(CommonString.KEY_COVERAGE_REMARK, data.getRemark()); + values.put(CommonString.KEY_REASON_ID, data.getReasonid()); + values.put(CommonString.KEY_REASON, data.getReason()); + values.put(CommonString.KEY_GEO_TAG, data.getGEO_TAG()); + + return db.insert(CommonString.TABLE_COVERAGE_DATA, null, values); + + } catch (Exception ex) { + Log.d("Database Exception ", ex.toString()); + } + return 0; + } + + } diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/GeoTag/GeoTagActivity.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/GeoTag/GeoTagActivity.java index e815df5..483b1e7 100644 --- a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/GeoTag/GeoTagActivity.java +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/GeoTag/GeoTagActivity.java @@ -1,24 +1,44 @@ -package cpm.com.gskmtorange.geotag; +package cpm.com.gskmtorange.GeoTag; +import android.Manifest; import android.app.AlertDialog; +import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; +import android.content.res.ColorStateList; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Color; import android.location.Geocoder; import android.location.Location; import android.location.LocationManager; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Build; import android.os.Bundle; +import android.os.Environment; import android.preference.PreferenceManager; +import android.provider.MediaStore; import android.provider.Settings; import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; + import android.util.Log; +import android.view.View; +import android.widget.ProgressBar; +import android.widget.TextView; import android.widget.Toast; +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; @@ -32,31 +52,59 @@ import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MarkerOptions; +import org.ksoap2.SoapEnvelope; +import org.ksoap2.serialization.SoapObject; +import org.ksoap2.serialization.SoapSerializationEnvelope; +import org.ksoap2.transport.HttpTransportSE; +import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.StringReader; +import java.net.SocketException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + import cpm.com.gskmtorange.R; import cpm.com.gskmtorange.constant.CommonString; -import cpm.com.gskmtorange.database.GSKOrangeDB; +import cpm.com.gskmtorange.Database.GSKOrangeDB; +import cpm.com.gskmtorange.GetterSetter.GeotaggingBeans; +import cpm.com.gskmtorange.messgae.AlertMessage; +import cpm.com.gskmtorange.upload.Base64; +import cpm.com.gskmtorange.xmlGetterSetter.FailureGetterSetter; +import cpm.com.gskmtorange.xmlHandlers.FailureXMLHandler; /** * Created by ashishc on 27-12-2016. */ -public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCallback,GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener -{ +public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener { + + String result, errormsg = ""; + ; + private ProgressBar pb; private GoogleMap mMap; - double latitude =0.0; - double longitude =0.0; - + double latitude = 0.0; + double longitude = 0.0; + protected String diskpath = "", _path, _pathforcheck, img_str = "", status; private Location mLastLocation; private LocationManager locmanager = null; - FloatingActionButton fab,fabcarmabtn; + FloatingActionButton fab, fabcarmabtn; SupportMapFragment mapFragment; SharedPreferences preferences; - String username,storeid,str; + String username, storeid, str, storename, visitData; GSKOrangeDB db; LocationManager locationManager; Geocoder geocoder; boolean enabled; + private Dialog dialog; private final static int PLAY_SERVICES_RESOLUTION_REQUEST = 1000; private GoogleApiClient mGoogleApiClient; private LocationRequest mLocationRequest; @@ -64,7 +112,17 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCa private static int FATEST_INTERVAL = 100; // 1 sec private static int DISPLACEMENT = 5; // 10 meters private static final String TAG = GeoTagActivity.class.getSimpleName(); - + String defaultCameraPackage = ""; + File file; + private int factor, k; + ArrayList geotaglist = new ArrayList(); + private TextView percentage, message; + private FailureGetterSetter failureGetterSetter = null; + /** + * ATTENTION: This was auto-generated to implement the App Indexing API. + * See https://g.co/AppIndexing/AndroidStudio for more information. + */ + private GoogleApiClient client; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -72,9 +130,14 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCa Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); preferences = PreferenceManager.getDefaultSharedPreferences(this); - username = preferences.getString(CommonString.KEY_USERNAME, null); + username = preferences.getString(CommonString.KEY_USERNAME, null); + storeid = preferences.getString(CommonString.KEY_STORE_ID, null); + storename = preferences.getString(CommonString.KEY_STORE_NAME, null); + visitData = preferences.getString(CommonString.KEY_VISIT_DATE, null); + final PackageManager packageManager = getPackageManager(); + fab = (FloatingActionButton) findViewById(R.id.fab); fabcarmabtn = (FloatingActionButton) findViewById(R.id.camrabtn); @@ -82,19 +145,14 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCa db = new GSKOrangeDB(GeoTagActivity.this); db.open(); - - - storeid = getIntent().getStringExtra("Storeid"); + //storeid = getIntent().getStringExtra("Storeid"); str = CommonString.FILE_PATH; - - mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); + mapFragment.getMapAsync(this); - - locationManager = (LocationManager) this .getSystemService(LOCATION_SERVICE); geocoder = new Geocoder(this); @@ -108,7 +166,6 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCa } - if (checkPlayServices()) { // Building the GoogleApi client @@ -117,14 +174,10 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCa createLocationRequest(); } - locmanager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); enabled = locmanager.isProviderEnabled(LocationManager.GPS_PROVIDER); - - if (!enabled) { - AlertDialog.Builder alertDialog = new AlertDialog.Builder( GeoTagActivity.this); @@ -161,11 +214,57 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCa } + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (!img_str.equalsIgnoreCase("")) { + status = "Y"; + db.updateStatus(storeid, status, latitude, longitude); + db.InsertSTOREgeotag(storeid, latitude, longitude, img_str, status); + img_str = ""; + + new GeoTagUpload(GeoTagActivity.this).execute(); + + + } else { + Snackbar.make(view, "Please Take Image Before Save", Snackbar.LENGTH_LONG).setAction("Action", null).show(); + + + } + + } + }); + + fabcarmabtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + List list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES); + for (int n = 0; n < list.size(); n++) { + if ((list.get(n).flags & ApplicationInfo.FLAG_SYSTEM) == 1) { + Log.d("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString()); + Log.d("TAG", "package name : " + list.get(n).packageName); + if (list.get(n).loadLabel(packageManager).toString().equalsIgnoreCase("Camera")) { + defaultCameraPackage = list.get(n).packageName; + break; + } + } + } + + _pathforcheck = storeid + "Store" + "Image" + getCurrentTime().replace(":", "") + ".jpg"; + + _path = CommonString.FILE_PATH + _pathforcheck; + + + startCameraActivity(); + + } + }); + // ATTENTION: This was auto-generated to implement the App Indexing API. + // See https://g.co/AppIndexing/AndroidStudio for more information. + client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); } - - private boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil .isGooglePlayServicesAvailable(this); @@ -203,8 +302,8 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCa protected void startLocationUpdates() { - if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED - || ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { + 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); @@ -225,8 +324,8 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCa mLastLocation = LocationServices.FusedLocationApi .getLastLocation(mGoogleApiClient); - if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED - || ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { + 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(); @@ -255,12 +354,12 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCa } @Override - public void onLocationChanged (Location location){ + public void onLocationChanged(Location location) { } @Override - public void onConnectionFailed (ConnectionResult connectionResult) { + public void onConnectionFailed(ConnectionResult connectionResult) { Log.i(TAG, "Connection failed: ConnectionResult.getErrorCode() = " + connectionResult.getErrorCode()); } @@ -270,10 +369,15 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCa } protected void onStart() { - super.onStart(); + super.onStart();// ATTENTION: This was auto-generated to implement the App Indexing API. +// See https://g.co/AppIndexing/AndroidStudio for more information. + client.connect(); if (mGoogleApiClient != null) { mGoogleApiClient.connect(); } + // ATTENTION: This was auto-generated to implement the App Indexing API. + // See https://g.co/AppIndexing/AndroidStudio for more information. + AppIndex.AppIndexApi.start(client, getIndexApiAction()); } @Override @@ -290,10 +394,15 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCa @Override protected void onStop() { - super.onStop(); + super.onStop();// ATTENTION: This was auto-generated to implement the App Indexing API. +// See https://g.co/AppIndexing/AndroidStudio for more information. + AppIndex.AppIndexApi.end(client, getIndexApiAction()); if (mGoogleApiClient.isConnected()) { mGoogleApiClient.disconnect(); } + // ATTENTION: This was auto-generated to implement the App Indexing API. + // See https://g.co/AppIndexing/AndroidStudio for more information. + client.disconnect(); } @Override @@ -302,7 +411,586 @@ public class GeoTagActivity extends AppCompatActivity implements OnMapReadyCa stopLocationUpdates(); } + public String getCurrentTime() { + Calendar m_cal = Calendar.getInstance(); + + SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss:mmm"); + String cdate = formatter.format(m_cal.getTime()); + + /* String intime = m_cal.get(Calendar.HOUR_OF_DAY) + ":" + + m_cal.get(Calendar.MINUTE) + ":" + m_cal.get(Calendar.SECOND);*/ + + return cdate; + + } + + protected void startCameraActivity() { + /* Log.i("MakeMachine", "startCameraActivity()"); + file = new File(_path); + Uri outputFileUri = Uri.fromFile(file); + + + Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); + + + takePictureIntent.setPackage(defaultCameraPackage); + + takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); + + startActivityForResult(takePictureIntent, 1);*/ + + Log.i("MakeMachine", "startCameraActivity()"); + File file = new File(_path); + Uri outputFileUri = Uri.fromFile(file); + + String defaultCameraPackage=""; + final PackageManager packageManager = getPackageManager(); + List list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES); + for (int n=0;n= Build.VERSION_CODES.KITKAT) { + if (list.get(n).loadLabel(packageManager).toString().equalsIgnoreCase("Camera")) { + defaultCameraPackage = list.get(n).packageName; + break; + } + } else { + if (list.get(n).loadLabel(packageManager).toString().equalsIgnoreCase("Gallery")) { + defaultCameraPackage = list.get(n).packageName; + break; + } + } + } + + } + + Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); + + + takePictureIntent.setPackage(defaultCameraPackage); + + takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); + + startActivityForResult(takePictureIntent, 1); + + + } + + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + + Log.i("MakeMachine", "resultCode: " + resultCode); + switch (resultCode) { + case 0: + Log.i("MakeMachine", "User cancelled"); + break; + + case -1: + + if (_pathforcheck != null && !_pathforcheck.equals("")) { + if (new File(str + _pathforcheck).exists()) { + + + fabcarmabtn.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.mipmap.camera_icon_done)); + + fabcarmabtn.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#4DB6AC"))); + + img_str = _pathforcheck; + _pathforcheck = ""; + + } + } + + break; + } + + super.onActivityResult(requestCode, resultCode, data); + } + + /** + * 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(); + } + + + public class GeoTagUpload extends AsyncTask { + + private Context context; + + GeoTagUpload(Context context) { + this.context = context; + } + + @Override + protected void onPreExecute() { + + super.onPreExecute(); + + dialog = new Dialog(context); + dialog.setContentView(R.layout.custom); + dialog.setTitle("Uploading Data"); + dialog.setCancelable(false); + dialog.show(); + pb = (ProgressBar) dialog.findViewById(R.id.progressBar1); + percentage = (TextView) dialog.findViewById(R.id.percentage); + message = (TextView) dialog.findViewById(R.id.message); + } + + @Override + protected String doInBackground(Void... params) { + try { + + GSKOrangeDB db = new GSKOrangeDB(GeoTagActivity.this); + db.open(); + + geotaglist = db.getinsertGeotaggingData("Y"); + + // uploading Geotag + + SAXParserFactory saxPF = SAXParserFactory.newInstance(); + SAXParser saxP = saxPF.newSAXParser(); + XMLReader xmlR = saxP.getXMLReader(); + + + String geo_xml = ""; + ArrayList geotemplist = new ArrayList(); + if (geotaglist.size() > 0) { + + for (int i = 0; i < geotaglist.size(); i++) { + + runOnUiThread(new Runnable() { + public void run() { + // TODO Auto-generated method stub + k = k + factor; + pb.setProgress(k); + percentage.setText(k + "%"); + message.setText("Uploading Geotag Data..."); + } + }); + + String onXML = "[GeoTag_DATA][STORE_ID]" + + geotaglist.get(i).getStoreid() + + "[/STORE_ID]" + + "[LATTITUDE]" + + geotaglist.get(i).getLatitude() + + "[/LATTITUDE]" + + "[LONGITUDE]" + + geotaglist.get(i).getLongitude() + + "[/LONGITUDE]" + + "[FRONT_IMAGE]" + + geotaglist.get(i).getUrl1() + + "[/FRONT_IMAGE]" + + "[CREATED_BY]" + username + + "[/CREATED_BY][/GeoTag_DATA]"; + + geo_xml = geo_xml + onXML; + + geotemplist.add(geotaglist.get(i).getStoreid()); + + } + + geo_xml = "[DATA]" + geo_xml + + "[/DATA]"; + + SoapObject request = new SoapObject(CommonString.NAMESPACE, + CommonString.METHOD_UPLOAD_STOCK_XML_DATA); + request.addProperty("MID", "0"); + request.addProperty("KEYS", "GEOTAG_NEW_DATA"); + request.addProperty("USERNAME", username); + + request.addProperty("XMLDATA", geo_xml); + + SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( + SoapEnvelope.VER11); + envelope.dotNet = true; + envelope.setOutputSoapObject(request); + + HttpTransportSE androidHttpTransport = new HttpTransportSE( + CommonString.URL); + androidHttpTransport.call( + CommonString.SOAP_ACTION_UPLOAD_ASSET_XMLDATA, envelope); + Object result = (Object) envelope.getResponse(); + + if (result.toString().equalsIgnoreCase( + CommonString.KEY_SUCCESS)) { + String statusD = "D"; + + for (int i = 0; i < geotemplist.size(); i++) { + db.updateGeoTagData(geotemplist.get(i).toString(), statusD); + + db.updateDataStatus(geotemplist.get(i).toString(), statusD); + + } + + } else { + + if (result.toString().equalsIgnoreCase( + CommonString.KEY_FALSE)) { + return CommonString.METHOD_UPLOAD_ASSET; + } + + // for failure + FailureXMLHandler failureXMLHandler = new FailureXMLHandler(); + xmlR.setContentHandler(failureXMLHandler); + + InputSource is = new InputSource(); + is.setCharacterStream(new StringReader(result + .toString())); + xmlR.parse(is); + + failureGetterSetter = failureXMLHandler + .getFailureGetterSetter(); + + if (failureGetterSetter.getStatus().equalsIgnoreCase( + CommonString.KEY_FAILURE)) { + return CommonString.METHOD_UPLOAD_ASSET + "," + + failureGetterSetter.getErrorMsg(); + + } else { + + } + } + } + + + return CommonString.KEY_SUCCESS; + + } catch (SocketException ex) { + ex.printStackTrace(); + + + } catch (Exception ex) { + + + ex.printStackTrace(); + } + + + return ""; + + } + + + @Override + protected void onPostExecute(String result) { + super.onPostExecute(result); + + dialog.dismiss(); + + if (result.equals(CommonString.KEY_SUCCESS)) { + + + new GeoTagImageUpload(GeoTagActivity.this).execute(); + + Intent intent = new Intent( + GeoTagActivity.this, + GeoTagStoreList.class); + + startActivity(intent); + + GeoTagActivity.this.finish(); + + } + else if(!result.equals(CommonString.KEY_SUCCESS)) + { + + AlertMessage message = new AlertMessage( + GeoTagActivity.this, AlertMessage.MESSAGE_DATA_NOT + + result, "failure", null); + message.showMessage(); + + + } + + else if (!result.equals("")) { + + + } + + } + + } + + public class GeoTagImageUpload extends AsyncTask { + + private Context context; + + GeoTagImageUpload(Context context) { + this.context = context; + } + + @Override + protected void onPreExecute() { + + super.onPreExecute(); + + dialog = new Dialog(context); + dialog.setContentView(R.layout.custom); + dialog.setTitle("Uploading Geotag Images"); + dialog.setCancelable(false); + dialog.show(); + pb = (ProgressBar) dialog.findViewById(R.id.progressBar1); + percentage = (TextView) dialog.findViewById(R.id.percentage); + message = (TextView) dialog.findViewById(R.id.message); + } + + + @Override + protected String doInBackground(Void... params) { + try { + + GSKOrangeDB db = new GSKOrangeDB(GeoTagActivity.this); + db.open(); + + + geotaglist = db.getinsertGeotaggingData("D"); + + // Uploading Geotag + + SAXParserFactory saxPF = SAXParserFactory.newInstance(); + SAXParser saxP = saxPF.newSAXParser(); + XMLReader xmlR = saxP.getXMLReader(); + + + if (geotaglist.size() > 0) { + + for (int i = 0; i < geotaglist.size(); i++) { + + runOnUiThread(new Runnable() { + + public void run() { + // TODO Auto-generated method stub + k = k + factor; + pb.setProgress(k); + percentage.setText(k + "%"); + message.setText("Uploading Geotag Images..."); + } + }); + + if (geotaglist.get(i).getUrl1() != null + && !geotaglist.get(i).getUrl1() + .equalsIgnoreCase("")) { + + if (new File(Environment.getExternalStorageDirectory() + "/GSK_MT_Images/" + + geotaglist.get(i).getUrl1()).exists()) { + result = UploadGeoImage(geotaglist.get(i).getUrl1(), "GeoTag"); + + + if (!result.toString().equalsIgnoreCase(CommonString.KEY_SUCCESS)) { + + return "GeoTag"; + } + + + if (result.toString().equalsIgnoreCase(CommonString.KEY_FALSE)) { + + return CommonString.METHOD_Get_DR_STORE_IMAGES_GEO; + } else if (result + .equalsIgnoreCase(CommonString.KEY_FAILURE)) { + + return CommonString.METHOD_Get_DR_STORE_IMAGES_GEO + "," + errormsg; + } + + + + /* runOnUiThread(new Runnable() { + + public void run() { + // TODO Auto-generated method stub + + message.setText("Image1 Upload"); + } + });*/ + } + } + + +// for(int i =0 ; i < geotaglist.size(); i++){ + +// } + + + } + + + } + + + return CommonString.KEY_SUCCESS; + + } + catch (SocketException ex) { + + ex.printStackTrace(); + } + + catch (Exception ex) { + ex.printStackTrace(); + + } + + return ""; + + } + + + @Override + protected void onPostExecute(String result) { + super.onPostExecute(result); + + dialog.dismiss(); + + if (result.equalsIgnoreCase(CommonString.KEY_SUCCESS)) { + + + //Toast.makeText(getApplicationContext(),"GeoTag Uploaded ",Toast.LENGTH_LONG).show(); + + String Statustag = "U"; + db.open(); + + for (int i = 0; i < geotaglist.size(); i++) { + + + db.updateGeoTagData(geotaglist.get(i).getStoreid(), Statustag); + + db.updateDataStatus(geotaglist.get(i).getStoreid(), Statustag); + + // db.updateGeoTagDataInMain(geotaglist.get(i).getStoreid()); + + db.deleteGeoTagData(geotaglist.get(i).getStoreid()); + + + } + + + + AlertMessage message = new AlertMessage( + GeoTagActivity.this, AlertMessage.MESSAGE_ERROR + + result, "success", null); + message.showMessage(); + + + } + else if(!result.equals(CommonString.KEY_SUCCESS)) + { + + AlertMessage message = new AlertMessage( + GeoTagActivity.this, AlertMessage.MESSAGE_DATA_NOT + + result, "failure", null); + message.showMessage(); + + + } + + + + else if (!result.equals("")) { + + } + + } + + } + + public String UploadGeoImage(String path, String folder) throws Exception { + + errormsg = ""; + BitmapFactory.Options o = new BitmapFactory.Options(); + o.inJustDecodeBounds = true; + BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/GSK_MT_Images/" + path, o); + + // The new size we want to scale to + final int REQUIRED_SIZE = 1024; + + // Find the correct scale value. It should be the power of 2. + int width_tmp = o.outWidth, height_tmp = o.outHeight; + int scale = 1; + + while (true) { + if (width_tmp < REQUIRED_SIZE && height_tmp < REQUIRED_SIZE) + break; + width_tmp /= 2; + height_tmp /= 2; + scale *= 2; + } + + // Decode with inSampleSize + BitmapFactory.Options o2 = new BitmapFactory.Options(); + o2.inSampleSize = scale; + Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/GSK_MT_Images/" + path, o2); + + ByteArrayOutputStream bao = new ByteArrayOutputStream(); + bitmap.compress(Bitmap.CompressFormat.JPEG, 90, bao); + byte[] ba = bao.toByteArray(); + String ba1 = Base64.encodeBytes(ba); + + SoapObject request = new SoapObject(CommonString.NAMESPACE, + CommonString.METHOD_Get_DR_POSM_IMAGES); + + request.addProperty("img", ba1); + request.addProperty("name", path); + request.addProperty("FolderName", folder); + + SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( + SoapEnvelope.VER11); + envelope.dotNet = true; + envelope.setOutputSoapObject(request); + + HttpTransportSE androidHttpTransport = new HttpTransportSE( + CommonString.URL); + + androidHttpTransport.call( + CommonString.SOAP_ACTION_Get_DR_POSM_IMAGES, envelope); + Object result = (Object) envelope.getResponse(); + + if (result.toString().equalsIgnoreCase(CommonString.KEY_SUCCESS)) { + + new File(Environment.getExternalStorageDirectory() + "/GSK_MT_Images/" + path).delete(); + + + + /*SAXParserFactory saxPF = SAXParserFactory.newInstance(); + SAXParser saxP = saxPF.newSAXParser(); + XMLReader xmlR = saxP.getXMLReader(); + + // for failure + FailureXMLHandler failureXMLHandler = new FailureXMLHandler(); + xmlR.setContentHandler(failureXMLHandler); + + InputSource is = new InputSource(); + is.setCharacterStream(new StringReader(result.toString())); + xmlR.parse(is); + + failureGetterSetter = failureXMLHandler + .getFailureGetterSetter(); + + if (failureGetterSetter.getStatus().equalsIgnoreCase( + CommonString.KEY_FAILURE)) { + errormsg = failureGetterSetter.getErrorMsg(); + return CommonString.KEY_FAILURE; + }*/ + + } else if (result.toString().equalsIgnoreCase(CommonString.KEY_FALSE)) { + return CommonString.KEY_FALSE; + } else { + return CommonString.KEY_FAILURE; + } + + return result.toString(); + } } diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/GeoTag/GeoTagStoreList.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/GeoTag/GeoTagStoreList.java index 51a00f7..fe7ff0d 100644 --- a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/GeoTag/GeoTagStoreList.java +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/GeoTag/GeoTagStoreList.java @@ -1,31 +1,31 @@ -package cpm.com.gskmtorange.geotag; +package cpm.com.gskmtorange.GeoTag; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; +import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.BaseAdapter; -import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.ListView; import android.widget.RelativeLayout; import android.widget.TextView; -import android.widget.Toast; import java.util.ArrayList; +import java.util.Collections; +import java.util.List; -import cpm.com.gskmtorange.dailyentry.StoreListActivity; -import cpm.com.gskmtorange.database.GSKOrangeDB; -import cpm.com.gskmtorange.gettersetter.StoreBean; +import cpm.com.gskmtorange.MainActivity; +import cpm.com.gskmtorange.Database.GSKOrangeDB; +import cpm.com.gskmtorange.GetterSetter.StoreBean; import cpm.com.gskmtorange.R; import cpm.com.gskmtorange.constant.CommonString; @@ -33,30 +33,35 @@ import cpm.com.gskmtorange.constant.CommonString; * Created by ashishc on 27-12-2016. */ -public class GeoTagStoreList extends AppCompatActivity { +public class GeoTagStoreList extends AppCompatActivity implements View.OnClickListener { private SharedPreferences preferences; ArrayList storelist = new ArrayList(); String date,visit_status; GSKOrangeDB db; - ListView list; + // ListView list; + ValueAdapter adapter; + RecyclerView recyclerView; + private SharedPreferences.Editor editor = null; LinearLayout parent_linear,nodata_linear; protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.storelistlayout); - list = (ListView) findViewById(R.id.list_id); + //list = (ListView) findViewById(R.id.list_id); + + recyclerView=(RecyclerView) findViewById(R.id.drawer_layout_recycle); + // nodata_linear = (LinearLayout) findViewById(R.id.no_data_lay); //parent_linear = (LinearLayout) findViewById(R.id.parent_linear); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - preferences = PreferenceManager.getDefaultSharedPreferences(this); date = preferences.getString(CommonString.KEY_DATE, null); visit_status = preferences.getString(CommonString.KEY_STOREVISITED_STATUS, ""); @@ -64,41 +69,24 @@ public class GeoTagStoreList extends AppCompatActivity { db = new GSKOrangeDB(GeoTagStoreList.this); db.open(); - - list = (ListView)findViewById(R .id.list_id); - - storelist = db.getStoreData(date); - if (storelist.size()>0) { - list.setAdapter(new MyAdaptor()); + + adapter=new ValueAdapter(getApplicationContext(),storelist); + recyclerView.setAdapter(adapter); + recyclerView.setLayoutManager(new LinearLayoutManager(this)); + } + else + { - list.setOnItemClickListener(new AdapterView.OnItemClickListener() { - - @Override - public void onItemClick(AdapterView parent, View view, - int position, long id) { - - - Intent in =new Intent(GeoTagStoreList.this,GeoTagActivity.class); - - startActivity(in); - finish(); - - - Toast.makeText(getApplicationContext(),"Click",Toast.LENGTH_LONG).show(); - - - - } - }); - + } } +/* private class MyAdaptor extends BaseAdapter { @Override @@ -141,27 +129,20 @@ public class GeoTagStoreList extends AppCompatActivity { holder.storename.setText(storelist.get(position).getSTORE_NAME()); //holder.storeaddress.setText(storelist.get(position).getCITY()); - - - - - - - return convertView; } } +*/ - private class ViewHolder { + /*private class ViewHolder { TextView storename, storeaddress; ImageView imgtick; Button checkout; RelativeLayout l1; - } - + }*/ @Override public boolean onOptionsItemSelected(MenuItem item) { @@ -172,7 +153,7 @@ public class GeoTagStoreList extends AppCompatActivity { if(id==android.R.id.home){ - // NavUtils.navigateUpFromSameTask(this); + finish(); overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out); @@ -181,6 +162,234 @@ public class GeoTagStoreList extends AppCompatActivity { return super.onOptionsItemSelected(item); } + @Override + public void onBackPressed() { + // TODO Auto-generated method stub + Intent intent = new Intent(GeoTagStoreList.this, MainActivity.class); + + startActivity(intent); + GeoTagStoreList.this.finish(); + } + + + /*protected void onListItemClick(ListView l, View v, int position, long id) { + // TODO Auto-generated method stub + // super.onListItemClick(l, v, position, id); + + storelist = db.getStoreData(date); + StoreBean sb = storelist.get(position); + + // When clicked, show a toast with the TextView text + if (storelist.get(position).getGEO_TAG().equalsIgnoreCase("U")) { + + + Snackbar.make(v, R.string.title_geo_tag_activity_upload_data, Snackbar.LENGTH_LONG).setAction("Action", null).show(); + + + } else if (storelist.get(position).getGEO_TAG().equalsIgnoreCase("D")){ + + + Snackbar.make(v, R.string.title_geo_tag_activity_geo_data, Snackbar.LENGTH_LONG).setAction("Action", null).show(); + + + } + + else if (storelist.get(position).getGEO_TAG().equalsIgnoreCase("Y")) { + + + Snackbar.make(v, R.string.title_geo_tag_activity_geo_already_done, Snackbar.LENGTH_LONG).setAction("Action", null).show(); + + + + } else if (storelist.get(position).getGEO_TAG().equalsIgnoreCase("P")) { + + Snackbar.make(v, R.string.title_geo_tag_activity_geo_already_done, Snackbar.LENGTH_LONG).setAction("Action", null).show(); + + } else { + + // PUT IN PREFERENCES + editor = preferences.edit(); + editor.putString(CommonString.KEY_STORE_ID, sb.getSTORE_ID()); + editor.putString(CommonString.KEY_STORE_NAME, sb.getSTORE_NAME()); + editor.putString(CommonString.KEY_VISIT_DATE, sb.getVISIT_DATE()); + editor.commit(); + + Intent intent = new Intent(GeoTagStoreList.this, GeoTagActivity.class); + startActivity(intent); + GeoTagStoreList(); + } + } + + @Override + public void onClick(View arg0) { + // TODO Auto-generated method stub + + } + + + public void GeoTagStoreList() { + + this.finish(); + + }*/ + + public class ValueAdapter extends RecyclerView.Adapter{ + + private LayoutInflater inflator; + + List data= Collections.emptyList(); + + public ValueAdapter(Context context, List data){ + + inflator = LayoutInflater.from(context); + this.data=data; + + } + + @Override + public ValueAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int i) { + + View view=inflator.inflate(R.layout.geotagstorelist,parent,false); + + MyViewHolder holder=new MyViewHolder(view); + + return holder; + } + + @Override + public void onBindViewHolder(final ValueAdapter.MyViewHolder viewHolder, final int position) { + + final StoreBean current=data.get(position); + + //viewHolder.txt.setText(current.txt); + + viewHolder.txt.setText(current.getSTORE_NAME()); + + if(current.getGEO_TAG().equalsIgnoreCase("Y")) + { + viewHolder.imageview.setVisibility(View.VISIBLE); + viewHolder.imageview.setBackgroundResource(R.mipmap.geopin); + } + else if(current.getGEO_TAG().equalsIgnoreCase("D")){ + viewHolder.imageview.setVisibility(View.VISIBLE); + viewHolder.imageview.setBackgroundResource(R.mipmap.tick_d); + } + else if(current.getGEO_TAG().equalsIgnoreCase("U")){ + viewHolder.imageview.setVisibility(View.VISIBLE); + viewHolder.imageview.setBackgroundResource(R.mipmap.tick_u); + } + else if(current.getGEO_TAG().equalsIgnoreCase("P")){ + viewHolder.imageview.setVisibility(View.VISIBLE); + viewHolder.imageview.setBackgroundResource(R.mipmap.tick_p); + } + else + { + viewHolder.imageview.setVisibility(View.INVISIBLE); + } + + viewHolder.relativelayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + if(current.getGEO_TAG().equalsIgnoreCase("Y")) + { + Snackbar.make(v, R.string.title_geo_tag_activity_geo_already_done, Snackbar.LENGTH_LONG).setAction("Action", null).show(); + } + else if(current.getGEO_TAG().equalsIgnoreCase("D")){ + + Snackbar.make(v, R.string.title_geo_tag_activity_geo_data, Snackbar.LENGTH_LONG).setAction("Action", null).show(); + + } + else if(current.getGEO_TAG().equalsIgnoreCase("U")){ + + Snackbar.make(v, R.string.title_geo_tag_activity_upload_data, Snackbar.LENGTH_LONG).setAction("Action", null).show(); + + + } + else if(current.getGEO_TAG().equalsIgnoreCase("P")){ + + Snackbar.make(v, R.string.title_geo_tag_activity_geo_data, Snackbar.LENGTH_LONG).setAction("Action", null).show(); + } + else + { + + // PUT IN PREFERENCES + editor = preferences.edit(); + editor.putString(CommonString.KEY_STORE_ID, current.getSTORE_ID()); + editor.putString(CommonString.KEY_STORE_NAME, current.getSTORE_NAME()); + editor.putString(CommonString.KEY_VISIT_DATE, current.getVISIT_DATE()); + editor.commit(); + + Intent in =new Intent(GeoTagStoreList.this,GeoTagActivity.class); + startActivity(in); + finish(); + } + + } + }); + } + + @Override + public int getItemCount() { + return data.size(); + } + + class MyViewHolder extends RecyclerView.ViewHolder{ + + TextView txt; + ImageView icon; + RelativeLayout relativelayout; + ImageView imageview; + + public MyViewHolder(View itemView) { + super(itemView); + txt=(TextView) itemView.findViewById(R.id.geolistviewxml_storename); + relativelayout=(RelativeLayout) itemView.findViewById(R.id.relativelayout); + imageview=(ImageView) itemView.findViewById(R.id.imageView1); + + } + } + + } + + + public List getdata() { + List data = new ArrayList<>(); + + storelist = db.getStoreData(date); + + StoreBean storelistdata=new StoreBean(); + + + for(int i=0;i coverage; ArrayList storelist = new ArrayList(); - - - ListView list; + //ListView list; private SharedPreferences preferences; - - String date,visit_status; + String date, visit_status; GSKOrangeDB db; - + StoreListActivity.ValueAdapter adapter; + RecyclerView recyclerView; + private SharedPreferences.Editor editor = null; + LinearLayout linearlay; + String store_id; + private Dialog dialog; + boolean result_flag = false, leaveflag = false; @Override protected void onCreate(Bundle savedInstanceState) { @@ -63,132 +74,24 @@ public class StoreListActivity extends AppCompatActivity { db.open(); - list = (ListView)findViewById(R .id.list_id); - + linearlay = (LinearLayout) findViewById(R.id.linearlayout); + recyclerView = (RecyclerView) findViewById(R.id.drawer_layout_recycle); storelist = db.getStoreData(date); + coverage=db.getCoverageData(date); + if (storelist.size() > 0) { + //list.setAdapter(new MyAdaptor()); + adapter = new StoreListActivity.ValueAdapter(getApplicationContext(), storelist); + recyclerView.setAdapter(adapter); + recyclerView.setLayoutManager(new LinearLayoutManager(this)); - if (storelist.size()>0) { - list.setAdapter(new MyAdaptor()); + } else { + + recyclerView.setVisibility(View.INVISIBLE); + linearlay.setVisibility(View.VISIBLE); } - list.setOnItemClickListener(new AdapterView.OnItemClickListener() { - - @Override - public void onItemClick(AdapterView parent, View view, - int position, long id) { - - - Toast.makeText(getApplicationContext(),"Click",Toast.LENGTH_LONG).show(); - - - - } - }); - - } - - - private class MyAdaptor extends BaseAdapter { - - @Override - public int getCount() { - - return storelist.size(); - } - - @Override - public Object getItem(int position) { - - return position; - } - - @Override - public long getItemId(int position) { - - return position; - } - - @Override - public View getView(final int position, View convertView, ViewGroup parent) { - ViewHolder holder = null; - if (convertView == null) { - holder = new ViewHolder(); - - LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); - convertView = inflater.inflate(R.layout.storeviewlist, null); - - holder.storename = (TextView) convertView - .findViewById(R.id.storelistviewxml_storename); - holder.storeaddress = (TextView) convertView - .findViewById(R.id.storelistviewxml_storeaddress); - - holder.imgtick = (ImageView) convertView - .findViewById(R.id.storelistviewxml_storeico); - - holder.checkout = (Button) convertView - .findViewById(R.id.chkout); - - holder.l1 = (RelativeLayout) convertView - .findViewById(R.id.storenamelistview_layout); - - convertView.setTag(holder); - - } else { - holder = (ViewHolder) convertView.getTag(); - } - holder.storename.setText(storelist.get(position).getSTORE_NAME()); - holder.storeaddress.setText(storelist.get(position).getCITY()); - - - - - - holder.checkout.setOnClickListener(new View.OnClickListener() { - - @Override - public void onClick(View v) { - - AlertDialog.Builder builder = new AlertDialog.Builder( - StoreListActivity.this); - builder.setMessage("Are you sure you want to checkout") - .setCancelable(false) - .setPositiveButton("OK", - new DialogInterface.OnClickListener() { - public void onClick( - DialogInterface dialog, int id) { - - - } - }) - .setNegativeButton("Cancel", - new DialogInterface.OnClickListener() { - public void onClick( - DialogInterface dialog, int id) { - dialog.cancel(); - } - }); - AlertDialog alert = builder.create(); - alert.show(); - - } - }); - - - - return convertView; - } - - } - - - private class ViewHolder { - TextView storename, storeaddress; - ImageView imgtick; - Button checkout; - - RelativeLayout l1; } @@ -200,7 +103,7 @@ public class StoreListActivity extends AppCompatActivity { // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); - if(id==android.R.id.home){ + if (id == android.R.id.home) { // NavUtils.navigateUpFromSameTask(this); finish(); @@ -213,4 +116,286 @@ public class StoreListActivity extends AppCompatActivity { } + public class ValueAdapter extends RecyclerView.Adapter { + + private LayoutInflater inflator; + + List data = Collections.emptyList(); + + public ValueAdapter(Context context, List data) { + + inflator = LayoutInflater.from(context); + this.data = data; + + } + + @Override + public StoreListActivity.ValueAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int i) { + + View view = inflator.inflate(R.layout.storeviewlist, parent, false); + + StoreListActivity.ValueAdapter.MyViewHolder holder = new StoreListActivity.ValueAdapter.MyViewHolder(view); + + return holder; + } + + @Override + public void onBindViewHolder(final StoreListActivity.ValueAdapter.MyViewHolder viewHolder, final int position) { + + final StoreBean current = data.get(position); + + + String storeid = current.getSTORE_ID(); + //viewHolder.txt.setText(current.txt); + + viewHolder.txt.setText(current.getSTORE_NAME()); + viewHolder.address.setText(current.getADDRESS()); + + if (current.getCHECKOUT_STATUS().equalsIgnoreCase(CommonString.KEY_VALID)) { + viewHolder.chkbtn.setVisibility(View.VISIBLE); + viewHolder.imageview.setVisibility(View.INVISIBLE); + } else if (current.getUPLOAD_STATUS().equalsIgnoreCase(CommonString.KEY_U)) { + viewHolder.imageview.setVisibility(View.VISIBLE); + viewHolder.imageview.setBackgroundResource(R.mipmap.tick_u); + viewHolder.chkbtn.setVisibility(View.INVISIBLE); + } else if (current.getUPLOAD_STATUS().equalsIgnoreCase(CommonString.KEY_D)) { + viewHolder.imageview.setVisibility(View.VISIBLE); + viewHolder.imageview.setBackgroundResource(R.mipmap.tick_d); + viewHolder.chkbtn.setVisibility(View.INVISIBLE); + } else if (current.getCHECKOUT_STATUS().equalsIgnoreCase(CommonString.KEY_C)) { + viewHolder.imageview.setVisibility(View.VISIBLE); + viewHolder.imageview.setBackgroundResource(R.mipmap.tick_c); + viewHolder.chkbtn.setVisibility(View.INVISIBLE); + } else if (current.getUPLOAD_STATUS().equalsIgnoreCase(CommonString.KEY_P)) { + viewHolder.imageview.setVisibility(View.VISIBLE); + viewHolder.imageview.setBackgroundResource(R.mipmap.tick_p); + viewHolder.chkbtn.setVisibility(View.INVISIBLE); + } else if (current.getUPLOAD_STATUS().equalsIgnoreCase(CommonString.KEY_L)) { + viewHolder.imageview.setVisibility(View.VISIBLE); + viewHolder.imageview.setBackgroundResource(R.mipmap.tickl); + viewHolder.chkbtn.setVisibility(View.INVISIBLE); + } else if (current.getCHECKOUT_STATUS().equalsIgnoreCase(CommonString.KEY_INVALID)) { + + + if (coverage.size() > 0) { + + int i; + + for (i = 0; i < coverage.size(); i++) { + + + if (coverage.get(i).getInTime() != null) { + + if (coverage.get(i).getOutTime() == null) { + + if (storeid.equals(coverage.get(i).getStoreId())) { + viewHolder.imageview.setVisibility(View.VISIBLE); + viewHolder.imageview.setBackgroundResource(R.mipmap.checkin); + viewHolder.chkbtn.setVisibility(View.INVISIBLE); + + } + break; + } + + } + + } + } + } else { + viewHolder.imageview.setVisibility(View.INVISIBLE); + viewHolder.chkbtn.setVisibility(View.INVISIBLE); + } + + + viewHolder.relativelayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + store_id = current.getSTORE_ID(); + + + if (current.getUPLOAD_STATUS().equalsIgnoreCase(CommonString.KEY_U)) { + Snackbar.make(v, R.string.title_store_list_activity_store_already_done, Snackbar.LENGTH_LONG).setAction("Action", null).show(); + } else if (current.getUPLOAD_STATUS().equalsIgnoreCase(CommonString.KEY_D)) { + + Snackbar.make(v, R.string.title_store_list_activity_store_data_uploaded, Snackbar.LENGTH_LONG).setAction("Action", null).show(); + } else if (current.getCHECKOUT_STATUS().equalsIgnoreCase(CommonString.KEY_C)) { + + Snackbar.make(v, R.string.title_store_list_activity_store_already_checkout, Snackbar.LENGTH_LONG).setAction("Action", null).show(); + + } else if (current.getUPLOAD_STATUS().equalsIgnoreCase(CommonString.KEY_P)) { + + Snackbar.make(v, R.string.title_store_list_activity_store_again_uploaded, Snackbar.LENGTH_LONG).setAction("Action", null).show(); + } else if (current.getUPLOAD_STATUS().equalsIgnoreCase(CommonString.KEY_L)) { + Snackbar.make(v, R.string.title_store_list_activity_store_closed, Snackbar.LENGTH_LONG).setAction("Action", null).show(); + } else { + + // PUT IN PREFERENCES + editor = preferences.edit(); + editor.putString(CommonString.KEY_STORE_ID, current.getSTORE_ID()); + editor.putString(CommonString.KEY_STORE_NAME, current.getSTORE_NAME()); + editor.putString(CommonString.KEY_VISIT_DATE, current.getVISIT_DATE()); + editor.putString(CommonString.KEY_CAMERA_ALLOW, current.getCAMERA_ALLOW()); + editor.putString(CommonString.KEY_CHECKOUT_STATUS, current.getCHECKOUT_STATUS()); + editor.putString(CommonString.KEY_CLASS_ID, current.getCLASS_ID()); + editor.putString(CommonString.KEY_EMP_ID, current.getEMP_ID()); + editor.putString(CommonString.KEY_GEO_TAG, current.getGEO_TAG()); + editor.putString(CommonString.KEY_KEYACCOUNT_ID, current.getKEYACCOUNT_ID()); + editor.putString(CommonString.KEY_STORETYPE_ID, current.getSTORETYPE_ID()); + editor.putString(CommonString.KEY_UPLOAD_STATUS, current.getUPLOAD_STATUS()); + editor.commit(); + + // showMyDialog(store_id, current.getSTORE_NAME(), "Yes", current.getVISIT_DATE(), current.getCHECKOUT_STATUS()); + + if (!setcheckedmenthod(store_id)) { + boolean enteryflag = true; + if (coverage.size() > 0) { + int i; + for (i = 0; i < coverage.size(); i++) { + + if (coverage.get(i).getInTime() != null) { + + if (coverage.get(i).getOutTime() == null) { + if (!store_id.equals(coverage.get(i).getStoreId())) { + Snackbar.make(v, R.string.title_store_list_checkout_current, Snackbar.LENGTH_SHORT).setAction("Action", null).show(); + enteryflag = false; + } + break; + } + } + } + } + + if (enteryflag) { + showMyDialog(store_id, current.getSTORE_NAME(), "Yes", current.getVISIT_DATE(), current.getCHECKOUT_STATUS()); + } + } else { + Snackbar.make(v, R.string.title_store_list_checkout_Already_filled, Snackbar.LENGTH_SHORT).setAction("Action", null).show(); + } + } + } + }); + } + + @Override + public int getItemCount() { + return data.size(); + } + + class MyViewHolder extends RecyclerView.ViewHolder { + + TextView txt, address; + ImageView icon; + RelativeLayout relativelayout; + ImageView imageview; + Button chkbtn; + + public MyViewHolder(View itemView) { + super(itemView); + txt = (TextView) itemView.findViewById(R.id.storelistviewxml_storename); + address = (TextView) itemView.findViewById(R.id.storelistviewxml_storeaddress); + + relativelayout = (RelativeLayout) itemView.findViewById(R.id.storenamelistview_layout); + imageview = (ImageView) itemView.findViewById(R.id.imageView2); + + chkbtn = (Button) itemView.findViewById(R.id.chkout); + + } + } + + } + + + void showMyDialog(final String storeCd, final String storeName, final String status, final String visitDate, final String checkout_status) { + dialog = new Dialog(this); + dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); + dialog.setContentView(R.layout.dialogbox); + + RadioGroup radioGroup = (RadioGroup) dialog.findViewById(R.id.radiogrpvisit); + + radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { + + @Override + public void onCheckedChanged(RadioGroup group, int checkedId) { + // find which radio button is selected + if (checkedId == R.id.yes) { + + Intent in = new Intent(StoreListActivity.this, StoreimageActivity.class); + startActivity(in); + + overridePendingTransition(R.anim.activity_in, R.anim.activity_out); + + dialog.cancel(); + + } else if (checkedId == R.id.no) { + + dialog.cancel(); + + if (checkout_status.equals(CommonString.KEY_INVALID) || checkout_status.equals(CommonString.KEY_VALID)) { + AlertDialog.Builder builder = new AlertDialog.Builder(StoreListActivity.this); + builder.setMessage(CommonString.DATA_DELETE_ALERT_MESSAGE) + .setCancelable(false) + .setPositiveButton("Yes", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int id) { + + + + /*Intent in = new Intent(StoreListActivity.this, NonWorkingReason.class); + startActivity(in);*/ + + } + }) + .setNegativeButton("No", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int id) { + + + dialog.cancel(); + } + }); + AlertDialog alert = builder.create(); + + alert.show(); + } else { + + + + + /* Intent in = new Intent(StoreListActivity.this, NonWorkingReason.class); + startActivity(in);*/ + } + + } + } + + }); + + + dialog.show(); + } + + + public boolean setcheckedmenthod(String store_cd) { + + + for (int i = 0; i < coverage.size(); i++) { + if (store_cd.equals(coverage.get(i).getStoreId())) { + if (coverage.get(i).getOutTime() != null) { + result_flag = true; + break; + } + } else { + + result_flag = false; + + } + } + + return result_flag; + } + + } diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/dailyentry/StoreimageActivity.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/dailyentry/StoreimageActivity.java new file mode 100644 index 0000000..46d34ce --- /dev/null +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/dailyentry/StoreimageActivity.java @@ -0,0 +1,381 @@ +package cpm.com.gskmtorange.dailyentry; + +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.location.Location; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.provider.MediaStore; +import android.support.v4.content.ContextCompat; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.Toast; +import com.google.android.gms.common.ConnectionResult; +import com.google.android.gms.common.api.GoogleApiClient; +import com.google.android.gms.location.LocationServices; + +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +import cpm.com.gskmtorange.R; +import cpm.com.gskmtorange.constant.CommonString; +import cpm.com.gskmtorange.Database.GSKOrangeDB; +import cpm.com.gskmtorange.GetterSetter.CoverageBean; + +/** + * Created by ashishc on 31-05-2016. + */ +public class StoreimageActivity extends AppCompatActivity implements View.OnClickListener,GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { + + + ImageView img_cam,img_clicked; + Button btn_save; + + String _pathforcheck,_path,str; + + String store_id,visit_date,username,intime,date; + private SharedPreferences preferences; + AlertDialog alert; + String img_str; + private GSKOrangeDB database; + + String lat,lon; + GoogleApiClient mGoogleApiClient; + ArrayList coverage_list; + + + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_storeimage); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + + getSupportActionBar().setHomeButtonEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + img_cam = (ImageView) findViewById(R.id.img_selfie); + img_clicked = (ImageView) findViewById(R.id.img_cam_selfie); + + btn_save = (Button) findViewById(R.id.btn_save_selfie); + + preferences = PreferenceManager.getDefaultSharedPreferences(this); + + store_id = preferences.getString(CommonString.KEY_STORE_ID, null); + + visit_date = preferences.getString(CommonString.KEY_DATE, null); + date = preferences.getString(CommonString.KEY_DATE, null); + username = preferences.getString(CommonString.KEY_USERNAME, null); + + intime = preferences.getString(CommonString.KEY_STORE_IN_TIME, ""); + + str = CommonString.FILE_PATH; + + database = new GSKOrangeDB(this); + database.open(); + + + coverage_list = database.getCoverageData(date); + + img_cam.setOnClickListener(this); + img_clicked.setOnClickListener(this); + btn_save.setOnClickListener(this); + + // Create an instance of GoogleAPIClient. + if (mGoogleApiClient == null) { + mGoogleApiClient = new GoogleApiClient.Builder(this) + .addConnectionCallbacks(this) + .addOnConnectionFailedListener(this) + .addApi(LocationServices.API) + .build(); + } + + if ( Build.VERSION.SDK_INT >= 23 && + ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && + ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + return ; + } + + + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + if(id==android.R.id.home){ + + // NavUtils.navigateUpFromSameTask(this); + finish(); + + overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out); + + } + + return super.onOptionsItemSelected(item); + } + + @Override + public void onBackPressed() { + /*Intent i = new Intent(this, DailyEntryScreen.class); + startActivity(i);*/ + + finish(); + + + overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out); + } + + @Override + public void onClick(View v) { + + int id = v.getId(); + + switch (id){ + + case R.id.img_cam_selfie: + + _pathforcheck = store_id + "Store" + + "Image" + visit_date.replace("/","") + getCurrentTime().replace(":","")+".jpg"; + + _path = CommonString.FILE_PATH + _pathforcheck; + + intime = getCurrentTime(); + + startCameraActivity(); + + break; + + case R.id.btn_save_selfie: + + if (img_str !=null) { + + AlertDialog.Builder builder = new AlertDialog.Builder( + StoreimageActivity.this); + builder.setMessage("Do you want to save the data ") + .setCancelable(false) + .setPositiveButton("OK", + new DialogInterface.OnClickListener() { + public void onClick( + DialogInterface dialog, + int id) { + + alert.getButton( + AlertDialog.BUTTON_POSITIVE) + .setEnabled(false); + + String status ="INVALID"; + + + CoverageBean cdata = new CoverageBean(); + cdata.setStoreId(store_id); + cdata.setVisitDate(visit_date); + cdata.setUserId(username); + cdata.setInTime(intime); + cdata.setReason(""); + cdata.setReasonid("0"); + cdata.setLatitude(lat); + cdata.setLongitude(lon); + cdata.setImage(img_str); + cdata.setRemark(""); + cdata.setStatus(CommonString.KEY_CHECK_IN); + + database.InsertCoverageData(cdata); + + database.updateCheckoutStatus(store_id, status); + + /* SharedPreferences.Editor editor = preferences.edit(); + + editor.putString(CommonString.KEY_STOREVISITED_STATUS, ""); + editor.putString(CommonString.KEY_STORE_IN_TIME, ""); + + editor.commit();*/ + + + /* Intent in=new Intent(StoreimageActivity.this,StoreEntry.class); + startActivity(in); + + + + finish();*/ + } + }) + .setNegativeButton("Cancel", + new DialogInterface.OnClickListener() { + public void onClick( + DialogInterface dialog, + int id) { + dialog.cancel(); + } + }); + + alert = builder.create(); + alert.show(); + + } + else { + Toast.makeText(getApplicationContext(), + "Please click the image", Toast.LENGTH_SHORT).show(); + + } + + break; + + } + + } + + protected void startCameraActivity() { + + try { + /*Log.i("MakeMachine", "startCameraActivity()"); + File file = new File(_path); + Uri outputFileUri = Uri.fromFile(file); + + Intent intent = new Intent( + MediaStore.ACTION_IMAGE_CAPTURE); + intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); + + startActivityForResult(intent, 0);*/ + + Log.i("MakeMachine", "startCameraActivity()"); + File file = new File(_path); + Uri outputFileUri = Uri.fromFile(file); + + String defaultCameraPackage=""; + final PackageManager packageManager = getPackageManager(); + List list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES); + for (int n=0;n= Build.VERSION_CODES.KITKAT) { + if (list.get(n).loadLabel(packageManager).toString().equalsIgnoreCase("Camera")) { + defaultCameraPackage = list.get(n).packageName; + break; + } + } else { + if (list.get(n).loadLabel(packageManager).toString().equalsIgnoreCase("Gallery")) { + defaultCameraPackage = list.get(n).packageName; + break; + } + } + } + + } + + Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); + intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); + intent.setPackage(defaultCameraPackage); + startActivityForResult(intent, 0); + + + } catch (Exception e) { + + e.printStackTrace(); + } + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + + Log.i("MakeMachine", "resultCode: " + resultCode); + switch (resultCode) { + case 0: + Log.i("MakeMachine", "User cancelled"); + break; + + case -1: + + if (_pathforcheck != null && !_pathforcheck.equals("")) { + if (new File(str + _pathforcheck).exists()) { + + + Bitmap bmp = BitmapFactory.decodeFile(str + _pathforcheck); + + img_cam.setImageBitmap(bmp); + + img_clicked.setVisibility(View.GONE); + img_cam.setVisibility(View.VISIBLE); + + img_str = _pathforcheck; + _pathforcheck = ""; + + + } + } + + break; + } + + + super.onActivityResult(requestCode, resultCode, data); + } + + + public String getCurrentTime() { + + Calendar m_cal = Calendar.getInstance(); + + SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss:mmm"); + String cdate = formatter.format(m_cal.getTime()); + + /* String intime = m_cal.get(Calendar.HOUR_OF_DAY) + ":" + + m_cal.get(Calendar.MINUTE) + ":" + m_cal.get(Calendar.SECOND);*/ + + return cdate; + + } + + @Override + public void onConnected(Bundle bundle) { + + Location mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); + if (mLastLocation != null) { + lat = String.valueOf(mLastLocation.getLatitude()); + lon = String.valueOf(mLastLocation.getLongitude()); + } + + } + + @Override + public void onConnectionSuspended(int i) { + + } + + @Override + public void onConnectionFailed(ConnectionResult connectionResult) { + + } + + protected void onStart() { + mGoogleApiClient.connect(); + super.onStart(); + } + + protected void onStop() { + mGoogleApiClient.disconnect(); + super.onStop(); + } + + } diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/download/DownloadActivity.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/download/DownloadActivity.java index 873d2ab..b68481a 100644 --- a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/download/DownloadActivity.java +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/download/DownloadActivity.java @@ -26,7 +26,7 @@ import java.io.StringReader; import java.net.MalformedURLException; -import cpm.com.gskmtorange.database.GSKOrangeDB; +import cpm.com.gskmtorange.Database.GSKOrangeDB; import cpm.com.gskmtorange.R; import cpm.com.gskmtorange.constant.CommonString; @@ -70,7 +70,7 @@ public class DownloadActivity extends AppCompatActivity { preferences = PreferenceManager.getDefaultSharedPreferences(this); userId = preferences.getString(CommonString.KEY_USERNAME, null); - culture_id = preferences.getString(CommonString.KEY_CULTURE_ID, null); + culture_id = preferences.getString(CommonString.KEY_CULTURE_ID, ""); new UploadTask(DownloadActivity.this).execute(); } @@ -79,8 +79,7 @@ public class DownloadActivity extends AppCompatActivity { String name; } - private class UploadTask extends AsyncTask{ - + private class UploadTask extends AsyncTask { private Context context; UploadTask(Context context) { @@ -100,75 +99,63 @@ public class DownloadActivity extends AppCompatActivity { message = (TextView) dialog.findViewById(R.id.message); dialog.setCancelable(false); dialog.show(); - } @Override protected String doInBackground(Void... voids) { - try { - - String resultHttp=""; + String resultHttp = ""; data = new Data(); data.value = 10; data.name = "JCP Data Downloading"; publishProgress(data); - XmlPullParserFactory factory = XmlPullParserFactory - .newInstance(); + XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser xpp = factory.newPullParser(); - SoapObject request = new SoapObject(CommonString.NAMESPACE, - CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD); + SoapObject request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD); request.addProperty("UserName", userId); request.addProperty("Type", "JOURNEY_PLAN"); request.addProperty("cultureid", culture_id); - SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( - SoapEnvelope.VER11); + SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); - HttpTransportSE androidHttpTransport = new HttpTransportSE( - CommonString.URL); + HttpTransportSE androidHttpTransport = new HttpTransportSE(CommonString.URL); + androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope); - androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, - envelope); Object result = (Object) envelope.getResponse(); - if(result.toString()!=null){ - + if (result.toString() != null) { //InputStream stream = new ByteArrayInputStream(result.toString().getBytes("UTF-8")); - xpp.setInput(new StringReader(result.toString())); - // xpp.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); - // xpp.setInput(stream,"UTF-8"); + 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); - if(jcpgettersetter.getSTORE_ID().size()>0){ + if (jcpgettersetter.getSTORE_ID().size() > 0) { resultHttp = CommonString.KEY_SUCCESS; String jcpTable = jcpgettersetter.getTable_journey_plan(); TableBean.setJourneyPlan(jcpTable); - - }else{ + } else { return "JOURNEY_PLAN"; } data.value = 10; data.name = "JCP Data Downloading"; - } - publishProgress(data); + publishProgress(data); + // Store List Master - request = new SoapObject(CommonString.NAMESPACE, - CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD); - + request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD); request.addProperty("UserName", userId); request.addProperty("Type", "SKU_MASTER"); request.addProperty("cultureid", culture_id); @@ -178,36 +165,33 @@ public class DownloadActivity extends AppCompatActivity { envelope.setOutputSoapObject(request); androidHttpTransport = new HttpTransportSE(CommonString.URL); + androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope); - androidHttpTransport.call( - CommonString.SOAP_ACTION_UNIVERSAL, envelope); result = (Object) envelope.getResponse(); - if(result.toString()!=null){ - xpp.setInput(new StringReader(result.toString())); + if (result.toString() != null) { + xpp.setInput(new StringReader(result.toString())); xpp.next(); eventType = xpp.getEventType(); - skumastergettersetter =XMLHandlers.skuMasterXMLHandler(xpp, eventType); - if(skumastergettersetter.getSKU_ID().size()>0){ + skumastergettersetter = XMLHandlers.skuMasterXMLHandler(xpp, eventType); + if (skumastergettersetter.getSKU_ID().size() > 0) { String skutable = skumastergettersetter.getTable_SKU_MASTER(); - if(skutable!=null){ + if (skutable != null) { resultHttp = CommonString.KEY_SUCCESS; TableBean.setSkuMaster(skutable); } - }else{ + } else { return "SKU_MASTER"; } data.value = 20; data.name = "SKU_MASTER Data Download"; } - publishProgress(data); - // BRAND_MASTER - request = new SoapObject(CommonString.NAMESPACE, - CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD); + // BRAND_MASTER + request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD); request.addProperty("UserName", userId); request.addProperty("Type", "BRAND_MASTER"); request.addProperty("cultureid", culture_id); @@ -217,36 +201,33 @@ public class DownloadActivity extends AppCompatActivity { envelope.setOutputSoapObject(request); androidHttpTransport = new HttpTransportSE(CommonString.URL); + androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope); - androidHttpTransport.call( - CommonString.SOAP_ACTION_UNIVERSAL, envelope); result = (Object) envelope.getResponse(); - if(result.toString()!=null){ - xpp.setInput(new StringReader(result.toString())); + if (result.toString() != null) { + xpp.setInput(new StringReader(result.toString())); xpp.next(); eventType = xpp.getEventType(); - brandMasterGetterSetter =XMLHandlers.brandMasterXMLHandler(xpp, eventType); - if(brandMasterGetterSetter.getBRAND_ID().size()>0){ + brandMasterGetterSetter = XMLHandlers.brandMasterXMLHandler(xpp, eventType); + if (brandMasterGetterSetter.getBRAND_ID().size() > 0) { String brandtable = brandMasterGetterSetter.getTable_BRAND_MASTER(); - if(brandtable!=null){ + if (brandtable != null) { resultHttp = CommonString.KEY_SUCCESS; TableBean.setBrandMaster(brandtable); } - }else{ + } else { return "BRAND_MASTER"; } data.value = 30; data.name = "BRAND_MASTER Data Download"; } - publishProgress(data); - // SUB_CATEGORY_MASTER - request = new SoapObject(CommonString.NAMESPACE, - CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD); + // SUB_CATEGORY_MASTER + request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD); request.addProperty("UserName", userId); request.addProperty("Type", "SUB_CATEGORY_MASTER"); request.addProperty("cultureid", culture_id); @@ -256,36 +237,32 @@ public class DownloadActivity extends AppCompatActivity { envelope.setOutputSoapObject(request); androidHttpTransport = new HttpTransportSE(CommonString.URL); + androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope); - androidHttpTransport.call( - CommonString.SOAP_ACTION_UNIVERSAL, envelope); result = (Object) envelope.getResponse(); - if(result.toString()!=null){ + if (result.toString() != null) { xpp.setInput(new StringReader(result.toString())); xpp.next(); eventType = xpp.getEventType(); - subCategoryMasterGetterSetter =XMLHandlers.subCategoryMasterXMLHandler(xpp, eventType); - if(subCategoryMasterGetterSetter.getSUB_CATEGORY_ID().size()>0){ + subCategoryMasterGetterSetter = XMLHandlers.subCategoryMasterXMLHandler(xpp, eventType); + if (subCategoryMasterGetterSetter.getSUB_CATEGORY_ID().size() > 0) { String categorytable = subCategoryMasterGetterSetter.getTable_SUB_CATEGORY_MASTER(); - if(categorytable!=null){ + if (categorytable != null) { resultHttp = CommonString.KEY_SUCCESS; TableBean.setSubCategoryMaster(categorytable); } - }else{ + } else { return "SUB_CATEGORY_MASTER"; } - - data.value = 20; + data.value = 40; data.name = "SUB_CATEGORY_MASTER Data Download"; } - publishProgress(data); - // CATEGORY_MASTER - request = new SoapObject(CommonString.NAMESPACE, - CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD); + // CATEGORY_MASTER + request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD); request.addProperty("UserName", userId); request.addProperty("Type", "CATEGORY_MASTER"); request.addProperty("cultureid", culture_id); @@ -295,36 +272,32 @@ public class DownloadActivity extends AppCompatActivity { envelope.setOutputSoapObject(request); androidHttpTransport = new HttpTransportSE(CommonString.URL); + androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope); - androidHttpTransport.call( - CommonString.SOAP_ACTION_UNIVERSAL, envelope); result = (Object) envelope.getResponse(); - if(result.toString()!=null){ - xpp.setInput(new StringReader(result.toString())); + if (result.toString() != null) { + xpp.setInput(new StringReader(result.toString())); xpp.next(); eventType = xpp.getEventType(); - categoryMasterGetterSetter =XMLHandlers.categoryMasterXMLHandler(xpp, eventType); - if(categoryMasterGetterSetter.getCATEGORY_ID().size()>0){ + categoryMasterGetterSetter = XMLHandlers.categoryMasterXMLHandler(xpp, eventType); + if (categoryMasterGetterSetter.getCATEGORY_ID().size() > 0) { String skutable = categoryMasterGetterSetter.getTable_CATEGORY_MASTER(); - if(skutable!=null){ + if (skutable != null) { resultHttp = CommonString.KEY_SUCCESS; TableBean.setCategoryMaster(skutable); } - }else{ + } else { return "CATEGORY_MASTER"; } - - data.value = 20; + data.value = 50; data.name = "CATEGORY_MASTER Data Download"; } - publishProgress(data); - // DISPLAY_MASTER - request = new SoapObject(CommonString.NAMESPACE, - CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD); + // DISPLAY_MASTER + request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD); request.addProperty("UserName", userId); request.addProperty("Type", "DISPLAY_MASTER"); request.addProperty("cultureid", culture_id); @@ -334,36 +307,32 @@ public class DownloadActivity extends AppCompatActivity { envelope.setOutputSoapObject(request); androidHttpTransport = new HttpTransportSE(CommonString.URL); + androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope); - androidHttpTransport.call( - CommonString.SOAP_ACTION_UNIVERSAL, envelope); result = (Object) envelope.getResponse(); - if(result.toString()!=null){ - xpp.setInput(new StringReader(result.toString())); + if (result.toString() != null) { + xpp.setInput(new StringReader(result.toString())); xpp.next(); eventType = xpp.getEventType(); - displayMasterGetterSetter =XMLHandlers.displayMasterXMLHandler(xpp, eventType); - if(displayMasterGetterSetter.getDISPLAY_ID().size()>0){ + displayMasterGetterSetter = XMLHandlers.displayMasterXMLHandler(xpp, eventType); + if (displayMasterGetterSetter.getDISPLAY_ID().size() > 0) { String display_table = displayMasterGetterSetter.getTable_DISPLAY_MASTER(); - if(display_table!=null){ + if (display_table != null) { resultHttp = CommonString.KEY_SUCCESS; TableBean.setDisplayMaster(display_table); } - }else{ + } else { return "DISPLAY_MASTER"; } - - data.value = 20; + data.value = 60; data.name = "DISPLAY_MASTER Data Download"; } - publishProgress(data); - // MAPPING_STOCK - request = new SoapObject(CommonString.NAMESPACE, - CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD); + // MAPPING_STOCK + request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD); request.addProperty("UserName", userId); request.addProperty("Type", "MAPPING_STOCK"); request.addProperty("cultureid", culture_id); @@ -373,36 +342,32 @@ public class DownloadActivity extends AppCompatActivity { envelope.setOutputSoapObject(request); androidHttpTransport = new HttpTransportSE(CommonString.URL); + androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope); - androidHttpTransport.call( - CommonString.SOAP_ACTION_UNIVERSAL, envelope); result = (Object) envelope.getResponse(); - if(result.toString()!=null){ + if (result.toString() != null) { xpp.setInput(new StringReader(result.toString())); xpp.next(); eventType = xpp.getEventType(); - mappingStockGetterSetter =XMLHandlers.mappingStockXMLHandler(xpp, eventType); - if(mappingStockGetterSetter.getSKU_ID().size()>0){ + mappingStockGetterSetter = XMLHandlers.mappingStockXMLHandler(xpp, eventType); + if (mappingStockGetterSetter.getSKU_ID().size() > 0) { String stocktable = mappingStockGetterSetter.getTable_MAPPING_STOCK(); - if(stocktable!=null){ + if (stocktable != null) { resultHttp = CommonString.KEY_SUCCESS; TableBean.setMappingStock(stocktable); } - }else{ + } else { return "MAPPING_STOCK"; } - - data.value = 20; + data.value = 80; data.name = "MAPPING_STOCK Data Download"; } - publishProgress(data); - // MAPPING_T2P - request = new SoapObject(CommonString.NAMESPACE, - CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD); + // MAPPING_T2P + request = new SoapObject(CommonString.NAMESPACE, CommonString.METHOD_NAME_UNIVERSAL_DOWNLOAD); request.addProperty("UserName", userId); request.addProperty("Type", "MAPPING_T2P"); request.addProperty("cultureid", culture_id); @@ -412,84 +377,65 @@ public class DownloadActivity extends AppCompatActivity { envelope.setOutputSoapObject(request); androidHttpTransport = new HttpTransportSE(CommonString.URL); + androidHttpTransport.call(CommonString.SOAP_ACTION_UNIVERSAL, envelope); - androidHttpTransport.call( - CommonString.SOAP_ACTION_UNIVERSAL, envelope); result = (Object) envelope.getResponse(); - if(result.toString()!=null){ - xpp.setInput(new StringReader(result.toString())); + if (result.toString() != null) { + xpp.setInput(new StringReader(result.toString())); xpp.next(); eventType = xpp.getEventType(); - mappingt2PGetterSetter =XMLHandlers.mappingT2pXMLHandler(xpp, eventType); - if(mappingt2PGetterSetter.getSTORE_ID().size()>0){ + mappingt2PGetterSetter = XMLHandlers.mappingT2pXMLHandler(xpp, eventType); + if (mappingt2PGetterSetter.getSTORE_ID().size() > 0) { String t2ptable = mappingt2PGetterSetter.getTable_MAPPING_T2P(); - if(t2ptable!=null){ + if (t2ptable != null) { resultHttp = CommonString.KEY_SUCCESS; TableBean.setMappingT2p(t2ptable); } - }else{ + } else { return "MAPPING_T2P"; } - - data.value = 20; + data.value = 100; data.name = "MAPPING_T2P Data Download"; } - publishProgress(data); - - - - - db.open(); - db.InsertJCP(jcpgettersetter); + db.InsertCategory(categoryMasterGetterSetter); + db.InsertSubCategoryMaster(subCategoryMasterGetterSetter); + db.InsertBrandMaster(brandMasterGetterSetter); + db.InsertSkuMaster(skumastergettersetter); + db.InsertDisplayMaster(displayMasterGetterSetter); + + db.InsertMAPPING_T2P(mappingt2PGetterSetter); + db.InsertMappingStock(mappingStockGetterSetter); - - - - - - - - - - - - }catch (MalformedURLException e) { - + } catch (MalformedURLException e) { /*final AlertMessage message = new AlertMessage( CompleteDownloadActivity.this, AlertMessage.MESSAGE_EXCEPTION, "download", e);*/ runOnUiThread(new Runnable() { - @Override public void run() { // TODO Auto-generated method stub showAlert(CommonString.MESSAGE_EXCEPTION); } }); - } catch (IOException e) { /* final AlertMessage message = new AlertMessage( CompleteDownloadActivity.this, AlertMessage.MESSAGE_SOCKETEXCEPTION, "socket", e);*/ runOnUiThread(new Runnable() { - @Override public void run() { showAlert(CommonString.MESSAGE_SOCKETEXCEPTION); - } }); - } - - catch (Exception e) { + } catch (Exception e) { /* final AlertMessage message = new AlertMessage( CompleteDownloadActivity.this, AlertMessage.MESSAGE_EXCEPTION, "download", e);*/ @@ -498,15 +444,12 @@ public class DownloadActivity extends AppCompatActivity { e.printStackTrace(); e.getCause();*/ runOnUiThread(new Runnable() { - @Override public void run() { - showAlert(CommonString.MESSAGE_EXCEPTION); } }); } - return ""; } @@ -517,7 +460,6 @@ public class DownloadActivity extends AppCompatActivity { pb.setProgress(values[0].value); percentage.setText(values[0].value + "%"); message.setText(values[0].name); - } @Override @@ -525,7 +467,6 @@ public class DownloadActivity extends AppCompatActivity { super.onPostExecute(s); dialog.dismiss(); - finish(); } diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gettersetter/CoverageBean.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gettersetter/CoverageBean.java new file mode 100644 index 0000000..5023fd5 --- /dev/null +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gettersetter/CoverageBean.java @@ -0,0 +1,223 @@ +package cpm.com.gskmtorange.gettersetter; + +public class CoverageBean +{ + protected int MID; + protected String process_id; + + public String getGEO_TAG() { + return GEO_TAG; + } + + public void setGEO_TAG(String GEO_TAG) { + this.GEO_TAG = GEO_TAG; + } + + protected String GEO_TAG; + public String getProcess_id() { + return process_id; + } + + public void setProcess_id(String process_id) { + this.process_id = process_id; + } + + protected String storeId; + protected String storename; + + public String getStorename() { + return storename; + } + + public void setStorename(String storename) { + this.storename = storename; + } + + protected String Remark; + + public String getRemark() { + return Remark; + } + + public void setRemark(String remark) { + Remark = remark; + } + + protected String userId; + protected String app_version; + protected String image_allow; + + public String getImage_allow() { + return image_allow; + } + + public void setImage_allow(String image_allow) { + this.image_allow = image_allow; + } + + public String getApp_version() { + return app_version; + } + + public void setApp_version(String app_version) { + this.app_version = app_version; + } + + protected String inTime; + + protected String outTime; + + protected String visitDate; + + protected String keycontactId; + + protected String isdDeploy; + + protected String uploadStatus; + + private String latitude; + + private String longitude; + + private String reasonid=""; + + private String sub_reasonId=""; + + public String getSub_reasonId() { + return sub_reasonId; + } + + public void setSub_reasonId(String sub_reasonId) { + this.sub_reasonId = sub_reasonId; + } + + private String reason=""; + + private String status="N"; + + private String image=""; + + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public int getMID() { + return MID; + } + + public void setMID(int mID) { + MID = mID; + } + + public String getStoreId() { + return storeId; + } + + public void setStoreId(String storeId) { + this.storeId = storeId; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getInTime() { + return inTime; + } + + public void setInTime(String inTime) { + this.inTime = inTime; + } + + public String getOutTime() { + return outTime; + } + + public void setOutTime(String outTime) { + this.outTime = outTime; + } + + public String getVisitDate() { + return visitDate; + } + + public void setVisitDate(String visitDate) { + this.visitDate = visitDate; + } + + public String getKeycontactId() { + return keycontactId; + } + + public void setKeycontactId(String keycontactId) { + this.keycontactId = keycontactId; + } + + public String getIsdDeploy() { + return isdDeploy; + } + + public void setIsdDeploy(String isdDeploy) { + this.isdDeploy = isdDeploy; + } + + public String getUploadStatus() { + return uploadStatus; + } + + public void setUploadStatus(String uploadStatus) { + this.uploadStatus = uploadStatus; + } + + public String getLatitude() { + return latitude; + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public String getReasonid() { + return reasonid; + } + + public void setReasonid(String reasonid) { + this.reasonid = reasonid; + } + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + + + +} diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gettersetter/GeotaggingBeans.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gettersetter/GeotaggingBeans.java new file mode 100644 index 0000000..4470b5f --- /dev/null +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gettersetter/GeotaggingBeans.java @@ -0,0 +1,78 @@ +package cpm.com.gskmtorange.gettersetter; + +public class GeotaggingBeans { + + + + public String storeid; + public String url1; + public String url2; + public String status; + public String getStatus() { + return status; + } + public void setStatus(String status) { + this.status = status; + } + + public String url3; + public double Latitude ; + public double Longitude; + + public String getStoreid() { + return storeid; + } + public void setStoreid(String storeid) { + this.storeid = storeid; + } + public double getLatitude() { + return Latitude; + } + public void setLatitude(double d) { + Latitude = d; + } + public double getLongitude() { + return Longitude; + } + public void setLongitude(double d) { + Longitude = d; + } + + + public void setUrl1(String url1) + { + + this.url1=url1; + } + + public String getUrl1() + { + + return url1; + } + + public void setUrl2(String url2) + { + + this.url2=url2; + } + + public String getUrl2() + { + + return url2; + } + + public void setUrl3(String url3) + { + + this.url3=url3; + } + + public String getUrl3() + { + + return url3; + } + +} diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/CategoryListActivity.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/CategoryListActivity.java new file mode 100644 index 0000000..8e7364b --- /dev/null +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/CategoryListActivity.java @@ -0,0 +1,166 @@ +package cpm.com.gskmtorange.gsk_dailyentry; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.GridLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import cpm.com.gskmtorange.R; +import cpm.com.gskmtorange.xmlGetterSetter.CategoryGetterSetter; + +public class CategoryListActivity extends AppCompatActivity { + RecyclerView recyclerView; + ArrayList categoryList; + CategoryListAdapter adapter; + TextView txt_categoryName; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_category_list); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + getSupportActionBar().setHomeButtonEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + txt_categoryName = (TextView) findViewById(R.id.txt_categoryName); + txt_categoryName.setText("Category List"); + + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + } + + @Override + protected void onResume() { + super.onResume(); + + recyclerView = (RecyclerView) findViewById(R.id.recyclerView); + categoryList = new ArrayList<>(); + + CategoryGetterSetter data = new CategoryGetterSetter(); + data.setCategory_name("Oral Health"); + data.setCategory_img(R.drawable.category); + categoryList.add(data); + + data = new CategoryGetterSetter(); + data.setCategory_name("Nutritionals"); + data.setCategory_img(R.drawable.category); + categoryList.add(data); + + data = new CategoryGetterSetter(); + data.setCategory_name("Wellness"); + data.setCategory_img(R.drawable.category); + categoryList.add(data); + + adapter = new CategoryListAdapter(CategoryListActivity.this, categoryList); + recyclerView.setAdapter(adapter); + recyclerView.setLayoutManager(new GridLayoutManager(getApplicationContext(), 2)); + } + + public class CategoryListAdapter extends RecyclerView.Adapter { + private LayoutInflater inflator; + List list = Collections.emptyList(); + Context context; + + public CategoryListAdapter(CategoryListActivity context, List list) { + inflator = LayoutInflater.from(context); + this.list = list; + this.context = context; + } + + @Override + public CategoryListAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int i) { + View view = inflator.inflate(R.layout.category_menu_row, parent, false); + MyViewHolder holder = new MyViewHolder(view); + return holder; + } + + @Override + public void onBindViewHolder(MyViewHolder holder, int position) { + final CategoryGetterSetter categoryData = list.get(position); + + holder.categoryName.setText(categoryData.getCategory_name()); + holder.categoryIcon.setImageResource(categoryData.getCategory_img()); + + holder.lay_menu.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(CategoryListActivity.this, CategoryWisePerformanceActivity.class); + intent.putExtra("categoryName", categoryData.getCategory_name()); + startActivity(intent); + } + }); + + + } + + + @Override + public int getItemCount() { + return list.size(); + } + + class MyViewHolder extends RecyclerView.ViewHolder { + TextView categoryName; + ImageView categoryIcon; + LinearLayout lay_menu; + + public MyViewHolder(View itemView) { + super(itemView); + categoryName = (TextView) itemView.findViewById(R.id.categoryName); + categoryIcon = (ImageView) itemView.findViewById(R.id.categoryIcon); + lay_menu = (LinearLayout) itemView.findViewById(R.id.lay_menu); + } + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + if (id == android.R.id.home) { + finish(); + } + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/CategoryWisePerformanceActivity.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/CategoryWisePerformanceActivity.java new file mode 100644 index 0000000..07eeef2 --- /dev/null +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/CategoryWisePerformanceActivity.java @@ -0,0 +1,208 @@ +package cpm.com.gskmtorange.gsk_dailyentry; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; +import android.view.LayoutInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import cpm.com.gskmtorange.R; +import cpm.com.gskmtorange.xmlGetterSetter.CategoryWisePerformaceGetterSetter; + +public class CategoryWisePerformanceActivity extends AppCompatActivity { + TextView txt_categoryName; + RecyclerView recyclerView; + + String categoryName = ""; + + ArrayList categoryWisePerformanceList; + CategoryWisePerformaceAdapter adapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_category_wise_performance); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + getSupportActionBar().setHomeButtonEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + recyclerView = (RecyclerView) findViewById(R.id.recyclerView); + txt_categoryName = (TextView) findViewById(R.id.txt_categoryName); + + categoryName = getIntent().getStringExtra("categoryName"); + + txt_categoryName.setText("CategoryWise Performance " + categoryName); + + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { +/* Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show();*/ + Intent intent = new Intent(CategoryWisePerformanceActivity.this, DailyDataMenuActivity.class); + intent.putExtra("categoryName", categoryName); + startActivity(intent); + } + }); + } + + @Override + protected void onResume() { + super.onResume(); + + categoryWisePerformanceList = new ArrayList<>(); + CategoryWisePerformaceGetterSetter data = new CategoryWisePerformaceGetterSetter(); + + data.setPeriod("Period"); + data.setSos("SOS"); + data.setT2p("T2P"); + data.setPromo("Promo"); + data.setMsl_availability("MSL Availability"); + data.setOss("OSS"); + categoryWisePerformanceList.add(data); + + data = new CategoryWisePerformaceGetterSetter(); + data.setPeriod("LTM"); + data.setSos("75"); + data.setT2p("0"); + data.setPromo("0"); + data.setMsl_availability("25"); + data.setOss("55"); + categoryWisePerformanceList.add(data); + + data = new CategoryWisePerformaceGetterSetter(); + data.setPeriod("MTM"); + data.setSos("75"); + data.setT2p("0"); + data.setPromo("0"); + data.setMsl_availability("25"); + data.setOss("55"); + categoryWisePerformanceList.add(data); + + data = new CategoryWisePerformaceGetterSetter(); + data.setPeriod("RTM"); + data.setSos("75"); + data.setT2p("0"); + data.setPromo("0"); + data.setMsl_availability("25"); + data.setOss("55"); + categoryWisePerformanceList.add(data); + + data = new CategoryWisePerformaceGetterSetter(); + data.setPeriod("LTM"); + data.setSos("75"); + data.setT2p("0"); + data.setPromo("0"); + data.setMsl_availability("25"); + data.setOss("55"); + categoryWisePerformanceList.add(data); + + data = new CategoryWisePerformaceGetterSetter(); + data.setPeriod("MTM"); + data.setSos("75"); + data.setT2p("0"); + data.setPromo("0"); + data.setMsl_availability("25"); + data.setOss("55"); + categoryWisePerformanceList.add(data); + + data = new CategoryWisePerformaceGetterSetter(); + data.setPeriod("RTM"); + data.setSos("75"); + data.setT2p("0"); + data.setPromo("0"); + data.setMsl_availability("25"); + data.setOss("55"); + categoryWisePerformanceList.add(data); + + adapter = new CategoryWisePerformaceAdapter(CategoryWisePerformanceActivity.this, categoryWisePerformanceList); + recyclerView.setAdapter(adapter); + recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext())); + } + + public class CategoryWisePerformaceAdapter extends RecyclerView.Adapter { + Context context; + private LayoutInflater inflator; + List list = Collections.emptyList(); + + public CategoryWisePerformaceAdapter(Context context, List list) { + inflator = LayoutInflater.from(context); + this.list = list; + this.context = context; + } + + @Override + public CategoryWisePerformaceAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int i) { + View view = inflator.inflate(R.layout.item_category_wise_performance, parent, false); + CategoryWisePerformaceAdapter.MyViewHolder holder = new CategoryWisePerformaceAdapter.MyViewHolder(view); + return holder; + } + + @Override + public void onBindViewHolder(CategoryWisePerformaceAdapter.MyViewHolder holder, int position) { + final CategoryWisePerformaceGetterSetter categoryData = list.get(position); + + holder.txt_period.setText(categoryData.getPeriod()); + holder.txt_sos.setText(categoryData.getSos()); + holder.txt_t2p.setText(categoryData.getT2p()); + holder.txt_promo.setText(categoryData.getPromo()); + holder.txt_msl_availability.setText(categoryData.getMsl_availability()); + holder.txt_oss.setText(categoryData.getOss()); + } + + @Override + public int getItemCount() { + return list.size(); + } + + class MyViewHolder extends RecyclerView.ViewHolder { + TextView txt_period, txt_sos, txt_t2p, txt_promo, txt_msl_availability, txt_oss; + LinearLayout lay_menu; + + public MyViewHolder(View itemView) { + super(itemView); + lay_menu = (LinearLayout) itemView.findViewById(R.id.lay_menu); + txt_period = (TextView) itemView.findViewById(R.id.txt_period); + txt_sos = (TextView) itemView.findViewById(R.id.txt_sos); + txt_t2p = (TextView) itemView.findViewById(R.id.txt_t2p); + txt_promo = (TextView) itemView.findViewById(R.id.txt_promo); + txt_msl_availability = (TextView) itemView.findViewById(R.id.txt_msl_availability); + txt_oss = (TextView) itemView.findViewById(R.id.txt_oss); + } + } + + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + if (id == android.R.id.home) { + finish(); + } + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/DailyDataMenuActivity.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/DailyDataMenuActivity.java new file mode 100644 index 0000000..798ae71 --- /dev/null +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/DailyDataMenuActivity.java @@ -0,0 +1,195 @@ +package cpm.com.gskmtorange.gsk_dailyentry; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.GridLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import cpm.com.gskmtorange.R; +import cpm.com.gskmtorange.xmlGetterSetter.DailyDataMenuGetterSetter; + +public class DailyDataMenuActivity extends AppCompatActivity { + RecyclerView recyclerView; + ArrayList categoryList; + DailyDataMenuAdapter adapter; + TextView txt_categoryName; + String categoryName = ""; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_daily_data_menu); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + getSupportActionBar().setHomeButtonEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + recyclerView = (RecyclerView) findViewById(R.id.recyclerView); + txt_categoryName = (TextView) findViewById(R.id.txt_categoryName); + + categoryName = getIntent().getStringExtra("categoryName"); + + txt_categoryName.setText("Daily Data Menu - " + categoryName); + + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + } + + @Override + protected void onResume() { + super.onResume(); + + categoryList = new ArrayList<>(); + + DailyDataMenuGetterSetter data = new DailyDataMenuGetterSetter(); + data.setCategory_name("MSL Availability"); + data.setCategory_img(R.drawable.category); + categoryList.add(data); + + data = new DailyDataMenuGetterSetter(); + data.setCategory_name("Stock & Facing"); + data.setCategory_img(R.drawable.category); + categoryList.add(data); + + data = new DailyDataMenuGetterSetter(); + data.setCategory_name("T2P Compliance"); + data.setCategory_img(R.drawable.category); + categoryList.add(data); + + data = new DailyDataMenuGetterSetter(); + data.setCategory_name("Additional Visibility"); + data.setCategory_img(R.drawable.category); + categoryList.add(data); + + data = new DailyDataMenuGetterSetter(); + data.setCategory_name("Promo Compliance"); + data.setCategory_img(R.drawable.category); + categoryList.add(data); + + data = new DailyDataMenuGetterSetter(); + data.setCategory_name("Competition Visibility"); + data.setCategory_img(R.drawable.category); + categoryList.add(data); + + data = new DailyDataMenuGetterSetter(); + data.setCategory_name("Competition Promo"); + data.setCategory_img(R.drawable.category); + categoryList.add(data); + + adapter = new DailyDataMenuAdapter(DailyDataMenuActivity.this, categoryList); + recyclerView.setAdapter(adapter); + recyclerView.setLayoutManager(new GridLayoutManager(getApplicationContext(), 2)); + } + + public class DailyDataMenuAdapter extends RecyclerView.Adapter { + private LayoutInflater inflator; + List list = Collections.emptyList(); + Context context; + + public DailyDataMenuAdapter(Context context, List list) { + inflator = LayoutInflater.from(context); + this.list = list; + this.context = context; + } + + @Override + public DailyDataMenuAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int i) { + View view = inflator.inflate(R.layout.daily_main_menu_row, parent, false); + DailyDataMenuAdapter.MyViewHolder holder = new DailyDataMenuAdapter.MyViewHolder(view); + return holder; + } + + @Override + public void onBindViewHolder(DailyDataMenuAdapter.MyViewHolder holder, int position) { + final DailyDataMenuGetterSetter dailyData = list.get(position); + + holder.categoryName.setText(dailyData.getCategory_name()); + holder.categoryIcon.setImageResource(dailyData.getCategory_img()); + + holder.lay_menu.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (dailyData.getCategory_name().equalsIgnoreCase("MSL Availability")) { + Intent intent = new Intent(DailyDataMenuActivity.this, MSL_AvailabilityActivity.class); + intent.putExtra("categoryName", dailyData.getCategory_name()); + startActivity(intent); + } else if (dailyData.getCategory_name().equalsIgnoreCase("Stock & Facing")) { + Intent intent1 = new Intent(DailyDataMenuActivity.this, Stock_FacingActivity.class); + intent1.putExtra("categoryName", dailyData.getCategory_name()); + startActivity(intent1); + } + + } + }); + } + + @Override + public int getItemCount() { + return list.size(); + } + + class MyViewHolder extends RecyclerView.ViewHolder { + TextView categoryName; + ImageView categoryIcon; + LinearLayout lay_menu; + + public MyViewHolder(View itemView) { + super(itemView); + categoryName = (TextView) itemView.findViewById(R.id.categoryName); + categoryIcon = (ImageView) itemView.findViewById(R.id.categoryIcon); + lay_menu = (LinearLayout) itemView.findViewById(R.id.lay_menu); + } + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + if (id == android.R.id.home) { + finish(); + } + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} + diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/MSL_AvailabilityActivity.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/MSL_AvailabilityActivity.java new file mode 100644 index 0000000..abc3613 --- /dev/null +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/MSL_AvailabilityActivity.java @@ -0,0 +1,360 @@ +package cpm.com.gskmtorange.gsk_dailyentry; + +import android.content.Context; +import android.graphics.Typeface; +import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.CardView; +import android.support.v7.widget.Toolbar; +import android.view.LayoutInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.view.inputmethod.InputMethodManager; +import android.widget.AbsListView; +import android.widget.BaseExpandableListAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ExpandableListView; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.TextView; +import android.widget.ToggleButton; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import cpm.com.gskmtorange.R; +import cpm.com.gskmtorange.xmlGetterSetter.MSL_AvailabilityGetterSetter; + +public class MSL_AvailabilityActivity extends AppCompatActivity { + ExpandableListView expandableListView; + TextView txt_mslAvailabilityName; + + ArrayList headerDataList; + ArrayList childDataList; + List hashMapListHeaderData; + HashMap> hashMapListChildData; + + ExpandableListAdapter adapter; + + String title; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_msl__availability); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + getSupportActionBar().setHomeButtonEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + expandableListView = (ExpandableListView) findViewById(R.id.expandableListView); + txt_mslAvailabilityName = (TextView) findViewById(R.id.txt_mslAvailabilityName); + + title = getIntent().getStringExtra("categoryName"); + txt_mslAvailabilityName.setText(title); + + prepareList(); + + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + + expandableListView.setOnScrollListener(new AbsListView.OnScrollListener() { + @Override + public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { + } + + @Override + public void onScrollStateChanged(AbsListView arg0, int arg1) { + InputMethodManager inputManager = (InputMethodManager) getApplicationContext() + .getSystemService(Context.INPUT_METHOD_SERVICE); + if (getCurrentFocus() != null) { + inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); + getCurrentFocus().clearFocus(); + } + + expandableListView.invalidateViews(); + } + }); + + // Listview Group click listener + expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { + @Override + public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { + return false; + } + }); + + // Listview Group expanded listener + expandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() { + @Override + public void onGroupExpand(int groupPosition) { + InputMethodManager inputManager = (InputMethodManager) getApplicationContext() + .getSystemService(Context.INPUT_METHOD_SERVICE); + if (getWindow().getCurrentFocus() != null) { + inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); + getCurrentFocus().clearFocus(); + } + } + }); + + // Listview Group collasped listener + expandableListView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() { + @Override + public void onGroupCollapse(int groupPosition) { + InputMethodManager inputManager = (InputMethodManager) getApplicationContext() + .getSystemService(Context.INPUT_METHOD_SERVICE); + if (getWindow().getCurrentFocus() != null) { + inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); + getCurrentFocus().clearFocus(); + } + } + }); + + // Listview on child click listener + expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { + @Override + public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, + int childPosition, long id) { + return false; + } + }); + + } + + private void prepareList() { + headerDataList = new ArrayList<>(); + + MSL_AvailabilityGetterSetter msl = new MSL_AvailabilityGetterSetter(); + msl.setBrandName("Parodontax header 1"); + msl.setMbq("1"); + msl.setAvailable("No"); + headerDataList.add(msl); + + msl = new MSL_AvailabilityGetterSetter(); + msl.setBrandName("Parodontax header 2"); + msl.setMbq("2"); + msl.setAvailable("Yes"); + headerDataList.add(msl); + + msl = new MSL_AvailabilityGetterSetter(); + msl.setBrandName("Parodontax header 3"); + msl.setMbq("3"); + msl.setAvailable("Yes"); + headerDataList.add(msl); + + msl = new MSL_AvailabilityGetterSetter(); + msl.setBrandName("Parodontax header 4"); + msl.setMbq("4"); + msl.setAvailable("No"); + headerDataList.add(msl); + + + hashMapListHeaderData = new ArrayList<>(); + hashMapListChildData = new HashMap<>(); + + if (headerDataList.size() > 0) { + + for (int i = 0; i < headerDataList.size(); i++) { + hashMapListHeaderData.add(headerDataList.get(i)); + + childDataList = new ArrayList<>(); + + MSL_AvailabilityGetterSetter msl1 = new MSL_AvailabilityGetterSetter(); + msl.setBrandName("Parodontax 1"); + msl.setMbq("1"); + msl.setAvailable("No"); + childDataList.add(msl1); + + msl1 = new MSL_AvailabilityGetterSetter(); + msl.setBrandName("Parodontax 2"); + msl.setMbq("2"); + msl.setAvailable("No"); + childDataList.add(msl1); + + hashMapListChildData.put(hashMapListHeaderData.get(i), childDataList); + } + + } + + adapter = new ExpandableListAdapter(this, hashMapListHeaderData, hashMapListChildData); + expandableListView.setAdapter(adapter); + } + + public class ExpandableListAdapter extends BaseExpandableListAdapter { + private Context _context; + private List _listDataHeader; + private HashMap> _listDataChild; + + public ExpandableListAdapter(Context context, List listDataHeader, + HashMap> listChildData) { + this._context = context; + this._listDataHeader = listDataHeader; + this._listDataChild = listChildData; + } + + @Override + public Object getGroup(int groupPosition) { + return this._listDataHeader.get(groupPosition); + } + + @Override + public int getGroupCount() { + return this._listDataHeader.size(); + } + + @Override + public long getGroupId(int groupPosition) { + return groupPosition; + } + + @Override + public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { + MSL_AvailabilityGetterSetter headerTitle = (MSL_AvailabilityGetterSetter) getGroup(groupPosition); + + if (convertView == null) { + LayoutInflater infalInflater = (LayoutInflater) this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + convertView = infalInflater.inflate(R.layout.item_msl_availability_header, null, false); + } + + TextView txt_categoryHeader = (TextView) convertView.findViewById(R.id.txt_categoryHeader); + RelativeLayout rel_header = (RelativeLayout) convertView.findViewById(R.id.rel_categoryHeader); + ImageView img_camera = (ImageView) convertView.findViewById(R.id.img_camera); + + txt_categoryHeader.setTypeface(null, Typeface.BOLD); + txt_categoryHeader.setText(headerTitle.getBrandName()); + + /*img_camera.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + String date = new Date().toLocaleString().toString(); + String TempDate = new Date().toLocaleString().toString().replace(' ', '_').replace(',', '_').replace(':', '-'); + + _pathforcheck = "Stock" + headerTitle.getBrand_cd() + "_" + store_cd + "_" + visit_date.replace("/", "") + getCurrentTime().replace(":", "") + ".jpg"; + child_position = groupPosition; + path = str + _pathforcheck; + + startCameraActivity(groupPosition); + } + }); + + if (!img1.equalsIgnoreCase("")) { + if (groupPosition == child_position) { + headerTitle.setImg_cam(img1); + img1 = ""; + } + } + + if (headerTitle.getImg_cam().equals("")) { + img_camera.setBackgroundResource(R.drawable.cam); + } else { + img_camera.setBackgroundResource(R.drawable.camtick); + } + + if (!checkflag) { + if (checkHeaderArray.contains(groupPosition)) { + txt_header.setTextColor(getResources().getColor(R.color.red)); + } else { + txt_header.setTextColor(getResources().getColor(R.color.grey_dark)); + } + }*/ + + return convertView; + } + + @Override + public Object getChild(int groupPosition, int childPosititon) { + return this._listDataChild.get(this._listDataHeader.get(groupPosition)).get(childPosititon); + } + + @Override + public int getChildrenCount(int groupPosition) { + return this._listDataChild.get(this._listDataHeader.get(groupPosition)).size(); + } + + @Override + public long getChildId(int groupPosition, int childPosition) { + return childPosition; + } + + @Override + public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, + View convertView, ViewGroup parent) { + MSL_AvailabilityGetterSetter childData = (MSL_AvailabilityGetterSetter) getChild(groupPosition, childPosition); + ViewHolder holder = null; + + if (convertView == null) { + LayoutInflater infalInflater = (LayoutInflater) this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + convertView = infalInflater.inflate(R.layout.item_msl_availability_child, null, false); + + holder = new ViewHolder(); + holder.cardView = (CardView) convertView.findViewById(R.id.card_view); + holder.lin_category = (LinearLayout) convertView.findViewById(R.id.lin_category); + + holder.txt_skuName = (TextView) convertView.findViewById(R.id.txt_skuName); + holder.ed_mbq = (EditText) convertView.findViewById(R.id.ed_mbq); + holder.toggle_available = (ToggleButton) convertView.findViewById(R.id.toggle_available); + convertView.setTag(holder); + } else { + holder = (ViewHolder) convertView.getTag(); + } + + holder.txt_skuName.setText(childData.getBrandName()); + holder.ed_mbq.setText(childData.getMbq()); + + holder.toggle_available.setTextOff("No"); + holder.toggle_available.setTextOn("Yes"); + + return convertView; + } + + @Override + public boolean hasStableIds() { + return false; + } + + @Override + public boolean isChildSelectable(int groupPosition, int childPosition) { + return true; + } + } + + public class ViewHolder { + EditText ed_mbq; + CardView cardView; + TextView txt_skuName; + ToggleButton toggle_available; + LinearLayout lin_category; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + if (id == android.R.id.home) { + finish(); + } + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/Stock_FacingActivity.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/Stock_FacingActivity.java new file mode 100644 index 0000000..478891c --- /dev/null +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/gsk_dailyentry/Stock_FacingActivity.java @@ -0,0 +1,467 @@ +package cpm.com.gskmtorange.gsk_dailyentry; + +import android.content.Context; +import android.content.Intent; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.graphics.Typeface; +import android.net.Uri; +import android.os.Bundle; +import android.os.Environment; +import android.provider.MediaStore; +import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.CardView; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.view.inputmethod.InputMethodManager; +import android.widget.AbsListView; +import android.widget.BaseExpandableListAdapter; +import android.widget.EditText; +import android.widget.ExpandableListView; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.TextView; +import android.widget.ToggleButton; + +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +import cpm.com.gskmtorange.R; +import cpm.com.gskmtorange.xmlGetterSetter.MSL_AvailabilityGetterSetter; +import cpm.com.gskmtorange.xmlGetterSetter.Stock_FacingGetterSetter; + +public class Stock_FacingActivity extends AppCompatActivity { + ExpandableListView expandableListView; + TextView txt_stockFacingName; + + ArrayList headerDataList; + ArrayList childDataList; + List hashMapListHeaderData; + HashMap> hashMapListChildData; + + ExpandableListAdapter adapter; + + String title; + + String path = "", str = "", _pathforcheck = "", img1 = ""; + static int child_position = -1; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_stock_facing); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + getSupportActionBar().setHomeButtonEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + expandableListView = (ExpandableListView) findViewById(R.id.expandableListView); + txt_stockFacingName = (TextView) findViewById(R.id.txt_stockFacingName); + + title = getIntent().getStringExtra("categoryName"); + txt_stockFacingName.setText(title); + + prepareList(); + + str = Environment.getExternalStorageState(); + + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + + expandableListView.setOnScrollListener(new AbsListView.OnScrollListener() { + @Override + public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { + } + + @Override + public void onScrollStateChanged(AbsListView arg0, int arg1) { + InputMethodManager inputManager = (InputMethodManager) getApplicationContext() + .getSystemService(Context.INPUT_METHOD_SERVICE); + if (getCurrentFocus() != null) { + inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); + getCurrentFocus().clearFocus(); + } + + expandableListView.invalidateViews(); + } + }); + + // Listview Group click listener + expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { + @Override + public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { + return false; + } + }); + + // Listview Group expanded listener + expandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() { + @Override + public void onGroupExpand(int groupPosition) { + InputMethodManager inputManager = (InputMethodManager) getApplicationContext() + .getSystemService(Context.INPUT_METHOD_SERVICE); + if (getWindow().getCurrentFocus() != null) { + inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); + getCurrentFocus().clearFocus(); + } + } + }); + + // Listview Group collasped listener + expandableListView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() { + @Override + public void onGroupCollapse(int groupPosition) { + InputMethodManager inputManager = (InputMethodManager) getApplicationContext() + .getSystemService(Context.INPUT_METHOD_SERVICE); + if (getWindow().getCurrentFocus() != null) { + inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); + getCurrentFocus().clearFocus(); + } + } + }); + + // Listview on child click listener + expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { + @Override + public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, + int childPosition, long id) { + return false; + } + }); + } + + private void prepareList() { + headerDataList = new ArrayList<>(); + + Stock_FacingGetterSetter msl = new Stock_FacingGetterSetter(); + msl.setBrandName("Parodontax header 1"); + msl.setMbq("1"); + msl.setAvailable("No"); + headerDataList.add(msl); + + msl = new Stock_FacingGetterSetter(); + msl.setBrandName("Parodontax header 2"); + msl.setMbq("2"); + msl.setAvailable("Yes"); + headerDataList.add(msl); + + msl = new Stock_FacingGetterSetter(); + msl.setBrandName("Parodontax header 3"); + msl.setMbq("3"); + msl.setAvailable("Yes"); + headerDataList.add(msl); + + msl = new Stock_FacingGetterSetter(); + msl.setBrandName("Parodontax header 4"); + msl.setMbq("4"); + msl.setAvailable("No"); + headerDataList.add(msl); + + + hashMapListHeaderData = new ArrayList<>(); + hashMapListChildData = new HashMap<>(); + + if (headerDataList.size() > 0) { + + for (int i = 0; i < headerDataList.size(); i++) { + hashMapListHeaderData.add(headerDataList.get(i)); + + childDataList = new ArrayList<>(); + + Stock_FacingGetterSetter msl1 = new Stock_FacingGetterSetter(); + msl.setBrandName("Parodontax 1"); + msl.setMbq("1"); + msl.setAvailable("No"); + childDataList.add(msl1); + + msl1 = new Stock_FacingGetterSetter(); + msl.setBrandName("Parodontax 2"); + msl.setMbq("2"); + msl.setAvailable("No"); + childDataList.add(msl1); + + hashMapListChildData.put(hashMapListHeaderData.get(i), childDataList); + } + + } + + adapter = new ExpandableListAdapter(this, hashMapListHeaderData, hashMapListChildData); + expandableListView.setAdapter(adapter); + } + + public class ExpandableListAdapter extends BaseExpandableListAdapter { + private Context _context; + private List _listDataHeader; + private HashMap> _listDataChild; + + public ExpandableListAdapter(Context context, List listDataHeader, + HashMap> listChildData) { + this._context = context; + this._listDataHeader = listDataHeader; + this._listDataChild = listChildData; + } + + @Override + public Object getGroup(int groupPosition) { + return this._listDataHeader.get(groupPosition); + } + + @Override + public int getGroupCount() { + return this._listDataHeader.size(); + } + + @Override + public long getGroupId(int groupPosition) { + return groupPosition; + } + + @Override + public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { + final Stock_FacingGetterSetter headerTitle = (Stock_FacingGetterSetter) getGroup(groupPosition); + + if (convertView == null) { + LayoutInflater infalInflater = (LayoutInflater) this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + convertView = infalInflater.inflate(R.layout.item_stock_facing_header, null, false); + } + + TextView txt_stockFaceupHeader = (TextView) convertView.findViewById(R.id.txt_stockFaceupHeader); + LinearLayout lin_stockFaceupHeader = (LinearLayout) convertView.findViewById(R.id.lin_stockFaceupHeader); + ImageView img_reference = (ImageView) convertView.findViewById(R.id.img_reference); + ImageView img_camera1 = (ImageView) convertView.findViewById(R.id.img_camera1); + ImageView img_camera2 = (ImageView) convertView.findViewById(R.id.img_camera2); + ImageView img_edit = (ImageView) convertView.findViewById(R.id.img_edit); + + txt_stockFaceupHeader.setTypeface(null, Typeface.BOLD); + txt_stockFaceupHeader.setText(headerTitle.getBrandName()); + + img_camera1.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + String date = new Date().toLocaleString().toString(); + String tempDate = new Date().toLocaleString().toString().replace(' ', '_').replace(',', '_').replace(':', '-'); + + _pathforcheck = "Stock Camera1_" + tempDate + ".jpg"; + child_position = groupPosition; + path = str + _pathforcheck; + + startCameraActivity(groupPosition); + } + }); + + if (!img1.equalsIgnoreCase("")) { + if (groupPosition == child_position) { + //headerTitle.setImg_cam(img1); + img1 = ""; + } + } + + + /*if (headerTitle.getImg_cam().equals("")) { + img_camera1.setBackgroundResource(R.drawable.ic_menu_camera); + } else { + //img_camera1.setBackgroundResource(R.drawable.camtick); + }*/ + + /*img_camera.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + String date = new Date().toLocaleString().toString(); + String TempDate = new Date().toLocaleString().toString().replace(' ', '_').replace(',', '_').replace(':', '-'); + + _pathforcheck = "Stock" + headerTitle.getBrand_cd() + "_" + store_cd + "_" + visit_date.replace("/", "") + getCurrentTime().replace(":", "") + ".jpg"; + child_position = groupPosition; + path = str + _pathforcheck; + + startCameraActivity(groupPosition); + } + }); + + if (!img1.equalsIgnoreCase("")) { + if (groupPosition == child_position) { + headerTitle.setImg_cam(img1); + img1 = ""; + } + } + + if (headerTitle.getImg_cam().equals("")) { + img_camera.setBackgroundResource(R.drawable.cam); + } else { + img_camera.setBackgroundResource(R.drawable.camtick); + } + + if (!checkflag) { + if (checkHeaderArray.contains(groupPosition)) { + txt_header.setTextColor(getResources().getColor(R.color.red)); + } else { + txt_header.setTextColor(getResources().getColor(R.color.grey_dark)); + } + }*/ + + return convertView; + } + + @Override + public Object getChild(int groupPosition, int childPosititon) { + return this._listDataChild.get(this._listDataHeader.get(groupPosition)).get(childPosititon); + } + + @Override + public int getChildrenCount(int groupPosition) { + return this._listDataChild.get(this._listDataHeader.get(groupPosition)).size(); + } + + @Override + public long getChildId(int groupPosition, int childPosition) { + return childPosition; + } + + @Override + public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, + View convertView, ViewGroup parent) { + Stock_FacingGetterSetter childData = (Stock_FacingGetterSetter) getChild(groupPosition, childPosition); + ViewHolder holder = null; + + if (convertView == null) { + LayoutInflater infalInflater = (LayoutInflater) this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + convertView = infalInflater.inflate(R.layout.item_stock_facing_child, null, false); + + holder = new ViewHolder(); + holder.cardView = (CardView) convertView.findViewById(R.id.card_view); + holder.lin_category = (LinearLayout) convertView.findViewById(R.id.lin_category); + + holder.txt_skuName = (TextView) convertView.findViewById(R.id.txt_skuName); + holder.ed_stock = (EditText) convertView.findViewById(R.id.ed_stock); + holder.ed_facing = (EditText) convertView.findViewById(R.id.ed_facing); + convertView.setTag(holder); + } else { + holder = (ViewHolder) convertView.getTag(); + } + + holder.txt_skuName.setText(childData.getBrandName()); + holder.ed_stock.setText(childData.getMbq()); + + return convertView; + } + + @Override + public boolean hasStableIds() { + return false; + } + + @Override + public boolean isChildSelectable(int groupPosition, int childPosition) { + return true; + } + } + + public class ViewHolder { + EditText ed_stock, ed_facing; + CardView cardView; + TextView txt_skuName; + LinearLayout lin_category; + } + + private void startCameraActivity(int position) { + try { + Log.e("Stock & Facing ", "startCameraActivity()"); + File file = new File(path); + Uri outputFileUri = Uri.fromFile(file); + + /*String defaultCameraPackage = ""; + final PackageManager packageManager = getPackageManager(); + List list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES); + + for (int n = 0; n < list.size(); n++) { + if ((list.get(n).flags & ApplicationInfo.FLAG_SYSTEM) == 1) { +// Log.d("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString()); +// Log.d("TAG", "package name : " + list.get(n).packageName); + if (list.get(n).loadLabel(packageManager).toString().equalsIgnoreCase("Camera")) { + defaultCameraPackage = list.get(n).packageName; + break; + } + } + } + + Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); + intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); + intent.setPackage(defaultCameraPackage); + startActivityForResult(intent, position);*/ + + Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); + intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); + startActivityForResult(intent, position); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + Log.e("Stock & Facing", "resultCode: " + resultCode); + switch (resultCode) { + case 0: + Log.e("Stock & Facing", "User cancelled"); + break; + case -1: + if (_pathforcheck != null && !_pathforcheck.equals("")) { + if (new File(str + _pathforcheck).exists()) { + img1 = _pathforcheck; + //adapter.notifyDataSetChanged(); + _pathforcheck = ""; + } + } + break; + } + // TODO Auto-generated method stub + super.onActivityResult(requestCode, resultCode, data); + } + + public String getCurrentTime() { + Calendar m_cal = Calendar.getInstance(); + SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss"); + String cdate = formatter.format(m_cal.getTime()); + /* String intime = m_cal.get(Calendar.HOUR_OF_DAY) + ":" + + m_cal.get(Calendar.MINUTE) + ":" + m_cal.get(Calendar.SECOND);*/ + + return cdate; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + if (id == android.R.id.home) { + finish(); + } + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/messgae/AlertMessage.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/messgae/AlertMessage.java new file mode 100644 index 0000000..9820940 --- /dev/null +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/messgae/AlertMessage.java @@ -0,0 +1,112 @@ +package cpm.com.gskmtorange.messgae; + +import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.Intent; + +import cpm.com.gskmtorange.GeoTag.GeoTagStoreList; + +/** + * Created by ashishc on 03-01-2017. + */ + +public class AlertMessage { + + public static final String MESSAGE_ERROR = "Network Error , "; + + public static final String MESSAGE_DATA_NOT = "Data Not Uploaded , "; + + private Exception exception; + String value; + private String data, condition,exceptionString; + private Activity activity; + private String error; + + + + public AlertMessage(Activity activity, String data, String condition, + Exception exception) { + this.activity = activity; + this.data = data; + this.condition = condition; + this.exception = exception; + } + + public AlertMessage(Activity activity, String data, String condition, + String exception, String a) { + this.activity = activity; + this.data = data; + this.condition = condition; + this.exceptionString = exception; + this.error = a; + } + + + public void showMessage() { + + if (condition.equals("success")) { + + ShowAlert1(data); + } + else if(condition.equals("failure")) + { + ShowAlertSocket(data); + } + + + + } + + public void ShowAlert1(String str) { + + AlertDialog.Builder builder = new AlertDialog.Builder(activity); + builder.setTitle("Parinaam"); + builder.setMessage(str).setCancelable(false) + .setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + Intent i = new Intent(activity, GeoTagStoreList.class); + activity.startActivity(i); + + activity.finish(); + + } + }); + AlertDialog alert = builder.create(); + alert.show(); + + } + + + public void ShowAlertSocket(String str) { + + AlertDialog.Builder builder = new AlertDialog.Builder(activity); + builder.setTitle("Parinaam"); + builder.setMessage(str).setCancelable(false) + .setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + Intent i = new Intent(activity, GeoTagStoreList.class); + activity.startActivity(i); + + activity.finish(); + + } + }); + AlertDialog alert = builder.create(); + alert.show(); + + } + + + + + + +} + + + + + diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/upload/Base64.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/upload/Base64.java new file mode 100644 index 0000000..0853330 --- /dev/null +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/upload/Base64.java @@ -0,0 +1,1810 @@ +package cpm.com.gskmtorange.upload; + + +/** + *

Encodes and decodes to and from Base64 notation.

+ *

Homepage: http://iharder.net/base64.

+ * + *

The options parameter, which appears in a few places, is used to pass + * several pieces of information to the encoder. In the "higher level" methods such as + * encodeBytes( bytes, options ) the options parameter can be used to indicate such + * things as first gzipping the bytes before encoding them, not inserting linefeeds + * (though that breaks strict Base64 compatibility), and encoding using the URL-safe + * and Ordered dialects.

+ * + *

The constants defined in Base64 can be OR-ed together to combine options, so you + * might make a call like this:

+ * + * String encoded = Base64.encodeBytes( mybytes, Base64.GZIP | Base64.DONT_BREAK_LINES ); + * + *

to compress the data before encoding it and then making the output have no newline characters.

+ * + * + *

+ * Change Log: + *

+ *
    + *
  • v2.2.2 - Fixed encodeFileToFile and decodeFileToFile to use the + * Base64.InputStream class to encode and decode on the fly which uses + * less memory than encoding/decoding an entire file into memory before writing.
  • + *
  • v2.2.1 - Fixed bug using URL_SAFE and ORDERED encodings. Fixed bug + * when using very small files (~< 40 bytes).
  • + *
  • v2.2 - Added some helper methods for encoding/decoding directly from + * one file to the next. Also added a main() method to support command line + * encoding/decoding from one file to the next. Also added these Base64 dialects: + *
      + *
    1. The default is RFC3548 format.
    2. + *
    3. Calling Base64.setFormat(Base64.BASE64_FORMAT.URLSAFE_FORMAT) generates + * URL and file name friendly format as described in Section 4 of RFC3548. + * http://www.faqs.org/rfcs/rfc3548.html
    4. + *
    5. Calling Base64.setFormat(Base64.BASE64_FORMAT.ORDERED_FORMAT) generates + * URL and file name friendly format that preserves lexical ordering as described + * in http://www.faqs.org/qa/rfcc-1940.html
    6. + *
    + * Special thanks to Jim Kellerman at http://www.powerset.com/ + * for contributing the new Base64 dialects. + *
  • + * + *
  • v2.1 - Cleaned up javadoc comments and unused variables and methods. Added + * some convenience methods for reading and writing to and from files.
  • + *
  • v2.0.2 - Now specifies UTF-8 encoding in places where the code fails on systems + * with other encodings (like EBCDIC).
  • + *
  • v2.0.1 - Fixed an error when decoding a single byte, that is, when the + * encoded data was a single byte.
  • + *
  • v2.0 - I got rid of methods that used booleans to set options. + * Now everything is more consolidated and cleaner. The code now detects + * when data that's being decoded is gzip-compressed and will decompress it + * automatically. Generally things are cleaner. You'll probably have to + * change some method calls that you were making to support the new + * options format (ints that you "OR" together).
  • + *
  • v1.5.1 - Fixed bug when decompressing and decoding to a + * byte[] using decode( String s, boolean gzipCompressed ). + * Added the ability to "suspend" encoding in the Output Stream so + * you can turn on and off the encoding if you need to embed base64 + * data in an otherwise "normal" stream (like an XML file).
  • + *
  • v1.5 - Output stream pases on flush() command but doesn't do anything itself. + * This helps when using GZIP streams. + * Added the ability to GZip-compress objects before encoding them.
  • + *
  • v1.4 - Added helper methods to read/write files.
  • + *
  • v1.3.6 - Fixed OutputStream.flush() so that 'position' is reset.
  • + *
  • v1.3.5 - Added flag to turn on and off line breaks. Fixed bug in input stream + * where last buffer being read, if not completely full, was not returned.
  • + *
  • v1.3.4 - Fixed when "improperly padded stream" error was thrown at the wrong time.
  • + *
  • v1.3.3 - Fixed I/O streams which were totally messed up.
  • + *
+ * + *

+ * I am placing this code in the Public Domain. Do with it as you will. + * This software comes with no guarantees or warranties but with + * plenty of well-wishing instead! + * Please visit http://iharder.net/base64 + * periodically to check for updates or to contribute improvements. + *

+ * + * @author Robert Harder + * @author rob@iharder.net + * @version 2.2.2 + */ +public class Base64 +{ + +/* ******** P U B L I C F I E L D S ******** */ + + + /** No options specified. Value is zero. */ + public final static int NO_OPTIONS = 0; + + /** Specify encoding. */ + public final static int ENCODE = 1; + + + /** Specify decoding. */ + public final static int DECODE = 0; + + + /** Specify that data should be gzip-compressed. */ + public final static int GZIP = 2; + + + /** Don't break lines when encoding (violates strict Base64 specification) */ + public final static int DONT_BREAK_LINES = 8; + + /** + * Encode using Base64-like encoding that is URL- and Filename-safe as described + * in Section 4 of RFC3548: + * http://www.faqs.org/rfcs/rfc3548.html. + * It is important to note that data encoded this way is not officially valid Base64, + * or at the very least should not be called Base64 without also specifying that is + * was encoded using the URL- and Filename-safe dialect. + */ + public final static int URL_SAFE = 16; + + + /** + * Encode using the special "ordered" dialect of Base64 described here: + * http://www.faqs.org/qa/rfcc-1940.html. + */ + public final static int ORDERED = 32; + + +/* ******** P R I V A T E F I E L D S ******** */ + + + /** Maximum line length (76) of Base64 output. */ + private final static int MAX_LINE_LENGTH = 76; + + + /** The equals sign (=) as a byte. */ + private final static byte EQUALS_SIGN = (byte)'='; + + + /** The new line character (\n) as a byte. */ + private final static byte NEW_LINE = (byte)'\n'; + + + /** Preferred encoding. */ + private final static String PREFERRED_ENCODING = "UTF-8"; + + + // I think I end up not using the BAD_ENCODING indicator. + //private final static byte BAD_ENCODING = -9; // Indicates error in encoding + private final static byte WHITE_SPACE_ENC = -5; // Indicates white space in encoding + private final static byte EQUALS_SIGN_ENC = -1; // Indicates equals sign in encoding + + +/* ******** S T A N D A R D B A S E 6 4 A L P H A B E T ******** */ + + /** The 64 valid Base64 values. */ + //private final static byte[] ALPHABET; + /* Host platform me be something funny like EBCDIC, so we hardcode these values. */ + private final static byte[] _STANDARD_ALPHABET = + { + (byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E', (byte)'F', (byte)'G', + (byte)'H', (byte)'I', (byte)'J', (byte)'K', (byte)'L', (byte)'M', (byte)'N', + (byte)'O', (byte)'P', (byte)'Q', (byte)'R', (byte)'S', (byte)'T', (byte)'U', + (byte)'V', (byte)'W', (byte)'X', (byte)'Y', (byte)'Z', + (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f', (byte)'g', + (byte)'h', (byte)'i', (byte)'j', (byte)'k', (byte)'l', (byte)'m', (byte)'n', + (byte)'o', (byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t', (byte)'u', + (byte)'v', (byte)'w', (byte)'x', (byte)'y', (byte)'z', + (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5', + (byte)'6', (byte)'7', (byte)'8', (byte)'9', (byte)'+', (byte)'/' + }; + + + /** + * Translates a Base64 value to either its 6-bit reconstruction value + * or a negative number indicating some other meaning. + **/ + private final static byte[] _STANDARD_DECODABET = + { + -9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 0 - 8 + -5,-5, // Whitespace: Tab and Linefeed + -9,-9, // Decimal 11 - 12 + -5, // Whitespace: Carriage Return + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 14 - 26 + -9,-9,-9,-9,-9, // Decimal 27 - 31 + -5, // Whitespace: Space + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 33 - 42 + 62, // Plus sign at decimal 43 + -9,-9,-9, // Decimal 44 - 46 + 63, // Slash at decimal 47 + 52,53,54,55,56,57,58,59,60,61, // Numbers zero through nine + -9,-9,-9, // Decimal 58 - 60 + -1, // Equals sign at decimal 61 + -9,-9,-9, // Decimal 62 - 64 + 0,1,2,3,4,5,6,7,8,9,10,11,12,13, // Letters 'A' through 'N' + 14,15,16,17,18,19,20,21,22,23,24,25, // Letters 'O' through 'Z' + -9,-9,-9,-9,-9,-9, // Decimal 91 - 96 + 26,27,28,29,30,31,32,33,34,35,36,37,38, // Letters 'a' through 'm' + 39,40,41,42,43,44,45,46,47,48,49,50,51, // Letters 'n' through 'z' + -9,-9,-9,-9 // Decimal 123 - 126 + /*,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 127 - 139 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 140 - 152 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 153 - 165 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 166 - 178 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 179 - 191 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 192 - 204 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 205 - 217 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 218 - 230 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 231 - 243 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9 // Decimal 244 - 255 */ + }; + + +/* ******** U R L S A F E B A S E 6 4 A L P H A B E T ******** */ + + /** + * Used in the URL- and Filename-safe dialect described in Section 4 of RFC3548: + * http://www.faqs.org/rfcs/rfc3548.html. + * Notice that the last two bytes become "hyphen" and "underscore" instead of "plus" and "slash." + */ + private final static byte[] _URL_SAFE_ALPHABET = + { + (byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E', (byte)'F', (byte)'G', + (byte)'H', (byte)'I', (byte)'J', (byte)'K', (byte)'L', (byte)'M', (byte)'N', + (byte)'O', (byte)'P', (byte)'Q', (byte)'R', (byte)'S', (byte)'T', (byte)'U', + (byte)'V', (byte)'W', (byte)'X', (byte)'Y', (byte)'Z', + (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f', (byte)'g', + (byte)'h', (byte)'i', (byte)'j', (byte)'k', (byte)'l', (byte)'m', (byte)'n', + (byte)'o', (byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t', (byte)'u', + (byte)'v', (byte)'w', (byte)'x', (byte)'y', (byte)'z', + (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5', + (byte)'6', (byte)'7', (byte)'8', (byte)'9', (byte)'-', (byte)'_' + }; + + /** + * Used in decoding URL- and Filename-safe dialects of Base64. + */ + private final static byte[] _URL_SAFE_DECODABET = + { + -9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 0 - 8 + -5,-5, // Whitespace: Tab and Linefeed + -9,-9, // Decimal 11 - 12 + -5, // Whitespace: Carriage Return + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 14 - 26 + -9,-9,-9,-9,-9, // Decimal 27 - 31 + -5, // Whitespace: Space + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 33 - 42 + -9, // Plus sign at decimal 43 + -9, // Decimal 44 + 62, // Minus sign at decimal 45 + -9, // Decimal 46 + -9, // Slash at decimal 47 + 52,53,54,55,56,57,58,59,60,61, // Numbers zero through nine + -9,-9,-9, // Decimal 58 - 60 + -1, // Equals sign at decimal 61 + -9,-9,-9, // Decimal 62 - 64 + 0,1,2,3,4,5,6,7,8,9,10,11,12,13, // Letters 'A' through 'N' + 14,15,16,17,18,19,20,21,22,23,24,25, // Letters 'O' through 'Z' + -9,-9,-9,-9, // Decimal 91 - 94 + 63, // Underscore at decimal 95 + -9, // Decimal 96 + 26,27,28,29,30,31,32,33,34,35,36,37,38, // Letters 'a' through 'm' + 39,40,41,42,43,44,45,46,47,48,49,50,51, // Letters 'n' through 'z' + -9,-9,-9,-9 // Decimal 123 - 126 + /*,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 127 - 139 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 140 - 152 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 153 - 165 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 166 - 178 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 179 - 191 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 192 - 204 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 205 - 217 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 218 - 230 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 231 - 243 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9 // Decimal 244 - 255 */ + }; + + + +/* ******** O R D E R E D B A S E 6 4 A L P H A B E T ******** */ + + /** + * I don't get the point of this technique, but it is described here: + * http://www.faqs.org/qa/rfcc-1940.html. + */ + private final static byte[] _ORDERED_ALPHABET = + { + (byte)'-', + (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', + (byte)'5', (byte)'6', (byte)'7', (byte)'8', (byte)'9', + (byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E', (byte)'F', (byte)'G', + (byte)'H', (byte)'I', (byte)'J', (byte)'K', (byte)'L', (byte)'M', (byte)'N', + (byte)'O', (byte)'P', (byte)'Q', (byte)'R', (byte)'S', (byte)'T', (byte)'U', + (byte)'V', (byte)'W', (byte)'X', (byte)'Y', (byte)'Z', + (byte)'_', + (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f', (byte)'g', + (byte)'h', (byte)'i', (byte)'j', (byte)'k', (byte)'l', (byte)'m', (byte)'n', + (byte)'o', (byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t', (byte)'u', + (byte)'v', (byte)'w', (byte)'x', (byte)'y', (byte)'z' + }; + + /** + * Used in decoding the "ordered" dialect of Base64. + */ + private final static byte[] _ORDERED_DECODABET = + { + -9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 0 - 8 + -5,-5, // Whitespace: Tab and Linefeed + -9,-9, // Decimal 11 - 12 + -5, // Whitespace: Carriage Return + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 14 - 26 + -9,-9,-9,-9,-9, // Decimal 27 - 31 + -5, // Whitespace: Space + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 33 - 42 + -9, // Plus sign at decimal 43 + -9, // Decimal 44 + 0, // Minus sign at decimal 45 + -9, // Decimal 46 + -9, // Slash at decimal 47 + 1,2,3,4,5,6,7,8,9,10, // Numbers zero through nine + -9,-9,-9, // Decimal 58 - 60 + -1, // Equals sign at decimal 61 + -9,-9,-9, // Decimal 62 - 64 + 11,12,13,14,15,16,17,18,19,20,21,22,23, // Letters 'A' through 'M' + 24,25,26,27,28,29,30,31,32,33,34,35,36, // Letters 'N' through 'Z' + -9,-9,-9,-9, // Decimal 91 - 94 + 37, // Underscore at decimal 95 + -9, // Decimal 96 + 38,39,40,41,42,43,44,45,46,47,48,49,50, // Letters 'a' through 'm' + 51,52,53,54,55,56,57,58,59,60,61,62,63, // Letters 'n' through 'z' + -9,-9,-9,-9 // Decimal 123 - 126 + /*,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 127 - 139 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 140 - 152 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 153 - 165 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 166 - 178 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 179 - 191 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 192 - 204 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 205 - 217 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 218 - 230 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 231 - 243 + -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9 // Decimal 244 - 255 */ + }; + + +/* ******** D E T E R M I N E W H I C H A L H A B E T ******** */ + + + /** + * Returns one of the _SOMETHING_ALPHABET byte arrays depending on + * the options specified. + * It's possible, though silly, to specify ORDERED and URLSAFE + * in which case one of them will be picked, though there is + * no guarantee as to which one will be picked. + */ + private final static byte[] getAlphabet( int options ) + { + if( (options & URL_SAFE) == URL_SAFE ) return _URL_SAFE_ALPHABET; + else if( (options & ORDERED) == ORDERED ) return _ORDERED_ALPHABET; + else return _STANDARD_ALPHABET; + + } // end getAlphabet + + + /** + * Returns one of the _SOMETHING_DECODABET byte arrays depending on + * the options specified. + * It's possible, though silly, to specify ORDERED and URL_SAFE + * in which case one of them will be picked, though there is + * no guarantee as to which one will be picked. + */ + private final static byte[] getDecodabet( int options ) + { + if( (options & URL_SAFE) == URL_SAFE ) return _URL_SAFE_DECODABET; + else if( (options & ORDERED) == ORDERED ) return _ORDERED_DECODABET; + else return _STANDARD_DECODABET; + + } // end getAlphabet + + + + /** Defeats instantiation. */ + private Base64(){} + + + /** + * Encodes or decodes two files from the command line; + * feel free to delete this method (in fact you probably should) + * if you're embedding this code into a larger program. + */ + public final static void main( String[] args ) + { + if( args.length < 3 ){ + usage("Not enough arguments."); + } // end if: args.length < 3 + else { + String flag = args[0]; + String infile = args[1]; + String outfile = args[2]; + if( flag.equals( "-e" ) ){ + Base64.encodeFileToFile( infile, outfile ); + } // end if: encode + else if( flag.equals( "-d" ) ) { + Base64.decodeFileToFile( infile, outfile ); + } // end else if: decode + else { + usage( "Unknown flag: " + flag ); + } // end else + } // end else + } // end main + + /** + * Prints command line usage. + * + * @param msg A message to include with usage info. + */ + private final static void usage( String msg ) + { + System.err.println( msg ); + System.err.println( "Usage: java Base64 -e|-d inputfile outputfile" ); + } // end usage + + +/* ******** E N C O D I N G M E T H O D S ******** */ + + + /** + * Encodes up to the first three bytes of array threeBytes + * and returns a four-byte array in Base64 notation. + * The actual number of significant bytes in your array is + * given by numSigBytes. + * The array threeBytes needs only be as big as + * numSigBytes. + * Code can reuse a byte array by passing a four-byte array as b4. + * + * @param b4 A reusable byte array to reduce array instantiation + * @param threeBytes the array to convert + * @param numSigBytes the number of significant bytes in your array + * @return four byte array in Base64 notation. + * @since 1.5.1 + */ + private static byte[] encode3to4( byte[] b4, byte[] threeBytes, int numSigBytes, int options ) + { + encode3to4( threeBytes, 0, numSigBytes, b4, 0, options ); + return b4; + } // end encode3to4 + + + /** + *

Encodes up to three bytes of the array source + * and writes the resulting four Base64 bytes to destination. + * The source and destination arrays can be manipulated + * anywhere along their length by specifying + * srcOffset and destOffset. + * This method does not check to make sure your arrays + * are large enough to accomodate srcOffset + 3 for + * the source array or destOffset + 4 for + * the destination array. + * The actual number of significant bytes in your array is + * given by numSigBytes.

+ *

This is the lowest level of the encoding methods with + * all possible parameters.

+ * + * @param source the array to convert + * @param srcOffset the index where conversion begins + * @param numSigBytes the number of significant bytes in your array + * @param destination the array to hold the conversion + * @param destOffset the index where output will be put + * @return the destination array + * @since 1.3 + */ + private static byte[] encode3to4( + byte[] source, int srcOffset, int numSigBytes, + byte[] destination, int destOffset, int options ) + { + byte[] ALPHABET = getAlphabet( options ); + + // 1 2 3 + // 01234567890123456789012345678901 Bit position + // --------000000001111111122222222 Array position from threeBytes + // --------| || || || | Six bit groups to index ALPHABET + // >>18 >>12 >> 6 >> 0 Right shift necessary + // 0x3f 0x3f 0x3f Additional AND + + // Create buffer with zero-padding if there are only one or two + // significant bytes passed in the array. + // We have to shift left 24 in order to flush out the 1's that appear + // when Java treats a value as negative that is cast from a byte to an int. + int inBuff = ( numSigBytes > 0 ? ((source[ srcOffset ] << 24) >>> 8) : 0 ) + | ( numSigBytes > 1 ? ((source[ srcOffset + 1 ] << 24) >>> 16) : 0 ) + | ( numSigBytes > 2 ? ((source[ srcOffset + 2 ] << 24) >>> 24) : 0 ); + + switch( numSigBytes ) + { + case 3: + destination[ destOffset ] = ALPHABET[ (inBuff >>> 18) ]; + destination[ destOffset + 1 ] = ALPHABET[ (inBuff >>> 12) & 0x3f ]; + destination[ destOffset + 2 ] = ALPHABET[ (inBuff >>> 6) & 0x3f ]; + destination[ destOffset + 3 ] = ALPHABET[ (inBuff ) & 0x3f ]; + return destination; + + case 2: + destination[ destOffset ] = ALPHABET[ (inBuff >>> 18) ]; + destination[ destOffset + 1 ] = ALPHABET[ (inBuff >>> 12) & 0x3f ]; + destination[ destOffset + 2 ] = ALPHABET[ (inBuff >>> 6) & 0x3f ]; + destination[ destOffset + 3 ] = EQUALS_SIGN; + return destination; + + case 1: + destination[ destOffset ] = ALPHABET[ (inBuff >>> 18) ]; + destination[ destOffset + 1 ] = ALPHABET[ (inBuff >>> 12) & 0x3f ]; + destination[ destOffset + 2 ] = EQUALS_SIGN; + destination[ destOffset + 3 ] = EQUALS_SIGN; + return destination; + + default: + return destination; + } // end switch + } // end encode3to4 + + + + /** + * Serializes an object and returns the Base64-encoded + * version of that serialized object. If the object + * cannot be serialized or there is another error, + * the method will return null. + * The object is not GZip-compressed before being encoded. + * + * @param serializableObject The object to encode + * @return The Base64-encoded object + * @since 1.4 + */ + public static String encodeObject( java.io.Serializable serializableObject ) + { + return encodeObject( serializableObject, NO_OPTIONS ); + } // end encodeObject + + + + /** + * Serializes an object and returns the Base64-encoded + * version of that serialized object. If the object + * cannot be serialized or there is another error, + * the method will return null. + *

+ * Valid options:

+		 *	 GZIP: gzip-compresses object before encoding it.
+		 *	 DONT_BREAK_LINES: don't break lines at 76 characters
+		 *		 Note: Technically, this makes your encoding non-compliant.
+		 * 
+ *

+ * Example: encodeObject( myObj, Base64.GZIP ) or + *

+ * Example: encodeObject( myObj, Base64.GZIP | Base64.DONT_BREAK_LINES ) + * + * @param serializableObject The object to encode + * @param options Specified options + * @return The Base64-encoded object + * @see Base64#GZIP + * @see Base64#DONT_BREAK_LINES + * @since 2.0 + */ + public static String encodeObject( java.io.Serializable serializableObject, int options ) + { + // Streams + java.io.ByteArrayOutputStream baos = null; + java.io.OutputStream b64os = null; + java.io.ObjectOutputStream oos = null; + java.util.zip.GZIPOutputStream gzos = null; + + // Isolate options + int gzip = (options & GZIP); + int dontBreakLines = (options & DONT_BREAK_LINES); + + try + { + // ObjectOutputStream -> (GZIP) -> Base64 -> ByteArrayOutputStream + baos = new java.io.ByteArrayOutputStream(); + b64os = new Base64.OutputStream( baos, ENCODE | options ); + + // GZip? + if( gzip == GZIP ) + { + gzos = new java.util.zip.GZIPOutputStream( b64os ); + oos = new java.io.ObjectOutputStream( gzos ); + } // end if: gzip + else + oos = new java.io.ObjectOutputStream( b64os ); + + oos.writeObject( serializableObject ); + } // end try + catch( java.io.IOException e ) + { + e.printStackTrace(); + return null; + } // end catch + finally + { + try{ oos.close(); } catch( Exception e ){} + try{ gzos.close(); } catch( Exception e ){} + try{ b64os.close(); } catch( Exception e ){} + try{ baos.close(); } catch( Exception e ){} + } // end finally + + // Return value according to relevant encoding. + try + { + return new String( baos.toByteArray(), PREFERRED_ENCODING ); + } // end try + catch (java.io.UnsupportedEncodingException uue) + { + return new String( baos.toByteArray() ); + } // end catch + + } // end encode + + + + /** + * Encodes a byte array into Base64 notation. + * Does not GZip-compress data. + * + * @param source The data to convert + * @since 1.4 + */ + public static String encodeBytes( byte[] source ) + { + return encodeBytes( source, 0, source.length, NO_OPTIONS ); + } // end encodeBytes + + + + /** + * Encodes a byte array into Base64 notation. + *

+ * Valid options:

+		 *	 GZIP: gzip-compresses object before encoding it.
+		 *	 DONT_BREAK_LINES: don't break lines at 76 characters
+		 *		 Note: Technically, this makes your encoding non-compliant.
+		 * 
+ *

+ * Example: encodeBytes( myData, Base64.GZIP ) or + *

+ * Example: encodeBytes( myData, Base64.GZIP | Base64.DONT_BREAK_LINES ) + * + * + * @param source The data to convert + * @param options Specified options + * @see Base64#GZIP + * @see Base64#DONT_BREAK_LINES + * @since 2.0 + */ + public static String encodeBytes( byte[] source, int options ) + { + return encodeBytes( source, 0, source.length, options ); + } // end encodeBytes + + + /** + * Encodes a byte array into Base64 notation. + * Does not GZip-compress data. + * + * @param source The data to convert + * @param off Offset in array where conversion should begin + * @param len Length of data to convert + * @since 1.4 + */ + public static String encodeBytes( byte[] source, int off, int len ) + { + return encodeBytes( source, off, len, NO_OPTIONS ); + } // end encodeBytes + + + + /** + * Encodes a byte array into Base64 notation. + *

+ * Valid options:

+		 *	 GZIP: gzip-compresses object before encoding it.
+		 *	 DONT_BREAK_LINES: don't break lines at 76 characters
+		 *		 Note: Technically, this makes your encoding non-compliant.
+		 * 
+ *

+ * Example: encodeBytes( myData, Base64.GZIP ) or + *

+ * Example: encodeBytes( myData, Base64.GZIP | Base64.DONT_BREAK_LINES ) + * + * + * @param source The data to convert + * @param off Offset in array where conversion should begin + * @param len Length of data to convert + * @param options Specified options + * @param options alphabet type is pulled from this (standard, url-safe, ordered) + * @see Base64#GZIP + * @see Base64#DONT_BREAK_LINES + * @since 2.0 + */ + public static String encodeBytes( byte[] source, int off, int len, int options ) + { + // Isolate options + int dontBreakLines = ( options & DONT_BREAK_LINES ); + int gzip = ( options & GZIP ); + + // Compress? + if( gzip == GZIP ) + { + java.io.ByteArrayOutputStream baos = null; + java.util.zip.GZIPOutputStream gzos = null; + Base64.OutputStream b64os = null; + + + try + { + // GZip -> Base64 -> ByteArray + baos = new java.io.ByteArrayOutputStream(); + b64os = new Base64.OutputStream( baos, ENCODE | options ); + gzos = new java.util.zip.GZIPOutputStream( b64os ); + + gzos.write( source, off, len ); + gzos.close(); + } // end try + catch( java.io.IOException e ) + { + e.printStackTrace(); + return null; + } // end catch + finally + { + try{ gzos.close(); } catch( Exception e ){} + try{ b64os.close(); } catch( Exception e ){} + try{ baos.close(); } catch( Exception e ){} + } // end finally + + // Return value according to relevant encoding. + try + { + return new String( baos.toByteArray(), PREFERRED_ENCODING ); + } // end try + catch (java.io.UnsupportedEncodingException uue) + { + return new String( baos.toByteArray() ); + } // end catch + } // end if: compress + + // Else, don't compress. Better not to use streams at all then. + else + { + // Convert option to boolean in way that code likes it. + boolean breakLines = dontBreakLines == 0; + + int len43 = len * 4 / 3; + byte[] outBuff = new byte[ ( len43 ) // Main 4:3 + + ( (len % 3) > 0 ? 4 : 0 ) // Account for padding + + (breakLines ? ( len43 / MAX_LINE_LENGTH ) : 0) ]; // New lines + int d = 0; + int e = 0; + int len2 = len - 2; + int lineLength = 0; + for( ; d < len2; d+=3, e+=4 ) + { + encode3to4( source, d+off, 3, outBuff, e, options ); + + lineLength += 4; + if( breakLines && lineLength == MAX_LINE_LENGTH ) + { + outBuff[e+4] = NEW_LINE; + e++; + lineLength = 0; + } // end if: end of line + } // en dfor: each piece of array + + if( d < len ) + { + encode3to4( source, d+off, len - d, outBuff, e, options ); + e += 4; + } // end if: some padding needed + + + // Return value according to relevant encoding. + try + { + return new String( outBuff, 0, e, PREFERRED_ENCODING ); + } // end try + catch (java.io.UnsupportedEncodingException uue) + { + return new String( outBuff, 0, e ); + } // end catch + + } // end else: don't compress + + } // end encodeBytes + + + + + +/* ******** D E C O D I N G M E T H O D S ******** */ + + + /** + * Decodes four bytes from array source + * and writes the resulting bytes (up to three of them) + * to destination. + * The source and destination arrays can be manipulated + * anywhere along their length by specifying + * srcOffset and destOffset. + * This method does not check to make sure your arrays + * are large enough to accomodate srcOffset + 4 for + * the source array or destOffset + 3 for + * the destination array. + * This method returns the actual number of bytes that + * were converted from the Base64 encoding. + *

This is the lowest level of the decoding methods with + * all possible parameters.

+ * + * + * @param source the array to convert + * @param srcOffset the index where conversion begins + * @param destination the array to hold the conversion + * @param destOffset the index where output will be put + * @param options alphabet type is pulled from this (standard, url-safe, ordered) + * @return the number of decoded bytes converted + * @since 1.3 + */ + private static int decode4to3( byte[] source, int srcOffset, byte[] destination, int destOffset, int options ) + { + byte[] DECODABET = getDecodabet( options ); + + // Example: Dk== + if( source[ srcOffset + 2] == EQUALS_SIGN ) + { + // Two ways to do the same thing. Don't know which way I like best. + //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 ) + // | ( ( DECODABET[ source[ srcOffset + 1] ] << 24 ) >>> 12 ); + int outBuff = ( ( DECODABET[ source[ srcOffset ] ] & 0xFF ) << 18 ) + | ( ( DECODABET[ source[ srcOffset + 1] ] & 0xFF ) << 12 ); + + destination[ destOffset ] = (byte)( outBuff >>> 16 ); + return 1; + } + + // Example: DkL= + else if( source[ srcOffset + 3 ] == EQUALS_SIGN ) + { + // Two ways to do the same thing. Don't know which way I like best. + //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 ) + // | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 ) + // | ( ( DECODABET[ source[ srcOffset + 2 ] ] << 24 ) >>> 18 ); + int outBuff = ( ( DECODABET[ source[ srcOffset ] ] & 0xFF ) << 18 ) + | ( ( DECODABET[ source[ srcOffset + 1 ] ] & 0xFF ) << 12 ) + | ( ( DECODABET[ source[ srcOffset + 2 ] ] & 0xFF ) << 6 ); + + destination[ destOffset ] = (byte)( outBuff >>> 16 ); + destination[ destOffset + 1 ] = (byte)( outBuff >>> 8 ); + return 2; + } + + // Example: DkLE + else + { + try{ + // Two ways to do the same thing. Don't know which way I like best. + //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 ) + // | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 ) + // | ( ( DECODABET[ source[ srcOffset + 2 ] ] << 24 ) >>> 18 ) + // | ( ( DECODABET[ source[ srcOffset + 3 ] ] << 24 ) >>> 24 ); + int outBuff = ( ( DECODABET[ source[ srcOffset ] ] & 0xFF ) << 18 ) + | ( ( DECODABET[ source[ srcOffset + 1 ] ] & 0xFF ) << 12 ) + | ( ( DECODABET[ source[ srcOffset + 2 ] ] & 0xFF ) << 6) + | ( ( DECODABET[ source[ srcOffset + 3 ] ] & 0xFF ) ); + + + destination[ destOffset ] = (byte)( outBuff >> 16 ); + destination[ destOffset + 1 ] = (byte)( outBuff >> 8 ); + destination[ destOffset + 2 ] = (byte)( outBuff ); + + return 3; + }catch( Exception e){ + System.out.println(""+source[srcOffset]+ ": " + ( DECODABET[ source[ srcOffset ] ] ) ); + System.out.println(""+source[srcOffset+1]+ ": " + ( DECODABET[ source[ srcOffset + 1 ] ] ) ); + System.out.println(""+source[srcOffset+2]+ ": " + ( DECODABET[ source[ srcOffset + 2 ] ] ) ); + System.out.println(""+source[srcOffset+3]+ ": " + ( DECODABET[ source[ srcOffset + 3 ] ] ) ); + return -1; + } // end catch + } + } // end decodeToBytes + + + + + /** + * Very low-level access to decoding ASCII characters in + * the form of a byte array. Does not support automatically + * gunzipping or any other "fancy" features. + * + * @param source The Base64 encoded data + * @param off The offset of where to begin decoding + * @param len The length of characters to decode + * @return decoded data + * @since 1.3 + */ + public static byte[] decode( byte[] source, int off, int len, int options ) + { + byte[] DECODABET = getDecodabet( options ); + + int len34 = len * 3 / 4; + byte[] outBuff = new byte[ len34 ]; // Upper limit on size of output + int outBuffPosn = 0; + + byte[] b4 = new byte[4]; + int b4Posn = 0; + int i = 0; + byte sbiCrop = 0; + byte sbiDecode = 0; + for( i = off; i < off+len; i++ ) + { + sbiCrop = (byte)(source[i] & 0x7f); // Only the low seven bits + sbiDecode = DECODABET[ sbiCrop ]; + + if( sbiDecode >= WHITE_SPACE_ENC ) // White space, Equals sign or better + { + if( sbiDecode >= EQUALS_SIGN_ENC ) + { + b4[ b4Posn++ ] = sbiCrop; + if( b4Posn > 3 ) + { + outBuffPosn += decode4to3( b4, 0, outBuff, outBuffPosn, options ); + b4Posn = 0; + + // If that was the equals sign, break out of 'for' loop + if( sbiCrop == EQUALS_SIGN ) + break; + } // end if: quartet built + + } // end if: equals sign or better + + } // end if: white space, equals sign or better + else + { + System.err.println( "Bad Base64 input character at " + i + ": " + source[i] + "(decimal)" ); + return null; + } // end else: + } // each input character + + byte[] out = new byte[ outBuffPosn ]; + System.arraycopy( outBuff, 0, out, 0, outBuffPosn ); + return out; + } // end decode + + + + + /** + * Decodes data from Base64 notation, automatically + * detecting gzip-compressed data and decompressing it. + * + * @param s the string to decode + * @return the decoded data + * @since 1.4 + */ + public static byte[] decode( String s ) + { + return decode( s, NO_OPTIONS ); + } + + + /** + * Decodes data from Base64 notation, automatically + * detecting gzip-compressed data and decompressing it. + * + * @param s the string to decode + * @param options encode options such as URL_SAFE + * @return the decoded data + * @since 1.4 + */ + public static byte[] decode( String s, int options ) + { + byte[] bytes; + try + { + bytes = s.getBytes( PREFERRED_ENCODING ); + } // end try + catch( java.io.UnsupportedEncodingException uee ) + { + bytes = s.getBytes(); + } // end catch + // + + // Decode + bytes = decode( bytes, 0, bytes.length, options ); + + + // Check to see if it's gzip-compressed + // GZIP Magic Two-Byte Number: 0x8b1f (35615) + if( bytes != null && bytes.length >= 4 ) + { + + int head = ((int)bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00); + if( java.util.zip.GZIPInputStream.GZIP_MAGIC == head ) + { + java.io.ByteArrayInputStream bais = null; + java.util.zip.GZIPInputStream gzis = null; + java.io.ByteArrayOutputStream baos = null; + byte[] buffer = new byte[2048]; + int length = 0; + + try + { + baos = new java.io.ByteArrayOutputStream(); + bais = new java.io.ByteArrayInputStream( bytes ); + gzis = new java.util.zip.GZIPInputStream( bais ); + + while( ( length = gzis.read( buffer ) ) >= 0 ) + { + baos.write(buffer,0,length); + } // end while: reading input + + // No error? Get new bytes. + bytes = baos.toByteArray(); + + } // end try + catch( java.io.IOException e ) + { + // Just return originally-decoded bytes + } // end catch + finally + { + try{ baos.close(); } catch( Exception e ){} + try{ gzis.close(); } catch( Exception e ){} + try{ bais.close(); } catch( Exception e ){} + } // end finally + + } // end if: gzipped + } // end if: bytes.length >= 2 + + return bytes; + } // end decode + + + + + /** + * Attempts to decode Base64 data and deserialize a Java + * Object within. Returns null if there was an error. + * + * @param encodedObject The Base64 data to decode + * @return The decoded and deserialized object + * @since 1.5 + */ + public static Object decodeToObject( String encodedObject ) + { + // Decode and gunzip if necessary + byte[] objBytes = decode( encodedObject ); + + java.io.ByteArrayInputStream bais = null; + java.io.ObjectInputStream ois = null; + Object obj = null; + + try + { + bais = new java.io.ByteArrayInputStream( objBytes ); + ois = new java.io.ObjectInputStream( bais ); + + obj = ois.readObject(); + } // end try + catch( java.io.IOException e ) + { + e.printStackTrace(); + obj = null; + } // end catch + catch( ClassNotFoundException e ) + { + e.printStackTrace(); + obj = null; + } // end catch + finally + { + try{ bais.close(); } catch( Exception e ){} + try{ ois.close(); } catch( Exception e ){} + } // end finally + + return obj; + } // end decodeObject + + + + /** + * Convenience method for encoding data to a file. + * + * @param dataToEncode byte array of data to encode in base64 form + * @param filename Filename for saving encoded data + * @return true if successful, false otherwise + * + * @since 2.1 + */ + public static boolean encodeToFile( byte[] dataToEncode, String filename ) + { + boolean success = false; + Base64.OutputStream bos = null; + try + { + bos = new Base64.OutputStream( + new java.io.FileOutputStream( filename ), Base64.ENCODE ); + bos.write( dataToEncode ); + success = true; + } // end try + catch( java.io.IOException e ) + { + + success = false; + } // end catch: IOException + finally + { + try{ bos.close(); } catch( Exception e ){} + } // end finally + + return success; + } // end encodeToFile + + + /** + * Convenience method for decoding data to a file. + * + * @param dataToDecode Base64-encoded data as a string + * @param filename Filename for saving decoded data + * @return true if successful, false otherwise + * + * @since 2.1 + */ + public static boolean decodeToFile( String dataToDecode, String filename ) + { + boolean success = false; + Base64.OutputStream bos = null; + try + { + bos = new Base64.OutputStream( + new java.io.FileOutputStream( filename ), Base64.DECODE ); + bos.write( dataToDecode.getBytes( PREFERRED_ENCODING ) ); + success = true; + } // end try + catch( java.io.IOException e ) + { + success = false; + } // end catch: IOException + finally + { + try{ bos.close(); } catch( Exception e ){} + } // end finally + + return success; + } // end decodeToFile + + + + + /** + * Convenience method for reading a base64-encoded + * file and decoding it. + * + * @param filename Filename for reading encoded data + * @return decoded byte array or null if unsuccessful + * + * @since 2.1 + */ + public static byte[] decodeFromFile( String filename ) + { + byte[] decodedData = null; + Base64.InputStream bis = null; + try + { + // Set up some useful variables + java.io.File file = new java.io.File( filename ); + byte[] buffer = null; + int length = 0; + int numBytes = 0; + + // Check for size of file + if( file.length() > Integer.MAX_VALUE ) + { + System.err.println( "File is too big for this convenience method (" + file.length() + " bytes)." ); + return null; + } // end if: file too big for int index + buffer = new byte[ (int)file.length() ]; + + // Open a stream + bis = new Base64.InputStream( + new java.io.BufferedInputStream( + new java.io.FileInputStream( file ) ), Base64.DECODE ); + + // Read until done + while( ( numBytes = bis.read( buffer, length, 4096 ) ) >= 0 ) + length += numBytes; + + // Save in a variable to return + decodedData = new byte[ length ]; + System.arraycopy( buffer, 0, decodedData, 0, length ); + + } // end try + catch( java.io.IOException e ) + { + System.err.println( "Error decoding from file " + filename ); + } // end catch: IOException + finally + { + try{ bis.close(); } catch( Exception e) {} + } // end finally + + return decodedData; + } // end decodeFromFile + + + + /** + * Convenience method for reading a binary file + * and base64-encoding it. + * + * @param filename Filename for reading binary data + * @return base64-encoded string or null if unsuccessful + * + * @since 2.1 + */ + public static String encodeFromFile( String filename ) + { + String encodedData = null; + Base64.InputStream bis = null; + try + { + // Set up some useful variables + java.io.File file = new java.io.File( filename ); + byte[] buffer = new byte[ Math.max((int)(file.length() * 1.4),40) ]; // Need max() for math on small files (v2.2.1) + int length = 0; + int numBytes = 0; + + // Open a stream + bis = new Base64.InputStream( + new java.io.BufferedInputStream( + new java.io.FileInputStream( file ) ), Base64.ENCODE ); + + // Read until done + while( ( numBytes = bis.read( buffer, length, 4096 ) ) >= 0 ) + length += numBytes; + + // Save in a variable to return + encodedData = new String( buffer, 0, length, Base64.PREFERRED_ENCODING ); + + } // end try + catch( java.io.IOException e ) + { + System.err.println( "Error encoding from file " + filename ); + } // end catch: IOException + finally + { + try{ bis.close(); } catch( Exception e) {} + } // end finally + + return encodedData; + } // end encodeFromFile + + + + + /** + * Reads infile and encodes it to outfile. + * + * @param infile Input file + * @param outfile Output file + * @return true if the operation is successful + * @since 2.2 + */ + public static boolean encodeFileToFile( String infile, String outfile ) + { + boolean success = false; + java.io.InputStream in = null; + java.io.OutputStream out = null; + try{ + in = new Base64.InputStream( + new java.io.BufferedInputStream( + new java.io.FileInputStream( infile ) ), + Base64.ENCODE ); + out = new java.io.BufferedOutputStream( new java.io.FileOutputStream( outfile ) ); + byte[] buffer = new byte[65536]; // 64K + int read = -1; + while( ( read = in.read(buffer) ) >= 0 ){ + out.write( buffer,0,read ); + } // end while: through file + success = true; + } catch( java.io.IOException exc ){ + exc.printStackTrace(); + } finally{ + try{ in.close(); } catch( Exception exc ){} + try{ out.close(); } catch( Exception exc ){} + } // end finally + + return success; + } // end encodeFileToFile + + + + /** + * Reads infile and decodes it to outfile. + * + * @param infile Input file + * @param outfile Output file + * @return true if the operation is successful + * @since 2.2 + */ + public static boolean decodeFileToFile( String infile, String outfile ) + { + boolean success = false; + java.io.InputStream in = null; + java.io.OutputStream out = null; + try{ + in = new Base64.InputStream( + new java.io.BufferedInputStream( + new java.io.FileInputStream( infile ) ), + Base64.DECODE ); + out = new java.io.BufferedOutputStream( new java.io.FileOutputStream( outfile ) ); + byte[] buffer = new byte[65536]; // 64K + int read = -1; + while( ( read = in.read(buffer) ) >= 0 ){ + out.write( buffer,0,read ); + } // end while: through file + success = true; + } catch( java.io.IOException exc ){ + exc.printStackTrace(); + } finally{ + try{ in.close(); } catch( Exception exc ){} + try{ out.close(); } catch( Exception exc ){} + } // end finally + + return success; + } // end decodeFileToFile + + + /* ******** I N N E R C L A S S I N P U T S T R E A M ******** */ + + + + /** + * A {@link Base64.InputStream} will read data from another + * java.io.InputStream, given in the constructor, + * and encode/decode to/from Base64 notation on the fly. + * + * @see Base64 + * @since 1.3 + */ + public static class InputStream extends java.io.FilterInputStream + { + private boolean encode; // Encoding or decoding + private int position; // Current position in the buffer + private byte[] buffer; // Small buffer holding converted data + private int bufferLength; // Length of buffer (3 or 4) + private int numSigBytes; // Number of meaningful bytes in the buffer + private int lineLength; + private boolean breakLines; // Break lines at less than 80 characters + private int options; // Record options used to create the stream. + private byte[] alphabet; // Local copies to avoid extra method calls + private byte[] decodabet; // Local copies to avoid extra method calls + + + /** + * Constructs a {@link Base64.InputStream} in DECODE mode. + * + * @param in the java.io.InputStream from which to read data. + * @since 1.3 + */ + public InputStream( java.io.InputStream in ) + { + this( in, DECODE ); + } // end constructor + + + /** + * Constructs a {@link Base64.InputStream} in + * either ENCODE or DECODE mode. + *

+ * Valid options:

+				 *	 ENCODE or DECODE: Encode or Decode as data is read.
+				 *	 DONT_BREAK_LINES: don't break lines at 76 characters
+				 *		 (only meaningful when encoding)
+				 *		 Note: Technically, this makes your encoding non-compliant.
+				 * 
+ *

+ * Example: new Base64.InputStream( in, Base64.DECODE ) + * + * + * @param in the java.io.InputStream from which to read data. + * @param options Specified options + * @see Base64#ENCODE + * @see Base64#DECODE + * @see Base64#DONT_BREAK_LINES + * @since 2.0 + */ + public InputStream( java.io.InputStream in, int options ) + { + super( in ); + this.breakLines = (options & DONT_BREAK_LINES) != DONT_BREAK_LINES; + this.encode = (options & ENCODE) == ENCODE; + this.bufferLength = encode ? 4 : 3; + this.buffer = new byte[ bufferLength ]; + this.position = -1; + this.lineLength = 0; + this.options = options; // Record for later, mostly to determine which alphabet to use + this.alphabet = getAlphabet(options); + this.decodabet = getDecodabet(options); + } // end constructor + + /** + * Reads enough of the input stream to convert + * to/from Base64 and returns the next byte. + * + * @return next byte + * @since 1.3 + */ + public int read() throws java.io.IOException + { + // Do we need to get data? + if( position < 0 ) + { + if( encode ) + { + byte[] b3 = new byte[3]; + int numBinaryBytes = 0; + for( int i = 0; i < 3; i++ ) + { + try + { + int b = in.read(); + + // If end of stream, b is -1. + if( b >= 0 ) + { + b3[i] = (byte)b; + numBinaryBytes++; + } // end if: not end of stream + + } // end try: read + catch( java.io.IOException e ) + { + // Only a problem if we got no data at all. + if( i == 0 ) + throw e; + + } // end catch + } // end for: each needed input byte + + if( numBinaryBytes > 0 ) + { + encode3to4( b3, 0, numBinaryBytes, buffer, 0, options ); + position = 0; + numSigBytes = 4; + } // end if: got data + else + { + return -1; + } // end else + } // end if: encoding + + // Else decoding + else + { + byte[] b4 = new byte[4]; + int i = 0; + for( i = 0; i < 4; i++ ) + { + // Read four "meaningful" bytes: + int b = 0; + do{ b = in.read(); } + while( b >= 0 && decodabet[ b & 0x7f ] <= WHITE_SPACE_ENC ); + + if( b < 0 ) + break; // Reads a -1 if end of stream + + b4[i] = (byte)b; + } // end for: each needed input byte + + if( i == 4 ) + { + numSigBytes = decode4to3( b4, 0, buffer, 0, options ); + position = 0; + } // end if: got four characters + else if( i == 0 ){ + return -1; + } // end else if: also padded correctly + else + { + // Must have broken out from above. + throw new java.io.IOException( "Improperly padded Base64 input." ); + } // end + + } // end else: decode + } // end else: get data + + // Got data? + if( position >= 0 ) + { + // End of relevant data? + if( /*!encode &&*/ position >= numSigBytes ) + return -1; + + if( encode && breakLines && lineLength >= MAX_LINE_LENGTH ) + { + lineLength = 0; + return '\n'; + } // end if + else + { + lineLength++; // This isn't important when decoding + // but throwing an extra "if" seems + // just as wasteful. + + int b = buffer[ position++ ]; + + if( position >= bufferLength ) + position = -1; + + return b & 0xFF; // This is how you "cast" a byte that's + // intended to be unsigned. + } // end else + } // end if: position >= 0 + + // Else error + else + { + // When JDK1.4 is more accepted, use an assertion here. + throw new java.io.IOException( "Error in Base64 code reading stream." ); + } // end else + } // end read + + + /** + * Calls {@link #read()} repeatedly until the end of stream + * is reached or len bytes are read. + * Returns number of bytes read into array or -1 if + * end of stream is encountered. + * + * @param dest array to hold values + * @param off offset for array + * @param len max number of bytes to read into array + * @return bytes read into array or -1 if end of stream is encountered. + * @since 1.3 + */ + public int read( byte[] dest, int off, int len ) throws java.io.IOException + { + int i; + int b; + for( i = 0; i < len; i++ ) + { + b = read(); + + //if( b < 0 && i == 0 ) + // return -1; + + if( b >= 0 ) + dest[off + i] = (byte)b; + else if( i == 0 ) + return -1; + else + break; // Out of 'for' loop + } // end for: each byte read + return i; + } // end read + + } // end inner class InputStream + + + + + + + /* ******** I N N E R C L A S S O U T P U T S T R E A M ******** */ + + + + /** + * A {@link Base64.OutputStream} will write data to another + * java.io.OutputStream, given in the constructor, + * and encode/decode to/from Base64 notation on the fly. + * + * @see Base64 + * @since 1.3 + */ + public static class OutputStream extends java.io.FilterOutputStream + { + private boolean encode; + private int position; + private byte[] buffer; + private int bufferLength; + private int lineLength; + private boolean breakLines; + private byte[] b4; // Scratch used in a few places + private boolean suspendEncoding; + private int options; // Record for later + private byte[] alphabet; // Local copies to avoid extra method calls + private byte[] decodabet; // Local copies to avoid extra method calls + + /** + * Constructs a {@link Base64.OutputStream} in ENCODE mode. + * + * @param out the java.io.OutputStream to which data will be written. + * @since 1.3 + */ + public OutputStream( java.io.OutputStream out ) + { + this( out, ENCODE ); + } // end constructor + + + /** + * Constructs a {@link Base64.OutputStream} in + * either ENCODE or DECODE mode. + *

+ * Valid options:

+				 *	 ENCODE or DECODE: Encode or Decode as data is read.
+				 *	 DONT_BREAK_LINES: don't break lines at 76 characters
+				 *		 (only meaningful when encoding)
+				 *		 Note: Technically, this makes your encoding non-compliant.
+				 * 
+ *

+ * Example: new Base64.OutputStream( out, Base64.ENCODE ) + * + * @param out the java.io.OutputStream to which data will be written. + * @param options Specified options. + * @see Base64#ENCODE + * @see Base64#DECODE + * @see Base64#DONT_BREAK_LINES + * @since 1.3 + */ + public OutputStream( java.io.OutputStream out, int options ) + { + super( out ); + this.breakLines = (options & DONT_BREAK_LINES) != DONT_BREAK_LINES; + this.encode = (options & ENCODE) == ENCODE; + this.bufferLength = encode ? 3 : 4; + this.buffer = new byte[ bufferLength ]; + this.position = 0; + this.lineLength = 0; + this.suspendEncoding = false; + this.b4 = new byte[4]; + this.options = options; + this.alphabet = getAlphabet(options); + this.decodabet = getDecodabet(options); + } // end constructor + + + /** + * Writes the byte to the output stream after + * converting to/from Base64 notation. + * When encoding, bytes are buffered three + * at a time before the output stream actually + * gets a write() call. + * When decoding, bytes are buffered four + * at a time. + * + * @param theByte the byte to write + * @since 1.3 + */ + public void write(int theByte) throws java.io.IOException + { + // Encoding suspended? + if( suspendEncoding ) + { + super.out.write( theByte ); + return; + } // end if: supsended + + // Encode? + if( encode ) + { + buffer[ position++ ] = (byte)theByte; + if( position >= bufferLength ) // Enough to encode. + { + out.write( encode3to4( b4, buffer, bufferLength, options ) ); + + lineLength += 4; + if( breakLines && lineLength >= MAX_LINE_LENGTH ) + { + out.write( NEW_LINE ); + lineLength = 0; + } // end if: end of line + + position = 0; + } // end if: enough to output + } // end if: encoding + + // Else, Decoding + else + { + // Meaningful Base64 character? + if( decodabet[ theByte & 0x7f ] > WHITE_SPACE_ENC ) + { + buffer[ position++ ] = (byte)theByte; + if( position >= bufferLength ) // Enough to output. + { + int len = Base64.decode4to3( buffer, 0, b4, 0, options ); + out.write( b4, 0, len ); + //out.write( Base64.decode4to3( buffer ) ); + position = 0; + } // end if: enough to output + } // end if: meaningful base64 character + else if( decodabet[ theByte & 0x7f ] != WHITE_SPACE_ENC ) + { + throw new java.io.IOException( "Invalid character in Base64 data." ); + } // end else: not white space either + } // end else: decoding + } // end write + + + + /** + * Calls {@link #write(int)} repeatedly until len + * bytes are written. + * + * @param theBytes array from which to read bytes + * @param off offset for array + * @param len max number of bytes to read into array + * @since 1.3 + */ + public void write( byte[] theBytes, int off, int len ) throws java.io.IOException + { + // Encoding suspended? + if( suspendEncoding ) + { + super.out.write( theBytes, off, len ); + return; + } // end if: supsended + + for( int i = 0; i < len; i++ ) + { + write( theBytes[ off + i ] ); + } // end for: each byte written + + } // end write + + + + /** + * Method added by PHIL. [Thanks, PHIL. -Rob] + * This pads the buffer without closing the stream. + */ + public void flushBase64() throws java.io.IOException + { + if( position > 0 ) + { + if( encode ) + { + out.write( encode3to4( b4, buffer, position, options ) ); + position = 0; + } // end if: encoding + else + { + throw new java.io.IOException( "Base64 input not properly padded." ); + } // end else: decoding + } // end if: buffer partially full + + } // end flush + + + /** + * Flushes and closes (I think, in the superclass) the stream. + * + * @since 1.3 + */ + public void close() throws java.io.IOException + { + // 1. Ensure that pending characters are written + flushBase64(); + + // 2. Actually close the stream + // Base class both flushes and closes. + super.close(); + + buffer = null; + out = null; + } // end close + + + + /** + * Suspends encoding of the stream. + * May be helpful if you need to embed a piece of + * base640-encoded data in a stream. + * + * @since 1.5.1 + */ + public void suspendEncoding() throws java.io.IOException + { + flushBase64(); + this.suspendEncoding = true; + } // end suspendEncoding + + + /** + * Resumes encoding of the stream. + * May be helpful if you need to embed a piece of + * base640-encoded data in a stream. + * + * @since 1.5.1 + */ + public void resumeEncoding() + { + this.suspendEncoding = false; + } // end resumeEncoding + + + + } // end inner class OutputStream + + +} // end class Base64 \ No newline at end of file diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/CategoryGetterSetter.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/CategoryGetterSetter.java new file mode 100644 index 0000000..1674bc9 --- /dev/null +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/CategoryGetterSetter.java @@ -0,0 +1,27 @@ +package cpm.com.gskmtorange.xmlGetterSetter; + +/** + * Created by gagang on 22-12-2016. + */ + +public class CategoryGetterSetter { + + String category_name; + int category_img = -1; + + public String getCategory_name() { + return category_name; + } + + public void setCategory_name(String category_name) { + this.category_name = category_name; + } + + public int getCategory_img() { + return category_img; + } + + public void setCategory_img(int category_img) { + this.category_img = category_img; + } +} diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/CategoryWisePerformaceGetterSetter.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/CategoryWisePerformaceGetterSetter.java new file mode 100644 index 0000000..ad875c1 --- /dev/null +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/CategoryWisePerformaceGetterSetter.java @@ -0,0 +1,57 @@ +package cpm.com.gskmtorange.xmlGetterSetter; + +/** + * Created by gagang on 23-12-2016. + */ + +public class CategoryWisePerformaceGetterSetter { + String period, sos, t2p, promo, msl_availability, oss; + + public String getPeriod() { + return period; + } + + public void setPeriod(String period) { + this.period = period; + } + + public String getSos() { + return sos; + } + + public void setSos(String sos) { + this.sos = sos; + } + + public String getT2p() { + return t2p; + } + + public void setT2p(String t2p) { + this.t2p = t2p; + } + + public String getPromo() { + return promo; + } + + public void setPromo(String promo) { + this.promo = promo; + } + + public String getMsl_availability() { + return msl_availability; + } + + public void setMsl_availability(String msl_availability) { + this.msl_availability = msl_availability; + } + + public String getOss() { + return oss; + } + + public void setOss(String oss) { + this.oss = oss; + } +} diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/DailyDataMenuGetterSetter.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/DailyDataMenuGetterSetter.java new file mode 100644 index 0000000..f5f0a43 --- /dev/null +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/DailyDataMenuGetterSetter.java @@ -0,0 +1,27 @@ +package cpm.com.gskmtorange.xmlGetterSetter; + +/** + * Created by gagang on 22-12-2016. + */ + +public class DailyDataMenuGetterSetter { + + String category_name; + int category_img = -1; + + public String getCategory_name() { + return category_name; + } + + public void setCategory_name(String category_name) { + this.category_name = category_name; + } + + public int getCategory_img() { + return category_img; + } + + public void setCategory_img(int category_img) { + this.category_img = category_img; + } +} diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/MSL_AvailabilityGetterSetter.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/MSL_AvailabilityGetterSetter.java new file mode 100644 index 0000000..c4d96f2 --- /dev/null +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/MSL_AvailabilityGetterSetter.java @@ -0,0 +1,33 @@ +package cpm.com.gskmtorange.xmlGetterSetter; + +/** + * Created by gagang on 23-12-2016. + */ + +public class MSL_AvailabilityGetterSetter { + String brandName, mbq, available; + + public String getBrandName() { + return brandName; + } + + public void setBrandName(String brandName) { + this.brandName = brandName; + } + + public String getMbq() { + return mbq; + } + + public void setMbq(String mbq) { + this.mbq = mbq; + } + + public String getAvailable() { + return available; + } + + public void setAvailable(String available) { + this.available = available; + } +} diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/SkuGetterSetter.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/SkuGetterSetter.java new file mode 100644 index 0000000..fb4cc4d --- /dev/null +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/SkuGetterSetter.java @@ -0,0 +1,51 @@ +package cpm.com.gskmtorange.xmlGetterSetter; + +import java.util.ArrayList; + +/** + * Created by yadavendras on 28-12-2016. + */ + +public class SkuGetterSetter { + String SKU_ID, SKU, BRAND_ID, MRP, SKU_SEQUENCE; + + public String getSKU_ID() { + return SKU_ID; + } + + public void setSKU_ID(String SKU_ID) { + this.SKU_ID = SKU_ID; + } + + public String getSKU() { + return SKU; + } + + public void setSKU(String SKU) { + this.SKU = SKU; + } + + public String getBRAND_ID() { + return BRAND_ID; + } + + public void setBRAND_ID(String BRAND_ID) { + this.BRAND_ID = BRAND_ID; + } + + public String getMRP() { + return MRP; + } + + public void setMRP(String MRP) { + this.MRP = MRP; + } + + public String getSKU_SEQUENCE() { + return SKU_SEQUENCE; + } + + public void setSKU_SEQUENCE(String SKU_SEQUENCE) { + this.SKU_SEQUENCE = SKU_SEQUENCE; + } +} diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/Stock_FacingGetterSetter.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/Stock_FacingGetterSetter.java new file mode 100644 index 0000000..bb2b594 --- /dev/null +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlGetterSetter/Stock_FacingGetterSetter.java @@ -0,0 +1,33 @@ +package cpm.com.gskmtorange.xmlGetterSetter; + +/** + * Created by gagang on 23-12-2016. + */ + +public class Stock_FacingGetterSetter { + String brandName, mbq, available; + + public String getBrandName() { + return brandName; + } + + public void setBrandName(String brandName) { + this.brandName = brandName; + } + + public String getMbq() { + return mbq; + } + + public void setMbq(String mbq) { + this.mbq = mbq; + } + + public String getAvailable() { + return available; + } + + public void setAvailable(String available) { + this.available = available; + } +} diff --git a/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlHandlers/FailureXMLHandler.java b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlHandlers/FailureXMLHandler.java new file mode 100644 index 0000000..710890b --- /dev/null +++ b/GSKMTOrange/src/main/java/cpm/com/gskmtorange/xmlHandlers/FailureXMLHandler.java @@ -0,0 +1,53 @@ +package cpm.com.gskmtorange.xmlHandlers; + + + +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +import cpm.com.gskmtorange.xmlGetterSetter.FailureGetterSetter; + +public class FailureXMLHandler extends DefaultHandler{ + + private String elementValue; + private FailureGetterSetter failureGetterSetter = null; + + + public FailureGetterSetter getFailureGetterSetter() + { + return failureGetterSetter; + } + + @Override + public void startDocument() throws SAXException { + // TODO Auto-generated method stub + super.startDocument(); + + failureGetterSetter = new FailureGetterSetter(); + } + + @Override + public void characters(char[] ch, int start, int length) + throws SAXException { + // TODO Auto-generated method stub + super.characters(ch, start, length); + + elementValue = new String(ch, start, length); + } + + @Override + public void endElement(String uri, String localName, String qName) + throws SAXException { + // TODO Auto-generated method stub + super.endElement(uri, localName, qName); + + if(qName.equals("STATUS")) + { + failureGetterSetter.setStatus(elementValue); + } + else if(qName.equals("ERRORMSG")) + { + failureGetterSetter.setErrorMsg(elementValue); + } + } +} diff --git a/GSKMTOrange/src/main/res/drawable/category.png b/GSKMTOrange/src/main/res/drawable/category.png new file mode 100644 index 0000000..84bd621 Binary files /dev/null and b/GSKMTOrange/src/main/res/drawable/category.png differ diff --git a/GSKMTOrange/src/main/res/drawable/competition.png b/GSKMTOrange/src/main/res/drawable/competition.png new file mode 100644 index 0000000..13cc952 Binary files /dev/null and b/GSKMTOrange/src/main/res/drawable/competition.png differ diff --git a/GSKMTOrange/src/main/res/drawable/primary_bay.png b/GSKMTOrange/src/main/res/drawable/primary_bay.png new file mode 100644 index 0000000..a33b1da Binary files /dev/null and b/GSKMTOrange/src/main/res/drawable/primary_bay.png differ diff --git a/GSKMTOrange/src/main/res/drawable/promotions.png b/GSKMTOrange/src/main/res/drawable/promotions.png new file mode 100644 index 0000000..1c9a5ca Binary files /dev/null and b/GSKMTOrange/src/main/res/drawable/promotions.png differ diff --git a/GSKMTOrange/src/main/res/drawable/save_icon.png b/GSKMTOrange/src/main/res/drawable/save_icon.png new file mode 100644 index 0000000..b8b3dbb Binary files /dev/null and b/GSKMTOrange/src/main/res/drawable/save_icon.png differ diff --git a/GSKMTOrange/src/main/res/drawable/secondary_display.png b/GSKMTOrange/src/main/res/drawable/secondary_display.png new file mode 100644 index 0000000..b0c025a Binary files /dev/null and b/GSKMTOrange/src/main/res/drawable/secondary_display.png differ diff --git a/GSKMTOrange/src/main/res/drawable/touch_points.png b/GSKMTOrange/src/main/res/drawable/touch_points.png new file mode 100644 index 0000000..a81089c Binary files /dev/null and b/GSKMTOrange/src/main/res/drawable/touch_points.png differ diff --git a/GSKMTOrange/src/main/res/layout/activity_category_list.xml b/GSKMTOrange/src/main/res/layout/activity_category_list.xml new file mode 100644 index 0000000..0b3ab65 --- /dev/null +++ b/GSKMTOrange/src/main/res/layout/activity_category_list.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/GSKMTOrange/src/main/res/layout/activity_category_wise_performance.xml b/GSKMTOrange/src/main/res/layout/activity_category_wise_performance.xml new file mode 100644 index 0000000..108bc80 --- /dev/null +++ b/GSKMTOrange/src/main/res/layout/activity_category_wise_performance.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/GSKMTOrange/src/main/res/layout/activity_daily_data_menu.xml b/GSKMTOrange/src/main/res/layout/activity_daily_data_menu.xml new file mode 100644 index 0000000..86f7248 --- /dev/null +++ b/GSKMTOrange/src/main/res/layout/activity_daily_data_menu.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/GSKMTOrange/src/main/res/layout/activity_geo_tag.xml b/GSKMTOrange/src/main/res/layout/activity_geo_tag.xml index 1740f82..bf1afd1 100644 --- a/GSKMTOrange/src/main/res/layout/activity_geo_tag.xml +++ b/GSKMTOrange/src/main/res/layout/activity_geo_tag.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" - tools:context="cpm.com.gskmtorange.geotag.GeoTagActivity"> + tools:context="cpm.com.gskmtorange.GeoTag.GeoTagActivity"> + + + + + + + + + + + + diff --git a/GSKMTOrange/src/main/res/layout/activity_stock_facing.xml b/GSKMTOrange/src/main/res/layout/activity_stock_facing.xml new file mode 100644 index 0000000..82b3ec7 --- /dev/null +++ b/GSKMTOrange/src/main/res/layout/activity_stock_facing.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + diff --git a/GSKMTOrange/src/main/res/layout/activity_storeimage.xml b/GSKMTOrange/src/main/res/layout/activity_storeimage.xml new file mode 100644 index 0000000..af63741 --- /dev/null +++ b/GSKMTOrange/src/main/res/layout/activity_storeimage.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + diff --git a/GSKMTOrange/src/main/res/layout/category_menu_row.xml b/GSKMTOrange/src/main/res/layout/category_menu_row.xml new file mode 100644 index 0000000..4abf0d1 --- /dev/null +++ b/GSKMTOrange/src/main/res/layout/category_menu_row.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GSKMTOrange/src/main/res/layout/content_category_list.xml b/GSKMTOrange/src/main/res/layout/content_category_list.xml new file mode 100644 index 0000000..ec1e039 --- /dev/null +++ b/GSKMTOrange/src/main/res/layout/content_category_list.xml @@ -0,0 +1,35 @@ + + + + + + + + + + diff --git a/GSKMTOrange/src/main/res/layout/content_category_wise_performance.xml b/GSKMTOrange/src/main/res/layout/content_category_wise_performance.xml new file mode 100644 index 0000000..4f7e8dc --- /dev/null +++ b/GSKMTOrange/src/main/res/layout/content_category_wise_performance.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + diff --git a/GSKMTOrange/src/main/res/layout/content_daily_main_menu.xml b/GSKMTOrange/src/main/res/layout/content_daily_main_menu.xml new file mode 100644 index 0000000..788d0c0 --- /dev/null +++ b/GSKMTOrange/src/main/res/layout/content_daily_main_menu.xml @@ -0,0 +1,35 @@ + + + + + + + + + + diff --git a/GSKMTOrange/src/main/res/layout/content_geo_tag.xml b/GSKMTOrange/src/main/res/layout/content_geo_tag.xml index 472a12d..e358564 100644 --- a/GSKMTOrange/src/main/res/layout/content_geo_tag.xml +++ b/GSKMTOrange/src/main/res/layout/content_geo_tag.xml @@ -11,7 +11,7 @@ android:paddingRight="@dimen/custom_margin" android:paddingTop="@dimen/custom_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" - tools:context="cpm.com.gskmtorange.geotag.GeoTagActivity" + tools:context="cpm.com.gskmtorange.GeoTag.GeoTagActivity" tools:showIn="@layout/activity_geo_tag"> diff --git a/GSKMTOrange/src/main/res/layout/content_msl__availability.xml b/GSKMTOrange/src/main/res/layout/content_msl__availability.xml new file mode 100644 index 0000000..8e9fda9 --- /dev/null +++ b/GSKMTOrange/src/main/res/layout/content_msl__availability.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GSKMTOrange/src/main/res/layout/content_stock_facing.xml b/GSKMTOrange/src/main/res/layout/content_stock_facing.xml new file mode 100644 index 0000000..4d1552a --- /dev/null +++ b/GSKMTOrange/src/main/res/layout/content_stock_facing.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GSKMTOrange/src/main/res/layout/contentstoreimage.xml b/GSKMTOrange/src/main/res/layout/contentstoreimage.xml new file mode 100644 index 0000000..4abae3d --- /dev/null +++ b/GSKMTOrange/src/main/res/layout/contentstoreimage.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +