Exemple #1
0
        protected override void OnResume()
        {
            base.OnResume();

            settings.RegisterOnSharedPreferenceChangeListener(this);
            prefListener.OnResume();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            prefs = PreferenceManager.GetDefaultSharedPreferences(this);
            prefs.RegisterOnSharedPreferenceChangeListener(this);
            lastSyncDate = DateTime.Parse(prefs.GetString("LastSyncDate", "1900-12-12"));
            //lastSyncDate = new DateTime(1900,12,12);

            //Init country from preference
            LeagueIds = GetLeaguesFromSharedPreference(prefs);

            //Set content view
            SetContentView(Resource.Layout.Main);

            //Initialize the toolbar
            InitToolbar();

            //Initialize the drawerlayout
            InitDrawerlayout();

            //Get updates and connect to signalr
            Init();

            //Check play services
            if (FirebaseNotificationService.Instance(this).IsPlayServicesAvailable())
            {
                if (FirebaseInstanceId.Instance.Token != null)
                {
                    Log.Debug("Refreshed Token:", FirebaseInstanceId.Instance.Token);
                }
            }
            StartService(new Intent(this, typeof(EventIntentService)));
        }
 /// <summary>
 /// A observable sequence of keys for changed shared preferences.
 /// </summary>
 /// <returns>The observable sequence of keys for changed shared preferences.</returns>
 /// <param name="sharedPreferences">The shared preferences to get the changes from.</param>
 public static IObservable <string?> PreferenceChanged(this ISharedPreferences sharedPreferences) =>
 Observable.Create <string?>(observer =>
 {
     var listener = new OnSharedPreferenceChangeListener(observer);
     sharedPreferences.RegisterOnSharedPreferenceChangeListener(listener);
     return(Disposable.Create(() => sharedPreferences.UnregisterOnSharedPreferenceChangeListener(listener)));
 });
Exemple #4
0
        public SettingsService()
        {
            ISharedPreferences sharedPreferences =
                PreferenceManager.GetDefaultSharedPreferences(CrossCurrentActivity.Current.Activity);

            sharedPreferences.RegisterOnSharedPreferenceChangeListener(this);
        }
Exemple #5
0
 public override void OnResume()
 {
     base.OnResume();
     //必须在这里进行注册,否则分享后跳转回来后未注册,不会执行通知和免提的代码。
     preferences.RegisterOnSharedPreferenceChangeListener(this);
     //Activity.GetPreferences(FileCreationMode.Private).RegisterOnSharedPreferenceChangeListener(this);
 }
Exemple #6
0
        public SettingsService()
        {
            ISharedPreferences sharedPreferences =
                PreferenceManager.GetDefaultSharedPreferences(Forms.Context);

            sharedPreferences.RegisterOnSharedPreferenceChangeListener(this);
        }
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     AddPreferencesFromResource(Resource.Xml.prefs);
     sharedPreferences = PreferenceManager.SharedPreferences;
     sharedPreferences.RegisterOnSharedPreferenceChangeListener(this);
     alarmManager = (AlarmManager)Activity.GetSystemService(Context.AlarmService);
 }
Exemple #8
0
        protected override void OnStart()
        {
            base.OnStart();
            startTime = Java.Lang.JavaSystem.CurrentTimeMillis();
            timerHandler.PostDelayed(timerRunnable, 0);
            ISharedPreferences sRef = PreferenceManager.GetDefaultSharedPreferences(this);

            sRef.RegisterOnSharedPreferenceChangeListener(new OptionsListener(this));
        }
        public override void OnCreatePreferences(Bundle savedInstanceState, string rootKey)
        {
            AddPreferencesFromResource(Resource.Xml.music_widget_prefs);
            if (Build.VERSION.SdkInt > BuildVersionCodes.KitkatWatch)                       //In kitkat you can only use the RemoteController
                                                                                            //thats why you can't choose a music widget control method.
            {
                Preference musiccontrolmethod = FindPreference("musicwidgetcontrolmethod"); //Preference that's disabled by default.
                musiccontrolmethod.Selectable = true;
                musiccontrolmethod.Enabled    = true;
            }
            string         interval           = configurationManager.RetrieveAValue(ConfigurationParameters.MusicWidgetMethod, "1"); //1 is the default value, music_widget_prefs.xml
            ListPreference musicWidgetControl = FindPreference("musicwidgetcontrolmethod") as ListPreference;

            musicWidgetControl.Value   = interval;
            musicWidgetControl.Summary = musicWidgetControl.Entry;

            sharedPreferences.RegisterOnSharedPreferenceChangeListener(this);
        }
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            AddPreferencesFromResource(R.Xmls.preferences);
            ISharedPreferences sharedPreferences = this.PreferenceManager.SharedPreferences;

            DisplayCurrentPreferenceValues(sharedPreferences);
            sharedPreferences.RegisterOnSharedPreferenceChangeListener(this);
        }
