|
1 | | -# Apporio-Tracking-System |
| 1 | +# ATS (Apporio Tracking System) |
| 2 | + |
| 3 | +[](https://www.apporio.com) |
| 4 | + |
| 5 | +Ats is a universal solution for the developer that is a basic need of creating taxi like application. This Library basically separates three main part related to tracking based application |
| 6 | + |
| 7 | + - ###### Tracking For a particualr device or multiple device over a single screen |
| 8 | + - ###### Service for fetching location |
| 9 | + - ###### Trip Settlement |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +### Implementation in Android |
| 15 | +- #### Step One |
| 16 | + Create you developer account and obtain App Id for the library to work [plugins/dropbox/README.md][PlDb] |
| 17 | + |
| 18 | +- #### Step Two |
| 19 | + Add jitpack server in youe project level .gradle file |
| 20 | + ```sh |
| 21 | + allprojects { |
| 22 | + repositories { |
| 23 | + ... |
| 24 | + maven { url 'https://jitpack.io' } |
| 25 | + } |
| 26 | + } |
| 27 | + ``` |
| 28 | +
|
| 29 | + In app level gradle add the implementation |
| 30 | + ```sh |
| 31 | + implementation 'com.github.User:Repo:1.0.5' |
| 32 | + ``` |
| 33 | + Allow follwing permission in order to connect your app wtih socket server and fetching location. |
| 34 | + ```sh |
| 35 | + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> |
| 36 | + <uses-permission android:name="android.permission.INTERNET" /> |
| 37 | + ``` |
| 38 | +
|
| 39 | +- #### Step Three |
| 40 | + In Your Main Application Class (Initial setup) |
| 41 | + ```sh |
| 42 | + ATS.startInit(this).setAppId("APP_ID_OBTAINED_IN_STEP_ONE") |
| 43 | + .fetchLocationWhenVehicleIsStop(false) |
| 44 | + .enableLogs(true) |
| 45 | + .setLocationInterval(6000) |
| 46 | + .setDeveloperMode(true) |
| 47 | + .setNotificationTittle("APPLICATION_NAME") |
| 48 | + .setNotificationContent("CONTENT WHEN NOTIFICATION IS SHOWING WHILE FETCHING LOCATION") |
| 49 | + .setConnectedStateColor(Color.argb(0, 102, 0 , 204)) |
| 50 | + .setDisconnectedColor(Color.argb(0 , 255, 255, 102)) |
| 51 | + .setSocketEndPoint("NA") |
| 52 | + .setNotificationIcon(R.drawable.samll_notification_icon) |
| 53 | + .init(); |
| 54 | + ``` |
| 55 | +
|
| 56 | + |
| 57 | +
|
| 58 | + |
| 59 | + | Method | Description | |
| 60 | + | ------ | ------ | |
| 61 | + | fetchLocationWhenVehicleIsStop(boolean value) | There are some situation where device stop emiting location when device(vehicle) is on same place (device generally do this in order to save battery). This library stores the last location in cashe and execute a different background thread that emit last saved location as per the configuread interval | |
| 62 | + | enableLogs(boolean value) | ATS lib itself has own log mechanism , you can enable or disable it. Search "ATS:" in logact that will throw only. | |
| 63 | + | setLocationInterval(int value) - in miliseconds | This will be the minimum time of interval for fetching location, it is recomended not to set less than 6 sec in order to save battery and internet usage | |
| 64 | + | setDeveloperMode(boolean value) | There are lots of things going inside the library like fetching of location, creation of location stack and auto-synchronisation of stack. If developer mode is true you can visualise all things hapenning inside the library. This is usefull while the field testing like if you needs to know weather device is fetching location or not, location service is running or not , device is connected to server or not , app foregorund status and battery status. | |
| 65 | + | setNotificationTittle(String title) | This works only in live mode of library. As per google service guidline it is mandatory to show a notification in status bar if you running a service for long time. eg. Like in taxi application you can set "Driver Name or application name" | |
| 66 | + | setNotificationContent(String title) | This works only in live mode of library. e.g. in taxi like application you can set "Driver is on duty now." | |
| 67 | + | .setConnectedStateColor(int args) .setDisconnectedColor(int args) | Library has two color for the background of notification showing in status bar. One when device is conncted to the server and one when it is disconnected. default color is green when device is connected and red when it is disconnected. you can set any colo here according to you applicaiton theme | |
| 68 | + | setNotificationIcon(int icon) | This is just for setting icon when location service is running to show in status bar | |
| 69 | + | .setSocketEndPoint(String endpoint) | By defualt after applying app id the application will get connect to the defualt server of application, but if you have server code as well you deploy it on any cloud instance and connect with that server by using this method | |
| 70 | +
|
| 71 | +
|
| 72 | +
|
| 73 | +
|
| 74 | +
|
| 75 | +- #### Step Four |
| 76 | + Set your listeners and tag for tracking, methods list are as follows |
| 77 | + ###### getAtsid() |
| 78 | + ```sh |
| 79 | + ATS.getAtsid(); // unique id that will be sync over you backend |
| 80 | + ``` |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + ###### enableLogs(boolean value) |
| 88 | + ```sh |
| 89 | + ATS.enableLogs(true); // enable disable library logs |
| 90 | + ``` |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | + ###### setTag(String tag, AtsOnTagSetListener atsOnTagSetListener) |
| 99 | + ```sh |
| 100 | + ATS.setTag("AAAA", new AtsOnTagSetListener() { |
| 101 | + @Override |
| 102 | + public void onSuccess(String message) { |
| 103 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); } |
| 104 | + @Override |
| 105 | + public void onFailed(String message) { Toast.makeText(MainActivity.this,""+message, Toast.LENGTH_SHORT).show(); } |
| 106 | + }); |
| 107 | + ``` |
| 108 | + |
| 109 | + ###### ATS.getTag() |
| 110 | + ```sh |
| 111 | + Toast.makeText(this, ""+ATS.getTag(), Toast.LENGTH_SHORT).show(); |
| 112 | + ``` |
| 113 | + |
| 114 | + ###### removeTag(AtsOnTagSetListener atsOnTagSetListener); |
| 115 | + ```sh |
| 116 | + ATS.removeTag(new AtsOnTagSetListener() { |
| 117 | + @Override |
| 118 | + public void onSuccess(String message) { |
| 119 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 120 | + } |
| 121 | + @Override |
| 122 | + public void onFailed(String message) { |
| 123 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 124 | + } |
| 125 | + }); |
| 126 | + ``` |
| 127 | + |
| 128 | + ###### startListeningAtsID(String targetAtsIdToListen, AtsOnAddMessageListener atsOnAddMessageListener) |
| 129 | + ```sh |
| 130 | + ATS.startListeningAtsID(""+TEST_ATS_ID,new AtsOnAddMessageListener() { |
| 131 | + @Override |
| 132 | + public void onRegistrationSuccess(String message) { |
| 133 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 134 | + } |
| 135 | + @Override |
| 136 | + public void onRegistrationFailed(String message) { |
| 137 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 138 | + } |
| 139 | + @Override |
| 140 | + public void onMessage(String message) { |
| 141 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 142 | + } |
| 143 | + }); |
| 144 | + ``` |
| 145 | + |
| 146 | + ###### stopListeningAtsId(String targetAtsIdToRemove , AtsOnRemoveMessageListener atsOnRemoveMessageListener) |
| 147 | + ```sh |
| 148 | + ATS.stopListeningAtsId(""+TEST_ATS_ID, new AtsOnRemoveMessageListener() { |
| 149 | + @Override |
| 150 | + public void onRemoveSuccess(String message) { |
| 151 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 152 | + } |
| 153 | +
|
| 154 | + @Override |
| 155 | + public void onRemoveFailed(String message) { |
| 156 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 157 | + } |
| 158 | + }); |
| 159 | + ``` |
| 160 | + |
| 161 | + ###### removeAllListeners(AtsOnRemoveMessageListener atsOnRemoveMessageListener) |
| 162 | + ```sh |
| 163 | + ATS.removeAllListeners(new AtsOnRemoveMessageListener() { |
| 164 | + @Override |
| 165 | + public void onRemoveSuccess(String message) { |
| 166 | + LOGS.e(TAG , ""+message); |
| 167 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 168 | + } |
| 169 | + @Override |
| 170 | + public void onRemoveFailed(String message) { |
| 171 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 172 | + } |
| 173 | + }); |
| 174 | + ``` |
| 175 | + |
| 176 | + ###### listenTagAccordingToRadius(String tag, double latitude, double longitude, int radiusInMeter, AtsTagListener atsTagListener) |
| 177 | + |
| 178 | + ```sh |
| 179 | + ATS.listenTagAccordingToRadius("AAAA", 28.411827, 77.042085, 5000, new AtsTagListener() { |
| 180 | + @Override |
| 181 | + public void onSuccess(String message) { |
| 182 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 183 | + } |
| 184 | +
|
| 185 | + @Override |
| 186 | + public void onFailed(String message) { |
| 187 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 188 | + } |
| 189 | +
|
| 190 | + @Override |
| 191 | + public void onAdd(String message) { |
| 192 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 193 | + } |
| 194 | +
|
| 195 | + @Override |
| 196 | + public void onChange(String message) { |
| 197 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 198 | + } |
| 199 | + @Override |
| 200 | + public void onRemove(String message) { |
| 201 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 202 | + } |
| 203 | + }); |
| 204 | + ``` |
| 205 | + |
| 206 | + ###### stopListeningTag(AtsOnTagSetListener atsOnTagSetListener) |
| 207 | + ```sh |
| 208 | + ATS.stopListeningTag(new AtsOnTagSetListener() { |
| 209 | + @Override |
| 210 | + public void onSuccess(String message) { |
| 211 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 212 | + } |
| 213 | + @Override |
| 214 | + public void onFailed(String message) { |
| 215 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 216 | + } |
| 217 | + }); |
| 218 | + ``` |
| 219 | + |
| 220 | + ###### startTrip(String tripIdentifier , AtsOnTripSetListener atsOnTripSetListener) |
| 221 | + ```sh |
| 222 | + ATS.startTrip("TRIP_ID_TWO", new AtsOnTripSetListener() { |
| 223 | + @Override |
| 224 | + public void onSuccess(String message) { |
| 225 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 226 | + } |
| 227 | +
|
| 228 | + @Override |
| 229 | + public void onFailed(String message) { |
| 230 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 231 | + } |
| 232 | + }); |
| 233 | + ``` |
| 234 | + |
| 235 | + ###### endTrip(String tripIdentifier, AtsOnTripSetListener atsOnTripSetListener) |
| 236 | + ```sh |
| 237 | + ATS.endTrip("TRIP_ID_TWO", new AtsOnTripSetListener() { |
| 238 | + @Override |
| 239 | + public void onSuccess(String message) { |
| 240 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 241 | + } |
| 242 | +
|
| 243 | + @Override |
| 244 | + public void onFailed(String message) { |
| 245 | + Toast.makeText(MainActivity.this, ""+message, Toast.LENGTH_SHORT).show(); |
| 246 | + } |
| 247 | + }); |
| 248 | + ``` |
0 commit comments