protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.main); RequestedOrientation = ScreenOrientation.Portrait; UserDialogs.Init(this); _application = ApplicationContext as MyApplication; var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); if (toolbar != null) { SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); } _drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); //Set hamburger items menu SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu); //setup navigation view _navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); var view = _navigationView.GetHeaderView(0); var usernameTextView = view.FindViewById <TextView>(Resource.Id.nav_header_username); usernameTextView.Text = _application.CurrentUser.Username; var nameTextView = view.FindViewById <TextView>(Resource.Id.nav_header_name); nameTextView.Text = _application.CurrentUser.Firstname + " " + _application.CurrentUser.Lastname; var emailTextView = view.FindViewById <TextView>(Resource.Id.nav_header_email); emailTextView.Text = _application.CurrentUser.Email; var changeTeamTextView = _navigationView.FindViewById <TextView>(Resource.Id.nav_footer_item_change_team); changeTeamTextView.Click += ChangeTeam; var logoutTextView = _navigationView.FindViewById <TextView>(Resource.Id.nav_footer_item_logout); logoutTextView.Click += Logout; var layout = FindViewById <RelativeLayout>(Resource.Id.content_frame_wrapper); _currentPadding[0] = layout.PaddingLeft; _currentPadding[1] = layout.PaddingTop; _currentPadding[2] = layout.PaddingRight; _currentPadding[3] = layout.PaddingBottom; //handle navigation _navigationView.NavigationItemSelected += (sender, e) => { _previousItem?.SetChecked(false); _navigationView.SetCheckedItem(e.MenuItem.ItemId); _previousItem = e.MenuItem; switch (e.MenuItem.ItemId) { case Resource.Id.nav_calendar: ListItemClicked(0); break; case Resource.Id.nav_news: ListItemClicked(1); break; case Resource.Id.nav_member_list: ListItemClicked(2); break; } _drawerLayout.CloseDrawers(); }; //if first time you will want to go ahead and click first item. if (savedInstanceState == null) { _navigationView.SetCheckedItem(Resource.Id.nav_calendar); var fragment = CalendarFragment.NewInstance(); fragment.OnAttach(ApplicationContext); SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.content_frame, fragment) .Commit(); } }
async Task ExecuteCreateContainerAsync() { if (IsBusy) { return; } if (!ReadyToSave) { //This should never happen as the save button should be disabled Logger.Report(new Exception("Create container called when ReadyToSave was false"), "Method", "ExecuteCreateContainerAsync"); return; } if (containerName.Length < 3 || containerName.Length > 63 || !Regex.IsMatch(containerName, @"^[a-z0-9]+(-[a-z0-9]+)*$")) { MessagingService.Current.SendMessage <MessagingServiceAlert>(MessageKeys.Message, new MessagingServiceAlert { Title = "Container name is invalid", Message = "Container names must be between 3 and 63 chars, only contain lowercase letters, numbers, and hyphens, must begin with a number or letter, must not contain consecutive hyphens, or end with a hyphen.", Cancel = "OK" }); return; } IProgressDialog savingDialog = UserDialogs.Loading("Saving Container"); savingDialog.Show(); try { IsBusy = true; string connectionString = Constants.StorageConnectionString; connectionString = connectionString.Replace("<ACCOUNTNAME>", SelectedStorageAccount.Name); connectionString = connectionString.Replace("<ACCOUNTKEY>", SelectedStorageAccount.PrimaryKey); CloudStorageAccount sa = CloudStorageAccount.Parse(connectionString); var blobClient = sa.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference(ContainerName); if (container == null) { Console.WriteLine("Container is null"); } if (await container.ExistsAsync()) { MessagingService.Current.SendMessage <MessagingServiceAlert>(MessageKeys.Message, new MessagingServiceAlert { Title = "Container Exists", Message = "A container with the name \"" + ContainerName + "\" already exists in this storage account.", Cancel = "OK" }); return; } else { await container.CreateAsync(); if (SelectedAccessType != "Private") { if (SelectedAccessType == "Container") { await container.SetPermissionsAsync(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Container }); } else if (SelectedAccessType == "Blob") { await container.SetPermissionsAsync(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob }); } } var realm = App.GetRealm(); var storageAccountName = selectedStorageAccount.Name; realm.Write(() => { realm.Add(new RealmCloudBlobContainer(container.Name, selectedStorageAccount.Name, container.Uri.ToString())); }); if (containersVM != null) { containersVM.AddContainer(new ASECloudBlobContainer(container, selectedStorageAccount.Name)); App.Logger.Track(AppEvent.CreatedContainer.ToString()); } //This is here and in finally so we'll dismiss this before popping the page so the //Loader doesn't stay longer than the popup if (savingDialog != null) { if (savingDialog.IsShowing) { savingDialog.Hide(); } savingDialog.Dispose(); } await PopupNavigation.PopAsync(); } } catch (Exception ex) { Logger.Report(ex, "Method", "ExecuteCreateContainerAsync"); MessagingService.Current.SendMessage(MessageKeys.Error, ex); } finally { IsBusy = false; if (savingDialog != null) { if (savingDialog.IsShowing) { savingDialog.Hide(); } savingDialog.Dispose(); } } return; }
protected override void OnCreate(Bundle bundle) { ToolbarResource = Resource.Layout.Toolbar; TabLayoutResource = Resource.Layout.Tabbar; //Window.AddFlags(WindowManagerFlags.Fullscreen); //SetContentView(Resource.Layout.Tabbar); //var uiOptions = (int)Window.DecorView.SystemUiVisibility; //uiOptions |= (int)SystemUiFlags.LowProfile; //uiOptions |= (int)SystemUiFlags.HideNavigation; //uiOptions |= (int)SystemUiFlags.ImmersiveSticky; //uiOptions |= (int)SystemUiFlags.Fullscreen; //Window.DecorView.SystemUiVisibility = // (StatusBarVisibility)uiOptions; //if (Build.VERSION.SdkInt >= Build.VERSION_CODES.Lollipop) //{ // Window.AddFlags(WindowManagerFlags.LayoutNoLimits); // Window.AddFlags(WindowManagerFlags.LayoutInScreen); // Window.DecorView.SetFitsSystemWindows(true); // Window.DecorView.SystemUiVisibility = 0; // var statusBarHeightInfo = typeof(FormsAppCompatActivity).GetField("_statusBarHeight", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); // if (statusBarHeightInfo != null) statusBarHeightInfo.SetValue(this, 0); // Window.SetStatusBarColor(new Android.Graphics.Color(18, 52, 86, 255)); //} Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("MzUyMDBAMzEzNzJlMzIyZTMwTEV0K0JaZXY0ZUZZclhJd0t1ZkkvRS9mUXNvT2d6WGthRFE0OGx6WGRwcz0="); AppCenter.Start("60a0a275-523a-4433-9ed1-39739f3b13c2", typeof(Analytics), typeof(Crashes)); base.OnCreate(bundle); //Window.DecorView.SystemUiVisibility = (StatusBarVisibility)SystemUiFlags.HideNavigation; CachedImageRenderer.Init(true); var ignore = typeof(SvgCachedImage); var config = new FFImageLoading.Config.Configuration { VerboseLogging = false, VerbosePerformanceLogging = false, VerboseMemoryCacheLogging = false, VerboseLoadingCancelledLogging = false }; ImageService.Instance.Initialize(config); UserDialogs.Init(this); XF.Material.Droid.Material.Init(this, bundle); Xamarin.Essentials.Platform.Init(this, bundle); EntryCustomReturn.Forms.Plugin.Android.CustomReturnEntryRenderer.Init(); }
protected override void OnLaunched(LaunchActivatedEventArgs e) { global::Xamarin.Forms.Forms.Init(e); UserDialogs.Init(); base.OnLaunched(e); }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); BluetoothLowEnergyAdapter.InitActivity(this); UserDialogs.Init(this); Forms.Init(this, bundle); new Timer().Schedule( new TimerAction( () => { RunOnUiThread( () => { if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.Bluetooth) != Permission.Granted) { if (ActivityCompat.ShouldShowRequestPermissionRationale(this, Manifest.Permission.Bluetooth)) { UserDialogs.Instance.Alert( "Yes should show rationale for Bluetooth", "ShouldShowRequestPermissionRationale"); } else { Log.Info("Requesting permission for Bluetooth"); ActivityCompat.RequestPermissions(this, new[] { Manifest.Permission.Bluetooth }, 24112); } } else { Log.Info("Already have permission for Bluetooth"); } if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.BluetoothAdmin) != Permission.Granted) { if (ActivityCompat.ShouldShowRequestPermissionRationale( this, Manifest.Permission.BluetoothAdmin)) { UserDialogs.Instance.Alert( "Yes should show rationale for BluetoothAdmin", "ShouldShowRequestPermissionRationale"); } else { Log.Info("Requesting permission for BluetoothAdmin"); ActivityCompat.RequestPermissions( this, new[] { Manifest.Permission.BluetoothAdmin }, 24113); } } else { Log.Info("Already have permission for BluetoothAdmin"); } }); }), 12000); LoadApplication(new FormsApp(BluetoothLowEnergyAdapter.ObtainDefaultAdapter(ApplicationContext))); }
private void RegisterThirdPartyControls() { UserDialogs.Init(this); }
protected override void OnCreate(Bundle bundle) { // Create your application here UserDialogs.Init(this); base.OnCreate(bundle); }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); AssetManager assets = Assets; string path = FilesDir.AbsolutePath; string rc_path = path + "/default_rc"; if (!File.Exists(rc_path)) { using (StreamReader sr = new StreamReader(assets.Open("linphonerc_default"))) { string content = sr.ReadToEnd(); File.WriteAllText(rc_path, content); } } string factory_path = path + "/factory_rc"; if (!File.Exists(factory_path)) { using (StreamReader sr = new StreamReader(assets.Open("linphonerc_factory"))) { string content = sr.ReadToEnd(); File.WriteAllText(factory_path, content); } } UserDialogs.Init(this); Forms.Init(this, bundle); Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, bundle); App.ConfigFilePath = rc_path; App.FactoryFilePath = factory_path; App app = new App(this.Handle); System.Diagnostics.Debug.WriteLine("DEVICE=" + Build.Device); System.Diagnostics.Debug.WriteLine("MODEL=" + Build.Model); System.Diagnostics.Debug.WriteLine("MANUFACTURER=" + Build.Manufacturer); System.Diagnostics.Debug.WriteLine("SDK=" + Build.VERSION.Sdk); LinearLayout fl = new LinearLayout(this); ViewGroup.LayoutParams lparams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); fl.LayoutParameters = lparams; displayCamera = new TextureView(this); ViewGroup.LayoutParams dparams = new ViewGroup.LayoutParams(640, 480); displayCamera.LayoutParameters = dparams; captureCamera = new TextureView(this); ViewGroup.LayoutParams cparams = new ViewGroup.LayoutParams(320, 240); captureCamera.LayoutParameters = cparams; fl.AddView(displayCamera); fl.AddView(captureCamera); //app.getLayoutView().Children.Add(fl); app.Core.NativeVideoWindowId = displayCamera.Handle; app.Core.NativePreviewWindowId = captureCamera.Handle; app.Core.VideoDisplayEnabled = true; app.Core.VideoCaptureEnabled = true; instance = this; CreateNotificationChannel(); LoadApplication(app); //CreateNotificationFromIntent(Intent); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); UserDialogs.Init(this); }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); #region Facebook Auth FacebookSdk.SdkInitialize(this); #endregion #region Google Auth var serverClientId = Resources.GetString(Resource.String.serverClientId); //var clientId = Resources.GetString(Resource.String.clientId); var options = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestScopes(new Scope(Scopes.PlusLogin)) //.RequestScopes(new Scope(Scopes.Profile)) //.RequestProfile() //.RequestId() .RequestIdToken(serverClientId) .RequestServerAuthCode(serverClientId) .RequestEmail() .Build(); SharedGoogleApiClient.Instance.GoogleApiClient = new GoogleApiClient.Builder(this) //.AddConnectionCallbacks(this) //.AddOnConnectionFailedListener(this) //.EnableAutoManage(this, this) .AddApi(Android.Gms.Auth.Api.Auth.GOOGLE_SIGN_IN_API, options) //.AddApi(PlusClass.API) .Build(); #endregion #region Azure Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init(); //sqlite db AzureService.DbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), AzureService.DbPath); if (!File.Exists(AzureService.DbPath)) { File.Create(AzureService.DbPath).Dispose(); } #endregion #region Mobile Center MobileCenter.Start(Keys.MobileCenterAppKey, typeof(Analytics), typeof(Crashes)); #endregion global::Xamarin.Forms.Forms.Init(this, bundle); ImageCircleRenderer.Init(); UserDialogs.Init(this); LoadApplication(new App()); }
public static void SetIoc(Application application) { UserDialogs.Init(application); CachedImageRenderer.Init(); ZXing.Net.Mobile.Forms.Android.Platform.Init(); CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity); //var container = new UnityContainer(); var container = new Container(); // Android Stuff container.RegisterSingleton(application.ApplicationContext); container.RegisterSingleton <Application>(application); // Services container.RegisterSingleton <IDatabaseService, DatabaseService>(); container.RegisterSingleton <ISqlService, SqlService>(); container.RegisterSingleton <ISecureStorageService, AndroidKeyStoreStorageService>(); container.RegisterSingleton <ICryptoService, CryptoService>(); container.RegisterSingleton <IKeyDerivationService, BouncyCastleKeyDerivationService>(); container.RegisterSingleton <IAuthService, AuthService>(); container.RegisterSingleton <IFolderService, FolderService>(); container.RegisterSingleton <ILoginService, LoginService>(); container.RegisterSingleton <ISyncService, SyncService>(); container.RegisterSingleton <IDeviceActionService, DeviceActionService>(); container.RegisterSingleton <IAppIdService, AppIdService>(); container.RegisterSingleton <IPasswordGenerationService, PasswordGenerationService>(); container.RegisterSingleton <IReflectionService, ReflectionService>(); container.RegisterSingleton <ILockService, LockService>(); container.RegisterSingleton <IAppInfoService, AppInfoService>(); container.RegisterSingleton <IGoogleAnalyticsService, GoogleAnalyticsService>(); container.RegisterSingleton <IDeviceInfoService, DeviceInfoService>(); container.RegisterSingleton <ILocalizeService, LocalizeService>(); container.RegisterSingleton <ILogService, LogService>(); container.RegisterSingleton <IHttpService, HttpService>(); container.RegisterSingleton <ITokenService, TokenService>(); container.RegisterSingleton <ISettingsService, SettingsService>(); container.RegisterSingleton <IMemoryService, MemoryService>(); container.RegisterSingleton <IAppSettingsService, AppSettingsService>(); // Repositories container.RegisterSingleton <IFolderRepository, FolderRepository>(); container.RegisterSingleton <IFolderApiRepository, FolderApiRepository>(); container.RegisterSingleton <ILoginRepository, LoginRepository>(); container.RegisterSingleton <IAttachmentRepository, AttachmentRepository>(); container.RegisterSingleton <ILoginApiRepository, LoginApiRepository>(); container.RegisterSingleton <IConnectApiRepository, ConnectApiRepository>(); container.RegisterSingleton <IDeviceApiRepository, DeviceApiRepository>(); container.RegisterSingleton <IAccountsApiRepository, AccountsApiRepository>(); container.RegisterSingleton <ICipherApiRepository, CipherApiRepository>(); container.RegisterSingleton <ISettingsRepository, SettingsRepository>(); container.RegisterSingleton <ISettingsApiRepository, SettingsApiRepository>(); container.RegisterSingleton <ITwoFactorApiRepository, TwoFactorApiRepository>(); // Other container.RegisterSingleton(CrossSettings.Current); container.RegisterSingleton(CrossConnectivity.Current); container.RegisterSingleton(UserDialogs.Instance); container.RegisterSingleton(CrossFingerprint.Current); // Push var pushListener = new PushNotificationListener(); container.RegisterSingleton <IPushNotificationListener>(pushListener); CrossPushNotification.Initialize(pushListener, "962181367620"); container.RegisterSingleton(CrossPushNotification.Current); container.Verify(); Resolver.SetResolver(new SimpleInjectorResolver(container)); }
public void UserDialogsInit(Activity activity) { UserDialogs.Init(activity); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); //inicializar dialogos UserDialogs.Init(Application); MobileBarcodeScanner.Initialize(Application); // Create your application here SetContentView(Resource.Layout.DetalleProducto); _producto = new Negocio.Producto() { IdProducto = Intent.GetIntExtra(Negocio.Constantes.MENSAJE_IDPRODUCTO, 0) }; _producto.GetProductoById(); TextView txt = FindViewById <TextView>(Resource.Id.txtBarraProducto); EditText txtEdit = FindViewById <EditText>(Resource.Id.txtEditProducto); var button = FindViewById <SatelliteMenu.SatelliteMenuButton>(Resource.Id.menuSateliteProducto); button.AddItems(new[] { new SatelliteMenuButtonItem(Negocio.Constantes.MENU_SCAN, Resource.Drawable.ic_barcode_scan) }); button.MenuItemClick += MenuItem_Click; View vBotonBack = FindViewById <View>(Resource.Id.BackButtonProducto); vBotonBack.Click += BotonBack_Click; Spinner spinner1 = FindViewById <Spinner>(Resource.Id.spinner1); txt.Visibility = ViewStates.Visible; txtEdit.Visibility = ViewStates.Gone; spinner1.Visibility = ViewStates.Gone; txt.Text = _producto.Descripcion; txtEdit.Text = _producto.Descripcion; if (savedInstanceState != null) { int accionTemp = savedInstanceState.GetInt(Negocio.Constantes.MENSAJE_ACCION); AccionEnCurso = (Negocio.Constantes.Acciones)accionTemp; _producto.IdProducto = savedInstanceState.GetInt(Negocio.Constantes.MENSAJE_IDPRODUCTO); if (_producto.IdProducto != 0) { if (AccionEnCurso == Negocio.Constantes.Acciones.ACCIONES_NONE) { button.AddItems(new[] { new SatelliteMenuButtonItem(Negocio.Constantes.MENU_ANADIR, Resource.Drawable.ic_add_circle_outline_black_24dp), new SatelliteMenuButtonItem(Negocio.Constantes.MENU_BORRAR, Resource.Drawable.ic_delete_black_24dp), new SatelliteMenuButtonItem(Negocio.Constantes.MENU_EDIT, Resource.Drawable.ic_create_black_24dp) }); } else if (AccionEnCurso == Negocio.Constantes.Acciones.ACCIONES_EDIT) { txt.Visibility = ViewStates.Gone; txtEdit.Visibility = ViewStates.Visible; spinner1.Visibility = ViewStates.Visible; List <Negocio.Grupo> ListaGrupo = GestorApp.myData.GetAllGrupos(); ListaGrupo.OrderBy(g => g.Descripcion); List <string> ListaGrupoString = GetDescripcionesGrupos(ListaGrupo); ArrayAdapter SpinnerAdapter = new ArrayAdapter(this, Resource.Layout.ProductLayoutSpinner, ListaGrupoString); spinner1.Adapter = SpinnerAdapter; Negocio.Grupo _grupo = _producto.GetGrupo(); int posicion = ListaGrupoString.IndexOf(_grupo.Descripcion); spinner1.SetSelection(posicion); button.AddItems(new[] { new SatelliteMenuButtonItem(Negocio.Constantes.MENU_SALVAR, Resource.Drawable.ic_save_black_24dp), new SatelliteMenuButtonItem(Negocio.Constantes.MENU_CANCELAR, Resource.Drawable.ic_clear_black_24dp), }); } } } else { button.AddItems(new[] { new SatelliteMenuButtonItem(Negocio.Constantes.MENU_ANADIR, Resource.Drawable.ic_add_circle_outline_black_24dp), new SatelliteMenuButtonItem(Negocio.Constantes.MENU_BORRAR, Resource.Drawable.ic_delete_black_24dp), new SatelliteMenuButtonItem(Negocio.Constantes.MENU_EDIT, Resource.Drawable.ic_create_black_24dp) }); } List <Negocio.Existencias> lExistencias = _producto.GetExistencias(); List <Negocio.Elemento> lElementos = _producto.GetElementos(); var listView = FindViewById <ExpandableListView>(Resource.Id.lListaProducto); listView.SetAdapter(new Negocio.Adaptadores.ProductoExpandableAdapter(this, lExistencias, lElementos)); }
public override void OnCreate() { base.OnCreate(); UserDialogs.Init(this); }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.Window.RequestFeature(WindowFeatures.ActionBar); base.OnCreate(bundle); mContext = this; Instance = this; try { var width = Resources.DisplayMetrics.WidthPixels; var height = Resources.DisplayMetrics.HeightPixels; var density = Resources.DisplayMetrics.Density; //屏幕密度 App.ScreenWidth = width / density; //屏幕宽度 App.ScreenHeight = height / density; //屏幕高度 } catch (System.Exception) { } //返回此活动是否为任务的根 if (!IsTaskRoot) { Finish(); return; } PowerManager pm = (PowerManager)GetSystemService(Context.PowerService); isPause = pm.IsScreenOn; if (handler == null) { handler = new Handler(); } //注册广播,屏幕点亮状态监听,用于单独控制音乐播放 if (screenStateReceiver == null) { screenStateReceiver = new ScreenStateReceiver(); var intentFilter = new IntentFilter(); intentFilter.AddAction("_ACTION_SCREEN_OFF"); //熄屏 intentFilter.AddAction("_ACTION_SCREEN_ON"); //点亮 intentFilter.AddAction("_ACTION_BACKGROUND"); //后台 intentFilter.AddAction("_ACTION_FOREGROUND"); //前台 RegisterReceiver(screenStateReceiver, intentFilter); } Window.AddFlags(WindowManagerFlags.KeepScreenOn); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { Window.ClearFlags(WindowManagerFlags.TranslucentStatus); Window.AddFlags(WindowManagerFlags.TranslucentNavigation); TranslucentStatubar.Immersive(Window); Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); Window.ClearFlags(WindowManagerFlags.Fullscreen); } //在andrioid m之后,必须在运行时请求权限 GetPersimmions(); //图片裁切 BitImageEditor.Droid.Platform.Init(this, bundle); //初始 Popup Popup.Init(this); //版本更新配置 AutoUpdate.Init(this, "com.dcms.clientv3.fileprovider"); //初始 Xamarin.Forms 实验性标志 Forms.SetFlags("Shell_Experimental", "SwipeView_Experimental", "CarouselView_Experimental", "RadioButton_Experimental", "IndicatorView_Experimental", "Expander_Experimental", "Visual_Experimental", "CollectionView_Experimental", "FastRenderers_Experimental"); #region //初始 FFImageLoading CachedImageRenderer.Init(true); CachedImageRenderer.InitImageViewHandler(); ImageCircleRenderer.Init(); var config = new FFImageLoading.Config.Configuration() { VerboseLogging = false, VerbosePerformanceLogging = false, VerboseMemoryCacheLogging = false, VerboseLoadingCancelledLogging = false, }; ImageService.Instance.Initialize(config); #endregion Forms.Init(this, bundle); //初始 对话框组件 UserDialogs.Init(this); //初始 ZXing ZXingPlatform.Platform.Init(); LoadApplication(new App(new AndroidInitializer())); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); //// loading Japanese font from Assets folder //var fontName = "Roboto-Regular.ttf"; //var fontPath = System.IO.Path.Combine(CacheDir.AbsolutePath, fontName); //using (var asset = Assets.Open(fontName)) //{ // using (var dest = System.IO.File.Open(fontPath, System.IO.FileMode.Create)) // { // asset.CopyTo(dest); // } //} //// overriding default font with custom font that supports Japanese symbols //var font = SkiaSharp.SKTypeface.FromFile(fontPath); //Infragistics.Core.Controls.TypefaceManager.Instance.OverrideDefaultTypeface(font); UserDialogs.Init(this); //Below lines are required for notifications global::Xamarin.Forms.Forms.Init(this, savedInstanceState); //LoadApplication(new App()); //if (!IsPlayServiceAvailable()) //{ // throw new Exception("This device does not have Google Play Services and cannot receive push notifications."); //} //CreateNotificationChannel(); if (Intent.Extras != null) { foreach (var key in Intent.Extras.KeySet()) { if (key != null) { var value = Intent.Extras.GetString(key); Log.Debug(TAG, "Key: {0} Value: {1}", key, value); } } } IsPlayServicesAvailable(); CreateNotificationChannel(); //End of lines needed for notifications global::Xamarin.Auth.Presenters.XamarinAndroid.AuthenticationConfiguration.Init(this, savedInstanceState); global::Xamarin.Auth.CustomTabsConfiguration.CustomTabsClosingMessage = null; Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); //testing with forms9patch Forms9Patch.Droid.Settings.Initialize(this); LoadApplication(new App()); }
protected override void OnCreate(Bundle savedInstanceState) { Current = this; TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; SetSupportActionBar((Toolbar)FindViewById(ToolbarResource)); this.Window.AddFlags(WindowManagerFlags.Fullscreen | WindowManagerFlags.TurnScreenOn | WindowManagerFlags.HardwareAccelerated); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Settings.CustomUserDataDirectory = Application.Context.GetExternalFilesDir(null).ToString(); Log.Info("MP", "Settings.CustomUserDataDirectory " + Settings.CustomUserDataDirectory); WinForms.BundledPath = Application.Context.ApplicationInfo.NativeLibraryDir; Log.Info("MP", "WinForms.BundledPath " + WinForms.BundledPath); Test.UsbDevices = new USBDevices(); Test.Radio = new Radio(); //ConfigFirmwareManifest.ExtraDeviceInfo /* * var intent = new global::Android.Content.Intent(Intent.ActionOpenDocumentTree); * * intent.AddFlags(ActivityFlags.GrantWriteUriPermission | ActivityFlags.GrantReadUriPermission); * intent.PutExtra(DocumentsContract.ExtraInitialUri, "Mission Planner"); * * StartActivityForResult(intent, 1); */ UserDialogs.Init(this); AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironment_UnhandledExceptionRaiser; base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); { if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) != (int)Permission.Granted || ContextCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage) != (int)Permission.Granted) { ActivityCompat.RequestPermissions(this, new String[] { Manifest.Permission.AccessFineLocation, Manifest.Permission.LocationHardware, Manifest.Permission.WriteExternalStorage, Manifest.Permission.ReadExternalStorage }, 1); } while (ContextCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage) != (int)Permission.Granted) { Thread.Sleep(1000); } } { // print some info var pm = this.PackageManager; var name = this.PackageName; var pi = pm.GetPackageInfo(name, PackageInfoFlags.Activities); Console.WriteLine("pi.ApplicationInfo.DataDir " + pi?.ApplicationInfo?.DataDir); Console.WriteLine("pi.ApplicationInfo.DeviceProtectedDataDir " + pi?.ApplicationInfo?.DeviceProtectedDataDir); Console.WriteLine("pi.ApplicationInfo.NativeLibraryDir " + pi?.ApplicationInfo?.NativeLibraryDir); } { try { // restore assets Directory.CreateDirectory(Settings.GetUserDataDirectory()); File.WriteAllText(Settings.GetUserDataDirectory() + Path.DirectorySeparatorChar + "airports.csv", new StreamReader(Resources.OpenRawResource( Xamarin.Droid.Resource.Raw.airports)).ReadToEnd()); File.WriteAllText( Settings.GetUserDataDirectory() + Path.DirectorySeparatorChar + "BurntKermit.mpsystheme", new StreamReader( Resources.OpenRawResource( Droid.Resource.Raw.BurntKermit)).ReadToEnd()); File.WriteAllText( Settings.GetUserDataDirectory() + Path.DirectorySeparatorChar + "ParameterMetaData.xml", new StreamReader( Resources.OpenRawResource( Droid.Resource.Raw.ParameterMetaDataBackup)).ReadToEnd()); File.WriteAllText( Settings.GetUserDataDirectory() + Path.DirectorySeparatorChar + "camerasBuiltin.xml", new StreamReader( Resources.OpenRawResource( Droid.Resource.Raw.camerasBuiltin)).ReadToEnd()); File.WriteAllText( Settings.GetUserDataDirectory() + Path.DirectorySeparatorChar + "checklistDefault.xml", new StreamReader( Resources.OpenRawResource( Droid.Resource.Raw.checklistDefault)).ReadToEnd()); File.WriteAllText( Settings.GetUserDataDirectory() + Path.DirectorySeparatorChar + "mavcmd.xml", new StreamReader( Resources.OpenRawResource( Droid.Resource.Raw.mavcmd)).ReadToEnd()); } catch (Exception ex) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("Error"); alert.SetMessage("Failed to save to storage " + ex.ToString()); alert.SetNeutralButton("OK", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); } } global::Xamarin.Forms.Forms.Init(this, savedInstanceState); { // clean start, see if it was an intent/usb attach if (savedInstanceState == null) { proxyIfUsbAttached(this.Intent); } } LoadApplication(new App()); }
public static void Register(IApplication application, Activity context, Bundle bundle) { UserDialogs.Init(context); CachedImageRenderer.Init(true); Task.Run(() => CrossMedia.Current.Initialize()); }
void ContinueInit() { var list = Application.Context.GetExternalFilesDirs(null); list.ForEach(a => Log.Info("MP", "External dir option: " + a.AbsolutePath)); var list2 = Application.Context.GetExternalFilesDirs(Environment.DirectoryDownloads); list2.ForEach(a => Log.Info("MP", "External DirectoryDownloads option: " + a.AbsolutePath)); var pref = this.GetSharedPreferences("pref", FileCreationMode.Private); Settings.CustomUserDataDirectory = Application.Context.GetExternalFilesDir(null).ToString(); //pref.GetString("Directory", Application.Context.GetExternalFilesDir(null).ToString()); Log.Info("MP", "Settings.CustomUserDataDirectory " + Settings.CustomUserDataDirectory); try { WinForms.BundledPath = Application.Context.ApplicationInfo.NativeLibraryDir; } catch { } Log.Info("MP", "WinForms.BundledPath " + WinForms.BundledPath); Test.BlueToothDevice = new BTDevice(); Test.UsbDevices = new USBDevices(); Test.Radio = new Radio(); Test.GPS = new GPS(); Test.SystemInfo = new SystemInfo(); androidvideo = new AndroidVideo(); //disable //androidvideo.Start(); AndroidVideo.onNewImage += (e, o) => { WinForms.SetHUDbg(o); }; //ConfigFirmwareManifest.ExtraDeviceInfo /* * var intent = new global::Android.Content.Intent(Intent.ActionOpenDocumentTree); * * intent.AddFlags(ActivityFlags.GrantWriteUriPermission | ActivityFlags.GrantReadUriPermission); * intent.PutExtra(DocumentsContract.ExtraInitialUri, "Mission Planner"); * * StartActivityForResult(intent, 1); */ UserDialogs.Init(this); AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironment_UnhandledExceptionRaiser; { if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) != (int)Permission.Granted || ContextCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage) != (int)Permission.Granted || ContextCompat.CheckSelfPermission(this, Manifest.Permission.Bluetooth) != (int)Permission.Granted) { ActivityCompat.RequestPermissions(this, new String[] { Manifest.Permission.AccessFineLocation, Manifest.Permission.LocationHardware, Manifest.Permission.WriteExternalStorage, Manifest.Permission.ReadExternalStorage, Manifest.Permission.Bluetooth }, 1); } while (ContextCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage) != (int)Permission.Granted) { Thread.Sleep(1000); var text = "Checking Permissions - " + DateTime.Now.ToString("T"); DoToastMessage(text); } } try { // print some info var pm = this.PackageManager; var name = this.PackageName; var pi = pm.GetPackageInfo(name, PackageInfoFlags.Activities); Console.WriteLine("pi.ApplicationInfo.DataDir " + pi?.ApplicationInfo?.DataDir); Console.WriteLine("pi.ApplicationInfo.NativeLibraryDir " + pi?.ApplicationInfo?.NativeLibraryDir); // api level 24 - android 7 Console.WriteLine("pi.ApplicationInfo.DeviceProtectedDataDir " + pi?.ApplicationInfo?.DeviceProtectedDataDir); } catch {} { // clean start, see if it was an intent/usb attach //if (savedInstanceState == null) { DoToastMessage("Init Saved State"); proxyIfUsbAttached(this.Intent); Console.WriteLine(this.Intent?.Action); Console.WriteLine(this.Intent?.Categories); Console.WriteLine(this.Intent?.Data); Console.WriteLine(this.Intent?.DataString); Console.WriteLine(this.Intent?.Type); } } GC.Collect(); /* * Task.Run(() => * { * var gdaldir = Settings.GetRunningDirectory() + "gdalimages"; * Directory.CreateDirectory(gdaldir); * * MissionPlanner.Utilities.GDAL.GDALBase = new GDAL.GDAL(); * * GDAL.GDAL.ScanDirectory(gdaldir); * * GMap.NET.MapProviders.GMapProviders.List.Add(GDAL.GDALProvider.Instance); * }); */ DoToastMessage("Launch App"); LoadApplication(new App()); }
protected override void InitializeFirstChance() { base.InitializeFirstChance(); UserDialogs.Init(() => Mvx.IoCProvider.Resolve <IMvxAndroidCurrentTopActivity>().Activity); ActionSheetConfig.DefaultAndroidStyleId = Resource.Style.MainTheme_BottomSheet; }
protected override void InitializeFirstChance() { UserDialogs.Init(() => Mvx.Resolve <IMvxAndroidCurrentTopActivity>().Activity); //Mvx.RegisterType<IDialogService, DialogService>(); base.InitializeFirstChance(); }
private void Copy(string copyText, string alertLabel) { _clipboardService.CopyToClipboard(copyText); UserDialogs.Toast(string.Format(AppResources.ValueHasBeenCopied, alertLabel)); }
protected override void OnCreate(Bundle bundle) { try { FormsAppCompatActivity.ToolbarResource = Resource.Layout.Toolbar; FormsAppCompatActivity.TabLayoutResource = Resource.Layout.Tabbar; base.OnCreate(bundle); if (Settings.TurnFullScreenOn) { this.Window.AddFlags(WindowManagerFlags.Fullscreen); this.Window.AddFlags(WindowManagerFlags.KeepScreenOn); } if (Settings.TurnSecurityProtocolType3072On) { ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; HttpClient client = new HttpClient(new Xamarin.Android.Net.AndroidClientHandler()); } if (Settings.TurnTrustFailureOn_WebException) { //If you are Getting this error >>> System.Net.WebException: Error: TrustFailure /// then Set it to true System.Net.ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true; System.Security.Cryptography.AesCryptoServiceProvider b = new System.Security.Cryptography.AesCryptoServiceProvider(); } //Methods =>> Copy the text AndroidClipboardManager = (ClipboardManager)GetSystemService(ClipboardService); CachedImageRenderer.Init(); var ignore = new CircleTransformation(); var assembliesToInclude = new List <Assembly>() { typeof(CachedImage).GetTypeInfo().Assembly, typeof(CachedImageRenderer).GetTypeInfo().Assembly }; SegmentedControlRenderer.Init(); PullToRefreshLayoutRenderer.Init(); FFImageLoading.Forms.Droid.CachedImageRenderer.Init(); global::Xamarin.Forms.Forms.Init(this, bundle); try { var activity = Xamarin.Forms.Forms.Context; File httpCacheDir = new File(activity.CacheDir, "http"); long httpCacheSize = 10 * 1024 * 1024; // 10 MiB HttpResponseCache.Install(httpCacheDir, httpCacheSize); } catch (IOException ce) { } UserDialogs.Init(this); MobileAds.Initialize(ApplicationContext, Settings.Ad_Unit_ID); FormsWebViewRenderer.Initialize(); LoadApplication(new App()); } catch (Exception e) { Console.WriteLine(e); } }
protected override void InitializeFirstChance() { base.InitializeFirstChance(); UserDialogs.Init(() => Mvx.IoCProvider.Resolve <IMvxAndroidCurrentTopActivity>().Activity); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); UserDialogs.Init(this); LocalNotificationsImplementation.NotificationIconId = Resource.Drawable.icon; }
public SplashScreen() : base(Resource.Layout.SplashScreen) { UserDialogs.Init(() => Mvx.Resolve <IMvxAndroidCurrentTopActivity>().Activity); }
protected override void OnCreate(Bundle bundle) { // Changing to App's theme since we are OnCreate and we are ready to // "hide" the splash base.Window.RequestFeature(WindowFeatures.ActionBar); base.SetTheme(Resource.Style.AppTheme); FormsAppCompatActivity.ToolbarResource = Resource.Layout.Toolbar; FormsAppCompatActivity.TabLayoutResource = Resource.Layout.Tabs; base.OnCreate(bundle); //CrashManager.Register(this, GridCentral.Helpers.Keys.HockeyId_Android); //MetricsManager.Register(Application, GridCentral.Helpers.Keys.HockeyId_Android); //Initializing FFImageLoading CachedImageRenderer.Init(); global::Xamarin.Forms.Forms.Init(this, bundle); CarouselViewRenderer.Init(); UXDivers.Artina.Shared.GrialKit.Init(this, "GridCentral.Droid.GrialLicense"); UserDialogs.Init(() => (Activity)Forms.Context); PhoneCallImplementation.Init(); FormsHelper.ForceLoadingAssemblyContainingType(typeof(UXDivers.Effects.Effects)); mPushNotify paramValue = new mPushNotify(); paramValue.Messgae = Intent.GetStringExtra("message"); paramValue.Objecter = Intent.GetStringExtra("objecter"); paramValue.Type = Intent.GetStringExtra("type"); paramValue.Why = Intent.GetStringExtra("why"); if (!String.IsNullOrEmpty(paramValue.Messgae)) { LoadApplication(new App(paramValue)); } else { LoadApplication(new App()); //LoadApplication(UXDivers.Gorilla.Droid.Player.CreateApplication( // this, // new UXDivers.Gorilla.Config("Good Gorilla").RegisterAssembliesFromTypes<UXDivers.Artina.Shared.CircleImage, // GrialShapesFont, BindablePicker, XLabs.Forms.Controls.CheckBox, CarouselViewControl>())); } try { // Check to ensure everything's set up right GcmClient.CheckDevice(this); GcmClient.CheckManifest(this); // Register for push notifications System.Diagnostics.Debug.WriteLine("Registering..."); GcmClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS); } catch (Java.Net.MalformedURLException) { CreateAndShowDialog("There was an error creating the client. Verify the URL.", "Error"); } catch (Exception e) { CreateAndShowDialog(e.Message, "Error"); } CheckForUpdates(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); viewModel = new ImageSearchViewModel(); //Setup RecyclerView adapter = new ImageAdapter(this, viewModel); recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); recyclerView.SetAdapter(adapter); layoutManager = new GridLayoutManager(this, 2); recyclerView.SetLayoutManager(layoutManager); progressBar = FindViewById <ProgressBar>(Resource.Id.my_progress); progressBar.Visibility = ViewStates.Gone; var query = FindViewById <EditText>(Resource.Id.my_query); // Get our button from the layout resource, // and attach an event to it var clickButton = FindViewById <Button>(Resource.Id.my_button); clickButton.Click += async(sender, args) => { clickButton.Enabled = false; progressBar.Visibility = ViewStates.Visible; await viewModel.SearchForImagesAsync(query.Text); progressBar.Visibility = ViewStates.Gone; clickButton.Enabled = true; }; var photo = FindViewById <Button>(Resource.Id.button1); photo.Click += async(sender, args) => { await viewModel.TakePhotoAndAnalyzeAsync(); }; adapter.ItemClick += async(sender, args) => { clickButton.Enabled = false; progressBar.Visibility = ViewStates.Visible; await viewModel.AnalyzeImageAsync(viewModel.Images[args.Position].ImageLink); progressBar.Visibility = ViewStates.Gone; clickButton.Enabled = true; }; UserDialogs.Init(this); SupportActionBar.SetDisplayHomeAsUpEnabled(false); SupportActionBar.SetHomeButtonEnabled(false); }
public static void Init(FormsAppCompatActivity activity) { UserDialogs.Init(activity); CachedImageRenderer.Init(true); }
async Task ExecuteOnAppearingLogin(Page loginPage) { if (IsBusy) { return; } IsBusy = true; try { using (UserDialogs.Loading("Checking connection...")) { //Check Location Services first var check = await App.CheckLocationServices(); if (check != Plugin.Permissions.Abstractions.PermissionStatus.Granted) { Device.BeginInvokeOnMainThread(() => { if (check != Plugin.Permissions.Abstractions.PermissionStatus.Unknown) { App.LocationServicesFailure(); } App.GoLogout(); }); IsBusy = false; return; } } } catch (Exception ex) { Console.WriteLine(ex.Message); Device.BeginInvokeOnMainThread(() => { App.LocationServicesFailure(); }); IsBusy = false; return; } try { _ = Task.Run(async() => { // Look for existing account IEnumerable <IAccount> accounts = await App.AuthenticationClient.GetAccountsAsync(); if (accounts.Count() > 0) { using (UserDialogs.Loading("Logging in automatically...")) { AuthenticationResult result = await App.AuthenticationClient .AcquireTokenSilent(CommonConstants.Scopes, accounts.FirstOrDefault()) .ExecuteAsync(); string signInValue = ""; var token = new JwtSecurityToken(result.IdToken); bool emailSignIn = true; foreach (var claim in token.Claims) { if (claim.Type == "emails" || claim.Type == "signInNames.emailAddress") { signInValue = claim.Value; } else if (claim.Type == "signInNames.phoneNumber") { signInValue = claim.Value; emailSignIn = false; } } if (!String.IsNullOrEmpty(signInValue)) { Console.WriteLine("User '" + signInValue + "' already logged in, showing LOADS page"); await GotoList(signInValue, loginPage, emailSignIn); await App.soapService.StartListening(); } else { Console.WriteLine("User not logged in, showing Login page"); } } } else { Console.WriteLine("User not logged in, showing Login page"); } }); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); Console.WriteLine("User not logged in, showing Login page"); } finally { IsBusy = false; } }