| Line 31... |
Line 31... |
| 31 |
import com.google.android.gms.common.api.GoogleApiClient;
|
31 |
import com.google.android.gms.common.api.GoogleApiClient;
|
| 32 |
import com.google.android.gms.plus.Plus;
|
32 |
import com.google.android.gms.plus.Plus;
|
| 33 |
import com.mixpanel.android.mpmetrics.MixpanelAPI;
|
33 |
import com.mixpanel.android.mpmetrics.MixpanelAPI;
|
| 34 |
import com.saholic.profittill.Constants.ProfitTillConstants;
|
34 |
import com.saholic.profittill.Constants.ProfitTillConstants;
|
| 35 |
import com.saholic.profittill.R;
|
35 |
import com.saholic.profittill.R;
|
| - |
|
36 |
import com.saholic.profittill.Utils.AnalyticsUtility;
|
| 36 |
import com.saholic.profittill.Utils.UtilityFunctions;
|
37 |
import com.saholic.profittill.Utils.UtilityFunctions;
|
| - |
|
38 |
import com.saholic.profittill.Volley.Analytics;
|
| - |
|
39 |
import com.saholic.profittill.Volley.AnalyticsErrorResponse;
|
| - |
|
40 |
import com.saholic.profittill.Volley.AnalyticsJsonResponse;
|
| 37 |
|
41 |
|
| 38 |
import org.apache.http.HttpEntity;
|
42 |
import org.apache.http.HttpEntity;
|
| 39 |
import org.apache.http.HttpResponse;
|
43 |
import org.apache.http.HttpResponse;
|
| 40 |
import org.apache.http.NameValuePair;
|
44 |
import org.apache.http.NameValuePair;
|
| 41 |
import org.apache.http.client.ClientProtocolException;
|
45 |
import org.apache.http.client.ClientProtocolException;
|
| Line 54... |
Line 58... |
| 54 |
import java.util.Date;
|
58 |
import java.util.Date;
|
| 55 |
|
59 |
|
| 56 |
public class ReferrerActivity extends ActionBarActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
|
60 |
public class ReferrerActivity extends ActionBarActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
|
| 57 |
EditText referalCode;
|
61 |
EditText referalCode;
|
| 58 |
EditText mobileNumber;
|
62 |
EditText mobileNumber;
|
| 59 |
/*
|
- |
|
| 60 |
TextView inviteError;
|
- |
|
| 61 |
TextView thanks;
|
- |
|
| 62 |
TextView onlyPress;
|
- |
|
| 63 |
TextView getback;
|
- |
|
| 64 |
TextView inviteNumber;
|
- |
|
| 65 |
TextView giveusyour,or;
|
- |
|
| 66 |
TextView havent,press;
|
- |
|
| 67 |
TextView giveus;
|
- |
|
| 68 |
TextView inviteMessage,inviteMessage1;
|
- |
|
| 69 |
*/
|
- |
|
| 70 |
MixpanelAPI mixpanel;
|
63 |
MixpanelAPI mixpanel;
|
| 71 |
TextView inviteMessage,inviteMessage1,inviteNumber,giveus,thanks,incorrect;
|
64 |
TextView inviteMessage,inviteMessage1,inviteNumber,giveus,thanks,incorrect;
|
| 72 |
Button referrerSend,mobileNumberSend;
|
65 |
Button referrerSend,mobileNumberSend;
|
| 73 |
String type1;
|
66 |
String type1;
|
| 74 |
String invitationCode;
|
67 |
String invitationCode;
|
| 75 |
SharedPreferences userData;
|
68 |
SharedPreferences userData;
|
| Line 113... |
Line 106... |
| 113 |
inviteMessage.setText(apiData.getString("referralinvite.text", "Got your Invite Code?"));
|
106 |
inviteMessage.setText(apiData.getString("referralinvite.text", "Got your Invite Code?"));
|
| 114 |
inviteMessage1.setText(apiData.getString("no.referralinvite", "Haven't got the code..."));
|
107 |
inviteMessage1.setText(apiData.getString("no.referralinvite", "Haven't got the code..."));
|
| 115 |
giveus.setText(apiData.getString("referralMobileNumber.text","Leave ur no & we'll get back to you"));
|
108 |
giveus.setText(apiData.getString("referralMobileNumber.text","Leave ur no & we'll get back to you"));
|
| 116 |
inviteNumber.setVisibility(View.VISIBLE);
|
109 |
inviteNumber.setVisibility(View.VISIBLE);
|
| 117 |
inviteNumber.setText("Call " + apiData.getString("contactus.number", "") + " now");
|
110 |
inviteNumber.setText("Call " + apiData.getString("contactus.number", "") + " now");
|
| - |
|
111 |
|
| 118 |
/*InputMethodManager imm = (InputMethodManager)getSystemService(
|
112 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
| 119 |
Context.INPUT_METHOD_SERVICE);
|
113 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
| - |
|
114 |
t.setScreenName("Referrer Screen");
|
| 120 |
imm.hideSoftInputFromWindow(referalCode.getWindowToken(), 0);
|
115 |
t.send(new HitBuilders.ScreenViewBuilder().build());
|
| - |
|
116 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
| - |
|
117 |
AnalyticsUtility.getAnalyticsRequest(ReferrerActivity.this, userData.getString("id", ""), "Screen", "Referrer", "Referrer Screen"),
|
| 121 |
imm.hideSoftInputFromWindow(mobileNumber.getWindowToken(), 0);
|
118 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
| - |
|
119 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(ReferrerActivity.this);
|
| 122 |
*/
|
120 |
|
| 123 |
referalCode.setInputType(0);
|
121 |
referalCode.setInputType(0);
|
| 124 |
mobileNumber.setInputType(0);
|
122 |
mobileNumber.setInputType(0);
|
| 125 |
if(getIntent().getAction()=="Login"){
|
123 |
if(getIntent().getAction()=="Login"){
|
| 126 |
nameValuePairsGcm = new ArrayList<>();
|
124 |
nameValuePairsGcm = new ArrayList<>();
|
| 127 |
nameValuePairsGcm.add(new BasicNameValuePair("cid",getIntent().getExtras().getString("cid")));
|
125 |
nameValuePairsGcm.add(new BasicNameValuePair("cid",getIntent().getExtras().getString("cid")));
|
| Line 133... |
Line 131... |
| 133 |
}
|
131 |
}
|
| 134 |
|
132 |
|
| 135 |
referalCode.setOnClickListener(new View.OnClickListener() {
|
133 |
referalCode.setOnClickListener(new View.OnClickListener() {
|
| 136 |
@Override
|
134 |
@Override
|
| 137 |
public void onClick(View v) {
|
135 |
public void onClick(View v) {
|
| 138 |
/*referalCode.setInputType(1);*/
|
- |
|
| 139 |
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
136 |
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
| 140 |
// only will trigger it if no physical keyboard is open
|
- |
|
| 141 |
inputMethodManager.showSoftInput(referalCode, InputMethodManager.SHOW_IMPLICIT);
|
137 |
inputMethodManager.showSoftInput(referalCode, InputMethodManager.SHOW_IMPLICIT);
|
| 142 |
referalCode.requestFocus();
|
138 |
referalCode.requestFocus();
|
| 143 |
}
|
139 |
}
|
| 144 |
});
|
140 |
});
|
| 145 |
mobileNumber.setOnClickListener(new View.OnClickListener() {
|
141 |
mobileNumber.setOnClickListener(new View.OnClickListener() {
|
| Line 149... |
Line 145... |
| 149 |
}
|
145 |
}
|
| 150 |
});
|
146 |
});
|
| 151 |
inviteNumber.setOnClickListener(new View.OnClickListener() {
|
147 |
inviteNumber.setOnClickListener(new View.OnClickListener() {
|
| 152 |
@Override
|
148 |
@Override
|
| 153 |
public void onClick(View v) {
|
149 |
public void onClick(View v) {
|
| - |
|
150 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
| - |
|
151 |
AnalyticsUtility.getAnalyticsRequest(ReferrerActivity.this, userData.getString("id", ""), "Clicks", "Referrer", "Call to get Invite Code"),
|
| - |
|
152 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
| - |
|
153 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(ReferrerActivity.this);
|
| 154 |
Intent callIntent = new Intent(Intent.ACTION_CALL);
|
154 |
Intent callIntent = new Intent(Intent.ACTION_CALL);
|
| 155 |
callIntent.setData(Uri.parse("tel:0" + apiData.getString("contactus.number", "")));
|
155 |
callIntent.setData(Uri.parse("tel:0" + apiData.getString("contactus.number", "")));
|
| 156 |
startActivity(callIntent);
|
156 |
startActivity(callIntent);
|
| 157 |
}
|
157 |
}
|
| 158 |
});
|
158 |
});
|
| Line 163... |
Line 163... |
| 163 |
mixpanel.track("Referrer Screen", props);
|
163 |
mixpanel.track("Referrer Screen", props);
|
| 164 |
} catch (JSONException e) {
|
164 |
} catch (JSONException e) {
|
| 165 |
|
165 |
|
| 166 |
e.printStackTrace();
|
166 |
e.printStackTrace();
|
| 167 |
}
|
167 |
}
|
| 168 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
- |
|
| 169 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
- |
|
| 170 |
t.setScreenName("Referrer Screen");
|
- |
|
| 171 |
t.send(new HitBuilders.ScreenViewBuilder().build());
|
- |
|
| 172 |
|
- |
|
| 173 |
type1 = userData.getString("type",null);
|
168 |
type1 = userData.getString("type",null);
|
| 174 |
|
169 |
|
| 175 |
if(type1!=null && type1.equalsIgnoreCase("google")) {
|
170 |
if(type1!=null && type1.equalsIgnoreCase("google")) {
|
| 176 |
mGoogleApiClient = new GoogleApiClient.Builder(this)
|
171 |
mGoogleApiClient = new GoogleApiClient.Builder(this)
|
| 177 |
.addConnectionCallbacks(this)
|
172 |
.addConnectionCallbacks(this)
|
| Line 202... |
Line 197... |
| 202 |
else{
|
197 |
else{
|
| 203 |
if(isInternetOn()) {
|
198 |
if(isInternetOn()) {
|
| 204 |
InputMethodManager imm = (InputMethodManager)getSystemService(
|
199 |
InputMethodManager imm = (InputMethodManager)getSystemService(
|
| 205 |
Context.INPUT_METHOD_SERVICE);
|
200 |
Context.INPUT_METHOD_SERVICE);
|
| 206 |
imm.hideSoftInputFromWindow(referalCode.getWindowToken(), 0);
|
201 |
imm.hideSoftInputFromWindow(referalCode.getWindowToken(), 0);
|
| - |
|
202 |
|
| 207 |
new PushReferrerData().execute(referalCode.getText().toString());
|
203 |
new PushReferrerData().execute(referalCode.getText().toString());
|
| 208 |
}else{
|
204 |
}else{
|
| 209 |
InputMethodManager imm = (InputMethodManager)getSystemService(
|
205 |
InputMethodManager imm = (InputMethodManager)getSystemService(
|
| 210 |
Context.INPUT_METHOD_SERVICE);
|
206 |
Context.INPUT_METHOD_SERVICE);
|
| 211 |
imm.hideSoftInputFromWindow(referalCode.getWindowToken(), 0);
|
207 |
imm.hideSoftInputFromWindow(referalCode.getWindowToken(), 0);
|
| Line 401... |
Line 397... |
| 401 |
System.out.println("JSON Object in referrer " + jObjGmail.toString());
|
397 |
System.out.println("JSON Object in referrer " + jObjGmail.toString());
|
| 402 |
String success = jObjGmail.getString("success");
|
398 |
String success = jObjGmail.getString("success");
|
| 403 |
if(status == 200){
|
399 |
if(status == 200){
|
| 404 |
inviteDEditor.putString("referrerCode",arg0[0]);
|
400 |
inviteDEditor.putString("referrerCode",arg0[0]);
|
| 405 |
inviteDEditor.commit();
|
401 |
inviteDEditor.commit();
|
| 406 |
Log.d("In if","in if referrer" +inviteD.getString("referrerCode","").equalsIgnoreCase("") + inviteD.getString("referrerCode","") );
|
- |
|
| 407 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
402 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
| 408 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
403 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
| 409 |
t.send(new HitBuilders.EventBuilder()
|
404 |
t.send(new HitBuilders.EventBuilder()
|
| 410 |
.setCategory("Referrer ")
|
405 |
.setCategory("Referrer ")
|
| 411 |
.setAction("Referrer Saved Successfully")
|
406 |
.setAction("Referrer Saved Successfully")
|
| 412 |
.setLabel("Referrer for User" +userData.getString("id",null) + " is " + arg0[0])
|
407 |
.setLabel("Referrer for User" +userData.getString("id",null) + " is " + arg0[0])
|
| 413 |
.build());
|
408 |
.build());
|
| 414 |
} else {
|
- |
|
| 415 |
//TODO : handle properly. Don't allow user to proceed
|
- |
|
| 416 |
Log.d("Status ","status " + status);
|
- |
|
| 417 |
}
|
409 |
}
|
| 418 |
|
- |
|
| 419 |
nameValuePairs.clear();
|
- |
|
| 420 |
Log.e("pass 1", "connection success ");
|
- |
|
| 421 |
if(success.equalsIgnoreCase("true")){
|
410 |
if(success.equalsIgnoreCase("true")){
|
| 422 |
MixpanelAPI mixpanel= MixpanelAPI.getInstance(getApplicationContext(), ProfitTillConstants.MIX_PANEL_TOKEN);
|
411 |
MixpanelAPI mixpanel= MixpanelAPI.getInstance(getApplicationContext(), ProfitTillConstants.MIX_PANEL_TOKEN);
|
| 423 |
JSONObject props = new JSONObject();
|
412 |
JSONObject props = new JSONObject();
|
| 424 |
try {
|
413 |
try {
|
| 425 |
props.put("Referrer", "Referrer Saved Successfully");
|
414 |
props.put("Referrer", "Referrer Saved Successfully");
|
| Line 446... |
Line 435... |
| 446 |
@Override
|
435 |
@Override
|
| 447 |
protected void onPostExecute(String result) {
|
436 |
protected void onPostExecute(String result) {
|
| 448 |
super.onPostExecute(result);
|
437 |
super.onPostExecute(result);
|
| 449 |
pd2.dismiss();
|
438 |
pd2.dismiss();
|
| 450 |
if(result.equalsIgnoreCase("true")) {
|
439 |
if(result.equalsIgnoreCase("true")) {
|
| - |
|
440 |
|
| - |
|
441 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
| - |
|
442 |
AnalyticsUtility.getAnalyticsRequest(ReferrerActivity.this, userData.getString("id", ""), "Clicks", "Referrer", "Invite Code Entered"),
|
| - |
|
443 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
| - |
|
444 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(ReferrerActivity.this);
|
| - |
|
445 |
|
| 451 |
if(userData.getString("message","false").equalsIgnoreCase("true")) {
|
446 |
if(userData.getString("message","false").equalsIgnoreCase("true")) {
|
| 452 |
Intent i = new Intent(ReferrerActivity.this, MobileNumber.class);
|
447 |
Intent i = new Intent(ReferrerActivity.this, MobileNumber.class);
|
| 453 |
i.putExtra("displayView", "7");
|
448 |
i.putExtra("displayView", "7");
|
| 454 |
startActivity(i);
|
449 |
startActivity(i);
|
| 455 |
}else{
|
450 |
}else{
|
| Line 524... |
Line 519... |
| 524 |
t.send(new HitBuilders.EventBuilder()
|
519 |
t.send(new HitBuilders.EventBuilder()
|
| 525 |
.setCategory("First Time Mobile Entered ")
|
520 |
.setCategory("First Time Mobile Entered ")
|
| 526 |
.setAction("Number entered")
|
521 |
.setAction("Number entered")
|
| 527 |
.setLabel("First Time Mobile entered")
|
522 |
.setLabel("First Time Mobile entered")
|
| 528 |
.build());
|
523 |
.build());
|
| 529 |
|
- |
|
| 530 |
} else {
|
524 |
new Analytics(ProfitTillConstants.ANALYTICS_URL,
|
| - |
|
525 |
AnalyticsUtility.getAnalyticsRequest(ReferrerActivity.this, userData.getString("id", ""), "Clicks", "Referrer", "Number Entered"),
|
| 531 |
System.out.println(" NOT Transfered");
|
526 |
AnalyticsJsonResponse.getAnalyticsRequestInstance(),
|
| 532 |
|
- |
|
| - |
|
527 |
AnalyticsErrorResponse.getAnalyitcsResponseInstance()).anlyticsRequest(ReferrerActivity.this);
|
| 533 |
}
|
528 |
}
|
| 534 |
|
- |
|
| 535 |
if(success.equalsIgnoreCase("true")){
|
529 |
if(success.equalsIgnoreCase("true")){
|
| 536 |
userDataEditor.putString("message","false");;
|
530 |
userDataEditor.putString("message","false");;
|
| 537 |
userDataEditor.putString("mobileNumber",mobileNumber.getText().toString());
|
531 |
userDataEditor.putString("mobileNumber",mobileNumber.getText().toString());
|
| 538 |
userDataEditor.commit();
|
532 |
userDataEditor.commit();
|
| 539 |
return "true";
|
533 |
return "true";
|
| Line 553... |
Line 547... |
| 553 |
|
547 |
|
| 554 |
@Override
|
548 |
@Override
|
| 555 |
protected void onPostExecute(String result) {
|
549 |
protected void onPostExecute(String result) {
|
| 556 |
super.onPostExecute(result);
|
550 |
super.onPostExecute(result);
|
| 557 |
pd2.dismiss();
|
551 |
pd2.dismiss();
|
| 558 |
|
- |
|
| 559 |
thanks.setText(apiData.getString("thanks.referrer.message","Thanks and we will get back to you"));
|
552 |
thanks.setText(apiData.getString("thanks.referrer.message","Thanks and we will get back to you"));
|
| 560 |
thanks.setVisibility(View.VISIBLE);
|
553 |
thanks.setVisibility(View.VISIBLE);
|
| 561 |
}
|
554 |
}
|
| 562 |
}
|
555 |
}
|
| 563 |
ProgressDialog pd2;
|
556 |
ProgressDialog pd2;
|
| 564 |
@Override
|
557 |
@Override
|
| 565 |
public void onBackPressed() {
|
558 |
public void onBackPressed() {
|
| 566 |
/* super.onBackPressed();*/
|
- |
|
| 567 |
new AlertDialog.Builder(this)
|
559 |
new AlertDialog.Builder(this)
|
| 568 |
.setIcon(android.R.drawable.ic_dialog_alert)
|
560 |
.setIcon(android.R.drawable.ic_dialog_alert)
|
| 569 |
.setTitle("Exit!")
|
561 |
.setTitle("Exit!")
|
| 570 |
.setMessage("Are you sure you want to sign out?")
|
562 |
.setMessage("Are you sure you want to sign out?")
|
| 571 |
.setPositiveButton("Yes", new DialogInterface.OnClickListener()
|
563 |
.setPositiveButton("Yes", new DialogInterface.OnClickListener()
|
| Line 608... |
Line 600... |
| 608 |
if (mGoogleApiClient.isConnected()) {
|
600 |
if (mGoogleApiClient.isConnected()) {
|
| 609 |
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
|
601 |
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
|
| 610 |
mGoogleApiClient.disconnect();
|
602 |
mGoogleApiClient.disconnect();
|
| 611 |
mGoogleApiClient.connect();
|
603 |
mGoogleApiClient.connect();
|
| 612 |
glogout=true;
|
604 |
glogout=true;
|
| 613 |
/*
|
- |
|
| 614 |
userDataEditor.remove("id");
|
- |
|
| 615 |
userDataEditor.remove("type");
|
- |
|
| 616 |
userDataEditor.remove("email");
|
- |
|
| 617 |
userDataEditor.commit();
|
- |
|
| 618 |
*/
|
- |
|
| 619 |
userDataEditor.clear().commit();
|
605 |
userDataEditor.clear().commit();
|
| 620 |
} else {
|
606 |
} else {
|
| 621 |
glogout=false;
|
607 |
glogout=false;
|
| 622 |
}
|
608 |
}
|
| 623 |
}
|
609 |
}
|
| Line 629... |
Line 615... |
| 629 |
|
615 |
|
| 630 |
if ( connection.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTED ||
|
616 |
if ( connection.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTED ||
|
| 631 |
connection.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTING ||
|
617 |
connection.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTING ||
|
| 632 |
connection.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.CONNECTING ||
|
618 |
connection.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.CONNECTING ||
|
| 633 |
connection.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.CONNECTED ) {
|
619 |
connection.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.CONNECTED ) {
|
| 634 |
|
- |
|
| 635 |
/*Toast.makeText(this, " Connected ", Toast.LENGTH_LONG).show();*/
|
- |
|
| 636 |
return true;
|
620 |
return true;
|
| 637 |
|
621 |
|
| 638 |
} else if (
|
622 |
} else if (
|
| 639 |
connection.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.DISCONNECTED ||
|
623 |
connection.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.DISCONNECTED ||
|
| 640 |
connection.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.DISCONNECTED ) {
|
624 |
connection.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.DISCONNECTED ) {
|
| 641 |
|
- |
|
| 642 |
/* Toast.makeText(this, " Not Connected ", Toast.LENGTH_LONG).show();*/
|
- |
|
| 643 |
return false;
|
625 |
return false;
|
| 644 |
}
|
626 |
}
|
| 645 |
return false;
|
627 |
return false;
|
| 646 |
}
|
628 |
}
|
| 647 |
|
629 |
|