Пример #1
0
        static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e)
        {
            var ex = (Exception)e.ExceptionObject;

            XyrohLib.LogException("Unhandled Exception", ex);
            Environment.Exit(1);
        }
Пример #2
0
        private async Task ExecuteRefreshCommand()
        {
            XyrohLib.LogEvent("Refresh History", "DB");


            if (IsBusy)
            {
                XyrohLib.Log("VM BUSY - RETURNING");
                return;
            }
            IsBusy = true;
            try
            {
                var record = await this.GetHistory();
            }

            catch (Exception ex)
            {
                XyrohLib.LogCrash("DB", ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #3
0
        public SupportPage(string title, byte[] imageArray)
        {
            XyrohLib.LogEvent("Page : Support : With Screenshot");

            this.pageTitle          = title;
            this.capturedImageBytes = imageArray;

            try
            {
                // save to disk
                this.captureImagePath =
                    "Screen" + new DateTimeOffset(DateTime.Now).ToUnixTimeMilliseconds().ToString() + "_" +
                    Guid.NewGuid().ToString().ToString() + ".jpg";
                this.captureImagePath = Path.Combine(App.ImagesStore, this.captureImagePath);
                XyrohLib.Log("** fileName: " + this.captureImagePath);

                File.WriteAllBytes(this.captureImagePath, imageArray);
            }
            catch (Exception ex)
            {
                XyrohLib.LogCrash("Screen Capture", ex);
            }

            this.capturedImageBytes = null;

            this.Init();
        }
Пример #4
0
        protected async void OnReleaseNotesCellTapped(object sender, EventArgs e)
        {
            XyrohLib.LogEvent("Help : Release Notes : Tapped");

            // await this.Navigation.PushAsync(new ReleaseNotesPage());
            await Navigation.PushModalAsync(new WebViewPage("https://xyroh.com/faq/worst-apps/worst-url-shortener-release-history#main"));
        }
Пример #5
0
        public SupportPage(string title)
        {
            XyrohLib.LogEvent("Page : Support");

            this.pageTitle = title;
            this.Init();
        }
Пример #6
0
        private async Task <ObservableRangeCollection <ShortenedUrl> > GetHistory()
        {
            this.IsBusy    = true;
            this.LastError = string.Empty;


            try
            {
                this.History.Clear();

                var records = this.db.ShortenedUrl.ToList();
                records = records.OrderByDescending(x => x.CreatedAt).ToList();

                this.History.ReplaceRange(records);
            }
            catch (Exception ex)
            {
                this.LastError = "ERROR: " + ex.Message;
                XyrohLib.LogException("GetHistory", ex);
            }

            this.IsBusy = false;

            return(this.History);
        }
Пример #7
0
        public ShareExtensionPage()
        {
            XyrohLib.LogEvent("Page : Share Extension ");

            this.BindingContext = this.viewModel;
            this.InitializeComponent();
        }
Пример #8
0
        private async void onShareButtonClicked(object sender, EventArgs e)
        {
            XyrohLib.LogEvent("Button : Share URL");

            var button       = sender as ImageButton;
            var selectedItem = button.BindingContext as ShortenedUrl;

            if (!string.IsNullOrEmpty(selectedItem.ShortUrl))
            {
                this.viewModel.ShortURL = selectedItem.ShortUrl;

                await Share.RequestAsync(new ShareTextRequest
                {
                    Uri   = this.viewModel.ShortURL,
                    Title = "Shortened Link"
                });

                await Clipboard.SetTextAsync(selectedItem.ShortUrl);


                SnackBar.Message = "Shortened link copied to the Clipboard";
                SnackBar.IsOpen  = !SnackBar.IsOpen;

                /*if (this.viewModel.ShareCommand.CanExecute(null))
                 * {
                 *  this.viewModel.ShareCommand.Execute(null);
                 * }*/
            }
        }
Пример #9
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;

            //XyrohLib.Test();

            XyrohLib.setFileLog("test.log");
            //XyrohLib.setFileLog("test.log", 5000);
            //XyrohLib.setCrashreporter("https://*****:*****@sentry.io/292140");
            //XyrohLib.Test();
            //XyrohLib.Log("test log 10 ");

            //XyrohLib.setAnalytics("13e9d1b9-7bae-4e4d-b20c-b8e5e7779d58", "917eea77-d8c0-4fc2-a2dd-940da5e8dd87");

            for (int i = 0; i < 100; i++)
            {
                XyrohLib.LogEvent("Test Analytics Event" + i);
            }

            Console.WriteLine("File Path: " + XyrohLib.GetLogPath());

            //throw new Exception("KaBlam2");


            //logger.Log("test from console");
        }
Пример #10
0
        static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e)
        {
            Exception ex = (Exception)e.ExceptionObject;

            XyrohLib.LogCrash("unhandled exception", ex);
            //XyrohLib.LogCrash("unhandled exception", ex);
            Environment.Exit(1);
        }
Пример #11
0
        public WebViewPage(string url)
        {
            XyrohLib.LogEvent("Page : Web View", "Page");

            this.Url = url;
            InitializeComponent();

            webView.Source = this.Url;
        }
Пример #12
0
        private async void OnShareCommandExecuted(object state)
        {
            XyrohLib.LogEvent("Shorten Page : Share Link");

            await Share.RequestAsync(new ShareTextRequest
            {
                Uri   = this.ShortURL,
                Title = "Shortened Link"
            });
        }
Пример #13
0
        protected ShareViewController(IntPtr handle) : base(handle)
        {
            // Note: this .ctor should not contain any initialization logic.
            XyrohLib.setFileLog(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "sharedebug.txt"), 500000); // 0.5MB
            XyrohLib.setCrashreporter(BaseConfig.SentryKey);
            XyrohLib.setAnalytics(BaseConfig.AppCenteriOSKey, BaseConfig.AppCenterAndroidKey);
            XyrohLib.Log("**HERE**");

            XyrohLib.LogEvent("Extension : Share ");
        }
