Beispiel #1
0
        public MSProApp()
        {
            Version = "1.1";

            StatusPage       = (StatusPage)FreshPageModelResolver.ResolvePageModel <StatusViewModel>();
            StatusPage.Title = Translation.GetString("Status");
            StatusVM         = (StatusViewModel)StatusPage.BindingContext;

            CountriesPage       = (CountriesPage)FreshPageModelResolver.ResolvePageModel <CountriesViewModel>();
            CountriesPage.Title = Translation.GetString("Countries");
            CountriesVM         = (CountriesViewModel)CountriesPage.BindingContext;

            CitiesPage       = (CitiesPage)FreshPageModelResolver.ResolvePageModel <CitiesViewModel>();
            CitiesPage.Title = Translation.GetString("Cities");
            CitiesVM         = (CitiesViewModel)CitiesPage.BindingContext;

            TorLogPage       = (TorLogPage)FreshPageModelResolver.ResolvePageModel <TorLogViewModel>();
            TorLogPage.Title = Translation.GetString("Tor log");
            TorLogVM         = (TorLogViewModel)TorLogPage.BindingContext;

            SettingsPage       = (SettingsPage)FreshPageModelResolver.ResolvePageModel <SettingsViewModel>();
            SettingsPage.Title = Translation.GetString("Settings");
            SettingsVM         = (SettingsViewModel)SettingsPage.BindingContext;

            AboutPage       = (AboutPage)FreshPageModelResolver.ResolvePageModel <AboutViewModel>();
            AboutPage.Title = Translation.GetString("About");
            AboutVM         = (AboutViewModel)AboutPage.BindingContext;

            ProxyTips = new TabbedPage();
            ProxyTipsWifiPage wfPage = (ProxyTipsWifiPage)FreshPageModelResolver.ResolvePageModel <ProxyTipsWifiViewModel>();

            wfPage.Title = Translation.GetString("Wi-Fi");
            PTWFVM       = (ProxyTipsWifiViewModel)wfPage.BindingContext;

            ProxyTipsAPNPage apnPage = (ProxyTipsAPNPage)FreshPageModelResolver.ResolvePageModel <ProxyTipsAPNViewModel>();

            apnPage.Title = Translation.GetString("APN");
            PTAPNVM       = (ProxyTipsAPNViewModel)apnPage.BindingContext;
            ProxyTips.Children.Add(wfPage);
            ProxyTips.Children.Add(apnPage);

            MainPage = new NavigationPage(StatusPage);

            MessagingCenter.Subscribe <MSProApp, string>(this, "TorOutput", (sender, arg) =>
            {
                if (arg.CompareTo(System.String.Empty) != 0)
                {
                    TorLogVM.TorLog.Add(arg);
                    MessagingCenter.Send <StatusViewModel, string>(StatusVM, "NewLoadMessage", arg);
                }
                if (arg.IndexOf("[err]") != -1)
                {
                    //error!
                }
                if (arg.IndexOf("100%") != -1)
                {
                    Task tc = Task.Run(() =>
                    {
                        Tor.Connect();
                    });
                    tc.Wait();
                    MessagingCenter.Send <StatusPage>((StatusPage)StatusVM.CurrentPage, "BootstrappFinished");
                }
            });
            MessagingCenter.Subscribe <MSProApp>(this, "Start", (sender) =>
            {
                OnStart();
            });
        }
