Ejemplo n.º 1
0
        private void ClearCookies()
        {
            var web = new Android.Webkit.WebView(MainActivity.Current);

            web.ClearCache(true);
            web.ClearHistory();
            web.Dispose();

#pragma warning disable 0618

            if (Build.VERSION.SdkInt >= BuildVersionCodes.LollipopMr1)
            {
                CookieManager.Instance.RemoveAllCookies(null);
                CookieManager.Instance.Flush();
            }
            else
            {
                var cookieSyncMngr = CookieSyncManager.CreateInstance(MainActivity.Current);
                cookieSyncMngr.StartSync();
                var cookieManager = CookieManager.Instance;
                cookieManager.RemoveAllCookie();
                cookieManager.RemoveSessionCookie();
                cookieSyncMngr.StopSync();
                cookieSyncMngr.Sync();
            }

#pragma warning restore 0618
        }
        private Task OnPrintCookiesRequested(IEnumerable <string> urls = null)
        {
            if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.LollipopMr1)
            {
                CookieManager.Instance.Flush();
            }
            else
            {
#pragma warning disable CS0618
                CookieSyncManager cookieSyncMngr = CookieSyncManager.CreateInstance(Context);
                cookieSyncMngr.Sync();
#pragma warning restore CS0618
            }
            if (!CookieManager.Instance.HasCookies)
            {
                return(Task.CompletedTask);
            }
            if (urls == null)
            {
                System.Diagnostics.Debug.WriteLine("Android must be given the cookie urls to iterate over");
            }
            foreach (var url in urls)
            {
                var cookie = CookieManager.Instance.GetCookie(url);
                System.Diagnostics.Debug.WriteLine($"Cookie for {url}: {cookie}");
            }
            return(Task.CompletedTask);
        }
Ejemplo n.º 3
0
        private async Task <string> OnGetAllCookieRequestAsync()
        {
            if (Control == null || Element == null)
            {
                return(string.Empty);
            }
            var cookies = string.Empty;

            if (Control != null && Element != null)
            {
                string url = string.Empty;
                try
                {
                    url = Control.Url;
                }catch (Exception e)
                {
                    url = Element.BaseUrl;
                }
                if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.LollipopMr1)
                {
                    CookieManager.Instance.Flush();
                    cookies = CookieManager.Instance.GetCookie(url);
                }
                else
                {
                    CookieSyncManager cookieSyncMngr = CookieSyncManager.CreateInstance(Context);
                    cookieSyncMngr.StartSync();
                    CookieManager cookieManager = CookieManager.Instance;
                    cookies = cookieManager.GetCookie(url);
                }
            }

            return(cookies);
        }
        private Task OnClearCookiesRequest()
        {
            if (Control == null || Control.Disposed)
            {
                return(Task.CompletedTask);
            }

            if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.LollipopMr1)
            {
                CookieManager.Instance.RemoveAllCookies(null);
                CookieManager.Instance.Flush();
            }
            else
            {
#pragma warning disable CS0618
                //CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(context);
                CookieSyncManager cookieSyncMngr = CookieSyncManager.CreateInstance(Context);
                cookieSyncMngr.StartSync();
                CookieManager cookieManager = CookieManager.Instance;
                cookieManager.RemoveAllCookie();
                cookieManager.RemoveSessionCookie();
                cookieSyncMngr.StopSync();
                cookieSyncMngr.Sync();
#pragma warning restore CS0618
            }
            _cookieDomains.Clear();
            return(Task.CompletedTask);
        }
        public Task ClearCookiesAsync()
        {
            var context = Android.App.Application.Context;

            if (Build.VERSION.SdkInt >= BuildVersionCodes.LollipopMr1)
            {
                System.Diagnostics.Debug.WriteLine("Clearing cookies for API >= LollipopMr1");
                CookieManager.Instance.RemoveAllCookies(null);
                CookieManager.Instance.Flush();
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Clearing cookies for API < LollipopMr1");
#pragma warning disable CS0618 // Type or member is obsolete
                var cookieSyncMngr = CookieSyncManager.CreateInstance(context);
#pragma warning restore CS0618 // Type or member is obsolete
                cookieSyncMngr.StartSync();
                var cookieManager = CookieManager.Instance;
                cookieManager.RemoveAllCookie();
                cookieManager.RemoveSessionCookie();
                cookieSyncMngr.StopSync();
                cookieSyncMngr.Sync();
            }

            return(Task.FromResult(true));
        }
Ejemplo n.º 6
0
        //disable CS0618, "This method is obsolete on Android". CookieSyncManager.CreateInstance is causing it, but we need it on older Android versions.