Exemple #11
0
        protected override void OnCreate(Bundle savedInstance)
        {
            base.OnCreate(savedInstance);
            SetContentView(R.Layouts.MainLayout);
            main = this;

            PreferenceManager.SetDefaultValues(this, R.Xmls.preferences, false);
            ISharedPreferences sharedPrefs = PreferenceManager.GetDefaultSharedPreferences(this);

            sharedPrefs.RegisterOnSharedPreferenceChangeListener(this);

            var btnTopPilots = FindViewById <Button>(R.Ids.btnPilotStats);

            btnTopPilots.Click += delegate
            {
                var topPilotsIntent = new Intent(this, typeof(TopPilotsActivity));
                StartActivity(topPilotsIntent);
            };
            var btnOnlinePilots = FindViewById <Button>(R.Ids.btnOnlinePilots);

            btnOnlinePilots.Click += delegate
            {
                var onlinePilotsIntent = new Intent(this, typeof(OnlinePilotsActivity));
                StartActivity(onlinePilotsIntent);
            };
            var btnStationInventories = FindViewById <Button>(R.Ids.btnStationInventories);

            btnStationInventories.Click += delegate
            {
                var stationInventoriesIntent = new Intent(this, typeof(StationInventoryActivity));
                StartActivity(stationInventoriesIntent);
            };
            var btnItemStocks = FindViewById <Button>(R.Ids.btnItemStocks);

            btnItemStocks.Click += delegate
            {
                var itemStocksIntent = new Intent(this, typeof(ItemStocksActivity));
                StartActivity(itemStocksIntent);
            };

            var    btnMyPilotStats = FindViewById <Button>(R.Ids.btnMyPilotStats);
            string pilotName       = sharedPrefs.GetString("pref_pilotname", "");

            OnSharedPreferenceChanged(sharedPrefs, "pref_pilotname");
            btnMyPilotStats.Click += delegate
            {
                var    pilotDetails = new Intent(this, typeof(PilotDetailActivity));
                string curPilotName = sharedPrefs.GetString("pref_pilotname", "");
                pilotDetails.PutExtra("pilotID", long.MinValue);
                pilotDetails.PutExtra("pilotName", curPilotName);
                StartActivity(pilotDetails);
            };

            CheckForUpdate();
        }
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            AddPreferencesFromResource(Resource.Xml.settings);

            ISharedPreferences preferences = PreferenceManager.SharedPreferences;

            OnSharedPreferenceChanged(preferences, "paypal_payment_type");
            OnSharedPreferenceChanged(preferences, "android_pay_currency");
            OnSharedPreferenceChanged(preferences, "android_pay_allowed_countries_for_shipping");
            preferences.RegisterOnSharedPreferenceChangeListener(this);
        }
	    public void onCreate() {

		    // Let's restore the state of the service 
		    mSharedPreferences = PreferenceManager.GetDefaultSharedPreferences(this);
		    mPort = Integer.ParseInt(mSharedPreferences.GetString(KEY_PORT,mPort.ToString()));
		    mEnabled = mSharedPreferences.GetBoolean(KEY_ENABLED, mEnabled);

		    // If the configuration is modified, the server will adjust
		    mSharedPreferences.RegisterOnSharedPreferenceChangeListener(this);

		    start();
	    }
		protected override void OnCreate (Bundle bundle) {
			base.OnCreate (bundle);
			AddPreferencesFromResource (Resource.Layout.settings_prefs);

			prefs = PreferenceManager.GetDefaultSharedPreferences(this);
			prefs.RegisterOnSharedPreferenceChangeListener(this);

			prefVersion = FindPreference ("prefVersion");
			prefVersion.Title = Resources.GetString(Resource.String.app_name) + " v" + ApplicationContext.PackageManager.GetPackageInfo (ApplicationContext.PackageName, 0).VersionName + " (" + ApplicationContext.PackageManager.GetPackageInfo (ApplicationContext.PackageName, 0).VersionCode + ")";

			prefHoursNotifications = FindPreference ("prefHoursNotifications");
			prefHoursNotifications.Summary = string.Format (Resources.GetString (Resource.String.settings_interval_description), Resources.GetStringArray(Resource.Array.hours).GetValue(int.Parse(prefs.GetString ("prefHoursNotifications", "4"))-1));

		}