Beispiel #2
0
        protected override void OnStart()
        {
            //xlarge screens are at least 960dp x 720dp
            //large screens are at least 640dp x 480dp
            //normal screens are at least 470dp x 320dp
            //small screens are at least 426dp x 320dp

            MobileCenter.Start("android=7d19d3ff-dec3-42f0-80d7-3d5b74bc3593;", typeof(Analytics), typeof(Crashes));

            float dens = DependencyService.Get <IDisplaySize>().GetDensity();
            int   wd   = DependencyService.Get <IDisplaySize>().GetWidthDiP();
            int   hd   = DependencyService.Get <IDisplaySize>().GetHeightDiP();

            int bigger, smaller;

            if (wd > hd) //landscape
            {
                bigger  = wd;
                smaller = hd;
            }
            else //portrait
            {
                bigger  = hd;
                smaller = wd;
            }

            if (smaller >= 700) //SW700 and above
            {
                StatusPage sp = new StatusPage();
                sp.Title = AppStrings.Status;
                MainTabs.Children.Add(sp);

                CountriesPage cap = new CountriesPage();
                cap.Title = AppStrings.Countries;
                MainTabs.Children.Add(cap);

                CitiesPage cip = new CitiesPage();
                cip.Title = AppStrings.Cities;
                MainTabs.Children.Add(cip);

                TorLogPage tlp = new TorLogPage();
                tlp.Title = AppStrings.TorLog;
                MainTabs.Children.Add(tlp);

                AboutPage ap = new AboutPage();
                ap.Title = AppStrings.About;
                MainTabs.Children.Add(ap);

                MainPage = new NavigationPage(MainTabs);
            }
            else
            {
                if (smaller >= 500 && smaller < 700) //SW500
                {
                    StatusPageSW500 sp = new StatusPageSW500();
                    sp.Title = AppStrings.Status;
                    MainTabs.Children.Add(sp);

                    CountriesPageSW500 cap = new CountriesPageSW500();
                    cap.Title = AppStrings.Countries;
                    MainTabs.Children.Add(cap);

                    TorLogPageSW500 tlp = new TorLogPageSW500();
                    tlp.Title = AppStrings.TorLog;
                    MainTabs.Children.Add(tlp);

                    AboutPageSW400 ap = new AboutPageSW400();
                    ap.Title = AppStrings.About;
                    MainTabs.Children.Add(ap);

                    MainPage = new NavigationPage(MainTabs);
                }
                else
                {
                    if (smaller >= 400) //SW400
                    {
                        if (wd > hd)
                        {
                            StatusPagePhoneL       = new StatusPageSW400();
                            StatusPagePhoneL.Title = AppStrings.Status;
                            //Application.Current.MainPage.Navigation.PopAsync();
                            MainTabs.Children.Add(StatusPagePhoneL);
                            MainPage = new NavigationPage(MainTabs);
                            StatusPagePhoneL.DisplayPosition = DisplayPos.Landscape;
                        }
                        else
                        {
                            StatusPagePhoneP       = new StatusPageSW400p();
                            StatusPagePhoneP.Title = AppStrings.Status;
                            MainTabs.Children.Add(StatusPagePhoneP);
                            MainPage = new NavigationPage(MainTabs);
                            StatusPagePhoneP.DisplayPosition = DisplayPos.Portrait;
                        }

                        TorLogPageSW400 tlp = new TorLogPageSW400();
                        tlp.Title = AppStrings.TorLog;
                        MainTabs.Children.Add(tlp);

                        CountriesPageSW400 cap = new CountriesPageSW400();
                        cap.Title = AppStrings.Countries;
                        MainTabs.Children.Add(cap);

                        AboutPageSW400 ap = new AboutPageSW400();
                        ap.Title = AppStrings.About;
                        MainTabs.Children.Add(ap);
                    }
                    else//SW300
                    {
                        if (wd > hd)
                        {
                            StatusPagePhoneL       = new StatusPageSW300();
                            StatusPagePhoneL.Title = AppStrings.Status;
                            MainTabs.Children.Add(StatusPagePhoneL);
                            MainPage = new NavigationPage(MainTabs);
                            StatusPagePhoneL.DisplayPosition = DisplayPos.Landscape;
                        }
                        else
                        {
                            StatusPagePhoneP       = new StatusPageSW300p();
                            StatusPagePhoneP.Title = AppStrings.Status;
                            MainTabs.Children.Add(StatusPagePhoneP);

                            MainPage = new NavigationPage(MainTabs);
                            StatusPagePhoneP.DisplayPosition = DisplayPos.Portrait;
                        }

                        TorLogPageSW300 tlp = new TorLogPageSW300();
                        tlp.Title = AppStrings.TorLog;
                        MainTabs.Children.Add(tlp);

                        CountriesPageSW300 cap = new CountriesPageSW300();
                        cap.Title = AppStrings.Countries;
                        MainTabs.Children.Add(cap);

                        AboutPageSW300 ap = new AboutPageSW300();
                        ap.Title = AppStrings.About;
                        MainTabs.Children.Add(ap);
                    }
                }
            }
        }