Making use of keyboard inputs is fundamental to providing an excellent user experience. You’ll learn how to use Android with keyboard inputs, keyboard method actions, autocomplete suggestions, soft keyboards, and support hardware keyboards.
At the core of every great Android application is a seamless user experience. In this course, Android Keyboard Inputs: Getting Started, you will learn how to master the core concepts related to the Android SoftKeyboard, in addition to supporting hardware keyboards. First, you will take a close look at keyboard input types such as number pads. Then, you will manage the soft keyboard, keyboard method actions, and autocomplete suggestions. Finally, you will see how to support hardware keyboards for navigation. When you’re finished with this course, you will have a foundational knowledge on capturing inputs that will help you as you develop mobile applications.
Course Overview Hi, my name is Mitch Tabian, and welcome to my course, Android Keyboard Inputs: Getting Started. I'm a self-employed Android developer and I'm here to teach you about keyboard inputs with Android. Making use of keyboard inputs is absolutely fundamental to providing a seamless user experience. Keyboard inputs refers to a wide array of functionalities built around the soft keyboard and connecting an external keyboard. All applications require user input. Some require passwords, phone numbers, emails, location information, and many others. Using keyboard inputs, we can customize how that information is captured and how the user interacts with your application to retrieve it. Some of the major topics that we've cover include input types, the specific type of information captured by a view. A great example of this is specifying a phone number input type. The keyboard changes to a number pad and the numbers are formatted in a specific way as they're entered. The soft keyboard is an excellent tool for touch screens, but sometimes it exhibits strange behavior. It can distort the view and often becomes visible when it's not supposed to. You'll learn how to manage those potential issues. Connecting a hardware keyboard to a mobile phone isn't very common, but connecting one to a tablet is becoming more and more common every year. For that reason, it's absolutely necessary to make sure our applications can be navigated using a hardware keyboard. By the end of the course you'll have an excellent understanding of the most important concepts when it comes to keyboard inputs. You'll be able to specify input types, effectively manage the soft keyboard, and support navigation using a hardware keyboard. The course is meant for absolute beginners when it comes to keyboard inputs, but targets an intermediate developer overall. I hope you'll join me on this journey to learn about keyboard inputs with the Android keyboard inputs course, at Pluralsight.
Specifying the Input Method Type For the duration of the module, we'll be working with the source code files in the directory Module_3/Start/TabianDating. If you imported the code from GitHub, you'll want to start with the branch named Module_3. 2_Start. In this module we'll work on what I consider to be the basics of keyboard inputs. We'll work on setting specific input types for the edit text widgets. Things like the email address, phone number, and text. These aren't the only input types available. These are just the ones we'll be working on in the application. There's many more available and you'll likely find them useful in your other projects. There's things like passwords, number decimals, dates, date time, and text capitalization. We'll explore some of the others by referring to the Android documentation, but we won't actually be using them in the project. Properly formatting a phone number when entered into an edit text field is something you should be doing in all your applications. Lucky for us, the Android SDK has some convenience classes that we can use just for that. One way you can customize the soft keyboard is by using what's known as an IME option. IME options will change the way the Return key looks and also change its functionality. We'll explore some of the other options like actionNext, actionDone, actionSend, and actionSearch. Each IME option will look different so users will know what's going to happen when they press it. Sometimes when the soft keyboard is displayed, it can distort the view. We're going to take a look at how we can resolve that problem by setting something called the soft input mode.
Providing AutoComplete Suggestions For the duration of the module, we'll be working with the source code files in the directory Module_4/Start/TabianDating. If you imported the code from GitHub, you'll want to start with the branch named Module_4. 2_Start. Sometimes it's convenient to provide text suggestions to users. Some fields where text suggestions are appropriate are entering a city name, entering a country name, entering a greeting message, or maybe entering an age. Currently we don't have a city, country, or age field in our application, but we do have a chat. So we're going to predefine some greeting messages that users might want to take advantage of. The message suggestions will pop up if the user starts typing the first two characters of the greeting, then they can select the one they want to use. Of course they can also choose to not use the suggestions. Next we'll work on implementing a search view. A search view isn't technically part of the handling keyboard inputs guide in the Android documentation, but I think it's worth covering since it's basically an advanced version of auto suggestions. We're going to be using a search view to filter a list of chat messages. So if a user can't remember who they were talking to, but they remember what they were talking about, they'll be able to find that user. They'll also be able to search by name. This is going to work in basically the same way as the default texting application on your current device.
Detecting if SoftKeyboard Is Visible For the duration of the module, we'll be working with the source code files in the directory Module_5/Start/TabianDating. If you imported the code from GitHub, you'll want to get started with the branch named Module_5. 2_Start. Sometimes you just can't get the view to do what you want, especially if the soft keyboard is popping up and distorting it. As I mentioned in the previous module, the navigation view is sitting on top of the soft keyboard in messages fragment. This obviously doesn't yield a good user experience, it does not look good. I don't know if you noticed, but at the start of the course this wasn't happening. Do you what's changed? We changed the windowsSoftInputMode in the manifest to stateHidden. It used to be adjustPan. AdjustPan actually solves this problem. If we set the windowSoftInputMode to adjustPan, the toolbar will not be sitting on top of the keyboard, but unfortunately then we'd have the overlap issue in chat fragment. Ah, the joys of programming. But don't worry, we have options. We always have options. We're going to build a custom listener that detects when the keyboard is showing, if it is, we'll hide the bottom navigation.
Supporting Keyboard Navigation For the duration of the module, we'll be working with the source code files in the directory Module_6/Start/TabianDating. If you imported the code from GitHub, you'll want to start with the branch named Module_6. 2_Start. As you probably already know, by default the users have the ability to navigate applications using an attached keyboard. Keyboards aren't very popular with mobile devices, for obvious reasons, but they're growing in popularity with tablets. That being said, by default navigation will likely be clunky and far from perfect. It's up to us as the developer to anticipate problems and define an intuitive navigation system. Additionally, there's going to be some significant versioning issues. I'm going to be testing on two devices, one is running API version Oreo and the other is running API version Marshmallow. That's API level 26 and 23 respectively. I have two major goals in this module. Number one is I want to show you there's no absolute way for defining keyboard navigation. There's going to be a lot of things that don't work and you'll need to be creative and come up with solutions. Number two is to convey enough different situations and examples so you get an idea of what you'll likely run into in your other projects. I'll describe my thought process and how I solve the problems that I run into. Remember, our goal is to design effective keyboard navigation for the most versions possible. So all the solutions here will have that major goal in mind. Here's an example. When a users pressed the Tab key on an attached keyboard, what happens? That's the type of navigation we need to customize. Additionally, how do you open the navigation drawer? You can't get to it using Tab. For things like that, we need to bind specific keys. I'm going to be using a wireless Bluetooth keyboard to test, but if you don't have one, you can just use the Android emulator.
Handling Keyboard Actions For the duration of the module, we'll be working with the source code files in the directory Module_7/Start/TabianDating. If you imported the code from GitHub, you'll want to start with the branch named Module_7. 2_Start. So far we've defined how a user can navigate widgets on the screen by pressing Tab and the arrow keys. But some things aren't accessible using Tab and the arrow keys. In our application, widgets that aren't accessible are the navigation drawer, the swipeRefreshLayout and the SearchView. Another thing that could use improvement is swiping through tabs. In choose photo activity, the arrow keys are the only way a user can get to the tabs. It would be much more convenient if they could do something like press Control+Left or Control+Right to swipe. In ChatFragment, when a user presses the Enter key on the keyboard, a carriage return is executed, or in other words, they're taken to the next line. I actually like that functionality, but it introduces a problem. How do they actually send the message? Of course they could tab over and press the Send button, but it would be nice to be able to press a key and then just send the message. Something like Shift+Enter would be great for this, that way they can press Enter to move to the next line or Shift+Enter to actually send the message.