Пример #14
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            PopupButton.Clicked += (o, s) =>
            {
                XyrohLib.LogEvent("FAQ : Closed", "Event");

                Navigation.PopModalAsync();
            };
        }
Пример #15
0
        public DefaultPage()
        {
            XyrohLib.LogEvent("Page : Shorten ");

            this.BindingContext = this.viewModel;
            this.InitializeComponent();

            if (!string.IsNullOrEmpty(App.SharedURL))
            {
                this.viewModel.LongURL = App.SharedURL;
            }
        }
Пример #16
0
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            XyrohLib.Log("Configuring DB: ");
            var dbFolder = DependencyService.Get <IDBPath>().GetDBPath();

            XyrohLib.Log("Using Folder: " + dbFolder);
            var dbPath = Path.Combine(dbFolder, BaseConfig.dbName);

            XyrohLib.Log("Using DB: " + dbPath);

            optionsBuilder
            .UseSqlite($"Filename={dbPath}");
        }
Пример #17
0
        private async void OnCloseButtonClicked(object sender, EventArgs e)
        {
            try
            {
                XyrohLib.LogEvent("Support Page : Closed");

                await this.Navigation.PopAsync();
            }
            catch (Exception ex)
            {
                XyrohLib.LogCrash(ex);
            }
        }
Пример #18
0
        public HistoryPage()
        {
            XyrohLib.LogEvent("Page : History ");

            this.BindingContext = this.viewModel;
            this.InitializeComponent();


            /*foreach(var hist in this.viewModel.History)
             * {
             *  XyrohLib.Log("HIST: " + hist.ShortUrl + " : " + hist.CreatedDate);
             * }*/
        }
