| 21480 |
rajender |
1 |
package com.saholic.profittill.main;
|
|
|
2 |
|
| 22130 |
rajender |
3 |
import android.annotation.SuppressLint;
|
| 23184 |
rajender |
4 |
import android.annotation.TargetApi;
|
| 22130 |
rajender |
5 |
import android.app.Activity;
|
| 21480 |
rajender |
6 |
import android.app.AlertDialog;
|
|
|
7 |
import android.app.Fragment;
|
|
|
8 |
import android.app.ProgressDialog;
|
| 22130 |
rajender |
9 |
import android.content.BroadcastReceiver;
|
| 21480 |
rajender |
10 |
import android.content.ComponentName;
|
|
|
11 |
import android.content.Context;
|
|
|
12 |
import android.content.DialogInterface;
|
|
|
13 |
import android.content.Intent;
|
|
|
14 |
import android.content.IntentFilter;
|
|
|
15 |
import android.content.SharedPreferences;
|
| 23184 |
rajender |
16 |
import android.content.pm.PackageManager;
|
| 21480 |
rajender |
17 |
import android.content.pm.ResolveInfo;
|
| 23184 |
rajender |
18 |
import android.database.Cursor;
|
| 21480 |
rajender |
19 |
import android.graphics.Bitmap;
|
| 23184 |
rajender |
20 |
import android.graphics.BitmapFactory;
|
|
|
21 |
import android.graphics.Canvas;
|
| 22130 |
rajender |
22 |
import android.graphics.Color;
|
| 23184 |
rajender |
23 |
import android.graphics.Matrix;
|
|
|
24 |
import android.graphics.Paint;
|
| 22130 |
rajender |
25 |
import android.graphics.PorterDuff;
|
|
|
26 |
import android.graphics.drawable.ColorDrawable;
|
|
|
27 |
import android.graphics.drawable.Drawable;
|
| 23184 |
rajender |
28 |
import android.media.ExifInterface;
|
| 21480 |
rajender |
29 |
import android.net.ConnectivityManager;
|
|
|
30 |
import android.net.Uri;
|
|
|
31 |
import android.os.AsyncTask;
|
|
|
32 |
import android.os.Build;
|
|
|
33 |
import android.os.Bundle;
|
| 22130 |
rajender |
34 |
import android.os.Environment;
|
| 21480 |
rajender |
35 |
import android.os.Handler;
|
|
|
36 |
import android.os.Parcelable;
|
| 23184 |
rajender |
37 |
import android.provider.DocumentsContract;
|
| 22130 |
rajender |
38 |
import android.provider.MediaStore;
|
| 21480 |
rajender |
39 |
import android.support.v4.os.AsyncTaskCompat;
|
| 22130 |
rajender |
40 |
import android.support.v7.app.ActionBar;
|
|
|
41 |
import android.support.v7.app.AppCompatActivity;
|
|
|
42 |
import android.telephony.SmsMessage;
|
|
|
43 |
import android.telephony.TelephonyManager;
|
| 21480 |
rajender |
44 |
import android.util.Base64;
|
|
|
45 |
import android.util.Log;
|
|
|
46 |
import android.view.KeyEvent;
|
|
|
47 |
import android.view.LayoutInflater;
|
|
|
48 |
import android.view.Menu;
|
|
|
49 |
import android.view.MenuInflater;
|
| 22381 |
rajender |
50 |
import android.view.MenuItem;
|
| 21480 |
rajender |
51 |
import android.view.View;
|
|
|
52 |
import android.view.ViewGroup;
|
|
|
53 |
import android.webkit.CookieManager;
|
|
|
54 |
import android.webkit.CookieSyncManager;
|
|
|
55 |
import android.webkit.HttpAuthHandler;
|
|
|
56 |
import android.webkit.JavascriptInterface;
|
|
|
57 |
import android.webkit.ValueCallback;
|
| 22130 |
rajender |
58 |
import android.webkit.WebChromeClient;
|
| 22830 |
rajender |
59 |
import android.webkit.WebResourceError;
|
|
|
60 |
import android.webkit.WebResourceRequest;
|
| 21480 |
rajender |
61 |
import android.webkit.WebSettings;
|
|
|
62 |
import android.webkit.WebView;
|
|
|
63 |
import android.webkit.WebViewClient;
|
|
|
64 |
import android.widget.CheckBox;
|
|
|
65 |
import android.widget.CompoundButton;
|
|
|
66 |
import android.widget.Toast;
|
|
|
67 |
|
|
|
68 |
import com.google.android.gms.common.ConnectionResult;
|
|
|
69 |
import com.google.android.gms.common.api.GoogleApiClient;
|
|
|
70 |
import com.google.android.gms.plus.Plus;
|
| 22130 |
rajender |
71 |
import com.google.firebase.iid.FirebaseInstanceId;
|
| 23184 |
rajender |
72 |
import com.kosalgeek.android.photoutil.CameraPhoto;
|
|
|
73 |
import com.kosalgeek.android.photoutil.GalleryPhoto;
|
|
|
74 |
import com.kosalgeek.android.photoutil.ImageLoader;
|
| 21480 |
rajender |
75 |
import com.saholic.profittill.Constants.ProfitTillConstants;
|
|
|
76 |
import com.saholic.profittill.Database.OrderTransactionDetails;
|
|
|
77 |
import com.saholic.profittill.Network.NotificationCount;
|
|
|
78 |
import com.saholic.profittill.R;
|
|
|
79 |
import com.saholic.profittill.Utils.UtilityFunctions;
|
|
|
80 |
import com.testin.agent.TestinAgent;
|
|
|
81 |
|
|
|
82 |
import org.apache.http.HttpEntity;
|
|
|
83 |
import org.apache.http.HttpResponse;
|
|
|
84 |
import org.apache.http.NameValuePair;
|
|
|
85 |
import org.apache.http.client.ClientProtocolException;
|
|
|
86 |
import org.apache.http.client.HttpClient;
|
|
|
87 |
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
88 |
import org.apache.http.client.methods.HttpGet;
|
|
|
89 |
import org.apache.http.client.methods.HttpPost;
|
|
|
90 |
import org.apache.http.entity.StringEntity;
|
|
|
91 |
import org.apache.http.impl.client.DefaultHttpClient;
|
|
|
92 |
import org.apache.http.message.BasicNameValuePair;
|
|
|
93 |
import org.apache.http.util.EntityUtils;
|
|
|
94 |
import org.json.JSONArray;
|
|
|
95 |
import org.json.JSONException;
|
|
|
96 |
import org.json.JSONObject;
|
|
|
97 |
|
| 23184 |
rajender |
98 |
import java.io.BufferedOutputStream;
|
|
|
99 |
import java.io.ByteArrayOutputStream;
|
| 22130 |
rajender |
100 |
import java.io.File;
|
| 23184 |
rajender |
101 |
import java.io.FileNotFoundException;
|
|
|
102 |
import java.io.FileOutputStream;
|
| 21480 |
rajender |
103 |
import java.io.IOException;
|
|
|
104 |
import java.io.InputStream;
|
| 23184 |
rajender |
105 |
import java.io.OutputStream;
|
| 21480 |
rajender |
106 |
import java.io.UnsupportedEncodingException;
|
| 22830 |
rajender |
107 |
import java.net.URISyntaxException;
|
| 21480 |
rajender |
108 |
import java.text.SimpleDateFormat;
|
|
|
109 |
import java.util.ArrayList;
|
|
|
110 |
import java.util.Date;
|
|
|
111 |
import java.util.HashMap;
|
|
|
112 |
import java.util.Iterator;
|
|
|
113 |
import java.util.LinkedList;
|
|
|
114 |
import java.util.List;
|
|
|
115 |
import java.util.Map;
|
|
|
116 |
import java.util.StringTokenizer;
|
|
|
117 |
import java.util.regex.Matcher;
|
|
|
118 |
import java.util.regex.Pattern;
|
|
|
119 |
|
|
|
120 |
public class DealsHomeFragment extends Fragment implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
|
|
|
121 |
|
| 23184 |
rajender |
122 |
private File storageDir;
|
|
|
123 |
File photoFile = null;
|
|
|
124 |
|
| 21480 |
rajender |
125 |
public DealsHomeFragment() {
|
|
|
126 |
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
static boolean FLAG = false, REDIRECT = false, PAGE_LOAD = false, PAYTMFLAG = false, isPause = false, Flipkartflag = false;
|
|
|
130 |
int snapdealException = 0;
|
|
|
131 |
static String BASIC_AUTH = "Basic " + Base64.encodeToString("dtr:dtr18Feb2015".getBytes(), Base64.NO_WRAP);
|
|
|
132 |
public static WebView webView;
|
|
|
133 |
WebView amazonWebView, OrderHistoryWebView, amazonOrderHistoryWebView, amazonOrderHistoryCancelledWebView, paytmWebView;
|
|
|
134 |
WebView amazonAllUrlsWebView;
|
|
|
135 |
SharedPreferences userData;
|
|
|
136 |
SharedPreferences apiData;
|
|
|
137 |
SharedPreferences flipkartData;
|
|
|
138 |
SharedPreferences.Editor userDataEditor;
|
|
|
139 |
SharedPreferences.Editor apiSettingsEditor;
|
|
|
140 |
SharedPreferences.Editor flipkartDataEditor;
|
|
|
141 |
OrderTransactionDetails orderDetails;
|
|
|
142 |
LinkedList<ArrayList<NameValuePair>> orderLinkedList;
|
|
|
143 |
SharedPreferences amazonData;
|
|
|
144 |
String affliateUrl;
|
|
|
145 |
String landingURL;
|
| 22130 |
rajender |
146 |
String regId;
|
| 23184 |
rajender |
147 |
String temp;
|
| 22130 |
rajender |
148 |
String msg = "";
|
|
|
149 |
ArrayList<NameValuePair> messageNameValuePair;
|
| 21480 |
rajender |
150 |
boolean val = false;
|
|
|
151 |
String redirectUrls;
|
|
|
152 |
String pageLoad;
|
|
|
153 |
SharedPreferences.Editor amazonapiSettingsEditor;
|
|
|
154 |
List<NameValuePair> amazonOrderTrackingData;
|
|
|
155 |
int pageRedirect = 0;
|
|
|
156 |
int snapdealPageLoad;
|
|
|
157 |
final ArrayList<String> redirectUrlsList = new ArrayList<String>();
|
|
|
158 |
final ArrayList<String> pageLoadList = new ArrayList<String>();
|
|
|
159 |
String flipkartUrl;
|
|
|
160 |
View checkBoxView;
|
| 22130 |
rajender |
161 |
boolean glogout;
|
| 21480 |
rajender |
162 |
boolean flipkartFlag;
|
|
|
163 |
String saholicUrl;
|
|
|
164 |
JSONObject jSaholic;
|
|
|
165 |
JSONArray jsArraySaholic;
|
|
|
166 |
String type1;
|
|
|
167 |
ArrayList<String> orderSuccessUrlList;
|
|
|
168 |
public GoogleApiClient mGoogleApiClient;
|
|
|
169 |
ProgressDialog pd1 = null;
|
| 22130 |
rajender |
170 |
private static final String TAG = DealsHomeFragment.class.getSimpleName();
|
|
|
171 |
private String mCM;
|
|
|
172 |
private ValueCallback<Uri> mUM;
|
|
|
173 |
private ValueCallback<Uri[]> mUMA;
|
|
|
174 |
private final static int FCR=1;
|
| 23184 |
rajender |
175 |
GalleryPhoto galleryPhoto;
|
|
|
176 |
CameraPhoto cameraPhoto;
|
| 22130 |
rajender |
177 |
boolean doubleBackToExitPressedOnce = false;
|
| 21480 |
rajender |
178 |
String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
|
|
|
179 |
|
|
|
180 |
@Override
|
|
|
181 |
public void onCreate(Bundle savedInstanceState) {
|
|
|
182 |
super.onCreate(savedInstanceState);
|
|
|
183 |
setRetainInstance(true);
|
|
|
184 |
setHasOptionsMenu(true);
|
| 22130 |
rajender |
185 |
|
| 21480 |
rajender |
186 |
}
|
|
|
187 |
|
|
|
188 |
@Override
|
|
|
189 |
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
|
190 |
super.onCreateOptionsMenu(menu, inflater);
|
|
|
191 |
|
|
|
192 |
|
| 22130 |
rajender |
193 |
/* RelativeLayout badgeLayout = (RelativeLayout) menu.findItem(R.id.action_notifications).getActionView();
|
| 21480 |
rajender |
194 |
TextView notifciationCount = (TextView) badgeLayout.findViewById(R.id.inAppNotificationText);
|
|
|
195 |
if (userData.getInt("notification_count", 0) != 0) {
|
|
|
196 |
notifciationCount.setVisibility(View.VISIBLE);
|
|
|
197 |
notifciationCount.setText(userData.getInt("notification_count", 0) + "");
|
|
|
198 |
} else {
|
|
|
199 |
notifciationCount.setVisibility(View.GONE);
|
| 22130 |
rajender |
200 |
}*/
|
| 21480 |
rajender |
201 |
}
|
| 22381 |
rajender |
202 |
@Override
|
|
|
203 |
public boolean onOptionsItemSelected(MenuItem item) {
|
| 22830 |
rajender |
204 |
|
| 22381 |
rajender |
205 |
switch (item.getItemId()) {
|
| 21480 |
rajender |
206 |
|
| 22381 |
rajender |
207 |
case android.R.id.home:
|
|
|
208 |
Intent i = new Intent(getActivity(), MainActivity.class);
|
| 22830 |
rajender |
209 |
i.putExtra("displayView", "13");
|
| 22381 |
rajender |
210 |
startActivity(i);
|
|
|
211 |
return true;
|
|
|
212 |
|
|
|
213 |
}
|
|
|
214 |
return super.onOptionsItemSelected(item);
|
|
|
215 |
}
|
|
|
216 |
|
| 22830 |
rajender |
217 |
@Override
|
|
|
218 |
public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
|
|
|
219 |
super.startActivityForResult(intent, requestCode, options);
|
|
|
220 |
}
|
|
|
221 |
|
|
|
222 |
@Override
|
| 21480 |
rajender |
223 |
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
|
224 |
Bundle savedInstanceState) {
|
|
|
225 |
|
|
|
226 |
|
|
|
227 |
View rootView = inflater.inflate(R.layout.fragment_deals_home, container, false);
|
|
|
228 |
TestinAgent.init(getActivity());
|
| 22830 |
rajender |
229 |
int InstanceId = DealsHomeFragment.class.hashCode();
|
| 22130 |
rajender |
230 |
AppCompatActivity activity = (AppCompatActivity) getActivity();
|
|
|
231 |
ActionBar actionBar = activity.getSupportActionBar();
|
|
|
232 |
actionBar.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
|
| 23184 |
rajender |
233 |
galleryPhoto = new GalleryPhoto(getActivity());
|
|
|
234 |
cameraPhoto = new CameraPhoto(getActivity());
|
| 22130 |
rajender |
235 |
final Drawable upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
|
|
|
236 |
upArrow.setColorFilter(getResources().getColor(R.color.grey_black), PorterDuff.Mode.SRC_ATOP);
|
|
|
237 |
actionBar.setHomeAsUpIndicator(upArrow);
|
|
|
238 |
actionBar.setDisplayShowCustomEnabled(true);
|
|
|
239 |
actionBar.setDisplayShowTitleEnabled(false);
|
|
|
240 |
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
|
241 |
actionBar.setHomeButtonEnabled(true);
|
|
|
242 |
actionBar.setCustomView(R.layout.actionbarprofittill);
|
| 22381 |
rajender |
243 |
actionBar.hide();
|
| 21480 |
rajender |
244 |
amazonData = getActivity().getSharedPreferences("Amazon_Data", Context.MODE_PRIVATE);
|
|
|
245 |
userData = getActivity().getSharedPreferences("User_Data", Context.MODE_PRIVATE);
|
|
|
246 |
apiData = getActivity().getSharedPreferences("API_Data", Context.MODE_PRIVATE);
|
|
|
247 |
flipkartData = getActivity().getSharedPreferences("Flipkart_Data", Context.MODE_PRIVATE);
|
|
|
248 |
userDataEditor = userData.edit();
|
|
|
249 |
apiSettingsEditor = apiData.edit();
|
|
|
250 |
TestinAgent.setUserInfo(userData.getString("id", ""));
|
|
|
251 |
amazonapiSettingsEditor = amazonData.edit();
|
|
|
252 |
flipkartDataEditor = flipkartData.edit();
|
|
|
253 |
affliateUrl = getArguments().getString("key");
|
|
|
254 |
orderDetails = new OrderTransactionDetails(getActivity());
|
|
|
255 |
orderSuccessUrlList = new ArrayList<String>();
|
|
|
256 |
String issues = apiData.getString("list.order.success.url", "blank");
|
|
|
257 |
StringTokenizer st2 = new StringTokenizer(issues, "|");
|
|
|
258 |
|
|
|
259 |
while (st2.hasMoreElements()) {
|
|
|
260 |
orderSuccessUrlList.add(st2.nextToken());
|
|
|
261 |
}
|
|
|
262 |
if (isInternetOn()) {
|
|
|
263 |
if (orderDetails.countTotalRecords() > 0) {
|
|
|
264 |
sendQueuedResponse();
|
|
|
265 |
}
|
|
|
266 |
type1 = userData.getString("type", null);
|
|
|
267 |
if (type1 != null && type1.equalsIgnoreCase("google")) {
|
|
|
268 |
mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
|
|
|
269 |
.addConnectionCallbacks(this)
|
|
|
270 |
.addOnConnectionFailedListener(this).addApi(Plus.API)
|
|
|
271 |
.addScope(Plus.SCOPE_PLUS_LOGIN).build();
|
|
|
272 |
mGoogleApiClient.connect();
|
|
|
273 |
}
|
|
|
274 |
redirectUrls = apiData.getString("profitmandi.redirect.urls", "");
|
|
|
275 |
StringTokenizer st = new StringTokenizer(redirectUrls, "|");
|
|
|
276 |
while (st.hasMoreTokens()) {
|
|
|
277 |
redirectUrlsList.add(st.nextToken());
|
|
|
278 |
}
|
|
|
279 |
pageLoad = apiData.getString("profitmandi.pageloads.pattern", "");
|
|
|
280 |
StringTokenizer st1 = new StringTokenizer(pageLoad, "|");
|
|
|
281 |
while (st1.hasMoreTokens()) {
|
|
|
282 |
pageLoadList.add(st1.nextToken());
|
|
|
283 |
}
|
|
|
284 |
WebClientClass webViewClient = new WebClientClass();
|
|
|
285 |
if (webView != null) {
|
|
|
286 |
webView.loadUrl("about:blank");
|
|
|
287 |
}
|
|
|
288 |
webView = (WebView) rootView.findViewById(R.id.webView);
|
|
|
289 |
webView.setClickable(true);
|
|
|
290 |
webView.setFocusableInTouchMode(true);
|
|
|
291 |
webView.getSettings().setDomStorageEnabled(true);
|
| 22130 |
rajender |
292 |
webView.getSettings().setDatabaseEnabled(true);
|
| 21480 |
rajender |
293 |
webView.getSettings().setJavaScriptEnabled(true);
|
| 22130 |
rajender |
294 |
webView.getSettings().setAllowContentAccess(true);
|
|
|
295 |
webView.getSettings().setAllowFileAccess(true);
|
| 22830 |
rajender |
296 |
|
| 22130 |
rajender |
297 |
webView.addJavascriptInterface(new javascriptInterface(webView),"HTMLOUT");
|
|
|
298 |
if(Build.VERSION.SDK_INT >= 21){
|
|
|
299 |
webView.getSettings().setMixedContentMode(0);
|
|
|
300 |
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
|
|
301 |
}else if(Build.VERSION.SDK_INT >= 19){
|
|
|
302 |
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
|
|
303 |
}else if(Build.VERSION.SDK_INT < 19){
|
|
|
304 |
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
|
|
305 |
}
|
|
|
306 |
webView.setWebViewClient(new Callback());
|
|
|
307 |
webView.setWebChromeClient(new WebChromeClient(){
|
|
|
308 |
//For Android 3.0+
|
|
|
309 |
public void openFileChooser(ValueCallback<Uri> uploadMsg){
|
|
|
310 |
mUM = uploadMsg;
|
|
|
311 |
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
|
|
312 |
i.addCategory(Intent.CATEGORY_OPENABLE);
|
|
|
313 |
i.setType("*/*");
|
|
|
314 |
getActivity().startActivityForResult(Intent.createChooser(i,"File Chooser"), FCR);
|
|
|
315 |
}
|
|
|
316 |
// For Android 3.0+, above method not supported in some android 3+ versions, in such case we use this
|
|
|
317 |
public void openFileChooser(ValueCallback uploadMsg, String acceptType){
|
|
|
318 |
mUM = uploadMsg;
|
|
|
319 |
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
|
|
320 |
i.addCategory(Intent.CATEGORY_OPENABLE);
|
|
|
321 |
i.setType("*/*");
|
|
|
322 |
getActivity().startActivityForResult(
|
|
|
323 |
Intent.createChooser(i, "File Browser"),
|
|
|
324 |
FCR);
|
|
|
325 |
}
|
|
|
326 |
//For Android 4.1+
|
|
|
327 |
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture){
|
|
|
328 |
mUM = uploadMsg;
|
|
|
329 |
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
|
|
330 |
i.addCategory(Intent.CATEGORY_OPENABLE);
|
|
|
331 |
i.setType("*/*");
|
|
|
332 |
getActivity().startActivityForResult(Intent.createChooser(i, "File Chooser"), DealsHomeFragment.FCR);
|
|
|
333 |
}
|
|
|
334 |
//For Android 5.0+
|
|
|
335 |
public boolean onShowFileChooser(
|
|
|
336 |
WebView webView, ValueCallback<Uri[]> filePathCallback,
|
|
|
337 |
WebChromeClient.FileChooserParams fileChooserParams){
|
|
|
338 |
if(mUMA != null){
|
|
|
339 |
mUMA.onReceiveValue(null);
|
|
|
340 |
}
|
|
|
341 |
mUMA = filePathCallback;
|
| 23184 |
rajender |
342 |
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE );
|
| 22130 |
rajender |
343 |
if(takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null){
|
|
|
344 |
try{
|
|
|
345 |
photoFile = createImageFile();
|
|
|
346 |
takePictureIntent.putExtra("PhotoPath", mCM);
|
|
|
347 |
}catch(IOException ex){
|
|
|
348 |
Log.e(TAG, "Image file creation failed", ex);
|
|
|
349 |
}
|
|
|
350 |
if(photoFile != null){
|
|
|
351 |
mCM = "file:" + photoFile.getAbsolutePath();
|
| 23184 |
rajender |
352 |
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
|
| 22130 |
rajender |
353 |
}else{
|
|
|
354 |
takePictureIntent = null;
|
|
|
355 |
}
|
|
|
356 |
}
|
|
|
357 |
Intent contentSelectionIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
|
|
358 |
contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
|
359 |
String [] mimeTypes = {"image/*", "application/pdf"};
|
|
|
360 |
contentSelectionIntent.setType("*/*");
|
|
|
361 |
contentSelectionIntent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
|
|
|
362 |
// contentSelectionIntent.setType("image/*");
|
|
|
363 |
Intent[] intentArray;
|
|
|
364 |
if(takePictureIntent != null){
|
|
|
365 |
intentArray = new Intent[]{takePictureIntent};
|
|
|
366 |
}else{
|
|
|
367 |
intentArray = new Intent[0];
|
|
|
368 |
}
|
|
|
369 |
|
|
|
370 |
Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
|
|
|
371 |
chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
|
|
|
372 |
chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser");
|
|
|
373 |
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
|
|
|
374 |
startActivityForResult(chooserIntent, FCR);
|
|
|
375 |
return true;
|
|
|
376 |
}
|
|
|
377 |
});
|
| 21480 |
rajender |
378 |
webView.getSettings().setSavePassword(true);
|
|
|
379 |
CookieManager cookieManager = CookieManager.getInstance();
|
|
|
380 |
cookieManager.setAcceptCookie(true);
|
|
|
381 |
|
|
|
382 |
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
|
383 |
webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
|
|
384 |
webView.getSettings().setAllowContentAccess(true);
|
|
|
385 |
CookieManager cookieManager1 = CookieManager.getInstance();
|
|
|
386 |
cookieManager1.setAcceptThirdPartyCookies(webView, true);
|
|
|
387 |
}
|
| 22830 |
rajender |
388 |
if (Uri.parse(getArguments().getString("key")).getHost().contains("app.profitmandi")) {
|
| 21480 |
rajender |
389 |
userDataEditor.putString("saholic.data", UtilityFunctions.clearCookiesNew(getArguments().getString("key"), getActivity())).commit();
|
|
|
390 |
}
|
|
|
391 |
String url = getArguments().getString("key");
|
|
|
392 |
if (Uri.parse(url).getHost().equalsIgnoreCase(ProfitTillConstants.DOMAIN)) {
|
|
|
393 |
CookieSyncManager.createInstance(getActivity());
|
|
|
394 |
CookieManager cookieManager1 = CookieManager.getInstance();
|
|
|
395 |
cookieManager1.setCookie(url, "token=" + userData.getString("token", ""));
|
|
|
396 |
cookieManager1.setCookie(url, "walletAuthentication=true");
|
|
|
397 |
cookieManager1.setCookie(url, "shopcluesActive=true");
|
|
|
398 |
cookieManager1.setCookie(url, "paytmActive=true");
|
|
|
399 |
cookieManager1.setCookie(url, "shareApps=true");
|
|
|
400 |
cookieManager1.setCookie(url, "homeshop18=true");
|
|
|
401 |
cookieManager1.setCookie(url, "isRedirect=true");
|
|
|
402 |
}
|
|
|
403 |
if (!(userData.getBoolean("paytmLoggedIn", false))) {
|
|
|
404 |
Log.d("User Not Logged In", "User Not logged In");
|
|
|
405 |
} else {
|
|
|
406 |
if (userData.getString("paytmOrder", "").equalsIgnoreCase("true")) {
|
|
|
407 |
long nextFetchTime = userData.getLong("paytmNextFetchTime", 0);
|
|
|
408 |
if (nextFetchTime == 0 || nextFetchTime < System.currentTimeMillis()) {
|
|
|
409 |
if (isInternetOn()) {
|
|
|
410 |
new PaytmOrderURL().execute();
|
|
|
411 |
}
|
|
|
412 |
} else {
|
|
|
413 |
Log.d("Paytm False", "Paytm Time False");
|
|
|
414 |
}
|
|
|
415 |
} else {
|
|
|
416 |
Log.d("Paytm False", "Paytm False No orders");
|
|
|
417 |
}
|
|
|
418 |
}
|
|
|
419 |
if (!(userData.getBoolean("amazonLoggedIn", false))) {
|
|
|
420 |
Log.d("Not In Amazon", "Amazon");
|
|
|
421 |
}
|
|
|
422 |
else {
|
|
|
423 |
if (userData.getString("amazonOrder", "").equalsIgnoreCase("true")) {
|
|
|
424 |
long nextFetchTime = userData.getLong("amazonNextFetchTime", 0);
|
|
|
425 |
if (nextFetchTime == 0 || nextFetchTime < System.currentTimeMillis()) {
|
|
|
426 |
if (isInternetOn()) {
|
|
|
427 |
new FetchOrderURLS().execute();
|
|
|
428 |
}
|
|
|
429 |
}
|
|
|
430 |
else {
|
|
|
431 |
Log.d("Amazon False", "Amazon Time False" + userData.getLong("amazonNextFetchTime", 0));
|
|
|
432 |
}
|
|
|
433 |
} else {
|
|
|
434 |
Log.d("Amazon False", "Amazon False No orders");
|
|
|
435 |
}
|
|
|
436 |
}
|
| 22130 |
rajender |
437 |
// Map <String, String> extraHeaders = new HashMap<String, String>();
|
|
|
438 |
// extraHeaders.put("Auth-Token",userData.getString("token",""));
|
| 21480 |
rajender |
439 |
webView.setWebViewClient(webViewClient);
|
| 22130 |
rajender |
440 |
webView.loadUrl(url);
|
| 21480 |
rajender |
441 |
|
|
|
442 |
}
|
| 22130 |
rajender |
443 |
|
| 21480 |
rajender |
444 |
else {
|
|
|
445 |
SearchFragment nextFrag = new SearchFragment();
|
|
|
446 |
Bundle args = new Bundle();
|
|
|
447 |
args.putString("finishingurl", getArguments().getString("key"));
|
|
|
448 |
args.putString("fragmentNumber", "1");
|
|
|
449 |
nextFrag.setArguments(args);
|
|
|
450 |
getActivity().getFragmentManager().beginTransaction()
|
|
|
451 |
.replace(R.id.frame_container, nextFrag)
|
|
|
452 |
.addToBackStack(null)
|
|
|
453 |
.commit();
|
|
|
454 |
}
|
|
|
455 |
return rootView;
|
|
|
456 |
}
|
| 22830 |
rajender |
457 |
|
|
|
458 |
|
| 21480 |
rajender |
459 |
@Override
|
|
|
460 |
public void onViewCreated(View view, Bundle savedInstanceState) {
|
|
|
461 |
super.onViewCreated(view, savedInstanceState);
|
|
|
462 |
}
|
|
|
463 |
|
| 22130 |
rajender |
464 |
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
|
|
|
465 |
@Override
|
|
|
466 |
public void onReceive(Context context, Intent intent) {
|
|
|
467 |
final Bundle bundle = intent.getExtras();
|
|
|
468 |
|
|
|
469 |
try {
|
|
|
470 |
if (bundle != null) {
|
|
|
471 |
final Object[] pdusObj = (Object[]) bundle.get("pdus");
|
|
|
472 |
for (int i = 0; i < pdusObj.length; i++) {
|
|
|
473 |
|
|
|
474 |
SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) pdusObj[i]);
|
|
|
475 |
String phoneNumber = currentMessage.getDisplayOriginatingAddress();
|
|
|
476 |
|
|
|
477 |
String senderNum = phoneNumber;
|
|
|
478 |
String message = currentMessage.getDisplayMessageBody();
|
|
|
479 |
|
|
|
480 |
String lastTwo = null;
|
|
|
481 |
if (senderNum != null && senderNum.length() >= 6) {
|
|
|
482 |
lastTwo = senderNum.substring(senderNum.length() - 6);
|
|
|
483 |
}
|
|
|
484 |
try {
|
|
|
485 |
if (lastTwo.equalsIgnoreCase(apiData.getString("Sender_CLI","PROFTM"))){
|
|
|
486 |
messageNameValuePair = new ArrayList<>();
|
|
|
487 |
messageNameValuePair.add(new BasicNameValuePair("message",message));
|
|
|
488 |
getActivity().unregisterReceiver(broadcastReceiver);
|
|
|
489 |
new SendOtpMessage().execute();
|
|
|
490 |
}
|
|
|
491 |
else{
|
|
|
492 |
getActivity().registerReceiver(broadcastReceiver, new IntentFilter(SMS_RECEIVED));
|
|
|
493 |
}}
|
|
|
494 |
catch(Exception e){
|
|
|
495 |
e.printStackTrace();
|
|
|
496 |
}
|
|
|
497 |
}
|
|
|
498 |
}
|
|
|
499 |
|
|
|
500 |
}
|
|
|
501 |
catch (Exception e) {
|
|
|
502 |
e.printStackTrace();
|
|
|
503 |
|
|
|
504 |
}
|
|
|
505 |
}
|
|
|
506 |
};
|
|
|
507 |
|
| 21480 |
rajender |
508 |
JSONObject obj;
|
|
|
509 |
|
|
|
510 |
@Override
|
|
|
511 |
public void onConnected(Bundle bundle) {
|
|
|
512 |
|
|
|
513 |
}
|
|
|
514 |
|
|
|
515 |
@Override
|
|
|
516 |
public void onConnectionSuspended(int i) {
|
|
|
517 |
|
|
|
518 |
}
|
|
|
519 |
|
|
|
520 |
@Override
|
|
|
521 |
public void onConnectionFailed(ConnectionResult connectionResult) {
|
|
|
522 |
|
|
|
523 |
}
|
|
|
524 |
|
| 22130 |
rajender |
525 |
|
|
|
526 |
|
| 21480 |
rajender |
527 |
public class WebClientClass extends WebViewClient {
|
|
|
528 |
ProgressDialog pd = null;
|
|
|
529 |
|
|
|
530 |
ProgressDialog pd2 = null;
|
|
|
531 |
|
|
|
532 |
|
|
|
533 |
@Override
|
|
|
534 |
public void onReceivedHttpAuthRequest(WebView view,
|
|
|
535 |
HttpAuthHandler handler, String host, String realm) {
|
|
|
536 |
|
|
|
537 |
handler.proceed("dtr", "dtr18Feb2015");
|
|
|
538 |
}
|
|
|
539 |
|
|
|
540 |
@Override
|
|
|
541 |
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
|
|
542 |
|
|
|
543 |
if (apiData.getString("snapdealException", "false").equalsIgnoreCase("true")) {
|
|
|
544 |
List<String> snapdealExceptionUrls = new ArrayList<>();
|
|
|
545 |
StringTokenizer st = new StringTokenizer(apiData.getString("snapdeal.exception.urls", ""), "|");
|
|
|
546 |
while (st.hasMoreTokens()) {
|
|
|
547 |
snapdealExceptionUrls.add(st.nextToken());
|
|
|
548 |
}
|
|
|
549 |
try {
|
|
|
550 |
Log.d("Count", "Count " + apiData.getString("snapdeal.exception.count", "1"));
|
|
|
551 |
for (String s : snapdealExceptionUrls) {
|
|
|
552 |
if (url.contains(s)) {
|
|
|
553 |
if (snapdealException <= Integer.parseInt(apiData.getString("snapdeal.exception.count", "1"))) {
|
|
|
554 |
webView.reload();
|
|
|
555 |
snapdealException += 1;
|
|
|
556 |
}
|
|
|
557 |
return false;
|
|
|
558 |
}
|
|
|
559 |
}
|
|
|
560 |
} catch (Exception e) {
|
|
|
561 |
e.printStackTrace();
|
|
|
562 |
}
|
|
|
563 |
}
|
|
|
564 |
if (apiData.getString("isRedirect", "false").equalsIgnoreCase("true")) {
|
|
|
565 |
List<String> browserRedirectUrl = new ArrayList<>();
|
|
|
566 |
StringTokenizer st = new StringTokenizer(apiData.getString("redirect.urls", ""), "|");
|
|
|
567 |
while (st.hasMoreTokens()) {
|
|
|
568 |
browserRedirectUrl.add(st.nextToken());
|
|
|
569 |
}
|
|
|
570 |
for (String s : browserRedirectUrl) {
|
|
|
571 |
if (url.contains(s)) {
|
|
|
572 |
isPause = true;
|
|
|
573 |
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
|
|
574 |
startActivity(intent);
|
|
|
575 |
return true;
|
|
|
576 |
}
|
|
|
577 |
}
|
|
|
578 |
}
|
|
|
579 |
if (url.contains("apprub")) {
|
|
|
580 |
onShareClick(url);
|
|
|
581 |
return true;
|
|
|
582 |
}
|
| 22130 |
rajender |
583 |
if (url.contains(apiData.getString("wallet.auth", "api.profittill.com/special/native/login")) /*|| userData.getString("id", "").isEmpty()*/) {
|
| 21480 |
rajender |
584 |
android.webkit.CookieManager cookieManager = android.webkit.CookieManager.getInstance();
|
|
|
585 |
android.webkit.CookieSyncManager.createInstance(getActivity());
|
|
|
586 |
cookieManager.removeAllCookie();
|
|
|
587 |
AlertDialog alert;
|
|
|
588 |
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
|
|
589 |
builder.setMessage(apiData.getString("wallet.auth.message", "You are not authenticated. Please log in again")).setCancelable(false);
|
|
|
590 |
alert = builder.create();
|
|
|
591 |
alert.show();
|
|
|
592 |
try {
|
|
|
593 |
if (mGoogleApiClient.isConnected()) {
|
|
|
594 |
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
|
|
|
595 |
mGoogleApiClient.disconnect();
|
|
|
596 |
mGoogleApiClient.connect();
|
|
|
597 |
redirectPage(alert);
|
|
|
598 |
} else {
|
|
|
599 |
if (!mGoogleApiClient.isConnected()) {
|
|
|
600 |
redirectPage(alert);
|
|
|
601 |
}
|
|
|
602 |
}
|
|
|
603 |
} catch (Exception e) {
|
|
|
604 |
redirectPage(alert);
|
|
|
605 |
}
|
|
|
606 |
return true;
|
|
|
607 |
}
|
|
|
608 |
if (url.contains("com.saholic.profittill")) {
|
|
|
609 |
Intent intent = null;
|
|
|
610 |
try {
|
|
|
611 |
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getActivity().getPackageName()));
|
|
|
612 |
} catch (android.content.ActivityNotFoundException anfe) {
|
|
|
613 |
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + getActivity().getPackageName()));
|
|
|
614 |
}
|
|
|
615 |
startActivity(intent);
|
|
|
616 |
return true;
|
|
|
617 |
}
|
|
|
618 |
if (snapdealPageLoad == 1) {
|
|
|
619 |
pd2 = new ProgressDialog(getActivity());
|
|
|
620 |
pd2.setMessage("Wait for a moment and click again.");
|
|
|
621 |
pd2.setProgress(view.getProgress());
|
|
|
622 |
pd2.show();
|
|
|
623 |
return true;
|
|
|
624 |
}
|
|
|
625 |
if (url.startsWith("tel")) {
|
|
|
626 |
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
|
|
627 |
startActivity(intent);
|
|
|
628 |
return true;
|
|
|
629 |
}
|
| 22830 |
rajender |
630 |
|
|
|
631 |
/* if (url.contains("intent://send")) {
|
|
|
632 |
Intent intent = null;
|
|
|
633 |
try {
|
|
|
634 |
intent = new Intent().parseUri(url, Intent.URI_INTENT_SCHEME);
|
|
|
635 |
} catch (URISyntaxException e) {
|
|
|
636 |
e.printStackTrace();
|
|
|
637 |
}
|
|
|
638 |
startActivity(intent);
|
| 21480 |
rajender |
639 |
return true;
|
| 22830 |
rajender |
640 |
}*/
|
|
|
641 |
|
|
|
642 |
if (url.contains("mailto")) {
|
|
|
643 |
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
|
|
644 |
startActivity(intent);
|
| 21480 |
rajender |
645 |
return true;
|
|
|
646 |
}
|
| 22830 |
rajender |
647 |
|
|
|
648 |
|
| 21480 |
rajender |
649 |
return false;
|
|
|
650 |
|
|
|
651 |
}
|
|
|
652 |
|
| 22381 |
rajender |
653 |
|
| 21480 |
rajender |
654 |
@Override
|
|
|
655 |
public synchronized void onPageStarted(final WebView view, String url, Bitmap favicon) {
|
|
|
656 |
super.onPageStarted(view, url, favicon);
|
|
|
657 |
final CharSequence[] items = {" Don't show me again "};
|
|
|
658 |
final ArrayList seletedItems = new ArrayList();
|
|
|
659 |
try {
|
| 22130 |
rajender |
660 |
|
| 21480 |
rajender |
661 |
if (Uri.parse(url).getHost().equalsIgnoreCase(ProfitTillConstants.DOMAIN)) {
|
|
|
662 |
CookieSyncManager.createInstance(getActivity());
|
|
|
663 |
CookieManager cookieManager = CookieManager.getInstance();
|
|
|
664 |
cookieManager.setCookie(url, "token=" + userData.getString("token", ""));
|
|
|
665 |
cookieManager.setCookie(url, "walletAuthentication=true");
|
|
|
666 |
cookieManager.setCookie(url, "shopcluesActive=true");
|
|
|
667 |
cookieManager.setCookie(url, "paytmActive=true");
|
|
|
668 |
cookieManager.setCookie(url, "shareApps=true");
|
|
|
669 |
cookieManager.setCookie(url, "homeshop18=true");
|
|
|
670 |
cookieManager.setCookie(url, "isRedirect=true");
|
|
|
671 |
}
|
|
|
672 |
if (false) {
|
|
|
673 |
flipkartUrl = url;
|
|
|
674 |
|
|
|
675 |
if (flipkartData.getInt("showagainflag", 0) < 3) {
|
|
|
676 |
AlertDialog dialog;
|
|
|
677 |
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
|
|
678 |
builder.setMessage(apiData.getString("flipkart.message", "You won't be able to track your orders & earn cashbacks if you purchase using Flipkart App."))
|
|
|
679 |
.setView(checkBoxView)
|
|
|
680 |
.setCancelable(false)
|
|
|
681 |
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
|
|
682 |
@Override
|
|
|
683 |
public void onClick(DialogInterface dialog, int which) {
|
|
|
684 |
int i = flipkartData.getInt("showagainflag", 0);
|
|
|
685 |
flipkartDataEditor.putInt("showagainflag", ++i);
|
|
|
686 |
flipkartDataEditor.commit();
|
|
|
687 |
Intent flipkartIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(flipkartUrl));
|
|
|
688 |
startActivity(flipkartIntent);
|
|
|
689 |
}
|
|
|
690 |
})
|
|
|
691 |
.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
|
|
692 |
@Override
|
|
|
693 |
public void onClick(DialogInterface dialog, int id) {
|
| 22830 |
rajender |
694 |
view.loadUrl((apiData.getString("domain","http://app.profitmandi.com")));
|
| 21480 |
rajender |
695 |
|
|
|
696 |
}
|
|
|
697 |
});
|
|
|
698 |
dialog = builder.create();
|
|
|
699 |
dialog.show();
|
|
|
700 |
} else if (flipkartData.getInt("showagainflag", 0) == 3) {
|
|
|
701 |
AlertDialog dialog;
|
|
|
702 |
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
|
|
703 |
checkBoxView = View.inflate(getActivity(), R.layout.checkboxlayout, null);
|
|
|
704 |
CheckBox checkBox = (CheckBox) checkBoxView.findViewById(R.id.checkbox);
|
|
|
705 |
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
706 |
|
|
|
707 |
@Override
|
|
|
708 |
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
709 |
flipkartFlag = isChecked;
|
|
|
710 |
}
|
|
|
711 |
});
|
|
|
712 |
checkBox.setText("Don't show me again");
|
|
|
713 |
builder.setMessage(apiData.getString("flipkart.message", "You won't be able to track your orders & earn cashbacks if you purchase using Flipkart App."))
|
|
|
714 |
.setView(checkBoxView)
|
|
|
715 |
.setCancelable(false)
|
|
|
716 |
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
|
|
717 |
@Override
|
|
|
718 |
public void onClick(DialogInterface dialog, int which) {
|
|
|
719 |
if (flipkartFlag) {
|
|
|
720 |
int i = flipkartData.getInt("showagainflag", 0);
|
|
|
721 |
flipkartDataEditor.putInt("showagainflag", ++i);
|
|
|
722 |
flipkartDataEditor.commit();
|
|
|
723 |
}
|
|
|
724 |
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(flipkartUrl));
|
|
|
725 |
startActivity(i);
|
|
|
726 |
}
|
|
|
727 |
})
|
|
|
728 |
.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
|
|
729 |
@Override
|
|
|
730 |
public void onClick(DialogInterface dialog, int id) {
|
| 22830 |
rajender |
731 |
view.loadUrl((apiData.getString("domain","http://app.profitmandi.com")));
|
| 21480 |
rajender |
732 |
|
|
|
733 |
}
|
|
|
734 |
});
|
|
|
735 |
dialog = builder.create();
|
|
|
736 |
dialog.show();
|
|
|
737 |
} else {
|
|
|
738 |
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(flipkartUrl));
|
|
|
739 |
startActivity(i);
|
|
|
740 |
}
|
|
|
741 |
view.stopLoading();
|
|
|
742 |
} else {
|
|
|
743 |
for (String s : pageLoadList) {
|
|
|
744 |
if (url.contains(s)) {
|
|
|
745 |
PAGE_LOAD = true;
|
|
|
746 |
}
|
|
|
747 |
}
|
|
|
748 |
if (PAGE_LOAD) {
|
|
|
749 |
snapdealPageLoad = 1;
|
|
|
750 |
PAGE_LOAD = false;
|
|
|
751 |
} else {
|
|
|
752 |
snapdealPageLoad = 0;
|
|
|
753 |
for (String s : redirectUrlsList) {
|
|
|
754 |
if (url.contains(s)) {
|
|
|
755 |
REDIRECT = true;
|
|
|
756 |
break;
|
|
|
757 |
}
|
|
|
758 |
}
|
|
|
759 |
if (REDIRECT) {
|
|
|
760 |
pageRedirect = 2;
|
|
|
761 |
REDIRECT = false;
|
|
|
762 |
}
|
|
|
763 |
else if (pageRedirect == 2 || pageRedirect == 1) {
|
|
|
764 |
Toast.makeText(getActivity(), "Redirecting to deals...", Toast.LENGTH_SHORT).show();
|
|
|
765 |
Intent i = new Intent(getActivity(), MainActivity.class);
|
|
|
766 |
i.putExtra("displayView", "31");
|
|
|
767 |
i.putExtra("redirectUrl", apiData.getString("redirect.url", "") + "?user_id=" + userData.getString("id", ""));
|
|
|
768 |
startActivity(i);
|
|
|
769 |
pageRedirect = 0;
|
|
|
770 |
}
|
|
|
771 |
else {
|
|
|
772 |
landingURL = url;
|
| 22381 |
rajender |
773 |
/* if (url.contains(apiData.getString("mobile.website.url"," ")) || url.equalsIgnoreCase("http://api.profittill.com/categorydeals") || url.contains(apiData.getString("notification.page.url", "http://api.profittill.com/users/usernotification"))) {
|
| 21480 |
rajender |
774 |
pd = new ProgressDialog(getActivity());
|
|
|
775 |
pd.setTitle("Please wait");
|
|
|
776 |
pd.setMessage("Loading..");
|
|
|
777 |
pd.show();
|
| 22381 |
rajender |
778 |
}*/
|
| 21480 |
rajender |
779 |
getOrderSuccessUrlConfirmation(url);
|
|
|
780 |
if (displayActionBar) {
|
|
|
781 |
pd1 = new ProgressDialog(getActivity());
|
|
|
782 |
pd1.setTitle("Please wait");
|
|
|
783 |
pd1.setMessage("Loading..");
|
|
|
784 |
pd1.show();
|
|
|
785 |
}
|
|
|
786 |
}
|
|
|
787 |
}
|
|
|
788 |
if (Uri.parse(url).getHost().contains("saholic") && userData.getString("saholic.data", "false").equalsIgnoreCase("true")) {
|
|
|
789 |
|
|
|
790 |
}
|
|
|
791 |
else {
|
|
|
792 |
JSONObject j = new JSONObject();
|
|
|
793 |
JSONArray jsArray = new JSONArray();
|
|
|
794 |
j.put("url", url);
|
|
|
795 |
j.put("user_id", userData.getString("id", null));
|
|
|
796 |
j.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
797 |
jsArray.put(j);
|
|
|
798 |
AsyncTaskCompat.executeParallel(new pushData(), new JSONObject().put("pushdata", jsArray));
|
|
|
799 |
|
|
|
800 |
}
|
|
|
801 |
storeSubTagId(url);
|
|
|
802 |
}
|
|
|
803 |
}
|
|
|
804 |
catch (Exception e) {
|
|
|
805 |
e.printStackTrace();
|
|
|
806 |
}
|
|
|
807 |
}
|
|
|
808 |
|
|
|
809 |
@Override
|
|
|
810 |
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
|
| 22830 |
rajender |
811 |
try{
|
| 21480 |
rajender |
812 |
if (getActivity() != null) {
|
|
|
813 |
SearchFragment nextFrag = new SearchFragment();
|
|
|
814 |
Bundle args = new Bundle();
|
|
|
815 |
args.putString("finishingurl", failingUrl);
|
|
|
816 |
nextFrag.setArguments(args);
|
| 22130 |
rajender |
817 |
getActivity().getFragmentManager().beginTransaction().replace(R.id.frame_container,nextFrag).addToBackStack(null).commitAllowingStateLoss();
|
|
|
818 |
|
| 22830 |
rajender |
819 |
}}
|
|
|
820 |
catch (Exception e){
|
|
|
821 |
e.printStackTrace();
|
| 21480 |
rajender |
822 |
}
|
| 22830 |
rajender |
823 |
|
|
|
824 |
super.onReceivedError(view, errorCode, description, failingUrl);
|
| 21480 |
rajender |
825 |
}
|
| 22830 |
rajender |
826 |
|
|
|
827 |
|
| 21480 |
rajender |
828 |
@Override
|
|
|
829 |
public synchronized void onPageFinished(WebView view, String url) {
|
|
|
830 |
super.onPageFinished(view, url);
|
| 22381 |
rajender |
831 |
|
| 22830 |
rajender |
832 |
if(url.contains(apiData.getString("Web_Uri","http://app.profitmandi.com/entry-point"))){
|
| 22381 |
rajender |
833 |
|
|
|
834 |
|
| 22130 |
rajender |
835 |
// if(url.contains(ProfitTillConstants.Web_Uri)){
|
| 22830 |
rajender |
836 |
StringBuffer commandsBuffer = new StringBuffer("javascript:");
|
|
|
837 |
commandsBuffer.append("document.getElementById('authToken').value ='" +userData.getString("token","")+ "';");
|
|
|
838 |
commandsBuffer.append("document.getElementById('androidId').value ='" +UtilityFunctions.androidId(getActivity()) + "';");
|
|
|
839 |
String js1 =commandsBuffer.toString();
|
| 22130 |
rajender |
840 |
if(Build.VERSION.SDK_INT >= 19){
|
|
|
841 |
view.evaluateJavascript(js1, new ValueCallback<String>() {
|
|
|
842 |
@Override
|
|
|
843 |
public void onReceiveValue(String s) {
|
|
|
844 |
}
|
|
|
845 |
});
|
|
|
846 |
}
|
|
|
847 |
else {
|
|
|
848 |
view.loadUrl(js1);
|
|
|
849 |
}
|
| 22830 |
rajender |
850 |
|
|
|
851 |
|
| 22130 |
rajender |
852 |
String js2 =("javascript:document.getElementById('authTokenSubmit').click()");
|
|
|
853 |
view.loadUrl(js2);
|
|
|
854 |
String js = ("javascript:window.localStorage.removeItem('android.otpReceived');");
|
|
|
855 |
Log.d("storage",js);
|
| 21480 |
rajender |
856 |
view.loadUrl(js);
|
|
|
857 |
}
|
| 22130 |
rajender |
858 |
|
| 22830 |
rajender |
859 |
if(url.contains(apiData.getString("domain","http://app.profitmandi.com "))|| url.contains("about:blank")){
|
| 22130 |
rajender |
860 |
// ((AppCompatActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
861 |
((AppCompatActivity)getActivity()).getSupportActionBar().hide();
|
|
|
862 |
}
|
|
|
863 |
else{
|
|
|
864 |
((AppCompatActivity)getActivity()).getSupportActionBar().show();
|
|
|
865 |
}
|
| 22381 |
rajender |
866 |
|
|
|
867 |
view.loadUrl("javascript:try{" +
|
|
|
868 |
"var lastUrl=document.URL;" +
|
|
|
869 |
"setInterval(function(){var currentUrl=document.URL;" +
|
|
|
870 |
"if(currentUrl!=lastUrl){window.HTMLOUT.angularUrls(currentUrl);lastUrl=currentUrl;}},2000)" +
|
|
|
871 |
"}catch(error){Android.onError(error.message);}");
|
|
|
872 |
|
| 21480 |
rajender |
873 |
try {
|
|
|
874 |
if (url.equalsIgnoreCase("about:blank")) {
|
|
|
875 |
Log.d("Blankl Url", "Blank Url");
|
|
|
876 |
}
|
|
|
877 |
else {
|
|
|
878 |
if (getActivity() != null) {
|
|
|
879 |
if (url.contains(apiData.getString("notification.page.url", "http://api.profittill.com/users/usernotification"))) {
|
|
|
880 |
String notificationUrl = apiData.getString("notification.count", "http://45.33.50.227:3001/getNotificationCount") + "?user_id=" + userData.getString("id", "") + "&android_id=" + UtilityFunctions.androidId(getActivity());
|
|
|
881 |
new NotificationCount().getCount(getActivity(), null, notificationUrl);
|
|
|
882 |
new Handler().postDelayed(new Runnable() {
|
|
|
883 |
@Override
|
|
|
884 |
public void run() {
|
|
|
885 |
getActivity().invalidateOptionsMenu();
|
|
|
886 |
}
|
|
|
887 |
}, 1000);
|
|
|
888 |
}
|
|
|
889 |
}
|
|
|
890 |
if (apiData.getString("snapdealException", "true").equalsIgnoreCase("true")) {
|
|
|
891 |
List<String> snapdealExceptionUrlsPass = new ArrayList<>();
|
|
|
892 |
StringTokenizer st = new StringTokenizer(apiData.getString("snapdeal.exception.urls.pass", ""), "|");
|
|
|
893 |
while (st.hasMoreTokens()) {
|
|
|
894 |
snapdealExceptionUrlsPass.add(st.nextToken());
|
|
|
895 |
}
|
|
|
896 |
for (String s : snapdealExceptionUrlsPass) {
|
|
|
897 |
if (url.contains(s)) {
|
|
|
898 |
snapdealException = 0;
|
|
|
899 |
}
|
|
|
900 |
}
|
|
|
901 |
}
|
| 22381 |
rajender |
902 |
/* if (url.contains(apiData.getString("mobile.website.url",""))|| url.equalsIgnoreCase("http://api.profittill.com/categorydeals") || url.contains(apiData.getString("notification.page.url", "http://api.profittill.com/users/usernotification"))) {
|
| 21480 |
rajender |
903 |
pd.dismiss();
|
| 22381 |
rajender |
904 |
}*/
|
| 21480 |
rajender |
905 |
if (snapdealPageLoad == 1) {
|
|
|
906 |
snapdealPageLoad = 0;
|
|
|
907 |
}
|
|
|
908 |
if (pd2 != null) {
|
|
|
909 |
pd2.dismiss();
|
|
|
910 |
}
|
|
|
911 |
if (Uri.parse(url).getHost().equalsIgnoreCase("paytm.com")) {
|
|
|
912 |
view.loadUrl("javascript:try{" +
|
|
|
913 |
"var lastUrl=document.URL;" +
|
|
|
914 |
"setInterval(function(){var currentUrl=document.URL;" +
|
|
|
915 |
"if(currentUrl!=lastUrl){window.HTMLOUT.paytmUrls(currentUrl);lastUrl=currentUrl;}},2000)" +
|
|
|
916 |
"}catch(error){Android.onError(error.message);}");
|
|
|
917 |
}
|
|
|
918 |
if (Uri.parse(url).getHost().contains("saholic") && userData.getString("saholic.data", "false").equalsIgnoreCase("true")) {
|
|
|
919 |
saholicUrl = url;
|
|
|
920 |
view.loadUrl("javascript:window.HTMLOUT.saholicHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
|
|
921 |
}
|
|
|
922 |
if (url.contains(apiData.getString("amazon.tracking.order.url", ""))) {
|
|
|
923 |
fetchOrderDetails();
|
|
|
924 |
}
|
|
|
925 |
if (displayActionBar) {
|
|
|
926 |
if (url.contains("amazon")) {
|
|
|
927 |
view.loadUrl("javascript:window.HTMLOUT.showHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
|
|
928 |
pd1.dismiss();
|
|
|
929 |
amazonWebView = new WebView(webView.getContext());
|
|
|
930 |
amazonWebView.setVisibility(View.GONE);
|
|
|
931 |
amazonWebView.addJavascriptInterface(new amazonInterface(getActivity()), "HTMLOUT");
|
|
|
932 |
amazonWebView.getSettings().setJavaScriptEnabled(true);
|
|
|
933 |
|
|
|
934 |
} else if (url.contains(ProfitTillConstants.PAYTM)) {
|
|
|
935 |
PaytmWebViewClient paytmWebViewClient = new PaytmWebViewClient();
|
|
|
936 |
pd1.dismiss();
|
|
|
937 |
paytmWebView = new WebView(webView.getContext());
|
|
|
938 |
paytmWebView.setVisibility(View.GONE);
|
|
|
939 |
paytmWebView.addJavascriptInterface(new paytmInterface(getActivity()), "HTMLOUT");
|
|
|
940 |
paytmWebView.getSettings().setJavaScriptEnabled(true);
|
|
|
941 |
paytmWebView.loadUrl(getPaytmReferer(url));
|
|
|
942 |
paytmWebView.setWebViewClient(paytmWebViewClient);
|
|
|
943 |
} else {
|
|
|
944 |
view.loadUrl("javascript:window.HTMLOUT.flipkartHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
|
|
945 |
|
|
|
946 |
}
|
|
|
947 |
}
|
|
|
948 |
|
|
|
949 |
amazonOrderHistoryWebView = new WebView(webView.getContext());
|
|
|
950 |
amazonOrderHistoryWebView.setVisibility(View.GONE);
|
|
|
951 |
amazonOrderHistoryWebView.getSettings().setUserAgentString("Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36");
|
|
|
952 |
amazonOrderHistoryWebView.getSettings().setJavaScriptEnabled(true);
|
|
|
953 |
amazonOrderHistoryWebView.addJavascriptInterface(new amazonInterface(getActivity()), "HTMLOUT");
|
|
|
954 |
|
|
|
955 |
amazonOrderHistoryCancelledWebView = new WebView(webView.getContext());
|
|
|
956 |
amazonOrderHistoryCancelledWebView.setVisibility(View.GONE);
|
|
|
957 |
amazonOrderHistoryCancelledWebView.getSettings().setJavaScriptEnabled(true);
|
|
|
958 |
amazonOrderHistoryCancelledWebView.getSettings().setUserAgentString("Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36");
|
|
|
959 |
amazonOrderHistoryCancelledWebView.addJavascriptInterface(new amazonInterface(getActivity()), "HTMLOUT");
|
|
|
960 |
|
|
|
961 |
amazonAllUrlsWebView = new WebView(webView.getContext());
|
|
|
962 |
amazonAllUrlsWebView.setVisibility(View.GONE);
|
|
|
963 |
amazonAllUrlsWebView.getSettings().setUserAgentString("Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36");
|
|
|
964 |
amazonAllUrlsWebView.getSettings().setJavaScriptEnabled(true);
|
|
|
965 |
amazonAllUrlsWebView.addJavascriptInterface(new amazonInterface(getActivity()), "HTMLOUT");
|
|
|
966 |
|
|
|
967 |
if (url.contains("https://www.amazon.in/ap/signin")) {
|
|
|
968 |
if (!FLAG) {
|
|
|
969 |
FLAG = true;
|
|
|
970 |
userDataEditor.putString("amazonOrder", "true").commit();
|
|
|
971 |
userDataEditor.putBoolean("amazonLoggedIn", true).commit();
|
|
|
972 |
}
|
| 22830 |
rajender |
973 |
}
|
|
|
974 |
else if (FLAG) {
|
| 21480 |
rajender |
975 |
view.loadUrl("javascript:try{" +
|
|
|
976 |
"var lastUrl=document.URL;" +
|
|
|
977 |
"setInterval(function(){var currentUrl=document.URL;" +
|
|
|
978 |
"if(currentUrl!=lastUrl){window.HTMLOUT.amazonUrls(currentUrl);lastUrl=currentUrl;}},2000)" +
|
|
|
979 |
"}catch(error){Android.onError(error.message);}");
|
|
|
980 |
amazonOrderHistoryWebView = new WebView(webView.getContext());
|
|
|
981 |
amazonOrderHistoryWebView.setVisibility(View.GONE);
|
|
|
982 |
amazonOrderHistoryWebView.getSettings().setUserAgentString("Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36");
|
|
|
983 |
amazonOrderHistoryWebView.getSettings().setJavaScriptEnabled(true);
|
|
|
984 |
amazonOrderHistoryWebView.addJavascriptInterface(new amazonInterface(getActivity()), "HTMLOUT");
|
|
|
985 |
amazonOrderHistoryCancelledWebView = new WebView(webView.getContext());
|
|
|
986 |
amazonOrderHistoryCancelledWebView.setVisibility(View.GONE);
|
|
|
987 |
amazonOrderHistoryCancelledWebView.getSettings().setJavaScriptEnabled(true);
|
|
|
988 |
amazonOrderHistoryCancelledWebView.getSettings().setUserAgentString("Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36");
|
|
|
989 |
amazonOrderHistoryCancelledWebView.addJavascriptInterface(new amazonInterface(getActivity()), "HTMLOUT");
|
|
|
990 |
fetchOrderDetails();
|
|
|
991 |
FLAG = false;
|
|
|
992 |
}
|
|
|
993 |
|
|
|
994 |
if (url.contains("flipkart")) {
|
|
|
995 |
if (Flipkartflag) {
|
|
|
996 |
if (!url.contains("https://www.flipkart.com/login")) {
|
|
|
997 |
processFlipkartHtml();
|
|
|
998 |
Flipkartflag = false;
|
|
|
999 |
}
|
|
|
1000 |
}
|
|
|
1001 |
else if(url.contains("https://www.flipkart.com/rv/orderConfirmation")){
|
|
|
1002 |
processFlipkartHtml();
|
|
|
1003 |
}
|
|
|
1004 |
else {
|
|
|
1005 |
view.loadUrl("javascript:try{" +
|
|
|
1006 |
"var lastUrl=document.URL;" +
|
|
|
1007 |
"setInterval(function(){var currentUrl=document.URL;" +
|
|
|
1008 |
"if(currentUrl!=lastUrl){window.HTMLOUT.flipkartUrls(currentUrl);lastUrl=currentUrl;}},2000)" +
|
|
|
1009 |
"}catch(error){Android.onError(error.message);}");
|
|
|
1010 |
}
|
|
|
1011 |
|
|
|
1012 |
}
|
|
|
1013 |
|
|
|
1014 |
|
|
|
1015 |
view.setOnKeyListener(new View.OnKeyListener() {
|
|
|
1016 |
@Override
|
| 22381 |
rajender |
1017 |
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
|
|
1018 |
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
|
|
1019 |
WebView webView = (WebView) v;
|
|
|
1020 |
switch (keyCode) {
|
|
|
1021 |
case KeyEvent.KEYCODE_BACK:
|
|
|
1022 |
String veb=webView.getUrl();
|
| 22830 |
rajender |
1023 |
if ((webView.canGoBack() && !webView.getUrl().contains(apiData.getString("dashboard","http://app.profitmandi.com/pages/home/dashboard")) && !webView.getUrl().contains(apiData.getString("mobileOtp","http://app.profitmandi.com/pages/mobileOtp"))&& !webView.getUrl().contains(apiData.getString("registration","http://app.profitmandi.com/pages/registration")) && !webView.getUrl().contains(apiData.getString("checkRegistration","http://app.profitmandi.com/pages/checkRegistration"))&&!webView.getUrl().contains(apiData.getString("thankYou","http://app.profitmandi.com/pages/home/thankYou")))|| pageRedirect == 2) {
|
| 22381 |
rajender |
1024 |
webView.goBack();
|
|
|
1025 |
pageRedirect = 0;
|
|
|
1026 |
snapdealPageLoad = 0;
|
|
|
1027 |
return true;
|
|
|
1028 |
} else if (affliateUrl.contains("flipkart") || affliateUrl.contains("amazon") || affliateUrl.contains("snapdeal") || affliateUrl.contains("saholic") || affliateUrl.contains(apiData.getString("myorders.url", "")) || affliateUrl.contains(apiData.getString("search.url", ""))) {
|
|
|
1029 |
Intent i = new Intent(getActivity(), MainActivity.class);
|
|
|
1030 |
i.putExtra("displayView", "0");
|
|
|
1031 |
startActivity(i);
|
|
|
1032 |
return true;
|
|
|
1033 |
}
|
| 22830 |
rajender |
1034 |
else if (webView.getUrl().contains(apiData.getString("domain","http://app.profitmandi.com"))) {
|
| 22381 |
rajender |
1035 |
//else if(webView.getUrl().contains(ProfitTillConstants.Web_Uri)){
|
|
|
1036 |
if (doubleBackToExitPressedOnce) {
|
|
|
1037 |
new AlertDialog.Builder(getActivity())
|
|
|
1038 |
.setIcon(R.drawable.symbol)
|
|
|
1039 |
.setTitle("Exit!")
|
|
|
1040 |
.setMessage("Are you sure you want to close?")
|
|
|
1041 |
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
|
|
1042 |
@Override
|
|
|
1043 |
public void onClick(DialogInterface dialog, int which) {
|
|
|
1044 |
if(userData.getString("userStatus","").equals("notRegistered")||userData.getString("userStatus","").equals("registered")||userData.getString("userStatus","").equals("notVerifiedRetailer"))
|
|
|
1045 |
{
|
|
|
1046 |
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
|
|
|
1047 |
mGoogleApiClient.disconnect();
|
|
|
1048 |
userDataEditor.clear().commit();
|
|
|
1049 |
mGoogleApiClient.connect();
|
|
|
1050 |
userDataEditor.clear().commit();
|
|
|
1051 |
startActivity(new Intent(getActivity(), LoginActivity.class));
|
|
|
1052 |
|
| 22130 |
rajender |
1053 |
}
|
| 22381 |
rajender |
1054 |
else{
|
|
|
1055 |
Intent startMain = new Intent(Intent.ACTION_MAIN);
|
|
|
1056 |
startMain.addCategory(Intent.CATEGORY_HOME);
|
|
|
1057 |
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
1058 |
startActivity(startMain);
|
|
|
1059 |
}
|
|
|
1060 |
}
|
| 21480 |
rajender |
1061 |
|
| 22381 |
rajender |
1062 |
})
|
|
|
1063 |
.setNegativeButton("No", null)
|
|
|
1064 |
.show();
|
|
|
1065 |
return true;
|
|
|
1066 |
}
|
|
|
1067 |
doubleBackToExitPressedOnce = true;
|
|
|
1068 |
Toast.makeText(getActivity(), "Please click BACK again to exit", Toast.LENGTH_SHORT).show();
|
| 21480 |
rajender |
1069 |
|
| 22381 |
rajender |
1070 |
new Handler().postDelayed(new Runnable() {
|
| 22130 |
rajender |
1071 |
|
| 22381 |
rajender |
1072 |
@Override
|
|
|
1073 |
public void run() {
|
|
|
1074 |
doubleBackToExitPressedOnce = false;
|
| 21480 |
rajender |
1075 |
}
|
| 22381 |
rajender |
1076 |
}, 5000);
|
| 22830 |
rajender |
1077 |
}
|
|
|
1078 |
else {
|
| 22381 |
rajender |
1079 |
Intent i = new Intent(getActivity(), MainActivity.class);
|
|
|
1080 |
i.putExtra("displayView", "0");
|
|
|
1081 |
startActivity(i);
|
|
|
1082 |
return true;
|
| 21480 |
rajender |
1083 |
}
|
| 22381 |
rajender |
1084 |
|
|
|
1085 |
break;
|
| 21480 |
rajender |
1086 |
}
|
|
|
1087 |
}
|
| 22381 |
rajender |
1088 |
return false;
|
|
|
1089 |
}
|
|
|
1090 |
});
|
|
|
1091 |
}
|
| 22830 |
rajender |
1092 |
}
|
|
|
1093 |
catch (Exception e) {
|
| 22381 |
rajender |
1094 |
e.printStackTrace();
|
|
|
1095 |
TestinAgent.uploadException(getActivity(), "On Page Finished", e);
|
| 22830 |
rajender |
1096 |
}
|
|
|
1097 |
}}
|
|
|
1098 |
|
|
|
1099 |
public class Callback extends WebViewClient{
|
| 22130 |
rajender |
1100 |
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl){
|
|
|
1101 |
Toast.makeText(getActivity(), "Failed loading app!", Toast.LENGTH_SHORT).show();
|
| 21480 |
rajender |
1102 |
}
|
| 22830 |
rajender |
1103 |
}
|
| 22130 |
rajender |
1104 |
// Create an image file
|
| 22830 |
rajender |
1105 |
private File createImageFile() throws IOException{
|
| 22130 |
rajender |
1106 |
@SuppressLint("SimpleDateFormat") String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
|
|
|
1107 |
String imageFileName = "img_"+timeStamp+"_";
|
| 23184 |
rajender |
1108 |
storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
|
| 22130 |
rajender |
1109 |
return File.createTempFile(imageFileName,".jpg",storageDir);
|
| 22830 |
rajender |
1110 |
}
|
| 21480 |
rajender |
1111 |
|
| 22130 |
rajender |
1112 |
|
| 22830 |
rajender |
1113 |
|
|
|
1114 |
|
| 22130 |
rajender |
1115 |
@Override
|
| 23184 |
rajender |
1116 |
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
| 22130 |
rajender |
1117 |
super.onActivityResult(requestCode, resultCode, intent);
|
| 23184 |
rajender |
1118 |
|
|
|
1119 |
if(Build.VERSION.SDK_INT >= 21) {
|
| 22130 |
rajender |
1120 |
//Check if response is positive
|
| 23184 |
rajender |
1121 |
if(resultCode == Activity.RESULT_OK) {
|
|
|
1122 |
if(requestCode == FCR) {
|
|
|
1123 |
if(null == mUMA) {
|
| 22130 |
rajender |
1124 |
return;
|
|
|
1125 |
}
|
| 23184 |
rajender |
1126 |
if (intent == null) {
|
| 22130 |
rajender |
1127 |
//Capture Photo if no image available
|
| 23184 |
rajender |
1128 |
if (mCM != null) {
|
|
|
1129 |
new ImageCompression().execute(photoFile.getPath());
|
| 22130 |
rajender |
1130 |
}
|
| 23184 |
rajender |
1131 |
} else {
|
|
|
1132 |
|
|
|
1133 |
Uri dataString = intent.getData();
|
|
|
1134 |
String newPath=getRealPathFromURI_API19(getActivity(), dataString);
|
|
|
1135 |
|
|
|
1136 |
new ImageCompression().execute(newPath);
|
| 22130 |
rajender |
1137 |
}
|
|
|
1138 |
}
|
|
|
1139 |
}
|
| 23184 |
rajender |
1140 |
} else {
|
|
|
1141 |
if (requestCode == FCR) {
|
|
|
1142 |
if (null == mUM) return;
|
| 22130 |
rajender |
1143 |
Uri result = intent == null || resultCode != Activity.RESULT_OK ? null : intent.getData();
|
|
|
1144 |
mUM.onReceiveValue(result);
|
|
|
1145 |
mUM = null;
|
|
|
1146 |
}
|
|
|
1147 |
}
|
| 23184 |
rajender |
1148 |
if (resultCode != Activity.RESULT_OK) {
|
|
|
1149 |
mUMA.onReceiveValue(null);
|
|
|
1150 |
mUMA =null;
|
|
|
1151 |
}
|
|
|
1152 |
|
| 21480 |
rajender |
1153 |
}
|
|
|
1154 |
|
| 23184 |
rajender |
1155 |
@TargetApi(Build.VERSION_CODES.KITKAT)
|
|
|
1156 |
public static String getRealPathFromURI_API19(Context context, Uri uri){
|
|
|
1157 |
String filePath = "";
|
|
|
1158 |
String wholeID = null;
|
|
|
1159 |
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
|
|
|
1160 |
wholeID = DocumentsContract.getDocumentId(uri);
|
|
|
1161 |
}
|
|
|
1162 |
|
|
|
1163 |
// Split at colon, use second item in the array
|
|
|
1164 |
String id = wholeID.split(":")[1];
|
|
|
1165 |
|
|
|
1166 |
String[] column = { MediaStore.Images.Media.DATA };
|
|
|
1167 |
|
|
|
1168 |
// where id is equal to
|
|
|
1169 |
String sel = MediaStore.Images.Media._ID + "=?";
|
|
|
1170 |
|
|
|
1171 |
Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
|
|
1172 |
column, sel, new String[]{ id }, null);
|
|
|
1173 |
|
|
|
1174 |
int columnIndex = cursor.getColumnIndex(column[0]);
|
|
|
1175 |
|
|
|
1176 |
if (cursor.moveToFirst()) {
|
|
|
1177 |
filePath = cursor.getString(columnIndex);
|
|
|
1178 |
}
|
|
|
1179 |
cursor.close();
|
|
|
1180 |
return filePath;
|
|
|
1181 |
}
|
|
|
1182 |
|
|
|
1183 |
|
|
|
1184 |
public class ImageCompression extends AsyncTask<String, Void, Void> {
|
|
|
1185 |
|
|
|
1186 |
private static final float maxHeight = 800.0f;
|
|
|
1187 |
private static final float maxWidth = 800.0f;
|
|
|
1188 |
private File imageFile = null;
|
|
|
1189 |
private Context context;
|
|
|
1190 |
Uri[] results = null;
|
|
|
1191 |
|
|
|
1192 |
@Override
|
|
|
1193 |
protected void onPreExecute() {
|
|
|
1194 |
super.onPreExecute();
|
|
|
1195 |
|
|
|
1196 |
//making progress dialog visible
|
|
|
1197 |
//showProgressBar();
|
|
|
1198 |
}
|
|
|
1199 |
|
|
|
1200 |
@Override
|
|
|
1201 |
protected Void doInBackground(String... strings) {
|
|
|
1202 |
try {
|
|
|
1203 |
if (strings.length == 0 || strings[0] == null)
|
|
|
1204 |
return null;
|
|
|
1205 |
//obtaining image array after the required image is compressed
|
|
|
1206 |
imageFile = compressImage(strings[0]);
|
|
|
1207 |
} catch (Exception e) {
|
|
|
1208 |
// CrashLogs.crashLogger(e);
|
|
|
1209 |
}
|
|
|
1210 |
return null;
|
|
|
1211 |
}
|
|
|
1212 |
|
|
|
1213 |
@Override
|
|
|
1214 |
protected void onPostExecute(Void aVoid) {
|
|
|
1215 |
super.onPostExecute(aVoid);
|
|
|
1216 |
try {
|
|
|
1217 |
//sending data to server using multipart request
|
|
|
1218 |
//sendMultiPartRequest(imageArray);
|
|
|
1219 |
|
|
|
1220 |
if(imageFile !=null){
|
|
|
1221 |
|
|
|
1222 |
results = new Uri[]{Uri.fromFile(imageFile)};
|
|
|
1223 |
mUMA.onReceiveValue(results);
|
|
|
1224 |
mUMA = null;
|
|
|
1225 |
}
|
|
|
1226 |
|
|
|
1227 |
} catch (Exception e) {
|
|
|
1228 |
//CrashLogs.crashLogger(e);
|
|
|
1229 |
}
|
|
|
1230 |
}
|
|
|
1231 |
|
|
|
1232 |
//process to compress image to send it to the server
|
|
|
1233 |
public File compressImage(String imagePath) {
|
|
|
1234 |
Bitmap scaledBitmap = null;
|
|
|
1235 |
|
|
|
1236 |
BitmapFactory.Options options = new BitmapFactory.Options();
|
|
|
1237 |
options.inJustDecodeBounds = true;
|
|
|
1238 |
Bitmap bmp = BitmapFactory.decodeFile(imagePath, options);
|
|
|
1239 |
|
|
|
1240 |
int actualHeight = options.outHeight;
|
|
|
1241 |
int actualWidth = options.outWidth;
|
|
|
1242 |
|
|
|
1243 |
float imgRatio = (float) actualWidth / (float) actualHeight;
|
|
|
1244 |
float maxRatio = maxWidth / maxHeight;
|
|
|
1245 |
|
|
|
1246 |
if (actualHeight > maxHeight || actualWidth > maxWidth) {
|
|
|
1247 |
if (imgRatio < maxRatio) {
|
|
|
1248 |
imgRatio = maxHeight / actualHeight;
|
|
|
1249 |
actualWidth = (int) (imgRatio * actualWidth);
|
|
|
1250 |
actualHeight = (int) maxHeight;
|
|
|
1251 |
} else if (imgRatio > maxRatio) {
|
|
|
1252 |
imgRatio = maxWidth / actualWidth;
|
|
|
1253 |
actualHeight = (int) (imgRatio * actualHeight);
|
|
|
1254 |
actualWidth = (int) maxWidth;
|
|
|
1255 |
} else {
|
|
|
1256 |
actualHeight = (int) maxHeight;
|
|
|
1257 |
actualWidth = (int) maxWidth;
|
|
|
1258 |
}
|
|
|
1259 |
}
|
|
|
1260 |
|
|
|
1261 |
options.inSampleSize = calculateInSampleSize(options, actualWidth, actualHeight);
|
|
|
1262 |
options.inJustDecodeBounds = false;
|
|
|
1263 |
options.inDither = false;
|
|
|
1264 |
options.inPurgeable = true;
|
|
|
1265 |
options.inInputShareable = true;
|
|
|
1266 |
options.inTempStorage = new byte[16 * 1024];
|
|
|
1267 |
|
|
|
1268 |
try {
|
|
|
1269 |
bmp = BitmapFactory.decodeFile(imagePath, options);
|
|
|
1270 |
} catch (OutOfMemoryError exception) {
|
|
|
1271 |
// CrashLogs.crashLogger(exception);
|
|
|
1272 |
|
|
|
1273 |
}
|
|
|
1274 |
try {
|
|
|
1275 |
scaledBitmap = Bitmap.createBitmap(actualWidth, actualHeight, Bitmap.Config.RGB_565);
|
|
|
1276 |
} catch (OutOfMemoryError exception) {
|
|
|
1277 |
// CrashLogs.crashLogger(exception);
|
|
|
1278 |
}
|
|
|
1279 |
|
|
|
1280 |
float ratioX = actualWidth / (float) options.outWidth;
|
|
|
1281 |
float ratioY = actualHeight / (float) options.outHeight;
|
|
|
1282 |
float middleX = actualWidth / 2.0f;
|
|
|
1283 |
float middleY = actualHeight / 2.0f;
|
|
|
1284 |
|
|
|
1285 |
Matrix scaleMatrix = new Matrix();
|
|
|
1286 |
scaleMatrix.setScale(ratioX, ratioY, middleX, middleY);
|
|
|
1287 |
|
|
|
1288 |
Canvas canvas = new Canvas(scaledBitmap);
|
|
|
1289 |
canvas.setMatrix(scaleMatrix);
|
|
|
1290 |
canvas.drawBitmap(bmp, middleX - bmp.getWidth() / 2, middleY - bmp.getHeight() / 2, new Paint(Paint.FILTER_BITMAP_FLAG));
|
|
|
1291 |
|
|
|
1292 |
if (bmp != null) {
|
|
|
1293 |
bmp.recycle();
|
|
|
1294 |
}
|
|
|
1295 |
|
|
|
1296 |
ExifInterface exif;
|
|
|
1297 |
try {
|
|
|
1298 |
exif = new ExifInterface(imagePath);
|
|
|
1299 |
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0);
|
|
|
1300 |
Matrix matrix = new Matrix();
|
|
|
1301 |
if (orientation == 6) {
|
|
|
1302 |
matrix.postRotate(90);
|
|
|
1303 |
} else if (orientation == 3) {
|
|
|
1304 |
matrix.postRotate(180);
|
|
|
1305 |
} else if (orientation == 8) {
|
|
|
1306 |
matrix.postRotate(270);
|
|
|
1307 |
}
|
|
|
1308 |
scaledBitmap = Bitmap.createBitmap(scaledBitmap, 0, 0, scaledBitmap.getWidth(), scaledBitmap.getHeight(), matrix, true);
|
|
|
1309 |
} catch (IOException e) {
|
|
|
1310 |
// CrashLogs.crashLogger(e);
|
|
|
1311 |
}
|
|
|
1312 |
File outputFile = null;
|
|
|
1313 |
try {
|
|
|
1314 |
|
|
|
1315 |
|
|
|
1316 |
outputFile = getOutputMediaFile(temp);
|
|
|
1317 |
|
|
|
1318 |
try {
|
|
|
1319 |
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
|
|
|
1320 |
scaledBitmap.compress(Bitmap.CompressFormat.JPEG, 80, fileOutputStream);
|
|
|
1321 |
fileOutputStream.flush();
|
|
|
1322 |
fileOutputStream.close();
|
|
|
1323 |
} catch (Exception e) {
|
|
|
1324 |
// CrashLogs.crashLogger(e);
|
|
|
1325 |
}
|
|
|
1326 |
} catch (Exception e) {
|
|
|
1327 |
// CrashLogs.crashLogger(e);
|
|
|
1328 |
}
|
|
|
1329 |
/*try {
|
|
|
1330 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
1331 |
scaledBitmap.compress(Bitmap.CompressFormat.JPEG, 80, byteArrayOutputStream);
|
|
|
1332 |
return byteArrayOutputStream.toByteArray();
|
|
|
1333 |
} catch (Exception e) {
|
|
|
1334 |
// CrashLogs.crashLogger(e);
|
|
|
1335 |
}*/
|
|
|
1336 |
return outputFile;
|
|
|
1337 |
}
|
|
|
1338 |
|
|
|
1339 |
/*
|
|
|
1340 |
* method to calculate inSample size(used while compressing the image).
|
|
|
1341 |
* */
|
|
|
1342 |
public int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
|
|
|
1343 |
int inSampleSize = 1;
|
|
|
1344 |
try {
|
|
|
1345 |
final int height = options.outHeight;
|
|
|
1346 |
final int width = options.outWidth;
|
|
|
1347 |
|
|
|
1348 |
|
|
|
1349 |
if (height > reqHeight || width > reqWidth) {
|
|
|
1350 |
final int heightRatio = Math.round((float) height / (float) reqHeight);
|
|
|
1351 |
final int widthRatio = Math.round((float) width / (float) reqWidth);
|
|
|
1352 |
inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
|
|
|
1353 |
}
|
|
|
1354 |
final float totalPixels = width * height;
|
|
|
1355 |
final float totalReqPixelsCap = reqWidth * reqHeight * 2;
|
|
|
1356 |
|
|
|
1357 |
while (totalPixels / (inSampleSize * inSampleSize) > totalReqPixelsCap) {
|
|
|
1358 |
inSampleSize++;
|
|
|
1359 |
}
|
|
|
1360 |
|
|
|
1361 |
return inSampleSize;
|
|
|
1362 |
} catch (Exception e) {
|
|
|
1363 |
|
|
|
1364 |
// CrashLogs.crashLogger(e);
|
|
|
1365 |
return inSampleSize;
|
|
|
1366 |
}
|
|
|
1367 |
}
|
|
|
1368 |
}
|
|
|
1369 |
|
|
|
1370 |
public static final String IMAGE_DIRECTORY_NAME = "ProfitMandi";
|
|
|
1371 |
|
|
|
1372 |
public File getOutputMediaFile(String name) {
|
|
|
1373 |
// External sdcard location
|
|
|
1374 |
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
|
|
|
1375 |
File mediaStorageDir = new File(
|
|
|
1376 |
Environment
|
|
|
1377 |
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
|
|
|
1378 |
IMAGE_DIRECTORY_NAME);
|
|
|
1379 |
// Create the storage directory if it does not exist
|
|
|
1380 |
if (!mediaStorageDir.exists()) {
|
|
|
1381 |
if (!mediaStorageDir.mkdirs()) {
|
|
|
1382 |
return null;
|
|
|
1383 |
}
|
|
|
1384 |
}
|
|
|
1385 |
File mediaFile;
|
|
|
1386 |
mediaFile = new File(mediaStorageDir.getPath() + File.separator
|
|
|
1387 |
+ name +timeStamp+ ".jpg");
|
|
|
1388 |
return mediaFile;
|
|
|
1389 |
}
|
|
|
1390 |
|
|
|
1391 |
|
| 21480 |
rajender |
1392 |
private void processFlipkartHtml() {
|
|
|
1393 |
FlipkartWebview fkView = new FlipkartWebview();
|
|
|
1394 |
amazonOrderHistoryWebView = new WebView(webView.getContext());
|
|
|
1395 |
amazonOrderHistoryWebView.setVisibility(View.GONE);
|
|
|
1396 |
String post=apiData.getString("flipkart.response.url","https://www.flipkart.com/rv/accounts");
|
|
|
1397 |
amazonOrderHistoryWebView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.23 Mobile Safari/537.36");
|
|
|
1398 |
amazonOrderHistoryWebView.getSettings().setJavaScriptEnabled(true);
|
|
|
1399 |
amazonOrderHistoryWebView.addJavascriptInterface(new javascriptInterface(webView), "HTMLOUT");
|
|
|
1400 |
amazonOrderHistoryWebView.loadUrl(apiData.getString("flipkart.response.url","https://www.flipkart.com/rv/accounts"));
|
|
|
1401 |
amazonOrderHistoryWebView.setWebViewClient(fkView);
|
|
|
1402 |
}
|
|
|
1403 |
class ProcessFlipkartHtml extends AsyncTask<String, Integer, String> {
|
|
|
1404 |
ProgressDialog pg1 = null;
|
|
|
1405 |
@Override
|
|
|
1406 |
protected void onPreExecute() {
|
|
|
1407 |
|
|
|
1408 |
super.onPreExecute();
|
|
|
1409 |
|
| 22830 |
rajender |
1410 |
|
| 21480 |
rajender |
1411 |
}
|
|
|
1412 |
@Override
|
|
|
1413 |
protected String doInBackground(String... arg0) {
|
|
|
1414 |
try {
|
|
|
1415 |
HttpClient httpclient = new DefaultHttpClient();
|
|
|
1416 |
HttpPost httppost = new HttpPost(apiData.getString("amazon.order.tracking.post.url", null) + "?user_id=" + userData.getString("id", "") + "&store_id=" + UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code", "")), "flipkart"));
|
|
|
1417 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
|
|
1418 |
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairsRawHtml));
|
|
|
1419 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
1420 |
HttpEntity entity = response.getEntity();
|
|
|
1421 |
int status = response.getStatusLine().getStatusCode();
|
|
|
1422 |
|
|
|
1423 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
|
|
1424 |
JSONObject jobj =jObjGmail.getJSONObject("result");
|
|
|
1425 |
JSONObject headers = jobj.getJSONObject("headers");
|
|
|
1426 |
JSONArray url =jobj.getJSONArray("urls");
|
|
|
1427 |
for (int i = 0; i <url.length(); i++) {
|
|
|
1428 |
HttpClient client = new DefaultHttpClient();
|
|
|
1429 |
HttpGet get = new HttpGet(url.getString(i));
|
|
|
1430 |
Map<String, String> map = new HashMap<String, String>();
|
|
|
1431 |
Iterator iter = headers.keys();
|
|
|
1432 |
while (iter.hasNext()) {
|
|
|
1433 |
String key = (String) iter.next();
|
|
|
1434 |
String value = headers.getString(key);
|
|
|
1435 |
get.setHeader(key, value);
|
|
|
1436 |
}
|
|
|
1437 |
HttpResponse resp = client.execute(get);
|
|
|
1438 |
HttpEntity ent = resp.getEntity();
|
|
|
1439 |
JSONObject jOb = new JSONObject(EntityUtils.toString(ent));
|
|
|
1440 |
|
|
|
1441 |
HttpClient http = new DefaultHttpClient();
|
|
|
1442 |
ArrayList<NameValuePair> namevaluepairs = new ArrayList<>();
|
|
|
1443 |
namevaluepairs.add(new BasicNameValuePair("html",UtilityFunctions.compress(jOb.toString())));
|
|
|
1444 |
namevaluepairs.add(new BasicNameValuePair("url", url.getString(i)));
|
|
|
1445 |
namevaluepairs.add(new BasicNameValuePair("zip","1"));
|
|
|
1446 |
HttpPost post = new HttpPost(apiData.getString("amazon.order.tracking.post.url", null) + "?user_id=" + userData.getString("id", "") + "&store_id=" + UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code", "")), "flipkart"));
|
|
|
1447 |
post.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
|
|
1448 |
post.setEntity(new UrlEncodedFormEntity(namevaluepairs));
|
|
|
1449 |
HttpResponse res = http.execute(post);
|
|
|
1450 |
int sta = res.getStatusLine().getStatusCode();
|
|
|
1451 |
}
|
|
|
1452 |
|
|
|
1453 |
}
|
|
|
1454 |
catch (Exception e) {
|
|
|
1455 |
e.printStackTrace();
|
|
|
1456 |
return null;
|
|
|
1457 |
}
|
|
|
1458 |
return null;
|
|
|
1459 |
}
|
|
|
1460 |
@Override
|
|
|
1461 |
protected void onPostExecute(String jsonObject) {
|
|
|
1462 |
super.onPostExecute(jsonObject);
|
|
|
1463 |
|
|
|
1464 |
|
|
|
1465 |
}}
|
|
|
1466 |
|
|
|
1467 |
@Override
|
| 22830 |
rajender |
1468 |
public void onDetach() {
|
|
|
1469 |
super.onDetach();
|
|
|
1470 |
if(webView != null) {
|
|
|
1471 |
webView.clearHistory();
|
|
|
1472 |
webView.removeAllViews();
|
|
|
1473 |
webView.clearView();
|
|
|
1474 |
webView.destroy();
|
|
|
1475 |
}
|
|
|
1476 |
|
|
|
1477 |
}
|
|
|
1478 |
|
|
|
1479 |
|
|
|
1480 |
@Override
|
| 21480 |
rajender |
1481 |
public void onResume() {
|
|
|
1482 |
super.onResume();
|
|
|
1483 |
getView().setFocusableInTouchMode(true);
|
|
|
1484 |
getView().requestFocus();
|
|
|
1485 |
getView().setOnKeyListener(new View.OnKeyListener() {
|
|
|
1486 |
@Override
|
|
|
1487 |
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
|
|
1488 |
|
|
|
1489 |
if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_BACK) {
|
| 22381 |
rajender |
1490 |
try {
|
|
|
1491 |
String veb=webView.getUrl();
|
| 22830 |
rajender |
1492 |
if (webView.getUrl().contains(apiData.getString("dashboard","http://app.profitmandi.com/pages/home/dashboard"))||webView.getUrl().contains(apiData.getString("mobileOtp","http://app.profitmandi.com/pages/mobileOtp"))||webView.getUrl().contains(apiData.getString("registration","http://app.profitmandi.com/pages/registration"))||webView.getUrl().contains(apiData.getString("checkRegistration","http://app.profitmandi.com/pages/checkRegistration"))||webView.getUrl().contains(apiData.getString("thankYou","http://app.profitmandi.com/pages/home/thankYou"))) {
|
| 22381 |
rajender |
1493 |
if (doubleBackToExitPressedOnce) {
|
|
|
1494 |
new AlertDialog.Builder(getActivity())
|
|
|
1495 |
.setIcon(R.drawable.symbol)
|
|
|
1496 |
.setTitle("Exit!")
|
|
|
1497 |
.setMessage("Are you sure you want to close?")
|
|
|
1498 |
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
|
|
1499 |
@Override
|
|
|
1500 |
public void onClick(DialogInterface dialog, int which) {
|
|
|
1501 |
if(userData.getString("userStatus","").equals("notRegistered")||userData.getString("userStatus","").equals("registered")||userData.getString("userStatus","").equals("notVerifiedRetailer"))
|
|
|
1502 |
{
|
|
|
1503 |
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
|
|
|
1504 |
mGoogleApiClient.disconnect();
|
|
|
1505 |
userDataEditor.clear().commit();
|
|
|
1506 |
mGoogleApiClient.connect();
|
|
|
1507 |
startActivity(new Intent(getActivity(), LoginActivity.class));
|
|
|
1508 |
}
|
| 22830 |
rajender |
1509 |
else{
|
| 22381 |
rajender |
1510 |
Intent startMain = new Intent(Intent.ACTION_MAIN);
|
|
|
1511 |
startMain.addCategory(Intent.CATEGORY_HOME);
|
|
|
1512 |
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
| 21480 |
rajender |
1513 |
|
| 22381 |
rajender |
1514 |
startActivity(startMain);
|
|
|
1515 |
}}
|
| 22130 |
rajender |
1516 |
|
| 22381 |
rajender |
1517 |
})
|
|
|
1518 |
.setNegativeButton("No", null)
|
|
|
1519 |
.show();
|
|
|
1520 |
return true;
|
|
|
1521 |
}
|
|
|
1522 |
doubleBackToExitPressedOnce = true;
|
|
|
1523 |
Toast.makeText(getActivity(), "Please click BACK again to exit", Toast.LENGTH_SHORT).show();
|
| 22130 |
rajender |
1524 |
|
| 22381 |
rajender |
1525 |
new Handler().postDelayed(new Runnable() {
|
| 22130 |
rajender |
1526 |
|
| 22381 |
rajender |
1527 |
@Override
|
|
|
1528 |
public void run() {
|
|
|
1529 |
doubleBackToExitPressedOnce = false;
|
| 21480 |
rajender |
1530 |
}
|
| 22381 |
rajender |
1531 |
}, 5000);
|
|
|
1532 |
}
|
|
|
1533 |
else {
|
|
|
1534 |
if (webView.canGoBack()) {
|
|
|
1535 |
webView.goBack();
|
|
|
1536 |
} else {
|
|
|
1537 |
Intent i = new Intent(getActivity(), MainActivity.class);
|
|
|
1538 |
i.putExtra("displayView", "0");
|
|
|
1539 |
startActivity(i);
|
|
|
1540 |
}
|
|
|
1541 |
return true;
|
|
|
1542 |
}}
|
|
|
1543 |
catch (Exception e) {
|
| 21480 |
rajender |
1544 |
e.printStackTrace();
|
|
|
1545 |
return false;
|
|
|
1546 |
}
|
|
|
1547 |
}
|
|
|
1548 |
return false;
|
|
|
1549 |
}
|
|
|
1550 |
|
|
|
1551 |
});
|
|
|
1552 |
|
| 22381 |
rajender |
1553 |
}
|
|
|
1554 |
|
|
|
1555 |
|
| 21480 |
rajender |
1556 |
public void fetchOrderDetails() {
|
|
|
1557 |
if (isInternetOn()) {
|
|
|
1558 |
new FetchOrderURLS().execute();
|
|
|
1559 |
}
|
|
|
1560 |
}
|
|
|
1561 |
|
|
|
1562 |
public void pushDataInAmazon(String orderId) {
|
|
|
1563 |
|
|
|
1564 |
AmazonOrderDetails amazonOrderClient = new AmazonOrderDetails();
|
|
|
1565 |
nameValuePairsRawHtmlAmazon = new ArrayList<NameValuePair>();
|
|
|
1566 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("user_id", userData.getString("id", null)));
|
|
|
1567 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("id", orderId));
|
|
|
1568 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("store_id", apiData.getString("store.code.amazon", null)));
|
|
|
1569 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("order_url", amazonData.getString("amazonurl", "")));
|
|
|
1570 |
//nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("sub_tag",userData.getString("subtag",null)));
|
|
|
1571 |
amazonWebView.loadUrl(amazonData.getString("amazonurl", ""));
|
|
|
1572 |
amazonWebView.setWebViewClient(amazonOrderClient);
|
|
|
1573 |
|
|
|
1574 |
}
|
|
|
1575 |
|
|
|
1576 |
public void storeSubTagId(String url) {
|
|
|
1577 |
|
|
|
1578 |
if (url.contains(apiData.getString("store.subtag.snapdeal", null)) || url.contains(apiData.getString("store.subtag.flipkart", null)) || url.contains(apiData.getString("store.subtag.amazon", null)) || url.contains(apiData.getString("store.subtag.shopclues", "UID")) || url.contains(apiData.getString("store.subtag.paytm", "utm_term"))) {
|
|
|
1579 |
StringTokenizer st2 = new StringTokenizer(url, "&");
|
|
|
1580 |
while (st2.hasMoreElements()) {
|
|
|
1581 |
String token = st2.nextToken();
|
|
|
1582 |
if (token.contains(apiData.getString("store.subtag.snapdeal", null)) || token.contains(apiData.getString("store.subtag.flipkart", null)) || token.contains(apiData.getString("store.subtag.amazon", null)) || token.contains(apiData.getString("store.subtag.shopclues", "UID")) || token.contains(apiData.getString("store.subtag.paytm", "utm_term"))) {
|
|
|
1583 |
String subtagId = userData.getString("subtag", "null");
|
|
|
1584 |
if (subtagId == null) {
|
|
|
1585 |
userDataEditor.putString("subtag", token.split("=")[1]);
|
|
|
1586 |
userDataEditor.commit();
|
|
|
1587 |
} else {
|
|
|
1588 |
userDataEditor.remove("subtag");
|
|
|
1589 |
userDataEditor.commit();
|
|
|
1590 |
userDataEditor.putString("subtag", token.split("=")[1]);
|
|
|
1591 |
userDataEditor.commit();
|
|
|
1592 |
}
|
|
|
1593 |
} else
|
|
|
1594 |
continue;
|
|
|
1595 |
}
|
|
|
1596 |
} else
|
|
|
1597 |
return;
|
|
|
1598 |
}
|
|
|
1599 |
|
|
|
1600 |
|
|
|
1601 |
boolean displayActionBar;
|
|
|
1602 |
|
|
|
1603 |
public void getDisplayActionBar(String url) throws Exception {
|
|
|
1604 |
String snapdealConfirmation = apiData.getString("snapdeal.order.success.url", null);
|
|
|
1605 |
String flipkartConfirmation = apiData.getString("flipkart.order.success.url", null);
|
|
|
1606 |
String amazonConfirmation = apiData.getString("amazon.order.success.url", null);
|
|
|
1607 |
String amazonThankYouConfirmation = apiData.getString("amazon.order.success.thankyou.url", null);
|
|
|
1608 |
String saholicConfirmation = apiData.getString("saholic.order.success.url", null);
|
|
|
1609 |
if (url.contains(snapdealConfirmation) || url.contains(flipkartConfirmation) || url.contains(amazonConfirmation) || url.contains(amazonThankYouConfirmation) || url.contains(saholicConfirmation)) {
|
|
|
1610 |
displayActionBar = true;
|
|
|
1611 |
String storeID = getStoreId(url);
|
|
|
1612 |
if (storeID == null) {
|
|
|
1613 |
Log.e("Deals Page Activity", "Null value returned for storeID");
|
|
|
1614 |
} else {
|
|
|
1615 |
nameValuePairsRawHtml = new ArrayList<NameValuePair>();
|
|
|
1616 |
nameValuePairsRawHtml.add(new BasicNameValuePair("user_id", userData.getString("id", null)));
|
|
|
1617 |
nameValuePairsRawHtml.add(new BasicNameValuePair("store_id", storeID));
|
|
|
1618 |
nameValuePairsRawHtml.add(new BasicNameValuePair("order_url", url));
|
|
|
1619 |
nameValuePairsRawHtml.add(new BasicNameValuePair("sub_tag", userData.getString("subtag", null)));
|
|
|
1620 |
}
|
|
|
1621 |
} else {
|
|
|
1622 |
displayActionBar = false;
|
|
|
1623 |
}
|
|
|
1624 |
return;
|
|
|
1625 |
}
|
|
|
1626 |
|
|
|
1627 |
public void getOrderSuccessUrlConfirmation(String url) throws Exception {
|
|
|
1628 |
for (String s : orderSuccessUrlList) {
|
|
|
1629 |
if (url.contains(s)) {
|
|
|
1630 |
displayActionBar = true;
|
|
|
1631 |
String storeID = getStoreId(url);
|
|
|
1632 |
if (storeID == null) {
|
|
|
1633 |
Log.e("Deals Page Activity", "Null value returned for storeID");
|
|
|
1634 |
} else {
|
|
|
1635 |
nameValuePairsRawHtml = new ArrayList<NameValuePair>();
|
|
|
1636 |
nameValuePairsRawHtml.add(new BasicNameValuePair("user_id", userData.getString("id", null)));
|
|
|
1637 |
nameValuePairsRawHtml.add(new BasicNameValuePair("store_id", storeID));
|
|
|
1638 |
nameValuePairsRawHtml.add(new BasicNameValuePair("order_url", url));
|
|
|
1639 |
nameValuePairsRawHtml.add(new BasicNameValuePair("sub_tag", userData.getString("subtag", "")));
|
|
|
1640 |
}
|
|
|
1641 |
break;
|
|
|
1642 |
} else {
|
|
|
1643 |
displayActionBar = false;
|
|
|
1644 |
}
|
|
|
1645 |
}
|
|
|
1646 |
return;
|
|
|
1647 |
}
|
|
|
1648 |
|
|
|
1649 |
public String getStoreId(String url) {
|
|
|
1650 |
/* if(url.contains("snapdeal")){
|
|
|
1651 |
pageRedirect=Integer.parseInt(apiData.getString("pageredirect.snapdeal","0"));
|
|
|
1652 |
return apiData.getString("store.code.snapdeal",null);
|
|
|
1653 |
}
|
|
|
1654 |
else if(url.contains("flipkart")){
|
|
|
1655 |
pageRedirect=Integer.parseInt(apiData.getString("pageredirect.flipkart","0"));
|
|
|
1656 |
return apiData.getString("store.code.flipkart",null);
|
|
|
1657 |
}
|
|
|
1658 |
else if(url.contains("amazon")){
|
|
|
1659 |
pageRedirect=Integer.parseInt(apiData.getString("pageredirect.amazon","0"));
|
|
|
1660 |
return apiData.getString("store.code.amazon",null);
|
|
|
1661 |
}
|
|
|
1662 |
else if(url.contains("saholic")){
|
|
|
1663 |
return apiData.getString("store.code.spice",null);
|
|
|
1664 |
}
|
|
|
1665 |
else if(url.contains("shopclues")){
|
|
|
1666 |
return "7";
|
|
|
1667 |
}*/
|
|
|
1668 |
return UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code", "amazon=1,flipkart=2,snapdeal=3,saholic=4,shopclues=5,")), url);
|
|
|
1669 |
}
|
|
|
1670 |
|
|
|
1671 |
class pushData extends AsyncTask<JSONObject, Integer, String> {
|
|
|
1672 |
|
|
|
1673 |
@Override
|
|
|
1674 |
protected void onPreExecute() {
|
|
|
1675 |
|
|
|
1676 |
super.onPreExecute();
|
|
|
1677 |
}
|
|
|
1678 |
|
|
|
1679 |
@Override
|
|
|
1680 |
protected String doInBackground(JSONObject... objs) {
|
|
|
1681 |
HttpClient httpclient = new DefaultHttpClient();
|
|
|
1682 |
try {
|
|
|
1683 |
ArrayList<NameValuePair> nameValuePairs = new ArrayList<>();
|
|
|
1684 |
nameValuePairs.add(new BasicNameValuePair("pushdata",objs[0].toString()));
|
|
|
1685 |
HttpPost httppost = new HttpPost(apiData.getString("url.push.api", null));
|
|
|
1686 |
httppost.setHeader("Authorization", BASIC_AUTH);
|
|
|
1687 |
|
|
|
1688 |
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
|
|
|
1689 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
1690 |
int status = response.getStatusLine().getStatusCode();
|
|
|
1691 |
|
|
|
1692 |
if (status == 200) {
|
|
|
1693 |
return "success";
|
|
|
1694 |
} else {
|
|
|
1695 |
return "failure";
|
|
|
1696 |
}
|
|
|
1697 |
|
|
|
1698 |
} catch (ClientProtocolException e) {
|
|
|
1699 |
return "failure";
|
|
|
1700 |
} catch (IOException e) {
|
|
|
1701 |
return "failure";
|
|
|
1702 |
}
|
|
|
1703 |
}
|
|
|
1704 |
|
|
|
1705 |
@Override
|
|
|
1706 |
protected void onPostExecute(String result) {
|
| 22381 |
rajender |
1707 |
|
| 21480 |
rajender |
1708 |
super.onPostExecute(result);
|
| 22381 |
rajender |
1709 |
|
| 21480 |
rajender |
1710 |
}
|
|
|
1711 |
}
|
|
|
1712 |
|
|
|
1713 |
ArrayList<NameValuePair> nameValuePairsRawHtml = new ArrayList<NameValuePair>();
|
|
|
1714 |
ArrayList<NameValuePair> nameValuePairsRawHtmlAmazon = new ArrayList<NameValuePair>();
|
|
|
1715 |
|
|
|
1716 |
class javascriptInterface {
|
|
|
1717 |
|
|
|
1718 |
WebView view;
|
|
|
1719 |
|
|
|
1720 |
|
|
|
1721 |
|
| 22130 |
rajender |
1722 |
|
| 21480 |
rajender |
1723 |
/**
|
|
|
1724 |
* Instantiate the interface and set the context
|
|
|
1725 |
*/
|
|
|
1726 |
public javascriptInterface(WebView c) {
|
|
|
1727 |
|
|
|
1728 |
this.view=c;
|
|
|
1729 |
}
|
| 22130 |
rajender |
1730 |
@JavascriptInterface
|
|
|
1731 |
public void otpSent() {
|
|
|
1732 |
//Toast.makeText(getActivity(),"successfull",Toast.LENGTH_LONG).show();
|
|
|
1733 |
getActivity().registerReceiver(broadcastReceiver, new IntentFilter(SMS_RECEIVED));
|
|
|
1734 |
}
|
|
|
1735 |
@JavascriptInterface
|
|
|
1736 |
public void performClick(String strl) {
|
|
|
1737 |
Toast.makeText(getActivity(), strl, Toast.LENGTH_SHORT).show();
|
|
|
1738 |
}
|
|
|
1739 |
@JavascriptInterface
|
|
|
1740 |
public void authTokenChange(String newToken) {
|
|
|
1741 |
userDataEditor.putString("token" ,newToken);
|
|
|
1742 |
Log.d("newtoken",newToken);
|
|
|
1743 |
userDataEditor.commit();
|
|
|
1744 |
new AuthTokenChange().execute();
|
|
|
1745 |
}
|
| 21480 |
rajender |
1746 |
|
| 22130 |
rajender |
1747 |
@JavascriptInterface
|
|
|
1748 |
public void logout() {
|
|
|
1749 |
try{
|
|
|
1750 |
if (mGoogleApiClient.isConnected()) {
|
|
|
1751 |
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
|
|
|
1752 |
mGoogleApiClient.disconnect();
|
|
|
1753 |
mGoogleApiClient.connect();
|
|
|
1754 |
userDataEditor.clear().commit();
|
|
|
1755 |
startActivity(new Intent(getActivity(), LoginActivity.class));
|
|
|
1756 |
}
|
|
|
1757 |
else{
|
|
|
1758 |
if(!mGoogleApiClient.isConnected()){
|
|
|
1759 |
userDataEditor.clear().commit();
|
|
|
1760 |
startActivity(new Intent(getActivity(), LoginActivity.class));
|
|
|
1761 |
}
|
| 21480 |
rajender |
1762 |
|
| 22130 |
rajender |
1763 |
|
|
|
1764 |
}
|
|
|
1765 |
}catch (Exception e){
|
|
|
1766 |
userDataEditor.clear().commit();
|
|
|
1767 |
startActivity(new Intent(getActivity(), LoginActivity.class));
|
| 21480 |
rajender |
1768 |
}
|
|
|
1769 |
}
|
|
|
1770 |
|
|
|
1771 |
@JavascriptInterface
|
|
|
1772 |
public void showToast(String toast) {
|
|
|
1773 |
nameValuePairsRawHtml.add(new BasicNameValuePair("rawhtml", UtilityFunctions.compress(toast)));
|
|
|
1774 |
long x = orderDetails.insertOrderDetails(nameValuePairsRawHtml);
|
|
|
1775 |
List<List<NameValuePair>> postDataNameValuePair = new ArrayList<List<NameValuePair>>();
|
|
|
1776 |
postDataNameValuePair = orderDetails.readData1();
|
|
|
1777 |
for (List<NameValuePair> orderDetail : postDataNameValuePair) {
|
|
|
1778 |
orderDetail.add(new BasicNameValuePair("zip", "1"));
|
|
|
1779 |
orderDetail.add(new BasicNameValuePair("wifi", UtilityFunctions.checkWifi(getActivity()) + ""));
|
|
|
1780 |
orderDetail.add(new BasicNameValuePair("imeinumber", UtilityFunctions.getImeiNumber(getActivity())));
|
|
|
1781 |
orderDetail.add(new BasicNameValuePair("appversion", UtilityFunctions.getAppVersion(getActivity())));
|
|
|
1782 |
PushRawHTML pm = new PushRawHTML();
|
|
|
1783 |
pm.execute(orderDetail);
|
|
|
1784 |
}
|
|
|
1785 |
}
|
|
|
1786 |
|
|
|
1787 |
@JavascriptInterface
|
|
|
1788 |
public void amazonOrderTrackingHTML(String html) {
|
|
|
1789 |
amazonOrderTrackingData.add(new BasicNameValuePair("rawhtml", UtilityFunctions.compress(html)));
|
|
|
1790 |
amazonOrderTrackingData.add(new BasicNameValuePair("zip", "1"));
|
|
|
1791 |
amazonOrderTrackingData.add(new BasicNameValuePair("wifi", UtilityFunctions.checkWifi(getActivity()) + ""));
|
|
|
1792 |
amazonOrderTrackingData.add(new BasicNameValuePair("imeinumber", UtilityFunctions.getImeiNumber(getActivity())));
|
|
|
1793 |
amazonOrderTrackingData.add(new BasicNameValuePair("appversion", UtilityFunctions.getAppVersion(getActivity())));
|
|
|
1794 |
new AmazonOrderTrackingDetails().execute(amazonOrderTrackingData);
|
|
|
1795 |
}
|
|
|
1796 |
|
|
|
1797 |
@JavascriptInterface
|
|
|
1798 |
public void showHTML(String html) {
|
|
|
1799 |
|
|
|
1800 |
showToast(html);
|
|
|
1801 |
}
|
|
|
1802 |
|
|
|
1803 |
@JavascriptInterface
|
|
|
1804 |
public void flipkartHTML(String html) {
|
|
|
1805 |
nameValuePairsRawHtml.add(new BasicNameValuePair("rawhtml", UtilityFunctions.compress(html)));
|
|
|
1806 |
long x = orderDetails.insertOrderDetails(nameValuePairsRawHtml);
|
|
|
1807 |
List<List<NameValuePair>> postDataNameValuePair = new ArrayList<List<NameValuePair>>();
|
|
|
1808 |
postDataNameValuePair = orderDetails.readData1();
|
|
|
1809 |
for (List<NameValuePair> orderDetail : postDataNameValuePair) {
|
|
|
1810 |
orderDetail.add(new BasicNameValuePair("zip", "1"));
|
|
|
1811 |
orderDetail.add(new BasicNameValuePair("wifi", UtilityFunctions.checkWifi(getActivity()) + ""));
|
|
|
1812 |
orderDetail.add(new BasicNameValuePair("imeinumber", UtilityFunctions.getImeiNumber(getActivity())));
|
|
|
1813 |
orderDetail.add(new BasicNameValuePair("appversion", UtilityFunctions.getAppVersion(getActivity())));
|
|
|
1814 |
new loadData().execute(orderDetail);
|
|
|
1815 |
}
|
|
|
1816 |
}
|
|
|
1817 |
|
|
|
1818 |
@JavascriptInterface
|
|
|
1819 |
public void orderpage(String html) {
|
|
|
1820 |
|
|
|
1821 |
nameValuePairsRawHtml.add(new BasicNameValuePair("html", UtilityFunctions.compress(html)));
|
| 22130 |
rajender |
1822 |
nameValuePairsRawHtml.add(new BasicNameValuePair("url",apiData.getString("flipkart.response.url","https://www.flipkart.com/rv/accounts")));
|
| 21480 |
rajender |
1823 |
nameValuePairsRawHtml.add(new BasicNameValuePair("zip","1"));
|
|
|
1824 |
new ProcessFlipkartHtml().execute();
|
|
|
1825 |
}
|
|
|
1826 |
|
|
|
1827 |
@JavascriptInterface
|
|
|
1828 |
public void saholicHTML(String html) {
|
|
|
1829 |
|
|
|
1830 |
try {
|
|
|
1831 |
obj = new JSONObject();
|
|
|
1832 |
jSaholic = new JSONObject();
|
|
|
1833 |
jSaholic.put("html", UtilityFunctions.compress(html));
|
|
|
1834 |
jSaholic.put("zip", "1");
|
|
|
1835 |
jSaholic.put("user_id", userData.getString("id", null));
|
|
|
1836 |
} catch (Exception e) {
|
|
|
1837 |
|
|
|
1838 |
}
|
|
|
1839 |
new checkGateWayProblem().execute(saholicUrl);
|
|
|
1840 |
}
|
|
|
1841 |
|
|
|
1842 |
@JavascriptInterface
|
|
|
1843 |
public void amazonUrls(String url) {
|
|
|
1844 |
try {
|
|
|
1845 |
obj = new JSONObject();
|
|
|
1846 |
JSONObject j = new JSONObject();
|
|
|
1847 |
JSONArray jsArray = new JSONArray();
|
|
|
1848 |
j.put("url", url);
|
|
|
1849 |
j.put("user_id", userData.getString("id", null));
|
|
|
1850 |
j.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
1851 |
jsArray.put(j);
|
|
|
1852 |
obj.put("pushdata", jsArray);
|
|
|
1853 |
new pushData().execute(obj);
|
|
|
1854 |
} catch (Exception e) {
|
|
|
1855 |
e.printStackTrace();
|
|
|
1856 |
}
|
|
|
1857 |
|
|
|
1858 |
try {
|
|
|
1859 |
getOrderSuccessUrlConfirmation(url);
|
|
|
1860 |
if (displayActionBar) {
|
|
|
1861 |
fetchAmazonOrder(url);
|
|
|
1862 |
}
|
|
|
1863 |
} catch (Exception e) {
|
|
|
1864 |
e.printStackTrace();
|
|
|
1865 |
}
|
|
|
1866 |
}
|
|
|
1867 |
|
|
|
1868 |
@JavascriptInterface
|
|
|
1869 |
public void paytmUrls(String html) {
|
|
|
1870 |
try {
|
|
|
1871 |
obj = new JSONObject();
|
|
|
1872 |
JSONObject j = new JSONObject();
|
|
|
1873 |
JSONArray jsArray = new JSONArray();
|
|
|
1874 |
j.put("url", html);
|
|
|
1875 |
j.put("user_id", userData.getString("id", null));
|
|
|
1876 |
j.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
1877 |
jsArray.put(j);
|
|
|
1878 |
obj.put("pushdata", jsArray);
|
| 22130 |
rajender |
1879 |
new pushData().execute(obj);
|
| 21480 |
rajender |
1880 |
} catch (Exception e) {
|
|
|
1881 |
e.printStackTrace();
|
|
|
1882 |
}
|
|
|
1883 |
if (html.contains("https://paytm.com/login")) {
|
|
|
1884 |
if (!PAYTMFLAG) {
|
|
|
1885 |
PAYTMFLAG = true;
|
|
|
1886 |
userDataEditor.putString("paytmOrder", "true").commit();
|
|
|
1887 |
userDataEditor.putBoolean("paytmLoggedIn", true).commit();
|
|
|
1888 |
}
|
|
|
1889 |
} else if (PAYTMFLAG) {
|
|
|
1890 |
new PaytmOrderURL().execute();
|
|
|
1891 |
PAYTMFLAG = false;
|
|
|
1892 |
}
|
|
|
1893 |
|
|
|
1894 |
}
|
|
|
1895 |
|
|
|
1896 |
@JavascriptInterface
|
|
|
1897 |
public void flipkartUrls(String url) {
|
|
|
1898 |
try {
|
|
|
1899 |
obj = new JSONObject();
|
|
|
1900 |
JSONObject j = new JSONObject();
|
|
|
1901 |
JSONArray jsArray = new JSONArray();
|
|
|
1902 |
j.put("url", url);
|
|
|
1903 |
j.put("user_id", userData.getString("id", null));
|
|
|
1904 |
j.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
1905 |
jsArray.put(j);
|
|
|
1906 |
obj.put("pushdata", jsArray);
|
| 22130 |
rajender |
1907 |
new pushData().execute(obj);
|
| 21480 |
rajender |
1908 |
} catch (Exception e) {
|
|
|
1909 |
e.printStackTrace();
|
|
|
1910 |
}
|
|
|
1911 |
if (url.contains("https://www.flipkart.com/login")) {
|
|
|
1912 |
Flipkartflag = true;
|
|
|
1913 |
userDataEditor.putString("flipkartOrder", "true").commit();
|
|
|
1914 |
userDataEditor.putBoolean("flipkartLoggedIn", true).commit();
|
|
|
1915 |
}
|
|
|
1916 |
}
|
| 22381 |
rajender |
1917 |
@JavascriptInterface
|
|
|
1918 |
public void angularUrls(String url) {
|
|
|
1919 |
if(!isInternetOn()){
|
| 22830 |
rajender |
1920 |
try {
|
|
|
1921 |
SearchFragment nextFrag = new SearchFragment();
|
|
|
1922 |
Bundle args = new Bundle();
|
|
|
1923 |
args.putString("finishingurl", url);
|
|
|
1924 |
nextFrag.setArguments(args);
|
|
|
1925 |
getActivity().getFragmentManager().beginTransaction().replace(R.id.frame_container, nextFrag).addToBackStack(null).commitAllowingStateLoss();
|
|
|
1926 |
}catch (Exception e) {
|
|
|
1927 |
e.printStackTrace();
|
|
|
1928 |
}
|
| 22381 |
rajender |
1929 |
|
|
|
1930 |
}
|
|
|
1931 |
else{
|
|
|
1932 |
try {
|
|
|
1933 |
obj = new JSONObject();
|
|
|
1934 |
JSONObject j = new JSONObject();
|
|
|
1935 |
JSONArray jsArray = new JSONArray();
|
|
|
1936 |
j.put("url", url);
|
|
|
1937 |
j.put("user_id", userData.getString("id", null));
|
|
|
1938 |
j.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
1939 |
jsArray.put(j);
|
|
|
1940 |
obj.put("pushdata", jsArray);
|
|
|
1941 |
new pushData().execute(obj);
|
|
|
1942 |
} catch (Exception e) {
|
|
|
1943 |
e.printStackTrace();
|
|
|
1944 |
}}}
|
| 21480 |
rajender |
1945 |
}
|
| 22130 |
rajender |
1946 |
class AuthTokenChange extends AsyncTask<String, Integer, String> {
|
| 21480 |
rajender |
1947 |
|
|
|
1948 |
@Override
|
|
|
1949 |
protected void onPreExecute() {
|
|
|
1950 |
|
|
|
1951 |
super.onPreExecute();
|
|
|
1952 |
}
|
| 22130 |
rajender |
1953 |
|
| 21480 |
rajender |
1954 |
@Override
|
|
|
1955 |
protected String doInBackground(String... params) {
|
|
|
1956 |
try {
|
|
|
1957 |
HttpClient httpclient = new DefaultHttpClient();
|
| 22830 |
rajender |
1958 |
HttpGet httpget=new HttpGet(apiData.getString("Web_Api_Tokendetail","http://app.profitmandi.com/apis/user/detail/token"));
|
| 22130 |
rajender |
1959 |
// HttpGet httpget = new HttpGet(ProfitTillConstants.Web_Api + "/user/token-info");
|
|
|
1960 |
httpget.setHeader("Auth-Token", userData.getString("token", ""));
|
|
|
1961 |
HttpResponse response = httpclient.execute(httpget);
|
| 21480 |
rajender |
1962 |
HttpEntity entity = response.getEntity();
|
|
|
1963 |
int status = response.getStatusLine().getStatusCode();
|
|
|
1964 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
| 22130 |
rajender |
1965 |
Log.d("Json",String.valueOf(jObjGmail));
|
| 21480 |
rajender |
1966 |
return String.valueOf(jObjGmail);
|
|
|
1967 |
|
| 22130 |
rajender |
1968 |
} catch (UnsupportedEncodingException e) {
|
| 21480 |
rajender |
1969 |
e.printStackTrace();
|
| 22130 |
rajender |
1970 |
} catch (IOException e) {
|
| 21480 |
rajender |
1971 |
e.printStackTrace();
|
|
|
1972 |
} catch (JSONException e) {
|
|
|
1973 |
e.printStackTrace();
|
|
|
1974 |
}
|
|
|
1975 |
return null;
|
|
|
1976 |
}
|
|
|
1977 |
|
| 22130 |
rajender |
1978 |
@Override
|
|
|
1979 |
protected void onPostExecute(String result) {
|
|
|
1980 |
super.onPostExecute(result);
|
|
|
1981 |
try {
|
|
|
1982 |
JSONObject jsonObject = new JSONObject(result);
|
|
|
1983 |
JSONObject jobj=jsonObject.getJSONObject("response");
|
|
|
1984 |
String userStatus=jobj.getString("userStatus");
|
|
|
1985 |
userDataEditor.putString("userStatus",userStatus);
|
|
|
1986 |
userDataEditor.commit();
|
|
|
1987 |
if(!(userData.getString("userStatus","").equals("notRegistered"))) {
|
|
|
1988 |
String user_id = jobj.getString("userId");
|
|
|
1989 |
userDataEditor.putString("id", user_id);
|
|
|
1990 |
userDataEditor.commit();
|
|
|
1991 |
if(!(userData.getString("id", "").equals(""))){
|
|
|
1992 |
UtilityFunctions utf = new UtilityFunctions();
|
|
|
1993 |
new pushApkData().execute(utf.getDeviceInformation(getActivity()));
|
|
|
1994 |
}
|
|
|
1995 |
else {
|
|
|
1996 |
Toast.makeText(getActivity(),"Network issue",Toast.LENGTH_LONG).show();
|
|
|
1997 |
}}
|
|
|
1998 |
else{
|
|
|
1999 |
|
|
|
2000 |
}
|
|
|
2001 |
}
|
|
|
2002 |
catch (JSONException e) {
|
|
|
2003 |
e.printStackTrace();
|
|
|
2004 |
}
|
| 21480 |
rajender |
2005 |
}
|
| 22130 |
rajender |
2006 |
}
|
|
|
2007 |
class pushApkData extends AsyncTask<ArrayList<NameValuePair>, Integer, String> {
|
| 21480 |
rajender |
2008 |
|
| 22130 |
rajender |
2009 |
@Override
|
|
|
2010 |
protected void onPreExecute() {
|
|
|
2011 |
super.onPreExecute();
|
|
|
2012 |
}
|
| 21480 |
rajender |
2013 |
|
|
|
2014 |
@Override
|
| 22130 |
rajender |
2015 |
protected String doInBackground(ArrayList<NameValuePair>... arg0) {
|
|
|
2016 |
try {
|
|
|
2017 |
HttpClient httpclient = new DefaultHttpClient();
|
| 22830 |
rajender |
2018 |
HttpPost httppost = new HttpPost(apiData.getString("devices_info","http://api.profittill.com/devices/add"));
|
| 22130 |
rajender |
2019 |
//HttpPost httppost = new HttpPost(ProfitTillConstants.Push_Url);
|
|
|
2020 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
|
|
2021 |
httppost.setEntity(new UrlEncodedFormEntity(arg0[0]));
|
|
|
2022 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
2023 |
HttpEntity entity = response.getEntity();
|
|
|
2024 |
int status = response.getStatusLine().getStatusCode();
|
|
|
2025 |
if(status == 200){
|
|
|
2026 |
return "success";
|
|
|
2027 |
} else {
|
|
|
2028 |
return "failure";
|
|
|
2029 |
}
|
|
|
2030 |
} catch (Exception e) {
|
|
|
2031 |
return null;
|
|
|
2032 |
}
|
|
|
2033 |
}
|
|
|
2034 |
@Override
|
|
|
2035 |
protected void onPostExecute(String result) {
|
|
|
2036 |
super.onPostExecute(result);
|
|
|
2037 |
if (userData.getString("fcm_token_sent", "false").equals("false") && (!userData.getString("id", "").equals(""))) {
|
|
|
2038 |
regId = FirebaseInstanceId.getInstance().getToken();
|
|
|
2039 |
Log.d("RegisterActivity", "registerInBackground - regId: "
|
|
|
2040 |
+ regId);
|
|
|
2041 |
msg = "Device registered";
|
|
|
2042 |
new gcmPushData().execute(msg);
|
|
|
2043 |
}}}
|
|
|
2044 |
|
|
|
2045 |
class gcmPushData extends AsyncTask<String, Integer, String> {
|
|
|
2046 |
|
|
|
2047 |
@Override
|
| 21480 |
rajender |
2048 |
protected void onPreExecute() {
|
|
|
2049 |
super.onPreExecute();
|
|
|
2050 |
}
|
|
|
2051 |
|
|
|
2052 |
@Override
|
| 22130 |
rajender |
2053 |
protected String doInBackground(String... arg0) {
|
|
|
2054 |
String id = null;
|
|
|
2055 |
try {
|
|
|
2056 |
HttpClient httpclient = new DefaultHttpClient();
|
| 22830 |
rajender |
2057 |
HttpPost httppost = new HttpPost(apiData.getString("gcm.push.url","http://api.profittill.com/gcm_users/add"));
|
| 22130 |
rajender |
2058 |
//HttpPost httppost = new HttpPost(ProfitTillConstants.gcm_url);
|
|
|
2059 |
ArrayList<NameValuePair> nameValuePairsGcm = new ArrayList<>();
|
|
|
2060 |
TelephonyManager telephonyManager = (TelephonyManager)getActivity().getSystemService(Context.TELEPHONY_SERVICE);
|
|
|
2061 |
nameValuePairsGcm.add(new BasicNameValuePair("gcm_regid", regId));
|
|
|
2062 |
nameValuePairsGcm.add(new BasicNameValuePair("imeinumber", telephonyManager.getDeviceId()));
|
|
|
2063 |
nameValuePairsGcm.add(new BasicNameValuePair("user_id", userData.getString("id", null)));
|
|
|
2064 |
nameValuePairsGcm.add(new BasicNameValuePair("notification_type","fcm"));
|
|
|
2065 |
nameValuePairsGcm.add(new BasicNameValuePair("device_message", arg0[0]));
|
|
|
2066 |
nameValuePairsGcm.add(new BasicNameValuePair("androidid", UtilityFunctions.androidId(getActivity())));
|
|
|
2067 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
|
|
2068 |
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairsGcm));
|
|
|
2069 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
2070 |
HttpEntity entity = response.getEntity();
|
|
|
2071 |
int status = response.getStatusLine().getStatusCode();
|
|
|
2072 |
|
|
|
2073 |
if (status == 200) {
|
|
|
2074 |
Log.d("ResponseCode GCM ", status + "");
|
|
|
2075 |
userDataEditor.putString("fcm_token_sent", "true");
|
|
|
2076 |
userDataEditor.commit();
|
|
|
2077 |
} else {
|
|
|
2078 |
Log.d("ResponseCode GCM ", status + "");
|
|
|
2079 |
}
|
|
|
2080 |
nameValuePairsGcm.clear();
|
|
|
2081 |
Log.e("pass 1", "connection success ");
|
|
|
2082 |
} catch (Exception e) {
|
|
|
2083 |
Log.e("Fail 1", e.toString());
|
|
|
2084 |
|
|
|
2085 |
}
|
|
|
2086 |
return null;
|
|
|
2087 |
}
|
|
|
2088 |
|
|
|
2089 |
@Override
|
|
|
2090 |
protected void onPostExecute(String result)
|
|
|
2091 |
{
|
|
|
2092 |
|
|
|
2093 |
super.onPostExecute(result);
|
|
|
2094 |
}}
|
|
|
2095 |
|
|
|
2096 |
class loadData extends AsyncTask<List<NameValuePair>, Integer, JSONObject> {
|
|
|
2097 |
|
|
|
2098 |
@Override
|
|
|
2099 |
protected void onPreExecute() {
|
|
|
2100 |
super.onPreExecute();
|
|
|
2101 |
}
|
|
|
2102 |
|
|
|
2103 |
@Override
|
| 21480 |
rajender |
2104 |
protected JSONObject doInBackground(List<NameValuePair>... orderDetail) {
|
|
|
2105 |
|
|
|
2106 |
|
|
|
2107 |
try {
|
|
|
2108 |
HttpClient httpclient = new DefaultHttpClient();
|
|
|
2109 |
HttpPost httppost = new HttpPost(apiData.getString("orderpagehtml.push.api", null));
|
|
|
2110 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
|
|
2111 |
|
|
|
2112 |
httppost.setEntity(new UrlEncodedFormEntity(orderDetail[0]));
|
|
|
2113 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
2114 |
HttpEntity entity = response.getEntity();
|
|
|
2115 |
|
|
|
2116 |
int status = response.getStatusLine().getStatusCode();
|
|
|
2117 |
|
|
|
2118 |
if (status == 200) {
|
|
|
2119 |
NameValuePair y = orderDetail[0].get(2);
|
|
|
2120 |
int z = orderDetails.deleteRecord(y.getName(), new String[]{y.getValue()});
|
|
|
2121 |
} else {
|
|
|
2122 |
Log.d("Status in load Data ", "Status Load data " + status);
|
|
|
2123 |
|
|
|
2124 |
}
|
|
|
2125 |
String getJSON = EntityUtils.toString(entity);
|
|
|
2126 |
if (getJSON == null) {
|
|
|
2127 |
return null;
|
|
|
2128 |
} else {
|
|
|
2129 |
JSONObject jObjGmail = new JSONObject(getJSON);
|
|
|
2130 |
return jObjGmail;
|
|
|
2131 |
}
|
|
|
2132 |
} catch (Exception e) {
|
|
|
2133 |
return null;
|
|
|
2134 |
}
|
|
|
2135 |
}
|
|
|
2136 |
|
|
|
2137 |
|
|
|
2138 |
@Override
|
|
|
2139 |
protected void onPostExecute(JSONObject result) {
|
|
|
2140 |
if (result == null) {
|
|
|
2141 |
//Log.d("Error in fetching result ", "Flipkart html ");
|
|
|
2142 |
} else {
|
|
|
2143 |
try {
|
|
|
2144 |
if (result.getString("message").equalsIgnoreCase("PROCESSED"))
|
|
|
2145 |
orderDetails.deleterecords();
|
|
|
2146 |
} catch (Exception e) {
|
|
|
2147 |
}
|
|
|
2148 |
}
|
|
|
2149 |
super.onPostExecute(result);
|
|
|
2150 |
}
|
|
|
2151 |
}
|
|
|
2152 |
|
|
|
2153 |
class AmazonOrderDetails extends WebViewClient {
|
|
|
2154 |
|
|
|
2155 |
@Override
|
|
|
2156 |
public void onReceivedHttpAuthRequest(WebView view,
|
|
|
2157 |
HttpAuthHandler handler, String host, String realm) {
|
|
|
2158 |
|
|
|
2159 |
handler.proceed("dtr", "dtr18Feb2015");
|
|
|
2160 |
|
|
|
2161 |
}
|
|
|
2162 |
|
|
|
2163 |
@Override
|
|
|
2164 |
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
|
|
2165 |
super.onPageStarted(view, url, favicon);
|
|
|
2166 |
}
|
|
|
2167 |
|
|
|
2168 |
@Override
|
|
|
2169 |
public void onPageFinished(WebView view, String url) {
|
|
|
2170 |
view.loadUrl("javascript:window.HTMLOUT.showHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
|
|
2171 |
super.onPageFinished(view, url);
|
|
|
2172 |
}
|
|
|
2173 |
}
|
|
|
2174 |
|
|
|
2175 |
class amazonInterface {
|
|
|
2176 |
|
|
|
2177 |
Context mContext;
|
|
|
2178 |
|
|
|
2179 |
/**
|
|
|
2180 |
* Instantiate the interface and set the context
|
|
|
2181 |
*/
|
|
|
2182 |
public amazonInterface(Context c) {
|
|
|
2183 |
mContext = c;
|
|
|
2184 |
}
|
|
|
2185 |
|
|
|
2186 |
/**
|
|
|
2187 |
* Show a toast from the web page
|
|
|
2188 |
*/
|
|
|
2189 |
@JavascriptInterface
|
|
|
2190 |
public void showToast(String toast) {
|
|
|
2191 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("rawhtml", UtilityFunctions.compress(toast)));
|
|
|
2192 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("zip", "1"));
|
|
|
2193 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("wifi", UtilityFunctions.checkWifi(getActivity()) + ""));
|
|
|
2194 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("imeinumber", UtilityFunctions.getImeiNumber(getActivity())));
|
|
|
2195 |
nameValuePairsRawHtmlAmazon.add(new BasicNameValuePair("appversion", UtilityFunctions.getAppVersion(getActivity())));
|
|
|
2196 |
if (isInternetOn()) {
|
|
|
2197 |
new amazonPushData().execute(nameValuePairsRawHtmlAmazon);
|
|
|
2198 |
}
|
|
|
2199 |
}
|
|
|
2200 |
|
|
|
2201 |
|
|
|
2202 |
@JavascriptInterface
|
|
|
2203 |
public void showHTML(String html) {
|
|
|
2204 |
showToast(html);
|
|
|
2205 |
}
|
|
|
2206 |
|
|
|
2207 |
@JavascriptInterface
|
|
|
2208 |
public void orderHistory(String html) {
|
|
|
2209 |
List<NameValuePair> amazonOrderHistory = new ArrayList<>();
|
|
|
2210 |
amazonOrderHistory.add(new BasicNameValuePair("url", str.get(0)));
|
|
|
2211 |
amazonOrderHistory.add(new BasicNameValuePair("html", UtilityFunctions.compress(html)));
|
|
|
2212 |
amazonOrderHistory.add(new BasicNameValuePair("zip", "1"));
|
|
|
2213 |
amazonOrderHistory.add(new BasicNameValuePair("wifi", UtilityFunctions.checkWifi(getActivity()) + ""));
|
|
|
2214 |
amazonOrderHistory.add(new BasicNameValuePair("imeinumber", UtilityFunctions.getImeiNumber(getActivity())));
|
|
|
2215 |
amazonOrderHistory.add(new BasicNameValuePair("appversion", UtilityFunctions.getAppVersion(getActivity())));
|
|
|
2216 |
if (isInternetOn()) {
|
|
|
2217 |
new pushQueuedData().execute(amazonOrderHistory);
|
|
|
2218 |
userDataEditor.putLong("amazonNextFetchTime", System.currentTimeMillis() + ProfitTillConstants.DURATION_TRACKING_ORDERS).commit();
|
|
|
2219 |
}
|
|
|
2220 |
}
|
|
|
2221 |
|
|
|
2222 |
@JavascriptInterface
|
|
|
2223 |
public void cancelledHistory(String html) {
|
|
|
2224 |
List<NameValuePair> amazonOrderHistory = new ArrayList<>();
|
|
|
2225 |
amazonOrderHistory.add(new BasicNameValuePair("url", str.get(j++)));
|
|
|
2226 |
amazonOrderHistory.add(new BasicNameValuePair("html", UtilityFunctions.compress(html)));
|
|
|
2227 |
amazonOrderHistory.add(new BasicNameValuePair("zip", "1"));
|
|
|
2228 |
amazonOrderHistory.add(new BasicNameValuePair("wifi", UtilityFunctions.checkWifi(getActivity()) + ""));
|
|
|
2229 |
amazonOrderHistory.add(new BasicNameValuePair("imeinumber", UtilityFunctions.getImeiNumber(getActivity())));
|
|
|
2230 |
amazonOrderHistory.add(new BasicNameValuePair("appversion", UtilityFunctions.getAppVersion(getActivity())));
|
|
|
2231 |
if (isInternetOn()) {
|
|
|
2232 |
new pushCancelledQueuedData().execute(amazonOrderHistory);
|
|
|
2233 |
userDataEditor.putLong("amazonNextFetchTime", System.currentTimeMillis() + ProfitTillConstants.DURATION_TRACKING_ORDERS).commit();
|
|
|
2234 |
}
|
|
|
2235 |
}
|
|
|
2236 |
|
|
|
2237 |
@JavascriptInterface
|
|
|
2238 |
public void amazonOrderUrls(String html) {
|
|
|
2239 |
//Log.e("OrderUrls","Order amazonOrderUrls" + html);
|
|
|
2240 |
List<NameValuePair> amazonOrderHistory = new ArrayList<>();
|
|
|
2241 |
amazonOrderHistory.add(new BasicNameValuePair("url", str.get(1)));
|
|
|
2242 |
amazonOrderHistory.add(new BasicNameValuePair("html", UtilityFunctions.compress(html)));
|
|
|
2243 |
amazonOrderHistory.add(new BasicNameValuePair("zip", "1"));
|
|
|
2244 |
amazonOrderHistory.add(new BasicNameValuePair("wifi", UtilityFunctions.checkWifi(getActivity()) + ""));
|
|
|
2245 |
amazonOrderHistory.add(new BasicNameValuePair("imeinumber", UtilityFunctions.getImeiNumber(getActivity())));
|
|
|
2246 |
amazonOrderHistory.add(new BasicNameValuePair("appversion", UtilityFunctions.getAppVersion(getActivity())));
|
|
|
2247 |
if (isInternetOn()) {
|
|
|
2248 |
new pushCancelledQueuedData().execute(amazonOrderHistory);
|
|
|
2249 |
} else {
|
|
|
2250 |
|
|
|
2251 |
}
|
|
|
2252 |
}
|
|
|
2253 |
|
|
|
2254 |
}
|
|
|
2255 |
|
|
|
2256 |
int j;
|
|
|
2257 |
|
|
|
2258 |
class amazonPushData extends AsyncTask<List<NameValuePair>, Integer, String> {
|
|
|
2259 |
private StringBuilder sb;
|
|
|
2260 |
|
|
|
2261 |
private HttpResponse req;
|
|
|
2262 |
private InputStream is;
|
|
|
2263 |
|
|
|
2264 |
@Override
|
|
|
2265 |
protected void onPreExecute() {
|
|
|
2266 |
super.onPreExecute();
|
|
|
2267 |
Log.e("Pre execute", "Pre execute");
|
|
|
2268 |
|
|
|
2269 |
}
|
|
|
2270 |
|
|
|
2271 |
@Override
|
|
|
2272 |
protected String doInBackground(List<NameValuePair>... orderDetail) {
|
|
|
2273 |
try {
|
|
|
2274 |
HttpClient httpclient = new DefaultHttpClient();
|
|
|
2275 |
HttpPost httppost = new HttpPost(apiData.getString("orderpagehtml.push.api", null));
|
|
|
2276 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
|
|
2277 |
httppost.setEntity(new UrlEncodedFormEntity(orderDetail[0]));
|
|
|
2278 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
2279 |
HttpEntity entity = response.getEntity();
|
|
|
2280 |
int status = response.getStatusLine().getStatusCode();
|
|
|
2281 |
|
|
|
2282 |
if (status == 200) {
|
|
|
2283 |
System.out.println("ResponseCode of record: " + status + " is " + status);
|
|
|
2284 |
NameValuePair y = orderDetail[0].get(2);
|
|
|
2285 |
int z = orderDetails.deleteRecord(y.getName(), new String[]{y.getValue()});
|
|
|
2286 |
amazonapiSettingsEditor.remove("amazonurl");
|
|
|
2287 |
amazonapiSettingsEditor.commit();
|
|
|
2288 |
} else {
|
|
|
2289 |
/*Log.d("ResponseCode",status+"");
|
|
|
2290 |
System.out.println(" NOT Transfered");
|
|
|
2291 |
Log.d("ResponseCode",status+"");*/
|
|
|
2292 |
}
|
|
|
2293 |
/* Log.e("pass 1", "Amazon success ");*/
|
|
|
2294 |
} catch (Exception e) {
|
|
|
2295 |
/* Log.e("Fail 1", e.toString());*/
|
|
|
2296 |
|
|
|
2297 |
}
|
|
|
2298 |
return "success";
|
|
|
2299 |
}
|
|
|
2300 |
|
|
|
2301 |
@Override
|
|
|
2302 |
protected void onPostExecute(String result) {
|
|
|
2303 |
super.onPostExecute(result);
|
|
|
2304 |
new FetchOrderURLS().execute();
|
|
|
2305 |
}
|
|
|
2306 |
}
|
|
|
2307 |
|
|
|
2308 |
|
|
|
2309 |
class PushRawHTML extends AsyncTask<List<NameValuePair>, Integer, JSONObject> {
|
|
|
2310 |
@Override
|
|
|
2311 |
protected void onPreExecute() {
|
|
|
2312 |
super.onPreExecute();
|
|
|
2313 |
}
|
|
|
2314 |
|
|
|
2315 |
@Override
|
|
|
2316 |
protected JSONObject doInBackground(List<NameValuePair>... orderDetail) {
|
|
|
2317 |
|
|
|
2318 |
try {
|
|
|
2319 |
HttpClient httpclient = new DefaultHttpClient();
|
|
|
2320 |
HttpPost httppost = new HttpPost(apiData.getString("orderpagehtml.push.api", null));
|
|
|
2321 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
|
|
2322 |
httppost.setEntity(new UrlEncodedFormEntity(orderDetail[0]));
|
|
|
2323 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
2324 |
HttpEntity entity = response.getEntity();
|
|
|
2325 |
int status = response.getStatusLine().getStatusCode();
|
|
|
2326 |
|
|
|
2327 |
if (status == 200) {
|
|
|
2328 |
NameValuePair y = orderDetail[0].get(2);
|
|
|
2329 |
int z = orderDetails.deleteRecord(y.getName(), new String[]{y.getValue()});
|
|
|
2330 |
} else {
|
|
|
2331 |
}
|
|
|
2332 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
|
|
2333 |
|
|
|
2334 |
return jObjGmail;
|
|
|
2335 |
} catch (Exception e) {
|
|
|
2336 |
return null;
|
|
|
2337 |
}
|
|
|
2338 |
}
|
|
|
2339 |
|
|
|
2340 |
@Override
|
|
|
2341 |
protected void onPostExecute(JSONObject result) {
|
|
|
2342 |
super.onPostExecute(result);
|
|
|
2343 |
try {
|
|
|
2344 |
userDataEditor.putString("amazonOrder", "true").commit();
|
|
|
2345 |
userDataEditor.putBoolean("amazonLoggedIn", true).commit();
|
|
|
2346 |
userDataEditor.putLong("amazonNextFetchTime", System.currentTimeMillis() + ProfitTillConstants.DURATION_TRACKING_ORDERS).commit();
|
|
|
2347 |
if (result.getString("htmlRequired").equalsIgnoreCase("true")) {
|
|
|
2348 |
String orderId = result.getString("orderId");
|
|
|
2349 |
amazonapiSettingsEditor.putString("amazonurl", result.getString("url"));
|
|
|
2350 |
amazonapiSettingsEditor.commit();
|
|
|
2351 |
pushDataInAmazon(orderId);
|
|
|
2352 |
}
|
|
|
2353 |
} catch (Exception e) {
|
|
|
2354 |
|
|
|
2355 |
}
|
|
|
2356 |
}
|
|
|
2357 |
}
|
|
|
2358 |
|
|
|
2359 |
class AmazonOrderTrackingDetails extends AsyncTask<List<NameValuePair>, Integer, JSONObject> {
|
|
|
2360 |
@Override
|
|
|
2361 |
protected void onPreExecute() {
|
|
|
2362 |
super.onPreExecute();
|
|
|
2363 |
}
|
|
|
2364 |
|
|
|
2365 |
@Override
|
|
|
2366 |
protected JSONObject doInBackground(List<NameValuePair>... arg0) {
|
|
|
2367 |
try {
|
|
|
2368 |
HttpClient httpclient = new DefaultHttpClient();
|
|
|
2369 |
HttpPost httppost = new HttpPost(apiData.getString("orderpagehtml.push.api", null));
|
|
|
2370 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
|
|
2371 |
httppost.setEntity(new UrlEncodedFormEntity(arg0[0]));
|
|
|
2372 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
2373 |
HttpEntity entity = response.getEntity();
|
|
|
2374 |
int status = response.getStatusLine().getStatusCode();
|
|
|
2375 |
|
|
|
2376 |
if (status == 200) {
|
|
|
2377 |
} else {
|
|
|
2378 |
}
|
|
|
2379 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
|
|
2380 |
return jObjGmail;
|
|
|
2381 |
|
|
|
2382 |
} catch (Exception e) {
|
|
|
2383 |
return null;
|
|
|
2384 |
}
|
|
|
2385 |
}
|
|
|
2386 |
|
|
|
2387 |
@Override
|
|
|
2388 |
protected void onPostExecute(JSONObject result) {
|
|
|
2389 |
super.onPostExecute(result);
|
|
|
2390 |
}
|
|
|
2391 |
}
|
|
|
2392 |
|
|
|
2393 |
class pushQueuedData extends AsyncTask<List<NameValuePair>, Integer, JSONObject> {
|
|
|
2394 |
@Override
|
|
|
2395 |
protected void onPreExecute() {
|
|
|
2396 |
super.onPreExecute();
|
|
|
2397 |
}
|
|
|
2398 |
|
|
|
2399 |
@Override
|
|
|
2400 |
protected JSONObject doInBackground(List<NameValuePair>... pushOrder) {
|
|
|
2401 |
|
|
|
2402 |
try {
|
|
|
2403 |
HttpClient httpclient = new DefaultHttpClient();
|
|
|
2404 |
//Get store id
|
|
|
2405 |
// NameValuePair nvp = pushOrder[1].get(0);
|
|
|
2406 |
//String storeId = nvp.getValue();
|
|
|
2407 |
|
|
|
2408 |
String fetchUrl = apiData.getString("amazon.order.tracking.post.url", null) + "?user_id=" + userData.getString("id", "") + "&store_id=" + apiData.getString("store.code.amazon", "1");
|
|
|
2409 |
HttpPost httppost = new HttpPost(fetchUrl);
|
|
|
2410 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
|
|
2411 |
httppost.setEntity(new UrlEncodedFormEntity(pushOrder[0]));
|
|
|
2412 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
2413 |
HttpEntity entity = response.getEntity();
|
|
|
2414 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
|
|
2415 |
return jObjGmail;
|
|
|
2416 |
|
|
|
2417 |
} catch (Exception e) {
|
|
|
2418 |
return null;
|
|
|
2419 |
}
|
|
|
2420 |
|
|
|
2421 |
}
|
|
|
2422 |
|
|
|
2423 |
@Override
|
|
|
2424 |
protected void onPostExecute(JSONObject result) {
|
|
|
2425 |
super.onPostExecute(result);
|
|
|
2426 |
try {
|
|
|
2427 |
if (result == null) {
|
|
|
2428 |
|
|
|
2429 |
} else if (result.getString("result").equalsIgnoreCase("PARSE_ERROR")) {
|
|
|
2430 |
userDataEditor.putBoolean("amazonLoggedIn", false).commit();
|
|
|
2431 |
} else {
|
|
|
2432 |
addOrderHistoryCancelled(str.get(1));
|
|
|
2433 |
}
|
|
|
2434 |
} catch (Exception e) {
|
|
|
2435 |
e.printStackTrace();
|
|
|
2436 |
}
|
|
|
2437 |
}
|
|
|
2438 |
}
|
|
|
2439 |
|
|
|
2440 |
class pushCancelledQueuedData extends AsyncTask<List<NameValuePair>, Integer, String> {
|
|
|
2441 |
|
|
|
2442 |
@Override
|
|
|
2443 |
protected void onPreExecute() {
|
|
|
2444 |
super.onPreExecute();
|
|
|
2445 |
}
|
|
|
2446 |
|
|
|
2447 |
@Override
|
|
|
2448 |
protected String doInBackground(List<NameValuePair>... pushOrder) {
|
|
|
2449 |
|
|
|
2450 |
try {
|
|
|
2451 |
HttpClient httpclient = new DefaultHttpClient();
|
|
|
2452 |
|
|
|
2453 |
String fetchUrl = apiData.getString("amazon.order.tracking.post.url", null) + "?user_id=" + userData.getString("id", "") + "&store_id=" + apiData.getString("store.code.amazon", "1");
|
|
|
2454 |
HttpPost httppost = new HttpPost(fetchUrl);
|
|
|
2455 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
|
|
2456 |
httppost.setEntity(new UrlEncodedFormEntity(pushOrder[0]));
|
|
|
2457 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
2458 |
HttpEntity entity = response.getEntity();
|
|
|
2459 |
|
|
|
2460 |
return "success";
|
|
|
2461 |
} catch (Exception e) {
|
|
|
2462 |
return "failure";
|
|
|
2463 |
}
|
|
|
2464 |
|
|
|
2465 |
}
|
|
|
2466 |
|
|
|
2467 |
@Override
|
|
|
2468 |
protected void onPostExecute(String result) {
|
|
|
2469 |
super.onPostExecute(result);
|
|
|
2470 |
try {
|
|
|
2471 |
addOrderHistoryCancelled(str.get(++sizeList));
|
|
|
2472 |
} catch (Exception e) {
|
|
|
2473 |
e.printStackTrace();
|
|
|
2474 |
}
|
|
|
2475 |
FLAG = false;
|
|
|
2476 |
}
|
|
|
2477 |
}
|
|
|
2478 |
|
| 22130 |
rajender |
2479 |
class SendOtpMessage extends AsyncTask<String, Integer, String> {
|
|
|
2480 |
|
|
|
2481 |
@Override
|
|
|
2482 |
protected void onPreExecute() {
|
|
|
2483 |
|
|
|
2484 |
super.onPreExecute();
|
|
|
2485 |
}
|
|
|
2486 |
|
|
|
2487 |
@Override
|
|
|
2488 |
protected String doInBackground(String... params) {
|
|
|
2489 |
try {
|
|
|
2490 |
|
|
|
2491 |
HttpClient httpclient = new DefaultHttpClient();
|
| 22830 |
rajender |
2492 |
HttpPost httppost = new HttpPost(apiData.getString("Web_Api_Otp","http://app.profitmandi.com/apis/otp/parseOTP"));
|
| 22130 |
rajender |
2493 |
//HttpPost httppost = new HttpPost(ProfitTillConstants.Web_Api + "/otp/parseOTP");
|
|
|
2494 |
httppost.setHeader("Auth-Token", userData.getString("token", ""));
|
|
|
2495 |
httppost.setEntity(new UrlEncodedFormEntity(messageNameValuePair));
|
|
|
2496 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
2497 |
HttpEntity entity = response.getEntity();
|
|
|
2498 |
int status = response.getStatusLine().getStatusCode();
|
|
|
2499 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
|
|
2500 |
return String.valueOf(jObjGmail);
|
|
|
2501 |
|
|
|
2502 |
}
|
|
|
2503 |
catch (UnsupportedEncodingException e) {
|
|
|
2504 |
e.printStackTrace();
|
|
|
2505 |
}
|
|
|
2506 |
catch (IOException e) {
|
|
|
2507 |
e.printStackTrace();
|
|
|
2508 |
}
|
|
|
2509 |
catch (JSONException e) {
|
|
|
2510 |
e.printStackTrace();
|
|
|
2511 |
}
|
|
|
2512 |
return null;
|
|
|
2513 |
}
|
|
|
2514 |
@Override
|
|
|
2515 |
protected void onPostExecute(String result) {
|
|
|
2516 |
super.onPostExecute(result);
|
|
|
2517 |
try {
|
|
|
2518 |
JSONObject jsonObject = new JSONObject(result);
|
|
|
2519 |
String response=jsonObject.getString("response");
|
|
|
2520 |
|
|
|
2521 |
String js = ("javascript:window.localStorage.setItem('android.otpReceived','"+response +"');");
|
|
|
2522 |
webView.loadUrl(js);
|
|
|
2523 |
//webView.loadUrl("javascript:alert(window.localStorage.getItem('android.otpReceived'))");
|
|
|
2524 |
|
|
|
2525 |
Log.d("otp",js);
|
|
|
2526 |
/* for(int i=1; i<6; i++){
|
|
|
2527 |
js += "document.getElementsByName('otp" + i + "')[0].value ='" +response.substring(i-1,i) + "';";
|
|
|
2528 |
|
|
|
2529 |
}
|
|
|
2530 |
/* String js = ("javascript:document.getElementsByName('otp1')[0].value ='"+response +"';");
|
|
|
2531 |
//js +="document.getElementsByName('otpForm')[0].submit();";
|
|
|
2532 |
// Log.d("otp",js);
|
|
|
2533 |
if (Build.VERSION.SDK_INT >= 19) {
|
|
|
2534 |
webView.evaluateJavascript(js, new ValueCallback<String>() {
|
|
|
2535 |
@Override
|
|
|
2536 |
public void onReceiveValue(String s) {
|
|
|
2537 |
|
|
|
2538 |
}
|
|
|
2539 |
});
|
|
|
2540 |
} else {
|
|
|
2541 |
webView.loadUrl(js);
|
|
|
2542 |
}*/
|
|
|
2543 |
//String js2 =("javascript:document.getElementById('').click()");
|
|
|
2544 |
//webView.loadUrl(js2);
|
|
|
2545 |
} catch (JSONException e) {
|
|
|
2546 |
e.printStackTrace();
|
|
|
2547 |
}
|
|
|
2548 |
}
|
|
|
2549 |
|
|
|
2550 |
}
|
|
|
2551 |
|
| 21480 |
rajender |
2552 |
int sizeList;
|
|
|
2553 |
|
|
|
2554 |
class FetchOrderURLS extends AsyncTask<String, Integer, JSONObject> {
|
|
|
2555 |
|
|
|
2556 |
@Override
|
|
|
2557 |
protected void onPreExecute() {
|
|
|
2558 |
super.onPreExecute();
|
|
|
2559 |
}
|
|
|
2560 |
|
|
|
2561 |
@Override
|
|
|
2562 |
protected JSONObject doInBackground(String... arg0) {
|
|
|
2563 |
HttpClient httpclient = new DefaultHttpClient();
|
|
|
2564 |
try {
|
|
|
2565 |
String fetchUrl = apiData.getString("amazon.order.tracking.get.url", null) + "?user_id=" + userData.getString("id", "") + "&store_id=" + apiData.getString("store.code.amazon", "1");
|
|
|
2566 |
HttpGet httppost = new HttpGet(fetchUrl);
|
|
|
2567 |
|
|
|
2568 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
|
|
2569 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
2570 |
HttpEntity entity = response.getEntity();
|
|
|
2571 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
|
|
2572 |
return jObjGmail;
|
|
|
2573 |
|
|
|
2574 |
} catch (ClientProtocolException e) {
|
|
|
2575 |
return null;
|
|
|
2576 |
} catch (IOException e) {
|
|
|
2577 |
return null;
|
|
|
2578 |
}
|
|
|
2579 |
catch (Exception e) {
|
|
|
2580 |
e.printStackTrace();
|
|
|
2581 |
return null;
|
|
|
2582 |
}
|
|
|
2583 |
}
|
|
|
2584 |
|
|
|
2585 |
@Override
|
|
|
2586 |
protected void onPostExecute(JSONObject result) {
|
|
|
2587 |
super.onPostExecute(result);
|
|
|
2588 |
try {
|
|
|
2589 |
if (result == null) {
|
|
|
2590 |
userDataEditor.putString("amazonOrder", "false").commit();
|
|
|
2591 |
} else {
|
|
|
2592 |
if (result.length() == 0) {
|
|
|
2593 |
userDataEditor.putString("amazonOrder", "false").commit();
|
|
|
2594 |
} else {
|
|
|
2595 |
JSONArray js = result.getJSONArray("result");
|
|
|
2596 |
if (js.length() != 0) {
|
|
|
2597 |
str = new ArrayList<>();
|
|
|
2598 |
for (int i = 0; i < js.length(); i++) {
|
|
|
2599 |
String s = js.getString(i);
|
|
|
2600 |
str.add(s);
|
|
|
2601 |
}
|
|
|
2602 |
sizeList = 1;
|
|
|
2603 |
j = 1;
|
|
|
2604 |
addOrderHistory(str.get(0));
|
|
|
2605 |
} else {
|
|
|
2606 |
userDataEditor.putString("amazonOrder", "false").commit();
|
|
|
2607 |
}
|
|
|
2608 |
}
|
|
|
2609 |
}
|
|
|
2610 |
} catch (Exception e) {
|
|
|
2611 |
}
|
|
|
2612 |
}
|
|
|
2613 |
}
|
|
|
2614 |
|
|
|
2615 |
int count = 0;
|
|
|
2616 |
List<String> str;
|
|
|
2617 |
|
|
|
2618 |
public void addOrderHistory(String s) {
|
|
|
2619 |
AmazonOrderHistoryDetails amazonOrderClient = new AmazonOrderHistoryDetails();
|
|
|
2620 |
amazonOrderHistoryWebView = new WebView(webView.getContext());
|
|
|
2621 |
amazonOrderHistoryWebView.setVisibility(View.GONE);
|
|
|
2622 |
amazonOrderHistoryWebView.getSettings().setUserAgentString("Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36");
|
|
|
2623 |
amazonOrderHistoryWebView.getSettings().setJavaScriptEnabled(true);
|
|
|
2624 |
amazonOrderHistoryWebView.addJavascriptInterface(new amazonInterface(getActivity()), "HTMLOUT");
|
|
|
2625 |
amazonOrderHistoryWebView.loadUrl(s);
|
|
|
2626 |
amazonOrderHistoryWebView.setWebViewClient(amazonOrderClient);
|
|
|
2627 |
}
|
|
|
2628 |
|
|
|
2629 |
public void addOrderHistoryCancelled(String s) {
|
|
|
2630 |
AmazonOrderCancelledDetails amazonOrderClient1 = new AmazonOrderCancelledDetails();
|
|
|
2631 |
amazonOrderHistoryCancelledWebView = new WebView(webView.getContext());
|
|
|
2632 |
amazonOrderHistoryCancelledWebView.setVisibility(View.GONE);
|
|
|
2633 |
amazonOrderHistoryCancelledWebView.getSettings().setJavaScriptEnabled(true);
|
|
|
2634 |
amazonOrderHistoryCancelledWebView.getSettings().setUserAgentString("Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36");
|
|
|
2635 |
amazonOrderHistoryCancelledWebView.addJavascriptInterface(new amazonInterface(getActivity()), "HTMLOUT");
|
|
|
2636 |
amazonOrderHistoryCancelledWebView.loadUrl(s);
|
|
|
2637 |
amazonOrderHistoryCancelledWebView.setWebViewClient(amazonOrderClient1);
|
|
|
2638 |
}
|
|
|
2639 |
|
|
|
2640 |
class AmazonOrderHistoryDetails extends WebViewClient {
|
|
|
2641 |
|
|
|
2642 |
@Override
|
|
|
2643 |
public void onReceivedHttpAuthRequest(WebView view,
|
|
|
2644 |
HttpAuthHandler handler, String host, String realm) {
|
|
|
2645 |
|
|
|
2646 |
handler.proceed("dtr", "dtr18Feb2015");
|
|
|
2647 |
|
|
|
2648 |
}
|
|
|
2649 |
|
|
|
2650 |
@Override
|
|
|
2651 |
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
|
|
2652 |
super.onPageStarted(view, url, favicon);
|
|
|
2653 |
}
|
|
|
2654 |
|
|
|
2655 |
@Override
|
|
|
2656 |
public void onPageFinished(WebView view, String url) {
|
|
|
2657 |
super.onPageFinished(view, url);
|
|
|
2658 |
if (url.contains("signin")) {
|
|
|
2659 |
userDataEditor.putBoolean("amazonLoggedIn", false).commit();
|
|
|
2660 |
} else {
|
|
|
2661 |
view.loadUrl("javascript:window.HTMLOUT.orderHistory('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
|
|
2662 |
}
|
|
|
2663 |
}
|
|
|
2664 |
}
|
|
|
2665 |
|
|
|
2666 |
class AmazonOrderCancelledDetails extends WebViewClient {
|
|
|
2667 |
|
|
|
2668 |
@Override
|
|
|
2669 |
public void onReceivedHttpAuthRequest(WebView view,
|
|
|
2670 |
HttpAuthHandler handler, String host, String realm) {
|
|
|
2671 |
|
|
|
2672 |
handler.proceed("dtr", "dtr18Feb2015");
|
|
|
2673 |
|
|
|
2674 |
}
|
|
|
2675 |
|
|
|
2676 |
@Override
|
|
|
2677 |
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
|
|
2678 |
super.onPageStarted(view, url, favicon);
|
|
|
2679 |
}
|
|
|
2680 |
|
|
|
2681 |
@Override
|
|
|
2682 |
public void onPageFinished(WebView view, String url) {
|
|
|
2683 |
super.onPageFinished(view, url);
|
|
|
2684 |
view.loadUrl("javascript:window.HTMLOUT.cancelledHistory('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
|
|
2685 |
}
|
|
|
2686 |
}
|
|
|
2687 |
|
|
|
2688 |
|
|
|
2689 |
public final boolean isInternetOn() {
|
|
|
2690 |
|
|
|
2691 |
ConnectivityManager connec =
|
|
|
2692 |
(ConnectivityManager) getActivity().getSystemService(getActivity().getBaseContext().CONNECTIVITY_SERVICE);
|
|
|
2693 |
|
|
|
2694 |
if (connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTED ||
|
|
|
2695 |
connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.CONNECTING ||
|
|
|
2696 |
connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.CONNECTING ||
|
|
|
2697 |
connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.CONNECTED) {
|
|
|
2698 |
return true;
|
|
|
2699 |
|
|
|
2700 |
} else if (
|
|
|
2701 |
connec.getNetworkInfo(0).getState() == android.net.NetworkInfo.State.DISCONNECTED ||
|
|
|
2702 |
connec.getNetworkInfo(1).getState() == android.net.NetworkInfo.State.DISCONNECTED) {
|
|
|
2703 |
|
|
|
2704 |
return false;
|
|
|
2705 |
}
|
|
|
2706 |
return false;
|
|
|
2707 |
}
|
|
|
2708 |
|
|
|
2709 |
class checkGateWayProblem extends AsyncTask<String, Integer, String> {
|
|
|
2710 |
@Override
|
|
|
2711 |
protected void onPreExecute() {
|
|
|
2712 |
super.onPreExecute();
|
|
|
2713 |
}
|
|
|
2714 |
|
|
|
2715 |
@Override
|
|
|
2716 |
protected String doInBackground(String... arg0) {
|
|
|
2717 |
HttpClient httpclient = new DefaultHttpClient();
|
|
|
2718 |
try {
|
|
|
2719 |
HttpPost httppost = new HttpPost(arg0[0]);
|
|
|
2720 |
final String basicAuth = "Basic " + Base64.encodeToString("dtr:dtr18Feb2015".getBytes(), Base64.NO_WRAP);
|
|
|
2721 |
httppost.setHeader("Authorization", basicAuth);
|
|
|
2722 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
2723 |
int status = response.getStatusLine().getStatusCode();
|
|
|
2724 |
|
|
|
2725 |
jsArraySaholic = new JSONArray();
|
|
|
2726 |
jSaholic.put("url", arg0[0]);
|
|
|
2727 |
|
|
|
2728 |
jSaholic.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
2729 |
jSaholic.put("httpstatus", status);
|
|
|
2730 |
jSaholic.put("cookies", CookieManager.getInstance().getCookie(arg0[0]));
|
|
|
2731 |
jsArraySaholic.put(jSaholic);
|
|
|
2732 |
obj.put("pushdata", jsArraySaholic);
|
|
|
2733 |
Log.d("status ", "Status in checkGatewayProbelm " + status);
|
|
|
2734 |
if (status == 200) {
|
|
|
2735 |
return "success";
|
|
|
2736 |
} else {
|
|
|
2737 |
return "failure";
|
|
|
2738 |
}
|
|
|
2739 |
|
|
|
2740 |
} catch (ClientProtocolException e) {
|
|
|
2741 |
return "failure";
|
|
|
2742 |
} catch (IOException e) {
|
|
|
2743 |
return "failure";
|
|
|
2744 |
} catch (JSONException e) {
|
|
|
2745 |
return "failure";
|
|
|
2746 |
}
|
|
|
2747 |
}
|
|
|
2748 |
|
|
|
2749 |
@Override
|
|
|
2750 |
protected void onPostExecute(String result) {
|
|
|
2751 |
super.onPostExecute(result);
|
|
|
2752 |
new pushData1().execute(obj);
|
|
|
2753 |
}
|
|
|
2754 |
}
|
|
|
2755 |
|
|
|
2756 |
class pushData1 extends AsyncTask<JSONObject, Integer, String> {
|
|
|
2757 |
|
|
|
2758 |
@Override
|
|
|
2759 |
protected void onPreExecute() {
|
|
|
2760 |
super.onPreExecute();
|
|
|
2761 |
}
|
|
|
2762 |
|
|
|
2763 |
@Override
|
|
|
2764 |
protected String doInBackground(JSONObject... arg0) {
|
|
|
2765 |
HttpClient httpclient = new DefaultHttpClient();
|
|
|
2766 |
try {
|
|
|
2767 |
ArrayList<NameValuePair> nameValuePairs = new ArrayList<>();
|
|
|
2768 |
nameValuePairs.add(new BasicNameValuePair("pushdata", arg0[0].toString()));
|
|
|
2769 |
HttpPost httppost = new HttpPost(apiData.getString("url.push.api", null));
|
|
|
2770 |
final String basicAuth = "Basic " + Base64.encodeToString("dtr:dtr18Feb2015".getBytes(), Base64.NO_WRAP);
|
|
|
2771 |
httppost.setHeader("Authorization", basicAuth);
|
|
|
2772 |
|
|
|
2773 |
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
|
|
|
2774 |
System.out.println("JSON object in push Data 1 " + arg0[0].toString());
|
|
|
2775 |
StringEntity se = new StringEntity(arg0[0].toString());
|
|
|
2776 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
2777 |
int status = response.getStatusLine().getStatusCode();
|
|
|
2778 |
|
|
|
2779 |
if (status == 200) {
|
|
|
2780 |
return "success";
|
|
|
2781 |
} else {
|
|
|
2782 |
return "failure";
|
|
|
2783 |
}
|
|
|
2784 |
|
|
|
2785 |
} catch (ClientProtocolException e) {
|
|
|
2786 |
return "failure";
|
|
|
2787 |
} catch (IOException e) {
|
|
|
2788 |
return "failure";
|
|
|
2789 |
}
|
|
|
2790 |
}
|
|
|
2791 |
|
|
|
2792 |
@Override
|
|
|
2793 |
protected void onPostExecute(String result) {
|
|
|
2794 |
super.onPostExecute(result);
|
|
|
2795 |
}
|
|
|
2796 |
}
|
|
|
2797 |
|
|
|
2798 |
public void redirectPage(final AlertDialog builder) {
|
|
|
2799 |
Handler h = new Handler();
|
|
|
2800 |
h.postDelayed(new Runnable() {
|
|
|
2801 |
@Override
|
|
|
2802 |
public void run() {
|
|
|
2803 |
if (builder != null) {
|
|
|
2804 |
builder.dismiss();
|
|
|
2805 |
}
|
|
|
2806 |
userDataEditor.clear().commit();
|
|
|
2807 |
startActivity(new Intent(getActivity(), LoginActivity.class));
|
|
|
2808 |
}
|
|
|
2809 |
}, 3000);
|
|
|
2810 |
|
|
|
2811 |
}
|
|
|
2812 |
|
|
|
2813 |
public void sendQueuedResponse() {
|
|
|
2814 |
|
|
|
2815 |
List<List<NameValuePair>> postDataNameValuePair = new ArrayList<List<NameValuePair>>();
|
|
|
2816 |
postDataNameValuePair = orderDetails.readData1();
|
|
|
2817 |
for (List<NameValuePair> orderDetail : postDataNameValuePair) {
|
|
|
2818 |
orderDetail.add(new BasicNameValuePair("zip", "1"));
|
|
|
2819 |
orderDetail.add(new BasicNameValuePair("wifi", UtilityFunctions.checkWifi(getActivity()) + ""));
|
|
|
2820 |
orderDetail.add(new BasicNameValuePair("imeinumber", UtilityFunctions.getImeiNumber(getActivity())));
|
|
|
2821 |
orderDetail.add(new BasicNameValuePair("appversion", UtilityFunctions.getAppVersion(getActivity())));
|
|
|
2822 |
PushRawHTML pm = new PushRawHTML();
|
|
|
2823 |
pm.execute(orderDetail);
|
|
|
2824 |
}
|
|
|
2825 |
}
|
|
|
2826 |
|
|
|
2827 |
|
|
|
2828 |
class PaytmWebViewClient extends WebViewClient {
|
|
|
2829 |
@Override
|
|
|
2830 |
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
|
|
2831 |
super.onPageStarted(view, url, favicon);
|
|
|
2832 |
}
|
|
|
2833 |
|
|
|
2834 |
@Override
|
|
|
2835 |
public void onPageFinished(WebView view, String url) {
|
|
|
2836 |
super.onPageFinished(view, url);
|
|
|
2837 |
if (url.contains(apiData.getString("paytm.myorders.url", "paytm.com/myorders"))) {
|
|
|
2838 |
view.loadUrl("javascript:window.location='" + getPaytmUrl(url) + "';");
|
|
|
2839 |
} else {
|
|
|
2840 |
view.loadUrl("javascript:window.HTMLOUT.showHTML(document.getElementsByTagName('html')[0].innerHTML);");
|
|
|
2841 |
}
|
|
|
2842 |
}
|
|
|
2843 |
}
|
|
|
2844 |
|
|
|
2845 |
public String getPaytmUrl(String url) {
|
|
|
2846 |
String returnUrl = null;
|
|
|
2847 |
//Pattern p = Pattern.compile("[/]myorders/(\\d+)");
|
|
|
2848 |
Pattern p = Pattern.compile(apiData.getString("paytm.myorders.pattern", "[/]myorders/(\\d+)"));
|
|
|
2849 |
Matcher m = p.matcher(url);
|
|
|
2850 |
if (m.find()) {
|
|
|
2851 |
returnUrl = m.group(1);
|
|
|
2852 |
}
|
|
|
2853 |
System.out.println(apiData.getString("paytm.orderdetail.url", "https://paytm.com/shop/orderdetail/") + returnUrl + "?actions=1&channel=web&version=2");
|
|
|
2854 |
return apiData.getString("paytm.orderdetail.url", "https://paytm.com/shop/orderdetail/") + returnUrl + "?actions=1&channel=web&version=2";
|
|
|
2855 |
}
|
|
|
2856 |
|
|
|
2857 |
|
|
|
2858 |
public String getPaytmReferer(String url) {
|
|
|
2859 |
String returnUrl = null;
|
|
|
2860 |
Pattern p = Pattern.compile(apiData.getString("paytm.summary.pattern", "[/]summary/(\\d+)"));
|
|
|
2861 |
//Pattern p = Pattern.compile("[/]summary/(\\d+)");
|
|
|
2862 |
Matcher m = p.matcher(url);
|
|
|
2863 |
if (m.find()) {
|
|
|
2864 |
returnUrl = m.group(1);
|
|
|
2865 |
}
|
|
|
2866 |
System.out.println("In paytm Referer" + apiData.getString("paytm.myorders.url", "https://paytm.com/myorders/") + returnUrl);
|
|
|
2867 |
return apiData.getString("paytm.myorders.url", "https://paytm.com/myorders/") + returnUrl;
|
|
|
2868 |
}
|
|
|
2869 |
|
|
|
2870 |
|
|
|
2871 |
class PaytmOrderURL extends AsyncTask<String, Integer, JSONObject> {
|
|
|
2872 |
|
|
|
2873 |
@Override
|
|
|
2874 |
protected void onPreExecute() {
|
|
|
2875 |
super.onPreExecute();
|
|
|
2876 |
}
|
|
|
2877 |
|
|
|
2878 |
@Override
|
|
|
2879 |
protected JSONObject doInBackground(String... arg0) {
|
|
|
2880 |
HttpClient httpclient = new DefaultHttpClient();
|
|
|
2881 |
try {
|
|
|
2882 |
String fetchUrl = apiData.getString("amazon.order.tracking.get.url", null) + "?user_id=" + userData.getString("id", "") + "&store_id=" + UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code", "")), "paytm");
|
|
|
2883 |
HttpGet httppost = new HttpGet(fetchUrl);
|
|
|
2884 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
|
|
2885 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
2886 |
HttpEntity entity = response.getEntity();
|
|
|
2887 |
int status = response.getStatusLine().getStatusCode();
|
|
|
2888 |
|
|
|
2889 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
|
|
2890 |
return jObjGmail;
|
|
|
2891 |
} catch (JSONException e) {
|
|
|
2892 |
return null;
|
|
|
2893 |
} catch (ClientProtocolException e) {
|
|
|
2894 |
return null;
|
|
|
2895 |
} catch (IOException e) {
|
|
|
2896 |
e.printStackTrace();
|
|
|
2897 |
return null;
|
|
|
2898 |
}
|
|
|
2899 |
}
|
|
|
2900 |
|
|
|
2901 |
@Override
|
|
|
2902 |
protected void onPostExecute(JSONObject result) {
|
|
|
2903 |
super.onPostExecute(result);
|
|
|
2904 |
try {
|
|
|
2905 |
if (result != null) {
|
|
|
2906 |
if (result.length() == 0) {
|
|
|
2907 |
userDataEditor.putString("paytmOrder", "false").commit();
|
|
|
2908 |
} else {
|
|
|
2909 |
JSONArray js = result.getJSONArray("result");
|
|
|
2910 |
if (js.length() != 0) {
|
|
|
2911 |
strPaytmUrls = new ArrayList<>();
|
|
|
2912 |
strPaytmReferer = new ArrayList<>();
|
|
|
2913 |
for (int i = 0; i < js.length(); i++) {
|
|
|
2914 |
JSONObject paytmURLRef = js.getJSONObject(i);
|
|
|
2915 |
String url = paytmURLRef.getString("url");
|
|
|
2916 |
String referer = paytmURLRef.getString("referer");
|
|
|
2917 |
strPaytmUrls.add(url);
|
|
|
2918 |
strPaytmReferer.add(referer);
|
|
|
2919 |
}
|
|
|
2920 |
paytmOrderTracking(strPaytmUrls.get(0), strPaytmReferer.get(0));
|
|
|
2921 |
} else {
|
|
|
2922 |
userDataEditor.putString("paytmOrder", "false").commit();
|
|
|
2923 |
}
|
|
|
2924 |
}
|
|
|
2925 |
}
|
|
|
2926 |
} catch (Exception e) {
|
|
|
2927 |
e.printStackTrace();
|
|
|
2928 |
}
|
|
|
2929 |
|
|
|
2930 |
}
|
|
|
2931 |
}
|
|
|
2932 |
|
|
|
2933 |
|
|
|
2934 |
class PaytmOrderCreation extends AsyncTask<List<NameValuePair>, Integer, JSONObject> {
|
|
|
2935 |
|
|
|
2936 |
@Override
|
|
|
2937 |
protected void onPreExecute() {
|
|
|
2938 |
super.onPreExecute();
|
|
|
2939 |
}
|
|
|
2940 |
|
|
|
2941 |
@Override
|
|
|
2942 |
protected JSONObject doInBackground(List<NameValuePair>... orderDetail) {
|
|
|
2943 |
|
|
|
2944 |
|
|
|
2945 |
try {
|
|
|
2946 |
HttpClient httpclient = new DefaultHttpClient();
|
|
|
2947 |
HttpPost httppost = new HttpPost(apiData.getString("orderpagehtml.push.api", null));
|
|
|
2948 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
|
|
2949 |
httppost.setEntity(new UrlEncodedFormEntity(orderDetail[0]));
|
|
|
2950 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
2951 |
HttpEntity entity = response.getEntity();
|
|
|
2952 |
|
|
|
2953 |
int status = response.getStatusLine().getStatusCode();
|
|
|
2954 |
|
|
|
2955 |
if (status == 200) {
|
|
|
2956 |
NameValuePair y = orderDetail[0].get(2);
|
|
|
2957 |
int z = orderDetails.deleteRecord(y.getName(), new String[]{y.getValue()});
|
|
|
2958 |
} else {
|
|
|
2959 |
}
|
|
|
2960 |
String getJSON = EntityUtils.toString(entity);
|
|
|
2961 |
if (getJSON == null) {
|
|
|
2962 |
return null;
|
|
|
2963 |
} else {
|
|
|
2964 |
JSONObject jObjGmail = new JSONObject(getJSON);
|
|
|
2965 |
return jObjGmail;
|
|
|
2966 |
}
|
|
|
2967 |
} catch (Exception e) {
|
|
|
2968 |
return null;
|
|
|
2969 |
}
|
|
|
2970 |
}
|
|
|
2971 |
|
|
|
2972 |
|
|
|
2973 |
@Override
|
|
|
2974 |
protected void onPostExecute(JSONObject result) {
|
|
|
2975 |
if (result == null) {
|
|
|
2976 |
|
|
|
2977 |
} else {
|
|
|
2978 |
userDataEditor.putString("paytmOrder", "true").commit();
|
|
|
2979 |
userDataEditor.putLong("paytmNextFetchTime", System.currentTimeMillis() + 21600000).commit();
|
|
|
2980 |
try {
|
|
|
2981 |
if (result.getString("message").equalsIgnoreCase("PROCESSED"))
|
|
|
2982 |
orderDetails.deleterecords();
|
|
|
2983 |
} catch (Exception e) {
|
|
|
2984 |
}
|
|
|
2985 |
}
|
|
|
2986 |
super.onPostExecute(result);
|
|
|
2987 |
}
|
|
|
2988 |
}
|
|
|
2989 |
|
|
|
2990 |
public void paytmOrderTracking(List<String> paytmUrls, List<String> paytmReferers) {
|
|
|
2991 |
for (int i = 1; i < paytmReferers.size(); i++) {
|
|
|
2992 |
PaytmOrderTrackingClient paytmOrderTrackingClient = new PaytmOrderTrackingClient(paytmUrls.get(i));
|
|
|
2993 |
paytmWebView = new WebView(webView.getContext());
|
|
|
2994 |
paytmWebView.setVisibility(View.GONE);
|
|
|
2995 |
paytmWebView.addJavascriptInterface(new paytmInterface(getActivity()), "HTMLOUT");
|
|
|
2996 |
paytmWebView.getSettings().setJavaScriptEnabled(true);
|
|
|
2997 |
paytmWebView.loadUrl(paytmReferers.get(i));
|
|
|
2998 |
paytmWebView.setWebViewClient(paytmOrderTrackingClient);
|
|
|
2999 |
}
|
|
|
3000 |
userDataEditor.putLong("paytmNextFetchTime", System.currentTimeMillis() + 21600000).commit();
|
|
|
3001 |
}
|
|
|
3002 |
|
|
|
3003 |
public void paytmOrderTracking(String paytmUrl, String paytmReferer) {
|
|
|
3004 |
PaytmOrderTrackingClient paytmOrderTrackingClient = new PaytmOrderTrackingClient(paytmUrl);
|
|
|
3005 |
paytmWebView = new WebView(webView.getContext());
|
|
|
3006 |
paytmWebView.setVisibility(View.GONE);
|
|
|
3007 |
paytmWebView.addJavascriptInterface(new paytmInterface(getActivity()), "HTMLOUT");
|
|
|
3008 |
paytmWebView.getSettings().setJavaScriptEnabled(true);
|
|
|
3009 |
paytmWebView.loadUrl(paytmReferer);
|
|
|
3010 |
paytmWebView.setWebViewClient(paytmOrderTrackingClient);
|
|
|
3011 |
userDataEditor.putLong("paytmNextFetchTime", System.currentTimeMillis() + 21600000).commit();
|
|
|
3012 |
}
|
|
|
3013 |
|
|
|
3014 |
class PaytmOrderTrackingClient extends WebViewClient {
|
|
|
3015 |
String paytmUrlAfterReferer;
|
|
|
3016 |
|
|
|
3017 |
public PaytmOrderTrackingClient(String paytmUrl) {
|
|
|
3018 |
paytmUrlAfterReferer = paytmUrl;
|
|
|
3019 |
}
|
|
|
3020 |
|
|
|
3021 |
@Override
|
|
|
3022 |
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
|
|
3023 |
super.onPageStarted(view, url, favicon);
|
|
|
3024 |
}
|
|
|
3025 |
|
|
|
3026 |
@Override
|
|
|
3027 |
public void onPageFinished(WebView view, String url) {
|
|
|
3028 |
super.onPageFinished(view, url);
|
|
|
3029 |
if (url.contains(apiData.getString("paytm.myorders.url", "paytm.com/myorders"))) {
|
|
|
3030 |
view.loadUrl("javascript:window.location='" + paytmUrlAfterReferer + "';");
|
|
|
3031 |
} else {
|
|
|
3032 |
view.loadUrl("javascript:window.HTMLOUT.paytmTracking(document.getElementsByTagName('html')[0].innerHTML);");
|
|
|
3033 |
}
|
|
|
3034 |
}
|
|
|
3035 |
}
|
|
|
3036 |
|
|
|
3037 |
List<String> strPaytmUrls, strPaytmReferer;
|
|
|
3038 |
int paytmCounter = 0;
|
|
|
3039 |
|
|
|
3040 |
class PaytmPushTrackingUrls extends AsyncTask<List<NameValuePair>, Integer, JSONObject> {
|
|
|
3041 |
@Override
|
|
|
3042 |
protected void onPreExecute() {
|
|
|
3043 |
super.onPreExecute();
|
|
|
3044 |
}
|
|
|
3045 |
|
|
|
3046 |
@Override
|
|
|
3047 |
protected JSONObject doInBackground(List<NameValuePair>... pushOrder) {
|
|
|
3048 |
|
|
|
3049 |
try {
|
|
|
3050 |
HttpClient httpclient = new DefaultHttpClient();
|
|
|
3051 |
String fetchUrl = apiData.getString("amazon.order.tracking.post.url", null) + "?user_id=" + userData.getString("id", "") + "&store_id=" + "&store_id=" + UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code", "")), "paytm");
|
|
|
3052 |
HttpPost httppost = new HttpPost(fetchUrl);
|
|
|
3053 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
|
|
3054 |
httppost.setEntity(new UrlEncodedFormEntity(pushOrder[0]));
|
|
|
3055 |
HttpResponse response = httpclient.execute(httppost);
|
|
|
3056 |
HttpEntity entity = response.getEntity();
|
|
|
3057 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
|
|
3058 |
return jObjGmail;
|
|
|
3059 |
} catch (Exception e) {
|
|
|
3060 |
return null;
|
|
|
3061 |
}
|
|
|
3062 |
}
|
|
|
3063 |
|
|
|
3064 |
@Override
|
|
|
3065 |
protected void onPostExecute(JSONObject result) {
|
|
|
3066 |
super.onPostExecute(result);
|
|
|
3067 |
try {
|
|
|
3068 |
if (result == null) {
|
|
|
3069 |
|
|
|
3070 |
} else if (result.getString("result").equalsIgnoreCase("PARSE_ERROR")) {
|
|
|
3071 |
userDataEditor.putBoolean("paytmLoggedIn", false).commit();
|
|
|
3072 |
} else {
|
|
|
3073 |
paytmOrderTracking(strPaytmUrls, strPaytmReferer);
|
|
|
3074 |
}
|
|
|
3075 |
} catch (Exception e) {
|
|
|
3076 |
e.printStackTrace();
|
|
|
3077 |
}
|
|
|
3078 |
}
|
|
|
3079 |
}
|
|
|
3080 |
|
|
|
3081 |
class paytmInterface {
|
|
|
3082 |
|
|
|
3083 |
Context mContext;
|
|
|
3084 |
|
|
|
3085 |
public paytmInterface(Context c) {
|
|
|
3086 |
mContext = c;
|
|
|
3087 |
}
|
|
|
3088 |
|
|
|
3089 |
@JavascriptInterface
|
|
|
3090 |
public void showHTML(String html) {
|
|
|
3091 |
nameValuePairsRawHtml.add(new BasicNameValuePair("rawhtml", UtilityFunctions.compress(html)));
|
|
|
3092 |
long x = orderDetails.insertOrderDetails(nameValuePairsRawHtml);
|
|
|
3093 |
List<List<NameValuePair>> postDataNameValuePair = new ArrayList<List<NameValuePair>>();
|
|
|
3094 |
postDataNameValuePair = orderDetails.readData1();
|
|
|
3095 |
for (List<NameValuePair> orderDetail : postDataNameValuePair) {
|
|
|
3096 |
orderDetail.add(new BasicNameValuePair("zip", "1"));
|
|
|
3097 |
new PaytmOrderCreation().execute(orderDetail);
|
|
|
3098 |
}
|
|
|
3099 |
}
|
|
|
3100 |
|
|
|
3101 |
@JavascriptInterface
|
|
|
3102 |
public void paytmTracking(String html) {
|
|
|
3103 |
try {
|
|
|
3104 |
String url = strPaytmUrls.get(paytmCounter++);
|
|
|
3105 |
List<NameValuePair> amazonOrderHistory = new ArrayList<NameValuePair>();
|
|
|
3106 |
amazonOrderHistory.add(new BasicNameValuePair("url", url));
|
|
|
3107 |
amazonOrderHistory.add(new BasicNameValuePair("html", UtilityFunctions.compress(html)));
|
|
|
3108 |
amazonOrderHistory.add(new BasicNameValuePair("zip", "1"));
|
|
|
3109 |
if (isInternetOn()) {
|
|
|
3110 |
new PaytmPushTrackingUrls().execute(amazonOrderHistory);
|
|
|
3111 |
} else {
|
|
|
3112 |
|
|
|
3113 |
}
|
|
|
3114 |
} catch (Exception e) {
|
|
|
3115 |
e.printStackTrace();
|
|
|
3116 |
}
|
|
|
3117 |
|
|
|
3118 |
}
|
|
|
3119 |
}
|
|
|
3120 |
|
|
|
3121 |
public void onShareClick(String url) {
|
|
|
3122 |
try {
|
|
|
3123 |
List<Intent> targetShareIntents = new ArrayList<Intent>();
|
|
|
3124 |
Intent shareIntent = new Intent();
|
|
|
3125 |
shareIntent.setAction(Intent.ACTION_SEND);
|
|
|
3126 |
shareIntent.setType("text/plain");
|
|
|
3127 |
List<ResolveInfo> resInfos = getActivity().getPackageManager().queryIntentActivities(shareIntent, 0);
|
|
|
3128 |
if (!resInfos.isEmpty()) {
|
|
|
3129 |
for (ResolveInfo resInfo : resInfos) {
|
|
|
3130 |
String packageName = resInfo.activityInfo.packageName;
|
|
|
3131 |
Intent intent = new Intent();
|
|
|
3132 |
intent.setComponent(new ComponentName(packageName, resInfo.activityInfo.name));
|
|
|
3133 |
intent.setAction(Intent.ACTION_SEND);
|
|
|
3134 |
intent.setType("text/plain");
|
|
|
3135 |
intent.putExtra(Intent.EXTRA_TEXT, Uri.parse(url).getQueryParameter("message"));
|
|
|
3136 |
intent.setPackage(packageName);
|
|
|
3137 |
targetShareIntents.add(intent);
|
|
|
3138 |
}
|
|
|
3139 |
if (!targetShareIntents.isEmpty()) {
|
|
|
3140 |
Intent chooserIntent = Intent.createChooser(targetShareIntents.remove(0), "Choose app to share");
|
|
|
3141 |
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetShareIntents.toArray(new Parcelable[]{}));
|
|
|
3142 |
startActivity(chooserIntent);
|
|
|
3143 |
}
|
|
|
3144 |
}
|
|
|
3145 |
} catch (Exception e) {
|
|
|
3146 |
e.printStackTrace();
|
|
|
3147 |
}
|
|
|
3148 |
}
|
|
|
3149 |
|
|
|
3150 |
public void fetchAmazonOrder(String url) {
|
|
|
3151 |
pd1 = new ProgressDialog(getActivity());
|
|
|
3152 |
pd1.setTitle("Please wait");
|
|
|
3153 |
pd1.setMessage("Placing your order...");
|
|
|
3154 |
pd1.show();
|
|
|
3155 |
webView.post(new Runnable() {
|
|
|
3156 |
@Override
|
|
|
3157 |
public void run() {
|
|
|
3158 |
webView.loadUrl("javascript:window.HTMLOUT.showHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
|
|
3159 |
}
|
|
|
3160 |
});
|
|
|
3161 |
|
|
|
3162 |
}
|
|
|
3163 |
|
|
|
3164 |
@Override
|
|
|
3165 |
public void onPause() {
|
|
|
3166 |
super.onPause();
|
|
|
3167 |
if (apiData.getString("deal.redirect", "false").equalsIgnoreCase("true")) {
|
|
|
3168 |
if (webView != null) {
|
|
|
3169 |
if (isPause) {
|
| 22830 |
rajender |
3170 |
webView.loadUrl(apiData.getString("app.domain.profitmandi", "http://app.profitmandi.com"));
|
| 21480 |
rajender |
3171 |
isPause = false;
|
|
|
3172 |
}
|
|
|
3173 |
}
|
|
|
3174 |
}
|
|
|
3175 |
}
|
|
|
3176 |
|
|
|
3177 |
class FlipkartWebview extends WebViewClient {
|
|
|
3178 |
|
|
|
3179 |
@Override
|
|
|
3180 |
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
|
|
3181 |
super.onPageStarted(view, url, favicon);
|
|
|
3182 |
}
|
|
|
3183 |
|
|
|
3184 |
@Override
|
|
|
3185 |
public void onPageFinished(WebView view, String url) {
|
|
|
3186 |
super.onPageFinished(view, url);
|
|
|
3187 |
if(url.contains(apiData.getString("flipkart.response.url","https://www.flipkart.com/rv/accounts"))) {
|
|
|
3188 |
view.loadUrl("javascript:window.HTMLOUT.orderpage('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
|
|
3189 |
}
|
|
|
3190 |
|
|
|
3191 |
}
|
|
|
3192 |
}
|
|
|
3193 |
}
|