Subversion Repositories SmartDukaan

Rev

Rev 16452 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16452 Rev 17056
Line 1... Line 1...
1
package com.saholic.profittill.main;
1
package com.saholic.profittill.main;
2
 
2
 
3
import android.app.AlertDialog;
3
import android.app.AlertDialog;
4
import android.app.Fragment;
4
import android.app.Fragment;
5
import android.app.ProgressDialog;
5
import android.app.ProgressDialog;
-
 
6
import android.content.ComponentName;
6
import android.content.Context;
7
import android.content.Context;
7
import android.content.DialogInterface;
8
import android.content.DialogInterface;
8
import android.content.Intent;
9
import android.content.Intent;
9
import android.content.SharedPreferences;
10
import android.content.SharedPreferences;
10
import android.content.pm.PackageManager;
11
import android.content.pm.PackageManager;
-
 
12
import android.content.pm.ResolveInfo;
11
import android.graphics.Bitmap;
13
import android.graphics.Bitmap;
12
import android.net.ConnectivityManager;
14
import android.net.ConnectivityManager;
13
import android.net.Uri;
15
import android.net.Uri;
14
import android.os.AsyncTask;
16
import android.os.AsyncTask;
15
import android.os.Build;
17
import android.os.Build;
16
import android.os.Bundle;
18
import android.os.Bundle;
17
import android.os.Handler;
19
import android.os.Handler;
-
 
20
import android.os.Parcelable;
18
import android.util.Base64;
21
import android.util.Base64;
19
import android.util.Log;
22
import android.util.Log;
20
import android.view.KeyEvent;
23
import android.view.KeyEvent;
21
import android.view.LayoutInflater;
24
import android.view.LayoutInflater;
22
import android.view.View;
25
import android.view.View;
Line 188... Line 191...
188
              CookieManager cookieManager1 = CookieManager.getInstance();
191
              CookieManager cookieManager1 = CookieManager.getInstance();
189
              cookieManager1.setCookie(url, "token=" + userData.getString("token", ""));
192
              cookieManager1.setCookie(url, "token=" + userData.getString("token", ""));
190
              cookieManager1.setCookie(url, "walletAuthentication=true");
193
              cookieManager1.setCookie(url, "walletAuthentication=true");
191
              cookieManager1.setCookie(url, "shopcluesActive=true");
194
              cookieManager1.setCookie(url, "shopcluesActive=true");
192
              cookieManager1.setCookie(url, "paytmActive=true");
195
              cookieManager1.setCookie(url, "paytmActive=true");
-
 
196
              cookieManager1.setCookie(url, "shareApps=true");
193
          }
197
          }
194
          if(!(userData.getBoolean("paytmLoggedIn",false))){
198
          if(!(userData.getBoolean("paytmLoggedIn",false))){
195
             Log.d("User Not Logged In","User Not logged In");
199
             Log.d("User Not Logged In","User Not logged In");
196
          }else {
200
          }else {
197
              if (userData.getString("paytmOrder", "").equalsIgnoreCase("true")) {
201
              if (userData.getString("paytmOrder", "").equalsIgnoreCase("true")) {
Line 260... Line 264...
260
        }
264
        }
261
 
265
 
262
        @Override
266
        @Override
263
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
267
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
264
 
268
 
-
 
269
 
-
 
270
            if(url.contains("apprub")){
-
 
271
                onShareClick(url);
-
 
272
                return true;
-
 
273
            }
265
            if(url.contains(apiData.getString("wallet.auth","api.profittill.com/special/native/login")) || userData.getString("id","").isEmpty()){
274
            if(url.contains(apiData.getString("wallet.auth","api.profittill.com/special/native/login")) || userData.getString("id","").isEmpty()){
266
                android.webkit.CookieManager cookieManager = android.webkit.CookieManager.getInstance();
275
                android.webkit.CookieManager cookieManager = android.webkit.CookieManager.getInstance();
267
                android.webkit.CookieSyncManager.createInstance(getActivity());
276
                android.webkit.CookieSyncManager.createInstance(getActivity());
268
                cookieManager.removeAllCookie();
277
                cookieManager.removeAllCookie();
269
                AlertDialog alert;
278
                AlertDialog alert;
Line 330... Line 339...
330
                        CookieManager cookieManager = CookieManager.getInstance();
339
                        CookieManager cookieManager = CookieManager.getInstance();
331
                        cookieManager.setCookie(url, "token=" + userData.getString("token", ""));
340
                        cookieManager.setCookie(url, "token=" + userData.getString("token", ""));
332
                        cookieManager.setCookie(url, "walletAuthentication=true");
341
                        cookieManager.setCookie(url, "walletAuthentication=true");
333
                        cookieManager.setCookie(url, "shopcluesActive=true");
342
                        cookieManager.setCookie(url, "shopcluesActive=true");
334
                        cookieManager.setCookie(url, "paytmActive=true");
343
                        cookieManager.setCookie(url, "paytmActive=true");
-
 
344
                        cookieManager.setCookie(url, "shareApps=true");
335
                    }
345
                    }
336
                    if(url.contains("dl.flipkart.com/dl/")){
346
                    if(url.contains("dl.flipkart.com/dl/")){
337
                        flipkartUrl=url;
347
                        flipkartUrl=url;
338
 
348
 
339
                        if(flipkartData.getInt("showagainflag",0)<3) {
349
                        if(flipkartData.getInt("showagainflag",0)<3) {
Line 2004... Line 2014...
2004
                e.printStackTrace();
2014
                e.printStackTrace();
2005
            }
2015
            }
2006
 
2016
 
2007
        }
2017
        }
2008
    }
2018
    }
-
 
2019
 
-
 
2020
    public void onShareClick(String url){
-
 
2021
        try {
-
 
2022
            List<Intent> targetShareIntents = new ArrayList<Intent>();
-
 
2023
            Intent shareIntent = new Intent();
-
 
2024
            shareIntent.setAction(Intent.ACTION_SEND);
-
 
2025
            shareIntent.setType("text/plain");
-
 
2026
            List<ResolveInfo> resInfos = getActivity().getPackageManager().queryIntentActivities(shareIntent, 0);
-
 
2027
            if (!resInfos.isEmpty()) {
-
 
2028
                for (ResolveInfo resInfo : resInfos) {
-
 
2029
                    String packageName = resInfo.activityInfo.packageName;
-
 
2030
                    Intent intent = new Intent();
-
 
2031
                    intent.setComponent(new ComponentName(packageName, resInfo.activityInfo.name));
-
 
2032
                    intent.setAction(Intent.ACTION_SEND);
-
 
2033
                    intent.setType("text/plain");
-
 
2034
                    intent.putExtra(Intent.EXTRA_TEXT, Uri.parse(url).getQueryParameter("message"));
-
 
2035
                    intent.setPackage(packageName);
-
 
2036
                    targetShareIntents.add(intent);
-
 
2037
                }
-
 
2038
                if (!targetShareIntents.isEmpty()) {
-
 
2039
                    Intent chooserIntent = Intent.createChooser(targetShareIntents.remove(0), "Choose app to share");
-
 
2040
                    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetShareIntents.toArray(new Parcelable[]{}));
-
 
2041
                    startActivity(chooserIntent);
-
 
2042
                }
-
 
2043
            }
-
 
2044
        }catch (Exception e){
-
 
2045
            e.printStackTrace();
-
 
2046
        }
-
 
2047
    }
2009
}
2048
}