| Line 1... |
Line 1... |
| 1 |
package com.saholic.profittill;
|
1 |
package com.saholic.profittill;
|
| 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.SharedPreferences;
|
10 |
import android.content.SharedPreferences;
|
| - |
|
11 |
import android.content.pm.PackageInfo;
|
| 10 |
import android.content.pm.PackageManager;
|
12 |
import android.content.pm.PackageManager;
|
| 11 |
import android.net.ConnectivityManager;
|
13 |
import android.net.ConnectivityManager;
|
| 12 |
import android.net.Uri;
|
14 |
import android.net.Uri;
|
| 13 |
import android.os.AsyncTask;
|
15 |
import android.os.AsyncTask;
|
| 14 |
import android.os.Build;
|
16 |
import android.os.Build;
|
| 15 |
import android.os.Bundle;
|
17 |
import android.os.Bundle;
|
| 16 |
import android.support.annotation.NonNull;
|
18 |
import android.support.annotation.NonNull;
|
| 17 |
import android.support.v4.app.ActivityCompat;
|
19 |
import android.support.v4.app.ActivityCompat;
|
| 18 |
import android.support.v4.content.ContextCompat;
|
20 |
import android.support.v4.content.ContextCompat;
|
| 19 |
import android.support.v7.app.ActionBarActivity;
|
21 |
import android.support.v7.app.ActionBarActivity;
|
| - |
|
22 |
import android.support.v7.app.AppCompatActivity;
|
| 20 |
import android.telephony.TelephonyManager;
|
23 |
import android.telephony.TelephonyManager;
|
| 21 |
import android.util.Log;
|
24 |
import android.util.Log;
|
| 22 |
import android.view.Menu;
|
25 |
import android.view.Menu;
|
| 23 |
import android.view.MenuItem;
|
26 |
import android.view.MenuItem;
|
| - |
|
27 |
import android.view.View;
|
| - |
|
28 |
import android.view.ViewGroup;
|
| 24 |
import android.widget.ProgressBar;
|
29 |
import android.widget.ProgressBar;
|
| 25 |
import android.widget.Toast;
|
30 |
import android.widget.Toast;
|
| 26 |
|
31 |
|
| 27 |
import com.google.android.gms.analytics.HitBuilders;
|
32 |
import com.google.android.gms.analytics.HitBuilders;
|
| 28 |
import com.google.android.gms.analytics.Tracker;
|
33 |
import com.google.android.gms.analytics.Tracker;
|
| 29 |
import com.google.android.gms.common.ConnectionResult;
|
34 |
import com.google.android.gms.common.ConnectionResult;
|
| 30 |
import com.google.android.gms.common.api.GoogleApiClient;
|
35 |
import com.google.android.gms.common.api.GoogleApiClient;
|
| - |
|
36 |
import com.google.android.gms.plus.Plus;
|
| 31 |
import com.google.firebase.iid.FirebaseInstanceId;
|
37 |
import com.google.firebase.iid.FirebaseInstanceId;
|
| 32 |
import com.saholic.profittill.Constants.ProfitTillConstants;
|
38 |
import com.saholic.profittill.Constants.ProfitTillConstants;
|
| 33 |
import com.saholic.profittill.Utils.UtilityFunctions;
|
39 |
import com.saholic.profittill.Utils.UtilityFunctions;
|
| - |
|
40 |
import com.saholic.profittill.main.DealsHomeFragment;
|
| 34 |
import com.saholic.profittill.main.GoogleAnalyticsTracker;
|
41 |
import com.saholic.profittill.main.GoogleAnalyticsTracker;
|
| - |
|
42 |
import com.saholic.profittill.main.HowItWorks;
|
| 35 |
import com.saholic.profittill.main.LoginActivity;
|
43 |
import com.saholic.profittill.main.LoginActivity;
|
| 36 |
import com.saholic.profittill.main.MainActivity;
|
44 |
import com.saholic.profittill.main.MainActivity;
|
| - |
|
45 |
import com.saholic.profittill.main.ScreenActivity;
|
| 37 |
import com.testin.agent.TestinAgent;
|
46 |
import com.testin.agent.TestinAgent;
|
| 38 |
|
47 |
|
| 39 |
import org.apache.http.HttpEntity;
|
48 |
import org.apache.http.HttpEntity;
|
| 40 |
import org.apache.http.HttpResponse;
|
49 |
import org.apache.http.HttpResponse;
|
| 41 |
import org.apache.http.NameValuePair;
|
50 |
import org.apache.http.NameValuePair;
|
| Line 54... |
Line 63... |
| 54 |
public class SplashScreen extends ActionBarActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener{
|
63 |
public class SplashScreen extends ActionBarActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener{
|
| 55 |
SharedPreferences apiData, userData, apkData;
|
64 |
SharedPreferences apiData, userData, apkData;
|
| 56 |
SharedPreferences.Editor apiEditor, userEditor, apkDataEditor,userDataEditor;
|
65 |
SharedPreferences.Editor apiEditor, userEditor, apkDataEditor,userDataEditor;
|
| 57 |
UtilityFunctions utilityFunctions;
|
66 |
UtilityFunctions utilityFunctions;
|
| 58 |
AlertDialog dialog1;
|
67 |
AlertDialog dialog1;
|
| - |
|
68 |
public GoogleApiClient mGoogleApiClient;
|
| 59 |
AlertDialog.Builder b;
|
69 |
AlertDialog.Builder b;
|
| 60 |
ProgressBar pd;
|
70 |
ProgressBar pd;
|
| - |
|
71 |
Context c;
|
| - |
|
72 |
String type1;
|
| 61 |
FirebaseInstanceId fcm;
|
73 |
FirebaseInstanceId fcm;
|
| 62 |
String regId;
|
74 |
String regId;
|
| 63 |
ArrayList<NameValuePair> apkDataListValue;
|
75 |
ArrayList<NameValuePair> apkDataListValue;
|
| 64 |
ArrayList<NameValuePair> nameValuePairsGcm;
|
76 |
ArrayList<NameValuePair> nameValuePairsGcm;
|
| 65 |
public static final int READ_PHONE_STATE_PERMISSION = 100;
|
77 |
public static final int READ_PHONE_STATE_PERMISSION = 100;
|
| Line 67... |
Line 79... |
| 67 |
@Override
|
79 |
@Override
|
| 68 |
protected void onCreate(Bundle savedInstanceState) {
|
80 |
protected void onCreate(Bundle savedInstanceState) {
|
| 69 |
TestinAgent.init(this);
|
81 |
TestinAgent.init(this);
|
| 70 |
super.onCreate(savedInstanceState);
|
82 |
super.onCreate(savedInstanceState);
|
| 71 |
setContentView(R.layout.activity_splash_screen);
|
83 |
setContentView(R.layout.activity_splash_screen);
|
| - |
|
84 |
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
| - |
|
85 |
getSupportActionBar().hide();
|
| - |
|
86 |
}
|
| 72 |
GIFView gifImageView = (GIFView) findViewById(R.id.gif);
|
87 |
GIFView gifImageView = (GIFView) findViewById(R.id.gif);
|
| 73 |
gifImageView.setGifImageResource(R.drawable.progressbar);
|
88 |
gifImageView.setGifImageResource(R.drawable.progressbar);
|
| 74 |
userData = getApplicationContext().getSharedPreferences("User_Data", MODE_PRIVATE);
|
89 |
userData = getApplicationContext().getSharedPreferences("User_Data", MODE_PRIVATE);
|
| 75 |
apkData = getApplicationContext().getSharedPreferences("APK_Data", MODE_PRIVATE);
|
90 |
apkData = getApplicationContext().getSharedPreferences("APK_Data", MODE_PRIVATE);
|
| 76 |
apiData = getApplicationContext().getSharedPreferences("API_Data", MODE_PRIVATE);
|
91 |
apiData = getApplicationContext().getSharedPreferences("API_Data", MODE_PRIVATE);
|
| 77 |
apkDataEditor = apkData.edit();
|
92 |
apkDataEditor = apkData.edit();
|
| 78 |
userEditor = userData.edit();
|
93 |
userDataEditor = userData.edit();
|
| 79 |
apiEditor = apiData.edit();
|
94 |
apiEditor = apiData.edit();
|
| - |
|
95 |
|
| 80 |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
96 |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
| 81 |
requestPermissions(new String[]{Manifest.permission.READ_PHONE_STATE}, READ_PHONE_STATE_PERMISSION);
|
97 |
requestPermissions(new String[]{Manifest.permission.READ_PHONE_STATE}, READ_PHONE_STATE_PERMISSION);
|
| 82 |
}
|
98 |
}
|
| 83 |
else{
|
99 |
else{
|
| 84 |
PermissionIngranted=true;
|
100 |
PermissionIngranted=true;
|
| 85 |
}
|
101 |
}
|
| - |
|
102 |
|
| - |
|
103 |
type1 = userData.getString("type", null);
|
| - |
|
104 |
if (type1 != null && type1.equalsIgnoreCase("google")) {
|
| - |
|
105 |
mGoogleApiClient = new GoogleApiClient.Builder(SplashScreen.this)
|
| - |
|
106 |
.addConnectionCallbacks(this)
|
| - |
|
107 |
.addOnConnectionFailedListener(this).addApi(Plus.API)
|
| - |
|
108 |
.addScope(Plus.SCOPE_PLUS_LOGIN).build();
|
| - |
|
109 |
mGoogleApiClient.connect();
|
| - |
|
110 |
}
|
| 86 |
String url = "";
|
111 |
String url = "";
|
| 87 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
112 |
Tracker t = ((GoogleAnalyticsTracker) getApplicationContext()).getTracker(
|
| 88 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
113 |
GoogleAnalyticsTracker.TrackerName.APP_TRACKER);
|
| 89 |
t.setScreenName("Splash Screen");
|
114 |
t.setScreenName("Splash Screen");
|
| 90 |
t.send(new HitBuilders.ScreenViewBuilder().build());
|
115 |
t.send(new HitBuilders.ScreenViewBuilder().build());
|
| Line 160... |
Line 185... |
| 160 |
dialog1.show();
|
185 |
dialog1.show();
|
| 161 |
}
|
186 |
}
|
| 162 |
}
|
187 |
}
|
| 163 |
|
188 |
|
| 164 |
|
189 |
|
| - |
|
190 |
private int getFirstTimeRun() throws PackageManager.NameNotFoundException {
|
| - |
|
191 |
SharedPreferences appPreferences = getSharedPreferences("MyAPP", 0);
|
| - |
|
192 |
int appCurrentBuildVersion = BuildConfig.VERSION_CODE;
|
| - |
|
193 |
int appLastBuildVersion = appPreferences.getInt("app_first_time", 0);
|
| - |
|
194 |
|
| - |
|
195 |
if (appLastBuildVersion == appCurrentBuildVersion ) {
|
| - |
|
196 |
final String idCheck = userData.getString("id", null);
|
| - |
|
197 |
|
| - |
|
198 |
if(idCheck != null){
|
| - |
|
199 |
Intent startActivityIntent=new Intent(SplashScreen.this, MainActivity.class);
|
| - |
|
200 |
Intent intent = getIntent();
|
| - |
|
201 |
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
|
| - |
|
202 |
Uri uri = intent.getData();
|
| - |
|
203 |
startActivityIntent.setAction("31");
|
| - |
|
204 |
startActivityIntent.setData(Uri.parse(uri.toString()));
|
| - |
|
205 |
}
|
| - |
|
206 |
startActivity(startActivityIntent);
|
| - |
|
207 |
}
|
| - |
|
208 |
else{
|
| - |
|
209 |
Intent startActivityIntent=new Intent(SplashScreen.this,LoginActivity .class);
|
| - |
|
210 |
Intent intent = getIntent();
|
| - |
|
211 |
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
|
| - |
|
212 |
Uri uri = intent.getData();
|
| - |
|
213 |
startActivityIntent.setAction("31");
|
| - |
|
214 |
startActivityIntent.setData(Uri.parse(uri.toString()));
|
| - |
|
215 |
}
|
| - |
|
216 |
startActivity(startActivityIntent);
|
| - |
|
217 |
}
|
| - |
|
218 |
return 1;
|
| - |
|
219 |
}
|
| - |
|
220 |
|
| - |
|
221 |
else {
|
| - |
|
222 |
appPreferences.edit().putInt("app_first_time",
|
| - |
|
223 |
appCurrentBuildVersion).apply();
|
| - |
|
224 |
if (appLastBuildVersion == 0) {
|
| - |
|
225 |
Intent startActivityIntent=new Intent(SplashScreen.this, ScreenActivity.class);
|
| - |
|
226 |
startActivity(startActivityIntent);
|
| - |
|
227 |
|
| - |
|
228 |
}
|
| - |
|
229 |
else {
|
| - |
|
230 |
try{
|
| - |
|
231 |
if (mGoogleApiClient.isConnected()) {
|
| - |
|
232 |
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
|
| - |
|
233 |
mGoogleApiClient.disconnect();
|
| - |
|
234 |
mGoogleApiClient.connect();
|
| - |
|
235 |
userDataEditor.clear().commit();
|
| - |
|
236 |
startActivity(new Intent(SplashScreen.this,LoginActivity.class));
|
| - |
|
237 |
}
|
| - |
|
238 |
else{
|
| - |
|
239 |
if(!mGoogleApiClient.isConnected()){
|
| - |
|
240 |
userDataEditor.clear().commit();
|
| - |
|
241 |
startActivity(new Intent(SplashScreen.this, LoginActivity.class));
|
| - |
|
242 |
}
|
| - |
|
243 |
|
| - |
|
244 |
}
|
| - |
|
245 |
}catch (Exception e){
|
| - |
|
246 |
userDataEditor.clear().commit();
|
| - |
|
247 |
startActivity(new Intent(SplashScreen.this, LoginActivity.class));
|
| - |
|
248 |
}
|
| - |
|
249 |
}
|
| - |
|
250 |
}
|
| - |
|
251 |
return 2;
|
| - |
|
252 |
}
|
| - |
|
253 |
|
| - |
|
254 |
@Override
|
| - |
|
255 |
public Intent getIntent() {
|
| - |
|
256 |
return super.getIntent();
|
| - |
|
257 |
}
|
| - |
|
258 |
|
| - |
|
259 |
@Override
|
| - |
|
260 |
public void setContentView(View view, ViewGroup.LayoutParams params) {
|
| - |
|
261 |
super.setContentView(view, params);
|
| - |
|
262 |
}
|
| - |
|
263 |
|
| - |
|
264 |
public SplashScreen() {
|
| - |
|
265 |
super();
|
| - |
|
266 |
}
|
| - |
|
267 |
|
| 165 |
public void requestphoneUpdates(){
|
268 |
public void requestphoneUpdates(){
|
| 166 |
|
269 |
|
| 167 |
if (ContextCompat.checkSelfPermission(SplashScreen.this,
|
270 |
if (ContextCompat.checkSelfPermission(SplashScreen.this,
|
| 168 |
Manifest.permission.READ_PHONE_STATE)
|
271 |
Manifest.permission.READ_PHONE_STATE)
|
| 169 |
!= PackageManager.PERMISSION_GRANTED) {
|
272 |
!= PackageManager.PERMISSION_GRANTED) {
|
| 170 |
if (ActivityCompat.shouldShowRequestPermissionRationale(SplashScreen.this,
|
273 |
if (ActivityCompat.shouldShowRequestPermissionRationale(SplashScreen.this,
|
| Line 219... |
Line 322... |
| 219 |
});
|
322 |
});
|
| 220 |
dialog1 = b.create();
|
323 |
dialog1 = b.create();
|
| 221 |
dialog1.show();
|
324 |
dialog1.show();
|
| 222 |
}}
|
325 |
}}
|
| 223 |
else {
|
326 |
else {
|
| 224 |
Toast.makeText(getApplicationContext(),"Permission is required to enter in application",Toast.LENGTH_LONG).show();
|
327 |
// Toast.makeText(getApplicationContext(),"Permission is required to enter in application",Toast.LENGTH_LONG).show();
|
| 225 |
PermissionIngranted = false;
|
328 |
PermissionIngranted = false;
|
| 226 |
}
|
329 |
}
|
| 227 |
}
|
330 |
}
|
| 228 |
catch (Exception e){
|
331 |
catch (Exception e){
|
| 229 |
e.printStackTrace();
|
332 |
e.printStackTrace();
|
| Line 284... |
Line 387... |
| 284 |
HttpResponse response = httpclient.execute(httppost);
|
387 |
HttpResponse response = httpclient.execute(httppost);
|
| 285 |
HttpEntity entity = response.getEntity();
|
388 |
HttpEntity entity = response.getEntity();
|
| 286 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
389 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
| 287 |
return jObjGmail;
|
390 |
return jObjGmail;
|
| 288 |
|
391 |
|
| - |
|
392 |
}
|
| 289 |
} catch (Exception e) {
|
393 |
catch(Exception e) {
|
| 290 |
e.printStackTrace();
|
394 |
e.printStackTrace();
|
| 291 |
return null;
|
395 |
return null;
|
| 292 |
|
396 |
|
| 293 |
}
|
397 |
}
|
| 294 |
|
398 |
|
| Line 315... |
Line 419... |
| 315 |
}
|
419 |
}
|
| 316 |
String timestamp=result.getString("t");
|
420 |
String timestamp=result.getString("t");
|
| 317 |
String failureCount=result.getString("failureCount");
|
421 |
String failureCount=result.getString("failureCount");
|
| 318 |
apkDataEditor.putString("timestamp",timestamp);
|
422 |
apkDataEditor.putString("timestamp",timestamp);
|
| 319 |
apkDataEditor.commit();
|
423 |
apkDataEditor.commit();
|
| 320 |
final String idCheck = userData.getString("id",null);
|
- |
|
| 321 |
if(Integer.parseInt(failureCount)<=0) {
|
- |
|
| 322 |
/* if(userData.getString("docsSubmitted","false").equalsIgnoreCase("true")){
|
- |
|
| 323 |
Intent i = new Intent(SplashScreen.this, PendingActivity.class);
|
- |
|
| 324 |
startActivity(i);
|
424 |
getFirstTimeRun();
|
| 325 |
}
|
- |
|
| 326 |
else if (userData.getString("referralCodeRequired", "false").equalsIgnoreCase("true")) {
|
- |
|
| 327 |
Intent startActivityIntent=new Intent(SplashScreen.this, BasicInformation.class);
|
- |
|
| 328 |
|
- |
|
| 329 |
startActivity(startActivityIntent);
|
- |
|
| 330 |
} else if (userData.getString("message", "false").equalsIgnoreCase("true")) {
|
- |
|
| 331 |
Intent startActivityIntent=new Intent(SplashScreen.this, MobileNumber.class);
|
- |
|
| 332 |
Intent intent = getIntent();
|
- |
|
| 333 |
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
|
- |
|
| 334 |
Uri uri = intent.getData();
|
- |
|
| 335 |
startActivityIntent.setAction("31");
|
- |
|
| 336 |
startActivityIntent.setData(Uri.parse(uri.toString()));
|
- |
|
| 337 |
}
|
- |
|
| 338 |
|
425 |
|
| 339 |
startActivity(startActivityIntent);
|
- |
|
| 340 |
} else */
|
- |
|
| 341 |
if (idCheck != null) {
|
- |
|
| 342 |
Intent startActivityIntent=new Intent(SplashScreen.this, MainActivity.class);
|
- |
|
| 343 |
Intent intent = getIntent();
|
- |
|
| 344 |
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
|
- |
|
| 345 |
Uri uri = intent.getData();
|
- |
|
| 346 |
startActivityIntent.setAction("31");
|
- |
|
| 347 |
startActivityIntent.setData(Uri.parse(uri.toString()));
|
- |
|
| 348 |
}
|
- |
|
| 349 |
startActivity(startActivityIntent);
|
- |
|
| 350 |
} else {
|
- |
|
| 351 |
Intent startActivityIntent=new Intent(SplashScreen.this,LoginActivity .class);
|
- |
|
| 352 |
Intent intent = getIntent();
|
- |
|
| 353 |
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
|
- |
|
| 354 |
Uri uri = intent.getData();
|
- |
|
| 355 |
startActivityIntent.setAction("31");
|
- |
|
| 356 |
startActivityIntent.setData(Uri.parse(uri.toString()));
|
- |
|
| 357 |
}
|
- |
|
| 358 |
startActivity(startActivityIntent);
|
- |
|
| 359 |
}
|
- |
|
| 360 |
}else{
|
- |
|
| 361 |
registerGCM();
|
- |
|
| 362 |
}
|
- |
|
| 363 |
}catch (Exception e){
|
426 |
}catch (Exception e){
|
| 364 |
finish();
|
427 |
finish();
|
| 365 |
}
|
428 |
}
|
| 366 |
}
|
429 |
}
|
| 367 |
}
|
430 |
}
|
| Line 375... |
Line 438... |
| 375 |
|
438 |
|
| 376 |
@Override
|
439 |
@Override
|
| 377 |
protected String doInBackground(String... arg0) {
|
440 |
protected String doInBackground(String... arg0) {
|
| 378 |
try {
|
441 |
try {
|
| 379 |
HttpClient httpclient = new DefaultHttpClient();
|
442 |
HttpClient httpclient = new DefaultHttpClient();
|
| 380 |
HttpPost httppost = new HttpPost("http://api.profittill.com/devices/add");
|
443 |
HttpPost httppost = new HttpPost(apiData.getString("devices_info","http://api.profittill.com/devices/add"));
|
| 381 |
//HttpPost httppost = new HttpPost(ProfitTillConstants.Push_Url);
|
444 |
//HttpPost httppost = new HttpPost(ProfitTillConstants.Push_Url);
|
| 382 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
445 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
| 383 |
httppost.setEntity(new UrlEncodedFormEntity(apkDataListValue));
|
446 |
httppost.setEntity(new UrlEncodedFormEntity(apkDataListValue));
|
| 384 |
HttpResponse response = httpclient.execute(httppost);
|
447 |
HttpResponse response = httpclient.execute(httppost);
|
| 385 |
HttpEntity entity = response.getEntity();
|
448 |
HttpEntity entity = response.getEntity();
|