Esempio n. 1
0
        protected override void Initialize(Application application, Dictionary<string, Type> views, Dictionary<string, Type> dialogs)
        {
            base.Initialize(application, views, dialogs);

            RegisterInstance<IImagePickerService>(new ImagePickerService());
            RegisterInstance<ILocalizationService>(new LocalizationService(application, typeof(Resource.String)));
        }
Esempio n. 2
0
        public static void UpdateWindowSoftInputModeAdjust(this AApplication platformView, Application application)
        {
            var adjust = SoftInput.AdjustPan;

            if (Application.Current != null)
            {
                WindowSoftInputModeAdjust elementValue = Application.Current.OnThisPlatform().GetWindowSoftInputModeAdjust();

                switch (elementValue)
                {
                case WindowSoftInputModeAdjust.Resize:
                    adjust = SoftInput.AdjustResize;
                    break;

                case WindowSoftInputModeAdjust.Unspecified:
                    adjust = SoftInput.AdjustUnspecified;
                    break;

                default:
                    adjust = SoftInput.AdjustPan;
                    break;
                }
            }

            IMauiContext mauiContext = application.FindMauiContext(true);
            Context      context     = mauiContext?.Context;
            Activity     activity    = context.GetActivity();

            activity?.Window?.SetSoftInputMode(adjust);
        }
        public AuthenticationService(IMobileServiceClient mobileService, Application application)
        {
            this.mobileService = mobileService;

            application.RegisterActivityLifecycleCallbacks(lifecycleHandler);

            lifecycleHandler.ActivityResumed += (s, e) => currentActivity = e.Activity;
        }
Esempio n. 4
0
 public static void Uninit(Android.App.Application app)
 {
     if (activityLifecycleManager != null)
     {
         app.UnregisterActivityLifecycleCallbacks(activityLifecycleManager);
         activityLifecycleManager = null;
     }
 }
Esempio n. 5
0
        public static void Init(Android.App.Application app, bool requestPublishPermissions)
        {
            RequestPublishPermissions = requestPublishPermissions;

            app.RegisterActivityLifecycleCallbacks(activityLifecycleManager);

            FacebookApi.IsUsingNative             = true;
            FacebookApi.ShowFacebookAuthenticator = Login;
        }
Esempio n. 6
0
        public static void InitializeIfNeeded(Context ctx, Application app)
        {
            if (_initialized) return;

            CrashManager.Register(ctx);
            MetricsManager.Register(ctx, app);

            _initialized = true;
        }
Esempio n. 7
0
        public static void Init(Android.App.Application app)
        {
            SocialAuthManager.Current.AccountStore.SecureStore = new SecureStore();

            if (activityLifecycleManager == null)
            {
                activityLifecycleManager = new ActivityLifecycleCallbackManager();
                app.RegisterActivityLifecycleCallbacks(activityLifecycleManager);
            }
        }
 public void Initialize(Application application)
 {
     _config =
         application.GetType().GetCustomAttributes(typeof(GoogleFormReporterSettingsAttribute), false).SingleOrDefault()
         as GoogleFormReporterSettingsAttribute;
     if (_config == null)
         throw new ArgumentException("Application class need to be marked with GoogleFormReporterAttribute");
     if (string.IsNullOrEmpty(_config.FormKey))
         throw new ArgumentException("FromKey can not be null or empty");
     _formUrl = new Uri("https://docs.google.com/spreadsheet/formResponse?formkey=" + _config.FormKey + "&ifq");
 }
