Swipe gestures in a UITableView

When we have a UITableView, sometimes we want to add some actions when the user swipes over a row of the table. We can capture swipes to the left, right, down or up directions.
To capture both left and right swipe gestures, add the following code to your UITableViewController in the viewDidLoad method.

UISwipeGestureRecognizer *gestureLeft = [[UISwipeGestureRecognizer alloc] 
     initWithTarget:self 
     action:@selector(handleSwipeLeft:)];
[gestureLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[self.tableView addGestureRecognizer:gestureLeft];
    
UISwipeGestureRecognizer *gestureRight = [[UISwipeGestureRecognizer alloc] 
     initWithTarget:self 
     action:@selector(handleSwipeRight:)];
[gestureRight setDelegate:self];
[gestureRight setDirection:UISwipeGestureRecognizerDirectionRight];
[self.tableView addGestureRecognizer:gestureRight];

The action parameter indicates the method that will be executed when the gesture is recognized. We have to include these methods in our controller too.


- (void)handleSwipeLeft:(UISwipeGestureRecognizer *)gestureRecognizer
{
    CGPoint point = [gestureRecognizer locationInView:self.tableView];
    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:point];
    
    // Action...
}

- (void)handleSwipeRight:(UISwipeGestureRecognizer *)gestureRecognizer
{
    CGPoint point = [gestureRecognizer locationInView:self.tableView];
    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:point];
    
    // Action...
}

The method locationInView returns the location of the gesture, represented as a point in the local coordinate system of the view. Using the indexPathForRowAtPoint method of the UITableView object, we can obtain the row of the gesture.

We could use also the same action method to handle all the swipe gestures. Change the action methods from handleSwipeLeft and handleSwipeRight to handleSwipe, and add the following method instead.

- (void)handleSwipe:(UISwipeGestureRecognizer *)gestureRecognizer
{
    CGPoint point = [gestureRecognizer locationInView:self.tableView];
    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:point];

    switch ([gestureRecognizer direction]) {
        case UISwipeGestureRecognizerDirectionLeft:
            // Action
            break;
        case UISwipeGestureRecognizerDirectionRight:
            // Action
            break;
        default:
            break;
    }
}
Share Button

Read More

Location Manager in iOS 8

The Core Location service in iOS 8 includes now two different modes of authorization: While Using the App and Always.

Location permissions

