Custom Picker

screenCustom Picker is an easy to use and customizable alternate to UIPickerView. It is written in Swift language. The Custom Picker started as normal UIPicker but it was to limited in its design and methods. Also, I want to achieve a flat-picker with selected area background customizable which was not possible with default UIPicker.

So I made a use UITableView and customize its scroll to get the look and feel of UIPickerView. With the use of UITableView, I have made the picker flat. Now the second limitation of UIPickerView i.e. non-customizable selected area, for this I used an overlay view and customize it according to my need.

Requirements

It requires Xcode 7.0+ and Swift 2.3.

Application Usage

Custom Picker includes a sample of the project of Unit Conversion where a user can select the to and from units and input the number in one UITextField and the output will be shown in other UITextField.

Create a new picker

To use this picker you have to instantiate the CutomPickerView like instantiate any normal UIPickerView and implements it CustomPickerViewDelegate and CustomPickerViewDataSource methods

    let leftPickerView = CustomPickerView(frame: CGRectMake(0.0, 0.0, self.contentViewOfLeftpicker.frame.width,  self.contentViewOfLeftpicker.frame.height))

    leftPickerView.delegate = self
    leftPickerView.dataSource = self

    self.contentViewOfLeftpicker!.addSubview(leftPickerView)

Implement the Delegate and DataSource

The delegate methods that needs to be overridden are

func customPickerView(customPickerView: CustomPickerView, titleForRow row: Int, forLabel label: UILabel) -> String

 func customPickerView(customPickerView: CustomPickerView, didSelectRow row: Int)

func rowHeightForCustomPickerView(customPickerView: CustomPickerView) -> CGFloat

func labelStyleForCustomPickerView(customPickerView: CustomPickerView, forLabel label: UILabel)

func imageStyleForCustomPickerView(customPickerView: CustomPickerView, forImageView imageView: UIImageView)

Firstly you must rowHeightForCustomPickerView(_:)

func rowHeightForCustomPickerView(customPickerView: CustomPickerView) -> CGFloat {
        return 50.0
    }

Then you have to implement titleForRow method it sets the title for each row in a picker

func customPickerView(customPickerView: CustomPickerView, titleForRow row: Int, forLabel label: UILabel) -> String {

        return (label.tag == -1) ? pickerDataFullForm[row] as! String : pickerDataShortForm[row] as! String
    }

Next is the method that provides the didSelectRow

func customPickerView(customPickerView: CustomPickerView, didSelectRow row: Int) {

        leftPickerView.labelUnitFull.text = pickerDataFullForm[row] as? String
        leftPickerView.labelUnitShort.text = pickerDataShortForm[row] as? String

    }

Next method is labelStyleForCustomPickerView method this method is used to give custom style to UILabel in CustomPickerView

func labelStyleForCustomPickerView(customPickerView: CustomPickerView, forLabel label: UILabel) {
        if (label.tag == -1) {

            label.textColor = UIColor.blackColor()
            label.font = UIFont(name: "HelveticaNeue-Bold", size: 20.0)
        }else{

            label.textColor = UIColor.lightGrayColor()
            label.font = UIFont(name: "HelveticaNeue-Bold", size: 15.0)
        }
    }

And the last delegate method is imageStyleForCustomPickerView this is used to give any background image to the overlay view.

    func imageStyleForCustomPickerView(customPickerView: CustomPickerView, forImageView imageView: UIImageView) {
        if customPickerView == leftPickerView {
            leftPickerView.arrowImage.image = UIImage(named: "LeftArrow")
        }
    }

CustomPickerViewDataSource

The CustomPickerView consists of only one data source method. This method returns the number of rows in that picker:

 func numberOfRowsInCustomPickerView(customPickerView: CustomPickerView) -> Int

Using Testfairy for an Android App

TestFairy is a beta testing platform for mobile apps allowing developers to see videos showing users behavior. It allows Android apps as well as iOS apps.

