Skip to main content
Tag

Development

.NET 7 and future development

By Blog

As we near the end of the year, it’s a great time to reflect on the future of .NET and how we can continue to use the power of Microsoft Azure to deliver great results for our customers.

One of the exciting developments for .NET in the coming years is the release of .NET 7. This new version is set to include a number of new features and improvements, such as support for building web applications with Blazor and improved performance. With .NET 7, we will be able to build even more efficient and scalable applications for our clients.

Another area where Azure can help us deliver great results for our customers is in the realm of cloud computing. Azure provides a wide range of cloud services, including virtual machines, web and mobile apps, data storage, and analytics. By leveraging these services, we can help our clients move their applications and workloads to the cloud, enabling them to scale and grow their businesses more effectively.

Finally, we are excited about the potential of Azure to enable the creation of intelligent applications through the use of artificial intelligence and machine learning. By incorporating these technologies into our solutions, we can help our clients make more informed decisions and improve their operations.

Overall, we are confident that the combination of .NET 7 and the powerful capabilities of Azure will enable us to continue delivering great results for our customers well into the future.

For more information on .NET 7 and Azure, be sure to check out the following resources:

Detect non system input method

By Blog

On Android developers cannot define whether the input field supports non standards/custom keyboards. This might be an issue for secured applications, like mobile banking, or any line of business apps. What can be done then is to at least notify the user that this is the case and he should be careful not to use such input methods when logging in and use only the system default ones.

The code to check that is:

InputMethodManager methodManager = (InputMethodManager)this.GetSystemService (Context.InputMethodService);

foreach (var inputMethodInfo in methodManager.EnabledInputMethodList)
{
    if (inputMethodInfo.Id.Equals (Settings.Secure.GetString (ContentResolver, Settings.Secure.DefaultInputMethod)) == false)
    {
        if ((inputMethodInfo.ServiceInfo.ApplicationInfo.Flags & ApplicationInfoFlags.System) == 0)
        {
            // we found non default input method, so show the error toast and return;
        }
    }
}

Happy coding.

iOS Custom badge control

By Blog

Ever needed to create custom badge to UITabBarItem? Well here you go. I think it is pretty selfexplanatory.

public static class UITabBarItem_CustomBadge
	{
		public static void SetCustomBadgeValue (this UITabBarItem tabBarItem, string value, UIFont font, UIColor textColor, UIColor borderColor)
		{
			UIView view = (UIView)tabBarItem.ValueForKey (new NSString ("view"));

			tabBarItem.BadgeValue = value;

			// remove old one
			foreach (UIView subview in view.Subviews)
			{
				if (subview.Tag == 99) // badge has tag of 99
				{
					subview.RemoveFromSuperview ();

					break;
				}
			}

			foreach (UIView subview in view.Subviews)
			{
				if (subview.ToString ().StartsWith ("<_UIBadgeView:"))
				{
					// create new label view that we can style.
					// remove background, add border, make it nice
					var label = new UILabel (subview.Frame);

					label.TextAlignment = UITextAlignment.Center;
					label.Font = font;
					label.Text = value;
					label.BackgroundColor = borderColor.ColorWithAlpha (.5f);
					label.TextColor = textColor;
					label.Layer.BorderColor = borderColor.CGColor;
					label.Layer.BorderWidth = 1;
					label.Layer.CornerRadius = label.Frame.Height / 2;
					label.Layer.MasksToBounds = true;

					view.AddSubview (label);
					subview.Hidden = true;

					label.Tag = 99; // fake it here for iOS ;)
				}
			}
		}
	}

Enjoy and happy coding!

Paper for Facebook image scroll in Xamarin.iOS

By Blog

Paper for Facebook has some nice and neat features. One of them is scroll of an image using the tilt of the device.

Here is the implementation of such feature in Xamarin.iOS.

public override void ViewDidLoad ()
{
	base.ViewDidLoad ();
	
	// Perform any additional setup after loading the view, typically from a nib.
	mainScrollView.Bounces = false;
	mainScrollView.UserInteractionEnabled = false;

	var movingImageView = new UIImageView (UIImage.FromFile ("landscape.jpg"));
	mainScrollView.AddSubview (movingImageView);

	mainScrollView.ContentSize = new SizeF (movingImageView.Frame.Width, mainScrollView.Frame.Height);
	mainScrollView.ContentOffset = new PointF ((float)(mainScrollView.ContentSize.Width - View.Frame.Width) / 2.0f, 0);

	motionManager = new CMMotionManager ();
	motionManager.GyroUpdateInterval = 1 / 60.0;

	// this is how fast the image should move when rotate the device
	var motionMovingRate = 4;
	var shakeThreshold = 0.1;

	//get the max and min offset x value
	var maxXOffset = mainScrollView.ContentSize.Width - mainScrollView.Frame.Width;
	var minXOffset = 0;

	motionManager.StartGyroUpdates (NSOperationQueue.CurrentQueue, (CMGyroData gyroData, NSError error) => {
		if (Math.Abs (gyroData.RotationRate.y) >= shakeThreshold) 
		{
			var targetX = mainScrollView.ContentOffset.X - gyroData.RotationRate.y * motionMovingRate;

			if (targetX > maxXOffset)
						targetX = maxXOffset;
			else if (targetX < minXOffset)
						targetX = minXOffset;

			mainScrollView.ContentOffset = new PointF ((float)targetX, 0);
		}
	});
}

Download the source code and project from here.

Happy coding!

IOS6 style Navigation Bar in IOS7

By Blog

So you need to create that old style look in an app, maybe because it is a legacy code and your client needs this because of approved style guides and new ones do not exist for IOS7 yet?

Then do not despair, it is easier than you think. I used appearance for UINavigationBar to set up the basics.

[[UINavigationBar appearance] setTitleTextAttributes: @{ UITextAttributeFont : SOME_FONT_IF_YOU_WISH }];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"NavBar.png"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
        self.window.clipsToBounds = YES;
    }

Then you need to make sure all the views are not offset by 64pixels down. It is again very simple, just force the inset to be used for non transparent navigation bar too. I call this in viewDidLoad and viewWillAppear.

- (void)updateInsetIOS7
{
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        self.edgesForExtendedLayout = UIRectEdgeAll;
        self.extendedLayoutIncludesOpaqueBars = YES;
    }
}

Happy coding!