Пример #19
0
        private async void OnSendTicketButtonClicked(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(this.TicketEmail.Text) || string.IsNullOrEmpty(this.TicketSubject.Text) || string.IsNullOrEmpty(this.TicketDescription.Text))
                {
                    await this.DisplayAlert("Oops", "Please ensure all fields are completed", "OK");
                }
                else
                {
                    XyrohLib.LogEvent("Support Page : Send Ticket");

                    this.SendButton.IsEnabled = false;

                    // get log and db
                    var attachments = new List <string>();
                    attachments.Add(XyrohLib.GetLogPath());

                    // screencap?
                    if (File.Exists(this.captureImagePath))
                    {
                        XyrohLib.Log("Attaching: " + this.captureImagePath);
                        attachments.Add(this.captureImagePath);
                    }

                    var ticketId = await XyrohLib.CreateTicketWithAttachment(this.TicketEmail.Text, this.TicketSubject.Text, this.TicketDescription.Text, new string[] { "urlshortener", "worst", "mobile", "xyrohlib" }, attachments);

                    if (ticketId > 0)
                    {
                        await this.DisplayAlert("Ticket Created", "Ticket Ref: " + ticketId.ToString() + " Successfully Created", "OK");

                        await this.Navigation.PopAsync();
                    }
                    else
                    {
                        throw new Exception("Couldn't create Ticket - Please try again");
                    }
                }
            }
            catch (Exception ex)
            {
                XyrohLib.LogCrash(ex);

                await this.DisplayAlert("Error", "Error: " + ex.Message, "OK");

                this.SendButton.IsEnabled = true;
            }
        }
Пример #20
0
        private async void OnShaked(object sender, EventArgs e)
        {
            XyrohLib.LogEvent("Shake Detected");

            try
            {
                // capture the screen
                var screenImage = await DependencyService.Get <IScreen>().CaptureScreenAsync();

                // await this.Navigation.PushModalAsync(new SupportPage("Send Feedback", screenImage));
                await this.Navigation.PushAsync(new SupportPage("Send Feedback", screenImage));
            }
            catch (Exception ex)
            {
                XyrohLib.LogCrash(ex);
            }
        }
Пример #21
0
        public BaseViewModel()
        {
            var connectivity = Connectivity.NetworkAccess;

            if (connectivity == NetworkAccess.Internet)
            {
                // Connection to internet is available
                this.IsOnline = true;
            }
            else
            {
                this.IsOnline = false;
            }

            XyrohLib.Log("ONLINE: " + this.IsOnline);

            Connectivity.ConnectivityChanged += this.ConnectivityChanged;
        }
Пример #22
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            var sharedURL = string.Empty;

            if (this.Intent.Action == Android.Content.Intent.ActionSend)
            {
                XyrohLib.LogEvent("Android Share Intent Received");
                sharedURL = this.Intent.Extras.GetString(Android.Content.Intent.ExtraText);
            }

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            this.LoadApplication(new App(sharedURL));
        }
Пример #23
0
        // public static SQLiteContext DB { get; set; }

        public App(string sharedURL)
        {
            this.InitializeComponent();

            // XyrohLib Crash handler Setup
            XyrohLib.setFileLog(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "debug.txt"), 500000); // 0.5MB
            XyrohLib.setCrashreporter(BaseConfig.SentryKey);

            #if DEBUG
            // XyrohLib.setAnalytics(SettingsViewModel.AppCenteriOSKey, SettingsViewModel.AppCenterAndroidKey);
            #else
            XyrohLib.setAnalytics(BaseConfig.AppCenteriOSKey, BaseConfig.AppCenterAndroidKey);
            #endif

            // Freshdesk
            XyrohLib.SetHelpDesk(BaseConfig.FreshDeskURL, BaseConfig.FreshDeskKey, "c29tZSByYW5kb20gdW5uZWNlc3Nhcnkga2V5");

            VersionTracking.Track();

            // filesystem prep
            try
            {
                App.ImagesStore = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "screenshots");
                Directory.CreateDirectory(App.ImagesStore);
            }
            catch (Exception ex)
            {
                XyrohLib.LogCrash(ex);
            }

            // db Prep - Singleton doesn't work in share extension as no 'App'
            // App.DB = new SQLiteContext();

            if (!string.IsNullOrEmpty(sharedURL))
            {
                XyrohLib.Log(sharedURL);
                App.SharedURL = sharedURL;
            }
            // this.MainPage = new MainPage();
            this.MainPage = new NavigationPage(new MainPage());
        }
