Quantcast
Channel: Yudiz Solutions Ltd.
Viewing all 595 articles
Browse latest View live

Material Design Components for iOS

$
0
0

Overview

Material design is created by team of engineers and UX designers at Google.
MDC provides attractive and functional UI components and is available for Android, iOS, Web and Flutters.
Material design is system for building beautiful apps in iOS(swift) by using Material components.
Material components for iOS(MDC-IOS) creates consistency between apps & websites.

Installation of Material Components in Project

Installation with cocoapods

Add the following to your pod file.
pod ‘MaterialComponents
Then run the following command
pod install
Importing
Then import the Material components.
For ex. import MaterialComponents.MaterialBottomAppBar

List of Useful Material Components(MDC)

  1. Buttons
  2. Textfield
  3. Chip view
  4. Bottom view
  5. Snack bar(Bottom toast)
  6. Tab bar
  7. Slider
  8. Spinner(Loader)
  9. Highlighted view
  10. Page control

1. Buttons

  • There are three types of button in Material components.
  • Flat, raised and floating button.
  • All buttons show ink splashes when user interacts with the button.
  • You can set elevation for particular control state of button.
  • Floating action button can be animated using collapse and expand method.

material_design_image3

//For MDCButton      
        let button = MDCButton()
        button.setElevation(ShadowElevation(rawValue: 6), for: .normal) // For add shadow on button.
        view.addSubview(button)