This includes App Distribution, Video Recording, Logs, Crash Reports, User feedback on shake, Community Pages. It gives 2 months free trial.

After that, you have to choose the plan, according to the plan they will provide the features. In basic plan, they have given, App Distribution and Crash Reports features.

Also, they have provided the SDKs for Android and iOS as well. You can refer this link for Testfairy SDK implementation in Android and this link for Testfairy SDK implementation in iOS.

For developer level testing you can use Genymotion and for tester level testing you can use Testfairy.

Using Genymotion in Android

Let’s get familiar with Genymotion.

Genymotion is the most powerful Android emulator for app developers & testers.

Developers can install the plugin of Genymotion in Android Studio plugin with few simple steps:

  1. Click File–> Settings
  2. Click on Plugins tabs left side on Settings window.
    settings
  3. Click Browse Repositories and search for Genymotion.
    genymotion_plugin
    On the right side of Browse Repositories pop up, there will be a button with name “Install”.
  4. Click on install button.
  5. Restart your Android Studio IDE. Now you can see, Genymotion is installed in Android studio.


How to use the Genymotion for the app?

  • After installation of Genymotion plugin, there will be a phone like an icon on the toolbar of Android Studio.
  • After clicking that icon Genymotion Device Manager will open, where you can see the list of available Genymotion virtual devices.
  • Select one of them or you can create the virtual device by clicking on New button.
  • Creating new virtual device will show a popup shown below,virtual_device_creation_wizard
    Where you have options to choose Android versions and Device model after that click on Next button.

    • You can choose the name for the virtual device shown as below,virtual_device_name
    • Click Next and download and install will start for the virtual device.That’s all. Now you can click on start button to start Genymotion virtual device.Now you can run your App on this device. Just hit Run button on your Android Studio’s toolbar, choose your virtual device from Available Virtual Devices and it will run your project on it.
    • To avoid the issues in your android app you can follow Do’s and Don’ts for Android this blog.

Do’s and Don’ts for Android Apps

There are few things most of the new android developers face. To avoid these issues while developing one should be following best practices to improve the functionality of the android app and to attain optimum results.

Do’s  for Android App Development

  • Prefer ConstraintLayout while making designs in xml file of android. It is more flexible. If necessary, look for others.
  • Give meaningful id name for each view in xml. For example, If you are using EditText for username and password then their names should be editTextUsername and editTextPassword.
  • If any group of views is repeatable in more than one xml file, make a different file with that group of views and include it where you want. Eg. <include layout=“@layout/toolbar”/> : toolbar is a different layout which has the design for common toolbar used in the app.
  • Write all the texts, used in the app, in string.xml file and give reference of that string in layout xml file. Also, all the messages should be defined in string.xml file. Later on, it will be easier to modify it.
  • Write all the dimensions, used in the app, in dimen.xml file and give reference of that dimensions in layout xml file.
  • Write all the colors, used in the app, in color.xml file and give reference of that color in layout xml file.
  • Try using style.xml file for custom view design instead of doing it programmatically.
  • All constants should be declared in separate java file say, Constants.java, Each constant should be static(it will allocate memory only one time and can be reusable) and final(not changeable).
  • Define all commonly used methods in one class say, Utils.java.
  • If code lines are exceeding 15-20 lines, put the code in a method.
  • The naming of variables, objects, methods, classes, interfaces, etc should be self-explanatory.
  • It’s better to write a separate class for any reusable functionality.
  • Project code should be divided into different modules. According to the module, you can put the java files in different packages under the main package.
  • The module can be Login, DrawerItems (if an app has the drawer, list out all the main files of drawer items), etc.. and it will depend on the project’s features.
  • Use fragment, if you want to show more than one screen in single Activity. A fragment is nothing but the part, part of design. It is totally dependent on Activity.
  • Interfaces can be used to pass the data of one class to other class(it can be Activity, Fragment, Service, or simple Java class) on any triggered event.
  • Service: It is used as a background task. Eg. To do network call, to play music in the background, etc.
  • Use Glide/Picasso library to load image URLs.
  • Use Retrofit library to make network calls. See this blog how to use it in android.
  • Use GreenDAO library to do local database transactions.
  • Use Genymotion virtual device to run the android app.
  • You can use Testfairy to distribute your android app remotely.

 