#pragma warning disable 0618
        public WebLayout(global::Android.Content.Context context) : base(context)
        {
            // required for pre-21 android
            CookieSyncManager.CreateInstance(context.ApplicationContext);

            CookieManager.Instance.RemoveAllCookie( );

            WebView = new WebView(context.ApplicationContext);
            //WebView = new WebView( context );
            WebView.Settings.SaveFormData = false;

            WebView.ClearFormData( );
            WebView.SetWebViewClient(new WebViewLayoutClient( )
            {
                Parent = this
            });
            WebView.Settings.JavaScriptEnabled = true;
            WebView.Settings.SetSupportZoom(true);
            WebView.Settings.BuiltInZoomControls  = true;
            WebView.Settings.LoadWithOverviewMode = true; //Load 100% zoomed out
            WebView.ScrollBarStyle         = ScrollbarStyles.OutsideOverlay;
            WebView.ScrollbarFadingEnabled = true;

            WebView.VerticalScrollBarEnabled   = true;
            WebView.HorizontalScrollBarEnabled = true;
            AddView(WebView);

            ProgressBar = new ProgressBar(context);
            ProgressBar.Indeterminate = true;
            ProgressBar.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(0));
            ProgressBar.LayoutParameters = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
            ((RelativeLayout.LayoutParams)ProgressBar.LayoutParameters).AddRule(LayoutRules.CenterInParent);
            AddView(ProgressBar);
            ProgressBar.BringToFront();
        }
        private Task OnClearCookiesRequest()
        {
            if (Control == null)
            {
                return(Task.CompletedTask);
            }

            if (Build.VERSION.SdkInt >= BuildVersionCodes.LollipopMr1)
            {
                CookieManager.Instance.RemoveAllCookies(null);
                CookieManager.Instance.Flush();
            }
            else
            {
                //CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(context);
                var cookieSyncMngr = CookieSyncManager.CreateInstance(Context);
                cookieSyncMngr.StartSync();
                var cookieManager = CookieManager.Instance;
                cookieManager.RemoveAllCookie();
                cookieManager.RemoveSessionCookie();
                cookieSyncMngr.StopSync();
                cookieSyncMngr.Sync();
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 8
0
        public void LogIn(string url, Action <RequestSecurityTokenResponse> onLoggedIn, Action assumeCancelled, string identityProviderName = null)
        {
            var appContext = Mvx.Resolve <IMvxAndroidGlobals>().ApplicationContext;

            CookieSyncManager.CreateInstance(appContext);

            var manager = CookieManager.Instance;

            if (manager != null)
            {
                manager.SetAcceptCookie(true);
            }

            _onLoggedIn        = onLoggedIn;
            _assumeCancelled   = assumeCancelled;
            _messageHub        = Mvx.Resolve <IMvxMessenger>();
            _subscriptionToken = _messageHub.Subscribe <RequestTokenMessage>(message =>
            {
                _response = message.TokenResponse;
            });

            var intent = new Intent(appContext, typeof(AccessControlWebAuthActivity));

            intent.PutExtra("cheesebaron.mvxplugins.azureaccesscontrol.droid.Url", url);

            StartActivityForResult(LoginIdentityRequestCode, intent);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Очистить куки
        /// </summary>
        public Task ClearCookiesAsync()
        {
            var context = Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity;

            // Если SDK больше, чем Android 5.1.1
            if (Build.VERSION.SdkInt >= BuildVersionCodes.LollipopMr1)
            {
                System.Diagnostics.Debug.WriteLine("Очистка куки для API >= 5.1.1");
                CookieManager.Instance.RemoveAllCookies(null);
                CookieManager.Instance.Flush();
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Очистка куки для API < 5.1.1");
#pragma warning disable 618
                var cookieSyncMngr = CookieSyncManager.CreateInstance(context);
                cookieSyncMngr.StartSync();
                var cookieManager = CookieManager.Instance;
                cookieManager.RemoveAllCookie();
                cookieManager.RemoveSessionCookie();
                cookieSyncMngr.StopSync();
                cookieSyncMngr.Sync();
#pragma warning restore 618
            }

            return(Task.FromResult(true));
        }
        private async Task <string> OnGetCookieRequestAsync(string key)
        {
            return(await Task.Run(() =>
            {
                var cookie = default(string);

                if (Control != null && Element != null)
                {
                    var url = string.Empty;
                    try
                    {
                        url = Control.Url;
                    }
                    catch (Exception e)
                    {
                        url = Element.BaseUrl;
                    }

                    string cookieCollectionString;
                    string[] cookieCollection;

                    try
                    {
                        if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.LollipopMr1)
                        {
                            CookieManager.Instance.Flush();
                            cookieCollectionString = CookieManager.Instance.GetCookie(url);
                        }
                        else
                        {
                            var cookieSyncMngr = CookieSyncManager.CreateInstance(Context);
                            cookieSyncMngr.StartSync();
                            var cookieManager = CookieManager.Instance;
                            cookieCollectionString = cookieManager.GetCookie(url);
                        }

                        cookieCollection = cookieCollectionString.Split(new string[] { "; " }, StringSplitOptions.None);

                        foreach (var c in cookieCollection)
                        {
                            var keyValue = c.Split(new[] { '=' }, 2);
                            if (keyValue.Length > 1 && keyValue[0] == key)
                            {
                                cookie = keyValue[1];
                                break;
                            }
                        }
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }

                return cookie;
            }));
        }
Ejemplo n.º 11
0
            public override void OnPageFinished(WebView view, string url)
            {
                if (Build.VERSION.SdkInt < Build.VERSION_CODES.Lollipop)
                {
                    CookieSyncManager.CreateInstance(context);
                }
                Android.Webkit.CookieManager cookieManager = CookieManager.Instance;
                string cookieStr = cookieManager.GetCookie("https://www.cnblogs.com/");

                if (string.IsNullOrWhiteSpace(cookieStr))
                {
                    return;
                }
                string[] cookieArray = cookieStr.Split(';');
                List <RestSharp.HttpCookie> cookieList = new List <RestSharp.HttpCookie>();

                foreach (var item in cookieArray)
                {
                    if (!string.IsNullOrWhiteSpace(item))
                    {
                        string cookieItemText       = item.Trim();
                        RestSharp.HttpCookie cookie = new RestSharp.HttpCookie();
                        int nameIndex = cookieItemText.IndexOf('=');
                        cookie.Name  = cookieItemText.Substring(0, nameIndex);
                        cookie.Value = cookieItemText.Substring(nameIndex + 1, cookieItemText.Length - nameIndex - 1);
                        cookieList.Add(cookie);
                    }
                }
                CookieSyncManager.Instance.Sync();
                List <HttpHeader> headers = new List <HttpHeader>();

                headers.Add(new HttpHeader()
                {
                    Name = "Host", Value = "www.cnblogs.com"
                });
                headers.Add(new HttpHeader()
                {
                    Name = "Origin", Value = "https://www.cnblogs.com"
                });
                headers.Add(new HttpHeader()
                {
                    Name = "X-Requested-With", Value = "XMLHttpRequest"
                });
                headers.Add(new HttpHeader()
                {
                    Name = "Referer", Value = "https://www.cnblogs.com/"
                });
                HttpClientUtil.PostWebHttp <WebResponseMessage, DiggBuryModel>("https://www.cnblogs.com/mvc/vote/VoteBlogPost.aspx", new DiggBuryModel("ansang", 9371764), headers, cookieList,
                                                                               (model) => {
                    System.Diagnostics.Debug.Write(model.Message);
                },
                                                                               (error) =>
                {
                    System.Diagnostics.Debug.Write(error);
                });
                base.OnPageFinished(view, url);
            }
Ejemplo n.º 12
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            _webView = FindViewById <WebView>(Resource.Id.webbrowser_view_webview);
            WebSettings settings = _webView.Settings;

            settings.JavaScriptEnabled = true;
            settings.SetAppCacheEnabled(true);
            settings.BuiltInZoomControls = true;
            settings.SetPluginState(WebSettings.PluginState.On);

            _webView.SetWebChromeClient(new WebChromeClient());

            CookieSyncManager.CreateInstance(this);
            CookieManager cookieManager = CookieManager.Instance;

            cookieManager.RemoveSessionCookie();
            String cookieString = "param=value";

            cookieManager.SetCookie("https://thebridge.spaces.nexudus.com/", cookieString);
            CookieSyncManager.Instance.Sync();

            var abc = new Dictionary <String, String> {
                ["Cookie"] = cookieString
            };

            _webView.LoadUrl(ViewModel.Url, abc);

            try
            {
                if (!string.IsNullOrEmpty(ViewModel.Url))
                {
                    _webView?.SetWebViewClient(new WebViewClient());
                    _webView?.LoadUrl(ViewModel.Url);
                }
            }
            catch (Exception ex)
            {
                Mvx.Resolve <IExceptionService>().HandleException(ex);
            }

            _urlChangedListener = new MvxPropertyChangedListener(ViewModel).Listen(() => ViewModel.Url, () =>
            {
                RunOnUiThread(() =>
                {
                    _webView.StopLoading();
                    _webView.LoadUrl(ViewModel.Url);
                });
            });
        }
        protected override void OnElementChanged(ElementChangedEventArgs <FormsWebView> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                CookieSyncManager cookieSyncManager = CookieSyncManager.CreateInstance(Control.Context);
                CookieManager     cookieManager     = CookieManager.Instance;
                cookieManager.SetAcceptCookie(true);
                cookieManager.RemoveSessionCookie();
                cookieManager.RemoveAllCookie();
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Clears all cookies.
        /// </summary>
        /// <seealso cref="ClearCookiesBeforeLogin"/>
        public static void ClearCookies()
        {
#if PLATFORM_IOS
            var store   = NSHttpCookieStorage.SharedStorage;
            var cookies = store.Cookies;
            foreach (var c in cookies)
            {
                store.DeleteCookie(c);
            }
#elif PLATFORM_ANDROID
            CookieSyncManager.CreateInstance(Application.Context);
            CookieManager.Instance.RemoveAllCookie();
#endif
        }
Ejemplo n.º 15
0
        public void ClearAllBrowserCaches()
        {
            var appContext = Mvx.Resolve <IMvxAndroidGlobals>().ApplicationContext;

            CookieSyncManager.CreateInstance(appContext);

            var manager = CookieManager.Instance;

            if (manager == null)
            {
                return;
            }
            if (manager.HasCookies)
            {
                manager.RemoveAllCookie();
            }
        }
Ejemplo n.º 16
0
 public void ClearCookies()
 {
     if ((int)Build.VERSION.SdkInt >= (int)Android.OS.BuildVersionCodes.LollipopMr1)
     {
         CookieManager.Instance.RemoveAllCookies(null);
         CookieManager.Instance.Flush();
     }
     else
     {
         CookieSyncManager cookieSyncMngr = CookieSyncManager.CreateInstance(Context);
         cookieSyncMngr.StartSync();
         CookieManager cookieManager = CookieManager.Instance;
         cookieManager.RemoveAllCookie();
         cookieManager.RemoveSessionCookie();
         cookieSyncMngr.StopSync();
         cookieSyncMngr.Sync();
     }
 }
Ejemplo n.º 17
0
        public void ClearCookies()
        {
            if (Build.VERSION.SdkInt >= BuildVersionCodes.LollipopMr1)
            {
                CookieManager.Instance.RemoveAllCookies(null);
                CookieManager.Instance.Flush();
            }
            else
            {
#pragma warning disable CS0618 // Тип или член устарел
                CookieSyncManager cookieSyncMngr = CookieSyncManager.CreateInstance(MainActivity.Instance.ApplicationContext);
#pragma warning restore CS0618
                cookieSyncMngr.StartSync();
                CookieManager cookieManager = CookieManager.Instance;
                cookieManager.RemoveAllCookie();
                cookieManager.RemoveSessionCookie();
                cookieSyncMngr.StopSync();
                cookieSyncMngr.Sync();
            }
        }
        void DeleteCookies(object sender, EventArgs e)
        {
            string domain = (string)sender;

            // TODO Don't remove all cookies or cache, but domain-specific
#if __ANDROID__
            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
            {
                CookieManager.Instance.RemoveAllCookies(null);
                CookieManager.Instance.Flush();
            }
            else
            {
                CookieSyncManager manager = CookieSyncManager.CreateInstance(Forms.Context);
                manager.StartSync();

                CookieManager.Instance.RemoveAllCookie();
                CookieManager.Instance.RemoveSessionCookie();

                manager.StopSync();
                manager.Sync();
            }
#elif __IOS__
            var cache = Foundation.NSUrlCache.SharedCache;
            cache.RemoveAllCachedResponses();
            cache.DiskCapacity   = 0;
            cache.MemoryCapacity = 0;

            EvaluateJavascript("localStorage.clear();");

            var jar = Foundation.NSHttpCookieStorage.SharedStorage;

            foreach (var cookie in jar.Cookies)
            {
                if (cookie.Domain.Contains(domain))
                {
                    jar.DeleteCookie(cookie);
                }
            }
#endif
        }
Ejemplo n.º 19
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            StatusBarCompat.SetOrdinaryToolBar(this);
            handler        = new Handler();
            loginPresenter = new LoginPresenter(this);
            toolbar        = FindViewById <Toolbar>(Resource.Id.toolbar);
            toolbar.SetNavigationIcon(Resource.Drawable.back_24dp);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            toolbar.SetNavigationOnClickListener(this);

            progressBar     = FindViewById <ProgressBar>(Resource.Id.progressBar);
            progressBar.Max = 100;
            dialog          = new ProgressDialog(this);
            dialog.SetCancelable(false);
            dialog.SetMessage("正在获取token");

            loginView = FindViewById <WebView>(Resource.Id.loginView);
            loginView.Settings.JavaScriptEnabled = true;
            loginView.Settings.SetSupportZoom(true);
            loginView.Settings.BuiltInZoomControls = true;
            loginView.Settings.CacheMode           = CacheModes.NoCache;
            loginView.ClearHistory();
            loginView.ClearFormData();
            loginView.ClearCache(true);
            loginView.SetWebChromeClient(new LoginWebChromeClient(progressBar));
            loginView.SetWebViewClient(new LoginWebViewClient(this));

            CookieSyncManager cookieSyncManager = CookieSyncManager.CreateInstance(loginView.Context);
            CookieManager     cookieManager     = CookieManager.Instance;

            cookieManager.SetAcceptCookie(true);
            cookieManager.RemoveSessionCookie();
            cookieManager.RemoveAllCookie();

            loginView.LoadUrl(string.Format(ApiUtils.Authorize, Resources.GetString(Resource.String.ClientId)) + new Random().Next(1000, 9999));
        }
Ejemplo n.º 20
0
        //private static void ScheduleAppRestart(Context context)
        //{
        //    Intent intent = context.PackageManager.GetLaunchIntentForPackage(context.PackageName);
        //    intent.PutExtra("logOut", true);
        //    intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.ClearTask | ActivityFlags.NewTask);
        //    PendingIntent pendingIntent = PendingIntent.GetActivity(MainApplication.GetInstance().BaseContext, 0, intent, PendingIntentFlags.OneShot);
        //    AlarmManager mgr = (AlarmManager)MainApplication.GetInstance().BaseContext.GetSystemService(Context.AlarmService);
        //    mgr.Set(AlarmType.Rtc, JavaSystem.CurrentTimeMillis() + 1000, pendingIntent);
        //}

        public static void ClearWebViewCache(Context context)
        {
            var mWebView = new WebView(context);

            mWebView.ClearCache(true);
            mWebView.ClearHistory();

            if (Build.VERSION.SdkInt >= BuildVersionCodes.LollipopMr1)
            {
                CookieManager.Instance.RemoveAllCookies(null);
                CookieManager.Instance.Flush();
            }
            else
            {
                CookieSyncManager cookieSyncMngr = CookieSyncManager.CreateInstance(context);
                cookieSyncMngr.StartSync();
                CookieManager cookieManager = CookieManager.Instance;
                cookieManager.RemoveAllCookie();
                cookieManager.RemoveSessionCookie();
                cookieSyncMngr.StopSync();
                cookieSyncMngr.Sync();
            }
        }
        private Task OnAddCookieRequested(System.Net.Cookie cookie)
        {
            if (Control == null || cookie == null || String.IsNullOrEmpty(cookie.Domain) || String.IsNullOrEmpty(cookie.Name))
            {
                return(Task.CompletedTask);
            }
            if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.LollipopMr1)
            {
                SetCookie(cookie);
                CookieManager.Instance.Flush();
            }
            else
            {
#pragma warning disable CS0618
                CookieSyncManager cookieSyncMngr = CookieSyncManager.CreateInstance(Context);
                cookieSyncMngr.StartSync();
                SetCookie(cookie);
                cookieSyncMngr.StopSync();
                cookieSyncMngr.Sync();
#pragma warning restore CS0618
            }
            return(Task.CompletedTask);
        }
Ejemplo n.º 22
0
        public Task ClearCookiesAsync()
        {
            var context = Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity;

            if (Build.VERSION.SdkInt >= BuildVersionCodes.LollipopMr1)
            {
                System.Diagnostics.Debug.WriteLine("Clearing cookies for API >= LollipopMr1");
                CookieManager.Instance.RemoveAllCookies(null);
                CookieManager.Instance.Flush();
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Clearing cookies for API < LollipopMr1");
                CookieSyncManager cookieSyncMngr = CookieSyncManager.CreateInstance(context);
                cookieSyncMngr.StartSync();
                CookieManager cookieManager = CookieManager.Instance;
                cookieManager.RemoveAllCookie();
                cookieManager.RemoveSessionCookie();
                cookieSyncMngr.StopSync();
                cookieSyncMngr.Sync();
            }

            return(Task.FromResult(true));
        }
Ejemplo n.º 23
0
        private async Task OnClearCookiesRequest()
        {
            if (Control == null || Control.Disposed)
            {
                return;
            }

            if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.LollipopMr1)
            {
                CookieManager.Instance.RemoveAllCookies(null);
                CookieManager.Instance.Flush();
            }
            else
            {
                //CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(context);
                CookieSyncManager cookieSyncMngr = CookieSyncManager.CreateInstance(Context);
                cookieSyncMngr.StartSync();
                CookieManager cookieManager = CookieManager.Instance;
                cookieManager.RemoveAllCookie();
                cookieManager.RemoveSessionCookie();
                cookieSyncMngr.StopSync();
                cookieSyncMngr.Sync();
            }
        }
