├── .DS_Store ├── LICENSE ├── PickMeUp-Android ├── .gradle │ └── 1.12 │ │ └── taskArtifacts │ │ ├── cache.properties │ │ ├── cache.properties.lock │ │ ├── fileHashes.bin │ │ ├── fileSnapshots.bin │ │ ├── outputFileStates.bin │ │ └── taskArtifacts.bin ├── .idea │ ├── .name │ ├── compiler.xml │ ├── copyright │ │ └── profiles_settings.xml │ ├── encodings.xml │ ├── gradle.xml │ ├── libraries │ │ ├── org_eclipse_paho_android_service.xml │ │ ├── org_eclipse_paho_client_mqttv3.xml │ │ ├── play_services_4_2_42.xml │ │ └── support_v4_19_1_0.xml │ ├── misc.xml │ ├── modules.xml │ ├── scopes │ │ └── scope_settings.xml │ ├── vcs.xml │ └── workspace.xml ├── LICENSE ├── README.md ├── app │ ├── .gitignore │ ├── app.iml │ ├── build.gradle │ ├── libs │ │ ├── org.eclipse.paho.android.service.jar │ │ └── org.eclipse.paho.client.mqttv3.jar │ ├── proguard-rules.pro │ └── src │ │ ├── debug │ │ └── res │ │ │ └── values │ │ │ └── google_maps_api.xml │ │ ├── main │ │ ├── .classpath │ │ ├── .project │ │ ├── AndroidManifest.xml │ │ ├── bin │ │ │ └── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── ibm │ │ │ │ └── pickmeup │ │ │ │ ├── PickMeUpApplication.java │ │ │ │ ├── activities │ │ │ │ ├── ChatActivity.java │ │ │ │ ├── ChatPrepActivity.java │ │ │ │ ├── DriverArrivedActivity.java │ │ │ │ ├── DriverDetailsActivity.java │ │ │ │ ├── LoginActivity.java │ │ │ │ ├── MapActivity.java │ │ │ │ ├── PaymentSentActivity.java │ │ │ │ ├── SearchDriversActivity.java │ │ │ │ └── TripEndDetailsActivity.java │ │ │ │ ├── dialogs │ │ │ │ └── ErrorDialog.java │ │ │ │ ├── receivers │ │ │ │ └── RouterReceiver.java │ │ │ │ └── utils │ │ │ │ ├── ActionListener.java │ │ │ │ ├── ChatRowAdapter.java │ │ │ │ ├── ChatUtils.java │ │ │ │ ├── Constants.java │ │ │ │ ├── LocationUtils.java │ │ │ │ ├── MessageConductor.java │ │ │ │ ├── MessageFactory.java │ │ │ │ ├── MqttHandler.java │ │ │ │ └── TopicFactory.java │ │ ├── project.properties │ │ └── res │ │ │ ├── drawable-xxhdpi │ │ │ ├── edittext.xml │ │ │ ├── ic_action_map.png │ │ │ ├── ic_action_microphone.png │ │ │ ├── ic_action_microphone_recording.png │ │ │ ├── ic_action_person.png │ │ │ ├── ic_action_photo.png │ │ │ ├── ic_action_play.png │ │ │ ├── ic_action_selfie.png │ │ │ ├── ic_action_send.png │ │ │ ├── ic_action_user.png │ │ │ ├── ic_driver.png │ │ │ ├── ic_launcher.png │ │ │ ├── ic_passenger.png │ │ │ ├── ic_user.png │ │ │ ├── map_details.xml │ │ │ └── round.xml │ │ │ ├── layout │ │ │ ├── activity_chat.xml │ │ │ ├── activity_chat_prep.xml │ │ │ ├── activity_driver_arrived.xml │ │ │ ├── activity_driver_details.xml │ │ │ ├── activity_login.xml │ │ │ ├── activity_map.xml │ │ │ ├── activity_payment_sent.xml │ │ │ ├── activity_search_drivers.xml │ │ │ ├── activity_trip_end_details.xml │ │ │ └── row_layout.xml │ │ │ ├── menu │ │ │ ├── chat.xml │ │ │ ├── chat_map_actions.xml │ │ │ ├── chat_prep.xml │ │ │ ├── driver_arrived.xml │ │ │ ├── driver_details.xml │ │ │ ├── login.xml │ │ │ ├── payment_sent.xml │ │ │ ├── search_drivers.xml │ │ │ └── trip_end_details.xml │ │ │ ├── values-v11 │ │ │ └── styles.xml │ │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ │ └── values │ │ │ ├── attrs.xml │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── release │ │ └── res │ │ └── values │ │ └── google_maps_api.xml ├── build.gradle ├── build │ └── intermediates │ │ ├── exploded-aar │ │ ├── com.android.support │ │ │ └── appcompat-v7 │ │ │ │ └── 19.1.0 │ │ │ │ ├── .classpath │ │ │ │ ├── .project │ │ │ │ ├── bin │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── classes │ │ │ │ │ └── .gitignore │ │ │ │ ├── gen │ │ │ │ └── .gitignore │ │ │ │ └── project.properties │ │ └── com.google.android.gms │ │ │ └── play-services │ │ │ └── 4.2.42 │ │ │ ├── .classpath │ │ │ ├── .project │ │ │ ├── bin │ │ │ ├── AndroidManifest.xml │ │ │ └── classes │ │ │ │ └── .gitignore │ │ │ ├── gen │ │ │ └── .gitignore │ │ │ └── project.properties │ │ └── model_data.bin ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── local.properties └── settings.gradle ├── PickMeUp-HTML5 ├── LICENSE ├── License.txt ├── README.md ├── css │ └── style.css ├── img │ ├── marker.png │ └── person.png ├── index.html └── js │ ├── App.js │ ├── Messenger.js │ ├── Utils.js │ ├── main.js │ └── utils │ ├── OpenLayers.js │ ├── jquery.min.js │ ├── mqttws31.js │ └── theme │ └── default │ └── style.css ├── PickMeUp-iOS ├── LICENSE ├── PickMeUp.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── PickMeUp.xccheckout ├── PickMeUp │ ├── Base.lproj │ │ └── .DS_Store │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── LaunchImage.launchimage │ │ │ └── Contents.json │ ├── Main_iPad.storyboard │ ├── Main_iPhone.storyboard │ ├── PMUAppDelegate.h │ ├── PMUAppDelegate.m │ ├── PMUCallbacks.h │ ├── PMUCallbacks.m │ ├── PMUChatViewController.h │ ├── PMUChatViewController.m │ ├── PMUConstants.h │ ├── PMUConstants.m │ ├── PMUDriver.h │ ├── PMUDriver.m │ ├── PMUFinalizeViewController.h │ ├── PMUFinalizeViewController.m │ ├── PMUMapViewController.h │ ├── PMUMapViewController.m │ ├── PMUMessage.h │ ├── PMUMessage.m │ ├── PMUMessageFactory.h │ ├── PMUMessageFactory.m │ ├── PMUMessageTableView.h │ ├── PMUMessageTableView.m │ ├── PMUMessageTableViewDataSource.h │ ├── PMUMessenger.h │ ├── PMUMessenger.m │ ├── PMUPairingViewController.h │ ├── PMUPairingViewController.m │ ├── PMURequest.h │ ├── PMURequest.m │ ├── PMURequestViewController.h │ ├── PMURequestViewController.m │ ├── PMUSpinnerViewController.h │ ├── PMUSpinnerViewController.m │ ├── PMUTopicFactory.h │ ├── PMUTopicFactory.m │ ├── PickMeUp-Info.plist │ ├── PickMeUp-Prefix.pch │ ├── Secondary_iPhone.storyboard │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── icons │ │ ├── .DS_Store │ │ ├── Icon-40.png │ │ ├── Icon-40@2x.png │ │ ├── Icon-60.png │ │ ├── Icon-60@2x.png │ │ ├── Icon-76.png │ │ ├── Icon-76@2x.png │ │ ├── Icon-Small.png │ │ ├── Icon-Small@2x.png │ │ ├── appIcon.png │ │ ├── bubbleMine.png │ │ ├── bubbleMine@2x.png │ │ ├── bubbleSomeone.png │ │ ├── bubbleSomeone@2x.png │ │ ├── ic_action_map.png │ │ ├── ic_action_microphone.png │ │ ├── ic_action_microphone_recording.png │ │ ├── ic_action_person.png │ │ ├── ic_action_photo.png │ │ ├── ic_action_play.png │ │ ├── ic_action_selfie.png │ │ ├── ic_action_send.png │ │ ├── ic_action_user.png │ │ ├── ic_driver.png │ │ ├── ic_passenger.png │ │ └── ic_user.png │ ├── include │ │ └── MqttOCClient.h │ ├── lib │ │ └── libiosMQTT.a │ └── main.m ├── PickMeUpTests │ ├── PickMeUpTests-Info.plist │ ├── PickMeUp_Tests.m │ └── en.lproj │ │ └── InfoPlist.strings └── README.md └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/.DS_Store -------------------------------------------------------------------------------- /PickMeUp-Android/.gradle/1.12/taskArtifacts/cache.properties: -------------------------------------------------------------------------------- 1 | #Wed Jul 23 15:16:03 CDT 2014 2 | -------------------------------------------------------------------------------- /PickMeUp-Android/.gradle/1.12/taskArtifacts/cache.properties.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/.gradle/1.12/taskArtifacts/cache.properties.lock -------------------------------------------------------------------------------- /PickMeUp-Android/.gradle/1.12/taskArtifacts/fileHashes.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/.gradle/1.12/taskArtifacts/fileHashes.bin -------------------------------------------------------------------------------- /PickMeUp-Android/.gradle/1.12/taskArtifacts/fileSnapshots.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/.gradle/1.12/taskArtifacts/fileSnapshots.bin -------------------------------------------------------------------------------- /PickMeUp-Android/.gradle/1.12/taskArtifacts/outputFileStates.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/.gradle/1.12/taskArtifacts/outputFileStates.bin -------------------------------------------------------------------------------- /PickMeUp-Android/.gradle/1.12/taskArtifacts/taskArtifacts.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/.gradle/1.12/taskArtifacts/taskArtifacts.bin -------------------------------------------------------------------------------- /PickMeUp-Android/.idea/.name: -------------------------------------------------------------------------------- 1 | PickMeUp-Android -------------------------------------------------------------------------------- /PickMeUp-Android/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /PickMeUp-Android/.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /PickMeUp-Android/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /PickMeUp-Android/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /PickMeUp-Android/.idea/libraries/org_eclipse_paho_android_service.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /PickMeUp-Android/.idea/libraries/org_eclipse_paho_client_mqttv3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /PickMeUp-Android/.idea/libraries/play_services_4_2_42.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /PickMeUp-Android/.idea/libraries/support_v4_19_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /PickMeUp-Android/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /PickMeUp-Android/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /PickMeUp-Android/.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /PickMeUp-Android/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PickMeUp-Android/README.md: -------------------------------------------------------------------------------- 1 | #Set up the PickMeUp Android project 2 | 3 | ##Prerequisites 4 | The following are the prerequisites for running the PickMeUp Android application: 5 | 6 | * PickMeUp Android application requires an Android device with Android 4.1 Jelly Bean (API level 16) or higher to run. 7 | * Running PickMeUp on an emulator is not advised as PickMeUp is using Google Play Services and Location Services. Using an emulator might cause the application to run with reduced functionality. 8 | * The application has been tested using Google Nexus 4, Google Nexus 7 and Samsung Galaxy S4. Using a smaller display or lower screen resolution is not recommended. 9 | * Google Account and Google Maps Android API v2 key is required to build the application. 10 | * Android SDK toolkit is required to build PickMeUp application. Stand-alone SDK tools as well as Eclipse or Android Studio bundle can be used. 11 | * PickMeUp source code includes a Gradle build file which can be run using Gradle command line tools, Android Studio IDE or using Eclipse with the Gradle plugin. 12 | 13 | ##Registering for Google Maps API 14 | Opening a Google account and registering for Google Maps API is free of charge. Any Google account can be used to obtain the key for debug and development purposes. 15 | 16 | **Note:** Before building the PickMeUp application, a Google Maps API key is required. To get a Google Maps API key simply follow this link and press *Create*: 17 | 18 | https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=9F:22:30:50:6D:43:4D:E7:FB:98:79:76:DC:67:E1:1B:CF:9A:01:10%3Bcom.ibm.pickmeup 19 | 20 | To add the credentials to an existing key the following line can be used: 21 | 22 | 9F:22:30:50:6D:43:4D:E7:FB:98:79:76:DC:67:E1:1B:CF:9A:01:10;com.ibm.pickmeup 23 | 24 | Once the key is generated, replace the google_maps_key entry with the key inside the following file: 25 | /PickMeUp/app/src/debug/res/values/google_maps_api.xml 26 | 27 | The key should start with *AIza*. 28 | 29 | ##Android SDK Packages 30 | The following SDK packages are required to build the PickMeUp application: 31 | * Android 4.4.2 (API 19) - SDK Platform 32 | * Google Repository 33 | * Android Support Repository 34 | * Android SDK Build-tools 19.1 -------------------------------------------------------------------------------- /PickMeUp-Android/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 19 5 | buildToolsVersion "19.1.0" 6 | 7 | defaultConfig { 8 | applicationId "com.ibm.pickmeup" 9 | minSdkVersion 16 10 | targetSdkVersion 19 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | runProguard false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | compile 'com.google.android.gms:play-services:4.2.42' 25 | // You must install or update the Support Repository through the SDK manager to use this dependency. 26 | compile 'com.android.support:support-v4:19.+' 27 | compile files('libs/org.eclipse.paho.client.mqttv3.jar') 28 | compile files('libs/org.eclipse.paho.android.service.jar') 29 | } 30 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/libs/org.eclipse.paho.android.service.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/app/libs/org.eclipse.paho.android.service.jar -------------------------------------------------------------------------------- /PickMeUp-Android/app/libs/org.eclipse.paho.client.mqttv3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/app/libs/org.eclipse.paho.client.mqttv3.jar -------------------------------------------------------------------------------- /PickMeUp-Android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/user/dev/android-sdk-macosx/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/debug/res/values/google_maps_api.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | YOUR_KEY_HERE 18 | 19 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | LoginActivity 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | 22 | 26 | 27 | 33 | 36 | 39 | 40 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 54 | 55 | 57 | 58 | 60 | 61 | 65 | 66 | 71 | 72 | 74 | 75 | 77 | 78 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/bin/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 | 25 | 26 | 32 | 35 | 38 | 39 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 53 | 54 | 56 | 57 | 59 | 60 | 62 | 63 | 67 | 68 | 70 | 71 | 73 | 74 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/java/com/ibm/pickmeup/PickMeUpApplication.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | ******************************************************************************/ 13 | package com.ibm.pickmeup; 14 | 15 | import android.app.Application; 16 | import android.content.SharedPreferences; 17 | import android.graphics.Bitmap; 18 | import android.util.Log; 19 | 20 | import com.ibm.pickmeup.utils.Constants; 21 | 22 | import java.io.File; 23 | 24 | /** 25 | * PickMeUpApplication class is used to share global variables across Activities as well as setup 26 | * MQTT broker address and port number. This class gets executed before the main Activity 27 | */ 28 | public class PickMeUpApplication extends Application { 29 | 30 | private final static String TAG = PickMeUpApplication.class.getName(); 31 | private String driverName; 32 | private String driverId; 33 | private Bitmap driverPhoto; 34 | private Bitmap passengerPhoto; 35 | private String currentRunningActivity; 36 | 37 | @Override 38 | public void onCreate() { 39 | Log.d(TAG, ".onCreate() entered"); 40 | super.onCreate(); 41 | SharedPreferences settings = getSharedPreferences(Constants.SETTINGS, 0); 42 | SharedPreferences.Editor editor = settings.edit(); 43 | editor.putString(Constants.SETTINGS_MQTT_SERVER, "messagesight.demos.ibm.com"); 44 | editor.putString(Constants.SETTINGS_MQTT_PORT, "1883"); 45 | editor.commit(); 46 | 47 | // cleanup old voice chat messages 48 | File chatDirectory = this.getExternalFilesDir(null); 49 | for (File file : chatDirectory.listFiles()) { 50 | if (file.getName().contains(Constants.CHAT)) { 51 | Log.d(TAG, ".onCreate() - Cleaning up old voice chat messages - "+file.getName()); 52 | file.delete(); 53 | } 54 | } 55 | } 56 | 57 | public String getDriverName() { 58 | return this.driverName; 59 | } 60 | 61 | public void setDriverName(String name) { 62 | this.driverName = name; 63 | } 64 | 65 | public Bitmap getDriverPhoto() { 66 | return this.driverPhoto; 67 | } 68 | 69 | public void setDriverPhoto(Bitmap photo) { 70 | this.driverPhoto = photo; 71 | } 72 | 73 | public Bitmap getPassengerPhoto() { 74 | return this.passengerPhoto; 75 | } 76 | 77 | public void setPassengerPhoto(Bitmap photo) { 78 | this.passengerPhoto = photo; 79 | } 80 | 81 | public String getDriverId() { return this.driverId; } 82 | 83 | public void setDriverId(String driverId) { 84 | this.driverId = driverId; 85 | } 86 | 87 | public String getCurrentRunningActivity() { 88 | return currentRunningActivity; 89 | } 90 | 91 | public void setCurrentRunningActivity(String currentRunningActivity) { 92 | this.currentRunningActivity = currentRunningActivity; 93 | } 94 | 95 | public void setCurrentRunningActivityEmpty() { 96 | this.currentRunningActivity = null; 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/java/com/ibm/pickmeup/activities/ChatPrepActivity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | ******************************************************************************/ 13 | package com.ibm.pickmeup.activities; 14 | 15 | import android.app.Activity; 16 | import android.content.Intent; 17 | import android.content.SharedPreferences; 18 | import android.graphics.Bitmap; 19 | import android.os.Bundle; 20 | import android.provider.MediaStore; 21 | import android.util.Log; 22 | import android.view.View; 23 | import android.view.Window; 24 | import android.widget.Button; 25 | import android.widget.ImageView; 26 | import android.widget.TextView; 27 | 28 | import com.ibm.pickmeup.PickMeUpApplication; 29 | import com.ibm.pickmeup.R; 30 | import com.ibm.pickmeup.utils.Constants; 31 | import com.ibm.pickmeup.utils.MessageFactory; 32 | import com.ibm.pickmeup.utils.MqttHandler; 33 | import com.ibm.pickmeup.utils.TopicFactory; 34 | 35 | public class ChatPrepActivity extends Activity { 36 | 37 | private final static String TAG = ChatPrepActivity.class.getName(); 38 | private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 1; 39 | private ImageView cameraButton; 40 | 41 | @Override 42 | protected void onCreate(Bundle savedInstanceState) { 43 | Log.d(TAG, ".onCreate() entered"); 44 | 45 | super.onCreate(savedInstanceState); 46 | 47 | // hide the Action bar 48 | getWindow().requestFeature(Window.FEATURE_ACTION_BAR); 49 | if (getActionBar() != null) { 50 | getActionBar().hide(); 51 | } 52 | setContentView(R.layout.activity_chat_prep); 53 | 54 | // initialise 55 | initChatPrepActivity(); 56 | } 57 | 58 | /** 59 | * Initialising onscreen elements 60 | */ 61 | private void initChatPrepActivity() { 62 | Log.d(TAG, ".initChatPrepActivity() entered"); 63 | 64 | // get passenger name from the preferences 65 | SharedPreferences settings = getSharedPreferences(Constants.SETTINGS, 0); 66 | TextView name = (TextView) findViewById(R.id.passengerName); 67 | name.setText(settings.getString(Constants.SETTINGS_NAME, "")); 68 | 69 | // setup camera button for taking a selfie 70 | cameraButton = (ImageView) findViewById(R.id.selfieButton); 71 | cameraButton.setOnClickListener(new View.OnClickListener() { 72 | @Override 73 | public void onClick(View v) { 74 | 75 | //snapping a picture using an existing default camera app 76 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 77 | if (intent.resolveActivity(getPackageManager()) != null) { 78 | startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); 79 | } 80 | } 81 | }); 82 | 83 | // setup continue button 84 | Button button = (Button) findViewById(R.id.pickmeupButton); 85 | button.setOnClickListener(new View.OnClickListener() { 86 | @Override 87 | public void onClick(View v) { 88 | // move to the next screen 89 | Intent searchDriverIntent = new Intent(getApplicationContext(), SearchDriversActivity.class); 90 | startActivity(searchDriverIntent); 91 | } 92 | }); 93 | } 94 | 95 | @Override 96 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 97 | Log.d(TAG, ".onActivityResult() entered"); 98 | if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK) { 99 | Log.d(TAG, ".onActivityResult() - Result code is OK"); 100 | 101 | // getting selfie bitmap 102 | Bundle extras = data.getExtras(); 103 | Bitmap imageBitmap = (Bitmap) extras.get(Constants.DATA); 104 | 105 | // scaling selfie to 256x256 106 | Bitmap passengerSelfie = Bitmap.createScaledBitmap(imageBitmap, 256, 256, true); 107 | if (cameraButton == null) { 108 | cameraButton = (ImageView) findViewById(R.id.selfieButton); 109 | } 110 | 111 | // setting selfie to the camera button 112 | cameraButton.setAdjustViewBounds(false); 113 | cameraButton.setScaleType(ImageView.ScaleType.FIT_CENTER); 114 | cameraButton.setImageBitmap(passengerSelfie); 115 | 116 | // recording selfie bitmap in memory for other activities to use 117 | PickMeUpApplication app = (PickMeUpApplication) getApplication(); 118 | app.setPassengerPhoto(passengerSelfie); 119 | 120 | // making the continue button visible 121 | Button continueButton = (Button) findViewById(R.id.pickmeupButton); 122 | continueButton.setVisibility(View.VISIBLE); 123 | } 124 | } 125 | 126 | @Override 127 | public void onBackPressed() { 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/java/com/ibm/pickmeup/activities/DriverArrivedActivity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | ******************************************************************************/ 13 | package com.ibm.pickmeup.activities; 14 | 15 | import android.app.Activity; 16 | import android.graphics.Bitmap; 17 | import android.graphics.BitmapFactory; 18 | import android.os.Bundle; 19 | import android.util.Log; 20 | import android.view.Window; 21 | import android.widget.ImageView; 22 | import android.widget.TextView; 23 | 24 | import com.ibm.pickmeup.PickMeUpApplication; 25 | import com.ibm.pickmeup.R; 26 | 27 | public class DriverArrivedActivity extends Activity { 28 | 29 | private final static String TAG = DriverArrivedActivity.class.getName(); 30 | 31 | @Override 32 | protected void onCreate(Bundle savedInstanceState) { 33 | Log.d(TAG, ".onCreate() entered"); 34 | 35 | super.onCreate(savedInstanceState); 36 | 37 | // hide the Action bar 38 | getWindow().requestFeature(Window.FEATURE_ACTION_BAR); 39 | if (getActionBar() != null) { 40 | getActionBar().hide(); 41 | } 42 | 43 | setContentView(R.layout.activity_driver_arrived); 44 | 45 | // initialse 46 | initDriverArrivedActivity(); 47 | } 48 | 49 | /** 50 | * Initialising onscreen elements 51 | */ 52 | private void initDriverArrivedActivity() { 53 | Log.d(TAG, ".initDriverArrivedActivity() entered"); 54 | 55 | PickMeUpApplication app = (PickMeUpApplication) getApplication(); 56 | 57 | // setting driver name 58 | TextView driverName = (TextView) findViewById(R.id.driverArrivedName); 59 | driverName.setText(app.getDriverName()); 60 | 61 | // setting driver picture 62 | ImageView picture = (ImageView) findViewById(R.id.driverArrivedPhoto); 63 | Bitmap driverPhoto = app.getDriverPhoto(); 64 | if (driverPhoto == null) { 65 | driverPhoto = BitmapFactory.decodeResource(getResources(), R.drawable.ic_user); 66 | } 67 | picture.setImageBitmap(driverPhoto); 68 | } 69 | 70 | @Override 71 | public void onBackPressed() { 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/java/com/ibm/pickmeup/activities/LoginActivity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | ******************************************************************************/ 13 | package com.ibm.pickmeup.activities; 14 | 15 | import android.app.Activity; 16 | import android.content.Context; 17 | import android.content.Intent; 18 | import android.content.SharedPreferences; 19 | import android.os.Bundle; 20 | import android.util.Log; 21 | import android.view.View; 22 | import android.view.Window; 23 | import android.widget.Button; 24 | import android.widget.TextView; 25 | import android.widget.Toast; 26 | 27 | import com.ibm.pickmeup.R; 28 | import com.ibm.pickmeup.utils.Constants; 29 | import com.ibm.pickmeup.utils.LocationUtils; 30 | 31 | public class LoginActivity extends Activity { 32 | 33 | private final static String TAG = LoginActivity.class.getName(); 34 | private Context context; 35 | private TextView name; 36 | private SharedPreferences settings; 37 | 38 | @Override 39 | protected void onCreate(Bundle savedInstanceState) { 40 | Log.d(TAG, ".onCreate() entered"); 41 | 42 | super.onCreate(savedInstanceState); 43 | 44 | // hide the Action bar 45 | getWindow().requestFeature(Window.FEATURE_ACTION_BAR); 46 | if (getActionBar() != null) { 47 | getActionBar().hide(); 48 | } 49 | 50 | setContentView(R.layout.activity_login); 51 | } 52 | 53 | @Override 54 | protected void onResume() { 55 | Log.d(TAG, ".onResume() entered"); 56 | 57 | super.onResume(); 58 | 59 | // initialise 60 | initialiseLoginActivity(); 61 | 62 | // connect to location services 63 | LocationUtils.getInstance(context).connect(); 64 | } 65 | 66 | @Override 67 | protected void onDestroy() { 68 | Log.d(TAG, ".onDestroy() entered"); 69 | 70 | super.onDestroy(); 71 | 72 | // disconnect from location services 73 | LocationUtils.getInstance(context).disconnect(); 74 | } 75 | 76 | /** 77 | * Initialising onscreen elements and shared properties 78 | */ 79 | private void initialiseLoginActivity() { 80 | Log.d(TAG, ".initialiseLoginActivity() entered"); 81 | 82 | context = getApplicationContext(); 83 | settings = getSharedPreferences(Constants.SETTINGS, 0); 84 | 85 | // setting up the name input field 86 | name = (TextView) findViewById(R.id.loginName); 87 | name.setText(settings.getString(Constants.SETTINGS_NAME, "")); 88 | name.setBackgroundResource(R.drawable.edittext); 89 | 90 | Button button = (Button) findViewById(R.id.loginButton); 91 | button.setOnClickListener(new View.OnClickListener() { 92 | @Override 93 | public void onClick(View v) { 94 | handleOnLogin(); 95 | } 96 | }); 97 | } 98 | 99 | /** 100 | * Method to handle passenger name on login and start serching for available drivers 101 | */ 102 | private void handleOnLogin() { 103 | Log.d(TAG, ".handleOnLogin() entered"); 104 | 105 | String passengerName = name.getText().toString(); 106 | // check if name is empty 107 | if (name.getText() == null || name.getText().length() == 0) { 108 | Log.d(TAG, ".handleOnLogin() - Passenger name was left empty"); 109 | Toast.makeText(context, R.string.name_not_specified, Toast.LENGTH_LONG).show(); 110 | } else { 111 | Log.d(TAG, ".handleOnLogin() - Passenger name is "+passengerName); 112 | 113 | // save passenger name to shared preferences 114 | SharedPreferences.Editor editor = settings.edit(); 115 | editor.putString(Constants.SETTINGS_NAME, passengerName); 116 | editor.commit(); 117 | 118 | // start next activity 119 | prepareProfile(); 120 | } 121 | } 122 | 123 | /** 124 | * Starts next activity 125 | */ 126 | private void prepareProfile() { 127 | Log.d(TAG, ".searchForDrivers() entered"); 128 | // call next activity 129 | Intent chatPrepIntent = new Intent(context, ChatPrepActivity.class); 130 | startActivity(chatPrepIntent); 131 | } 132 | 133 | @Override 134 | public void onBackPressed() { 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/java/com/ibm/pickmeup/activities/SearchDriversActivity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | ******************************************************************************/ 13 | package com.ibm.pickmeup.activities; 14 | 15 | import android.app.Activity; 16 | import android.content.BroadcastReceiver; 17 | import android.content.Context; 18 | import android.content.Intent; 19 | import android.content.IntentFilter; 20 | import android.os.Bundle; 21 | import android.util.Log; 22 | import android.view.Window; 23 | 24 | import com.ibm.pickmeup.R; 25 | import com.ibm.pickmeup.dialogs.ErrorDialog; 26 | import com.ibm.pickmeup.utils.Constants; 27 | import com.ibm.pickmeup.utils.MessageFactory; 28 | import com.ibm.pickmeup.utils.MqttHandler; 29 | import com.ibm.pickmeup.utils.TopicFactory; 30 | 31 | public class SearchDriversActivity extends Activity { 32 | 33 | private final static String TAG = SearchDriversActivity.class.getName(); 34 | private BroadcastReceiver connectivityReceiver; 35 | 36 | @Override 37 | protected void onCreate(Bundle savedInstanceState) { 38 | Log.d(TAG, ".onCreate() entered"); 39 | super.onCreate(savedInstanceState); 40 | 41 | // hide action bar 42 | getWindow().requestFeature(Window.FEATURE_ACTION_BAR); 43 | if (getActionBar() != null) { 44 | getActionBar().hide(); 45 | } 46 | 47 | setContentView(R.layout.activity_search_drivers); 48 | } 49 | 50 | @Override 51 | protected void onResume() { 52 | Log.d(TAG, ".onResume() entered"); 53 | super.onResume(); 54 | 55 | //register receivers 56 | registerReceivers(); 57 | 58 | //connect to MQTT broker 59 | connectToMqtt(); 60 | } 61 | 62 | @Override 63 | protected void onPause() { 64 | super.onPause(); 65 | 66 | // unregister connectivityReceiver 67 | unregisterReceivers(); 68 | } 69 | 70 | /** 71 | * Message to initiate an MQTT connection 72 | */ 73 | private void connectToMqtt() { 74 | Log.d(TAG, ".connectToMqtt() entered"); 75 | // grab hold of MqttHandler to connect to the server 76 | MqttHandler.getInstance(this).connect(); 77 | } 78 | 79 | /** 80 | * Create and register connectivityReceiver 81 | */ 82 | private void registerReceivers() { 83 | 84 | // create connectivityReceiver if it doesn't exist 85 | if (connectivityReceiver == null) { 86 | Log.d(TAG, ".onResume() - Registering connectivityReceiver"); 87 | connectivityReceiver = new BroadcastReceiver() { 88 | 89 | @Override 90 | public void onReceive(Context context, Intent intent) { 91 | Log.d(TAG, ".onReceive() - Received intent for connectivityReceiver"); 92 | if (intent.getIntExtra(Constants.CONNECTIVITY_MESSAGE, -1) == Constants.ERROR_BROKER_UNAVAILABLE) { 93 | // the connection was unsuccessful - show the error dialog to the user 94 | ErrorDialog dialog = new ErrorDialog(); 95 | dialog.setCancelable(false); 96 | dialog.show(getFragmentManager(), ""); 97 | } 98 | } 99 | }; 100 | } 101 | 102 | // register connectivityReceiver 103 | getApplicationContext().registerReceiver(connectivityReceiver, 104 | new IntentFilter(Constants.ACTION_INTENT_CONNECTIVITY_MESSAGE_RECEIVED)); 105 | } 106 | 107 | /** 108 | * Unregister all local BroadcastReceivers 109 | */ 110 | private void unregisterReceivers() { 111 | Log.d(TAG, ".unregisterReceivers() entered"); 112 | if (connectivityReceiver != null) { 113 | getApplicationContext().unregisterReceiver(connectivityReceiver); 114 | connectivityReceiver = null; 115 | } 116 | } 117 | 118 | @Override 119 | public void onBackPressed() { 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/java/com/ibm/pickmeup/dialogs/ErrorDialog.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | ******************************************************************************/ 13 | package com.ibm.pickmeup.dialogs; 14 | 15 | import android.app.Activity; 16 | import android.app.AlertDialog; 17 | import android.app.Dialog; 18 | import android.app.DialogFragment; 19 | import android.content.DialogInterface; 20 | import android.os.Bundle; 21 | import android.util.Log; 22 | 23 | import com.ibm.pickmeup.R; 24 | import com.ibm.pickmeup.utils.MqttHandler; 25 | 26 | /** 27 | * ErrorDialog is a dialog that displays an error message when the client cannot connect to the 28 | * MQTT broker. The dialog will offer the user to go to the previous screen (Exit) or retry 29 | * connecting to the server (Retry) 30 | */ 31 | 32 | public class ErrorDialog extends DialogFragment { 33 | 34 | private static final String TAG = ErrorDialog.class.getName(); 35 | private Activity currentActivity; 36 | 37 | @Override 38 | public Dialog onCreateDialog(Bundle savedInstanceState) { 39 | Log.d(TAG, ".onCreateDialog() entered"); 40 | 41 | // get hold of the current activity 42 | currentActivity = getActivity(); 43 | 44 | // Use the Builder class for convenient dialog construction 45 | AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 46 | builder.setMessage(R.string.broker_unavailable_check_connectivity) 47 | .setPositiveButton(R.string.retry, 48 | new DialogInterface.OnClickListener() { 49 | public void onClick(DialogInterface dialog, 50 | int id) { 51 | Log.d(TAG, ".onClick() entered - retry button"); 52 | 53 | // attempt to reconnect 54 | MqttHandler.getInstance(currentActivity.getApplicationContext()).connect(); 55 | } 56 | } 57 | ).setNegativeButton(R.string.exit, 58 | new DialogInterface.OnClickListener() { 59 | public void onClick(DialogInterface dialog, 60 | int id) { 61 | Log.d(TAG, ".onClick() entered - exit button"); 62 | 63 | // go back to the previous screen 64 | currentActivity.finish(); 65 | } 66 | } 67 | ); 68 | 69 | return builder.create(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/java/com/ibm/pickmeup/utils/ChatUtils.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | ******************************************************************************/ 13 | package com.ibm.pickmeup.utils; 14 | 15 | import android.content.Context; 16 | import android.content.Intent; 17 | import android.util.Log; 18 | 19 | import com.ibm.pickmeup.PickMeUpApplication; 20 | import com.ibm.pickmeup.activities.ChatActivity; 21 | 22 | import java.util.ArrayList; 23 | import java.util.Iterator; 24 | import java.util.List; 25 | import java.util.concurrent.CopyOnWriteArrayList; 26 | 27 | /** 28 | * ChatUtils is used to create ChatMessages, save ChatMessages in a list to be displayed in a 29 | * chat window at a later stage (i.e. when the ChatActivity gets opened) or emit broadcasts to 30 | * ChatActivity to display chat messages if the activity is on the foreground. 31 | */ 32 | public class ChatUtils { 33 | private final static String TAG = ChatUtils.class.getName(); 34 | private static ChatUtils instance; 35 | private Context context; 36 | private PickMeUpApplication app; 37 | private List chatMessageList; 38 | 39 | private ChatUtils(Context context) { 40 | this.context = context; 41 | this.app = (PickMeUpApplication) context.getApplicationContext(); 42 | this.chatMessageList = new CopyOnWriteArrayList(); 43 | } 44 | 45 | public static ChatUtils getInstance(Context context) { 46 | Log.d(TAG, ".getInstance() entered"); 47 | if (instance == null) { 48 | instance = new ChatUtils(context); 49 | } 50 | return instance; 51 | } 52 | 53 | /** 54 | * Method to process a chat message string. If ChatActivity is in the foreground, this method 55 | * will send a broadcast to the activity to display the chat message. Alternatively the message 56 | * is added to the chatMessageList to be collected later. 57 | * 58 | * @param msg chat message string 59 | */ 60 | public void addTextMessageToChat(String msg) { 61 | Log.d(TAG, ".addTextMessageToChat() entered"); 62 | String runningActivity = app.getCurrentRunningActivity(); 63 | if (runningActivity != null && runningActivity.equals(ChatActivity.class.getName())) { 64 | // current running activity is ChatActivity 65 | Intent actionIntent = new Intent(Constants.ACTION_INTENT_CHAT_MESSAGE_PROCESSED); 66 | actionIntent.putExtra(Constants.DATA, msg); 67 | actionIntent.putExtra(Constants.FORMAT, Constants.TEXT); 68 | context.sendBroadcast(actionIntent); 69 | } else { 70 | // current running activity is not ChatActivity 71 | chatMessageList.add(msg); 72 | } 73 | } 74 | 75 | /** 76 | * Get chat message off the chatMessageList if there are any. This method will remove chat 77 | * messages off the chatMessageList while processing them 78 | * 79 | * @return messageListInstance list of messages collected from chatMessageList or null if none 80 | * were available 81 | */ 82 | public ArrayList getChatMessagesIfAny() { 83 | Log.d(TAG, ".getChatMessagesIfAny() entered"); 84 | if (chatMessageList.size() > 0) { 85 | ArrayList messageListInstance = new ArrayList(); 86 | for (String message : chatMessageList) { 87 | messageListInstance.add(message); 88 | // once we added the message to the messageListInstance we can remove it 89 | chatMessageList.remove(message); 90 | } 91 | return messageListInstance; 92 | } 93 | // no messages in the list - return null 94 | return null; 95 | } 96 | 97 | public enum ChatSenderType { 98 | PASSENGER, DRIVER 99 | } 100 | 101 | /** 102 | * ChatMessage class is a simple wrapper object around a chat string, sender type 103 | * (driver or passenger) and chat message type (text or voice) 104 | */ 105 | public class ChatMessage { 106 | 107 | private String message; 108 | private ChatSenderType type; 109 | private String chatMessageType; 110 | 111 | public ChatMessage(String chatMessage, ChatSenderType type, String chatMessageType) { 112 | this.type = type; 113 | this.message = chatMessage; 114 | this.chatMessageType = chatMessageType; 115 | } 116 | 117 | public String getMessage() { 118 | return this.message; 119 | } 120 | 121 | public ChatSenderType getSenderType() { 122 | return this.type; 123 | } 124 | 125 | public String getChatMessageType() { return this.chatMessageType; } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/java/com/ibm/pickmeup/utils/Constants.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | ******************************************************************************/ 13 | package com.ibm.pickmeup.utils; 14 | 15 | /** 16 | * Constants utils class 17 | */ 18 | public class Constants { 19 | 20 | public final static String APP_ID = "com.ibm.pickmeup"; 21 | 22 | public final static String SETTINGS_MQTT_SERVER = "messagesight.demos.ibm.com"; 23 | public final static String SETTINGS_MQTT_PORT = "1883"; 24 | public final static String SETTINGS_NAME = "name"; 25 | public final static String SETTINGS = APP_ID+".Settings"; 26 | 27 | public enum ActionStateStatus { 28 | CONNECTING, CONNECTED, DISCONNECTED, SUBSCRIBE, UNSIBSCRIBE, PUBLISH 29 | } 30 | 31 | public final static String PICK_ME_UP = "pickmeup/"; 32 | public final static String PASSENGER_HEAD_PREFIX = PICK_ME_UP+"passengers/"; 33 | public final static String REQUESTS_HEAD_PREFIX = PICK_ME_UP+"requests/"; 34 | public final static String DRIVER_HEAD_PREFIX = PICK_ME_UP+"drivers/"; 35 | public final static String INBOX = "inbox"; 36 | public final static String PICTURE = "picture"; 37 | public final static String PAYMENTS = "payments"; 38 | 39 | public final static String NAME = "name"; 40 | public final static String TRIP_START = "tripStart"; 41 | public final static String TRIP_END = "tripEnd"; 42 | public final static String TRIP_PROCESSED = "tripProcessed"; 43 | public final static String COST = "cost"; 44 | public final static String TIP = "tip"; 45 | public final static String RATING = "rating"; 46 | public final static String TIME = "time"; 47 | public final static String DISTANCE= "distance"; 48 | public final static String MILES= "mi"; 49 | public final static String CONNECTION_TIME = "connectionTime"; 50 | public final static String LONGITUDE = "lon"; 51 | public final static String LATITUDE = "lat"; 52 | public final static String LOCATION = "location"; 53 | public final static String TYPE = "type"; 54 | public final static String ACCEPT = "accept"; 55 | public final static String DRIVER_ID = "driverId"; 56 | public final static String PASSENGER_ID = "passengerId"; 57 | public final static String URL = "url"; 58 | public final static String CHAT = "chat"; 59 | public final static String FORMAT = "format"; 60 | public final static String DATA = "data"; 61 | public final static String TEXT = "text"; 62 | public final static String PAYMENT_TOTAL = "paymentTotal"; 63 | public final static String DRIVER_PICTURE = "driverPicture"; 64 | public final static String CONNECTIVITY_MESSAGE = "connectivityMessage"; 65 | public final static String ROUTE_MESSAGE_TYPE = "routeMessageType"; 66 | public final static String BASE64_PHOTO_PREFIX = "data:image/png;base64,"; 67 | 68 | public final static String ACTION_INTENT_DRIVER_ACCEPTED = Constants.APP_ID + "." + "DRIVER_ACCEPTED"; 69 | public final static String ACTION_INTENT_DRIVER_DETAILS_RECEIVED = Constants.APP_ID + "." + "DRIVER_DETAILS_RECEIVED"; 70 | public final static String ACTION_INTENT_DRIVER_DETAILS_UPDATE = Constants.APP_ID + "." + "DRIVER_DETAILS_UPDATE"; 71 | public final static String ACTION_INTENT_CHAT_MESSAGE_RECEIVED = Constants.APP_ID + "." + "CHAT_MESSAGE_RECEIVED"; 72 | public final static String ACTION_INTENT_CHAT_MESSAGE_PROCESSED = Constants.APP_ID + "." + "CHAT_MESSAGE_PROCESSED"; 73 | public final static String ACTION_INTENT_CONNECTIVITY_MESSAGE_RECEIVED = Constants.APP_ID + "." + "CONNECTIVITY_MESSAGE_RECEIVED"; 74 | public final static String ACTION_INTENT_COORDINATES_CHANGED = Constants.APP_ID + "." + "COORDINATES_CHANGED"; 75 | public final static String ACTION_INTENT_START_TRIP = Constants.APP_ID + "." + "START_TRIP"; 76 | public final static String ACTION_INTENT_END_TRIP = Constants.APP_ID + "." + "END_TRIP"; 77 | public final static String ACTION_INTENT_ROUTE_MESSAGE = Constants.APP_ID + "." + "ROUTER"; 78 | public final static String ACTION_INTENT_PAYMENT_RECEIVED = Constants.APP_ID + "." + "PAYMENT_RECEIVED"; 79 | 80 | public final static int LOCATION_MIN_TIME = 30000; 81 | public final static float LOCATION_MIN_DISTANCE = 5; 82 | public final static double DEFAULT_LATITUDE = 30.390361; 83 | public final static double DEFAULT_LONGITUDE = -97.7110845; 84 | 85 | public final static String AUDIO_FORMAT = ".3gp"; 86 | public final static String VOICE = "data:audio/wav;base64"; 87 | public final static String LOW_BEEP = "lowBeep"; 88 | public final static String HIGH_BEEP = "highBeep"; 89 | 90 | public final static int ERROR_BROKER_UNAVAILABLE = 3; 91 | } 92 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/java/com/ibm/pickmeup/utils/TopicFactory.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | ******************************************************************************/ 13 | package com.ibm.pickmeup.utils; 14 | 15 | import android.content.Context; 16 | import android.content.SharedPreferences; 17 | 18 | import com.ibm.pickmeup.PickMeUpApplication; 19 | 20 | /** 21 | * TopicFactory is a utils class that generates topic strings according to the Constants 22 | */ 23 | public class TopicFactory { 24 | 25 | private static TopicFactory instance; 26 | private SharedPreferences settings; 27 | private PickMeUpApplication app; 28 | 29 | public static TopicFactory getInstance(Context context) { 30 | if (instance == null) { 31 | instance = new TopicFactory(context); 32 | } 33 | return instance; 34 | } 35 | 36 | private TopicFactory(Context context) { 37 | settings = context.getSharedPreferences(Constants.SETTINGS, 0); 38 | app = (PickMeUpApplication) context.getApplicationContext(); 39 | } 40 | 41 | public String getPassengerPhotoTopic() { 42 | return Constants.PASSENGER_HEAD_PREFIX+getPassengerId()+"/"+Constants.PICTURE; 43 | } 44 | 45 | public String getPassengerInboxTopic() { 46 | return Constants.PASSENGER_HEAD_PREFIX+getPassengerId()+"/"+Constants.INBOX; 47 | } 48 | 49 | public String getPassengerTopLevelTopic() { 50 | return Constants.PASSENGER_HEAD_PREFIX+getPassengerId(); 51 | } 52 | 53 | public String getPassengerChatTopic() { 54 | return Constants.PASSENGER_HEAD_PREFIX + getPassengerId() + "/" + Constants.CHAT; 55 | } 56 | 57 | public String getPassengerLocationTopic() { 58 | return Constants.PASSENGER_HEAD_PREFIX + getPassengerId() + "/" + Constants.LOCATION; 59 | } 60 | 61 | public String getPassengerPaymentTopic() { 62 | return Constants.PICK_ME_UP + Constants.PAYMENTS; 63 | } 64 | 65 | public String getParingTopic() { 66 | return Constants.REQUESTS_HEAD_PREFIX +getPassengerId(); 67 | } 68 | 69 | public String getDriverTopLevelTopic() { 70 | return Constants.DRIVER_HEAD_PREFIX + getDriverId(); 71 | } 72 | 73 | public String getDriverPhotoTopic() { 74 | return Constants.DRIVER_HEAD_PREFIX + getDriverId() + "/" + Constants.PICTURE; 75 | } 76 | 77 | public String getDriverChatTopic() { 78 | return Constants.DRIVER_HEAD_PREFIX + getDriverId() + "/" + Constants.CHAT; 79 | } 80 | 81 | public String getDriverLocationTopic() { 82 | return Constants.DRIVER_HEAD_PREFIX + getDriverId() + "/" + Constants.LOCATION; 83 | } 84 | 85 | private String getDriverId() { 86 | return app.getDriverId(); 87 | } 88 | 89 | private String getPassengerId() { 90 | return settings.getString(Constants.SETTINGS_NAME, ""); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/drawable-xxhdpi/edittext.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 12 | 13 | 14 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_map.png -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_microphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_microphone.png -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_microphone_recording.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_microphone_recording.png -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_person.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_person.png -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_photo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_photo.png -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_play.png -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_selfie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_selfie.png -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_send.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_send.png -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_action_user.png -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_driver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_driver.png -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_passenger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_passenger.png -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mqtt-PickMeUp/8116e9c39a51988e04c3c6eb477f59bfb879d903/PickMeUp-Android/app/src/main/res/drawable-xxhdpi/ic_user.png -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/drawable-xxhdpi/map_details.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/drawable-xxhdpi/round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/layout/activity_chat.xml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 18 | 19 | 27 | 28 | 40 | 41 | 49 | 50 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /PickMeUp-Android/app/src/main/res/layout/activity_chat_prep.xml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 21 | 22 | 28 | 29 | 36 | 37 | 42 | 43 | 44 | 52 | 53 |