//For MDCFloatingButton 
        let floatingButton = MDCFloatingButton()
        floatingButton.setImage( UIImage(named: "Favorite"), for: .normal)
        floatingButton.backgroundColor = .white
        floatingButton.setElevation(ShadowElevation(rawValue: 6), for: .normal)
        floatingButton.addTarget(self, action: #selector(btnTapped(button:)), for: .touchUpInside)
        view.addSubview(floatingButton).

@objc func btnFloatingButtonTapped(floatingButton: MDCFloatingButton){
        floatingButton.collapse(true) {
            floatingButton.expand(true, completion: nil)
        }
    }

2. TextField

  • There are two main types of Text Fields in material components.
  • MDCTextfield and MDCMultilineTextField.
  • MDCTextfield is used for single line text input and MDCMultilineTextField for multiline text input.
  • We have to add textfield in ‘MDCTextInputControllerUnderline(textInput:)’ as text input for floating placeholder and underline.

//For animate placeholder and underline
var textFieldControllerFloating: MDCTextInputControllerUnderline!

//Multiline text Field 
let textFieldFloating = MDCMultilineTextField()
        textFieldFloating.textView?.delegate = self
        textFieldFloating.placeholder = "Enter UserName"
        textFieldFloating.expandsOnOverflow = false
        textFieldControllerFloating = MDCTextInputControllerUnderline(textInput: textFieldFloating)
        textFieldControllerFloating.characterCountMax = 15
        textFieldControllerFloating.floatingPlaceholderActiveColor = UIColor.lightGray
        textFieldControllerFloating.errorColor = .red
        view.addSubview(textFieldFloating)

//Text view delegate for animate placeholder 
func textViewDidChange(_ textView: UITextView) {
        let txt = textView.text.trimmingCharacters(in: .whitespaces)
        textFieldControllerFloating.isFloatingEnabled = !txt.isEmpty
    }

3. Chip View

  • There are two main types of chip view: Action chips and Choice chips.
  • Action chip offer action related to primary content. You can change UI according to action.
  • Choice chips allow selection from multiple chips.
  • Choice chips clearly indicate exact position and display options in a compact area.
  • You can use chips as toggle, radio button and single selection menu by customizing chip view.

material_design_image2

//Chip view with image
        let chipView = MDCChipView()
        chipView.sizeToFit()
        chipView.titleLabel.text = "Chip With Image"
        chipView.setTitleColor(UIColor.red, for: .selected)
        chipView.addTarget(self, action: #selector(chipViewTapped(_:)), for: .touchUpInside)
        self.view.addSubview(chipView)

//Tap action of chip view
@objc func chipViewTapped(_ sender: MDCChipView){
        sender.imageView.image = UIImage(named: "Favorite")
        sender.imagePadding = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 0)
    }

4. BottomView

  • Bottom View works much like a UITabBar and both are populated with an array of UITabBarItems.
  • It is to be suggested that at most three to five bar items are to be used.
  • User can add title as well as image in BottomView.

material_design_image4

//Setting up Bottom View
   let bottomView = MDCBottomNavigationBar()
   bottomView.items = [
            UITabBarItem(title: "Home", image:UIImage(named: "Home"), tag: 0),
            UITabBarItem(title: "Message", image:UIImage(named: "Email"), tag: 1),
            UITabBarItem(title: "Favorites", image: UIImage(named: "Favorite"), tag: 2),
            UITabBarItem(title: "Calls", image:UIImage(named: "calls"), tag: 3),
            UITabBarItem(title: "More", image:UIImage(named: "more"), tag: 4)
        ]
   bottomView.selectedItem = bottomView.items.first
   bottomView.titleVisibility = .always
   bottomView.alignment = .centered
   view.addSubview(bottomView)

5. SnackBar

  • Snackbars provide brief feedback about an operation through a message at the bottom of the screen.
  • It shows up normal readable text upto two lines.
  • Pop ups only contains text action.

//Setting up Snack Bar
    let message = MDCSnackbarMessage()
        message.text = "This is a SnackBar Toast"
        let action = MDCSnackbarMessageAction()
        let actionHandler = { () in
            let answerMessage = MDCSnackbarMessage()
            answerMessage.text = "Fascinating"
            MDCSnackbarManager.show(answerMessage)
        }
        action.handler = actionHandler
        action.title = "ok"
        message.action = action
        MDCSnackbarManager.show(message)

material_design_image1

6. TabBar

  • These tabs act like bar buttons, used to navigate between Screens.
  • On the selected tab user is redirected to related Subject Content.
  • It works on the behaviour of MDCTabBar that communicates via a delegate.

material_design_image7

//Setting up Tab Bar
        let tabBar = MDCTabBar()
        tabBar.items = [
            UITabBarItem(title: "Home", image:  imageLiteral(resourceName: "Home"), tag: 0),
            UITabBarItem(title: "Message", image:  imageLiteral(resourceName: "Email"), tag: 1),
            UITabBarItem(title: "Favorites", image:  imageLiteral(resourceName: "Favorite"), tag: 2),
            UITabBarItem(title: "Calls", image:  imageLiteral(resourceName: "calls"), tag: 3),
            UITabBarItem(title: "More", image:  imageLiteral(resourceName: "more"), tag: 4)
        ]
        tabBar.selectedItem = tabBar.items.first
        tabBar.alignment = .center
        tabBar.itemAppearance = .titledImages
        tabBar.barTintColor = .white
        tabBar.selectedItemTintColor = .black
        tabBar.unselectedItemTintColor = .gray
        tabBar.selectionIndicatorTemplate = IndicatorTemplate()// Custom class for selected Tab indicator
        tabBar.autoresizingMask = [.flexibleWidth, .flexibleBottomMargin]
        tabBar.sizeToFit()
        view.addSubview(tabBar)

7. Slider

  • MDCSlider is a third party control used to propagate between range or discrete set of values.
  • The current slider height is set to 27pt, to make enough space so that touches don’t affect other elements.
  • Discrete sliders shows value indicator by set numberOfDiscreteValues property.

material_design_image5

let slider = MDCSlider()
        slider.shouldDisplayDiscreteValueLabel = true
        slider.isEnabled = true
        slider.numberOfDiscreteValues = 5
        slider.minimumValue = 0
        slider.maximumValue = 100
        slider.inkColor = .black
        slider.isThumbHollowAtStart = true
        slider.addTarget(self, action: #selector(didChangeSliderValue), for: .valueChanged)
        view.addSubview(slider)

//Slider value change method
 @objc func didChangeSliderValue(_ sender: MDCSlider){
        sender.isStatefulAPIEnabled = true
        sender.setThumbColor(.red, for: .selected)
    }

8. Spinner(Loader)

  • Material Design allows user to display a loading indicator with multi color support.
  • User can use two styles of indicator :- linear and circular
  • It has a property to set multiple colors, i.e cycleColors which allow to add colors property.

material_design_image9

let activityIndicator = MDCActivityIndicator()
        activityIndicator.sizeToFit()
        activityIndicator.progress = 0.4
        activityIndicator.cycleColors = [.blue, .red, .green]
        activityIndicator.center = self.view.center
        view.addSubview(activityIndicator)
        activityIndicator.startAnimating()

9. Highlighted View

  • The Highlight view component is a way to visually highlight a part of the screen in order to introduce users to new features and functionality.
  • Through this you can highlight a view, and at a time display another view with different animations.
  • For example :- Switching the main view with highlighted view.

var highlightController: MDCFeatureHighlightViewController!        
        highlightController = MDCFeatureHighlightViewController(highlightedView: welcomeButton, completion: nil)
        highlightController.bodyColor = .white
        highlightController.titleColor = .white
        highlightController.titleText = "Welcome Sir!"
        highlightController.bodyText = "Text which you want to display when highlight"
        highlightController.outerHighlightColor =
            UIColor.black.withAlphaComponent(kMDCFeatureHighlightOuterHighlightAlpha)
        present(highlightController, animated: true, completion: nil)

material_design_image8

10. Page Control

  • MDCPageControl is designed in replacement of Native UIPageControl
  • MDCPageControl shows current page index, with its positioned indicator.
  • As the user scroll the page, the indicator in MDCPageControl navigates it’s indicator towards the next indicator position that is being scrolled towards.

let pageControl = MDCPageControl()
        pageControl.numberOfPages = 3
        let pageControlSize = pageControl.sizeThatFits(view.bounds.size)
        pageControl.addTarget(self, action: #selector(didChangePage), for: .valueChanged)
        pageControl.autoresizingMask = [.flexibleTopMargin, .flexibleWidth]
        view.addSubview(pageControl)

    /// Change page control
    ///
    /// - Parameter sender: MDCPageControl
    @objc func didChangePage(sender: MDCPageControl){
        var offset = scrollView.contentOffset
        offset.x = CGFloat(sender.currentPage) * scrollView.bounds.size.width;
        scrollView.setContentOffset(offset, animated: true)
    }

material_design_image6

Advantages and Disadvantages of Material Design and Material components(MDC) for iOS

Advantages:

  • Material design are minimalistic and stylish as compared to native components of iOS.
  • More intuitive and Material design is great both for experienced users and new users.
  • Material components looks Moderately skeuomorphic.
  • Material components uses animation so animations help users grasp the UI better.

Disadvantages:

  • Owned by google so it will be hard to improve something that you are not satisfied with without asking the proprietor.
  • Material components may take long time to implement compared to native iOS components.
  • Motion can be very energy-consuming.

What’s New In ANGULAR 7?

$
0
0

Overview

angular_7_image4

The 7th major version of Google’s popular framework, Angular has been released. The release primarily focuses on CLI prompts, drag-and-drop capabilities and Virtual Scroll in the CDK(Component Development Kit), Angular Material. Also get the support of Node 10, Typescript 3.1, RxJs 6.3. Unfortunately, Ivy-Renderer did not become part of this release.

Let’s take a closer look at some highlights,

How to Update?

For updating your existing Angular project to version 7,

ng update @angular/cli @angular/core

Visit update.angular.io for more information and guidance regarding the updates.

CLI prompts

The command-line interface provides more information about common commands such as ng new or ng add @ angular / material. This helps you to find built-in features like routing or support for SCSS.

The documentation of angular.io now includes documentation of Angular CLI.

Angular Material & CDK

Material design received a major update this year. You can see the design guidance, tooling, development component from Material. Some new functionality is added in CDK like virtual scrolling, Drag and Drop by importing ScrollingModule and DragDropModule.

Virtual Scrolling

The CDK now has scrolling capability which means that your loading/ unloading of DOM element is a bit faster & user-friendly. You can use that by importing ScrollingModule.

Here is how you can implement this feature in your application,

<cdk-virtual-scroll-viewport class="main" itemSize="50">
 <ul>
     <div *cdkVirtualFor="let item of items" class="example-item">{{item}}</div>
 </ul>
</cdk-virtual-scroll-viewport>

angular_7_image5

Drag & Drop

The CDK has now support for drag and drop which includes automatic rendering as user move items from one place to another place. Method used for reordering of lists is moveItemInArray And for transferring items is transferArrayItem.

Here is how you can implement this feature in your application,

In app.component.html file,

<div cdkDropList class="example-list" (cdkDropListDropped)="drop($event)">
 <div class="example-box" *ngFor="let item of items" cdkDrag>{{item}}</div>
</div>

In app.component.ts file,

drop(event: CdkDragDrop<string[]>) {
   moveItemInArray(this.items, event.previousIndex, event.currentIndex);
 }

angular_7_image2

Performance Improvements

As per tradition with the release of new versions, the Angular team also took a
look at the performance of the framework for version 7. We included the reflect-metadata polyfill in production, which is only needed in development.

In version 7, as a part of update it will automatically remove a polyfills.ts file, when you are building your application in JIT(Just-In-Time) mode, removing this polyfill from production builds and makes your application smaller in size.

This next feature is warning application creators when they are going over the budget with their bundle size. The default bundle size is a warning at 2 MB and an error at 5 MB. These default bundle size can be easily changed in your angular.json file by changing the bundle size in the angular.json file.

"budgets": [
  {
    "type": "initial",
    "maximumWarning": "2mb",
    "maximumError": "5mb"
  }
]

Angular Element

Angular Elements components now support content projection for custom elements.

Conclusion

With Angular 7, A new major release has come out, which is having many small improvements and designed by maintaining the dependencies and other performance improvements. But Ivy still is in under development so did not become a part of this update. Many partner projects like Angular Console, NativeScript, StackBlitz, @angular/fire are continuously helping Angular to expand environment.

Machine Learning .NET

$
0
0

Overview

Machine Learning is in vogue these days. Such a large number of developers are jumped into that research and development.

ml_dot_net_image9

There are mainly Four Machine Learning trends:

  • Intelligence on cloud
  • Quantum computing capabilities
  • Improved personalization
  • Data on data

At Long Last a NuGet Package for Machine Learning.

ml_dot_net_image1

Being a .Net Developer extremely upbeat that Microsoft has announced the Machine Learning Framework i.e. ML.NET.

“When you’re fundraising, it’s AI.
When you’re hiring, it’s ML.
When you’re implementing, it’s logistic regression.”
– Twitter

Introduction

ML.NET is a free, open-source, and cross-platform machine learning system that empowers you to manufacture custom machine learning arrangements and coordinate them into your .NET applications. This manages to furnish numerous assets about working with ML.NET

ml_dot_net_image3

This was originally developed in Microsoft Research and evolve into significant framework over the last decade. It is used across many product groups in Microsoft like Windows, Azure, Bing, and more.

In the First preview release

ML.NET enables Machine Learning tasks like

  • Classification (e.g. Content classification and Conclusion investigation)
  • Regression (e.g. Anticipating and Value forecast)

Along with these Machine Learning capabilities,
This first release of ML.NET framework also brings the first draft of .NET APIs for training models, using models for predictions, and in addition the core components of this framework,

  • Learning Algorithms
  • Transforms
  • Core Machine Learning data structures

This is as a matter of first importance a structure, which implies that it tends to be reached out to include prevalent Machine Learning Libraries like TensorFlow, Accord.NET, and CNTK(Cognitive Toolkit).

ML.NET Core Components

This is gone for giving the E2E(Exchange to Exchange) work process for imbuing ML into .NET applications across over pre-processing, feature engineering, modeling, evolution, and operationalization.

ml_dot_net_image4

Install ML.NET NuGet Package

Let us see to perceive how to include this NuGet Package in your .Net applications.

Important notes before starting

Initially, ensure that you have installed .NET Core 2.0 or later. ML.NET additionally takes a shot at the .NET Framework. Note that ML.NET right now should keep running in a 64-bit process.
Once you have all of these installed,

Steps of Build Project With ML.NET

  1. Open your Visual Studio 2017
  2. Create New Project
  3. Select Core Web application

ml_dot_net_image6

  1. Select Empty for now

ml_dot_net_image10

Once the application is built, Let us include required Microsoft.ML NuGet package.

  1. Search with “Microsoft.ML” In NuGet Package Manager and clicked on Install:

ml_dot_net_image5

In a fraction of seconds Build an Empty Project With Microsoft.ML NuGet packages are shown like this in Solution Explorer.

ml_dot_net_image8

And Now,

ml_dot_net_image7

Conclusion

Machine learning is blasting for the most recent few years. Individuals in the field are generally utilizing Python or R. Until this minute, it would be difficult to control the information and make brisk arrangements in C#. With ML.NET that is gradually evolving. While it is as yet missing a few highlights that Python and R have, this is a major positive development.

I am extremely eager to see where ML.NET framework will land and how it will be coordinated with the rest of the highlights of the .NET world in .NET Core 3. Machine learning is crossing the early adopter’s gap and Microsoft helping it.

Blockchain wiki

$
0
0

Overview

Hello all techie!! Today some new technologies like AI, Blockchain, Robotics, and IOT are buzzing the world of technology.
Right now, these technologies are getting so much attention from every technology experts.
Today we are trying to understand one technology named Blockchain from the above technologies.
Okay, guys, we are not going to debate about the future of blockchain like it is the bubble or it is just hype etc…
I only just know that this is the technology behind most successful cryptocurrencies and have more potential to be the future of the financial world and distributed web(web 3.0).
So here I am going to discuss what actually blockchain technology is and where it is going to be used.

Introduction

Before I start introduction about what is blockchain, let me clear some most rumored things about the blockchain.

  1. I think we weren’t pronouncing Blockchain as “B I T C O I N” right ??

blockchain_image2

I already wrote a blog previously on these misconceptions about bitcoin and blockchain if you have not read it, I recommend reading that blog first here.

  1. Many tech guys like us have the question that how we develop applications using blockchain as we develop in other programming languages.
    Here, we have to understand that blockchain isn’t the use case of the internet like email, e-commerce, social networking but it is something as fundamental and parallel to the internet.
  2. It sounded incredibly simple but it is very complex to understand.
  3. It has the potential to change our lives in the next 20 years in the same way that the internet has changed it in the last 20.

So, finally what is BLOCKCHAIN?

Many of you would say that “Blockchain” is the technology behind cryptocurrencies like bitcoin, ethereum, litecoin, etc. It’s true, but it’s like defining the internet as the technology behind email. Is it fair? Do we use internet only for email? No, the internet has much more capabilities except email. Like the internet, the blockchain has much more capabilities except cryptocurrencies.

blockchain_image5

Okay!! Right now you might have a question like – “Everyone is talking about blockchain potential application are endless and it will change everything etc.. but what exactly is blockchain?”

blockchain_image4

If you are google it you will get definition something like “The blockchain is a globally distributed ledger of economic transactions that can be computed to record not just economic transactions but basically everything of value.”
So, there are different ways to think about BLOCKCHAIN.
We try to understand it in other easy ways and with examples.

How does it work

Blockchain has below key features that encourage us to use blockchain instead of current centralized systems.

  1. P2P Network
  2. Proof-of-Work (Consensus)
  3. Immutability
  4. Cryptographic Security
  5. Distributed Network
  6. Smart Contract

We already know the meaning of Distributed and P2P network.

P2P Network:

Blockchain’s data is managed throughout an autonomous P2P network only. A simple
P2P network forms when 2 or more PCs get connected with each other and sharing resources without any need of one centralized server.

Above term, it sounds like google definition so we try to understand it with an easy example.

If you send money from India to a friend in the USA then it’s not the money that flies from here to where it’s actually a ledger entry that happened in my ledger and another parallel entry in my friend’s ledger and money is transferred.
Now, the problem in above scenario is that there are a bunch of other ledgers like banks ledger, regulators, insurance etc.. and each of these ledgers has to be reconciled and changed and because of these, you get so many changes which create complexity, is time-consuming, costly, less privacy and security.

Let’s try to solve some part of the above problem using one feature of blockchain that is P2P Network.
Think about Blockchain as the big global distributed ledger that was made of millions of computers connected with each other directly using P2P Network.
Now you and your friend that is in the USA is also connected in this one global blockchain ledger then you can directly send money to your friend without any intermediaries like bank, regulators etc..
So, we solved some part of this problem like complexity and time-consuming using blockchain p2p feature.
You might have some questions like,

  1. If banks and regulators are not there then how we can trust that the money is actually transferred to my friend or not and there may be a chance of hacking?
  2. If it is all distributed then how and who will be going to manage this entire network?

The answer to all your questions is in the next feature that is proof of work.

Proof-of-Work:

blockchain_image7

Above image gives answers to all your questions but let’s try to understand that.
As I said think blockchain as the big global distributed ledger. This ledger is nothing but a chain of blocks that stores every entry occurred in the network.
I already explained block structure in my previous blog you can also refer that for a better understanding of block.
Every Block contains some entries(data) and a hash of the previous block that creates the immutable chain. If you try to modify or change any existing block in blockchain it is nearly impossible to do that because every block contains the hash of the previous block so you try to change any block it generates a different hash compared to previous hash and you have to also modify all block hashes after this block before new block is generated or added to this chain. In short, the block structure provides the most powerful security to blockchain and creates the trust in data.
Remember that the above example of money transfer, this block structure solves the problem of security in that example.

Now, Proof-of-Work is the answer to the how or who maintains the blockchain network and creates the trust among the people that are connected to this network.
Let’s understand How to do it.
The blockchain is a distributed network of hundreds or thousands of connected nodes(computers) to each other. In this network, some nodes(computers) are connected as miners.
The concept of a miner is very complex and very deep diving but we try to understand the basics concepts of miners.
When every new entry enters in the blockchain ledger, miners compete to validate that entry and validate user by solving some big mathematical problem using their CPU power. The miner who solves the problem first is rewarded for using their CPU power and validate the entry.
NOTE: Blockchain is technology so everyone is trying to implement their different proof-of-work for security and trust, just like ethereum is trying to implement proof-of-stack instead of proof-of-work. Above explained proof-of-work is of bitcoin blockchain.

Smart Contracts:

The smart contract is pre-defined rules or logic and events on blockchain that trigger when some conditions are matched.
Let’s try to understand with our money transfer example.
If I want to put the condition on the blockchain network that one user can not send money more than three times per day.
Then how we can put this condition on blockchain network where there is no central authority available that check this condition because blockchain is distributed network and not owned by the single authority.
So blockchain has the feature like the smart contract that enables this condition on blockchain network for every user that is connected. Smart contracts are made of some programming logic that has some instructions and deployed on blockchain network.
Smart contracts are also immutable and can not be changed after it deployed on the network.
There are so much to do with smart contracts as we can also digitally form government contracts, land registry entries process etc..
We will more learn about smart contracts like how it is programmed and deployed on blockchain in upcoming blogs.

As I said Blockchain is technology rather than one network its have different types.

  1. Private Blockchain (Hyperledger)
  2. Public Blockchain (Bitcoin, Ethereum)
  3. Hybrid Blockchain

People using blockchain form above types of blockchain as per their use-cases.
Okay, guys I just try to explain blockchain using one example but believe me blockchain take much time and patience to understand it.

Was this Apple’s Special Event exciting?

$
0
0

Overview

List of devices/software updates Apple launched on 30th Oct in Brooklyn, New York:

MacBook Air

apple_event_image4

MacBook Air comes with 13.3-inch Retina display and Touch ID. To make it more secure T2 security chip is added. As last MacBook’s Keyboard had many issues, this time new Air has updated 3rd generation Butterfly keyboard. USB type-C is also added to make it slimmer and as same time faster and long-lasting. Clear screen with 4 million pixels. Audio is up to 25% louder. It supports up to 1.5 TB SSD. This time MacBook will come with the 100% recycled Aluminium body. Size and Weight are decreased than last Air. The color variants are Space Gray, Gold & Silver. The price is starting at $1199

Mac mini

apple_event_image2

New Mac mini has more power than other Mac mini. It comes with quad/6- core 8 generation Intel Core processor. It is almost 5x faster than the last mini. It supports up to 64GB of 2666 MHz memory. It also includes T2 chip. And 10Gb Ethernet is also given with 3 Thunderbolt ports. It comes with the Silver & black color option. Price is starting from $799.

iPad pro & Apple pencil

apple_event_image1

It’s a new edge – to – edge screen & design which makes it look better than older iPads. Screen sizes are 11 & 12.9 inch. It has the Liquid retina display as iPhone Xr. The A12 Bionic chip made it one the best PC & tablet in the market. As like iPhone X series it also has Face ID. USB type C is also given to make space compact and can transfer data and works as a power bank through it. The storage capacity is up to 1TB. It has E-sim feature. Price starting from $799.

The new Apple pencil 2 has a double tap. It can be attached with new iPad pro at side with the help of magnetic – wireless charging. Price starting from $129.

iOS 12.1 Update:

apple_event_image3

Awaiting update has come, everyone was excited. It has e-Sim support. Real-time depth control in new iPhones. Group FaceTime. New emojis were also added.

At last, we can say, the event was satisfying.

Fastlane: An automated app deployment tool – Part 3

$
0
0

Overview

Fastlane_image1

The Fastlane is the automated tool for deploying the entire apk and screenshots of the application on the app store.

Fastlane has the following capabilities:

  • Make a repeatable custom work process to build, upload and distribute new releases to the play store.
  • Upload and deal with the more significant part of your application’s metadata including screen captures.
  • Automatically submit new versions of your application for review.

Introduction

Fastlane helps developers by publishing/uploading an app screenshot along with all the necessary details with just a few commands.

In this part of the series, I’ll explain how to grab the screenshot automatically from the functionality of Fastlane. It allows you to:-

  1. Catch many screenshots in numerous languages on any simulator.
  2. Arrange it once, and store the setup so anybody on the group can run it.
  3. Get an outline of how your application looks like over every single supported devices and dialect.
  4. Accomplish something unique while the computer takes the screen captures for you. (Time-Saving)

We have finished the installation process in our previous Part 2 blog of Fastlane. Fastlane captures the screengrab automatically.

Setup the Espresso(If not found in gradle)

screengrab utilizes the capacities of Android’s worked in Instrumented tests joined with Espresso to drive communications with your application.

Add this dependency in your build.gradle file if it is not located(Generally, it is by default):-

dependencies {
     androidTestImplementation 'com.android.support.test:rules:1.0.2'
     androidTestImplementation 'com.android.support.test:runner:1.0.2'
     androidTestImplementation ('com.android.support.test.espresso:espresso-core:3.0.2') {
   		exclude group:'com.android.support', module:'support-v4'
          }
}

Setup the Android JUnit Test Runner

AndroidJUnitRunner is necessary for Android Test coding so please don’t remove it from build.gradle if you, unfortunately, removed it then please add it again.

android {
      defaultConfig{
             .....
             testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
             .....
      }
}

dependencies {
      testCompile ‘junit:junit:4.12’
}

Setup the Screengrab

Open the terminal and run the following command to install the gem for screengrab.

sudo gem install screengrab

Add the test dependency in the build.gradle file.

dependencies {
      androidTestCompile 'tools.fastlane:screengrab:1.0.0'
}

Permission to be needed for screen grabbing

Add the list of permission in your AndroidManifest.xml file to capture the screenshot and store the screenshot in the phone storage and change the locales for different languages.

<!-- Allows unlocking your device and activating its screen so UI tests can succeed -->
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<!-- Allows for storing and retrieving screenshots -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<!-- Allows changing locales -->
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />

Configure the Screengrab test code

  1. For automatically switching of locales you have to add the following code in your ExampleInstrumentedTest.java code.

@ClassRule
public static final LocaleTestRule localeTestRule = new LocaleTestRule();

  1. For capturing the screenshots add the following line in your test code.

Screengrab.screenshot("Example.png");

Example Code

Here is the ExampleInstrumentedTest.java which will perform the sleeping activity and manage the locales for taking the screenshots. (Locale will help you when we have a single app with the multiple languages)

@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {

   @ClassRule
   public static final LocaleTestRule localeTestRule = new LocaleTestRule();

   @Rule
   public ActivityTestRule<MainActivity> activityRule = new ActivityTestRule<>(MainActivity.class);
   Instrumentation.ActivityMonitor monitor = getInstrumentation().addMonitor(MainActivity.class.getSimpleName(), null, false);

   @Test
   public void testTakeScreenshot() {
       Activity secondActivity = getInstrumentation().waitForMonitorWithTimeout(monitor, 5000);    //This line will sleep upto 5 Seconds until my Splash screen is opened.
       Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy());     //Work with API level >=18
       Screengrab.screenshot("Dashboard.png");
   }

   @Test
   public void useAppContext() {
   }
}

Edit the fastfile

Create the new lane for capturing the screenshots and upload it to the app store by adding the following lines to your fastfile.

lane :screenshots do
    screengrab(
      locales: ['en-US'],     #uses when your app will running in multiple languages
      clear_previous_screenshots: 'true',
    )
    capture_android_screenshots
    upload_to_play_store
  end

Deploy your screenshots on Google Play Store

Now execute the fastlane screenshots command in the terminal after going inside the path up to the project folder and your screenshots will be live on the google play store within a few hours.

Fastlane_image2

How to Release Android APK on Google Play Store

$
0
0

Overview

In the Android world, Google Play Store is the ultimate platform for any developer or investor to make his presence felt, to increase the audience of his app, to engage with users and lots of other vital stuff, if he aims to release his app into the wild. 😀

Generating Signed APK

To upload an app on play store it’s necessary to generate a signed apk. Play store only accepts signed APK in order to upload the application. Generating signed APK simply means signing your app with a digital, public-key certificate. This allows other users to install your app via the Play store.

To sign an APK, we’ll need a file called keystore, having .jks extension. Speaking in very general terms, this file is used to authenticate ourselves for anyone who is asking. This file stores certificates and such authentic stuff.

Let’s get started.
In Android Studio, click on Build options then click on Generate Signed Apk.

how_to_reease_image4

Then select your app and click on Next.
Further, we have to create a keystore for your application to publish it on the play store. As described earlier, It is a file which secures your app data from unauthorized access and it is the certification that only the holder of the application can publish and update the app on play store.

Now, if you have not already generated key store for your app, then click on Create new to generate a new keystore for your app. Then select a path where you want to save and provide necessary key store password details. Then, provide alias of your key and password details. Add validity (in years) limit for your app on play store. Next, you need to add at least one certificate issuer field to continue. Now, click on OK to generate keystore for your app.

how_to_reease_image5

If you’ve generated key store earlier then click on choose existing and select the keystore path where your previously generated key store for this particular app resides. Also, provide Key store password, Key alias, Key password details.

how_to_reease_image10

Now, click on next, then choose APK destination folder where your app will be created. Also, select the Build type. Set Build type to release to upload it on play store. Then select both V1(Jar Signature) and V2(Full APK Signature) to generate signed apk. V1 and V2 are the mechanisms designed to make the APK signature more secure. Now, click on Finish. After some time, your signed apk will be generated and a successful app creation dialog will appear. Then click on locate to navigate to the generated signed apk folder.

Publishing app on Play Store

Now, to upload this signed apk on play store you must have a google developer account. Visit this post to get more details on it:
https://www.yudiz.com/google-developer-console-registration/

To upload an app on play store, go to your developer console and click on Create Application. Then provide the language and title for your application and click on Create.

how_to_reease_image3

Now, before filling details of content rating you must have to upload your android app on play store in alpha, beta or production phase from App releases.

how_to_reease_image6

I’ll talk about the Production phase. So, click on Manage button in Production Track. Now, click on Create Release. Fill out the necessary details and also upload your signed apk. Also, add a release name (like app version 1.0 or 2.5 etc.) and release note about the app update details. Then save the details.

Now, to finally roll-out or publish your application on play store, you must have to fill out all the necessary details related to the app in below three sections.

  1. Store listing
  2. Content rating
  3. Pricing & distribution

The fields marked with * are mandatory.

Store listing:

how_to_reease_image11

In the Store listing, you need to provide Title, Short description and Full description of the application.

In Graphic Assets, you have to add at least 2 screenshots for your application. In High-res icon you have to add an image which displays as your app icon in play store and in feature graphic you have to add a photo for your application banner. Make sure that images uploaded are of the exact size as mentioned. Provide the necessary details for categorization, contact details, and privacy policy. Now, save the details of Store listing by clicking on Save Draft.

When your details are successfully submitted for any section. It will turn in to the green tick mark (accepted). But, if any necessary details are missing or any corrections are required then it will provide the warnings which you have to fix and then continue further.

how_to_reease_image8

Content Rating:

how_to_reease_image2

In Content Rating, you have to provide a valid email address. Select your app category and fill out the necessary details and click on Save Questionnaire. Now, click on Calculate Rating. Then, click on the Apply Rating. Now, you’re done with this section. Please make sure that your content ratings represent your app in a transparent and correct manner. Providing ratings which contradict with the app’s functionality may result in app removal from Play Store in later stages.

Pricing & distribution:

how_to_reease_image9

Now, in pricing and distribution, you have to set your application to Paid or Free. Fill up other necessary details like selecting countries which should have access to your app, consent and user programs related details. Then click on Save Draft to successfully submit the details.

After this, all these three sections are accepted or verified.

Now, go to App releases then click on Edit Release, click Review and Rollout and then click on Start Roll-out to Production button. This will start publishing your app to upload on the play store.

how_to_reease_image7

Congratulations… you’ve successfully uploaded your app on the play store. It can be viewed on the play store in a few hours (In some cases it may take some more time to publish based on countries you selected to distribute your app).

TL;DR

We have to generate signed apk to upload application on play store.

To publish our android application on play store we must have a developer account. Then to finally rollout our application we have to fill up the necessary app related details in three different sections i.e., Store listing, Content Rating, Pricing & distribution.

We can also publish our app on play store using Fastlane technique which requires very fewer steps to process and upload your app on the play store. To get familiar with the Fastlane, visit the blog here:
https://www.yudiz.com/fastlane-an-automated-app-deployment-tool-part-1/

Yudiz rated as the top B2B company on Clutch Global -2018

$
0
0

Clutch, B2B ratings, and review firm in Washington D.C use extensive research to compare companies across a range of criteria. This year, for the first time ever, they are releasing a global ranking of companies across all categories, the Clutch 1000. Yudiz is honored to be included in this exclusive ranking. The list is based on a company’s ability-to-deliver score, encompassing their client reviews, brand reputation, and company history.

clutch_global_2018_image_1

In addition to the Clutch 1000, we’re proud to have been rated a high-performer amongst web, mobile app, game development, AR/VR, and blockchain developers. We strive to provide our clients with the highest quality and most comprehensive service possible and it’s gratifying to see that they appreciate our work.

clutch_global_2018_image_2

A large part of Clutch’s rating system weighs on the client interviews they conduct with a company’s references. To get a good review, clients must be happy with the cost, time-scale, focus, and of course, outcome of the project. To be rated as one of the absolute best companies on Clutch is an honor for us and speaks to the enormous generosity of our clients. Each review on Clutch features quotes from past clients, here are some of our favorites:

clutch_global_2018_image_3

clutch_global_2018_image_4

clutch_global_2018_image_5

We’re also proud to say that Clutch’s sister site, The Manifest, listed our team as one of the top 100 virtuals and augmented reality developers in the world. The Manifest helps businesses make engagement and consulting decisions by publishing surveys, industry reports, how-to guides, and lists of top ranking companies from around the globe.

We know that technology moves fast. Finding the best way to stay ahead of the competition and engage with your clients and customers are always going to be a challenge, but we have the tools and the people who can help you do it. Contact us and stay up-to-date with our Clutch profile to learn more.


Progressive Web Apps With Angular: Part 1

$
0
0

Overview

Progressive_Web_Apps_image1

Progressive Web Applications will be the game changer for Mobile application, many big companies like Flipkart, Twitter, Trivago, AliExpress are already using PWA features.

Here we are going to build Contact book using Angular 7. The application shows the list of contacts which is added by the user. The user can also edit the contact and some native feature like the splash screen, offline support and sharing data on any social media.

Getting Started

Let’s start a New Project named Contact Book. (My current Angular CLI version is 7.0.2, Node version is 10.8.0, NPM version is 6.2.0)

ng new ContactBook --routing
cd ContactBook
ng serve --open

The command will open a new tab in the default browser. The command will serve the project on http://localhost:4200/ with some default content.

Adding Angular Material

For designing purpose, Here we are using an Angular material framework.

npm install --save @angular/material @angular/cdk
npm install --save @angular/animations hammerjs

Also, need to import in styles.css

/* src/styles.css */

@import ‘~@angular/material/prebuilt-themes/indigo-pink.css’

Now we add some material design modules to our application like hammerjs and BrowserAnimationsModule . For the use of any component from the material design we need to import that. Here first we import Toolbar component in app.module.ts file. Don’t forget to add in imports.

import 'hammerjs';
import { BrowserAnimationsModule} from "@angular/platform-browser/animations";
import { MatToolbarModule } from "@angular/material";

Now we can use the toolbar in any component of this application. Here we use the toolbar in app.component.html file.

<mat-toolbar color="warn">
 <h1>My Contact Book</h1>
</mat-toolbar>
<router-outlet></router-outlet>

Create RESTful API

We need to create RESTful API for our project. Here we create simple API with NodeJs. For API, we create a new folder named as server in the current directory and then add a package.json file via npm init. Now the next step is to install dependencies that we are going to use. Install express-nedb-rest (npm install express-nedb-rest –save) that is an open source API using express & nedb that create restful API automatically. Then we install cors ( npm install cors –save) that are a technique which will serve API to sub party domain.

Now we create a new file called index.js for our server. This server we will be able to get an element from the database, to put the element to the database, to update and delete the element from the database.

index.js.

const express = require("express");
const nedb = require("nedb");
const rest = require("express-nedb-rest");
const cors = require("cors");
const app = express();

const datastore = new nedb({
   filename: "mycontactapp.db",
   autoload: true
});

const restAPI = rest();
restAPI.addDatastore('contacts', datastore);

app.use(cors());
app.use('/', restAPI);

app.listen(3000)

Now it’s time to run our server with node index. We can see the result something like below in the browser on http://localhost:3000/. Now our server is ready to use.

[{“name”:”contacts”,”link”:”http://localhost:3000/contacts”}]

Time to Put some logic

Let’s take contact dynamically from the server. For that purpose, we need to add
contact.ts.

export class Contact {
 _id: string
 phoneno: number
 email: string
 relation: string
 notes: string
 constructor(public name: string = "",
                     public address: string = "") { }
}

Now we need to generate service via ng generate service data. Update providers in app.module.ts file. Data service is used to get data from the database, update data into the database. For that first, we need to import httpmodule in the app.module.ts file. Then request to the server with GET request to get data from the database. Save or update data into the database. Here endpoint URL is server URL which will be changed according to the server.

Data.service.ts.

export class DataService {
 constructor(private http: Http) { }
 public endpoint = "http://localhost:3000"
 getList(callback) {
   this.http.get(`${this.endpoint}/contacts`).subscribe(res => {
     callback(res.json())
   })
 }

 get(contactId: string, callback) {
   this.http.get(`${this.endpoint}/contacts/${contactId}`).subscribe(res => {
     callback(res.json());
   })
 }

 save(contact, callback) {
   if (contact._id) {
     this.http.put(`${this.endpoint}/contacts/${contact._id}`, contact).subscribe(res => {
       callback(true);
     })
   } else {
     this.http.post(`${this.endpoint}/contacts`, contact).subscribe(res => {
       callback(true);
     })
   }
 }
}

Adding Components & Routing

We need to add components to separate contact detail form and display contact list which is added by the user and put routing for navigating from one page to another page. Now let’s generate component.

ng generate component list
ng generate component contact

As a result, angular generate two separate folders with necessary files and also update in the app.module.ts file.

In list.component.html file, we need to import angular material components to app.module.ts file. Add the following code

<mat-card  *ngFor="let contact of list">
 <mat-card-title >{{contact.name}}</mat-card-title>
 <mat-card-subtitle>Number: {{contact.phoneno}}</mat-card-subtitle>
 <mat-card-actions>
     <button (click)="goShare(contact)" name="share" mat-button>
       <mat-icon>share</mat-icon>
     </button>
     <button (click)="goDetails(contact)" name="list" mat-button>
       <mat-icon>list</mat-icon>
     </button>
   </mat-card-actions>
</mat-card>
<a id="btn-create" mat-fab routerLink="/contact" style="background-color: #f44336">
 <mat-icon alt="create">create</mat-icon>
</a>

In list.component.ts file add function to bind data dynamically and add routes. For sharing purpose here we are using WhatsApp URL. You can find URL from https://faq.whatsapp.com/en/iphone/23559013

export class ListComponent implements OnInit {
 list: [Contact];
 constructor(private data: DataService, 
                    private router: Router) { }

 ngOnInit() {
   this.data.getList(list =>{
     this.list=list;
    } )
 }
 goShare(contact: Contact) {
   const shareText = ` ${contact.name} 's contact no is ${contact.phoneno}`;
   if ('share' in navigator) {
     (navigator as any).share({
       title: contact.name,
       text: shareText,
       url: window.location.href
     }).then(() => {
       console.log("shared");
     }).catch(() => {
       console.log("error shared");
     });
   } else {
     const shareURL = `whatsapp://send?text=${encodeURIComponent(shareText)}`
     location.href = shareURL;
   }
 }
 goDetails(contact: Contact) {
   this.router.navigate(["/contact", contact._id])
 }
}

Now, we will create forms in contact.component.html file. Here we are using ngModule for binding data to the input.

<form action="" method="post">
 <mat-card>
   <mat-card-title>Basic Coffee Information</mat-card-title>
   <mat-form-field>
     <input matInput name="name" [(ngModel)]="contact.name">
     <mat-placeholder class="placeholder">Person name</mat-placeholder>
   </mat-form-field>
   <mat-form-field>
     <input matInput name="cno" [(ngModel)]="contact.phoneno">
     <mat-placeholder class="placeholder">Contact No</mat-placeholder>
   </mat-form-field>
   <mat-form-field>
     <input matInput name="email" [(ngModel)]="contact.email">
     <mat-placeholder class="placeholder">Email Address</mat-placeholder>
   </mat-form-field>
   <mat-form-field>
     <input matInput name="address" [(ngModel)]="contact.address">
     <mat-placeholder class="placeholder">Address</mat-placeholder>
   </mat-form-field>
 </mat-card>
 <mat-card>
   <mat-select placeholder="Relation" [(ngModel)]="contact.relation" name="relation">
     <mat-option *ngFor="let relation of relations" [value]="relation">
       {{relation}}
     </mat-option>
   </mat-select>
 </mat-card>
 <mat-card>
   <mat-form-field>
     <textarea matInput name="notes" [(ngModel)]="contact.notes"></textarea>
     <mat-placeholder class="placeholder">Notes</mat-placeholder>
   </mat-form-field>
 </mat-card>
 <mat-card>
   <button mat-raised-button (click)=cancel() name="cancel">Cancel</button>
   <button mat-raised-button color="warn" (click)=save() name="save">Save</button>
 </mat-card>
</form>

In contact.component.ts file we put logic to bind data with input and get the data according to the id for editing purpose.

export class ContactComponent implements OnInit {
 contact: Contact; // from contact.ts file
 routingSub: any;
 relations = ["Family", "Friends",”Partner”];
 constructor(private route: ActivatedRoute,
                    private router: Router,
                    private data: DataService) { }

 ngOnInit() {
   this.contact = new Contact()
   this.routingSub = this.route.params.subscribe(params => {
     console.log(params['id']);
     if (params["id"]) {
       this.data.get(params['id'], res => {
         this.contact = res;
       })
     }
   });
 }
 cancel() {
   this.router.navigate(['/']);
 }
 save() {
   this.data.save(this.contact, result => {
     if (result) {
       this.router.navigate(['/']);
     }
   })
 }
  ngOnDestory() {
   this.routingSub.unsubscribe();
 }
}

Check Audit

We need to check out how our application is going and where we need to change for PWA feature. All we need to do is open our Chrome DevTools and go to the Audits tab, where we can find such a powerful tool as Lighthouse — the best diagnostics of web pages. Now press Perform an Audit. it will take some time, then it will get some result. The result is not so good for now. We need to increase PWA score for the better result.

Progressive_Web_Apps_image3

Conclusion

Now Run Angular Project http://localhost:4200/ and Node server http://localhost:3000/ together in the terminal. This is how you can create & run angular 7 application with node integration. In PART 2, we are going to add PWA features & increase PWA score to our application.

Progressive_Web_Apps_image2

Game Testing is NOT a ‘Game’

$
0
0

Overview

The Game industry is a top growing industry in today’s era and it is growing steadily. Commonly the game’s success mainly depends on the quality of the game and performance of the game. This is where game testing comes into the picture. High-Quality testing is important for the game’s success. There are different types of games and each of them is unique by its own irrespective of the platform. Means Game testing is not as easy as we think, many Special qualities required for a game tester and there are lots of difficulties testers feel during game testing.

game_testing_image_1

Qualities Required in a game tester

  • Game Tester does not always require a technical degree, whereas a Software tester is preferable to have an Engineering degree in Computer field or any other technical field, but a game tester should have a passion for games, good written/communication skills and able to do repetitive work.
  • A game tester should be able to keep a continuous record of enormous amounts of dynamic details or Game flow.
  • In games, Recreating bugs is extremely difficult. To recreate bugs tester should have an expertise and well attention towards the game flow.
  • Games are always developed with respect to the latest Operating systems & hardware; hence, game testers must stay updated with the trends.
  • There are some similarities between software testing and game testing but all types of testing require expertise to perform it well and in a proper flow.

game_testing_image_2

Types of Games

  • Console
  • PC
  • Mobile
  • AR/VR
  • Web-based etc.

Challenges in Game Testing

User interface: Games are developed with respect to different resolutions of devices in the market. Tester’s responsibility is to check that the game works without any interruption across different Layouts & screen resolutions. In other words, Regression testing must be completed frequently to assure that the game’s Graphics does not change even when layout and resolutions change. Tester has to check the game in different Screen orientation. Testers have to keep an eagle eye on whole display during testing.

game_testing_image_3

Gameplay: Gameplay is as important as UI of the game for success in the market. Tester has to play all the levels, all character of the game, in other words, a tester has to test game till whole game and scenarios are not covered. And this is challenging for a tester to cover a whole game and to keep the record of the whole game and if any bug is there in gameplay then tester should be able to recreate the bug. In some games like where star ratings are there then, a tester has to test whole game with 3-star ratings, 2-star ratings and 1-star ratings; because some critical bugs are there which does not reflect in any star ratings.

game_testing_image_4

Multiplayer Feature: Testing a multiplayer game is challenging for Game testers. Multiplayer testing is about recreating a Bug/Scenario of many players, this can be challenging because players can be from anywhere, not from the same room. Sometimes it is impossible to recreate the Bug/Scenarios in a multiplayer game. There are lots of possibilities for testing the games. A multiplayer game goes through the backend server and for this situation, the network will be a crucial thing while testing.

game_testing_image_5

Game Authenticity: Tester has to test authentication of the game because nobody wants to lose their saved game or score not being updated due to a bug in authenticity. So it is the business of a tester to take care of this kind of bug and verify that the game authentication is working properly or not. Apart from this, other authentications are there like, users authentication, device authentication and authentication with the social media app. Tester has to check all the possible and required scenarios in authentication like forgot the password, forgot username etc.

game_testing_image_6

Social Media Integration: Social media synthesis with the game is a crucial part for the game. In most of the games, it is compulsory to sign up with a social application or share the game’s results on the social application. Hence the games should be tested in Android, iOS, Windows etc. devices, with various OS versions and device configuration. It will be a tedious task for a tester to test the same thing in multiple devices, so testers have to be passionate.

game_testing_image_7

Performance Testing: Without performance testing, medium & big games cannot be released. Here the challenge is to check the performance of the game in combination across devices, hardware, and platforms. The other challenge for checking the security of the game, as if the game is played online around the world. Then the tester has to verify that the game can withstand with the heavy rush, external attacks, and vulnerabilities.

game_testing_image_8

Conclusion

Hence we can conclude that Game testing is not as easy as we think and not enjoying at all for game tester because it is a repetitive task and to do the same thing constantly for a long time with full concentration and this is a hard job. And the very challenging task for the game tester is to reproduce the same scenarios again and again during testing the game and during verifying solved bugs. So game testing is also a hard work it is not as easy as people think.

Project Tiny Unity : A Package to build quality 2D games quickly

$
0
0

Overview

This article explains you about the Project Tiny package in Unity, what are the benefits of using this project tiny package and how to use this package in Unity.

project-tiny_image1

Introduction to Project Tiny

Tiny Unity is the package, which helps to build the small 2D Web Games, Social Applications Games, and Playable Ads easily and rapidly. This package is new runtime, modular design and using Pure ECS (Entity Component System) data-oriented approach as it leverages the C# job System and Burst Compiler, which helps to maximize the rendering of the content at runtime. Tiny Unity Package reduces the build size, so the user can load and play the game instantly on their device.

As of now, Project Tiny is using typescript to write the game logic, but once its support is ready, it will be replaced with C# to write the game logic, which will make the code size even smaller and provides the better and improved performance along with the better debugging experience.

So basically, the Project tiny makes the unity assets and game size compressed & smaller and increases the rendering speed of the games in Playable Ads, Games in messaging Apps. So the user can play the games without downloading and installing the games easily.

Benefits of using Tiny Unity Package

There are many benefits of Tiny Unity package such as:

  • We can maximize the download/loading speed of the game.
  • To optimize the games build size and loading the unity game in a web browser can be lower down to avoid the delay in rendering and playing the game.

For example, in the devices like iPhone 6s, the loading time of the web games is around 350 m/s to 600 m/s. While using Tiny Unity, the rendering of the web games can be three to four times faster (even when the internet connection is low) than the WebGL games due to its smaller build size like 100kb to 5mb.

  • Tiny Unity is used to optimize the ECS approach by making it simpler. It introduces prefabs to ECS. Prefabs are used as the Core Component while making new instances in the project. If the developer wants to do any change in the project, then the developer can only edit in the prefab and it will automatically reflect in all the instances or the developer can make the independent change in all the instances as per the need.
  • It supports 2D HTML 5 targets, 2D WebGL and Canvas for rendering targets.
  • There is more flexibility in development as its content can be embedded in Web App, Android App, iOS App, Native App.
  • Tiny unity supports the existing art assets, but it does not support the existing code. The developer will have to make some modifications in the existing code, as it uses the ECS approach.
  • Project Tiny provides the solid performance as it decreases the build size and loading time.
  • It provides the better editor experience as it allows the developer to pick which functionalities they want to include.

How to Get Started with Project Tiny?

Steps to Install Project Tiny:

  • Open Unity 2018.3 Package Manager
  • Simply open the Windows -> Package Manager
  • You need to install Tiny Mode Package
  • If Tiny Mode package is not available then click advance -> Preview Packages
  • Now Install Tiny Mode package from the Package Manager into the project
  • Now you can see Tiny Menu in the Menu bar
  • Now you can create the tiny project or import the tiny samples and start working

So, this is just an introduction part of project tiny package in unity. Stay Tuned for a more advanced post on a similar topic.

WordPress :: Migrate individual sites from multisite network

$
0
0

Overview

Your WordPress site has a multisite network if it has the following features::

  • Collection of different WordPress sites controlled by a single WordPress installation.
  • Collection of plugins and themes is shared for all websites in the same network.
  • It is multi-user version of WordPress.
  • Only administrator can install themes and plugins. Other users can only select them from the list made available by the system administrator.

Learn more about “Multisite Network in WordPress“.

Before starting site separation you are suggested to get a backup of your whole WordPress site!

Prerequisite

  1. Login as superadmin to your multisite network. ( find more about this role here )
  2. You will find a new option named “My sites” on the top left of your admin menu.
  3. You can navigate using My Sites > Network Admin > Sites

multisite-network-to-individual_image2

You will get your screen something like this :

multisite-network-to-individual_image3

  1. Get the ID of your site from listed sites
  2. Find ID by selecting the edit option of your site, then the URL should be like http://example.com/wp-admin/network/site-info.php?id=XX

Database Migration

Export the tables of your site from the database

  • Go to the Export tab of your multisite database in phpmyadmin.
  • Select tables relating to your site ID you are exporting.

For example, If your site ID is 2 then see the following:

multisite-network-to-individual_image4

  • Also, select users’ table and usermeta table as they are common for all sites.
  • Export selected tables.
  • Create a new database for the site that you want to create new.
  • Import the exported sql file and rename tables using the coming prefix to match with wordpress table structure.

or you can simply remove the site ids from the table names. such as change {prefix}_{site_id}_{tablename} to {prefix}_{tablename} . ( ex. wp_3_posts => wp_posts).

WordPress Installation

Download a new WordPress installation from here.

  • Extract the downloaded zip to your desired location.
  • Open config.php file and change database details. Use details of the database you just created in step- 4.

Make sure the table prefix in your database and table prefix config.php are the same.

Data Modification

Files

Remove plugins and themes folders from wp-content of the new installation.

  • Copy these folders from your multisite network.
  • Copy your site’s upload data from parent site’s wp‑content/uploads/sites/{ID}/.
  • Create uploads folder in our new wp-content and paste copied data here.

Database

Edit links in the database

  • Change site’s domain from multisite network domain to a new single site domain. For example, if your site was at example.com/site1 , change it to site1.com
  • Check your domains in case your site had a domain mapped to it and it’s not a domain you’re moving it to.

At this point, we have migrated our site physically.

Now login as admin for our newly created site. Users’ data will be the same as the old site. Check permalinks and make sure all URLs are working fine!

How to Add Bootstrap to an Angular Project

$
0
0

Creating an Angular project with Angular CLI

To create a new project write the below command in the terminal/command line.

ng new angular-bootstrap-example

Installing Bootstrap

We have two steps to add bootstrap in angular project

a: Installing Bootstrap from NPM

Next, we need to install Bootstrap. So, Type in your terminal cd for Example- cd angular-bootstrap-example press enters and type below command to install bootstrap :

For Bootstrap 3:
npm install bootstrap@3.3.7 ( install a particular version of bootstrap)
For Bootstrap 4:
npm install bootstrap (directly installed latest version)

b: Alternative – Local Bootstrap CSS

You can also download the Bootstrap CSS and add in your project. I have downloaded Bootstrap from the https://getbootstrap.com/ and added into src/assets/css/bootstrap.min.css

add_bootstrap_to_angular_image3

Importing the CSS

We have two variations to import bootstrap in angular project

a: If you have installed Bootstrap from NPM

just open the angular.json file and give your style path like below:

"styles": [
  		 "node_modules/bootstrap/dist/css/bootstrap.css",
       		 "scss/style.scss"   
   	 ],

add_bootstrap_to_angular_image10

b: If you added the Bootstrap CSS file locally

just open angular.json file and give your style path like below:

"styles": [
  		"src/assets/css/bootstrap.min.css",
       		"scss/style.scss"   
   	 ],

add_bootstrap_to_angular_image8

How to use Custom CSS in Angular

Make one CSS file in your src/assets/css/custom-style.css

add_bootstrap_to_angular_image1

just open the angular.json file and give your style path like below:

add_bootstrap_to_angular_image6

Note: Your custom CSS should be last of other CSS

How to install Bootstrap JavaScript Components with ngx-bootstrap (Option 1)

In some case, you want to use models, accordion, dropdown without installing jquery. So, angular provides wrapper library for Bootstrap called ngx-bootstrap and that we can also install from NPM:

npm i ngx-bootstrap

Adding the required Bootstrap modules in app.module.ts

If you want to use any ngx-bootstrap modules so go through ngx-bootstrap and add the module you want and also add that module in your app.module.ts. For example, suppose we want to use the Accordion component:

import { AccordionModule } from 'ngx-bootstrap/accordion';
   	 imports: [
   	        BrowserModule,
   	       AccordionModule.forRoot()
   	   ],

add_bootstrap_to_angular_image2

.forRoot() is like a global scope to provide the functionality of all modules be available in all components.

How to install Bootstrap JavaScript Components with ng-bootstrap (Option 2)

If you use Bootstrap 4 in your project and also used models, accordion, dropdown without installing jquery. In case angular provides wrapper library for Bootstrap 4 is: ng-bootstrap and that we can also install from NPM:

npm i @ng-bootstrap/ng-bootstrap

you also need to import NgbModule, in app.module.ts :
Other modules in your application can simply import NgbModule app.module.ts:

import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
    imports: [
   	      BrowserModule,
   	       NgbModule
   	   ],

add_bootstrap_to_angular_image5

add_bootstrap_to_angular_image11

If you want to use mdbootstrap

install mdb via NPM:
npm i angular-bootstrap-md

a: Add below code in you app.module.ts

import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
    import { MDBBootstrapModule } from 'angular-bootstrap-md';
    imports: [
    	    MDBBootstrapModule.forRoot()
	    ],
    schemas: [ NO_ERRORS_SCHEMA ]

add_bootstrap_to_angular_image4

b: Rename your style

rename /src/styles.css to styles.scss

c: Install external libs

npm install -–save chart.js@2.5.0 hammerjs

d: Add below lines to angular.json

"styles": [
    	    "node_modules/angular-bootstrap-md/scss/bootstrap/bootstrap.scss",
	    "node_modules/angular-bootstrap-md/scss/mdb-free.scss",
      	   "src/styles.scss"
    ],
    "scripts": [
     	 "node_modules/chart.js/dist/Chart.js",
     	 "node_modules/hammerjs/hammer.min.js"
    ],

add_bootstrap_to_angular_image7

e: ng serve

Conclusion

I hope that you will find this blog helpful for the novice for how to integrate external and custom CSS as well as JS in Angular.

Ultimate Guide of Making the Polished Wireframes – 1

$
0
0

Overview

Unless you’re hiding under the rock, I am sure you’d have heard of Wireframes. The most straightforward approach to consider wireframe is in terms of building a house. Before you apply all the paint and furnishings, the architect needs to prepare the floor plan. He needs to ensure the spaces in the housework well and that they are where the residents would expect them– Imagine having a kitchen in the main room or a light switch behind the toilet!

polished_wireframes_1_image4

What Are Wireframes?

  • The wireframes are the floor plan of your product, making a vessel for which design and content can flow into. Utilizing wireframes earlier in the design procedure compels you and your customers to look objectively at ease of use, transformation ways, element placement and helps point out flaws early.
  • At the Wireframing phase of the project plan, our thoughts are young and unpolished. Wireframes, regardless of whether made on pieces of paper, a whiteboard, or in software, serve to build up connections between elements in a project such as navigation, imagery, and calls to action. The building blocks of the final product are first envisioned in the wireframe.

polished_wireframes_1_image3

Why Are Wireframes Important?

  • Wireframes are easy to create; meaning could be experimented and developed with new ideas without taking too much time or effort if they fail. Areas like navigation and layout determine how the rest of the project proceeds and if there’s a problem, it’s better to tackle it at the start, rather than later with high-fidelity prototypes, where you might have to spend more time redo some work.

Benefits of Creating Wireframes:

  • Display product architecture visually.
  • Allow clarification and confirmation of features.
  • Help the design process being iterative.
  • Designs are more calculated.
  • Development team gets to know what they are building.
  • Content creation becomes clearer.
  • Time-saving process for the entire project.
  • Avoid hacks later on in the process.

To Whom The Wireframes Are Useful

  • Designers – Giving a basis to begin creating screens.
  • Developers – Using as a reference point for functional specifications
  • Stakeholders – Communication medium what you are going to build without muddling the waters with visual design elements or colors or branding. It allows the clients to provide feedback earlier in the process.

Few Important Tips for Creating Wireframes

•  Ask questions

As anonymously quoted by someone,” Knowledge is having the right answer. Intelligence is asking the right question”. So, always keep a habit of asking the right questions to the stakeholders/clients.

polished_wireframes_1_image1

•  Collaborate

Never wire alone. When you brainstorm together with your team members, the potential for a good outcome is bound to increase significantly. Showing your Wireframes to team members prior in the design process approves and enhances your thoughts.

•  Content is King

Know the importance of content/data and arrange the data into some meaningful order to make it easier to understand analyze or visualize. Try to use real content or believable dummy data.

•  Consistency is the key

As quoted by Brenda Laurel – Renowned UI Designer, “A design isn’t finished until somebody is using it”. Persistence will only get you to your goal but it is the consistency that will keep you focused on your goal. So it is your initial efforts that you devote to make the wireframes that count the most and rest is just a cake walk.

•  Don’t Get Lazy

Most of them would agree to the saying, “The Sign in the process is obvious, let’s not include it in the Wireframe” but only the experience would guide you not to. The ideal practice that should be followed is to Wireframe almost everything as every step holds its individual importance and it cannot be ignored.

•  Focus on Detailing – Typography, and Spacing

Showing the hierarchy of information through font is important. It can be shown through simply changing the size of the font and whether it is “Regular”, “Italic” or “Bold“.

•  Gathering Feedbacks

You should be gathering feedbacks on wireframes from stakeholders, quickly moving things around on your wireframes based on the feedback you receive, gather feedback again and iterate until you reach your intended goal.

Conclusion

This is just the beginning where I might just have intrigued your interest in Wireframes. If you’re really planning to learn on how to make them stay tuned to my upcoming blog. Coming Soon! 😉

polished_wireframes_1_image2

Guide to analyze the App Store Connect App Analytics

$
0
0

Overview

So, you spent countless hours on research, collecting data and information and developing your app. Your team and you spent numerous hours working on the app making it as much better as you can in the matter of performance and look and feel and what not. So the app is completed, uploaded on App Store, now what?

appstore-analytics_image7

Easy, you learn App Store Connect App Analytics, as an app merchant it’s very important for you to have the clear knowledge about the app analytics, it helps you look for opportunities for your business growth, helps you improve your app. And where do you learn it from? Right Here 👇.

Topics: The Analytics Topics we’ll cover

  1. App Store
  2. Sales
  3. Usage

The App Store

App store is expected to reach about 5 million apps in the coming two years 😲 . Yes, you read it right 5 million. It’s a pretty big market, you got to get your app discovered and noticed in the crowd of all these apps and the metrics provided by the App Store are just the thing you need for this purpose.

So, to start, first of all just log into your App store account then,

  • Directly click on the app analytics icon

appstore-analytics_image4

OR

  • Click on my apps and then click on App analytics

appstore-analytics_image2

On clicking app analytics you’ll see bar graphs as below.

appstore-analytics_image3

Impressions

When you scroll or browse through the app store you come across many apps, this increases the impression of that app. In short, Impression is the number of times a user came across the icon of your app while browsing or searching for an application. Through impression, Conversion Rate can be calculated. Conversion Rate is how many users come across your app and install it. If your impressions are high but the Conversion Rate is low, you need to work on your marketing strategies or look into the matter that why the user who comes across the app doesn’t choose to install it. As you can see above our Scroll It App has 3602 impressions but only 14 app units, so we got some work to do 😥.

Product Page Views

Product page View is the metrics of users who tapped on your app’s detail page view, the page where screenshots and additional details are displayed. This helps us to know how many users wanted to or were interested in downloading our application.

Sales

appstore-analytics_image5

App Units

App Units is the number of times a user actually downloaded your application in a day, i.e. how many times user tapped the buy or get button making it a download. Through this, you can further understand the behavior of the user. If your product page view is more an app unit is less that means the user is not satisfied with info provided on the page or something threw the user off.

In-App Purchases

It is the sales done in your app in a day from the in-app offerings. If your app doesn’t offer any in-app purchases, this metrics is supposed to be a flat line for you, but if you have in-app purchases in your app and you see blue spikes then, congratulations, your app is earning through in-app purchases.

Sales

Sales are the real-time cash 💰 earned by your app or the revenue generated by your app, this is the total of app purchases and in-app purchases but remember, you won’t get all of the revenue generated. Apple gets to take the 30% and the remaining 70% is your own.

Paying Users

Paying user is the number of users making a purchase in your app. This metric doesn’t provide that much important information. Detailed information can be calculated based on this metrics through, like per user expenditure or In-app Purchase to paying user ratio, as it will only show one paying the user for a user who made 3-4 in-app purchases.

Usage

Installations

Installations are the number of times the user installs your application. Well it sounds just like App-Units, right? Wrong. Installation is counted after user launches your application for the first time. If your user downloads the app but doesn’t open it then installation count won’t increase. If the user doesn’t have an active internet connection, that will also deprive the app store to get the correct installation count.

Sessions

People from development background are familiar with the word “session”. Here session is when your app has been run for minimum two seconds. If your app runs in the foreground even for two seconds then it’s a session if you send your app to background the session ends, that means if you bring it to foreground the session count will increase. It will help you to understand and analyze the number of users engaging with your application.

Active Devices

Active devices are the total number of devices that at least have one session in a day. It often happens that a user doesn’t use an app daily. Or downloads an app but never use it, then it’s obvious that the active device chart will not have enough spikes.

Active last 30 days

It is the metrics of the number of devices that at least have one session in the last 30 days 📅. Through these metrics, you can observe whether the app is doing well or it is in need of improvements.

Crashes

Crashes!!!! This metrics will show you how many times your app crashed on a user’s device 🤦 . However, this metrics can’t tell you where your app happened to crash in your code. That will be your job to do.

Conversion Rate

As mentioned earlier, the conversion rate is how many users downloaded your app after coming across your icon. It is the most powerful and useful metrics in-app analytics. It helps you understand that your app is able to attract users or not.

New User Per View by territory

Here the data is sorted according to territories. It shows us the users from different territories who came across our product page and downloaded the application. It helps you understand your geographical area of the target and make you understand if you have to make changes to attract a specific audience.

Blog in brief

  • Impression:- No. of times a user sees your app icon.
  • Product Page View:- User open your app description page.
  • App Unit:- User downloads your app.
  • In-app Purchase:- No. of in-app purchase made.
  • Sales :- App purchases + in-app purchases. Total revenue.
  • Paying users:- No. of users making a purchase
  • Installations:- User launches your app first time.
  • Sessions:- Every Time your app comes in the foreground for 2 or more than 2 seconds.
  • Active Devices:- Devices that have at least 1 session in a day.
  • Active last 30 days:- Device had at least 1 session in last 30 days.
  • Crashes:- Crashes faced by the user.
  • Conversion rate:- Ratio of app units to impressions.

SUMMING UP

So, the next step for you after developing and distributing your app on Appstore is to keep analyzing the app analytics provided by Apple itself to make your app popular. Who knows if one day you’ll be the owner of a powerful social media platform. Cheers to you for paying attention 🙇!!

appstore-analytics_image1


Farming of your IDEA

$
0
0

Overview

Here you can see the journey of IDEA (Requirement) to Mockup UX/UI Design (Process of UX/UI Design)

UX/UI Process is same as Farming Process

Farming_IDEA_image1

I will give you an example for UX/UI process of cryptocurrency wallet and for the farming process, an example is Rose Flower Farming

See the Suspense first

  • See the process of UX/UI with the Rose farming process
  • I gave an example of Rose farming because UX design (Features wise) is like the smell of a rose which is so aromatic and a UI design is more like a rose which is a beautiful flower.

“ Rose is a symbol of love make sure you will love the blog “

Farming_IDEA_image2

The journey from IDEA to Mockup UI design

Farming_IDEA_image3

Content Adaptation (Part 1- for iPhone)

$
0
0

Overview

As a developer, at some point in your work, you might have come across a strange maybe but a valid requirement. The client says I want “different layouts” for landscape and portrait 😟. He maybe valid at his perception but this gives you a burden. None of us like that. But it’s a pretty easy thing to do and here we’re going to learn how. It’s so easy that you won’t even have to write a line of code but do it just through interface builder. You’ll be surprised by how much power has the interface builder put in your hands.

Content Adaptation

Auto layout is a powerful tool when it comes to design. You can design for any particular device and by giving proper constraints you increase the design’s compatibility with other devices. But when it comes to having totally different layouts for device orientations, you got to work a little more to achieve desired results.
For understanding this concept of adaptive auto layout, it’s important for you to understand the size classes as you’ll be working around them to have adaptive layouts for orientations. Below you can see a chart where size classes are explained in brief.
Content_Adaptation_image1

So, you have to play around size classes. For orientation purpose you will be working with height, i.e. You’ll be varying your layout on varying height. If height is Regular(Portrait) we will make Layout1 and when height is Compact(Landscape) we will make Layout2. Keeping that in mind.

Note:- This adaptation won’t work on iPads as it has Regular height in both landscape and portrait mode 🤷‍♀️. You have to work around code for that. I’ll show you how in part 2 of this blog.

But before we move on to working through the storyboard, let me show you what we will be working for. Here’s a Slo-mo for the result we will be getting.

Content_Adaptation_image10

Impressive, eh?

Working On:-

  • Step 1:- Create a project. ✔️
  • Step 2:- Read on.

I created a project named BlogAdaptiveLayout. And I started working on the storyboard. I wanted to make an app with details about Harry Potter and his profile picture.

Things we are going to do.

  • Different layout design for different orientation
  • Varying fonts
  • Varying background image

Content_Adaptation_image16

Looks like a tone of work, but don’t worry, it’s pretty easy, like magic.

So far, I arranged all my components and gave them constraints. This is how it looks so far.

Content_Adaptation_image2

For those who don’t like the auto layout, this might look scary. Don’t worry, I’ll guide you through.
The constraints I’ve given so far are:

  • Background imageView with top Constraint from the safe area and all other from the superview.
  • Profile image:- Fixed height, width, and spacing from the top, Horizontally central aligned.
  • Name label:- Vertical spacing from profile image view and leading space to the container.
  • All other labels:- leading to label above it and vertical spacing of around 40 from the same.

So, we’re done with basic steps, easy, Right? Remember you have done all this for Regular height.

Now you’ll have to switch the orientation to landscape from the bar below. The reason is that we have created portrait design now we want for landscape or we can say we’ll work with compact height. Next step will be to click on Vary for Traits.

Content_Adaptation_image3

Select Height from the given two Options as we are working our way around the height. Everything we do for layout adaptation for orientation is based on height as height is the only size class that switches between regular to compact when going from portrait to landscape in all iPhones. If you try playing around width, it won’t switch to Regular in non-plus devices like SE, 6, 8 and even XS. Hope it’s pretty clear why height.

When you click on height, the bottom bar turns to a pretty shade of blue, like below.

Content_Adaptation_image7

As long as this bar is blue, you can know that every change you make now will reflect in this orientation or the landscape mode. If this bar is not blue, any changes you’ll do will even mess up your layout of portrait mode.

Changing background

Yes, you can have different images for imageView in a different orientation. So I added two images to my Assets Catalog named ”portrait” and “landscape”. While designing the portrait mode I gave it image as the “portrait”. If you simply change image name at this point then the image will change for both orientations. Then, what should you do? I’ll show you.

  • Select your imageView, go to the attributes inspector.
  • Click on the little plus near the image option.

Content_Adaptation_image13

    • Add variation keeping the height compact and width to any as we don’t care about width right now.

Note:- And if you try to give width then it will work for some device and won’t for some based on size classes.>

  • After you’ve added variation, it should look something like this

Content_Adaptation_image17

  • A small hC will appear near the text field. It means this variation is for Compact height.
  • Simply give the name of your image and Voila!! The image has changed. If you wish you can click on done variation and try switching to landscape and portrait mode and see the changes. But don’t forget to enter the blue thingy mode again by clicking Vary for Traits.

Changing Fonts

  • The process is pretty much similar. Just select all your labels. Go to the attributes inspector.
  • Click on the little plus besides font.
  • Add variation for compact height.

Content_Adaptation_image12

  • This is how it looks after selecting and entering fonts.
  • A small hC besides Font.

Content_Adaptation_image14

  • So for portrait, our fonts will be “Noteworthy” and for landscape, our fonts will be “Marker felt”.
  • You can change the color, size, background color.
  • You can change anything with a plus mark on its side in attributes inspector.

So after doing this easy but noticeable changes, this is how far we’ve come.

Content_Adaptation_image8

  • You can again check if it has worked by clicking done varying on the bottom blue bar.

Wouldn’t it be nice if we could get the profile picture on the left side and all details on the right side for landscape mode? Hang On.

Changing/ Uninstalling Constraints

  • So as per my new design, I’ll be deleting or technically uninstalling constraints.
  • I don’t need four constraints anymore, the center alignment of profile picture, leading constraint of the label to superview and vertical spacing between profile and label, the spacing of profile to superview.

Content_Adaptation_image11

  • Simply select the constraint and press backspace.
  • After uninstalling constraints, they’ll appear light in color

Content_Adaptation_image6

Note:- If you want to re-install constraint. Simply select the constraint and go to attribute inspector and select the variation you want to install constraint for.

Content_Adaptation_image4

  • Now simply add new constraints according to required layout.
  • Here’s what I’ve done
    • Give the profile image vertically aligned at center.
    • From profile’s trailing give 20 horizontal space to the first label.
    • Give any top constraint to the first name label.
    • To change the value of existing constraints, simply double click and change the value, rest will be handled by Xcode.
    • You can also change the value of existing constraints by selecting constraints and going to attribute inspector and follow the same process we did before.
  • Here’s the Result

Content_Adaptation_image15

  • Click on “Done Varying”. Switch, switch, switch the orientations, it works. 10 points to Gryffindor!!

Content_Adaptation_image18
PORTRAIT

Content_Adaptation_image19
LANDSCAPE

SUMMING UP

So, now you’ll be capable to do even complex designs, all you need is practice. Just be careful with those constraints. Just keep the above steps in mind and operate them on your designs or you can just flick and swish your wand, say a charm and it’s done. Come back for the next blog to learn how to make content adaptive for iPads. And most of all, thank you for your patience 🙏🏻.

Content_Adaptation_image9

If you have any query please feel free to reach out.

Content Adaptation (Part 2- for iPad)

$
0
0

Overview

In part 1 of this blog, we learned how easy it is to simply make your layout adaptive based on orientations. However, we came across some limitations. We were changing layout based on varying size classes but in iPad, the size classes don’t vary. They are Regular for both height and width. However, just like Ginny Weasley said, “Anything’s possible if you’ve got enough nerve”. So, we’re going to make our content adaptive for iPad as well.

Content_Adaptation_image2

In part 1 we performed everything without writing a single line of code but here we’ll have to write code. In fact, we’ll make content adaptation possible with code. But just writing the code won’t make it adaptive as well. You’ll have to perform steps of part 1 as well. So if you haven’t yet read part 1. Here it is

iPad Size Classes

For remembering the size classes for iPad, here’s a chart below.

Content_Adaptation_image1

At this point, I’ll assume you’ve read part 1. We want results such as the chart above, that if I change orientation the layout adapts according to it. So for iPhone, we make content adaptive on basis of compact and regular height but the iPad has only Regular type size classes so the variation can’t be applied as the size class never becomes compact and so the variation related to size class aren’t applied. So what will you do? We’ll make it compact. How? Read on.

UITraitCollection

o the trick here is to trick your iPad to follow size classes is to override UITraitCollection. I’m not going to discuss in-depth about UITraitCollection. But
UITraitCollection is a class that consists of traits such as horizontal size classes and vertical size classes. Also, it provides UIUserInterfaceIdiom that is enumeration for the type of interfaces such as iPad, iPhone, tv, etc. If you want to learn more about UITraitCollection that I suggest you do, Here’s the link to Apple Documentation

Override UITraitCollection

I’ll be making changes to the demo I made in part 1 called “Blog AdaptiveLayout”. I have changed a few constraints just to make it look proper in case of alignment.

Note:- It’s not at all necessary to change any constraints. The trick is to override UITraitCollection. You can change constraints as per your need

Code:- Simply Add below class in your project file and inherit in your view Controller or you can just copy the override code and paste it directly to your view controller.

public class CustomTraitCollectionViewControllerForiPad: UIViewController {
    override public var traitCollection: UITraitCollection {
        if UIDevice.current.userInterfaceIdiom == .pad {
            if UIDevice.current.orientation.isPortrait {
               return UITraitCollection(traitsFrom:[UITraitCollection(horizontalSizeClass: .compact), UITraitCollection(verticalSizeClass: .regular)])
            } else if UIDevice.current.orientation.isLandscape {
                 return UITraitCollection(traitsFrom:[UITraitCollection(horizontalSizeClass: .regular), UITraitCollection(verticalSizeClass: .compact)])
            }
        }
        return super.traitCollection
    }
}

After writing this code just switching the orientation on interface builder won’t work. You have to run your app in the simulator or a Device to check if it works, that I’m sure it definitely will.

Explanation:- So we override the traitCollection to make it work like we want to or in other words to customize the trait collection.

  • We checked if the interface is iPad.
  • If the orientation is .portrait, we
    • give horizontalSizeClass as .compact. (wC)
    • give verticalSizeClass as .regular. (hR)
  • If orientation is .landscape, we
    • give horizontalSizeClass as .regular (wR)
    • give verticalSizeClass as .compact. (hC)

You can assume that horizontalSizeClass refer to width and verticalSizeClass refer to height. That way it will be easy to know what to pass in the argument. Here we want our iPad’s size classes to behave like that of iPhone so we passed arguments based on that.

Note:- For your app to adapt layout, you will also have to apply the steps of Part 1 of this Blog. Without it, just the code won’t help. You can apply it before or after writing this code.

Here’s how it looks in our project.

Content_Adaptation_image3
PORTRAIT

Content_Adaptation_image6
LANDSCAPE

SUMMING UP

Now you can have a content adaptation in your iPad as well just by playing around UITraitCollection. Easy, Isn’t it? It’s good to have knowledge of what you’re playing around though. So I’ll recommend you to go through the apple documentation of UITraitCollection. Also, the code above can be modified according to your needs. For that, grab some knowledge related to your requirement as much as you can.

It was great to learn Content adaptation with you through this journey of two blogs. I hope I added something to your knowledge. Thank you for your patience. You can find more of our blogs here. Signing Off.

Content_Adaptation_image5

Firebase Remote Config

$
0
0

Overview

Thinking to have good control over your app even after the app is released into the wild? You have hit the correct link, my friend.
We always want to keep our users more engaged with our app as possible. As a user, I’ll probably not stick around with an app that is the same as it was a year ago. Providing regular updates play a major role here. But re-configuring/re-designing an app at regular intervals can be too costly. Google’s Firebase to the rescue!
For those who are not familiar with Firebase, it is a platform for mobile app teams to develop, grow and sustain in the app-world. It has all the app-tools that one can think of. From analytics to A/B testing for app search optimization, they have got it all. The tool that’ll be useful to solve our issue is Remote Config.

What is Remote Config?

Remote config can be thought of an API or cloud service that provides the app with dynamic parameters based on which the app can be configured. Speaking practically, suppose an app has a red theme and we need to change the theme to blue without re-developing it. To achieve this, we’ll define a parameter for the theme in remote config console, the app will fetch the parameter from the console when it is launched and if programmed correctly, it’ll change its theme in runtime based on the value of parameter received. This will make the app-theme completely dynamic as we have control over the parameter.
This is just one simple use case of remote config. It can be used in million other ways, depending on app requirements. Let me elaborate it with a practical approach. I’ll demonstrate a scenario wherein a user needs to forcefully update the android app if an update is available.

Practical

Create a project and add firebase support into it. As I don’t wish to get into details to make this post longer, you can refer this link for it.

To add remote config into the app, add following line in app’s gradle file.

implementation 'com.google.firebase:firebase-config:16.1.2'

As app updates are controlled by version number, the dynamic parameter for this demo is the app version. Let’s define it in the firebase console.

  1. Go to remote config section in firebase console and click on Add your first parameter.

firebase-remote-config-image3

  1. Define name of your parameter and its value. In my case, I have app_version and 1.0 respectively.

firebase-remote-config-image6

  1. Don’t forget to publish the changes.

firebase-remote-config-image4

Now, we need to fetch the parameter value in the app. A good place to write this code will be Application class as it executed in the very beginning when the app gets launched.
Add following code in application class’ onCreate( ) method

class BaseApp : Application() {
    override fun onCreate() {
        super.onCreate()

        val remoteConfig = FirebaseRemoteConfig.getInstance()

        val remoteConfigMap = mutableMapOf<String, String>()
        remoteConfigMap[parameterKey] = getCurrentAppVersion(this)

        remoteConfig.setDefaults(remoteConfigMap as Map<String, Any>?)
        remoteConfig.fetch()
                .addOnCompleteListener { task ->
                    if (task.isSuccessful)
                        remoteConfig.activateFetched()
                }
    }

    companion object {
        val parameterKey = "app_version"
        fun getCurrentAppVersion(context: Context): String {
            try {
                return context.packageManager.getPackageInfo(context.packageName, 0).versionName
            } catch (e: PackageManager.NameNotFoundException) {
                e.printStackTrace()
            }
            return ""
        }
    }
}

The above code basically fetches parameter from remote config and stores its value with the key that is set in FirebaseRemoteConfig object. Remember, the key should match with the parameter name defined in remote config (here, app_version)

We need to compare the fetched value with the current app version of the app. The code for it is written in launcher activity of the app (shown below). If the fetched value of version and the current version are not the same, it implies that the app-update is available and we should take actions accordingly, redirecting the user to play store, for instance.

class MainActivity : AppCompatActivity() {

   private lateinit var currentAppVersion: String
   private lateinit var playStoreAppVersion: String

   override fun onCreate(savedInstanceState: Bundle?) {
       super.onCreate(savedInstanceState)
       setContentView(R.layout.activity_main)

       currentAppVersion = BaseApp.getCurrentAppVersion(this)
       playStoreAppVersion = FirebaseRemoteConfig.getInstance().getString(BaseApp.parameterKey)

       tvVersion.text = "v: $currentAppVersion"

       if (isUpdateAvailable()) {
           //stuff for redirecting user to play store

           val alertDialog = AlertDialog.Builder(this).setTitle("App update is available v: $playStoreAppVersion")
                   .setCancelable(false)
                   .setNegativeButton("Ok") { p0, p1 -> finish() }.create()
           alertDialog.show()
       }
   }

   private fun isUpdateAvailable(): Boolean {
       return !playStoreAppVersion.equals(currentAppVersion, true)
   }
}

Here, an alert dialog will be shown, if the app update is available.
It may be stating the obvious, but we need to edit the parameter value in remote config after we release the app update and change it to latest app version.
That’s it. It’s a doddle, isn’t it? 😀

firebase-remote-config-image2

Credits: medium.com

The gif below shows the complete process on the user’s side: the app that is up-to-date and the app after the value of the parameter is changed.

Please note: Here, I have cleared app’s data to have immediate parameter-change effects. The effects can be achieved normally but it might take a while.

Conclusion

This feature of firebase can be very handy when it comes to dynamic apps. We can have apps that change their appearance, their features, and the UX over time. This is a strong weapon to grow and retain the user base of our apps.

Introduction to P5.js

$
0
0

Overview

  • p5.js is a JavaScript library that starts processing to make coding accessible for artists, designers, and beginners for today’s web.
  • p5.js is a full set of drawing object functionality. However, you’re not limited to your drawing canvas, for this, p5.js has an add-on library that makes it easy to interact with other HTML5 objects.
  • p5.js programs generally run in any browser. JavaScript interpreters are open-source and freely available and anyone can use it for free.

Get Started

  • There are mainly two functions we will use in program.
  • setup( ) and draw ( ), they are basically already in sketch.js file.
  • The setup() block runs for creating a program that does not need a loop running code repeatedly. The draw() block runs repeatedly, and is used for animation or create the Shape, Objects, Drawing, etc…

Benefits

  • P5.js is a full conversing Processing into javascript code and all the functions will be translated, and you’ll be writing in JavaScript.
  • You write javascript code directly, and it performs code like any other javascript file you include on your website.
  • P5 can be extended with add-on libraries.

Example

Step:1

  • Draw triangle is a plane created by connecting three points (X,Y,Z).
  • First Point Specify Two Arguments (x1,y1), Second Point Specify Two Arguments (x2,y2), Third Point Specify Two Arguments (x3,y3).
  • Another Point (tx, ty) is the translation point that translates the object.

Syntax: triangle(x1, y1, x2, y2, x3, y3);

triangle.js

// Define Attribute
class Triangle{
	constructor(x1_, y1_, x2_, y2_, x3_, y3_, clr_, tx_, ty_, rot_){
		this.x1 = x1_;
		this.y1 = y1_;
		this.x2 = x2_;
		this.y2 = y2_;
		this.x3 = x3_;
		this.y3 = y3_;
		this.clr = clr_;
		this.tx = tx_;
		this.ty = ty_;
		this.rot = rot_;
	}

// Display Triangle
display(){
push();
translate(this.tx, this.ty);
fill(this.clr);
rotate(this.rot);
triangle(this.x1, this.y1, this.x2, this.y2, this.x3, this.y3);
pop();
}
}

index.html

// link triangle.js file in html code

var mycolor;
var t = [];

function setup() {
createCanvas(windowWidth, windowHeight);
background(234, 226, 228);

let clr = color('rgba(20, 159, 132, 255)');
t[0] = new Triangle(-50,40,50,40,0,-40,clr,210,120, 0);

clr = color(39, 184, 153);
t[1] = new Triangle(-50,40,50,40,0,-40,clr,210,210, 180);

}

function draw() {
noStroke();
angleMode(DEGREES);

translate (width / 3, height / 3);
	for(let i = 0; i < 2; i++){
	t[i].display();
	}
}

p5_js_image1

Step:2

  • Display new object with triangle shape by using class, variable, function.

p5_js_image2

Step:3

  • Add animation effect by using mousePressed(), mouseDragged, mouseReleased() functions.

Video:

Demo Link: Click here

Conclusion

I hope this blog might help you to understand the few functions of p5.js. We would dig into other functions & bring light on it in later blogs. I would like to thank Sudev Kiyada for being so supportive to complete this blog.

Viewing all 595 articles
Browse latest View live