Ejemplo n.º 24
0
            public override void OnPageStarted(WebView view, string url, Android.Graphics.Bitmap favicon)
            {
                base.OnPageStarted(view, url, favicon);

                if (url.StartsWith(AppInfo._loginRedirectUri))
                {
                    _progressDialogMessage.Text = "Авторизация...";
                    if (!AppInfo.IsLocaleRu)
                    {
                        _progressDialogMessage.Text = "Authorization...";
                    }
                    _loginWebView.Visibility = ViewStates.Gone;
                }
                if (url.Contains("//m.facebook.com/home.php?_rdr"))
                {
                    _loginWebView.Visibility = ViewStates.Invisible;
                    CookieSyncManager.CreateInstance(_parent);
                    CookieManager cookieManager = CookieManager.Instance;
                    cookieManager.RemoveAllCookie();

                    _loginWebView.ClearHistory();
                    _loginWebView.Dispose();
                    _parent.Finish();
                    _parent.StartActivity(typeof(LoginActivity));
                }
                else
                {
                    _progressDialogMessage.Text = "Загрузка...";
                    if (!AppInfo.IsLocaleRu)
                    {
                        _progressDialogMessage.Text = "Loading...";
                    }
                }

                _progressDialog.Show();
            }
Ejemplo n.º 25
0
        private async Task <string> OnSetCookieRequestAsync(Cookie cookie)
        {
            if (Control != null && Element != null)
            {
                var url = new Uri(Control.Url).Host;
                if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.LollipopMr1)
                {
                    CookieManager.Instance.SetCookie(url, cookie.ToString());
                    CookieManager.Instance.Flush();
                }
                else
                {
                    CookieSyncManager cookieSyncMngr = CookieSyncManager.CreateInstance(Context);
                    cookieSyncMngr.StartSync();
                    CookieManager cookieManager = CookieManager.Instance;
                    cookieManager.SetCookie(url, cookie.ToString());
                    cookieManager.Flush();
                }
            }

            var toReturn = await OnGetCookieRequestAsync(cookie.Name);

            return(toReturn);
        }