Пример #24
0
        private async void OnShortenCommandExecuted(object state)
        {
            XyrohLib.Log("SERVICE: " + this.ShortenService);
            XyrohLib.Log("URL: " + this.LongURL);

            var shortenedURl = string.Empty;

            this.ShortURL   = shortenedURl;
            this.HasResults = false;

            switch (this.shortenService)
            {
            default:
            case "TinyUrl":
            {
                var client = new HttpClient();
                var url    = "http://tinyurl.com/api-create.php?url=" + this.LongURL;
                XyrohLib.Log("REQUEST: " + url);
                client.Timeout = TimeSpan.FromSeconds(5);

                try
                {
                    var response = await client.GetAsync(url);

                    var responseBody = await response.Content.ReadAsStringAsync();

                    XyrohLib.Log("RESP: " + responseBody);
                    XyrohLib.Log("Status Code: " + response.StatusCode.ToString());
                    if (response.IsSuccessStatusCode)
                    {
                        shortenedURl = responseBody.ToString();
                        XyrohLib.Log("Short: " + shortenedURl);
                    }
                    else
                    {
                        this.LastError = "Something went wrong, error: " + response.StatusCode.ToString();
                    }
                }
                catch (Exception postEx)
                {
                    XyrohLib.LogCrash(postEx);
                    this.LastError = "We couldn't shorten that URL, please check and try again";
                }
                break;
            }

            case "Firebase":
            {
                var client = new HttpClient();
                var url    = "https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=" + BaseConfig.FirebaseAPIKey.ToString();
                client.Timeout = TimeSpan.FromSeconds(5);

                try
                {
                    var json = new FirebaseLinkRequest();
                    json.longDynamicLink = BaseConfig.FirebaseURLDomain + "/?link=" +
                                           this.LongURL + "&apn=" + AppInfo.PackageName + "&ibi=" +
                                           AppInfo.PackageName;

                    XyrohLib.Log("JSON: " + JsonConvert.SerializeObject(json));

                    var requestBody = new StringContent(JsonConvert.SerializeObject(json).ToString(), Encoding.UTF8, "application/json");
                    var response    = await client.PostAsync(url, requestBody);

                    var responseString = await response.Content.ReadAsStringAsync();

                    XyrohLib.Log("RESP: " + responseString);
                    XyrohLib.Log("Status Code: " + response.StatusCode.ToString());
                    if (response.IsSuccessStatusCode)
                    {
                        var responseBody = JsonConvert.DeserializeObject <FirebaseLinkResponse>(responseString);

                        shortenedURl = responseBody.shortLink.ToString();
                        XyrohLib.Log("Short: " + shortenedURl);
                    }
                    else
                    {
                        this.LastError = "Something went wrong, error: " + response.StatusCode.ToString();
                    }
                }
                catch (Exception postEx)
                {
                    XyrohLib.LogCrash(postEx);
                    this.LastError = "We couldn't shorten that URL, please check and try again";
                }
                break;
            }
            }

            this.ShortURL = shortenedURl;
            if (!string.IsNullOrEmpty(this.ShortURL))
            {
                // save to history
                var history = new ShortenedUrl();
                history.ShortenService = this.shortenService;
                history.FullUrl        = this.LongURL;
                history.ShortUrl       = this.ShortURL;

                try
                {
                    // Can't use App singleton as App doesn't exist for the extension
                    this.db.Add(history);
                    await this.db.SaveChangesAsync();

                    XyrohLib.Log("Saved History: " + shortenedURl);
                }
                catch (Exception ex)
                {
                    XyrohLib.LogCrash("DB", ex);
                }

                await Clipboard.SetTextAsync(shortenedURl);

                this.HasResults = true;
                XyrohLib.Log("Final: " + this.ShortURL);


                await this.refresh();
            }
        }
Пример #25
0
        private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs e)
        {
            var ex = (Exception)e.Exception;

            XyrohLib.LogException("Unobserved Task Exception", ex);
        }
Пример #26
0
        private static void UnhandledAndroidEnvironmentExceptionHandler(object sender, RaiseThrowableEventArgs e)
        {
            var ex = (Exception)e.Exception;

            XyrohLib.LogException("Unhandled Android Environment Task Exception", ex);
        }
Пример #27
0
        protected async void OnSupportCellTapped(object sender, EventArgs e)
        {
            XyrohLib.LogEvent("Help : Support : Tapped");

            await this.Navigation.PushAsync(new SupportPage("Raise a Support Ticket"));
        }
Пример #28
0
        protected async void OnIdeaCellTapped(object sender, EventArgs e)
        {
            XyrohLib.LogEvent("Help : Idea : Tapped");

            await this.Navigation.PushAsync(new SupportPage("Suggest a Feature?"));
        }