# Conflicts:
#	GSKMTOrange/src/main/AndroidManifest.xml
#	GSKMTOrange/src/main/java/cpm/com/gskmtorange/MainActivity.java
This commit is contained in:
Gagan290
2017-01-05 16:02:09 +05:30
parent 25008a1aef
commit ade4954f45
11 changed files with 132 additions and 120 deletions
@@ -178,7 +178,7 @@ public class MainActivity extends AppCompatActivity
overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
} else if (id == R.id.nav_setting) {
startActivity(new Intent(MainActivity.this, CategoryListActivity.class));
//startActivity(new Intent(MainActivity.this, CategoryListActivity.class));
} else if (id == R.id.nav_export) {
AlertDialog.Builder builder1 = new AlertDialog.Builder(MainActivity.this);
@@ -23,6 +23,7 @@ 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;
@@ -37,36 +38,35 @@ import cpm.com.gskmtorange.R;
import cpm.com.gskmtorange.constant.CommonString;
import cpm.com.gskmtorange.Database.GSKOrangeDB;
import cpm.com.gskmtorange.GetterSetter.CoverageBean;
import cpm.com.gskmtorange.gsk_dailyentry.CategoryListActivity;
/**
* Created by ashishc on 31-05-2016.
*/
public class StoreimageActivity extends AppCompatActivity implements View.OnClickListener,GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
public class StoreimageActivity extends AppCompatActivity implements View.OnClickListener,
GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
ImageView img_cam,img_clicked;
ImageView img_cam, img_clicked;
Button btn_save;
String _pathforcheck,_path,str;
String _pathforcheck, _path, str;
String store_id,visit_date,username,intime,date;
String store_id, visit_date, username, intime, date;
private SharedPreferences preferences;
AlertDialog alert;
String img_str;
private GSKOrangeDB database;
String lat,lon;
String lat, lon;
GoogleApiClient mGoogleApiClient;
ArrayList<CoverageBean> 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);
@@ -90,8 +90,7 @@ public class StoreimageActivity extends AppCompatActivity implements View.OnClic
database = new GSKOrangeDB(this);
database.open();
coverage_list = database.getCoverageData(date);
coverage_list = database.getCoverageData(date);
img_cam.setOnClickListener(this);
img_clicked.setOnClickListener(this);
@@ -106,13 +105,11 @@ public class StoreimageActivity extends AppCompatActivity implements View.OnClic
.build();
}
if ( Build.VERSION.SDK_INT >= 23 &&
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 ;
return;
}
}
@Override
@@ -122,13 +119,10 @@ public class StoreimageActivity extends AppCompatActivity implements View.OnClic
// 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();
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
}
return super.onOptionsItemSelected(item);
@@ -136,12 +130,10 @@ public class StoreimageActivity extends AppCompatActivity implements View.OnClic
@Override
public void onBackPressed() {
/*Intent i = new Intent(this, DailyEntryScreen.class);
startActivity(i);*/
/*Intent i = new Intent(this, DailyEntryScreen.class);
startActivity(i);*/
finish();
overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out);
}
@@ -150,12 +142,12 @@ public class StoreimageActivity extends AppCompatActivity implements View.OnClic
int id = v.getId();
switch (id){
switch (id) {
case R.id.img_cam_selfie:
_pathforcheck = store_id + "Store"
+ "Image" + visit_date.replace("/","") + getCurrentTime().replace(":","")+".jpg";
+ "Image" + visit_date.replace("/", "") + getCurrentTime().replace(":", "") + ".jpg";
_path = CommonString.FILE_PATH + _pathforcheck;
@@ -167,41 +159,34 @@ public class StoreimageActivity extends AppCompatActivity implements View.OnClic
case R.id.btn_save_selfie:
if (img_str !=null) {
if (img_str != null) {
AlertDialog.Builder builder = new AlertDialog.Builder(
StoreimageActivity.this);
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) {
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
alert.getButton(
AlertDialog.BUTTON_POSITIVE)
.setEnabled(false);
alert.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
String status ="INVALID";
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);
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.InsertCoverageData(cdata);
database.updateCheckoutStatus(store_id, status);
database.updateCheckoutStatus(store_id, status);
/* SharedPreferences.Editor editor = preferences.edit();
@@ -211,41 +196,28 @@ public class StoreimageActivity extends AppCompatActivity implements View.OnClic
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();
}
});
Intent in = new Intent(StoreimageActivity.this, CategoryListActivity.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();
}
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);
@@ -261,10 +233,10 @@ public class StoreimageActivity extends AppCompatActivity implements View.OnClic
File file = new File(_path);
Uri outputFileUri = Uri.fromFile(file);
String defaultCameraPackage="";
String defaultCameraPackage = "";
final PackageManager packageManager = getPackageManager();
List<ApplicationInfo> list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);
for (int n=0;n<list.size();n++) {
for (int n = 0; n < list.size(); n++) {
if ((list.get(n).flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
Log.e("TAG", "Installed Applications : " + list.get(n).loadLabel(packageManager).toString());
Log.e("TAG", "package name : " + list.get(n).packageName);
@@ -281,38 +253,30 @@ public class StoreimageActivity extends AppCompatActivity implements View.OnClic
}
}
}
}
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
intent.setPackage(defaultCameraPackage);
startActivityForResult(intent, 0);
} catch (Exception e) {
} 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);
@@ -320,21 +284,14 @@ public class StoreimageActivity extends AppCompatActivity implements View.OnClic
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");
@@ -344,18 +301,15 @@ public class StoreimageActivity extends AppCompatActivity implements View.OnClic
+ 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
@@ -378,4 +332,4 @@ public class StoreimageActivity extends AppCompatActivity implements View.OnClic
super.onStop();
}
}
}
@@ -2,7 +2,9 @@ package cpm.com.gskmtorange.gsk_dailyentry;
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.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
@@ -24,6 +26,7 @@ import java.util.List;
import cpm.com.gskmtorange.Database.GSKOrangeDB;
import cpm.com.gskmtorange.R;
import cpm.com.gskmtorange.constant.CommonString;
import cpm.com.gskmtorange.xmlGetterSetter.CategoryGetterSetter;
public class CategoryListActivity extends AppCompatActivity {
@@ -35,6 +38,9 @@ public class CategoryListActivity extends AppCompatActivity {
GSKOrangeDB db;
private SharedPreferences preferences;
String store_id, visit_date, username, intime, date, keyAccount_id, class_id, storeType_id;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -48,6 +54,17 @@ public class CategoryListActivity extends AppCompatActivity {
db = new GSKOrangeDB(this);
db.open();
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, "");
keyAccount_id = preferences.getString(CommonString.KEY_KEYACCOUNT_ID, "");
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
txt_categoryName = (TextView) findViewById(R.id.txt_categoryName);
//txt_categoryName.setText("Category List");
txt_categoryName.setText(getResources().getString(R.string.title_activity_category_list));
@@ -69,7 +86,7 @@ public class CategoryListActivity extends AppCompatActivity {
recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
categoryList = new ArrayList<>();
categoryList = db.getCategoryListData("1", "1", "1");
categoryList = db.getCategoryListData(keyAccount_id, storeType_id, class_id);
adapter = new CategoryListAdapter(CategoryListActivity.this, categoryList);
recyclerView.setAdapter(adapter);
@@ -100,6 +117,14 @@ public class CategoryListActivity extends AppCompatActivity {
holder.categoryName.setText(categoryData.getCategory());
holder.categoryIcon.setImageResource(R.drawable.category);
/*if (categoryData.getCategory().equalsIgnoreCase("Oral Health")) {
holder.categoryIcon.setImageResource(R.drawable.ohc);
} else if (categoryData.getCategory().equalsIgnoreCase("Wellness")) {
holder.categoryIcon.setImageResource(R.drawable.pdr);
} else if (categoryData.getCategory().equalsIgnoreCase("Nutritionals")) {
holder.categoryIcon.setImageResource(R.drawable.hfd);
}*/
holder.lay_menu.setOnClickListener(new View.OnClickListener() {
@Override
@@ -3,8 +3,10 @@ package cpm.com.gskmtorange.gsk_dailyentry;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
@@ -34,6 +36,7 @@ import java.util.List;
import cpm.com.gskmtorange.Database.GSKOrangeDB;
import cpm.com.gskmtorange.R;
import cpm.com.gskmtorange.constant.CommonString;
import cpm.com.gskmtorange.xmlGetterSetter.MSL_AvailabilityGetterSetter;
public class MSL_AvailabilityActivity extends AppCompatActivity {
@@ -51,6 +54,9 @@ public class MSL_AvailabilityActivity extends AppCompatActivity {
String categoryName, categoryId, storeId;
private SharedPreferences preferences;
String store_id, visit_date, username, intime, date, keyAccount_id, class_id, storeType_id;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -61,15 +67,27 @@ public class MSL_AvailabilityActivity extends AppCompatActivity {
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
db = new GSKOrangeDB(this);
db.open();
expandableListView = (ExpandableListView) findViewById(R.id.expandableListView);
txt_mslAvailabilityName = (TextView) findViewById(R.id.txt_mslAvailabilityName);
db = new GSKOrangeDB(this);
db.open();
//preference data
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, "");
keyAccount_id = preferences.getString(CommonString.KEY_KEYACCOUNT_ID, "");
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
//Intent data
categoryName = getIntent().getStringExtra("categoryName");
categoryId = getIntent().getStringExtra("categoryId");
storeId = "";
//txt_mslAvailabilityName.setText(categoryName);
txt_mslAvailabilityName.setText(getResources().getString(R.string.title_activity_msl__availability));
@@ -89,10 +107,10 @@ public class MSL_AvailabilityActivity extends AppCompatActivity {
public void onClick(DialogInterface dialog, int id) {
db.open();
if (db.checkMsl_AvailabilityData(storeId, categoryId)) {
db.updateMSL_Availability(storeId, categoryId, hashMapListHeaderData, hashMapListChildData);
if (db.checkMsl_AvailabilityData(store_id, categoryId)) {
db.updateMSL_Availability(store_id, categoryId, hashMapListHeaderData, hashMapListChildData);
} else {
db.InsertMSL_Availability(storeId, categoryId, hashMapListHeaderData, hashMapListChildData);
db.InsertMSL_Availability(store_id, categoryId, hashMapListHeaderData, hashMapListChildData);
}
Toast.makeText(getApplicationContext(), "Data has been saved", Toast.LENGTH_LONG).show();
@@ -4,6 +4,7 @@ import android.app.AlertDialog;
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.graphics.Typeface;
@@ -11,6 +12,7 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
@@ -61,13 +63,16 @@ public class Stock_FacingActivity extends AppCompatActivity {
ExpandableListAdapter adapter;
GSKOrangeDB db;
String categoryName, categoryId, storeId, Error_Message = "";
String categoryName, categoryId, Error_Message = "";
String path = "", str = "", _pathforcheck = "", img1 = "", img2 = "";
static int child_position = -1;
boolean isDialogOpen = true;
boolean checkflag = true;
private SharedPreferences preferences;
String store_id, visit_date, username, intime, date, keyAccount_id, class_id, storeType_id;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -84,9 +89,19 @@ public class Stock_FacingActivity extends AppCompatActivity {
expandableListView = (ExpandableListView) findViewById(R.id.expandableListView);
txt_stockFacingName = (TextView) findViewById(R.id.txt_stockFacingName);
//preference data
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, "");
keyAccount_id = preferences.getString(CommonString.KEY_KEYACCOUNT_ID, "");
class_id = preferences.getString(CommonString.KEY_CLASS_ID, "");
storeType_id = preferences.getString(CommonString.KEY_STORETYPE_ID, "");
categoryName = getIntent().getStringExtra("categoryName");
categoryId = getIntent().getStringExtra("categoryId");
storeId = "";
//txt_stockFacingName.setText(categoryName);
txt_stockFacingName.setText(getResources().getString(R.string.title_activity_stock_facing));
@@ -110,10 +125,10 @@ public class Stock_FacingActivity extends AppCompatActivity {
public void onClick(DialogInterface dialog, int id) {
db.open();
if (db.checkStockAndFacingData(storeId, categoryId)) {
db.updateStockAndFacing(storeId, categoryId, hashMapListHeaderData, hashMapListChildData);
if (db.checkStockAndFacingData(store_id, categoryId)) {
db.updateStockAndFacing(store_id, categoryId, hashMapListHeaderData, hashMapListChildData);
} else {
db.InsertStock_Facing(storeId, categoryId, hashMapListHeaderData, hashMapListChildData);
db.InsertStock_Facing(store_id, categoryId, hashMapListHeaderData, hashMapListChildData);
}
Toast.makeText(getApplicationContext(), "Data has been saved", Toast.LENGTH_LONG).show();
@@ -292,10 +307,10 @@ public class Stock_FacingActivity extends AppCompatActivity {
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(':', '-');
//String date = new Date().toLocaleString().toString();
//String tempDate = new Date().toLocaleString().toString().replace(' ', '_').replace(',', '_').replace(':', '-');
_pathforcheck = "Stock_Cam1_" + storeId + "_" + getCurrentTime().replace(":", "") + ".jpg";
_pathforcheck = "Stock_Cam1_" + store_id + "_" + visit_date.replace("/", "") + "_" + getCurrentTime().replace(":", "") + ".jpg";
child_position = groupPosition;
path = str + _pathforcheck;
@@ -320,10 +335,10 @@ public class Stock_FacingActivity extends AppCompatActivity {
img_camera2.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(':', '-');
//String date = new Date().toLocaleString().toString();
//String tempDate = new Date().toLocaleString().toString().replace(' ', '_').replace(',', '_').replace(':', '-');
_pathforcheck = "Stock_Cam1_" + storeId + "_" + getCurrentTime().replace(":", "") + ".jpg";
_pathforcheck = "Stock_Cam2_" + store_id + "_" + visit_date.replace("/", "") + "_" + getCurrentTime().replace(":", "") + ".jpg";
child_position = groupPosition;
path = str + _pathforcheck;
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB