Added UI modifications and API testing code for Notification Service Consumer Sample.
authorAbitha Shankar <abitha.s@samsung.com>
Mon, 19 Sep 2016 06:08:10 +0000 (11:38 +0530)
committerMadan Lanka <lanka.madan@samsung.com>
Tue, 20 Sep 2016 10:47:47 +0000 (10:47 +0000)
patch 2 : updated the file name from review comments
patch 3 : removed dependencies from application

Change-Id: Ie52324bc8f0601b73483ec066093356d86641293
Signed-off-by: Abitha Shankar <abitha.s@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11903
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/notification/examples/android/NotiConsumerExample/app/build.gradle
service/notification/examples/android/NotiConsumerExample/app/src/main/java/com/sec/noticonsumerexample/ConsumerSample.java [moved from service/notification/examples/android/NotiConsumerExample/app/src/main/java/com/sec/noticonsumerexample/ConsumerProxy.java with 87% similarity]
service/notification/examples/android/NotiConsumerExample/app/src/main/java/com/sec/noticonsumerexample/MainActivity.java
service/notification/examples/android/NotiConsumerExample/app/src/main/res/layout/activity_main.xml
service/notification/examples/android/NotiConsumerExample/app/src/test/java/com/sec/noticonsumerexample/ExampleUnitTest.java [deleted file]
service/notification/examples/android/NotiConsumerExample/iotivity-armeabi-notification-service-release/build.gradle [deleted file]
service/notification/examples/android/NotiConsumerExample/iotivity-base-armeabi-release/build.gradle [deleted file]
service/notification/examples/android/NotiConsumerExample/settings.gradle

index 9023618..c7db51d 100755 (executable)
@@ -16,6 +16,4 @@ android {
 dependencies {\r
     compile fileTree(include: ['*.jar'], dir: 'libs')\r
     compile 'com.android.support:appcompat-v7:23.0.1'\r
-    compile project(':iotivity-base-armeabi-release')\r
-    compile project(':iotivity-armeabi-notification-service-release')\r
 }\r
-/******************************************************************\r
- * Copyright 2016 Samsung Electronics All Rights Reserved.\r
- * <p>\r
- * <p>\r
- * <p>\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * <p>\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * <p>\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- ******************************************************************/\r
-\r
-package com.sec.noticonsumerexample;\r
-\r
-import android.app.NotificationManager;\r
-import android.content.Context;\r
-import android.os.Handler;\r
-import android.os.Message;\r
-import android.util.Log;\r
-import android.widget.Toast;\r
-\r
-import org.iotivity.base.ModeType;\r
-import org.iotivity.base.OcPlatform;\r
-import org.iotivity.base.OcResourceHandle;\r
-import org.iotivity.base.PlatformConfig;\r
-import org.iotivity.base.QualityOfService;\r
-import org.iotivity.base.ServiceType;\r
-import org.iotivity.service.ns.common.NSException;\r
-import org.iotivity.service.ns.common.SyncInfo;\r
-import org.iotivity.service.ns.common.TopicsList;\r
-import org.iotivity.service.ns.consumer.ConsumerService;\r
-import org.iotivity.service.ns.consumer.Provider;\r
-\r
-import java.util.HashMap;\r
-\r
-public class ConsumerProxy\r
-    implements ConsumerService.OnProviderDiscoveredListener,\r
-    Provider.OnProviderStateListener,\r
-    Provider.OnMessageReceivedListner, Provider.OnSyncInfoReceivedListner\r
-{\r
-    private static final String TAG = "NS_CONSUMER_PROXY";\r
-\r
-    private Context mContext = null;\r
-    private ConsumerService consumerService = null;\r
-    private boolean mAcceptor = false;\r
-    private Provider mProvider = null;\r
-\r
-    private Handler mHandler = null;\r
-\r
-    private static final int PROVIDER_DISCOVERED = 1;\r
-    private static final int STATE_CHANGED = 2;\r
-    private static final int MESSAGE_RECEIVED = 3;\r
-    private static final int SYNCINFO_RECEIVED = 4;\r
-    private static final int TOPICS_RECEIVED = 5;\r
-\r
-    public ConsumerProxy(Context context)\r
-    {\r
-        Log.i(TAG, "Create consumerProxy Instance");\r
-\r
-        this.mContext = context;\r
-        consumerService = new ConsumerService();\r
-    }\r
-\r
-    public void setHandler(Handler handler)\r
-    {\r
-        this.mHandler = handler;\r
-    }\r
-\r
-    public boolean getAcceptor()\r
-    {\r
-        return mAcceptor;\r
-    }\r
-\r
-    private void configurePlatform()\r
-    {\r
-\r
-        PlatformConfig platformConfig = new PlatformConfig(\r
-            mContext,\r
-            ServiceType.IN_PROC,\r
-            ModeType.CLIENT_SERVER,\r
-            "0.0.0.0", // By setting to "0.0.0.0", it binds to all available interfaces\r
-            0,         // Uses randomly available port\r
-            QualityOfService.LOW\r
-        );\r
-\r
-        Log.i(TAG, "Configuring platform.");\r
-        OcPlatform.Configure(platformConfig);\r
-        try\r
-        {\r
-            OcPlatform.stopPresence(); // Initialize OcPlatform\r
-        }\r
-        catch (Exception e)\r
-        {\r
-            Log.e(TAG, "Exception: stopping presence when configuration step: " + e);\r
-        }\r
-        Log.i(TAG, "Configuration done Successfully");\r
-    }\r
-\r
-    public void startNotificationConsumer()\r
-    {\r
-        configurePlatform();\r
-        try\r
-        {\r
-            consumerService.start(this);\r
-        }\r
-        catch (Exception e)\r
-        {\r
-            Log.e(TAG, "Exception: startNotificationConsumer : " + e);\r
-        }\r
-    }\r
-\r
-    public void stopNotificationConsumer()\r
-    {\r
-        try\r
-        {\r
-            consumerService.stop();\r
-            mProvider = null;\r
-        }\r
-        catch (Exception e)\r
-        {\r
-            Log.e(TAG, "Exception: stopNotificationConsumer : " + e);\r
-        }\r
-    }\r
-\r
-    public void enableRemoteService(String serverAddress)\r
-    {\r
-        try\r
-        {\r
-            consumerService.enableRemoteService(serverAddress);\r
-        }\r
-        catch (Exception e)\r
-        {\r
-            Log.e(TAG, "Exception: enableRemoteService : " + e);\r
-        }\r
-    }\r
-\r
-    public void rescanProvider()\r
-    {\r
-        try\r
-        {\r
-            consumerService.rescanProvider();\r
-        }\r
-        catch (Exception e)\r
-        {\r
-            Log.e(TAG, "Exception: rescanProvider : " + e);\r
-        }\r
-    }\r
-    public void getTopicsList()\r
-    {\r
-        if (mProvider != null)\r
-        {\r
-            try\r
-            {\r
-                TopicsList topicsList = mProvider.getTopicList();\r
-            }\r
-            catch (Exception e)\r
-            {\r
-                Log.e(TAG, "Exception: getTopicsList : " + e);\r
-            }\r
-        }\r
-        else\r
-        {\r
-            Log.e(TAG, "getTopicsList Provider NULL");\r
-        }\r
-    }\r
-    public void updateTopicList(TopicsList topicsList)\r
-    {\r
-        if (mProvider != null)\r
-        {\r
-            try\r
-            {\r
-                mProvider.updateTopicList(topicsList);\r
-            }\r
-            catch (Exception e)\r
-            {\r
-                Log.e(TAG, "Exception: updateTopicList : " + e);\r
-            }\r
-        }\r
-        else\r
-        {\r
-            Log.e(TAG, "updateTopicList Provider NULL");\r
-        }\r
-    }\r
-    @Override\r
-    public void onProviderDiscovered(Provider provider)\r
-    {\r
-        Log.i(TAG, "onProviderDiscovered");\r
-        if (provider == null)\r
-        {\r
-            Log.e(TAG, "providerID is Null  ");\r
-            return;\r
-        }\r
-        mProvider = provider;\r
-        Log.i(TAG, "Provider ID: " + provider.getProviderId() );\r
-        Message msg = mHandler.obtainMessage(PROVIDER_DISCOVERED,\r
-                                             "Provider Discovered Id: " + provider.getProviderId());\r
-        mHandler.sendMessage(msg);\r
-        try\r
-        {\r
-            Log.i(TAG, "setListeners to Discovered Provider");\r
-            provider.setListener(this, this, this);\r
-            Log.i(TAG, "setListeners done");\r
-            if (! provider.isSubscribed())\r
-            {\r
-                Log.i(TAG, "Provider not subscribed. Acceptor is Consumer");\r
-                mAcceptor = false;\r
-                provider.subscribe();\r
-            }\r
-            else\r
-            {\r
-                Log.i(TAG, "Provider is already subscribed. Acceptor is Provider");\r
-                mAcceptor = true;\r
-            }\r
-        }\r
-        catch (Exception e)\r
-        {\r
-            Log.e(TAG, "Exception : " + e);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void onProviderStateReceived(Provider.ProviderState state)\r
-    {\r
-        Log.i(TAG, "onProviderStateReceived");\r
-\r
-        Log.i(TAG, "Provider state: " + state );\r
-        Message msg = mHandler.obtainMessage(STATE_CHANGED, "Provider state: " + state);\r
-        mHandler.sendMessage(msg);\r
-    }\r
-\r
-    @Override\r
-    public void onMessageReceived(org.iotivity.service.ns.common.Message message)\r
-    {\r
-        Log.i(TAG, "onMessageReceived");\r
-\r
-        Log.i(TAG, "Message Id: " + message.getMessageId());\r
-        Log.i(TAG, "Message title: " + message.getTitle());\r
-        Log.i(TAG, "Message Content: " + message.getContentText());\r
-        Log.i(TAG, "Message Topic: " + message.getTopic());\r
-        Log.i(TAG, "Message Source: " + message.getSourceName());\r
-\r
-        Message msg = mHandler.obtainMessage(MESSAGE_RECEIVED,\r
-                                             "Message Id: " + message.getMessageId() + "\n" +\r
-                                             "Message title: " + message.getTitle() + "\n" +\r
-                                             "Message Content: " + message.getContentText() + "\n" +\r
-                                             "Message Topic: " + message.getTopic() + "\n" +\r
-                                             "Message Source: " + message.getSourceName() );\r
-        mHandler.sendMessage(msg);\r
-        try\r
-        {\r
-            Log.i(TAG, "send READ syncInfo");\r
-            mProvider.sendSyncInfo(message.getMessageId(), SyncInfo.SyncType.READ);\r
-        }\r
-        catch (Exception e)\r
-        {\r
-            Log.e(TAG, "Exception : " + e);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void onSyncInfoReceived(SyncInfo sync)\r
-    {\r
-        Log.i(TAG, "onSyncInfoReceived");\r
-\r
-        Log.i(TAG, "Sync Id: " + sync.getMessageId());\r
-        Log.i(TAG, "Sync STATE: " + sync.getState());\r
-        Message msg = mHandler.obtainMessage(SYNCINFO_RECEIVED,\r
-                                             "Sync Id: " + sync.getMessageId() + "\n" +\r
-                                             "Sync STATE: " + sync.getState());\r
-        mHandler.sendMessage(msg);\r
-    }\r
-}\r
+/******************************************************************
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ * <p>
+ * <p>
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************/
+
+package com.sec.noticonsumerexample;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+
+import org.iotivity.base.ModeType;
+import org.iotivity.base.OcPlatform;
+import org.iotivity.base.PlatformConfig;
+import org.iotivity.base.QualityOfService;
+import org.iotivity.base.ServiceType;
+import org.iotivity.service.ns.common.NSException;
+import org.iotivity.service.ns.common.SyncInfo;
+import org.iotivity.service.ns.common.TopicsList;
+import org.iotivity.service.ns.common.Topic;
+import org.iotivity.service.ns.consumer.ConsumerService;
+import org.iotivity.service.ns.consumer.Provider;
+
+public class ConsumerSample
+    implements ConsumerService.OnProviderDiscoveredListener,
+    Provider.OnProviderStateListener,
+    Provider.OnMessageReceivedListner, Provider.OnSyncInfoReceivedListner
+{
+    private static final String TAG = "NS_CONSUMER_SAMPLE";
+
+    private Context mContext = null;
+    private ConsumerService consumerService = null;
+    private boolean mAcceptor = true;
+    private Provider mProvider = null;
+
+    private Handler mHandler = null;
+
+    private static final int PROVIDER_DISCOVERED = 1;
+    private static final int STATE_CHANGED = 2;
+    private static final int MESSAGE_RECEIVED = 3;
+    private static final int SYNCINFO_RECEIVED = 4;
+    private static final int TOPICS_RECEIVED = 5;
+
+    public ConsumerSample(Context context)
+    {
+        Log.i(TAG, "Create consumer sample Instance");
+
+        this.mContext = context;
+        consumerService = new ConsumerService();
+    }
+
+    public void setHandler(Handler handler)
+    {
+        this.mHandler = handler;
+    }
+
+    public boolean getAcceptor()
+    {
+        return mAcceptor;
+    }
+
+    private void configurePlatform()
+    {
+
+        PlatformConfig platformConfig = new PlatformConfig(
+            mContext,
+            ServiceType.IN_PROC,
+            ModeType.CLIENT_SERVER,
+            "0.0.0.0", // By setting to "0.0.0.0", it binds to all available interfaces
+            0,         // Uses randomly available port
+            QualityOfService.LOW
+        );
+
+        Log.i(TAG, "Configuring platform.");
+        OcPlatform.Configure(platformConfig);
+        try
+        {
+            OcPlatform.stopPresence(); // Initialize OcPlatform
+        }
+        catch (Exception e)
+        {
+            Log.e(TAG, "Exception: stopping presence when configuration step: " + e);
+        }
+        Log.i(TAG, "Configuration done Successfully");
+    }
+
+    public void startNotificationConsumer()
+    {
+        configurePlatform();
+        try
+        {
+            consumerService.start(this);
+        }
+        catch (Exception e)
+        {
+            Log.e(TAG, "Exception: startNotificationConsumer : " + e);
+        }
+    }
+
+    public void stopNotificationConsumer()
+    {
+        try
+        {
+            consumerService.stop();
+            mProvider = null;
+        }
+        catch (Exception e)
+        {
+            Log.e(TAG, "Exception: stopNotificationConsumer : " + e);
+        }
+    }
+
+    public void enableRemoteService(String serverAddress)
+    {
+        try
+        {
+            consumerService.enableRemoteService(serverAddress);
+        }
+        catch (NSException e)
+        {
+            Log.e(TAG, "NSException: enableRemoteService : " + e);
+        }
+    }
+
+    public void rescanProvider()
+    {
+        try
+        {
+            consumerService.rescanProvider();
+        }
+        catch (Exception e)
+        {
+            Log.e(TAG, "Exception: rescanProvider : " + e);
+        }
+    }
+    public void getTopicsList()
+    {
+        if (mProvider != null)
+        {
+            try
+            {
+                TopicsList topicsList = mProvider.getTopicList();
+                StringBuilder stringBuilder = new StringBuilder();
+                stringBuilder.append("TopicList Received :");
+                for(Topic topic : topicsList.getTopicsList())
+                {
+                    Log.i(TAG, "Topic Name : " + topic.getTopicName() );
+                    Log.i(TAG, "Topic State : " + topic.getState() );
+                    stringBuilder.append("\nTopic Name : " + topic.getTopicName());
+                    stringBuilder.append("\nTopic State : " + topic.getState());
+                }
+                Message msg = mHandler.obtainMessage(TOPICS_RECEIVED, stringBuilder.toString());
+                mHandler.sendMessage(msg);
+            }
+            catch (Exception e)
+            {
+                Log.e(TAG, "Exception: getTopicsList : " + e);
+            }
+        }
+        else
+        {
+            Log.e(TAG, "getTopicsList Provider NULL");
+        }
+    }
+    public void updateTopicList(TopicsList topicsList)
+    {
+        if (mProvider != null)
+        {
+            try
+            {
+                mProvider.updateTopicList(topicsList);
+            }
+            catch (Exception e)
+            {
+                Log.e(TAG, "Exception: updateTopicList : " + e);
+            }
+        }
+        else
+        {
+            Log.e(TAG, "updateTopicList Provider NULL");
+        }
+    }
+    @Override
+    public void onProviderDiscovered(Provider provider)
+    {
+        Log.i(TAG, "onProviderDiscovered");
+        if (provider == null)
+        {
+            Log.e(TAG, "providerID is Null  ");
+            return;
+        }
+        mProvider = provider;
+        Log.i(TAG, "Provider ID: " + provider.getProviderId() );
+        Message msg = mHandler.obtainMessage(PROVIDER_DISCOVERED,
+                                             "Provider Discovered Id: " + provider.getProviderId());
+        mHandler.sendMessage(msg);
+        try
+        {
+            Log.i(TAG, "setListeners to Discovered Provider");
+            provider.setListener(this, this, this);
+            Log.i(TAG, "setListeners done");
+            if (! provider.isSubscribed())
+            {
+                Log.i(TAG, "Provider not subscribed. Acceptor is Consumer");
+                mAcceptor = false;
+                provider.subscribe();
+            }
+            else
+            {
+                Log.i(TAG, "Provider is already subscribed. Acceptor is Provider");
+                mAcceptor = true;
+            }
+        }
+        catch (Exception e)
+        {
+            Log.e(TAG, "Exception : " + e);
+        }
+    }
+
+    @Override
+    public void onProviderStateReceived(Provider.ProviderState state)
+    {
+        Log.i(TAG, "onProviderStateReceived");
+
+        Log.i(TAG, "ProviderState Received : " + state );
+        Message msg = mHandler.obtainMessage(STATE_CHANGED, "ProviderState Received : " + state);
+        mHandler.sendMessage(msg);
+    }
+
+    @Override
+    public void onMessageReceived(org.iotivity.service.ns.common.Message message)
+    {
+        Log.i(TAG, "onMessageReceived");
+
+        Log.i(TAG, "Message Id: " + message.getMessageId());
+        Log.i(TAG, "Message title: " + message.getTitle());
+        Log.i(TAG, "Message Content: " + message.getContentText());
+        Log.i(TAG, "Message Topic: " + message.getTopic());
+        Log.i(TAG, "Message Source: " + message.getSourceName());
+
+        Message msg = mHandler.obtainMessage(MESSAGE_RECEIVED,
+                                             "Message Id: " + message.getMessageId() + "\n" +
+                                             "Message title: " + message.getTitle() + "\n" +
+                                             "Message Content: " + message.getContentText() + "\n" +
+                                             "Message Topic: " + message.getTopic() + "\n" +
+                                             "Message Source: " + message.getSourceName() );
+        mHandler.sendMessage(msg);
+        try
+        {
+            Log.i(TAG, "send READ syncInfo");
+            mProvider.sendSyncInfo(message.getMessageId(), SyncInfo.SyncType.READ);
+        }
+        catch (Exception e)
+        {
+            Log.e(TAG, "Exception : " + e);
+        }
+    }
+
+    @Override
+    public void onSyncInfoReceived(SyncInfo sync)
+    {
+        Log.i(TAG, "onSyncInfoReceived");
+
+        Log.i(TAG, "Sync Id: " + sync.getMessageId());
+        Log.i(TAG, "Sync STATE: " + sync.getState());
+        Message msg = mHandler.obtainMessage(SYNCINFO_RECEIVED,
+                                             "Sync Id: " + sync.getMessageId() + "\n" +
+                                             "Sync STATE: " + sync.getState());
+        mHandler.sendMessage(msg);
+    }
+}
index 7d9e463..d79c440 100755 (executable)
@@ -18,9 +18,6 @@
 \r
 package com.sec.noticonsumerexample;\r
 \r
-import android.app.Notification;\r
-import android.app.NotificationManager;\r
-import android.content.Intent;\r
 import android.os.Bundle;\r
 import android.os.Handler;\r
 import android.os.Message;\r
@@ -28,11 +25,11 @@ import android.support.v7.app.AppCompatActivity;
 import android.util.Log;\r
 import android.view.View;\r
 import android.widget.Button;\r
-import android.widget.EditText;\r
 import android.widget.TextView;\r
 import android.widget.Toast;\r
 \r
 import org.iotivity.service.ns.common.TopicsList;\r
+import org.iotivity.service.ns.common.Topic;\r
 \r
 public class MainActivity extends AppCompatActivity\r
 {\r
@@ -44,12 +41,12 @@ public class MainActivity extends AppCompatActivity
     private Button btnEnableRemoteService;\r
     private Button btnGetTopicList;\r
     private Button btnUpdateTopicList;\r
+    private Button btnClearLog;\r
     private static TextView TvLog;\r
 \r
     private boolean isStarted = false;\r
-    private String consumerId;\r
 \r
-    private ConsumerProxy mConsumerProxy = null;\r
+    private ConsumerSample mConsumerSample = null;\r
 \r
     private static final int PROVIDER_DISCOVERED = 1;\r
     private static final int STATE_CHANGED = 2;\r
@@ -100,6 +97,15 @@ public class MainActivity extends AppCompatActivity
                         }\r
                         break;\r
                     }\r
+                case TOPICS_RECEIVED:\r
+                    {\r
+                        String topicList = (String) msg.obj;\r
+                        if (topicList != null)\r
+                        {\r
+                            TvLog.append( topicList + "\n");\r
+                        }\r
+                        break;\r
+                    }\r
                 default:\r
                     break;\r
             }\r
@@ -130,6 +136,7 @@ public class MainActivity extends AppCompatActivity
         btnEnableRemoteService = (Button) findViewById(R.id.BtnEnableRemoteService);\r
         btnGetTopicList = (Button) findViewById(R.id.BtnGetTopicList);\r
         btnUpdateTopicList = (Button) findViewById(R.id.BtnUpdateTopicList);\r
+        btnClearLog = (Button) findViewById(R.id.BtnClearLog);\r
 \r
         TvLog = (TextView) findViewById(R.id.TvLog);\r
 \r
@@ -139,24 +146,20 @@ public class MainActivity extends AppCompatActivity
         btnEnableRemoteService.setOnClickListener(mClickListener);\r
         btnGetTopicList.setOnClickListener(mClickListener);\r
         btnUpdateTopicList.setOnClickListener(mClickListener);\r
+        btnClearLog.setOnClickListener(mClickListener);\r
 \r
-        mConsumerProxy = new ConsumerProxy(getApplicationContext());\r
-        mConsumerProxy.setHandler(mHandler);\r
+        mConsumerSample = new ConsumerSample(getApplicationContext());\r
+        mConsumerSample.setHandler(mHandler);\r
     }\r
 \r
     @Override\r
     protected void onDestroy()\r
     {\r
         if (isStarted)\r
-            mConsumerProxy.stopNotificationConsumer();\r
+            mConsumerSample.stopNotificationConsumer();\r
         super.onDestroy();\r
     }\r
 \r
-    public ConsumerProxy getProviderProxy()\r
-    {\r
-        return mConsumerProxy;\r
-    }\r
-\r
     Button.OnClickListener mClickListener = new View.OnClickListener()\r
     {\r
         public void onClick(View v)\r
@@ -165,84 +168,103 @@ public class MainActivity extends AppCompatActivity
             {\r
                 case R.id.BtnStart:\r
                     {\r
-                        if (isStarted == false)\r
+                        if (!isStarted)\r
                         {\r
                             Log.i(TAG, "Start NS Consumer Service");\r
 \r
                             TvLog.setText("Start NS-Consumer\n");\r
-                            mConsumerProxy.startNotificationConsumer();\r
+                            mConsumerSample.startNotificationConsumer();\r
                             isStarted = true;\r
                         }\r
                         else\r
                         {\r
-                            Log.e(TAG, "NS Consumer Service had already started");\r
+                            Log.e(TAG, "NS Consumer Service has already started");\r
+                            showToast("Error : Service has already started");\r
                         }\r
                     }\r
                     break;\r
 \r
                 case R.id.BtnStop:\r
                     {\r
-                        if (isStarted == false)\r
+                        if (!isStarted)\r
                         {\r
                             Log.e(TAG, "Fail to stop service. Service has not been started");\r
+                            showToast("Error : Service has not been started");\r
                             break;\r
                         }\r
                         TvLog.append("Stop NS-Consumer\n");\r
-                        mConsumerProxy.stopNotificationConsumer();\r
+                        mConsumerSample.stopNotificationConsumer();\r
                         isStarted = false;\r
                     }\r
                     break;\r
                 case R.id.BtnRescan:\r
                     {\r
-                        if (isStarted == false)\r
+                        if (!isStarted)\r
                         {\r
                             Log.e(TAG, "Fail to rescan. Service has not been started");\r
+                            showToast("Error : Service has not been started");\r
                             break;\r
                         }\r
-\r
                         TvLog.append("Rescan NS-Consumer\n");\r
-                        mConsumerProxy.rescanProvider();\r
+                        mConsumerSample.rescanProvider();\r
                     }\r
                     break;\r
                 case R.id.BtnEnableRemoteService:\r
                     {\r
-                        if (isStarted == false)\r
+                        if (!isStarted)\r
                         {\r
                             Log.e(TAG, "Fail to Enable RemoteService. Service has not been started");\r
+                            showToast("Error : Service has not been started");\r
                             break;\r
                         }\r
                         TvLog.append("EnableRemoteService NS-Consumer\n");\r
 \r
                         //TODO: Update to read the serverAddress from UI\r
                         String serverAddress = new String();\r
-                        mConsumerProxy.enableRemoteService(serverAddress);\r
+                        mConsumerSample.enableRemoteService(serverAddress);\r
                     }\r
                     break;\r
                 case R.id.BtnGetTopicList:\r
                     {\r
-                        if (isStarted == false)\r
+                        if (!isStarted)\r
                         {\r
                             Log.e(TAG, "Fail to GetTopicList. Service has not been started");\r
+                            showToast("Error : Service has not been started");\r
                             break;\r
                         }\r
                         TvLog.append("GetTopicList NS-Consumer\n");\r
-                        mConsumerProxy.getTopicsList();\r
+                        mConsumerSample.getTopicsList();\r
                     }\r
                     break;\r
                 case R.id.BtnUpdateTopicList:\r
                     {\r
-                        if (isStarted == false)\r
+                        if (!isStarted)\r
                         {\r
                             Log.e(TAG, "Fail to UpdateTopicList. Service has not been started");\r
+                            showToast("Error : Service has not been started");\r
+                            break;\r
+                        }\r
+                        if(mConsumerSample.getAcceptor())\r
+                        {\r
+                            Log.e(TAG, "Operation Not Allowed. ProviderService Acceptor is not Consumer");\r
+                            showToast("Operation Not Allowed. ProviderService Acceptor is not Consumer");\r
                             break;\r
                         }\r
                         TvLog.append("UpdateTopicList NS-Consumer\n");\r
 \r
-                        //TODO: Update to read the TopicsList from UI\r
-                        TopicsList topicsList = new TopicsList();\r
-                        mConsumerProxy.updateTopicList(topicsList);\r
+                        TopicsList topicList = new TopicsList();\r
+                        topicList.addTopic("OCF_TOPIC1", Topic.TopicState.SUBSCRIBED);\r
+                        topicList.addTopic("OCF_TOPIC2", Topic.TopicState.SUBSCRIBED);\r
+                        topicList.addTopic("OCF_TOPIC3", Topic.TopicState.UNSUBSCRIBED);\r
+\r
+                        mConsumerSample.updateTopicList(topicList);\r
                     }\r
                     break;\r
+                case R.id.BtnClearLog:\r
+                {\r
+                    TvLog.setText("");\r
+                }\r
+                break;\r
             }\r
         }\r
     };\r
index 2a93adc..b924bc2 100755 (executable)
@@ -12,8 +12,8 @@
     <LinearLayout\r
         android:layout_width="match_parent"\r
         android:layout_height="wrap_content"\r
-        android:paddingLeft="16dp"\r
-        android:paddingRight="16dp"\r
+        android:paddingLeft="1dp"\r
+        android:paddingRight="1dp"\r
         android:orientation="vertical" >\r
 \r
         <View\r
             android:paddingRight="5dp"\r
             android:orientation="vertical" >\r
 \r
+            <LinearLayout\r
+                android:layout_width="match_parent"\r
+                android:layout_height="wrap_content"\r
+                android:paddingLeft="5dp"\r
+                android:paddingRight="5dp"\r
+                android:orientation="horizontal" >\r
             <Button\r
                 android:layout_gravity="center_vertical|center_horizontal"\r
                 android:layout_height="60dp"\r
-                android:layout_width="match_parent"\r
+                android:layout_width="wrap_content"\r
+                android:layout_weight="1"\r
                 android:id="@+id/BtnStart"\r
                 android:text="START"/>\r
             <Button\r
                 android:layout_gravity="center_vertical|center_horizontal"\r
                 android:layout_height="60dp"\r
+                android:layout_width="wrap_content"\r
+                android:layout_weight="1"\r
+                android:id="@+id/BtnStop"\r
+                android:text="STOP"/>\r
+            </LinearLayout>\r
+        </LinearLayout>\r
+        <LinearLayout\r
+            android:layout_width="match_parent"\r
+            android:layout_height="wrap_content"\r
+            android:paddingLeft="5dp"\r
+            android:paddingRight="5dp"\r
+            android:orientation="vertical" >\r
+            <LinearLayout\r
                 android:layout_width="match_parent"\r
+                android:layout_height="wrap_content"\r
+                android:paddingLeft="5dp"\r
+                android:paddingRight="5dp"\r
+                android:orientation="horizontal" >\r
+            <Button\r
+                android:layout_gravity="center_vertical|center_horizontal"\r
+                android:layout_height="60dp"\r
+                android:layout_width="wrap_content"\r
+                android:layout_weight="1"\r
                 android:id="@+id/BtnRescan"\r
                 android:text="RESCAN"/>\r
             <Button\r
                 android:layout_gravity="center_vertical|center_horizontal"\r
-                android:layout_height="0dp"\r
+                android:layout_height="60dp"\r
+                android:layout_width="wrap_content"\r
+                android:layout_weight="1"\r
+                android:id="@+id/BtnGetTopicList"\r
+                android:text="Get TopicList"/>\r
+            </LinearLayout>\r
+        </LinearLayout>\r
+        <LinearLayout\r
+            android:layout_width="match_parent"\r
+            android:layout_height="wrap_content"\r
+            android:paddingLeft="5dp"\r
+            android:paddingRight="5dp"\r
+            android:orientation="vertical" >\r
+            <LinearLayout\r
                 android:layout_width="match_parent"\r
-                android:id="@+id/BtnEnableRemoteService"\r
-                android:text="Enable Remote Service"/>\r
+                android:layout_height="wrap_content"\r
+                android:paddingLeft="5dp"\r
+                android:paddingRight="5dp"\r
+                android:orientation="vertical" >\r
             <Button\r
                 android:layout_gravity="center_vertical|center_horizontal"\r
-                android:layout_height="0dp"\r
+                android:layout_height="1dp"\r
                 android:layout_width="match_parent"\r
-                android:id="@+id/BtnGetTopicList"\r
-                android:text="Get TopicList"/>\r
+                android:id="@+id/BtnEnableRemoteService"\r
+                android:text="Enable Remote Service"/>\r
             <Button\r
                 android:layout_gravity="center_vertical|center_horizontal"\r
-                android:layout_height="0dp"\r
+                android:layout_height="60dp"\r
                 android:layout_width="match_parent"\r
                 android:id="@+id/BtnUpdateTopicList"\r
                 android:text="Update TopicList"/>\r
-        </LinearLayout>\r
-\r
-        <LinearLayout\r
-            android:layout_width="match_parent"\r
-            android:layout_height="10dp">\r
+            </LinearLayout>\r
         </LinearLayout>\r
         <LinearLayout\r
             android:layout_width="match_parent"\r
             android:paddingRight="5dp"\r
             android:orientation="horizontal" >\r
 \r
-            <TextView\r
+            <Button\r
                 android:layout_gravity="center_vertical|center_horizontal"\r
-                android:layout_height="wrap_content"\r
+                android:layout_height="60dp"\r
                 android:layout_width="match_parent"\r
-                android:id="@+id/logging"\r
-                android:text="Log.."/>\r
+                android:id="@+id/BtnClearLog"\r
+                android:text="Clear Log"/>\r
         </LinearLayout>\r
 \r
         <ScrollView\r
 \r
             <LinearLayout\r
                 android:layout_width="match_parent"\r
-                android:layout_height="150dp"\r
+                android:layout_height="1000dp"\r
                 android:paddingLeft="5dp"\r
                 android:paddingRight="5dp"\r
                 android:orientation="horizontal" >\r
 \r
                 <TextView\r
                     android:layout_gravity="center_vertical|center_horizontal"\r
-                    android:layout_height="300dp"\r
+                    android:layout_height="1000dp"\r
                     android:layout_width="match_parent"\r
                     android:scrollbars="vertical"\r
                     android:id="@+id/TvLog"/>\r
 \r
         </ScrollView>\r
 \r
-        <LinearLayout\r
-            android:layout_width="match_parent"\r
-            android:layout_height="wrap_content"\r
-            android:paddingLeft="5dp"\r
-            android:paddingRight="5dp"\r
-            android:orientation="horizontal" >\r
-\r
-            <Button\r
-                android:layout_gravity="center_vertical|center_horizontal"\r
-                android:layout_height="60dp"\r
-                android:layout_width="match_parent"\r
-                android:id="@+id/BtnStop"\r
-                android:text="STOP"/>\r
-        </LinearLayout>\r
 \r
         <View\r
             android:layout_width="match_parent"\r
             android:layout_alignParentBottom="true"\r
             android:background="@android:color/darker_gray"/>\r
 \r
-        <LinearLayout\r
-            android:layout_width="match_parent"\r
-            android:layout_height="20dp">\r
-        </LinearLayout>\r
-\r
     </LinearLayout>\r
 \r
 \r
diff --git a/service/notification/examples/android/NotiConsumerExample/app/src/test/java/com/sec/noticonsumerexample/ExampleUnitTest.java b/service/notification/examples/android/NotiConsumerExample/app/src/test/java/com/sec/noticonsumerexample/ExampleUnitTest.java
deleted file mode 100755 (executable)
index 050d84a..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.sec.noticonsumerexample;\r
-\r
-import org.junit.Test;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-/**\r
- * To work on unit tests, switch the Test Artifact in the Build Variants view.\r
- */\r
-public class ExampleUnitTest {\r
-    @Test\r
-    public void addition_isCorrect() throws Exception {\r
-        assertEquals(4, 2 + 2);\r
-    }\r
-}
\ No newline at end of file
diff --git a/service/notification/examples/android/NotiConsumerExample/iotivity-armeabi-notification-service-release/build.gradle b/service/notification/examples/android/NotiConsumerExample/iotivity-armeabi-notification-service-release/build.gradle
deleted file mode 100755 (executable)
index 0cc2c63..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-configurations.maybeCreate("default")
-artifacts.add("default", file('iotivity-armeabi-notification-service-release.aar'))
\ No newline at end of file
diff --git a/service/notification/examples/android/NotiConsumerExample/iotivity-base-armeabi-release/build.gradle b/service/notification/examples/android/NotiConsumerExample/iotivity-base-armeabi-release/build.gradle
deleted file mode 100755 (executable)
index a4078ab..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-configurations.maybeCreate("default")
-artifacts.add("default", file('iotivity-base-armeabi-release.aar'))
\ No newline at end of file
index 836b36e..9d495b3 100755 (executable)
@@ -1 +1 @@
-include ':app', ':iotivity-base-armeabi-release', ':iotivity-armeabi-notification-service-release'
\ No newline at end of file
+include ':app'
\ No newline at end of file