Ejemplo n.º 26
0
        protected internal override void onCreate(Bundle savedInstanceState)
        {
            // When extending the BrightcovePlayer, we must assign the BrightcoveVideoView
            // before entering the superclass. This allows for some stock video player lifecycle
            // management.
            ContentView         = R.layout.ais_activity_main;
            brightcoveVideoView = (BrightcoveVideoView)findViewById(R.id.brightcove_video_view);
            eventEmitter        = brightcoveVideoView.EventEmitter;
            base.onCreate(savedInstanceState);

            platformId = Resources.getString([email protected]_id);
            baseUrl    = Resources.getString([email protected]_url);

            // Basic REST API Calls (minimum required)
            initUrl                  = baseUrl + platformId + "/init/";
            chooseIdpUrl             = baseUrl + platformId + "/chooser";
            authorizationResourceUrl = baseUrl + platformId + "/identity/resourceAccess/";
            singleLogoutUrl          = baseUrl + platformId + "/slo/";

            // Initialize our cookie syncing mechanism for the webview and start the
            // authorization workflow.
            CookieSyncManager.createInstance(this);
            (new GetIdentityProvidersAsyncTask(this)).execute(chooseIdpUrl);
        }
 public void ClearCookies()
 {
     CookieSyncManager.CreateInstance(Android.App.Application.Context);
     Android.Webkit.CookieManager.Instance.RemoveAllCookie();
 }