Similarly, you should know what are bad practices in android development, what to avoid while developing an android app. Below are some points developers should avoid.

Don’ts for Android App Development

  • Try to avoid using Relative layout, if it is not necessary.
  • Avoid using nested Linear layout it affects the UI performance.
  • Never use ‘my’ prefix in naming conventions. Also never use shortcut names. Eg tvNm, etPwd, etc.
  • Your code length for a class should not exceed 1000 lines. If possible try to add a supporting class.
  • Avoid using hard-coded values in Activity/Fragment as much as possible.
  • Avoid using libraries as a project module, instead, add dependencies in build.gradle file of app Module of the project.
  • Don’t use too many libraries.

iOS App Development trends in 2017

Apple has earned an income of $ 1.8 billion just in the applications and in-application buys over the New Year’s time of 2016. Apple App Store has alone assembled an income of $ 40 billion for the developers. This itself discusses the huge development that App Store has found in every one of these years furthermore for the developers.

Due to constant arrival of new gadgets and devices with varied features, the application engineers must be constantly on board updating as well as overhauled on learning in view of the latest patterns in versatile application advancement, for an increase in improvement in the zone of iOS application development.

Mentioned below are some of these iOS app development trends:

Swift Coding

Swift has picked up fame among the application developers for its comprehensive scope of systems and coding techniques. It deals with present day compiler foundation that empowers to compose solid codes utilizing Xcode instruments. As such, Apple’s Swift Programming has increased over Objective-C. Be that as it may, as Apple’s Swift went open source in 2015, there is an expanding number of clients embracing to Swift and this has surpassed the volume of clients for Objective-C.

There are many points of interest in Swift Programming, friendly codes and ease of learning as well as a lot of scopes to build, improvement, adapt and usability. 2017 will be a year which will see a select use of Swift 3.0, helping in the improvement of applications on iOS, watchOS, and tvOS. Swift will rise as the essential apparatus for creating Apple applications by supplanting Objective-C.

Applications driven by GPS and Augmented Reality

The little and the medium endeavors are progressively embracing area based versatile application improvement. This is advantageous in furnishing shoppers with data on items or administrations, surveys, examination of costs and a great deal more such exercises for versatile business.

GPS as a driver for portable application advancement was seen as the accomplishment of Pokemon Go in 2016. Be that as it may, we see a greater amount of these GPS-empowered applications in retail and robotization. The iOS application developers in 2017 and the years past will utilize a blend of AR and GPS.

Other application regions, for example, 3D Games will likewise observe the developers investigating the progressions on GPS innovation. As the clients open up to area based administrations, the fundamental sympathy toward the iOS application improvement is security,

Applications focussed on IoT

The quality of developers for IoT-based applications ascended by 34 % in 2016. We have seen an expanded income on the endeavors construct just with respect to IoT. The iOS application developers will attempt to exploit the market in light of Internet-empowered gadgets. The versatile application advancement on iOS will make esteem included applications for most extreme usage of the IoT items.

The concentration zones for iOS engineers in 2017 are the acknowledgment of signs from sensors in the IoT gadgets and in addition a safe trade of data over the Wi-Fi systems.

Security

iOS has picked up significance on account of its thoughtfulness regarding protection and security. Portable information security has grown up to a remarkable level, bringing on a range of sympathy toward the innovation goliaths. Apple has effectively stepped forward in the correct bearing as App Transport Security (ATS), which is to be made obligatory for the iOS applications. We will see more creative and more grounded information encryption innovations in 2017 and genuine endeavors are put into this range by the iOS application developers.

Undertaking Apps in light of iOS