Exemple #15
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            PreferenceManager.SharedPreferencesName = OptionsManager.OPTIONS_FILE;

            AddPreferencesFromResource(Resource.Xml.options);

            m_sharedPreferences = PreferenceManager.SharedPreferences;
            m_sharedPreferences.RegisterOnSharedPreferenceChangeListener(this);

            InitUI();
            RefreshUI();
        }
Exemple #16
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            AddPreferencesFromResource(Resource.Layout.settings_prefs);

            prefs = PreferenceManager.GetDefaultSharedPreferences(this);
            prefs.RegisterOnSharedPreferenceChangeListener(this);

            prefVersion       = FindPreference("prefVersion");
            prefVersion.Title = Resources.GetString(Resource.String.app_name) + " v" + ApplicationContext.PackageManager.GetPackageInfo(ApplicationContext.PackageName, 0).VersionName + " (" + ApplicationContext.PackageManager.GetPackageInfo(ApplicationContext.PackageName, 0).VersionCode + ")";

            prefHoursNotifications         = FindPreference("prefHoursNotifications");
            prefHoursNotifications.Summary = string.Format(Resources.GetString(Resource.String.settings_interval_description), Resources.GetStringArray(Resource.Array.hours).GetValue(int.Parse(prefs.GetString("prefHoursNotifications", "4")) - 1));
        }
Exemple #17
0
        public override void OnCreatePreferences(Bundle savedInstanceState, string rootKey)
        {
            PreferenceManager.SharedPreferencesName = "weatherpreferences";
            PreferenceManager.SharedPreferencesMode = (int)FileCreationMode.Private;
            AddPreferencesFromResource(Resource.Xml.weather_widget_prefs);
            string city = configurationManager.RetrieveAValue(ConfigurationParameters.WeatherCity, string.Empty);

            if (city != string.Empty)
            {
                Preference weatherCity = FindPreference("weathercity");
                weatherCity.Summary = city;
            }
            string country = configurationManager.RetrieveAValue(ConfigurationParameters.WeatherCountryCode, string.Empty);

            if (country == string.Empty)
            {
                TelephonyManager tm          = (TelephonyManager)Activity.GetSystemService(Context.TelephonyService);
                string           countryCode = tm.NetworkCountryIso;
                configurationManager.SaveAValue(ConfigurationParameters.WeatherCountryCode, countryCode);
            }
            country = configurationManager.RetrieveAValue(ConfigurationParameters.WeatherCountryCode, string.Empty);
            if (country != string.Empty)
            {
                Preference weatherCountry = FindPreference("weathercountrycode");
                weatherCountry.Summary = country;
            }
            string interval = configurationManager.RetrieveAValue(ConfigurationParameters.WeatherUpdateFrequency, "-1");

            if (interval != "-1")
            {
                ListPreference weatherUpdateFrequency = FindPreference("weatherupdatefrequency") as ListPreference;
                weatherUpdateFrequency.Value   = interval;
                weatherUpdateFrequency.Summary = weatherUpdateFrequency.Entry;
            }

            sharedPreferences.RegisterOnSharedPreferenceChangeListener(this);
        }
