protected override void OnHandleIntent(Intent intent) { if (intent.Action == "CloudClipboardCopy") { var settings = new Classes.Settings(this); var text = settings.CloudClipboardText; Handler handler = new Handler(Looper.MainLooper); handler.Post(() => { try { ClipboardManager clipboard = (ClipboardManager)GetSystemService(Context.ClipboardService); ClipData clip = ClipData.NewPlainText(text, text); clipboard.PrimaryClip = clip; Toast.MakeText(this, "Copied", ToastLength.Short).Show(); } catch (Exception ex) { Log.Debug("CloudClipboardService", ex.Message); } }); } }
private async Task InitRome() { if (Common.PackageManager == null) { Classes.Settings settings = new Classes.Settings(this); Common.PackageManager = new RomePackageManager(this); if (settings.UseInAppServiceOnWindowsDevices) { Common.PackageManager.SetAppServiceName("com.roamit.serviceinapp", "com.roamit.service"); } else { Common.PackageManager.SetAppServiceName("com.roamit.service"); } await Common.PackageManager.InitializeDiscovery(); } if (Common.MessageCarrierPackageManager == null) { Common.MessageCarrierPackageManager = new RomePackageManager(this); Common.MessageCarrierPackageManager.SetAppServiceName("com.roamit.messagecarrierservice"); await Common.MessageCarrierPackageManager.InitializeDiscovery(); } }
internal static async Task <bool> RemoveDevice(Context _context) { try { Classes.Settings settings = new Classes.Settings(_context); var deviceUniqueId = GetDeviceUniqueId(); if (CloudServiceAuthenticationHelper.IsAuthenticatedForApiV3()) { var apiLoginInfo = (CloudServiceAuthenticationHelper.GetApiLoginInfo()); var user = new QuickShare.Common.Service.v3.User(apiLoginInfo.AccountId, apiLoginInfo.Token); var result = await user.RemoveDevice(deviceUniqueId); if (result) { System.Diagnostics.Debug.WriteLine($"RemoveDevice Succeeded."); } else { System.Diagnostics.Debug.WriteLine($"RemoveDevice failed."); } return(result); } else { await FindUserId(); var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("deviceId", deviceUniqueId), }); var myHttpClient = new HttpClient(); var response = await myHttpClient.PostAsync($"{QuickShare.Common.Constants.ServerAddress}/api/User/{userId}/RemoveDevice", formContent); var responseText = await response.Content.ReadAsStringAsync(); if (responseText == "1, removed") { System.Diagnostics.Debug.WriteLine($"RemoveDevice Succeeded. Response was '{responseText}'"); return(true); } else { System.Diagnostics.Debug.WriteLine($"RemoveDevice Failed. Response was '{responseText}'"); return(false); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"RemoveDevice Failed due to unhandled exception: {ex.Message}"); return(false); } }
internal static async Task <bool> RegisterDevice(Context _context) { try { var firebaseToken = FirebaseInstanceId.Instance.Token; if (firebaseToken == null) { System.Diagnostics.Debug.WriteLine("firebaseToken is null. Device registration failed."); return(false); } await FindUserId(); Classes.Settings settings = new Classes.Settings(_context); var deviceName = settings.DeviceName; var osVersion = CrossDeviceInfo.Current.Version; var deviceUniqueId = GetDeviceUniqueId(); var appVersion = Application.Context.ApplicationContext.PackageManager.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0).VersionName; var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("name", deviceName), new KeyValuePair <string, string>("osVersion", osVersion), new KeyValuePair <string, string>("deviceId", deviceUniqueId), new KeyValuePair <string, string>("type", "Android"), new KeyValuePair <string, string>("token", firebaseToken), new KeyValuePair <string, string>("appVersion", appVersion), }); var myHttpClient = new HttpClient(); var response = await myHttpClient.PostAsync($"{QuickShare.Common.Constants.ServerAddress}/api/User/{userId}/RegisterDevice", formContent); var responseText = await response.Content.ReadAsStringAsync(); if ((responseText == "1, registered") || (responseText == "2, updated")) { System.Diagnostics.Debug.WriteLine($"RegisterDevice Succeeded. Response was '{responseText}'"); return(true); } else { System.Diagnostics.Debug.WriteLine($"RegisterDevice Failed. Response was '{responseText}'"); return(false); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"RegisterDevice Failed due to unhandled exception: {ex.Message}"); return(false); } }
internal static async Task <bool> RemoveDevice(Context _context) { try { await FindUserId(); Classes.Settings settings = new Classes.Settings(_context); var deviceUniqueId = GetDeviceUniqueId(); var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("deviceId", deviceUniqueId), }); var myHttpClient = new HttpClient(); var response = await myHttpClient.PostAsync($"{QuickShare.Common.Constants.ServerAddress}/api/User/{userId}/RemoveDevice", formContent); var responseText = await response.Content.ReadAsStringAsync(); if (responseText == "1, removed") { System.Diagnostics.Debug.WriteLine($"RemoveDevice Succeeded. Response was '{responseText}'"); return(true); } else { System.Diagnostics.Debug.WriteLine($"RemoveDevice Failed. Response was '{responseText}'"); return(false); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"RemoveDevice Failed due to unhandled exception: {ex.Message}"); return(false); } }