After you’ve done all the UI optimizations recommended by UX designers, how do you make your interface even more engaging? That’s where the Samsung Mobile SDK can help. Part 1 of Advancing Your UI introduces you to three new technologies -- Look, Motion, and Gesture – that allow you to create an interface that engages your audience in ways you have not yet explored.
5. A “Look” at features
Writing Buddy
– Hand writing recognition extension to UI elements
Air Button
– Quick access menu for various arrays of data
Smart Clip
– Clipboard capture with metadata recognition
Pointer Icon
– Extends icon for hover pointer to user-defined
images
6. Architecturally speaking……
View System modified to support extensions to
Android UI elements
– New default behaviors (Writing Buddy enabled on all
editable fields)
– New packaged library with added functionality to enhance
your UI
APPLICATION FRAMEWORK
View System
Slook Impl
Resource Manager
Activity Manager
Window Manager
Notification Manager
Telephony Manager
…..
Content Provider
7. Look implementation
Application
SDK Module
MyBeautifulApp
1.Request(Call Public API)
2.Check Feature
3.Check version
Slook
JAR
Slook
SlookWritingBuddy
SlookAirButton
Implement
7.Response
SlookSmartClip
SlookHoverPointIc
on
APPLICATION
5.Request(Call Internal API)
Slook
Implement
SlookImpl
WritingBuddyImpl
AirButtonImpl
View System
APPLICATION FRAMEWORK
6.Response
SmartClipImpl
HoverPointIconIm
pl
8. Samsung Mobile SDK Libraries
New APIs to check for presence
and properties of technology
9. Implementing Look Features
@Override
public void onCreate(Bundle savedInstanceState) {
Slook slook = new Slook();
try {
slook.initialize(this);
} catch (SsdkUnsupportedException e) {
// notify user device does not support
return;
}
if (slook.isFeatureEnabled(Slook.AIRBUTTON)
if (slook.isFeatureEnabled(Slook.SPEN_HOVER_ICON)
if (slook.isFeatureEnabled(Slook.SMARTCLIP)
if (slook.isFeatureEnabled(Slook.WRITINGBUDDY) {
Slook<class> variable = new Slook<class> }
10. Writing Buddy
On by default for editable fields (EditText, DatePicker)
Disable system wide with Direct pen input turned off
Disable on app-by-app basis through look library
11. Writing Buddy Extensions
SLookWritingBuddy class
– 2 constructors: ViewGroup and EditText
Support for text and images
– 2 Listeners with callbacks
15. Writing Buddy Miscellaneous Features
// Turn recognition on for numeric or alphanumeric
mType = SlookWritingBuddy.TYPE_EDITOR_NUMBER;
mType = SlookWritingBuddy.TYPE_EDITOR_TEXT;
mWritingBuddy.setEditorType(mType);
// enable or disable Writing Buddy
mWritingBuddy.setEnabled(mIsEnabled);
// true or false
16. Air Button
Activated with S Pen hover + side button
Defaults to “Air Command” system wide
Override behavior inside app
– com.samsung.android.sdk.look.airbutton
Implemented with an ArrayAdapter
– Array of “data” attached to view
– Array data can be text, images, contacts, video, audio
18. Air Button -- Text
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_airbutton_simple);
Button btnText = (Button) findViewById(R.id.btn_text);
createTextListWidgetFromView(btnText);
}
public SlookAirButton createTextListWidgetFromView(View v) {
SlookAirButton airButtonWidget = new SlookAirButton(
v,
// Button
getAdapterStringList(),
// Adapter
SlookAirButton.UI_TYPE_LIST); // Data type
airButtonWidget.setItemSelectListener(mCallback);
airButtonWidget.setPosition(0, 50);
return airButtonWidget;
}
19. Creating the list of Air Button Strings
public SlookAirButtonAdapter getAdapterStringList() {
ArrayList<AirButtonItem> stringList =
new ArrayList<AirButtonItem>();
stringList.add(new AirButtonItem(null,
“Come here at 5:00", null));
stringList.add(new AirButtonItem(null, "Why?", null));
stringList.add(new AirButtonItem(null,
"I wanna watch movie", null));
stringList.add(new AirButtonItem(null,
"Ok. No problem", null));
return new SlookAirButtonAdapter(stringList);
}
20. Data Types
new SlookAirButton(View parentview, SlookAirButtonAdapter adapter,
int uiType)
where uiType is:
SlookAirButton.UI_TYPE_LIST // use with text and media arrays
SlookAirButton.UI_TYPE_MENU // use with menu arrays
// ArrayAdapter Items
AirButtonItem(Drawable image,
String description,
Object data)
// R.drawable.image or null,
// Text or null
// null
new AirButtonItem(null, “text”, null)
new AirButtonItem(R.drawable.png, “text”, null)
// text only
// image and text
21. Positioning the List
get/setGravity(int g)
// within view
SlookAirButton.GRAVITY_LEFT
SlookAirButton.GRAVITY_RIGHT
SlookAirButton.GRAVITY_TOP
SlookAirButton.GRAVITY_BOTTOM
get/setDirection(int d)
// for adapter
SlookAirButton.DIRECTION_UPPER
SlookAirButton.DIRECTION_LOWER
SlookAirButton.DIRECTION_RIGHT
SlookAirButton.DIRECTION_LEFT
get/setPosition(int x, int y)
// coordinates
y
x
23. More . . .
// lets user scroll through lists
setScrollEnabled(boolean enable)
// animates the elements in the list when it opens
setBounceEffectEnabled(boolean enable)
// animates the list when hovering over elements
start/stopAnimationIcon(MotionEvent event)
ACTION_HOVER_ENTER | ACTION_HOVER_EXIT
25. Smart Clip Features
Default behavior
– Captures the text and images in ImageView and TextView
Extensions with Look
– Meta-data can now be included with the image clip
– Meta-data includes URLs, strings, as well as the launch
intent for your activity
– Meta data can be Static or Dynamic
26. Simple Use Case -- Scrapbook
public void onCreate(. . .) {
TextView tv = (TextView) findViewById(R.id.text_static);
SlookSmartClip sc = new SlookSmartClip(tv);
sc.clearAllMetaTag();
sc.addMetaTag(new SlookSmartClipMetaTag
(SlookSmartClipMetaTag.TAG_TYPE_URL, "http://www.samsung.com"));
sc.addMetaTag(new SlookSmartClipMetaTag
(SlookSmartClipMetaTag.TAG_TYPE_PLAIN_TEXT,
"This is android textview."));
}
public void someRoutine() {
sendData();
}
27. Simple Use Case – Scrapbook (con’t)
public void sendData() {
Intent intent = new Intent();
intent.setComponent(new
ComponentName("com.samsung.android.app.pinboard",
"com.samsung.android.app.pinboard.ui.PinboardActivity"));
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(SmartClipActivity.this,
”Scrapbook application is not installed.”,
Toast.LENGTH_SHORT).show();
}
}
28. Pointer Icon
Set pointer icon for the View you want it to appear
with
– Can be ViewGroup or View
Writing Buddy icon overrides
pointer icon
– Cannot redefine hover icon for these
fields without disabling writing buddy
29. Pointer Icon – Adding in code
public class MainActivity extends Activity {
SlookPointerIcon mPointerIcon = new SlookPointerIcon();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RelativeLayout panel = (RelativeLayout)
findViewById(R.id.container);
mPointerIcon.setHoverIcon (panel,
getResources().
getDrawable(R.drawable.x_pointer_icon));
}
32. What is Gesture?
Gesture allows you to use events generated by user’s
hand movements in your application
Recognizes hand movements using data from the
gesture sensor to the right of the device speaker
Requirements:
– Gesture sensor
– Android 4.3 (Jelly Bean API level
18) or higher
34. Implementation -- Check for support of feature
public void onCreate() {
private Sgesture mGesture;
private SgestureHand mHand;
mGesture = new Sgesture();
try {
mGesture.initialize(this);
} catch (IllegalArgumentException e) {
//Error Handling
} catch (SsdkUnsupportedException e) {
//Error Handling
}
if(mGesture.isFeatureEnabled(Sgesture.TYPE_HAND_PRIMITIVE)){
mHand = new SgestureHand(Looper.getMainLooper(), mGesture);
mHand.start(Sgesture.TYPE_HAND_PRIMITIVE, mChangeListener);
}
}
35. Register Listener
private final SgestureHand.ChangeListener mChangeListener =
new SgestureHand.ChangeListener() {
@Override
public void onChanged(Info info) {
Log.d(TAG, “Hand : angle = “ + info.getAngle());
// do something with data
180º / UP
}
};
270º / LEFT
public void onStop() {
mGestureHand.stop();
}
90º / RIGHT
0º / DOWN
38. What is Motion?
Package allows you to take advantage of movement
data coming in from sensors for both “calling”
motion and “forward” motion (walking or running)
39. “Calling” motion
Recognizes the motion of bringing device up to your ear
When you read a message on your device and bring the
device up to your ear, the call motion event is triggered,
and your application calls the phone number that sent
the message.
Requirements:
– Proximity sensor, acceleration
sensor, and a gyro sensor
– Android 4.3 (Jelly Bean API level 18) or
higher
40. “Forward” motion
Pedometer data generated when walking/running
with device (steps, calories, speed, distance, and step
status)
Requirements:
– Acceleration sensor, pressure sensor
– If no pressure sensor, number of
up/down steps is not recognized
– Android 4.3 (Jelly Bean API level 18) or
higher
46. Getting the latest Pedometer data
mPedometer.getInfo();
Application
mPedometer.updateInfo();
Application
SDK
Screen : ON
getInfo()
The latest
pedometer info.
SDK just knows the
pedometer information
before screen is off.
It can’t know whether
the data is the latest
data or not.
So in this case it returns
null.
SensorHub
SDK
Screen : OFF
updateInfo()
Request
Screen : OFF
getInfo()
null
You can receive the
latest pedometer info
through ChangeListener
though screen is off.
The latest data
The latest
pedometer info
47. What’s next…….
Advancing the UI -- Part II: MultiWindow and Visual
View
– Tuesday 9:00
– California West
My name is Anna Schaller and I head up the Tech Evangelist team of Developer Relations.As I said earlier today our job is to inspire you to create those “Moments of delight” in your apps. So I wanted to show you use cases for some of the features I’m going to talk about in this session. You saw examples of Air Button, Smart Clip, and Writing Buddy among other things.
If you’ve read through the Android Design Guidelines or listened to the “Android Design In Action” sound bites you’re already on the right path. You know, and have implemented the recommendations for layouts and design patterns, developing for multiple screen sizes, how to effectively use the Android widgets and resources. There is information out there on all this. So where do you go from here? How do you enhance the UI beyond all of this?
This is where the Mobile SDK comes in. There are several packages that offer features which enhance the user experience. Not just the UI, but the way a user engages with the device. This is what I’ll cover in two different sessions. This is part 1, where I’ll walk through Look, Gestures, and Motion. Part 2 is tomorrow morning at 9:00 and I”ll cover MultiWindwo and Visual View.
There are 4 components of the Look package:There’s Writing Buddy – which eliminates the need for a soft keyboard. It uses the recognition engine included in the platform to conters handwriting into text for editable fields.There’s Air Button – gives you a different way to access lists of thingsThere’s Smart Clip – which allows users to grab screen shots of thingsAnd there’s Pointer Icon – which lets you change out the default icon for pen hoverNOTE: all components of LOOK require a Pen to use the feature.
Before I get into the “how to” of it, I wanted to show you a bit of the architecture. The View System in the Android framework has been extended to include the implementations of LOOK APIs. The sid effect of that is that there are now new default behaviors in some cases (Writing Buddy). There is also a packaged library that needs to be included in your app but let me show you what you’re including……
LOOK functionality is coded in two parts. The library that you include in your application is just a set of interfaces. The actual implementation of each API is in the framework. Those are the modifications made to the VIEW System. So If we look at it from the application standpoint, overall size of APK does not increase by much because the library is so small.
Prior to this SDK release, there was no consistent way to tell if the technology was supported on any given device. Even across Samsung devices. For instance S Pen was only supported on the Note series of devices so if your app ran on a GS3 or GS4 it would fail. The sdk-v1.0.0.jar file contains an interface that’s implemented by every package. Each package tries to initialize itself inside an exception handler. If the call to initialize fails, that technology is not supported on that device. Let’s us support technologies on devices where it makes sense.LIGHTWAY SOLUTION
Okay, so lets “look” at what you need to do to get started. As we mentioned in the Mobile SDK session, every application should include the sdk-v1.0.0.jar file.
So lets start with Writing BuddyOn the Note 3 and 2014 10” tablet, it’s on by default for editable fields. The user can disable this system wide through a Setting for Direct Pen Input – turn off. It can also be disabled on an app-by-app basis. The icon you see on the right is what the user will see when they hover over the field. The
2 constructors – means you can attach the WritingBuddy panel to either an EditText widget OR any ViewGroup (FrameLayout, RelativeLayout, whatever container you want to assign it to) Different behavior for eachEditText accepts the text written in the WritingBuddy panelViewGroup allows you to open Writing Buddy but the text needs to be assigned to specific UI element (TextEdit for instance with setText)
These are the different forms the Writing Buddy take depending on how you initialize SLookWritingBuddy (ViewGroup) or (EditText). You can extend the default editText so that it also accepts images.
To add image recognition, you register the setImageWritingListener with the instance of WritingBuddy. (CODE WALKTHROUGH).To go to text mode you would set the Listener to null. mWritingBUddy.setImageWritingListener(null)
This shows you how to useWritingBuddy with a ViewGroup. In this case the nested FrameLayout is the ViewGroup where the WritingBuddy opens up. The actual text is written to the TextView element outside the FrameLayout at the bottom of the screen with a call to SetText().
There are a handful of APIs that let you control the environment. setEditorType() can be used to define the recognition that’s done – numeric only or text.setEnabled() is the call you make to turn WritingBuddy on or off programmatically.There are more but these should get you started.
AirButton is the second feature of the LOOK package.
Here are three examples of what Air Button looks likeArray of imagesArray of contactsArray of menu items.
To useAriButton with a list of text, the code looks like this. Standard onCreate() inflating the view and getting a handle to the buttonThe call to SlookAirButton() is where you define the list. The first parameter is the button, the second is the list of strings (we’ll see in a second), and the third defines the list type with UI_TTYPE_LIST
The list is initialized here. As I mentioned it’s using an ArrayAdapter with the array type defined as “AirButtonItem”. We’ll look at that on the next slide. Next just add the strings themselves.
So I mentioned the UITYPE as a parameter to SlookAirButton(). There are 2 types, one for lists that you use for text and images; and one for menusThe AirButtonItem supports three parameters -- only 2 of which are used – Image and string. Null can be used where no data is available so the two examples on the bottom show you how to set up the calls for different arrays
You can also position the array within the UI. setGravity() sets the starting location iwthin the view (button for instance)setDiretion() sets the direction of the array.setPosition() sets the distance from the view to open the list.
This is a picture of what it would look like. You have gravity – top, bottton, left and right. And you have direction. *Tip: In fullscreen view, GRAVITY_HOVER_POINT gravity is recommended.
So that’s Air Button.The third component in Look is Smart Clip. It’s leveraging the clipboard and letting users capture selected areas of the screen. It’s been available in previous released of the platforms but is expanded on in LOOK.
[Activity Link]:When the user captures with smartclip, you can add your activity as metadata and the user can launch your activity in scrapbook.[Static vs Dynamic]-Static: You can add meta data when your view is created.-Dynamic: You can add meta data when the user capture the screen by SmartClip
You can send it directly to Scrapbook, or let the system offer a list of apps that accept data from the clipboard.
Create an instance of SlookPointerIcon. Pass in the handle to the view to setHoverIcon() along with the new iimage.
1. Writing Buddy Text Message : TO person / message / toggle image and text // write hello and then scratch out / write welcome2. Air Button – Defalut Adapter – open Receip List; open image list – Simple Adapter – open menu3. Smart Clip – Open Bloomberg – select article and grab – drop in scrapbook – open scrapbook and see extra data4. Pointer Icon – Open S Note and see pointer icon
So that’s LOOK. Gesture is another way you can engage your users with your application.
Hand uses data from the gesture sensor to the right of the device speaker to recognize hand movements.Hand indicates theangle the hand moved. When your application receives a Hand gesture event, You can play a song in the music player or view images in the gallery. You can move your hand right, left and right to receive calls without touching the screen. You can also move your hand up and down to scroll in the browser or e-mail without touching the screen.
Create an Sgesture instancePass the Sgesture instance as a parameter to create an SgestureHand instance.Looper.getMainLooper() Class used to run a message loop for a thread. Returns the application's main looper, which lives in the main thread of the application.Call start() to register a ChangeListener instance for SgestureHand.
In the onChanged(Info info) method, handle the gesture events.
That raw data is retuned as either CALL data or PEDOMETER data depending on which class you’ve initialized in the package.
Create an Smotion instance
With CALL motion, you are retrieving whether the motion was on the right side of your head or the left side.
Forward motion data includes calories burned, distance, speed, and how many steps you’ve taken.
When a pedometer event happens while screen is on, you can receive pedometer informationIf Sensorhub has a pedometer information while screen is off, you can receive pedometer information as soon as the screen is on.The Galaxy S4 is also fitted with Atmel’s sensor hub management MCU (microcontroller unit) which collects and processes data from all connected sensors in real-time, optimizing multiple user experiences, such as gaming, navigation and virtual reality. In addition, the sensor hub MCU lowers the overall system power consumption via picoPower technology to prevent drain and enable longer battery life.“Samsung’s new Galaxy S4 illustrates how motion sensing is an important function in the new device,” explained IngarFredriksen, Senior Director of Flash-based Microcontrollers, Atmel Corporation. “With a sensor hub management solution, Atmel allows Galaxy S4 users the ability to enjoy applications requiring real-time motion sensing, without ever compromising battery life.”
If the screen is off, you can collect the information in one of two waysgetInfo() only collects data when the screen is on so when event to ????