Exemple #18
0
        public AppPrefs(Context context, ISharedPreferences prefs)
        {
            this.context = context;
            this.prefs   = prefs;
            _device      = new DevicePreferences(this);
            _alarm       = new AlarmPreferences(this);
            _job         = new JobPreferences(this);
            _fluid       = new FluidPreferences(this);
            _location    = new LocationPreferences(this);
            _units       = new UnitPreferences(this);
            _report      = new ReportPreferences(this);
            _portal      = new PortalPreferences(this);

            prefs.RegisterOnSharedPreferenceChangeListener(this);
        }
        // Initialize file
        private static void Init()
        {
#if !__ANDROID_WEAR__
            if (locationDB == null)
            {
                locationDB = new SQLiteAsyncConnection(
                    System.IO.Path.Combine(appDataFolder.Path, "locations.db"));
            }
#endif

            if (weatherDB == null)
            {
                weatherDB = new SQLiteAsyncConnection(
                    System.IO.Path.Combine(appDataFolder.Path, "weatherdata.db"));
            }

            preferences.RegisterOnSharedPreferenceChangeListener(App.SharedPreferenceListener);
        }
        private void Init()
        {
            if (initialized)
            {
                Realese();
            }
            tokenParser = new DTMFTokenParser();

            ISharedPreferences shared_prefs = Global.GetSharedPreferences(this);

            shared_prefs.RegisterOnSharedPreferenceChangeListener(this);
            prefs_model = new PreferencesModel(shared_prefs);

            var audio_mngr           = (AudioManager)GetSystemService(Context.AudioService);
            AudioFocusRequest result = audio_mngr.RequestAudioFocus(this, Stream.Music, AudioFocus.Gain);

            if (prefs_model.Notificando)
            {
                Notificando = true;
            }
            //modoComplemento = prefs_model.Modo_Complemento;

            TelephonyManager tmgr = (TelephonyManager)this.GetSystemService(Service.TelephonyService);

            if (phone_state_listener == null)
            {
                phone_state_listener = new MyPhoneStateListener(this);
            }
            tmgr.Listen(phone_state_listener, PhoneStateListenerFlags.CallState);
            initialized = true;

            Schudled_CallBack = prefs_model.Schudled_Call;

            if ((prefs_model.Teclado_Enabled || prefs_model.Ready) && !Detecting)
            {
                new System.Threading.Timer((o) => {
                    StartDetect();
                }, null, 2000, -1);
            }
        }
Exemple #21
0
        protected override void OnResume()
        {
            base.OnResume();
            connector = new DetectorServiceConnection(this);
            ToggleButton bt = FindViewById <ToggleButton> (Resource.Id.toggleButton1);

            BindService(new Intent(this.BaseContext, typeof(DetectorService)), connector, Bind.None);
            connector.BindComplete += OnBindComplete;
            //bt.Checked = Global.GetAppPreferences(this).Ready;

            DAL dal        = new DAL();
            var partitions = dal.GetAllPartitions();

            if (partitions.Find((part) => part.Activated) == null)
            {
                bt.Checked = false;
            }
            else
            {
                bt.Checked = true;
            }

            bt.CheckedChange += OnCheckedChange;
            //service.ToneDetected += OnToneDetected;

            lv_history = FindViewById <ListView> (Resource.Id.lv_history);

            history_adapter    = new HistoryGridAdapter(this, dal.GetTop10Events());
            lv_history.Adapter = history_adapter;

            lv_history.ItemClick += HistoryItemClicked;
            //bt.CheckedChange += OnToggleChecked;
            ISharedPreferences pref = Global.GetSharedPreferences(this);

            prefs_model = new PreferencesModel(pref);
            pref.RegisterOnSharedPreferenceChangeListener(this);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            this.SetTheme(ChangeTheme.getTheme());
            SetContentView(Resource.Layout.Settings);

            var transaction = FragmentManager.BeginTransaction();
            var setFragment = new SettingsFragment();

            transaction.Replace(Resource.Id.container, setFragment);
            transaction.Commit();

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetActionBar(toolbar);
            ActionBar.Title = "Asetukset";

            ActionBar.SetHomeButtonEnabled(true); // Takaisin-painike päällä
            ActionBar.SetDisplayHomeAsUpEnabled(true);

            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext);

            prefs.RegisterOnSharedPreferenceChangeListener(this);
        }
 private void AddMapChanged()
 {
     _preferences.RegisterOnSharedPreferenceChangeListener(this);
 }
Exemple #24
0
 public override void OnResume()
 {
     base.OnResume();
     sharedPreferences.RegisterOnSharedPreferenceChangeListener(this);
 }
Exemple #25
0
 public void AddOnChangeListener(object listener) =>
 sharedPreferences.RegisterOnSharedPreferenceChangeListener(listener
                                                            as ISharedPreferencesOnSharedPreferenceChangeListener);
 public void SetOnSharedPreferenceChangeListener(ISharedPreferencesOnSharedPreferenceChangeListener listener)
 {
     _preferences.RegisterOnSharedPreferenceChangeListener(listener);
 }