protected override void OnResume() { base.OnResume(); visibleContext = this; RegisterReceiver(chatReceiver, new IntentFilter("balintfodor.locationconnection.ChatReceiver")); isAppVisible = true; if (!(this is ListActivity)) //we need to exclude ListActivity, because we need to show the GettingLocation label { if (!locationUpdating && c.IsLocationEnabled() && (c.IsLoggedIn() && Session.UseLocation == true || !c.IsLoggedIn())) { StartLocationUpdates(); } } c.Log(LocalClassName.Split(".")[1] + " OnResume"); if (!ListActivity.initialized) //When opening app, Android sometimes resumes an Activity while the static variables are cleared out, resulting in error { c.Log(LocalClassName.Split(".")[1] + " Not initialized"); c.ReportErrorSilent("Initialization error"); Intent i = new Intent(this, typeof(ListActivity)); //current activity has to go through OnResume, therefore we cannot handle initialization errors in OnCreate StartActivity(i); } if (!(snack is null) && snack.IsShown) { snack.Dismiss(); } if (!(Session.SnackMessage is null)) //ChatList: for the situation when the user is deleted, while the other is on their page, and now want to load the chat. { if (this is ChatOneActivity) { RunOnUiThread(() => { c.SnackStr(Session.SnackMessage.Replace("[name]", Session.CurrentMatch.TargetName)); }); Session.SnackMessage = null; } else { RunOnUiThread(() => { c.SnackStr(Session.SnackMessage); }); Session.SnackMessage = null; } } }
public void Images_Click(object sender, System.EventArgs e) { if (!(snack is null)) { snack.Dismiss(); snack = null; } if (context.uploadedImages.Count < Constants.MaxNumPictures) { if (!context.imagesUploading && !context.imagesDeleting) { context.ImagesProgressText.Text = ""; context.ImagesProgress.Progress = 0; if (ContextCompat.CheckSelfPermission(context, Manifest.Permission.ReadExternalStorage) != (int)Permission.Granted) { if (ActivityCompat.ShouldShowRequestPermissionRationale(context, Manifest.Permission.ReadExternalStorage)) //shows when the user has once denied the permission, and now requesting it again. { var requiredPermissions = new String[] { Manifest.Permission.ReadExternalStorage }; context.c.SnackIndefAction(context.res.GetString(Resource.String.StorageRationale), new Action <View>(delegate(View obj) { ActivityCompat.RequestPermissions(context, requiredPermissions, 1); })); } else { ActivityCompat.RequestPermissions(context, new String[] { Manifest.Permission.ReadExternalStorage }, 1); } } else { SelectImage(); } } else { if (context.imagesUploading) { context.c.Snack(Resource.String.ImagesUploading); } else { context.c.Snack(Resource.String.ImagesDeleting); } } } else { context.c.SnackStr(context.res.GetString(Resource.String.MaxNumImages) + " " + Constants.MaxNumPictures + "."); } }