Ejemplo n.º 28
0
        public static void log_out(Activity context)
        {
            //string dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ormdemo.db3");
            //var db = new SQLiteConnection(dbPath);
            //var docs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            //var cards_cache_dir = Path.Combine(docs, Constants.CardsPersonalImages);
            //var logo_cache_dir = Path.Combine(docs, Constants.CardsLogo);



            #region clearing tables, variables and photos
            var taskA = new Task(async() =>
            {
                await _nativeMethods.RemovePersonalImages();
                await _nativeMethods.RemoveLogo();
                await _nativeMethods.RemoveOfflineCache();
                //var QRs_cache_dir = Path.Combine(docs, Constants.QRs_cache_dir);
            });
            taskA.Start();
            NativeMethods.ResetSocialNetworkList();
            _databaseMethods.CleanPersonalNetworksTable();
            _databaseMethods.ClearCompanyCardTable();
            _databaseMethods.ClearUsersCardTable();
            _databaseMethods.ClearValidTillRepeatAfterTable();
            _databaseMethods.CleanCloudSynTable();
            _databaseMethods.CleanCardNames();
            _databaseMethods.CleanEtagTable();
            //clearing table
            try
            {
                _databaseMethods.CleanDifferentPurposesTable();
            }
            catch { }

            //clearing table
            try
            {
                _databaseMethods.CleanLoginAfterTable();
            }
            catch { }

            //clearing table
            try
            {
                _databaseMethods.CleanLoginedFromTable();
            }
            catch { }

            //CompanyDataActivity.currentImage = null;
            CompanyDataActivity.CroppedResult = null;
            //CompanyAddressMapViewController.lat = null;
            //CompanyAddressMapViewController.lng = null;
            CompanyAddressMapActivity.CompanyLat            = null;
            CompanyAddressMapActivity.CompanyLng            = null;
            CompanyAddressActivity.FullCompanyAddressStatic = null;
            CompanyAddressActivity.Country       = null;
            CompanyAddressActivity.Region        = null;
            CompanyAddressActivity.City          = null;
            CompanyAddressActivity.Index         = null;
            CompanyAddressActivity.Notation      = null;
            CompanyDataActivity.CompanyName      = null;
            CompanyDataActivity.LinesOfBusiness  = null;
            CompanyDataActivity.Position         = null;
            CompanyDataActivity.FoundationYear   = null;
            CompanyDataActivity.Clients          = null;
            CompanyDataActivity.CompanyPhone     = null;
            CompanyDataActivity.CorporativePhone = null;
            CompanyDataActivity.Fax             = null;
            CompanyDataActivity.CompanyEmail    = null;
            CompanyDataActivity.CorporativeSite = null;
            PersonalDataActivity.MySurname      = null;
            PersonalDataActivity.MyName         = null;
            PersonalDataActivity.MyMiddlename   = null;
            PersonalDataActivity.MyPhone        = null;
            PersonalDataActivity.MyEmail        = null;
            PersonalDataActivity.MyHomePhone    = null;
            PersonalDataActivity.MySite         = null;
            PersonalDataActivity.MyDegree       = null;
            PersonalDataActivity.MyCardName     = null;
            try { PersonalImageAdapter.Photos.Clear(); } catch { }
            PersonalDataActivity.MyBirthdate = null;
            NativeMethods.ResetHomeAddress();
            NativeMethods.ResetCompanyAddress();
            try { CreatingCardActivity.Datalist.Clear(); } catch { }
            try { QrActivity.CardNames.Clear(); } catch { }
            EditCompanyDataActivity.Position          = null;
            EditCompanyDataActivity.LogoId            = null;
            QrActivity.CardsRemaining                 = 0;
            QrActivity.IsPremium                      = false;
            QrActivity.ExtraPersonData                = null;
            QrActivity.ExtraEmploymentData            = null;
            QrActivity.CompanyLogoInQr                = null;
            WaitingEmailConfirmActivity.CameFromPurge = false;
            //clearing webView cookies
            CookieSyncManager.CreateInstance(context);
            CookieManager cookieManager = CookieManager.Instance;
            cookieManager.RemoveAllCookies(null);
            #endregion clearing tables, variables and photos
        }