There is a surge in big business portable application advancement and this is reliant on two components, constant client cooperation and engagement and progressively overseeing information and assignments.

There are numerous open doors that manifest for the iOS application developers in creating venture applications. Venture applications are getting based on CRM of the association, utilizing nimble approach.

There will be a mix of huge information, IoT and endeavor portable application advancement that will be progressively utilized for iOS application improvement.

The volume fight is constantly won by Android as there is a higher number of Android-based gadgets yet iOS dependably wins the race for acquiring more prominent income. In this way, income turns into a noteworthy motivator for iOS application improvement.

QICE is a leading mobile app development company in India helping clients to increase their business visibility over the mobile. In today’s technological world it is imperative that each company owns a mobile app. Nevertheless, just owning a mobile app of your company promoting your business won’t do wonders for your business.

It needs proper assessment,  designing, development, testing, and marketing. We are there to bring into being the mobile app that suits specific business needs.We have the expertise and the skills in developing the application for various platforms like iPhone, iPad, and Android.

Deploying with Deploybot

I vividly remember the first time, I messed up a production server. It was my early days of being a programmer, and we had got our first client.

Back then, my deployment strategy was basically to upload files using FTP and then run any commands on the server via the shell. During a routine deployment, I noticed a file which remained in the server, and in trying to remove it, I typed sudo rm -rf /.

On the Production.

I watched the next few minutes in horror as the entire client’s machine was wiped clean and the site went down. Fortunately, my client was understanding, and we had backups – so there was not much of damage – but I had to spend the next 3 days fixing the mess (and contemplating if I am really cut out for this job.)

My biggest learning from the incident was to be very careful when on Production. Over the time, I learned Git and other tools, which made deployments more easier and safer. As someone developing in Laravel, and leading a team of Laravel developers – I am always on the look out to make deployments easier.

And I have tried everything from custom bash scripts to git workflows, where we would git pull on server. None of them however stuck primarily due to the complexities they bought in

And after much experimentation – my team and I zeroed down to DeployBot.

DeployBot allows you to deploy code from anywhere. It takes your code from your Github / Bitbucket or self hosted Git repositories and deploys to any server. At QICE, we primarily use Digital Ocean and AWS – both of which are supported by DeployBot and make it an ease to integrate in our projects.

Here’s how DeployBot has helped us

Continuous Deployment

Over the day, we make 2-3 deployments to our sandboxes on certain projects. And these are fairly large commits. DeployBot seamlessly gets the new commits and automatically ( or manual for production setups ) deploys the latest files to the server.

My team now does not have to worry about deploying to server. All we have to do is push to a branch, and we know it will end up being on the server.

Rollbacks

Despite much preparation, there are moments, when things don’t work on the production for weird reasons. Deploybot has a rollback to a specific version feature, which is quite nifty at times like these.

Pre and Post Deployment Commands

After deployment, we run a few commands ex : Gulp, Migrations and Composer updates.

Deploybot allows us to specify what commands to run before and after deployment. That means, more developer peace and not worrying about switching to server and typing in each command on production machines.

Modifying Configuration Files

Even after all this, you may have to sometimes go to the server to edit your configuration files.

Deploybot eliminates this as well, by asking you to enter your configuration files. Just ensure all the changes are in your configuration file before you deploy, and they are deployed in your next deployment.

Notifications

Pretty much every web app these days has Slack / Email integration – and so does Deploybot. It notifies us everytime there is a deployment in our Slack channels.

No more informing the entire team that the production is done and they can resume their work.

Amazing Support & Reliability

This is something of importance to us. In the past one year, that we used Deploybot, we faced a downtime of exactly 1 minute, where we couldn’t deploy to production. We reached out to Support and got a reply back within the next minute telling us that the issue has been fixed.

Thanks to Deploybot, my team and I can now focus on building stuff than worrying about getting it to our customers. If you are into developing web apps, it is an invaluable part of your toolset and takes care of all your deployment worries.