Esempio n. 9
0
        public static void Activate(Android.App.Application app)
        {
            Native.RegisterCallBack("CustomTabs", OnActivityResult);
            OAuthApi.ShowAuthenticator = ShowAuthenticator;

            if (activityLifecycleManager == null)
            {
                activityLifecycleManager = new ActivityLifecycleCallbackManager();
                app.RegisterActivityLifecycleCallbacks(activityLifecycleManager);
            }
            IsActivated = true;
        }
 public static void InitSdk(Android.App.Application application)
 {
     Application         = application;
     userDetailsProvider = new BandyerSdkUserDetailsProvider();
     BandyerSDK.Builder builder = new BandyerSDK.Builder(application, BandyerSdkForms.AppId)
                                  .SetEnvironment(Com.Bandyer.Android_sdk.Environment.Configuration.Sandbox())
                                  .WithCallEnabled(new BandyerSdkCallNotificationListener())
                                  .WithFileSharingEnabled()
                                  .WithWhiteboardEnabled()
                                  .WithChatEnabled()
                                  .WithUserDetailsProvider(userDetailsProvider);
     BandyerSDK.Init(builder);
 }
Esempio n. 11
0
        private void HandleActivityLifeCycle()
        {
            _callbacks = new MapLifeCycleCallBacks(onPause: _internalMapView.OnPause, onResume: _internalMapView.OnResume);

            _application = Context.ApplicationContext as Android.App.Application;
            if (_application != null)
            {
                _application.RegisterActivityLifecycleCallbacks(_callbacks);
            }
            else
            {
                this.Log().Error("ApplicationContext is invalid, could not RegisterActivityLifecycleCallbacks to release GPS when application is paused.");
            }
        }
        public AutoSuspendHelper(Application hostApplication)
        {
            hostApplication.RegisterActivityLifecycleCallbacks(new ObservableLifecycle(this));

            Observable.Merge(onCreate, onSaveInstanceState).Subscribe(x => LatestBundle = x);

            RxApp.SuspensionHost.IsLaunchingNew = onCreate.Where(x => x == null).Select(_ => Unit.Default);
            RxApp.SuspensionHost.IsResuming = onCreate.Where(x => x != null).Select(_ => Unit.Default);
            RxApp.SuspensionHost.IsUnpausing = onRestart;

            RxApp.SuspensionHost.ShouldPersistState = Observable.Merge(
                onPause.Select(_ => Disposable.Empty), onSaveInstanceState.Select(_ => Disposable.Empty));

            RxApp.SuspensionHost.ShouldInvalidateState = untimelyDemise;
        }
Esempio n. 13
0
 public void Register(Android.App.Application application)
 {
     if (mLastApp != null)
     {
         Application app;
         mLastApp.TryGetTarget(out app);
         if (application == app)
         {
             return;
         }
         else
         {
             mLastApp = new WeakReference <Application>(application);
         }
         application.RegisterActivityLifecycleCallbacks(this);
     }
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            mApplication = this.Application;
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            var listener = new Listener();

            FireCrasher.Instance.Install(this.Application, listener);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);

            fab.Click += FabOnClick;
        }
Esempio n. 15
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			
			// set our layout to be the home screen
			this.SetContentView(Resource.Layout.HomeScreen);

			//Find our controls
			this._taskListView = FindViewById<ListView> (Resource.Id.lstTasks);
			this._addTaskButton = FindViewById<Button> (Resource.Id.btnAddTask);
			app = this.Application;
			// wire up add task button handler
			if(this._addTaskButton != null)
			{
				this._addTaskButton.Click += (sender, e) => {
					this.StartActivity(typeof(TaskDetailsScreen));
				};
			}
			
			// wire up task click handler
			if(this._taskListView != null)
			{
				this._taskListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
					var taskDetails = new Intent (this, typeof (TaskDetailsScreen));
					taskDetails.PutExtra ("TaskID", this._tasks[e.Position].ID);
					this.StartActivity (taskDetails);
				};
			}

			// enable this to see logging
			//NativeCSS.SetDebugLogging(true);

			// To live edit, cd to styles.css and run "python -m SimpleHTTPServer"
			NativeCSS.StyleWithCSS("styles.css",
			                       new Uri("http://10.0.2.2:8000/styles.css"), 
			                       RemoteContentRefreshPeriod.EveryFiveSeconds);
				 	
		}
