public Settings(ISharedPreferences preferences, string systemLanguage, InfobaseManager.Infobase infobase) { _preferences = preferences; Language = systemLanguage; _name = infobase.Name; BaseUrl = infobase.BaseUrl; ApplicationString = infobase.ApplicationString; FtpPort = infobase.FtpPort; string lastUrl = _preferences.GetString("url", string.Empty); if (BaseUrl == lastUrl) { UserName = _preferences.GetString("user", infobase.UserName); Password = _preferences.GetString("password", infobase.Password); } else { UserName = infobase.UserName; Password = infobase.Password; } ClearCacheOnStart = infobase.IsActive && _preferences.GetBoolean("clearCache", ForceClearCache); infobase.IsActive = true; infobase.IsAutorun = true; WriteSettings(); }
internal OtherSettings(ISharedPreferences sharedPrefs) { ConnectTimeout = int.Parse(sharedPrefs.GetString("pref_timeout_connect", "10000")); ConnectCheckInterval = int.Parse(sharedPrefs.GetString("pref_interval_check_connect", "200")); ToastLevel = (ToastLevel)int.Parse(sharedPrefs.GetString("pref_toasts_level", "2")); IgnoreSslCertErrors = sharedPrefs.GetBoolean("pref_ignore_ssl_errors", true); StartUrl = sharedPrefs.GetString("pref_start_url", null); }
public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key) { Preference pref = FindPreference (key); if (pref.GetType () == typeof(ListPreference)) { var listPref = (ListPreference)pref; pref.Summary = listPref.Entry; } else { pref.Summary = sharedPreferences.GetString (key,""); } var prefEditor = sharedPreferences.Edit (); prefEditor.PutString (key,sharedPreferences.GetString (key,"")); prefEditor.Commit (); }
public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key) { if (key != "clearCache" && key != "anonymousAccess") { string value = sharedPreferences.GetString(key, string.Empty); FillSummary(key, value); if ((key == "user" || key == "password" || key == "url") && !sharedPreferences.GetBoolean("clearCache", true)) { ISharedPreferencesEditor editor = sharedPreferences.Edit(); editor.PutBoolean("clearCache", true); editor.Commit(); MakeToast(D.NEED_TO_REBOOT_FULL); } if (key == "application") MakeToast(D.NEED_TO_REBOOT); } else { MakeToast(D.NEED_TO_REBOOT_FULL); } BitBrowserApp.Current.SyncSettings(); }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView(Resource.Layout.Filter); prefs = PreferenceManager.GetDefaultSharedPreferences(this); RadioButton radio_gps = FindViewById<RadioButton>(Resource.Id.radioButton1); RadioButton radio_fb = FindViewById<RadioButton>(Resource.Id.radioButton2); prefs = PreferenceManager.GetDefaultSharedPreferences(this); string localizationSetting = prefs.GetString("localization",""); if (localizationSetting == "facebook") { radio_fb.Checked = true; radio_gps.Checked = false; } else { radio_fb.Checked = false; radio_gps.Checked = true; } radio_gps.Click += RadioButtonClick; radio_fb.Click += RadioButtonClick; Button backButton = FindViewById<Button>(Resource.Id.button1); backButton.Click += (object sender, EventArgs e) => { Intent intent = new Intent (this, typeof(MainActivity)); StartActivityForResult (intent, 0); }; }
public override void OnCreate () { base.OnCreate (); prefs = GetSharedPreferences (USER_PREFS, FileCreationMode.Private); userName = prefs.GetString (KEY_USERNAME, null); }
void DisplayCurrentPreferenceValues(ISharedPreferences sharedPreferences) { Preference pilotName = FindPreference("pref_pilotname"); string curPilotName = sharedPreferences.GetString("pref_pilotname", ""); if (curPilotName == "") { curPilotName = "Enter your pilot name"; } pilotName.Summary = curPilotName; }
public static AppPreferences Create(ISharedPreferences prefs) { return new AndroidAppPreferences(prefs) { FirtsTimeRunning = prefs.GetBoolean(AppPreferences.FirstTimeKey, true), Ip = prefs.GetString(AppPreferences.IpKey, ""), Port = prefs.GetInt(AppPreferences.PortKey, 0), UseSounds = prefs.GetBoolean(AppPreferences.UseSoundsKey, true), UseCache = prefs.GetBoolean(AppPreferences.UseCacheKey, true) }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); ConnectivityManager connectivityManager = (ConnectivityManager) GetSystemService(ConnectivityService); NetworkInfo activeConnection = connectivityManager.ActiveNetworkInfo; Button loginButton = FindViewById<Button>(Resource.Id.loginButton); Button filteButton = FindViewById<Button> (Resource.Id.button1); prefs = PreferenceManager.GetDefaultSharedPreferences(this); _locationManager = GetSystemService (Context.LocationService) as LocationManager; Criteria criteriaForLocationService = new Criteria { Accuracy = Accuracy.Fine }; acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true); filteButton.Click += (object sender, EventArgs e) => { Intent intent = new Intent (this, typeof(FilterActivity)); StartActivityForResult (intent, 0); }; loginButton.Click += (object sender, EventArgs e) => { bool isOnline = (activeConnection != null) && activeConnection.IsConnected; bool wifiIsOnline = (connectivityManager.GetNetworkInfo(ConnectivityType.Wifi)).IsConnected; if (isOnline || wifiIsOnline) { if (!string.IsNullOrEmpty (prefs.GetString ("token", ""))) { Intent intent = new Intent (this, typeof(SearchActivity)); StartActivityForResult (intent, 0); } else { auth = Global.LogIn (); auth.Completed += auth_Completed; StartActivity (auth.GetUI (this)); } } else { AlertDialog.Builder alert = new AlertDialog.Builder (this); alert.SetTitle ("Internet connection error"); alert.SetMessage ("Turn wifi or mobile data on"); alert.SetPositiveButton ("Ok", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); } }; }
protected override void OnCreate (Bundle savedInstanceState) { try { base.OnCreate (savedInstanceState); SetContentView(Resource.Layout.Search); loading = FindViewById<TextView>(Resource.Id.textView1); pBar = FindViewById<ProgressBar>(Resource.Id.searchPB); pBar.Visibility = ViewStates.Visible; loading.Visibility = ViewStates.Visible; loading.Text="Loading events"; prefs = PreferenceManager.GetDefaultSharedPreferences(this); string token = prefs.GetString("token",""); localizationSetting = prefs.GetString("localization",""); if (localizationSetting == "gps" && Global.GPSCoords == null) { AlertDialog.Builder alert = new AlertDialog.Builder (this); alert.SetTitle ("GPS error"); alert.SetMessage ("Turn gps on"); alert.SetPositiveButton ("Ok", (senderAlert, args) => { Intent intent = new Intent (this, typeof(MainActivity)); StartActivityForResult (intent, 0); } ); Dialog dialog = alert.Create (); dialog.Show (); } else { GetPlacesList (token,localizationSetting); } } catch(Exception ex) { throw ex; } }
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)); }
public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key) { string value = string.Empty; if (key != "clearCache" && key != "anonymousAccess") { Preference preference = (Preference)FindPreference(key); value = sharedPreferences.GetString(key, string.Empty); FillSummary(key, value); if ((key == "user" || key == "password" || key == "url") && !sharedPreferences.GetBoolean("clearCache", true)) { ISharedPreferencesEditor editor = sharedPreferences.Edit(); editor.PutBoolean("clearCache", true); editor.Commit(); Toast.MakeText(this, D.NEED_TO_REBOOT_FULL, ToastLength.Long).Show(); } if (key == "application") { Toast.MakeText(this, D.NEED_TO_REBOOT, ToastLength.Long).Show(); } } else { if (key == "anonymousAccess") { string user = ""; string password = ""; if (sharedPreferences.GetBoolean("anonymousAccess", false)) { user = Settings.AnonymousUserName; password = Settings.AnonymousPassword; } ISharedPreferencesEditor editor = sharedPreferences.Edit(); editor.PutString("user", user); editor.PutString("password", password); editor.Commit(); } Toast.MakeText(this, D.NEED_TO_REBOOT_FULL, ToastLength.Long).Show(); } BitBrowserApp.Current.SyncSettings(true); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.MyFriends); preferences = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext); token = JsonConvert.DeserializeObject<AuthenticationToken>(preferences.GetString("token", null)); mAddFriendButton = FindViewById<ImageButton>(Resource.Id.addFriendImageButton); mMyFriendsList = FindViewById<ListView>(Resource.Id.MyFriendsListView); mItems = new List<FriendListItem>(); RegisterForContextMenu(mMyFriendsList); GetMyFriends(); mAddFriendButton.Click += (object sender, EventArgs e) => { StartActivityForResult(typeof(FindFriendToAddActivity), 2); }; }
protected override void OnCreate(Bundle savedInstanceState) { SetTheme(Android.Resource.Style.ThemeDeviceDefault); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.TripPassListView); ActionBar ab = ActionBar; ab.SetDisplayHomeAsUpEnabled(true); Android.Net.ConnectivityManager cm = (Android.Net.ConnectivityManager) this.GetSystemService(Context.ConnectivityService); if (cm.ActiveNetworkInfo == null) { Toast.MakeText(this, "Network error. Try again later.", ToastLength.Long).Show(); } else { listView = FindViewById <ListView>(Resource.Id.trip_pass_listview); client = new HttpClient(); client.BaseAddress = new Uri(GetString(Resource.String.RestAPIBaseAddress)); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); progress = new Android.App.ProgressDialog(this); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetMessage("Loading Trips....."); progress.SetCancelable(false); ISharedPreferences pref = GetSharedPreferences(GetString(Resource.String.PreferenceFileName), FileCreationMode.Private); var member = pref.GetString(GetString(Resource.String.PreferenceSavedMember), ""); user = JsonConvert.DeserializeObject <Member>(member); RunOnUiThread(() => { progress.Show(); }); LoadTripDetails(user.MemberID); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.playerbrowser_activity); Window.SetFlags(WindowManagerFlags.LayoutNoLimits, WindowManagerFlags.LayoutNoLimits); // clear FLAG_TRANSLUCENT_STATUS flag: Window.ClearFlags(WindowManagerFlags.TranslucentStatus); Window.SetStatusBarColor(Android.Graphics.Color.Transparent); RequestedOrientation = ScreenOrientation.Landscape; this.Window.AddFlags(WindowManagerFlags.KeepScreenOn); //this.Window.AddFlags(WindowManagerFlags.Fullscreen); //this.Window.ClearFlags(WindowManagerFlags.Fullscreen); decorview = Window.DecorView; RelativeLayout root = FindViewById <RelativeLayout>(Resource.Id.rootView); screenheight = root.Height; root.ViewTreeObserver.AddOnGlobalLayoutListener(new mOnGlobalLayoutListener()); spinner = FindViewById <ProgressBar>(Resource.Id.progressBar1); webView = FindViewById <WebView>(Resource.Id.webview); webView.SetWebViewClient(new CustomWebViewClient()); webView.Settings.JavaScriptEnabled = true; webView.Settings.BuiltInZoomControls = false; webView.Settings.SetSupportZoom(false); webView.ScrollBarStyle = ScrollbarStyles.OutsideOverlay; webView.ScrollbarFadingEnabled = false; sharedPreferences = this.GetSharedPreferences("sharedprefrences", 0); var url = sharedPreferences.GetString("url", null); view(url); }
protected override void OnCreate(Bundle savedInstanceState) { _lang = app.GetString("Language", "en"); ChangeLanguage(_lang); base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.shipping); mToolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolBar); SetSupportActionBar(mToolbar); SupportActionBar ab = SupportActionBar; ab.SetDisplayHomeAsUpEnabled(true); SupportActionBar.Title = " "; TabLayout tabs = FindViewById <TabLayout>(Resource.Id.tabs); viewPager = FindViewById <ViewPager>(Resource.Id.viewpager); viewPager.SetOnTouchListener(this); SetUpViewPager(viewPager); tabs.SetupWithViewPager(viewPager); try { viewPager.BeginFakeDrag(); var tabstrip = ((ViewGroup)tabs.GetChildAt(0)); for (int i = 0; i < tabstrip.ChildCount; i++) { ViewGroup vgTab = (ViewGroup)tabstrip.GetChildAt(i); vgTab.Enabled = false; } } catch (Exception) { } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Create your application here SetContentView(Resource.Layout.loading); mainlayout = (LinearLayout)FindViewById(Resource.Id.mainlayout); mSharedPreference = GetSharedPreferences(Constant.Com_Fra, FileCreationMode.WorldWriteable); lodimgsrc = mSharedPreference.GetString(Constant.Lod_Img, ""); if (lodimgsrc != "") { Bitmap bmp = getLoacalBitmap(lodimgsrc); if (bmp != null) { mainlayout.SetBackgroundDrawable(new BitmapDrawable(bmp)); } } else { } mHandler.mcontext = this; //timeoutrunable = new Runnable(() => //{ // isTimeout = true; // Message msg = Message.Obtain(); // msg.What = MSG_INIT_TIMEOUT; // mHandler.SendMessage(msg); //}); //mHandler.PostDelayed(timeoutrunable, 60000); LoadThread loadthread = new LoadThread(); loadthread.context = this; loadthread.Start(); }
private void startGame() { ISharedPreferences sPref = PreferenceManager.GetDefaultSharedPreferences(this); string diff = sPref.GetString("difficultyPref", ""); Stream ist = null; if (diff.Equals("Medium")) { ist = Resources.OpenRawResource(Resource.Raw.medium); } else if (diff.Equals("Hard")) { ist = Resources.OpenRawResource(Resource.Raw.hard); } else { ist = Resources.OpenRawResource(Resource.Raw.easy); } GameController.getInstance().setInitial(SudokuFileReader.getRandSudoku(ist)); GameController.getInstance().clean(); FindViewById(Resource.Id.game_field).Invalidate(); }
private void ValidateLogin() { // Retrive the keeped information of the session Context mContext = Android.App.Application.Context; ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(mContext); string loginInfo = prefs.GetString(GlobalConstants.LOGIN_USER_INFORMATION, ""); LoginUser loginUser = JsonConvert.DeserializeObject <LoginUser>(loginInfo); Intent nextActivity; if ((loginUser != null) && loginUser.SuccessfulLogin) { nextActivity = new Intent(this, typeof(WeatherActivity)); nextActivity.PutExtra(GlobalConstants.USER_SESSION, loginInfo); } else { nextActivity = new Intent(this, typeof(LoginActivity)); } StartActivity(nextActivity); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); settings = PreferenceManager.GetDefaultSharedPreferences(this); editor = settings.Edit(); //editor.Clear().Commit(); prefListener = new PrefListener(this); colorSpinner = FindViewById <Spinner>(Resource.Id.colorSpinner); colorLayout = FindViewById <FrameLayout>(Resource.Id.colorLayout); currentAccentColor = AccentColors.GetIdFromResource(settings.GetString(ACCENT_COLOR_KEY, ACCENT_COLOR_DEFAULT)); AccentColor[] colors = AccentColors.GetAccentColors().ToArray(); colorSpinner.Adapter = new ArrayAdapter <AccentColor>(this, Resource.Layout.colorspinner_item, colors); colorLayout.SetBackgroundColor(GetColor(currentAccentColor)); colorSpinner.ItemSelected += ColorSpinner_ItemSelected; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); var view = inflater.Inflate(Resource.Layout.offer_items, container, false); ISharedPreferences pref = Application.Context.GetSharedPreferences("UserInfo", FileCreationMode.Private); userName = pref.GetString("Username", String.Empty); controller = new Controller(); AddOfferToCartBtn = view.FindViewById <Button>(Resource.Id.AddOfferToCartBtn); offerRating = view.FindViewById <RatingBar>(Resource.Id.offerRating); offerRating.RatingBarChange += OfferRating_RatingBarChange; mRecycleView = view.FindViewById <RecyclerView>(Resource.Id.offerItemsRecyclerView); mLayoutManager = new LinearLayoutManager(Activity); mRecycleView.SetLayoutManager(mLayoutManager); mAdapter = new OfferItemsListAdapter(itemsList); mRecycleView.SetAdapter(mAdapter); AddOfferToCartBtn.Click += AddOfferToCartBtn_Click; return(view); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_review); storeReviewDets = (EditText)FindViewById(Resource.Id.storeReviewDetails); courierReviewDets = (EditText)FindViewById(Resource.Id.courierReviewDetails); courierRating = (RatingBar)FindViewById(Resource.Id.courierReviewRating); storeRating = (RatingBar)FindViewById(Resource.Id.storeReviewRating); orderRating = (RatingBar)FindViewById(Resource.Id.orderReviewRating); submitBtn = (Button)FindViewById(Resource.Id.submitReviewBtn); ISharedPreferences pref = Application.Context.GetSharedPreferences("UserInfo", FileCreationMode.Private); userName = pref.GetString("Username", String.Empty); OrderID = Intent.GetIntExtra("OrderID", 0); controller = new Controller(); //StoreID = 0 orderDetails = controller.getOrderDets(OrderID); //CourierID = 1 submitBtn.Click += SubmitBtn_Click; // Create your application here }
private void Init() { Messages = new List <Models.Message>(); lvMessages = FindViewById <ListView>(Resource.Id.lvChats); adapter = new MessagesAdapter(this, Messages); lvMessages.Adapter = adapter; lvMessages.ItemClick += OnListItemClick; pref = PreferenceManager.GetDefaultSharedPreferences(this); CurrentUser = JsonConvert.DeserializeObject <User>(pref.GetString(Constants.PREF_USER_TAG, "")); InitilizeRegions(); _beaconManager = new BeaconManager(this); _beaconManager.SetForegroundScanPeriod(1500, 2000); _beaconManager.Ranging += OnRanging; _beaconManager.ExitedRegion += OnExitedRegion; }
public static void Init() { try { SharedData = PreferenceManager.GetDefaultSharedPreferences(Application.Context); LastPosition = Application.Context.GetSharedPreferences("last_position", FileCreationMode.Private); string getValue = SharedData.GetString("Night_Mode_key", string.Empty); ApplyTheme(getValue); if (Build.VERSION.SdkInt <= BuildVersionCodes.LollipopMr1) { SettingsPrefFragment.SChatHead = SharedData.GetBoolean("chatheads_key", InitFloating.CanDrawOverlays(Application.Context)); } SettingsPrefFragment.SSoundControl = SharedData.GetBoolean("checkBox_PlaySound_key", true); } catch (Exception e) { Console.WriteLine(e); } }
public override void OnCreate(Bundle savedInstanceState) { StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.SetVmPolicy(builder.Build()); StrictMode.ThreadPolicy.Builder builder1 = new StrictMode.ThreadPolicy.Builder().PermitAll(); StrictMode.SetThreadPolicy(builder1.Build()); base.OnCreate(savedInstanceState); progress = new Android.App.ProgressDialog(Activity); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetCancelable(false); progress.SetMessage("Please Wait..."); pref = Android.App.Application.Context.GetSharedPreferences("AboutExamInfo", FileCreationMode.Private); Abour_Exam = pref.GetString("FinalAboutExam", "false"); dba = new DBHelper(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_item); itemID = Intent.GetIntExtra("Itemid", 0); controller = new Controller(); item = controller.getItem(itemID); ISharedPreferences pref = Application.Context.GetSharedPreferences("UserInfo", FileCreationMode.Private); userName = pref.GetString("Username", String.Empty); AddCartBtn = (Button)FindViewById(Resource.Id.AddToCartBtn); itemQuantityTV = (TextView)FindViewById(Resource.Id.itemQuantity); itemImageIV = (ImageView)FindViewById(Resource.Id.itemImageView); itemNameTV = (TextView)FindViewById(Resource.Id.ItemNameTextView); itemTypeTV = (TextView)FindViewById(Resource.Id.ItemTypeTextView); itemPriceTV = (TextView)FindViewById(Resource.Id.ItemPriceTextView); addBtn = (RelativeLayout)FindViewById(Resource.Id.addIcon); removeBtn = (RelativeLayout)FindViewById(Resource.Id.removeIcon); myCart = (LinearLayout)FindViewById(Resource.Id.cartInItem); itemRating = (RatingBar)FindViewById(Resource.Id.itemRating); if (MainActivity.CartItems.numitems != 0) { myCart.Visibility = ViewStates.Visible; myCart.Click += MyCart_Click; } changed = false; itemRating.RatingBarChange += ItemRating_RatingBarChange; itemImageIV.SetImageBitmap(item.itemImage); itemNameTV.Text = item.itemName; itemTypeTV.Text = item.itemType; itemPriceTV.Text = item.itemPrice.ToString(); addBtn.Click += AddBtn_Click; removeBtn.Click += RemoveBtn_Click; AddCartBtn.Click += AddCartBtn_Click; // Create your application here }
void ratingClick(object sender, EventArgs e) { ISharedPreferences prefs = Application.Context.GetSharedPreferences("UserInfo", FileCreationMode.Private); string userID = prefs.GetString("userID", null); if (userID == null) { Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this); alert.SetTitle("Log In"); alert.SetMessage("You need to log in to submit a rating"); alert.SetPositiveButton("Log In", (senderAlert, args) => { Intent intent = new Intent(this, typeof(LogInActivity)); //intent.PutExtra("RestaurantInfo", JsonConvert.SerializeObject(restaurantInfo); intent.PutExtra("RestaurantInfo", Intent.GetStringExtra("RestaurantInfo")); StartActivity(intent); Finish(); }); alert.SetNegativeButton("Cancel", (senderAlert, args) => { ratingBar.Rating = 0; }); Dialog dialog = alert.Create(); dialog.Show(); } else { Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this); alert.SetTitle("Submit Rating"); alert.SetMessage("Would you like to submit your rating?"); alert.SetPositiveButton("Submit", (senderAlert, args) => { string rating = ratingBar.Rating.ToString(); submitRating(userID, ID, rating); }); alert.SetNegativeButton("Cancel", (senderAlert, args) => { ratingBar.Rating = 0; }); Dialog dialog = alert.Create(); dialog.Show(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.PersonalSetting); DataEdit = FindViewById <LinearLayout>(Resource.Id.SettingDataEdit); PasswordEdit = FindViewById <LinearLayout>(Resource.Id.SettingPasswardEdit); RealNameEdit = FindViewById <LinearLayout>(Resource.Id.SettingRealNameEdit); PhoneNum = FindViewById <TextView>(Resource.Id.PersonalSettingTextPhoneNum); ISharedPreferences LoginSP = GetSharedPreferences("LoginData", FileCreationMode.Private); PhoneNum.Text = LoginSP.GetString("PhoneNum", null); DataEdit.Click += delegate { Intent ActDataEdit = new Intent(this, typeof(DataEdit)); StartActivity(ActDataEdit); }; PasswordEdit.Click += delegate { Intent ActPasswordEdit = new Intent(this, typeof(PasswordEdit)); StartActivity(ActPasswordEdit); }; RealNameEdit.Click += delegate { string res = RealNameData.Post("http://115.159.145.115/IfRealName.php", PhoneNum.Text); if (res == "Failed") { Toast.MakeText(this, "已认证,快去借书吧!", ToastLength.Short).Show(); } else { Intent ActRealName = new Intent(this, typeof(RealName)); StartActivity(ActRealName); } }; }
private void ClearPositionsFile() { Console.WriteLine("=> saving positions to file"); // get shared preferences ISharedPreferences pref = Application.Context.GetSharedPreferences("PREFERENCE_NAME", FileCreationMode.Private); // read exisiting value var customers = pref.GetString("PositionsCell", null); // if preferences return null, initialize listOfPositionsCell if (customers == null) { _listPositions = new List <Position>(); } else { _listPositions = JsonConvert.DeserializeObject <List <Position> >(customers); } // if deserialization return null, initialize listOfPositionsCell if (_listPositions == null) { _listPositions = new List <Position>(); } // add your object to list of PositionsCell _listPositions.Clear(); // convert the list to json var listOfCustomersAsJson = JsonConvert.SerializeObject(_listPositions); ISharedPreferencesEditor editor = pref.Edit(); // set the value to PositionsCell key editor.PutString("PositionsCell", listOfCustomersAsJson); // commit the changes editor.Commit(); }
public RtcAudioManager(Context context) { _context = context; _audioManager = (AudioManager)context.GetSystemService(Context.AudioService); //_wiredHeadsetReceiver = new WiredHeadsetReceiver(); _amState = AudioManagerState.Uninitialized; ISharedPreferences preferences = PreferenceManager.GetDefaultSharedPreferences(context); _useSpeakerPhone = preferences.GetString(context.GetString(Resource.String.pref_speakerphone_key), context.GetString(Resource.String.pref_speakerphone_default)); if (_useSpeakerPhone.Equals(SpeakerPhoneFalse)) { _defaultAudioDevice = AudioDevice.Earpiece; } else { _defaultAudioDevice = AudioDevice.SpeakerPhone; } _proximitySensor = RTCProximitySensor.Create(_context, new Runnable(OnProximitySensorChangedState)); _wiredHeadsetReceiver = new WiredHeadsetReceiver(new Runnable(() => { UpdateAudioDeviceState(); })); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Lista_guardados); // Create your application here db = new sqlite_database_movements(); click = true; opciones = GetSharedPreferences(Legalproprefs, 0); if (opciones.GetString("nm_opr", "").Length == 0) { Intent intent = new Intent(this.ApplicationContext, typeof(MainActivity)); StartActivity(intent); } RunOnUiThread(() => { get_cuestionarios(); }); FindViewById <ImageView>(Resource.Id.imageView4).Click += (sender, e) => { var builder = new AlertDialog.Builder(this); builder.SetTitle("Aviso"); builder.SetMessage("Se cerrara la sesión ¿está seguro?"); builder.SetPositiveButton("Aceptar", (sender2, args) => { Toast.MakeText(this.ApplicationContext, "Adios", ToastLength.Long).Show(); //resultado.Text = respuesta.INSTANCIA.ID_INSTANCIA + " Operador: "+respuesta.id_Opr+" "+respuesta.nm_Oper; ISharedPreferencesEditor editor = opciones.Edit(); editor.PutString("nm_opr", ""); editor.PutInt("id_opr", 0); editor.PutString("nm_str", ""); editor.PutInt("instancia", 0); editor.Commit(); StartActivity(typeof(MainActivity)); }); builder.SetNegativeButton("Cancelar", (sender2, args) => { }); builder.Show(); }; }
protected override void OnCreate(Bundle savedInstanceState) { UserDialogs.Init(this); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_first); btnGo = FindViewById <Button>(Resource.Id.btnGo); etUser = FindViewById <EditText>(Resource.Id.etUser); ISharedPreferences pref = Application.Context.GetSharedPreferences("Username", FileCreationMode.Private);; String username = pref.GetString("Username", String.Empty); if (username != string.Empty) { // no saved credentials Intent intent = new Intent(this, typeof(MainActivity)); this.StartActivity(intent); this.Finish(); } btnGo.Click += buttonClicked; }
public MainApp(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer) { // Save instance for later use instance = this; TestFlight.TakeOff(this, "0596e62a-e3cb-4107-8d05-96fa7ae0c26a"); // Catch unhandled exceptions // Found at http://xandroid4net.blogspot.de/2013/11/how-to-capture-unhandled-exceptions.html // Add an exception handler for all uncaught exceptions. AndroidEnvironment.UnhandledExceptionRaiser += AndroidUnhandledExceptionHandler; AppDomain.CurrentDomain.UnhandledException += ApplicationUnhandledExceptionHandler; preferences = Application.Context.GetSharedPreferences("WF.Player.preferences", FileCreationMode.MultiProcess); path = preferences.GetString("path", ""); if (String.IsNullOrEmpty(path)) path = global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + Java.IO.File.Separator + "WF.Player"; try { if (!Directory.Exists (path)) Directory.CreateDirectory (path); } catch { } if (!Directory.Exists (path)) { AlertDialog.Builder builder = new AlertDialog.Builder (this); builder.SetTitle (GetString (Resource.String.main_error)); builder.SetMessage(String.Format(GetString(Resource.String.main_error_directory_not_found), path)); builder.SetCancelable (true); builder.SetNeutralButton(Resource.String.ok,(obj,arg) => { }); builder.Show (); } else { preferences.Edit().PutString("path", path).Commit(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); TextView tvUser = FindViewById <TextView>(Resource.Id.tvUser); Button btnCamera = FindViewById <Button>(Resource.Id.btnCamera); ImageView ivImage = FindViewById <ImageView>(Resource.Id.ivImage); btnCamera.Click += btnCamera_Click; RequestPermissions(permissionGroup, 0); ISharedPreferences pref = Application.Context.GetSharedPreferences("Username", FileCreationMode.Private);; username = pref.GetString("Username", String.Empty); tvUser.Text = username; }
private void Confirm() { // Input Check if (etHaisoDate.Text == "") { ShowDialog("エラー", "日付を入力してください。", () => { etHaisoDate.RequestFocus(); }); return; } if (etBin.Text == "") { ShowDialog("エラー", "便を入力してください。", () => { etBin.RequestFocus(); }); return; } // 登録済みメールバッグ数を取得 string souko_cd = prefs.GetString("souko_cd", ""); string haisoDate = etHaisoDate.Text.Replace("/", ""); try { int cnt = WebService.RequestMAIL020(souko_cd, haisoDate, etBin.Text); editor.PutString("haiso_date", haisoDate); editor.PutString("bin_no", etBin.Text); editor.PutInt("mail_back", cnt); editor.Apply(); StartFragment(FragmentManager, typeof(MailManageInputFragment)); } catch { ShowDialog("エラー", "登録済みメールバッグ数取得に失敗しました。", () => {}); Log.Error(TAG, "登録済みメールバッグ数取得に失敗しました。"); } }
private void SetTodokesakiAsync() { string soukoCd = prefs.GetString("souko_cd", ""); string kitakuCd = prefs.GetString("kitaku_cd", ""); string syuka_date = prefs.GetString("syuka_date", ""); vendorList = WebService.RequestKosu095(soukoCd, kitakuCd, syuka_date); if (vendorList.Count > 0) { ListView listView = view.FindViewById<ListView>(Resource.Id.listView1); listView.ItemClick += listView_ItemClick; vendorAdapter = new VendorAdapter(vendorList); listView.Adapter = vendorAdapter; } else { ShowDialog("報告", "表示データがありません。", () => { FragmentManager.PopBackStack(); }); } }
public async void ShowProfile() { var token = _prefs.GetString("token", null); if (token != null && (Activity as MainActivity).CheckConnection()) { try { var user = await _manager.GetProfile(token); usernameTxt.Text = $"Логин: {user.Email}"; surnameTxt.Text = $"Фамилия: {user.Surname}"; nameTxt.Text = $"Имя: {user.Name}"; patrTxt.Text = $"Отчество: {user.Patronymic}"; } catch (UnauthorizedAccessException) { var dialog = new Android.App.AlertDialog.Builder(Context); string message = "Ваши параметры авторизации устарели." + "\nВы будете возвращены на страницу авторизации, чтобы пройти процедуру авторизации заново"; dialog.SetMessage(message); dialog.SetCancelable(false); dialog.SetPositiveButton("Ок", delegate { (Activity as MainActivity).LogOut(); }); dialog.Show(); } catch (Exception ex) { var dialog = new Android.App.AlertDialog.Builder(Context); string message = ex.Message; dialog.SetMessage(message); dialog.SetPositiveButton("Ок", delegate { }); dialog.Show(); } } }
public override void Run() { try { ISharedPreferences mSharedPreference = context.GetSharedPreferences(Constant.Com_Fra, FileCreationMode.WorldWriteable); IEnvManagerSvr newinfo = RometeClientManager.GetClient(PsPropertiesUtil.GetProperties(context, "loadinfoUrl"), typeof(IEnvManagerSvr), 60000) as IEnvManagerSvr; AppEnvironment appenvironment = newinfo.GetUserEnv(mSharedPreference.GetString(Constant.PS_UTAG, ""), 0); Message msg = context.mainhandler.ObtainMessage(); Bundle bundle = new Bundle(); bundle.PutString("HeaderURL", appenvironment.MainPage.HeadUrl); bundle.PutInt("HeaderHeight", appenvironment.MainPage.HeadHeight); bundle.PutString("LoadImg", appenvironment.SplashImg); ObjList list = appenvironment.MainPage.FuncDefs; string[] funsname = new string[list.Count]; string[] funurl = new string[list.Count]; string[] funiconurl = new string[list.Count]; string[] funsbdnurl = new string[list.Count]; for (int i = 0; i < list.Count; i++) { funsname[i] = (list[i] as FuncEntry).Title; funurl[i] = (list[i] as FuncEntry).Url; funiconurl[i] = (list[i] as FuncEntry).IconUrl; funsbdnurl[i] = (list[i] as FuncEntry).StateUrl; } bundle.PutStringArray("funsname", funsname); bundle.PutStringArray("funsurl", funurl); bundle.PutStringArray("funsiconurl", funiconurl); bundle.PutStringArray("funsbdnurl", funsbdnurl); msg.Data = bundle; msg.What = 1; msg.Target = context.mainhandler; msg.SendToTarget(); } catch (System.Exception e) { throw; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.radniNalozi); Android.Widget.Toolbar toolbar = FindViewById <Android.Widget.Toolbar>(Resource.Id.toolbarHomePage); radniNaloziListView = FindViewById <RecyclerView>(Resource.Id.recyclerView); searchInput = FindViewById <EditText>(Resource.Id.searchInput); resultMessage = FindViewById <TextView>(Resource.Id.resultMessage); noviRNBtn = FindViewById <Button>(Resource.Id.noviRadniNalogBtn); SetActionBar(toolbar); ActionBar.Title = "Odabir radnog naloga"; noviRNBtn.Click += NoviRNBtn_Click; searchInput.KeyPress += SearchInput_KeyPress; searchInput.TextChanged += SearchInput_TextChanged; localDoneDeratization.Edit().Clear().Commit(); localAnketa.Edit().Clear().Commit(); localDoneDeratization.Edit().Clear().Commit(); localAnketa.Edit().Clear().Commit(); localRadniNalozi.Edit().Clear().Commit(); localPozicija.Edit().Clear().Commit(); localKomitentLokacija.Edit().Clear().Commit(); localDeratization.Edit().Clear().Commit(); localOdradeneAnkete.Edit().Clear().Commit(); localTipDeratizacije.Edit().Clear().Commit(); localMaterijali.Edit().Clear().Commit(); localPotvrda.Edit().Clear().Commit(); radniNalozi = db.Query <DID_RadniNalog>( "SELECT DID_RadniNalog.Id, DID_RadniNalog.Godina, DID_RadniNalog.Godina, DID_RadniNalog.Broj, DID_RadniNalog.Status, " + "DID_RadniNalog.PokretnoSkladiste, DID_RadniNalog.Voditelj, DID_RadniNalog.VoditeljKontakt, DID_RadniNalog.Izdavatelj, " + "DID_RadniNalog.Primatelj, DID_RadniNalog.DatumOd, DID_RadniNalog.DatumDo, DID_RadniNalog.DatumIzrade, DID_RadniNalog.DatumIzvrsenja, DID_RadniNalog.SinhronizacijaStatus, DID_RadniNalog.SinhronizacijaPrivremeniKljuc " + "FROM DID_RadniNalog " + "INNER JOIN DID_RadniNalog_Djelatnik ON DID_RadniNalog.Id = DID_RadniNalog_Djelatnik.RadniNalog " + "WHERE DID_RadniNalog_Djelatnik.Djelatnik = ?", localUsername.GetString("sifraDjelatnika", null)); PrikazRadnihNaloga(); }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_test_input); mAdView = FindViewById <AdView>(Resource.Id.adView1); var adRequest = new AdRequest.Builder().Build(); mAdView.LoadAd(adRequest); questions = JsonConvert.DeserializeObject <List <TestHelper.Question> >(Intent.GetStringExtra("questions")); foreach (TestHelper.Question question in questions) { question.is_answered = false; } editAnswer = FindViewById <EditText>(Resource.Id.editAnswer); textAnswer = FindViewById <TextView>(Resource.Id.textAnswer); FindViewById <Button>(Resource.Id.btnVerify).Click += btnVerify_Click; FindViewById <Button>(Resource.Id.btnNext).Click += btnNext_Click; FindViewById <Button>(Resource.Id.btnClose).Click += BtnClose_Click; questionIndex = 0; questionsAnswered = 0; progressAnswered = FindViewById <ProgressBar>(Resource.Id.progressAnswered); progressAnswered.Max = questions.Count(); GenerateQuestion(); ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext); string locale_saved_name = prefs.GetString("localeName", ""); var locales = await TextToSpeech.GetLocalesAsync(); locale = locales.FirstOrDefault(l => l.Name == locale_saved_name); duration_start = DateTime.Now; }
public static TextView CreateAndAddBoldDescriptionRow(View view, int layoutID, String text) { ISharedPreferences prefs = (view.Context).GetSharedPreferences("prefs.txt", FileCreationMode.Private); var fontsize = float.Parse(prefs.GetString("fontsize2", "14")) - 3.0f; // Get the screen's density scale float scale = view.Resources.DisplayMetrics.ScaledDensity; LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent, 1.0f); param.LeftMargin = (int)(5 * scale + 0.5f); param.RightMargin = (int)(5 * scale + 0.5f); param.TopMargin = (int)(0 * scale + 0.5f); param.BottomMargin = (int)(0 * scale + 0.5f); param.Weight = 1.0f; TextView txtName = new TextView(view.Context); txtName.Text = text; txtName.SetTextSize(ComplexUnitType.Sp, fontsize); txtName.LayoutParameters = param; txtName.Gravity = GravityFlags.Left; txtName.SetTypeface(null, Android.Graphics.TypefaceStyle.Bold); //txtName.SetTextColor(Android.Graphics.Color.LightGray); LinearLayout ll = new LinearLayout(view.Context); LinearLayout.LayoutParams param3 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); ll.Id = new Random().Next(); ll.LayoutParameters = param3; ll.Orientation = Orientation.Horizontal; ll.AddView(txtName); LinearLayout l0 = view.FindViewById <LinearLayout>(layoutID); l0.AddView(ll); return(txtName); }
public void InjectPreferences(Context context) { OnInjecting(context); injectByType(context, typeof(InjectPreferenceAttribute), (attribute, type) => { var preferenceAttribute = (InjectPreferenceAttribute)attribute; ISharedPreferences preferences = PreferenceManager.GetDefaultSharedPreferences(context); if (type == typeof(int)) { return(preferences.GetInt(preferenceAttribute.Key, (int)preferenceAttribute.DefaultValue)); } else if (type == typeof(long)) { return(preferences.GetLong(preferenceAttribute.Key, (long)preferenceAttribute.DefaultValue)); } else if (type == typeof(float)) { return(preferences.GetFloat(preferenceAttribute.Key, (float)preferenceAttribute.DefaultValue)); } else if (type == typeof(string)) { return(preferences.GetString(preferenceAttribute.Key, (string)preferenceAttribute.DefaultValue)); } else if (type == typeof(bool)) { return(preferences.GetBoolean(preferenceAttribute.Key, (bool)preferenceAttribute.DefaultValue)); } else { return(null); } }); OnInjected(); }
public static Cookie GetCookie(ISharedPreferences sharedPreferences, string cookieKey) { var cookieString = sharedPreferences.GetString(cookieKey, null); if (!string.IsNullOrEmpty(cookieString)) { var cookie = new Cookie(); var entries = cookieString.Split('|'); var cookieType = typeof(Cookie); foreach (var entry in entries) { var index = entry.IndexOf(':'); var propertyName = entry.Substring(0, index); var propertyValue = entry.Substring(index + 1); var property = cookieType.GetProperty(propertyName); property.SetValue(cookie, Utils.ConvertType(propertyValue, property.PropertyType), null); } return cookie; } return null; }
private async Task <HttpResponseMessage> AddFriendToFriendList(FriendListItem newFriendListItem) { var token = JsonConvert.DeserializeObject <AuthenticationToken>(preferences.GetString("token", null)); if (token == null) { return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } var url = GetString(Resource.String.ApiLink) + "/api/friendlist/addFriendListItem"; client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(token.TokenType, token.AccessToken); var json = JsonConvert.SerializeObject(newFriendListItem); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = null; response = await client.PostAsync(new Uri(url), content); return(response); }
private void GetPreferenceManager() { prefs = PreferenceManager.GetDefaultSharedPreferences(this); ProjectID = prefs.GetLong("ProjectID", 0); if (ProjectID == 0) { if (isNetworkConnected()) { prefs = IMApplication.pref; ProjectID = IMApplication.projectid; } else { Toast.MakeText(this, "Please check data connection. Select a project. Then try back !!!!", ToastLength.Short).Show(); } } EmpID = prefs.GetLong("EmpID", 5); UserType = prefs.GetLong("UserType", 1); UserPlan = prefs.GetString("UserPlan", ""); IsInternal = prefs.GetLong("IsInternal", 0); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView (Resource.Layout.Checklist); InitializeActionBar (SupportActionBar); ActionBarTitle.Text = "Totemisatie checklist"; sharedPrefs = GetSharedPreferences("checklist", FileCreationMode.Private); var ser = sharedPrefs.GetString("states", "empty"); List<List<bool>> states; if(!ser.Equals("empty")) states = JsonSerializer.DeserializeFromString<List<List<bool>>>(ser); else states = null; expand = FindViewById<ExpandableListView>(Resource.Id.expand); InitializeExpandableListView (); expandAdapater = new ExpendListAdapter(this, dictGroup, states); expand.SetAdapter(expandAdapater); }
internal ConnectionSettings(ISharedPreferences sharedPrefs) { Ssid = sharedPrefs.GetString("pref_ssid", null); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.NewMessage); preferences = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext); token = JsonConvert.DeserializeObject<AuthenticationToken>(preferences.GetString("token", null)); mTimeTextView = FindViewById<TextView>(Resource.Id.timeTextView); mStartPlaceEditText = FindViewById<EditText>(Resource.Id.startPlaceEditText); mEndPlaceEditText = FindViewById<EditText>(Resource.Id.endPlaceEditText); mAddButton = FindViewById<Button>(Resource.Id.addButton); mTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, 0); mTimeTextView.Text = $"Czas: {mTime.ToString("HH:mm")}"; mTimeTextView.Click += (object sender, EventArgs e) => { var timePickerFragment = new TimePickerDialogFragment(this, mTime, this); timePickerFragment.Show(FragmentManager, null); }; mAddButton.Click += async (object sender, EventArgs e) => { //sprawdzenie poprawnoœci wprowadzonych przez u¿ytkownika danych if (!mStartPlaceEditText.Text.Equals("") && !mEndPlaceEditText.Text.Equals("")) { mStartPlace = mStartPlaceEditText.Text; mEndPlace = mEndPlaceEditText.Text; var traveler = JsonConvert.DeserializeObject<Traveler>(preferences.GetString("traveler", null)); if (traveler == null || token == null) { Toast.MakeText(this, GetString(Resource.String.LoginTokenOrTravelerFailure), ToastLength.Long).Show(); Finish(); StartActivity(typeof(LoginActivity)); } else { //utworzenie nowego obiektu - wiadomoœci newMessage = new Information { TravelerId = traveler.Id, StartPlace = mStartPlace, EndPlace = mEndPlace, Time = mTime }; //sprawdzenie, czy œrodowisko jest po³¹czone z sieci¹ Internet var connectivityManager = (ConnectivityManager) GetSystemService(ConnectivityService); var activeNetworkInfo = connectivityManager.ActiveNetworkInfo; if (activeNetworkInfo == null || !activeNetworkInfo.IsConnected) { Toast.MakeText(this, GetString(Resource.String.NoConnectionInfo), ToastLength.Long).Show(); return; } //wywo³anie okna dialogowego progresu var loadingMessage = ProgressDialog.Show(this, GetString(Resource.String.SendingMessageTitle), GetString(Resource.String.SendingMessageContent), true, false); //wywo³anie metody obs³uguj¹cej ¿¹danie http i oczekiwanie na wiadomoœæ var apiMessage = await SaveMyMessage(newMessage); loadingMessage.Dismiss(); if (apiMessage.IsSuccessStatusCode) { //ustawienie pozytywnego rezultatu operacji i zakoñczenie aktywnoœci SetResult(Result.Ok); } Finish(); } } else Toast.MakeText(this, GetString(Resource.String.NewMessageNoDataInfo), ToastLength.Long).Show(); }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); // Create your application here SetContentView(Resource.Layout.settingsLayout); var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar> (Resource.Id.settingsToolbar); SetSupportActionBar (toolbar); SupportActionBar.Title = "Settings"; SupportActionBar.SetDisplayHomeAsUpEnabled (true); var madview = FindViewById<AdView>(Resource.Id.mysettingadview); AdRequest myrqst = new AdRequest.Builder ().AddTestDevice(AdRequest.DeviceIdEmulator).Build (); madview.LoadAd (myrqst); prefs = Application.Context.GetSharedPreferences ("WingsRecorder", FileCreationMode.Private); // var formattypes = new String[]{ "MP3", "3GP", "AMR" }; var fileFormatTextview = FindViewById<TextView> (Resource.Id.textViewFileFormat); fileFormatTextview.Text = prefs.GetString("FileType", MainActivity.formattypes[0]); var fileformatLinLay = FindViewById<LinearLayout> (Resource.Id.linearLayoutFileFormat); fileformatLinLay.Click += delegate { var builder = new Android.Support.V7.App.AlertDialog.Builder (this); builder.SetTitle ("Select File Format") .SetItems(MainActivity.formattypes, new EventHandler<DialogClickEventArgs>(delegate(object sender, DialogClickEventArgs e) { var prefedit = prefs.Edit (); fileFormatTextview.Text = MainActivity.formattypes[e.Which]; prefedit.PutString ("FileType", MainActivity.formattypes[e.Which]); prefedit.Commit(); })) .SetNegativeButton("Cancel", delegate { }); builder.Create().Show (); }; // var audioSourceTypes = new String[]{"Camcorder", "Mic", "Voice Call", // "Voice Communication", "Voice Recognition", "Voice UpLink", "Voice DownLink"}; var audioSouceTextview = FindViewById<TextView> (Resource.Id.textViewAudioSource); audioSouceTextview.Text = prefs.GetString("AudioSource", MainActivity.audioSourceTypes[2]); var audiosourceLinLay = FindViewById<LinearLayout> (Resource.Id.linearLayoutAudioSource); audiosourceLinLay.Click += delegate { var builder = new Android.Support.V7.App.AlertDialog.Builder (this); builder.SetTitle ("Select Audio Source") .SetItems (MainActivity.audioSourceTypes, new EventHandler<DialogClickEventArgs>(delegate(object sender, DialogClickEventArgs e) { var prefedit = prefs.Edit (); audioSouceTextview.Text = MainActivity.audioSourceTypes[e.Which]; prefedit.PutString ("AudioSource", MainActivity.audioSourceTypes[e.Which]); prefedit.Commit(); })) .SetNegativeButton("Cancel", delegate { }); builder.Create().Show (); }; // var currentpath = "/storage/emulated/0/"; // var f = new File(currentpath).ListFiles(); // var files = f.Where(x=>x.IsDirectory).ToList(); // var storagePathLinLay = FindViewById<LinearLayout> (Resource.Id.linearLayoutStorageLocation); storagePathLinLay.Click += delegate { StartActivity (new Intent (this, typeof(pathChooseActivity))); }; }
public override void OnScrolled (RecyclerView recyclerView, int dx, int dy) { pref = PreferenceManager.GetDefaultSharedPreferences(Application.Context); LinearLayoutManager linearLayoutManager = (LinearLayoutManager)recyclerView.GetLayoutManager (); int lastVisibleItem = linearLayoutManager.FindLastVisibleItemPosition(); int totalItemCount = recyclerView.GetAdapter().ItemCount; if (!IsLoading && totalItemCount <= (lastVisibleItem + visibleThreshold)) { // End has been reached // Do something var currPrefPage = pref.GetString ("CurrentPage", string.Empty); if (!String.IsNullOrEmpty (currPrefPage)) { if (Int32.Parse (currPrefPage) > 0) { currentPage++; } else { currentPage = 2; } } else { currentPage++; } var editor = pref.Edit(); editor.PutString("CurrentPage",currentPage.ToString()); editor.Apply(); IsLoading = true; Task.Factory.StartNew (async () => { try{ var newPostList = new List<Post>(); await WebClient.LoadPosts(newPostList,currentPage); (recyclerView.GetAdapter()as PostViewAdapter)._Posts.AddRange(newPostList); //recyclerView.GetAdapter().HasStableIds = true; _messageShown = false; Application.SynchronizationContext.Post (_ => {recyclerView.GetAdapter().NotifyDataSetChanged();}, null); //recyclerView.GetAdapter().NotifyItemRangeInserted(recyclerView.GetAdapter().ItemCount,newPostList.Count); }catch(Exception ex){ //Insights.Report(ex,new Dictionary<string,string>{{"Message",ex.Message}},Insights.Severity.Error); var text = ex.Message; if(!_messageShown){ Application.SynchronizationContext.Post (_ => { Toast.MakeText(Application.Context,"При загрузке данных произошла ошибка",ToastLength.Short).Show(); }, null); _messageShown = true; } } IsLoading = false; }); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.FindOtherTravelers); preferences = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext); mTimeTextView = FindViewById<TextView>(Resource.Id.otherTravelerTimeTextView); mFindOtherTravelerButton = FindViewById<Button>(Resource.Id.findOtherTravelerButton); mStartPlaceEdit = FindViewById<EditText>(Resource.Id.OtherTravelerStartPlaceEditText); mEndPlaceEdit = FindViewById<EditText>(Resource.Id.OtherTravelerEndPlaceEditText); mTravelTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, 0); mTimeTextView.Text = $"Czas: {mTravelTime.ToString("HH:mm")}"; mTimeTextView.Click += (object sender, EventArgs e) => { var timePickerFragment = new TimePickerDialogFragment(this, mTravelTime, this); timePickerFragment.Show(FragmentManager, null); }; mFindOtherTravelerButton.Click += async (object sender, EventArgs e) => { if (mStartPlaceEdit.Text.Equals("") || mEndPlaceEdit.Text.Equals("")) Toast.MakeText(this, GetString(Resource.String.OtherTravelersNoDataInfo), ToastLength.Long).Show(); else { mStartPlace = mStartPlaceEdit.Text; mEndPlace = mEndPlaceEdit.Text; var token = JsonConvert.DeserializeObject<AuthenticationToken>(preferences.GetString("token", null)); if (token == null) { Toast.MakeText(this, GetString(Resource.String.LoginTokenOrTravelerFailure), ToastLength.Long) .Show(); Finish(); StartActivity(typeof(LoginActivity)); } var connectivityManager = (ConnectivityManager) GetSystemService(ConnectivityService); var activeNetworkInfo = connectivityManager.ActiveNetworkInfo; if (activeNetworkInfo == null || !activeNetworkInfo.IsConnected) { Toast.MakeText(this, GetString(Resource.String.NoConnectionInfo), ToastLength.Long).Show(); return; } var url = string.Format(GetString(Resource.String.ApiLink) + "/api/information/getothertravelersbyinformations?travelHour={0}&travelMinutes={1}&startPlace={2}&endPlace={3}", mTravelTime.Hour, mTravelTime.Minute, mStartPlace, mEndPlace); client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(token.TokenType, token.AccessToken); var loadingMessage = ProgressDialog.Show(this, GetString(Resource.String.OtherTravelersListLoadingTitle), GetString(Resource.String.OtherTravelersListLoadingContent), true, false); var response = await client.GetAsync(new Uri(url)); loadingMessage.Dismiss(); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); var otherTravelersActivityIntent = new Intent(this, typeof (OtherTravelersActivity)); var putContent = new Bundle(); putContent.PutString("ResponseContent", content); putContent.PutString("StartPlace", mStartPlace); putContent.PutString("EndPlace", mEndPlace); otherTravelersActivityIntent.PutExtras(putContent); StartActivity(otherTravelersActivityIntent); } else if (response.StatusCode == HttpStatusCode.NotFound) Toast.MakeText(this, GetString(Resource.String.OtherTravelersNotFoundInfo), ToastLength.Long) .Show(); else Toast.MakeText(this, GetString(Resource.String.OtherTravelersNotOkInfo), ToastLength.Long) .Show(); } }; }
private void InitView() { //设置标题栏 var img_header_back = FindViewById<ImageView> (Resource.Id.img_header_back); img_header_back.Click += (sender, e) => { this.Finish(); OverridePendingTransition(Resource.Animation.bottom_out,0); }; var tv_back = FindViewById<TextView> (Resource.Id.tv_back); tv_back.Text = ""; var tv_desc = FindViewById<TextView> (Resource.Id.tv_desc); tv_desc.Text = "登录"; _jpushUtil = new JPushUtil (this); // Create your application here //或得共享实例变量 sp_userinfo = this.GetSharedPreferences(Global.SHAREDPREFERENCES_USERINFO,FileCreationMode.Private); //获得实例对象 edit_userName = FindViewById<EditText>(Resource.Id.edit_UserName); edit_userPassword = FindViewById<EditText> (Resource.Id.edit_PassWord); cb_passWord = FindViewById<CheckBox> (Resource.Id.cb_Password); btn_login = FindViewById<Button> (Resource.Id.btn_Login); tv_Register = FindViewById<TextView> (Resource.Id.tv_Register); var tv_forgetPwd = FindViewById<TextView> (Resource.Id.tv_forgetPwd); var img_eye = FindViewById<ImageView> (Resource.Id.img_eye); img_eye.Click += (sender, e) => { if(edit_userPassword.InputType == (Android.Text.InputTypes.ClassText|Android.Text.InputTypes.TextVariationPassword)) { edit_userPassword.InputType = Android.Text.InputTypes.ClassText|Android.Text.InputTypes.TextVariationVisiblePassword; img_eye.SetImageResource(Resource.Drawable.ic_login_eye_selected); } else if(edit_userPassword.InputType == (Android.Text.InputTypes.ClassText| Android.Text.InputTypes.TextVariationVisiblePassword)) { edit_userPassword.InputType = Android.Text.InputTypes.ClassText|Android.Text.InputTypes.TextVariationPassword; img_eye.SetImageResource(Resource.Drawable.ic_login_eye_normal); } }; //点击注册 tv_Register.Click += (sender, e) => { StartActivity(typeof(RegisterStepOneActivity)); OverridePendingTransition(Android.Resource.Animation.SlideInLeft,Android.Resource.Animation.SlideOutRight); }; //找回密码 tv_forgetPwd.Click += (sender, e) => { var intent = new Intent(this,typeof(SendSecurityCodeActivity)); var sendbundle = new Bundle(); sendbundle.PutString("SendType","FindPwd"); sendbundle.PutString("PhoneNumber",string.Empty); intent.PutExtras(sendbundle); StartActivity(intent); OverridePendingTransition(Android.Resource.Animation.SlideInLeft,Android.Resource.Animation.SlideOutRight); }; //如果选择了记住密码,则赋值 if (sp_userinfo.GetBoolean (Global.refrence_Password_Check, false)) { cb_passWord.Checked = true; edit_userName.Text = sp_userinfo.GetString (Global.refrence_UserName, string.Empty); edit_userPassword.Text = sp_userinfo.GetString (Global.refrence_Password, string.Empty); } //记住密码选择事件 cb_passWord.CheckedChange += (sender, e) => { if(cb_passWord.Checked) sp_userinfo.Edit().PutBoolean(Global.refrence_Password_Check,true).Commit(); else sp_userinfo.Edit().PutBoolean(Global.refrence_Password_Check,false).Commit(); }; //登录按钮事件 btn_login.Click += (sender, e) => { Login(); }; }
internal AuthSettings(ISharedPreferences sharedPrefs) { Username = sharedPrefs.GetString("pref_username", null); Password = sharedPrefs.GetString("pref_password", null); }
public void GetPreferences() { prefs = PreferenceManager.GetDefaultSharedPreferences(this); prefAutoDownload = prefs.GetBoolean ("prefAutoDownload", false); prefEnableNotifications = prefs.GetBoolean ("prefEnableNotifications", true); prefShowAppUpdates = prefs.GetBoolean ("prefShowAppUpdates", true); prefHoursNotifications = int.Parse(prefs.GetString ("prefHoursNotifications", "4"))-1; if (prefHoursNotifications == 1) { millisecondsNotifications = 3 * 60 * 60 * 1000; } else if (prefHoursNotifications == 2) { millisecondsNotifications = 6 * 60 * 60 * 1000; } else if (prefHoursNotifications == 3) { millisecondsNotifications = 9 * 60 * 60 * 1000; } else if (prefHoursNotifications == 4) { millisecondsNotifications = 12 * 60 * 60 * 1000; } else if (prefHoursNotifications == 5) { millisecondsNotifications = 24 * 60 * 60 * 1000; } else { millisecondsNotifications = 12 * 60 * 60 * 1000; } SetNotification (); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.AddFriend); preferences = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext); mAddFriendList = FindViewById<ListView>(Resource.Id.addFriendListView); mFriendAdd = FindViewById<Button>(Resource.Id.friendAddButton); mItems = new List<Traveler>(); var loadingMessage = ProgressDialog.Show(this, GetString(Resource.String.SearchingForFriendTitle), GetString(Resource.String.SearchingForFriendContent), true, false); var getContentFoundFriend = Intent.GetStringExtra("Content"); mItems.Clear(); var foundFriends = JsonConvert.DeserializeObject<List<Traveler>>(getContentFoundFriend); foreach (var foundFriend in foundFriends) { mItems.Add(new Traveler { Id = foundFriend.Id, Name = foundFriend.Name, Surname = foundFriend.Surname, DateOfBirth = foundFriend.DateOfBirth }); } var adapter = new AddFriendListViewAdapter(this, mItems); mAddFriendList.Adapter = adapter; loadingMessage.Dismiss(); mFriendAdd.Click += async (object sender, EventArgs e) => { if (mItemId == 0) Toast.MakeText(this, GetString(Resource.String.FoundFriendNotSelectedInfo), ToastLength.Long).Show(); else { var traveler = JsonConvert.DeserializeObject<Traveler>(preferences.GetString("traveler", null)); var connectivityManager = (ConnectivityManager)GetSystemService(ConnectivityService); var activeNetworkInfo = connectivityManager.ActiveNetworkInfo; if (traveler == null) { Toast.MakeText(this, GetString(Resource.String.LoginTokenOrTravelerFailure), ToastLength.Long) .Show(); Finish(); StartActivity(typeof(LoginActivity)); } else if (activeNetworkInfo == null || !activeNetworkInfo.IsConnected) Toast.MakeText(this, GetString(Resource.String.NoConnectionInfo), ToastLength.Long).Show(); else { newFriendListItem = new FriendListItem { OwnerId = traveler.Id, FriendId = mItemId }; var response = await AddFriendToFriendList(newFriendListItem); if (response.IsSuccessStatusCode) { SetResult(Result.Ok); Finish(); } else if (response.StatusCode == HttpStatusCode.Conflict) { SetResult((Result) 409); Finish(); } } } }; mAddFriendList.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { mItemId = mItems[e.Position].Id; Toast.MakeText(this, string.Format(GetString(Resource.String.FoundFriendSelectedInfo) + " {0}", mItems[e.Position].Name), ToastLength.Long).Show(); }; }
public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key) { var size = sharedPreferences.GetString(key, "0"); FindPreference(key).Summary = size == "0" ? "Small" : "Medium"; }
protected override void OnCreate(Bundle bundle) { RequestWindowFeature(WindowFeatures.NoTitle); base.OnCreate (bundle); SetContentView (Resource.Layout.Main); mSharedPreferences = this.GetSharedPreferences ("CheckInPrefs", FileCreationMode.Private); string storedUser = mSharedPreferences.GetString ("StoredUser", "NONE"); string storedPass = mSharedPreferences.GetString ("StoredPass", "NONE"); if (!storedUser.Equals("NONE") || !storedPass.Equals("NONE")) { FindViewById<EditText>(Resource.Id.txtUsername).SetText(storedUser, TextView.BufferType.Normal); FindViewById<EditText>(Resource.Id.txtPassword).SetText(storedPass, TextView.BufferType.Normal); FindViewById<CheckBox>(Resource.Id.cbStoreUser).Checked = true; } FindViewById<CheckBox>(Resource.Id.cbStoreUser).CheckedChange += delegate { ISharedPreferencesEditor cbeditor = mSharedPreferences.Edit (); cbeditor.Remove("StoredUser"); cbeditor.Remove("StoredPass"); cbeditor.Commit(); }; Button button = FindViewById<Button> (Resource.Id.btnLogin); button.Click += delegate { TextView txtPassword = FindViewById<TextView> (Resource.Id.txtPassword); TextView txtUsername = FindViewById<TextView> (Resource.Id.txtUsername); if (string.IsNullOrEmpty(txtPassword.Text) || string.IsNullOrEmpty(txtUsername.Text)) { var myHandler = new Handler(); myHandler.Post(() => { Android.Widget.Toast.MakeText(this, "Please Provide a Username and Password.", Android.Widget.ToastLength.Long).Show(); }); } else { try { var locSvc = new ROMPLocation(); var loginResp = new LoginResponse(); loginResp = locSvc.LearnerLogin(txtUsername.Text, txtPassword.Text); if (loginResp.Success) { CheckBox rememberMe = FindViewById<CheckBox> (Resource.Id.cbStoreUser); ISharedPreferencesEditor editor = mSharedPreferences.Edit (); if (rememberMe.Checked) { editor.PutString("StoredUser", txtUsername.Text); editor.PutString("StoredPass", txtPassword.Text); } else { editor.Remove("StoredUser"); } editor.Commit(); if (loginResp.GroupID <= 2) { var nextActivity = new Intent(this, typeof(ChooseModeActivity)); nextActivity.PutExtra("SessionKey", loginResp.SessionKey); nextActivity.PutExtra("GroupID", loginResp.GroupID); nextActivity.PutExtra("UserID", loginResp.UserID); StartActivity(nextActivity); Finish(); } else { var nextActivity = new Intent(this, typeof(CheckInActivity)); nextActivity.PutExtra("SessionKey", loginResp.SessionKey); nextActivity.PutExtra("GroupID", loginResp.GroupID); nextActivity.PutExtra("UserID", loginResp.UserID); StartActivity(nextActivity); Finish(); } } else { var myHandler = new Handler(); myHandler.Post(() => { Android.Widget.Toast.MakeText(this, "Login Failed. Please Try Again.", Android.Widget.ToastLength.Long).Show(); }); } } catch (Exception e) { var myHandler = new Handler(); myHandler.Post(() => { Android.Widget.Toast.MakeText(this, e.Message, Android.Widget.ToastLength.Long).Show(); }); System.Diagnostics.Debug.Write(e.Message); } } }; }
internal LoginPageSettings(ISharedPreferences sharedPrefs) { LoginPageUrl = sharedPrefs.GetString("pref_loginpage", null); }
public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key) { if (key == "pref_pilotname") { string pilotName = sharedPreferences.GetString("pref_pilotname", ""); var btnMyPilotStats = FindViewById<Button>(R.Ids.btnMyPilotStats); if (pilotName == "") { btnMyPilotStats.SetEnabled(false); btnMyPilotStats.Text = "Your Pilot Stats"; } else { btnMyPilotStats.SetEnabled(true); btnMyPilotStats.Text = pilotName + " Stats"; } } }
public void Initialize(ISharedPreferences pref){ preference = pref; leftPort = StringToMotorPort(preference.GetString("leftPort", "Motor A")); rightPort = StringToMotorPort(preference.GetString("rightPort", "Motor C")); additionalPort = StringToMotorPort(preference.GetString("additionalPort", "Motor B")); reverseLeft = preference.GetBoolean("reverseLeft", false); reverseRight = preference.GetBoolean("reverseRight", false); reverseAdditional = preference.GetBoolean("reverseAdditional", false); sendVehicleDataToMailbox = preference.GetBoolean("sendVehicleDataToMailbox", false); sensorValueToSpeech = preference.GetBoolean("sensorValueToSpeech", true); deviceName = preference.GetString("deviceName", ""); type = StringToBrickType(preference.GetString("brickType", "EV3")); vehicleMailbox = StringToMailbox(preference.GetString("vehicleMailbox", "Mailbox 0")); degreeOffset = StringToDegreeOffset(preference.GetString("degreeOffset", "Up")); sensor1 = preference.GetString("sensor1", "None"); sensor2 = preference.GetString("sensor2", "None"); sensor3 = preference.GetString("sensor3", "None"); sensor4 = preference.GetString("sensor4", "None"); }