Samsung Mobile SDK Tutorial 4

Samsung Mobile SDK Tutorial 4Welcome to part 4 of my Samsung Mobile SDK Tutorial. In this video I focus on Samsung S Look tools with a specific focus on Samsung WritingBuddy.

Samsung S Look provides specialized widgets like Samsung WritingBuddy, which recognizes hand writing as user input. S Look also provides AirButton which makes it easy to create popup menus. SmartClip allows you to capture and extract Metadata such as text and URLs and to crop screenshots using S-Pen.

If you like videos like this it helps if you tell Google+ with a click here

Donโ€™t forget to check out the Samsung Smart App Challenge and if it is still November 2013, donโ€™t forget to sign up to win a Samsung Galaxy Note 3, or Samsung Galaxy Gear Smart Watch on my site.

Code From the Video

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/information"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:orientation="vertical"
    >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        >
        
        <Button
            android:id="@+id/btn_enable"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Disable"
            />        
        <Button
            android:id="@+id/btn_enable_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Enable Image Listener"
            />         
    </LinearLayout>
       
    <EditText
        android:id="@+id/edit_input" 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Please write here by S-Pen"                        
        />
	<TextView
	    android:layout_width="match_parent"
	    android:layout_height="wrap_content"
	    android:text="[OUTPUT IMAGE]"
	    />   
	<ImageView 
	    android:id="@+id/image_output"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           />
   
</LinearLayout>

package com.samsung.android.example.slookdemos;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

import com.samsung.android.sdk.look.writingbuddy.SlookWritingBuddy;

public class WritingBuddyEditTextActivity extends Activity {

	// Provides methods that allow the user to click in
	// an EditText and write, or draw an image.
	// If text, or numbers text recognition is used
    private SlookWritingBuddy mWritingBuddy;

    // Used to load an image 
    private ImageView mOutputImageView;

    // The ability to use WritingBuddy is true by default
    private boolean mIsEnabled = true;

    // The ability to draw an image is disabled by default
    private boolean mEnableImage = false;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_writingbuddy_edittext);

        // Initialize the EditText and ImageView
        EditText editInput = (EditText) findViewById(R.id.edit_input);
        mOutputImageView = (ImageView) findViewById(R.id.image_output);

        // Creates an instance of Writing Buddy for the 
        // supplied EditText
        mWritingBuddy = new SlookWritingBuddy(editInput);

        // Initialize the button that enables Writing Buddy
        // and add a click listener to it
        Button enableButton = (Button) findViewById(R.id.btn_enable);
        enableButton.setOnClickListener(new View.OnClickListener() {

        	// If it is clicked the opposite state is used
            public void onClick(View v) {
                if (mIsEnabled) {
                    ((Button) v).setText("Enable");
                    mIsEnabled = false;
                } else {
                    ((Button) v).setText("Disable");
                    mIsEnabled = true;
                }
                
                // Writing Buddy is told if it is enabled or not
                // If so it will display a pen icon that the user
                // can click on to write out their answer
                mWritingBuddy.setEnabled(mIsEnabled);
            }
        });

        // If Image listener is enabled the user can draw a picture
        // and it won't be converted into text or a number
        Button modeButton = (Button) findViewById(R.id.btn_enable_image);
        modeButton.setOnClickListener(new View.OnClickListener() {

        	// If it is clicked the opposite state is used
            public void onClick(View v) {
                if (mEnableImage) {
                    mEnableImage = false;
                    
                    // Disable the ability to draw a picture
                    mWritingBuddy.setImageWritingListener(null);
                    
                    // Set the new value for the button
                    ((Button) v).setText("Enable Image Listener");
                } else {
                    mEnableImage = true;
                    
                    // If drawing is enabled clear the background of the writing surface
                    mWritingBuddy
                            .setImageWritingListener(new SlookWritingBuddy.ImageWritingListener() {
                                public void onImageReceived(Bitmap arg0) {
                                    mOutputImageView.setBackground(new BitmapDrawable(
                                            getResources(), arg0));
                                }
                            });
                    
                    // Set the new value for the button 
                    ((Button) v).setText("Disable Image Listener");
                }
            }
        });

    }
}