Esempio n. 16
0
 public AndroidScanner(Android.App.Application androidApplication)
 {
     _androidApplication = androidApplication;
 }
 public AppModule(Application app)
 {
     context = app;
 }
        public ApplicationNavigationService(Application application)
        {
            application.RegisterActivityLifecycleCallbacks(lifecycleHandler);

            lifecycleHandler.ActivityResumed += (s, e) => currentActivity = e.Activity;
        }
Esempio n. 19
0
 public SecureStore(Android.App.Application app)
 {
     activityLifecycleManager = new ActivityLifecycleCallbackManager();
     app.RegisterActivityLifecycleCallbacks(activityLifecycleManager);
 }
Esempio n. 20
0
 public AndroidViewProxy(Application.AndroidApplicationContext context, BaseScreen activity)
     : base(context)
 {
     _activity = activity;
 }
Esempio n. 21
0
        protected ActivityAwareService(Application application)
        {
            lifecycleHandler.ActivityResumed += (s, e) => CurrentActivity = e.Activity;

            application.RegisterActivityLifecycleCallbacks(lifecycleHandler);
        }
Esempio n. 22
0
 /// <summary>
 /// Initialize android user dialogs
 /// </summary>
 public static void Init(Application app) {
     ActivityLifecycleCallbacks.Register(app);
     Init((() => ActivityLifecycleCallbacks.CurrentTopActivity));
 }
Esempio n. 23
0
 public SystemStatus(Application app, int systemType)
     : this(app, systemType, 0)
 {
 }
Esempio n. 24
0
 public SystemStatus(Application app, string name)
 {
     this.app = app;
     this.name = name;
 }
		protected void LoadApplication(Application application)
		{
			if (application == null)
				throw new ArgumentNullException("application");

			(application as IApplicationController)?.SetAppIndexingProvider(new AndroidAppIndexProvider(this));

			_application = application;
			Xamarin.Forms.Application.Current = application;

			application.PropertyChanged += AppOnPropertyChanged;

			SetMainPage();
		}
Esempio n. 26
0
 public SystemStatus(Application app, int systemType, int status)
 {
     this.app = app;
     setSystemType(systemType);
     setStatus(status);
 }
		protected void LoadApplication(Application application)
		{
			if (application == null)
				throw new ArgumentNullException("application");

			_application = application;
			Xamarin.Forms.Application.Current = application;

			application.PropertyChanged += AppOnPropertyChanged;

			SetMainPage();
		}
Esempio n. 28
0
 public FontManager(Application app)
 {
     _context = app.ApplicationContext;
     _fontResources = new Dictionary<Font, Typeface>();
     InitResources();
 }
Esempio n. 29
0
 public static void TakeOff(Application application, Action<UAirship> callback)
 {
     TakeOff (application, new AirshipReadyCallback (callback));
 }
Esempio n. 30
0
 public void InitDataBase(Application application)
 {
     _helper = new DatabaseHelper(application, 1);
 }
 public static void Register(Application app)
 {
     app.RegisterActivityLifecycleCallbacks(new ActivityLifecycleCallbacks());
 }
Esempio n. 32
0
 public void InitFontManager(Application application)
 {
     _fontManager = new FontManager(application);
 }
Esempio n. 33
0
 public static void Create(Application app, string accountName, string developerSecret, Config conf)
 {
     JNIEnv.CallStaticVoidMethod(cls,
         JNIEnv.GetStaticMethodID(cls, "create", "(Landroid/app/Application;Ljava/lang/String;Ljava/lang/String;Lcom/tapstream/sdk/Config;)V"),
         new JValue(app), new JValue(new Java.Lang.String(accountName)), new JValue(new Java.Lang.String(developerSecret)), new JValue(conf.handle.Handle));
 }