In our code application we must request the user to accept one of these modes.

  • When In Use. This mode allows your app to use the location services when the app is in the foreground.
    if([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
       [self.locationManager requestWhenInUseAuthorization];
    
  • Always. This mode allows your app to use the location services when the app is in the foreground and in the background.
    if([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
       [self.locationManager requestAlwaysAuthorization];
    

Finally, we have to add in the Info.plist file of our app the values for the keys NSLocationWhenInUseUsageDescription or/and NSLocationAlwaysUsageDescription. These values contain the messages that will be displayed to the user when requesting the authorization.

info.plist properties

Share Button

Read More

Security in Cloud Computing: a Mapping Study

I have a new article published. For my PhD I write scientific articles that are submitted to scientific journals or conferences. This article is in English and it is published in Computer Science and Information Systems. The Computer Science and Information Systems journal is indexed in the Journal Citation Reports (JCR) and it has a two year impact factor of 0.575 (2013).

ComSIS publishes original papers of lasting value covering both theoretical foundations of computer science and commercial, industrial, or educational aspects that provide new insights into design and implementation of software and information systems.

Here is the reference and the link to my article:

Zapata, B. C., Fernández-Alemán, J. L., Toval, A.: Security in Cloud Computing: a Mapping Study. Computer Science and Information Systems, Vol. 12, No. 1, 161–184. (2015)

The abstract of the article:

JMS

A number of cloud applications are currently widely used. However, one of the main reasons for the slowing down in the growth of cloud computing is that of security. Even though some research has been done in the security field, it is necessary to assess the current state of research and practice. This paper aims for the study of the existing research about security in cloud computing to analyze the state of art and to identify future directions. The method selected to investigate the security in cloud computing is a systematic mapping study. A total of 344 papers were selected and classified by security goal, research type and contribution type. The main security specific issues extracted are data protection (30.29%), access management (20.14%), software isolation (16.7%), availability (16%), trust (13.6%) and governance (3.27%). Our results demonstrate that cloud computing seems to be a promising area for security research and evaluation.

Share Button

Read More

Android Studio Essentials

Android Studio Essentials is my third book that has been recently published by Packt Publishing here. You can get it also from Amazon here. This book is an update of my previous book “Android Studio Application Development”.

Android Studio Essentials coverAndroid Studio Essentials back

Android Studio is an IDE that is based on the JetBrains IntelliJ IDEA. It gives developers a unique platform to develop and debug Android apps using various developer tools. It has a wide array of features such as live layout facility, Gradle build support, and template-based wizards, which makes it a preferred choice for developers.

Starting off with the basic installation and configuration of Android Studio, this book aids you in building a new project by helping you to create a custom launcher icon and guiding you to choose your activity. You then gain an insight on the additional tools provided in Android Studio, namely the Software Development Kit (SDK) Manager, Android Virtual Device (AVD) Manager, and Javadoc.

Finally, it helps you to familiarize yourself with the Help section in Android Studio that enables you to search for the help you might require in different scenarios.

Share Button

Read More

Empirical Studies on Usability of mHealth Apps: A Systematic Literature Review

My fourth accepted article has just been published. For my PhD I write scientific articles that are submitted to scientific journals or conferences. This article is in English and it is published in the Journal of Medical Systems. The Journal of Medical Systems is indexed in the Journal Citation Reports (JCR) and its current impact factor is 1.372.

The Journal of Medical Systems provides a forum for the presentation and discussion of the increasingly extensive applications of new information systems techniques and methods across all health care settings. It features four sections focusing on mobile systems, systems level quality improvement, transaction processing systems, and patient facing systems.

Here is the reference and the link to my article:

Zapata BC, Fernández-Alemán JL, Idri A, Toval A. (2015) Empirical Studies on Usability of mHealth Apps: A Systematic Literature Review. J Med Syst 39(2). doi: 10.1007/s10916-014-0182-2

The abstract of the article:

JMS

The release of smartphones and tablets, which offer more advanced communication and computing capabilities, has led to the strong emergence of mHealth on the market. mHealth systems are being used to improve patients’ lives and their health, in addition to facilitating communication between doctors and patients. Researchers are now proposing mHealth applications for many health conditions such as dementia, autism, dysarthria, Parkinson’s disease, and so on. Usability becomes a key factor in the adoption of these applications, which are often used by people who have problems when using mobile devices and who have a limited experience of technology. The aim of this paper is to investigate the empirical usability evaluation processes described in a total of 22 selected studies related to mHealth applications by means of a Systematic Literature Review. Our results show that the empirical evaluation methods employed as regards usability could be improved by the adoption of automated mechanisms. The evaluation processes should also be revised to combine more than one method. This paper will help researchers and developers to create more usable applications. Our study demonstrates the importance of adapting health applications to users’ need.

Share Button

Read More

Create a git repository from an existing XCode project

The following steps can be followed to create a Git repository from an existing XCode project.

  1. Open the terminal and navigate to the directory containing your XCode project.
  2. Execute the following commands to create a local Git repository:
    > git init
    > git add .
  3. Open your project using XCode.
  4. Navigate to the menu “Source control” > “your project” > “Configure”.
  5.  Open the “Remotes” tab as shown in the following screenshot.
    git step 3
  6. Click on the + button.
  7. Add the remote repository indicating its remote address.
    git step 4
    git step 4 b
  8. Now that the remote repository has been configured, we can commit the project. Navigate to “Source control” > “Commit”. You can check the “Push to remote” option or we can do it in two different steps. Click on the Commit button.
    git step 5
  9. Push the local commit to the remote repository. Navigate to “Source control” > “Push”.
    git step 6
    git step 6 b
Share Button

Read More

This is my mother’s smartphone

Similarly to my old post: This is my Smartphone, now I want to show my mother’s smartphone.
The reason why I’m writing this post is because my mother isn’t very familiar with computers or technology in general, even less with smartphones. Using her previous phone, not a smartphone, she started having problems with reading the small screen and the small text sizes. Even so, she didn’t want to change her phone for a touchscreen smartphone, simply because smartphones seemed very difficult to understand for her.
I decided to configure my old smartphone adapting it to her and finally I persuaded her.

The device

The device is a Sony Ericsson Xperia arc S. This smartphone was released in 2011 but my mother’s one was bought in 2012. I want to convince her to buy a newer one, although the Xperia arc S works very well. The Android version of the device is 4.0.3.
Xperia arc S

The launcher

Android allows a large degree of customization. Launchers can serve different purposes, for example the launchers intended for older people, which provide an easier interface for novice users. My mother’s smartphone uses the launcher known as Wiser – Simple Launcher. This launcher is free, colorful, with big buttons, big text sizes and very easy to use.
Android app on Google Play
The home screen shows the main applications. The disadvantage is that you can’t change these main applications, they are fixed. The second screen (to the right) contains the favorite contacts and on the third screen, more applications are listed. You can configure the applications that are listed on the third screen.

Wiser homeWiser phone

The keyboard

Keyboards in Android can also be customized. My first idea was to change the default colors of the keyboard, so the letters had a strong contrast with that of the background. But that wasn’t enough, my mother needed bigger buttons. Finally I installed the Big Buttons Keyboard.
Android app on Google Play
The letters of this keyboard are not displayed like in a standard keyboard, but that’s ok for my mother, since she isn’t used to a qwerty keyboard anyway.
Big keyboard

Share Button

Read More

Assessing the Privacy Policies in Mobile Personal Health Records

My third accepted article was already published. For my PhD I write scientific articles that are submitted to scientific journals or conferences. This article is in English and it has been presented in the 36th IEEE Engineering in Medicine and Biology Society Conference, held in Chicago, USA.

The theme of the IEEE Engineering in Medicine and Biology Society Conference is “Discovering, Innovating, and Engineering Future Biomedicine”. It covers diverse topics from cutting-edge biomedical and healthcare technology research and development, clinical applications, to biomedical education.

Here is the reference and the link to my article:

Zapata BC, Niñirola AH, et al. (2014) Assessing the Privacy Policies in Mobile Personal Health Records. IEEE Engineering in Medicine and Biology Society Conference.

The abstract of the article:

EMBC

The huge increase in the number and use of smartphones and tablets has led health service providers to take an interest in mHealth. Popular mobile app markets like Apple App Store or Google Play contain thousands of health applications. Although mobile personal health records (mPHRs) have a number of benefits, important challenges appear in the form of adoption barriers. Security and privacy have been identified as part of these barriers and should be addressed. This paper analyzes and assesses a total of 24 free mPHRs for Android and iOS. Characteristics regarding privacy and security were extracted from the HIPAA. The results show important differences in both the mPHRs and the characteristics analyzed. A questionnaire containing six questions concerning privacy policies was defined. Our questionnaire may assist developers and stakeholders to evaluate the security and privacy of their mPHRs.

Share Button

Read More

Giveaway Winners: Free copy of new book on Android Studio

The giveaway that was published here has ended. The winners were generated automatically and they will be contacted to let them know about it.

Winners:
Angel (entry #53)
Paul (entry #106)
Victor (entry #41)

I used an external tool, PromoSimple (promosimple.com) to register the entrants and their number of entries. The following screenshot shows the Manage Winners page in which you can generate a winner for each prize.

Manage winners

To generate a random number, you can use the external site of Random.org or the PromoSimple generator.

Generate winners randomly

Thanks to everyone who participated and shared it!

You can still buy it at several sites:

Testing and Securing Android Studio Applications cover

Share Button

Read More

My new destination: San Francisco

After spending the last 10 months living in Rabat (Morocco), in a few weeks I’m starting a new project. My new destination is San Francisco, California, US.
I’m going to start working at SWARM mobile: http://www.swarm-mobile.com/. As described in Swarm webpage,

Swarm is committed to helping small business retailers understand their businesses and customers better. Our family of smart retail devices, coupled with advanced retail analytics and a comprehensive retail management platform, can help retailers increase sales through superior insights.

This opportunity is thanks to the Jóvenes con Futuro program: http://www.stepone.com/jovenes/about-the-program/.

The goal of the program is to match the brightest technical minds in Spain and arrange placement with companies in the San Francisco Bay Area and New York City.

 
I’m very excited about this new project. I expect to learn a lot and from the best.

Swarm
JCF
Share Button

Read More