package com.samsung.android.example.slookdemos;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;

// WritingBuddyActivity works in exactly the same way
// that the SlookActivity ListActivity works

public class WritingBuddyActivity extends ListActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        // We use SimpleAdapter to bind the static data provided 
        // by getData() to the Listview object which is bound to the
        // TextView in activity_main.xml
        // You pass the following to SimpleAdapter 
        // The Context, a list containing the data, 
        // simple_list_item_1 is a standard Android row layout,
        // list of column names that will be added to the map,
        // and the TextViews that should display the data
        setListAdapter(new SimpleAdapter(this, getData(), android.R.layout.simple_list_item_1,
                new String[] {
                    "title"
                }, new int[] {
                    android.R.id.text1
                }));
        
        // Get the activities ListView widget and enable filtering
        // for the ListView so that a keyboard can select an item
        getListView().setTextFilterEnabled(true);
    }

    // Returns a List filled with Maps which are key value pairs
    private List<Map<String, Object>> getData() {
        List<Map<String, Object>> myData = new ArrayList<Map<String, Object>>();

        addItem(myData,
                "1. EditText",
                activityIntent("com.samsung.android.example.slookdemos.WritingBuddyEditTextActivity"));
        addItem(myData,
                "2. ViewGroup",
                activityIntent("com.samsung.android.example.slookdemos.WritingBuddyViewGroupActivity"));
        return myData;
    }

    // Create an Intent which will be the class that is called
    // when the user clicks on a list item. 
    private Intent activityIntent(String componentName) {
        Intent result = new Intent();
        result.setClassName(this, componentName);
        return result;
    }

    // Receive a List that adds the title and Intent to a Hashmap
    // which is then added to the List 
    private void addItem(List<Map<String, Object>> data, String name, Object intent) {
        Map<String, Object> item = new HashMap<String, Object>();
        item.put("title", name);
        item.put("intent", intent);
        data.add(item);
    }

    // When the list item is clicked the corresponding class (Activity)
    // is executed
    @Override
    @SuppressWarnings("unchecked")
    protected void onListItemClick(ListView l, View v, int position, long id) {
        Map<String, Object> map = (Map<String, Object>) l.getItemAtPosition(position);
        Intent intent = (Intent) map.get("intent");
        startActivity(intent);
    }
}

Information on my Contest

The Requirements for Entering the Samsung Smart App Challenge can be found here : http://developer.samsung.com/ssac2013/note/main.do

Iโ€™m very excited to provide you with my Samsung Mobile SDK Tutorial! Over the next few videos I cover: the Samsung Mobile SDK.

Thanks to the nice people at Samsung and the Samsung Smart App Challenge, who are giving away $1.1 Million in prizes.

Iโ€™ll also be offering a give away. Between now and November the 30th, sign up for a free Samsung developer account at http://developer.samsung.com/signup and you will be eligible to win a Samsung GALAXY Note 3 device or one of three Samsung GALAXY Gear smart watches. I will choose a winner at random.

After you signup for the Samsung developer account, leave a comment on my website stating that you signed up. That is all!

7 Responses to “Samsung Mobile SDK Tutorial 4”

  1. SHAKEEB AYAZ says:

    yesterday page was not loading.. Finally signed up ๐Ÿ˜€

  2. reyden says:

    Hi Sir Derek,
    I sign up for a samsung developer account.
    Many thanks and More power.

  3. Jochem says:

    Hi Derek,

    I singed up for a samsung developers account. love your vids

    -Jochem

  4. Jochem says:

    Hello,
    I made a Samsung developers account.

Leave a Reply

Your email address will not be published.

Google+