Ejemplo n.º 29
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            buttonClickAnimation = AnimationUtils.LoadAnimation(this, global::Android.Resource.Animation.FadeIn);
            SetContentView(Resource.Layout.profilescreenactivitylayout);
            TextView profileTitle = FindViewById <TextView>(Resource.Id.profilescr_profiletextView);

            _flurryClient = new FlurryClient();



            RelativeLayout exitDialogRelativeLayout = new RelativeLayout(this);
            LayoutInflater exitDialoglayoutInflater = (LayoutInflater)BaseContext.GetSystemService(LayoutInflaterService);
            View           exitDialogView           = exitDialoglayoutInflater.Inflate(Resource.Layout.exitdialoglayout, null);

            Button   exitDialogCancelButton  = (Button)exitDialogView.FindViewById(Resource.Id.cancelButton);
            Button   exitDialogReadyButton   = (Button)exitDialogView.FindViewById(Resource.Id.readyButton);
            TextView exitTitleTextView       = (TextView)exitDialogView.FindViewById(Resource.Id.textView1);
            TextView exitDialogDescrTextView = (TextView)exitDialogView.FindViewById(Resource.Id.textView2);

            exitDialogRelativeLayout.AddView(exitDialogView);
            Dialog exitDialog = new Dialog(this, Resource.Style.FullHeightDialog);

            exitDialog.SetTitle("");
            exitDialog.SetContentView(exitDialogRelativeLayout);


            _context = this;

            Typeface font = Typeface.CreateFromAsset(this.Assets, "Roboto-Light.ttf");

            ImageButton logoutImageButton = FindViewById <ImageButton>(Resource.Id.profilescr_NavBar_LogoutImageButton);
            Button      logoutButtonFake  = FindViewById <Button>(Resource.Id.profilescr_logiutbuttonfake);
            Vibrator    vibe = (Vibrator)_context.GetSystemService(Context.VibratorService);

            logoutButtonFake.Click += delegate
            {
                logoutImageButton.StartAnimation(buttonClickAnimation);
                vibe.Vibrate(50);
                exitDialog.Show();
            };


            exitDialogCancelButton.Click += delegate { exitDialog.Dismiss(); vibe.Vibrate(50); };

            exitDialogReadyButton.Click += delegate
            {
                vibe.Vibrate(150);
                CookieSyncManager.CreateInstance(this);
                CookieManager cookieManager = CookieManager.Instance;
                cookieManager.RemoveAllCookie();

                File.Delete(@"/data/data/ru.hintsolutions.itsbeta/data.txt");
                itsbeta.achievements.LoginWebActivity.ItsbetaLoginWebViewClient.loadPreviousState = false;
                MainScreenActivity._isLogout = true;
                Finish();
            };



            TextView userFullname          = FindViewById <TextView>(Resource.Id.profilescr_usernameTextView);
            TextView userData              = FindViewById <TextView>(Resource.Id.profilescr_userAgelocTextView);
            TextView statText              = FindViewById <TextView>(Resource.Id.profilescr_statTextView);
            TextView allBadgesTextView     = FindViewById <TextView>(Resource.Id.profilescr_allBadgesTextView);
            TextView bonusesTextView       = FindViewById <TextView>(Resource.Id.textView2);
            TextView subCategoriesTextView = FindViewById <TextView>(Resource.Id.textView3);


            //profilescr_allBadgesTextView
            TextView badgesCount        = FindViewById <TextView>(Resource.Id.profilescr_allbadgescountTextView);
            TextView bonusesCount       = FindViewById <TextView>(Resource.Id.profilescr_bonusCountTextView);
            TextView subCategoriesCount = FindViewById <TextView>(Resource.Id.profilescr_subcategCountTextView);

            statText.SetTypeface(font, TypefaceStyle.Normal);
            userFullname.SetTypeface(font, TypefaceStyle.Normal);
            allBadgesTextView.SetTypeface(font, TypefaceStyle.Normal);
            bonusesTextView.SetTypeface(font, TypefaceStyle.Normal);
            subCategoriesTextView.SetTypeface(font, TypefaceStyle.Normal);


            userFullname.Text = AppInfo._user.Fullname;
            userData.Text     = GetUserAge(AppInfo._user.BirthDate) + ", " + AppInfo._user.City;


            if (!AppInfo.IsLocaleRu)
            {
                exitDialogCancelButton.Text  = "Cancel";
                exitDialogReadyButton.Text   = "Yes";
                exitTitleTextView.Text       = "Confirm";
                exitDialogDescrTextView.Text = "Do you really want to exit from current profile?";

                profileTitle.Text          = "PROFILE";
                statText.Text              = "Statistic";
                allBadgesTextView.Text     = "All Badges:";
                bonusesTextView.Text       = "Bonuses:";
                subCategoriesTextView.Text = "Subcategories:";
            }

            badgesCount.Text        = AppInfo._badgesCount.ToString();
            bonusesCount.Text       = AppInfo._bonusesCount.ToString();
            subCategoriesCount.Text = AppInfo._subcategCount.ToString();
        }