Esempio n. 34
0
        /// <summary>
        /// Start the application context
        /// </summary>
        public static bool Start(A.Content.Context launcherActivity, A.Content.Context context, A.App.Application application)
        {
            var retVal = new AndroidApplicationContext();

            retVal.Context = context;
            retVal.m_configurationManager = new ConfigurationManager();
            retVal.AndroidApplication     = application;

            // Not configured
            if (!retVal.ConfigurationManager.IsConfigured)
            {
                NoConfiguration?.Invoke(null, EventArgs.Empty);
                return(false);
            }
            else
            { // load configuration
                try
                {
                    // Set master application context
                    ApplicationContext.Current = retVal;
                    retVal.CurrentActivity     = launcherActivity;
                    try
                    {
                        retVal.ConfigurationManager.Load();
                        retVal.ConfigurationManager.Backup();
                    }
                    catch
                    {
                        if (retVal.ConfigurationManager.HasBackup() &&
                            retVal.Confirm(Strings.err_configuration_invalid_restore_prompt))
                        {
                            retVal.ConfigurationManager.Restore();
                            retVal.ConfigurationManager.Load();
                        }
                        else
                        {
                            throw;
                        }
                    }

                    retVal.AddServiceProvider(typeof(AndroidBackupService));

                    retVal.m_tracer = Tracer.GetTracer(typeof(AndroidApplicationContext), retVal.ConfigurationManager.Configuration);

                    // Is there a backup, and if so, does the user want to restore from that backup?
                    var backupSvc = retVal.GetService <IBackupService>();
                    if (backupSvc.HasBackup(BackupMedia.Public) &&
                        retVal.Configuration.GetAppSetting("ignore.restore") == null &&
                        retVal.Confirm(Strings.locale_confirm_restore))
                    {
                        backupSvc.Restore(BackupMedia.Public);
                    }

                    // Ignore restoration
                    if (!retVal.Configuration.GetSection <ApplicationConfigurationSection>().AppSettings.Any(o => o.Key == "ignore.restore"))
                    {
                        retVal.Configuration.GetSection <ApplicationConfigurationSection>().AppSettings.Add(new AppSettingKeyValuePair()
                        {
                            Key   = "ignore.restore",
                            Value = "true"
                        });
                    }

                    // HACK: For some reason the PCL doesn't do this automagically
                    //var connectionString = retVal.Configuration.GetConnectionString("openIzWarehouse");
                    //if (!File.Exists(connectionString.Value))
                    //{
                    //    retVal.m_tracer.TraceInfo("HAX: Creating warehouse file since PCL can't... {0}", connectionString.Value);
                    //    SqliteConnection.CreateFile(connectionString.Value);
                    //}
                    // Load configured applets
                    var configuredApplets = retVal.Configuration.GetSection <AppletConfigurationSection>().Applets;

                    retVal.SetProgress(context.GetString(Resource.String.startup_configuration), 0.2f);
                    var appletManager = retVal.GetService <IAppletManagerService>();

                    // Load all user-downloaded applets in the data directory
                    foreach (var appletInfo in configuredApplets)// Directory.GetFiles(this.m_configuration.GetSection<AppletConfigurationSection>().AppletDirectory)) {
                    {
                        try
                        {
                            retVal.m_tracer.TraceInfo("Loading applet {0}", appletInfo);
                            String appletPath = Path.Combine(retVal.Configuration.GetSection <AppletConfigurationSection>().AppletDirectory, appletInfo.Id);

                            if (!File.Exists(appletPath)) // reinstall
                            {
                                retVal.Configuration.GetSection <AppletConfigurationSection>().Applets.Clear();
                                retVal.SaveConfiguration();
                                retVal.Alert(Strings.locale_restartRequired);
                                throw new AppDomainUnloadedException();
                            }

                            // Load
                            using (var fs = File.OpenRead(appletPath))
                            {
                                AppletManifest manifest = AppletManifest.Load(fs);
                                // Is this applet in the allowed applets

                                // public key token match?
                                if (appletInfo.PublicKeyToken != manifest.Info.PublicKeyToken)
                                {
                                    retVal.m_tracer.TraceWarning("Applet {0} failed validation", appletInfo);
                                    ; // TODO: Raise an error
                                }

                                appletManager.LoadApplet(manifest);
                            }
                        }
                        catch (AppDomainUnloadedException) { throw; }
                    }
                    catch (Exception e)
                    {
                        retVal.m_tracer.TraceError("Applet Load Error: {0}", e);
                        if (retVal.Confirm(String.Format(Strings.err_applet_corrupt_reinstall, appletInfo.Id)))
                        {
                            String appletPath = Path.Combine(retVal.Configuration.GetSection <AppletConfigurationSection>().AppletDirectory, appletInfo.Id);
                            if (File.Exists(appletPath))
                            {
                                File.Delete(appletPath);
                            }
                        }
                        else
                        {
                            retVal.m_tracer.TraceError("Loading applet {0} failed: {1}", appletInfo, e.ToString());
                            throw;
                        }
                    }

                    // Are we going to deploy applets
                    // Upgrade applets from our app manifest
                    foreach (var itm in context.Assets.List("Applets"))
                    {
                        try
                        {
                            retVal.m_tracer.TraceVerbose("Loading {0}", itm);
                            AppletPackage pkg = AppletPackage.Load(context.Assets.Open(String.Format("Applets/{0}", itm)));

                            // Write data to assets directory
#if !DEBUG
                            if (appletManager.GetApplet(pkg.Meta.Id) == null || new Version(appletManager.GetApplet(pkg.Meta.Id).Info.Version) < new Version(pkg.Meta.Version))
#endif
                            appletManager.Install(pkg, true);
                        }
                        catch (Exception e)
                        {
                            retVal.m_tracer?.TraceError(e.ToString());
                        }
                    }

                    // Ensure data migration exists
                    try
                    {
                        // If the DB File doesn't exist we have to clear the migrations
                        if (!File.Exists(retVal.Configuration.GetConnectionString(retVal.Configuration.GetSection <DataConfigurationSection>().MainDataSourceConnectionStringName).Value))
                        {
                            retVal.m_tracer.TraceWarning("Can't find the OpenIZ database, will re-install all migrations");
                            retVal.Configuration.GetSection <DataConfigurationSection>().MigrationLog.Entry.Clear();
                        }
                        retVal.SetProgress(context.GetString(Resource.String.startup_data), 0.6f);

                        DataMigrator migrator = new DataMigrator();
                        migrator.Ensure();

                        // Set the entity source
                        EntitySource.Current = new EntitySource(retVal.GetService <IEntitySourceProvider>());

                        ApplicationServiceContext.Current  = ApplicationContext.Current;
                        ApplicationServiceContext.HostType = OpenIZHostType.MobileClient;
                    }
                    catch (Exception e)
                    {
                        retVal.m_tracer.TraceError(e.ToString());
                        throw;
                    }
                    finally
                    {
                        retVal.ConfigurationManager.Save();
                    }

                    // Is there a backup manager? If no then we will use the default backup manager


                    // Start daemons
                    ApplicationContext.Current.GetService <IUpdateManager>().AutoUpdate();
                    retVal.GetService <IThreadPoolService>().QueueNonPooledWorkItem(o => { retVal.Start(); }, null);

                    // Set the tracer writers for the PCL goodness!
                    foreach (var itm in retVal.Configuration.GetSection <DiagnosticsConfigurationSection>().TraceWriter)
                    {
                        OpenIZ.Core.Diagnostics.Tracer.AddWriter(itm.TraceWriter, itm.Filter);
                    }
                }
 /// <summary>
 /// Creates an instance of <see cref="AndroidPlatformProvider"/>.
 /// </summary>
 /// <param name="application">The Android Application</param>
 public AndroidPlatformProvider(Application application) {
     application.RegisterActivityLifecycleCallbacks(lifecycleHandler);
 }
Esempio n. 36
0
 public static void TakeOff(Application application, AirshipConfigOptions configOptions, Action<UAirship> callback)
 {
     TakeOff (application, configOptions, new AirshipReadyCallback (callback));
 }
		public void Setup(Context context, Application application, string instrumentationKey)
		{
			Com.Microsoft.Applicationinsights.Library.ApplicationInsights.Setup(context, application, instrumentationKey);
		}