| Line 1... |
Line 1... |
| 1 |
package com.saholic.profittill.main;
|
1 |
package com.saholic.profittill.main;
|
| 2 |
|
2 |
|
| 3 |
import android.Manifest;
|
3 |
import android.Manifest;
|
| 4 |
import android.app.AlertDialog;
|
4 |
import android.app.AlertDialog;
|
| - |
|
5 |
import android.app.FragmentManager;
|
| 5 |
import android.app.ProgressDialog;
|
6 |
import android.app.ProgressDialog;
|
| 6 |
import android.content.Context;
|
7 |
import android.content.Context;
|
| 7 |
import android.content.DialogInterface;
|
8 |
import android.content.DialogInterface;
|
| 8 |
import android.content.Intent;
|
9 |
import android.content.Intent;
|
| 9 |
import android.content.IntentSender;
|
10 |
import android.content.IntentSender;
|
| Line 60... |
Line 61... |
| 60 |
import org.json.JSONException;
|
61 |
import org.json.JSONException;
|
| 61 |
import org.json.JSONObject;
|
62 |
import org.json.JSONObject;
|
| 62 |
|
63 |
|
| 63 |
import java.io.IOException;
|
64 |
import java.io.IOException;
|
| 64 |
import java.io.UnsupportedEncodingException;
|
65 |
import java.io.UnsupportedEncodingException;
|
| - |
|
66 |
import java.net.URL;
|
| 65 |
import java.util.ArrayList;
|
67 |
import java.util.ArrayList;
|
| 66 |
import java.util.Date;
|
68 |
import java.util.Date;
|
| 67 |
|
69 |
|
| 68 |
public class LoginActivity extends ActionBarActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener{
|
70 |
public class LoginActivity extends ActionBarActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener{
|
| 69 |
public GoogleApiClient mGoogleApiClient;
|
71 |
public GoogleApiClient mGoogleApiClient;
|
| Line 71... |
Line 73... |
| 71 |
private boolean mIntentInProgress;
|
73 |
private boolean mIntentInProgress;
|
| 72 |
private boolean mSignInClicked;
|
74 |
private boolean mSignInClicked;
|
| 73 |
private ConnectionResult mConnectionResult;
|
75 |
private ConnectionResult mConnectionResult;
|
| 74 |
private static final int RC_SIGN_IN = 0;
|
76 |
private static final int RC_SIGN_IN = 0;
|
| 75 |
public static final int REQUEST_CODE_TOKEN_AUTH =1;
|
77 |
public static final int REQUEST_CODE_TOKEN_AUTH =1;
|
| 76 |
ArrayList<NameValuePair> nameValuePairs;
|
- |
|
| 77 |
ArrayList<NameValuePair> nameValuePairsGcm;
|
78 |
ArrayList<NameValuePair> nameValuePairsGcm;
|
| 78 |
SharedPreferences userData;
|
79 |
SharedPreferences userData;
|
| 79 |
SharedPreferences apiData;
|
80 |
SharedPreferences apiData;
|
| 80 |
SharedPreferences.Editor inviteDataEditor;
|
81 |
SharedPreferences.Editor inviteDataEditor;
|
| 81 |
SharedPreferences inviteData;
|
82 |
SharedPreferences inviteData;
|
| Line 90... |
Line 91... |
| 90 |
FirebaseInstanceId fcm;
|
91 |
FirebaseInstanceId fcm;
|
| 91 |
Context context;
|
92 |
Context context;
|
| 92 |
String regId;
|
93 |
String regId;
|
| 93 |
String msg = "";
|
94 |
String msg = "";
|
| 94 |
public static final int READ_Token_PERMISSION=101;
|
95 |
public static final int READ_Token_PERMISSION=101;
|
| 95 |
public static final String REG_ID = "regId";
|
- |
|
| 96 |
private static final String APP_VERSION = "appVersion";
|
- |
|
| 97 |
static final String TAG = "Register Activity";
|
96 |
static final String TAG = "Register Activity";
|
| 98 |
private boolean PermissionIngranted=false;
|
97 |
private boolean PermissionIngranted=false;
|
| 99 |
@Override
|
98 |
@Override
|
| 100 |
|
99 |
|
| 101 |
protected void onCreate(Bundle savedInstanceState) {
|
100 |
protected void onCreate(Bundle savedInstanceState) {
|
| Line 246... |
Line 245... |
| 246 |
private void resolveSignInError() {
|
245 |
private void resolveSignInError() {
|
| 247 |
if (mConnectionResult.hasResolution()) {
|
246 |
if (mConnectionResult.hasResolution()) {
|
| 248 |
try {
|
247 |
try {
|
| 249 |
mIntentInProgress = true;
|
248 |
mIntentInProgress = true;
|
| 250 |
mConnectionResult.startResolutionForResult(this, RC_SIGN_IN);
|
249 |
mConnectionResult.startResolutionForResult(this, RC_SIGN_IN);
|
| - |
|
250 |
}
|
| 251 |
} catch (IntentSender.SendIntentException e) {
|
251 |
catch (IntentSender.SendIntentException e) {
|
| 252 |
e.printStackTrace();
|
252 |
e.printStackTrace();
|
| 253 |
TestinAgent.uploadException(this,"Exception in Resolve sign in error", new Exception());
|
253 |
TestinAgent.uploadException(this,"Exception in Resolve sign in error", new Exception());
|
| 254 |
mIntentInProgress = false;
|
254 |
mIntentInProgress = false;
|
| 255 |
//mGoogleApiClient.connect();
|
255 |
mGoogleApiClient.connect();
|
| 256 |
revokeGplusAccess();
|
256 |
revokeGplusAccess();
|
| 257 |
}
|
257 |
}
|
| 258 |
}
|
258 |
}
|
| 259 |
}
|
259 |
}
|
| 260 |
|
260 |
|
| Line 375... |
Line 375... |
| 375 |
String json = "";
|
375 |
String json = "";
|
| 376 |
JSONObject jsonObject = new JSONObject();
|
376 |
JSONObject jsonObject = new JSONObject();
|
| 377 |
jsonObject.put("type", "GOOGLE");
|
377 |
jsonObject.put("type", "GOOGLE");
|
| 378 |
jsonObject.put("token", googletoken);
|
378 |
jsonObject.put("token", googletoken);
|
| 379 |
json = jsonObject.toString();
|
379 |
json = jsonObject.toString();
|
| 380 |
HttpPost httppost = new HttpPost(apiData.getString("Web_Api_Login","http://api.profitmandi.com:8080/profitmandi-web/user/googleLogin"));
|
380 |
HttpPost httppost = new HttpPost(apiData.getString("Web_Api_Login","http://app.profitmandi.com/apis/user/googleLogin"));
|
| 381 |
//HttpPost httppost = new HttpPost(ProfitTillConstants.Web_Api+"/user/googleLogin");
|
- |
|
| 382 |
StringEntity se = new StringEntity(json);
|
381 |
StringEntity se = new StringEntity(json);
|
| 383 |
httppost.setEntity(se);
|
382 |
httppost.setEntity(se);
|
| 384 |
httppost.setHeader("Content-type", "application/json");
|
383 |
httppost.setHeader("Content-type", "application/json");
|
| 385 |
HttpResponse response = httpclient.execute(httppost);
|
384 |
HttpResponse response = httpclient.execute(httppost);
|
| 386 |
HttpEntity entity = response.getEntity();
|
385 |
HttpEntity entity = response.getEntity();
|
| Line 458... |
Line 457... |
| 458 |
|
457 |
|
| 459 |
@Override
|
458 |
@Override
|
| 460 |
protected String doInBackground(String... params) {
|
459 |
protected String doInBackground(String... params) {
|
| 461 |
try {
|
460 |
try {
|
| 462 |
HttpClient httpclient = new DefaultHttpClient();
|
461 |
HttpClient httpclient = new DefaultHttpClient();
|
| 463 |
HttpGet httpget = new HttpGet(apiData.getString("Web_Api_Tokeninfo","http://api.profitmandi.com:8080/profitmandi-web/user/token-info"));
|
462 |
HttpGet httpget = new HttpGet(apiData.getString("Web_Api_Tokendetail","http://app.profitmandi.com/apis/user/detail/token"));
|
| 464 |
//HttpGet httpget = new HttpGet(ProfitTillConstants.Web_Api + "/user/token-info");
|
463 |
//HttpGet httpget = new HttpGet(ProfitTillConstants.Web_Api + "/user/token-info");
|
| 465 |
httpget.setHeader("Auth-Token", userData.getString("token", ""));
|
464 |
httpget.setHeader("Auth-Token", userData.getString("token", ""));
|
| 466 |
HttpResponse response = httpclient.execute(httpget);
|
465 |
HttpResponse response = httpclient.execute(httpget);
|
| 467 |
HttpEntity entity = response.getEntity();
|
466 |
HttpEntity entity = response.getEntity();
|
| 468 |
int status = response.getStatusLine().getStatusCode();
|
467 |
int status = response.getStatusLine().getStatusCode();
|
| Line 494... |
Line 493... |
| 494 |
userDataEditor.putString("id", user_id);
|
493 |
userDataEditor.putString("id", user_id);
|
| 495 |
userDataEditor.commit();
|
494 |
userDataEditor.commit();
|
| 496 |
if(!(userData.getString("id", "").equals(""))){
|
495 |
if(!(userData.getString("id", "").equals(""))){
|
| 497 |
UtilityFunctions utf = new UtilityFunctions();
|
496 |
UtilityFunctions utf = new UtilityFunctions();
|
| 498 |
new pushApkData().execute(utf.getDeviceInformation(getApplicationContext()));
|
497 |
new pushApkData().execute(utf.getDeviceInformation(getApplicationContext()));
|
| - |
|
498 |
Intent i = new Intent(LoginActivity.this,MainActivity.class);
|
| - |
|
499 |
i.putExtra("displayView","0");
|
| - |
|
500 |
startActivity(i);
|
| 499 |
}
|
501 |
}
|
| 500 |
else{
|
502 |
else{
|
| 501 |
Intent i = new Intent(LoginActivity.this,MainActivity.class);
|
503 |
Intent i = new Intent(LoginActivity.this,MainActivity.class);
|
| 502 |
i.putExtra("displayView","0");
|
504 |
i.putExtra("displayView","0");
|
| 503 |
startActivity(i);
|
505 |
startActivity(i);
|
| Line 604... |
Line 606... |
| 604 |
@Override
|
606 |
@Override
|
| 605 |
protected String doInBackground(String... arg0) {
|
607 |
protected String doInBackground(String... arg0) {
|
| 606 |
String id=null;
|
608 |
String id=null;
|
| 607 |
try {
|
609 |
try {
|
| 608 |
HttpClient httpclient = new DefaultHttpClient();
|
610 |
HttpClient httpclient = new DefaultHttpClient();
|
| 609 |
HttpPost httppost = new HttpPost(apiData.getString("gcm.push.url",null));
|
611 |
HttpPost httppost = new HttpPost(apiData.getString("gcm.push.url","http://api.profittill.com/gcm_users/add"));
|
| 610 |
//HttpPost httppost = new HttpPost(ProfitTillConstants.gcm_url);
|
612 |
//HttpPost httppost = new HttpPost(ProfitTillConstants.gcm_url);
|
| 611 |
nameValuePairsGcm = new ArrayList<>();
|
613 |
nameValuePairsGcm = new ArrayList<>();
|
| 612 |
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
|
614 |
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
|
| 613 |
nameValuePairsGcm.add(new BasicNameValuePair("gcm_regid",regId));
|
615 |
nameValuePairsGcm.add(new BasicNameValuePair("gcm_regid",regId));
|
| 614 |
nameValuePairsGcm.add(new BasicNameValuePair("imeinumber",telephonyManager.getDeviceId()));
|
616 |
nameValuePairsGcm.add(new BasicNameValuePair("imeinumber",telephonyManager.getDeviceId()));
|
| Line 663... |
Line 665... |
| 663 |
//Intent i = new Intent(LoginActivity.this, MobileNumber.class);
|
665 |
//Intent i = new Intent(LoginActivity.this, MobileNumber.class);
|
| 664 |
// i.putExtra("displayView", "7");
|
666 |
// i.putExtra("displayView", "7");
|
| 665 |
// startActivity(i);
|
667 |
// startActivity(i);
|
| 666 |
}
|
668 |
}
|
| 667 |
else{*/
|
669 |
else{*/
|
| 668 |
Intent i = new Intent(LoginActivity.this,MainActivity.class);
|
- |
|
| 669 |
i.putExtra("displayView","0");
|
- |
|
| 670 |
startActivity(i);
|
- |
|
| - |
|
670 |
|
| 671 |
}
|
671 |
}
|
| 672 |
}
|
672 |
}
|
| 673 |
|
673 |
|
| 674 |
|
674 |
|
| 675 |
public final boolean isInternetOn() {
|
675 |
public final boolean isInternetOn() {
|
| Line 750... |
Line 750... |
| 750 |
|
750 |
|
| 751 |
@Override
|
751 |
@Override
|
| 752 |
protected String doInBackground(ArrayList<NameValuePair>... arg0) {
|
752 |
protected String doInBackground(ArrayList<NameValuePair>... arg0) {
|
| 753 |
try {
|
753 |
try {
|
| 754 |
HttpClient httpclient = new DefaultHttpClient();
|
754 |
HttpClient httpclient = new DefaultHttpClient();
|
| 755 |
HttpPost httppost = new HttpPost("http://api.profittill.com/devices/add");
|
755 |
HttpPost httppost = new HttpPost(apiData.getString("devices_info","http://api.profittill.com/devices/add"));
|
| 756 |
//HttpPost httppost = new HttpPost(ProfitTillConstants.Push_Url);
|
- |
|
| 757 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
756 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
| 758 |
httppost.setEntity(new UrlEncodedFormEntity(arg0[0]));
|
757 |
httppost.setEntity(new UrlEncodedFormEntity(arg0[0]));
|
| 759 |
HttpResponse response = httpclient.execute(httppost);
|
758 |
HttpResponse response = httpclient.execute(httppost);
|
| 760 |
HttpEntity entity = response.getEntity();
|
759 |
HttpEntity entity = response.getEntity();
|
| 761 |
int status = response.getStatusLine().getStatusCode();
|
760 |
int status = response.getStatusLine().getStatusCode();
|