-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bus Tracking App. Developed model. Initial Commit
- Loading branch information
0 parents
commit 84eef6e
Showing
39 changed files
with
1,376 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion "25.0.2" | ||
defaultConfig { | ||
applicationId "com.vuedata.bustrackingapp" | ||
minSdkVersion 16 | ||
targetSdkVersion 25 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
multiDexEnabled true | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | ||
exclude group: 'com.android.support', module: 'support-annotations' | ||
}) | ||
compile 'com.android.support:appcompat-v7:25.1.0' | ||
compile 'com.google.firebase:firebase-database:10.0.1' | ||
compile 'com.google.firebase:firebase-auth:10.0.1' | ||
compile 'com.google.android.gms:play-services:10.0.1' | ||
testCompile 'junit:junit:4.12' | ||
} | ||
|
||
|
||
|
||
|
||
apply plugin: 'com.google.gms.google-services' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"project_info": { | ||
"project_number": "497528739497", | ||
"firebase_url": "https://bustrackingapp-810c5.firebaseio.com", | ||
"project_id": "bustrackingapp-810c5", | ||
"storage_bucket": "bustrackingapp-810c5.appspot.com" | ||
}, | ||
"client": [ | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:497528739497:android:a057bba46acd39af", | ||
"android_client_info": { | ||
"package_name": "com.vuedata.bustrackingapp" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "497528739497-32tldhp2hq9qph6ure0eevrnmaolhchj.apps.googleusercontent.com", | ||
"client_type": 1, | ||
"android_info": { | ||
"package_name": "com.vuedata.bustrackingapp", | ||
"certificate_hash": "C21C3436C9FEF8AA727807010099368D24AD674A" | ||
} | ||
}, | ||
{ | ||
"client_id": "497528739497-rl4eo7i8qa6hrdc6tu861rt7gsdl49th.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyBm2nMl1VVwo8bo00E7iS-S2RoXPhIRkzg" | ||
} | ||
], | ||
"services": { | ||
"analytics_service": { | ||
"status": 1 | ||
}, | ||
"appinvite_service": { | ||
"status": 2, | ||
"other_platform_oauth_client": [ | ||
{ | ||
"client_id": "497528739497-rl4eo7i8qa6hrdc6tu861rt7gsdl49th.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
] | ||
}, | ||
"ads_service": { | ||
"status": 2 | ||
} | ||
} | ||
} | ||
], | ||
"configuration_version": "1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in C:\Users\rakes\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
26 changes: 26 additions & 0 deletions
26
app/src/androidTest/java/com/vuedata/bustrackingapp/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.vuedata.bustrackingapp; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumentation test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() throws Exception { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.vuedata.bustrackingapp", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<resources> | ||
<!-- | ||
TODO: Before you run your application, you need a Google Maps API key. | ||
To get one, follow this link, follow the directions and press "Create" at the end: | ||
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=C2:1C:34:36:C9:FE:F8:AA:72:78:07:01:00:99:36:8D:24:AD:67:4A%3Bcom.vuedata.bustrackingapp | ||
You can also add your credentials to an existing key, using this line: | ||
C2:1C:34:36:C9:FE:F8:AA:72:78:07:01:00:99:36:8D:24:AD:67:4A;com.vuedata.bustrackingapp | ||
Alternatively, follow the directions here: | ||
https://developers.google.com/maps/documentation/android/start#get-key | ||
Once you have your key (it starts with "AIza"), replace the "google_maps_key" | ||
string in this file. | ||
--> | ||
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false"> | ||
AIzaSyC5Y3xe5iCnTeCxyPF-nzQmPj2j-KrZICU | ||
</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.vuedata.bustrackingapp"> | ||
|
||
<!-- | ||
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use | ||
Google Maps Android API v2, but you must specify either coarse or fine | ||
location permissions for the 'MyLocation' functionality. | ||
--> | ||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | ||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@drawable/icon" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".LoginActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".SearchBusActivity" /> | ||
<!-- | ||
The API key for Google Maps-based APIs is defined as a string resource. | ||
(See the file "res/values/google_maps_api.xml"). | ||
Note that the API key is linked to the encryption key used to sign the APK. | ||
You need a different API key for each encryption key, including the release key that is used to | ||
sign the APK for publishing. | ||
You can define the keys for the debug and release targets in src/debug/ and src/release/. | ||
--> | ||
<meta-data | ||
android:name="com.google.android.geo.API_KEY" | ||
android:value="@string/google_maps_key" /> | ||
|
||
<activity | ||
android:name=".TrackingActivity" | ||
android:label="@string/title_activity_tracking" /> | ||
<!-- | ||
ATTENTION: This was auto-generated to add Google Play services to your project for | ||
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information. | ||
--> | ||
<meta-data | ||
android:name="com.google.android.gms.version" | ||
android:value="@integer/google_play_services_version" /> | ||
|
||
<activity android:name=".SearchGoogleApiActivity"></activity> | ||
</application> | ||
|
||
</manifest> |
156 changes: 156 additions & 0 deletions
156
app/src/main/java/com/vuedata/bustrackingapp/LocationFinder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
// Calling Google Transit API | ||
|
||
package com.vuedata.bustrackingapp; | ||
|
||
import android.os.AsyncTask; | ||
import android.util.Log; | ||
|
||
import com.google.android.gms.maps.model.LatLng; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.io.UnsupportedEncodingException; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.net.URLEncoder; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Created by Maz Vuedata on 14-02-2017. | ||
*/ | ||
|
||
public class LocationFinder { | ||
|
||
private static final String DIRECTION_URL_API = "https://maps.googleapis.com/maps/api/directions/json?"; | ||
private static final String GOOGLE_API_KEY = "AIzaSyC5Y3xe5iCnTeCxyPF-nzQmPj2j-KrZICU"; | ||
private static final String TAG = SearchGoogleApiActivity.class.getName(); | ||
private LocationFinderListener listener; | ||
private String origin; | ||
private String destination; | ||
|
||
public LocationFinder(LocationFinderListener listener, String origin, String destination) { | ||
this.listener = listener; | ||
this.origin = origin; | ||
this.destination = destination; | ||
} | ||
|
||
// Control comes here from SearchGoogle API activity | ||
public void execute() throws UnsupportedEncodingException { | ||
listener.onDirectionFinderStart();// If we want to do anything to notify the api call is started we can do it here. | ||
new DownloadRawData().execute(createUrl()); // API calling Begins here... Before that REST API URL is generated in the Create URL function | ||
} | ||
|
||
//This Fucntion creates the google Transit URL. It is a GET api. so we will send the origin and desitination from the front end and send it with url | ||
//also we have modified the url such that it returns transit route and only bus routes. ( trains and others are omiited) | ||
private String createUrl() throws UnsupportedEncodingException { | ||
String urlOrigin = URLEncoder.encode(origin, "utf-8"); | ||
String urlDestination = URLEncoder.encode(destination, "utf-8"); | ||
|
||
String a = DIRECTION_URL_API + "origin=" + urlOrigin + "&destination=" + urlDestination + "&mode=transit&transit_mode=bus&key=" + GOOGLE_API_KEY; | ||
return a; | ||
} | ||
|
||
// This class calls the Google API and downloads the response.. | ||
|
||
private void parseJSon(String data) throws JSONException { | ||
if (data == null) | ||
return; | ||
|
||
/* List<Route> routes = new ArrayList<Route>();*/ | ||
JSONObject jsonData = new JSONObject(data); | ||
JSONArray jsonRoutes = jsonData.getJSONArray("routes"); | ||
for (int i = 0; i < jsonRoutes.length(); i++) { | ||
JSONObject jsonRoute = jsonRoutes.getJSONObject(i); | ||
Route route = new Route(); | ||
|
||
JSONObject overview_polylineJson = jsonRoute.getJSONObject("overview_polyline"); | ||
JSONArray jsonLegs = jsonRoute.getJSONArray("legs"); | ||
JSONObject jsonLeg = jsonLegs.getJSONObject(0); | ||
JSONObject jsonDistance = jsonLeg.getJSONObject("distance"); | ||
JSONObject jsonDuration = jsonLeg.getJSONObject("duration"); | ||
JSONObject jsonEndLocation = jsonLeg.getJSONObject("end_location"); | ||
JSONObject jsonStartLocation = jsonLeg.getJSONObject("start_location"); | ||
|
||
JSONArray jsonSteps = jsonLeg.getJSONArray("steps"); | ||
for (int j = 0; j < jsonSteps.length(); j++) { | ||
JSONObject jsonstep = jsonSteps.getJSONObject(j); | ||
String jsonTravelMode = jsonstep.getString("travel_mode"); | ||
|
||
// Getting all the details of the bus and storing it in a class. | ||
|
||
if (jsonTravelMode.equals("TRANSIT")) { | ||
JSONObject jsonTransitDetails = jsonstep.getJSONObject("transit_details"); | ||
route.html_instructions = jsonstep.getString("html_instructions"); | ||
JSONObject departure = jsonTransitDetails.getJSONObject("departure_time"); | ||
route.departure_time = departure.getString("text"); | ||
JSONObject dep_point = jsonTransitDetails.getJSONObject("departure_stop"); | ||
route.dep_name = dep_point.getString("name"); | ||
JSONObject arr_point = jsonTransitDetails.getJSONObject("arrival_stop"); | ||
route.arr_name = arr_point.getString("name"); | ||
JSONObject jsonLine = jsonTransitDetails.getJSONObject("line"); | ||
route.short_name = jsonLine.getString("short_name"); | ||
listener.onDirectionFinderSuccess(route); //When everthing is done, On directionFinder Sucess function is called. | ||
} | ||
} | ||
/*route.distance = new Distance(jsonDistance.getString("text"), jsonDistance.getInt("value")); | ||
route.duration = new Duration(jsonDuration.getString("text"), jsonDuration.getInt("value")); | ||
route.endAddress = jsonLeg.getString("end_address"); | ||
route.startAddress = jsonLeg.getString("start_address"); | ||
route.startLocation = new LatLng(jsonStartLocation.getDouble("lat"), jsonStartLocation.getDouble("lng")); | ||
route.endLocation = new LatLng(jsonEndLocation.getDouble("lat"), jsonEndLocation.getDouble("lng")); | ||
route.points = decodePolyLine(overview_polylineJson.getString("points")); | ||
routes.add(route); */ | ||
} | ||
|
||
/*listener.onDirectionFinderSuccess(routes);*/ | ||
} | ||
|
||
// Its an async task and the process goes asynchorously in background. | ||
private class DownloadRawData extends AsyncTask<String, Void, String> { | ||
|
||
@Override | ||
protected String doInBackground(String... params) { | ||
String link = params[0]; | ||
try { | ||
URL url = new URL(link); | ||
InputStream is = url.openConnection().getInputStream(); | ||
StringBuffer buffer = new StringBuffer(); | ||
BufferedReader reader = new BufferedReader(new InputStreamReader(is)); | ||
|
||
String line; | ||
while ((line = reader.readLine()) != null) { | ||
buffer.append(line + "\n"); | ||
} | ||
|
||
return buffer.toString(); | ||
|
||
} catch (MalformedURLException e) { | ||
e.printStackTrace(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
return null; | ||
} | ||
|
||
|
||
// When API call is done here comes the control with The responsse. | ||
@Override | ||
protected void onPostExecute(String res) { | ||
Log.d(TAG, "Bus is: " + res); | ||
try { | ||
parseJSon(res); // We are calling parsing the JSON file received so that we can use it. | ||
} catch (JSONException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/vuedata/bustrackingapp/LocationFinderListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.vuedata.bustrackingapp; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by Maz Vuedata on 14-02-2017. | ||
*/ | ||
|
||
public interface LocationFinderListener { | ||
void onDirectionFinderStart(); | ||
|
||
void onDirectionFinderSuccess(Route route); | ||
} |
Oops, something went wrong.