├── .gitignore ├── README.md ├── app ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── rahul │ │ └── uberapi │ │ └── android │ │ └── demo │ │ ├── Constants.java │ │ ├── DemoActivity.java │ │ ├── EndpointActivity.java │ │ ├── MainActivity.java │ │ ├── api │ │ ├── UberAPIClient.java │ │ ├── UberAuthTokenClient.java │ │ └── UberCallback.java │ │ └── model │ │ ├── History.java │ │ ├── Location.java │ │ ├── PriceEstimate.java │ │ ├── PriceEstimateList.java │ │ ├── Product.java │ │ ├── ProductList.java │ │ ├── Profile.java │ │ ├── TimeEstimate.java │ │ ├── TimeEstimateList.java │ │ ├── UberModel.java │ │ ├── User.java │ │ └── UserActivity.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── layout │ ├── activity_list.xml │ └── activity_main.xml │ └── values │ └── strings.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── screenshots ├── UberAPI-Android-Demo-1.png ├── UberAPI-Android-Demo-2.png ├── UberAPI-Android-Demo-3.png ├── UberAPI-Android-Demo-4.png └── UberAPI-Android-Demo.png └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | local.properties 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio 30 | .idea 31 | *.iml -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | UberAPI-Android-Demo 2 | ==================== 3 | 4 | What Is This? 5 | ------------- 6 | 7 | This is a simple Android application intended to provide a working example of Uber's external API. It provides the same functionality as their [python sample code](https://github.com/uber/Python-Sample-Application). 8 | 9 | ![](screenshots/UberAPI-Android-Demo.png) 10 | 11 | How To Use This 12 | --------------- 13 | 14 | 1. Navigate over to https://developer.uber.com/, and sign up for an Uber developer account. 15 | 2. Register a new Uber application - `profile` and `history` OAuth scopes are required. 16 | 3. Fill in the relevant information in the AndroidManifest.xml file in the `app/src/main`. Add your client id, secret and redirect url in their respective `meta-data` elements. 17 | 3. Open the UberAPI-Android-Demo in Android Studio or build it from the command line using Gradle. 18 | 5. Run the app 19 | 20 | License 21 | ======= 22 | 23 | Copyright 2014 Rahul Parsani 24 | 25 | Licensed under the Apache License, Version 2.0 (the "License"); 26 | you may not use this file except in compliance with the License. 27 | You may obtain a copy of the License at 28 | 29 | http://www.apache.org/licenses/LICENSE-2.0 30 | 31 | Unless required by applicable law or agreed to in writing, software 32 | distributed under the License is distributed on an "AS IS" BASIS, 33 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 34 | See the License for the specific language governing permissions and 35 | limitations under the License. 36 | 37 | Library licenses 38 | ================ 39 | 40 | __retrofit-1.6.1__ is subject to the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html). 41 | More information on [the official web site](http://square.github.io/retrofit/). 42 | 43 | __appcompat-v7__ is subject to the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html). -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 20 5 | buildToolsVersion "20.0.0" 6 | 7 | defaultConfig { 8 | applicationId "com.rahul.uberapi.android.demo" 9 | minSdkVersion 8 10 | targetSdkVersion 20 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.android.support:appcompat-v7:20.0.0' 25 | compile 'com.squareup.retrofit:retrofit:1.6.1' 26 | } 27 | -------------------------------------------------------------------------------- /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 /home/rarp/android-sdk-linux/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 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 12 | 13 | 16 | 17 | 20 | 21 | 24 | 25 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 38 | 39 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/Constants.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo; 2 | 3 | import android.app.Activity; 4 | import android.content.pm.ApplicationInfo; 5 | import android.content.pm.PackageManager; 6 | import android.os.Bundle; 7 | 8 | import com.google.gson.Gson; 9 | import com.google.gson.GsonBuilder; 10 | 11 | import java.util.HashMap; 12 | 13 | public class Constants { 14 | 15 | private static HashMap authParameters = new HashMap(); 16 | 17 | public static final String AUTHORIZE_URL = "https://login.uber.com/oauth/authorize"; 18 | public static final String BASE_URL = "https://login.uber.com/"; 19 | public static final String SCOPES = "profile history_lite history"; 20 | public static final String BASE_UBER_URL_V1 = "https://api.uber.com/v1/"; 21 | public static final String BASE_UBER_URL_V1_1 = "https://api.uber.com/v1.1/"; 22 | public static final double START_LATITUDE = 37.781955; 23 | public static final double START_LONGITUDE = -122.402367; 24 | public static final double END_LATITUDE = 37.744352; 25 | public static final double END_LONGITUDE = -122.416743; 26 | public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); 27 | 28 | public static String getUberClientId(Activity activity) { 29 | return getManifestData(activity, "com.rahul.uberapi.android.demo.UBER_CLIENT_ID"); 30 | } 31 | 32 | public static String getUberClientSecret(Activity activity) { 33 | return getManifestData(activity, "com.rahul.uberapi.android.demo.UBER_CLIENT_SECRET"); 34 | } 35 | 36 | public static String getUberRedirectUrl(Activity activity) { 37 | return getManifestData(activity, "com.rahul.uberapi.android.demo.UBER_REDIRECT_URL"); 38 | } 39 | 40 | public static String getManifestData(Activity activity, String name) { 41 | String data = authParameters.get(name); 42 | if (data != null) { 43 | return data; 44 | } 45 | try { 46 | ApplicationInfo ai = activity.getPackageManager().getApplicationInfo(activity.getPackageName(), PackageManager.GET_META_DATA); 47 | Bundle bundle = ai.metaData; 48 | data = bundle.getString(name); 49 | authParameters.put(name, data); 50 | } catch (Exception e) { 51 | e.printStackTrace(); 52 | } 53 | return data; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/DemoActivity.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.support.v7.app.ActionBarActivity; 7 | import android.view.View; 8 | import android.widget.AdapterView; 9 | import android.widget.ArrayAdapter; 10 | import android.widget.ListView; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | 16 | public class DemoActivity extends ActionBarActivity implements AdapterView.OnItemClickListener { 17 | 18 | public static void start(Context context, String accessToken, String tokenType) { 19 | Intent intent = new Intent(context, DemoActivity.class); 20 | intent.putExtra("access_token", accessToken); 21 | intent.putExtra("token_type", tokenType); 22 | context.startActivity(intent); 23 | } 24 | 25 | @Override 26 | protected void onCreate(Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | setContentView(R.layout.activity_list); 29 | 30 | ListView listView = (ListView) findViewById(R.id.list_view); 31 | listView.setOnItemClickListener(this); 32 | listView.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, android.R.id.text1, getOptionsList())); 33 | } 34 | 35 | private List getOptionsList() { 36 | List options = new ArrayList(); 37 | options.add(getString(R.string.demo_list_header_text, getIntent().getStringExtra("access_token"))); 38 | options.add(getString(R.string.products)); 39 | options.add(getString(R.string.time_estimates)); 40 | options.add(getString(R.string.price_estimates)); 41 | options.add(getString(R.string.history_v1)); 42 | options.add(getString(R.string.history_v1_1)); 43 | options.add(getString(R.string.me)); 44 | return options; 45 | } 46 | 47 | @Override 48 | public void onItemClick(AdapterView parent, View view, int position, long id) { 49 | EndpointActivity.start(this, position, 50 | getIntent().getStringExtra("access_token"), 51 | getIntent().getStringExtra("token_type")); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/EndpointActivity.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.support.v7.app.ActionBarActivity; 7 | import android.view.MenuItem; 8 | import android.widget.ArrayAdapter; 9 | import android.widget.ListView; 10 | 11 | import com.rahul.uberapi.android.demo.api.UberAPIClient; 12 | import com.rahul.uberapi.android.demo.api.UberCallback; 13 | import com.rahul.uberapi.android.demo.model.PriceEstimateList; 14 | import com.rahul.uberapi.android.demo.model.ProductList; 15 | import com.rahul.uberapi.android.demo.model.Profile; 16 | import com.rahul.uberapi.android.demo.model.TimeEstimateList; 17 | import com.rahul.uberapi.android.demo.model.UserActivity; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | import retrofit.client.Response; 23 | 24 | 25 | public class EndpointActivity extends ActionBarActivity { 26 | 27 | public static void start(Context context, int position, String accessToken, String tokenType) { 28 | Intent intent = new Intent(context, EndpointActivity.class); 29 | intent.putExtra("position", position); 30 | intent.putExtra("access_token", accessToken); 31 | intent.putExtra("token_type", tokenType); 32 | context.startActivity(intent); 33 | } 34 | 35 | @Override 36 | protected void onCreate(Bundle savedInstanceState) { 37 | super.onCreate(savedInstanceState); 38 | setContentView(R.layout.activity_list); 39 | 40 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 41 | 42 | int position = getIntent().getIntExtra("position", 0); 43 | switch (position) { 44 | case 1: 45 | UberAPIClient.getUberV1APIClient().getProducts(getAccessToken(), 46 | Constants.START_LATITUDE, 47 | Constants.START_LONGITUDE, 48 | new UberCallback() { 49 | @Override 50 | public void success(ProductList productList, Response response) { 51 | setupListAdapter("products", productList.toString()); 52 | } 53 | }); 54 | break; 55 | case 2: 56 | UberAPIClient.getUberV1APIClient().getTimeEstimates(getAccessToken(), 57 | Constants.START_LATITUDE, 58 | Constants.START_LONGITUDE, 59 | new UberCallback() { 60 | @Override 61 | public void success(TimeEstimateList timeEstimateList, Response response) { 62 | setupListAdapter("time", timeEstimateList.toString()); 63 | } 64 | }); 65 | break; 66 | case 3: 67 | UberAPIClient.getUberV1APIClient().getPriceEstimates(getAccessToken(), 68 | Constants.START_LATITUDE, 69 | Constants.START_LONGITUDE, 70 | Constants.END_LATITUDE, 71 | Constants.END_LONGITUDE, 72 | new UberCallback() { 73 | @Override 74 | public void success(PriceEstimateList priceEstimateList, Response response) { 75 | setupListAdapter("price", priceEstimateList.toString()); 76 | } 77 | }); 78 | break; 79 | case 4: 80 | UberAPIClient.getUberV1APIClient().getUserActivity(getAccessToken(), 81 | 0, 82 | 5, 83 | new UberCallback() { 84 | @Override 85 | public void success(UserActivity userActivity, Response response) { 86 | setupListAdapter("history (v1)", userActivity.toString()); 87 | } 88 | }); 89 | break; 90 | case 5: 91 | UberAPIClient.getUberV1_1APIClient().getUserActivity(getAccessToken(), 92 | 0, 93 | 5, 94 | new UberCallback() { 95 | @Override 96 | public void success(UserActivity userActivity, Response response) { 97 | setupListAdapter("history (v1.1)", userActivity.toString()); 98 | } 99 | }); 100 | break; 101 | case 6: 102 | UberAPIClient.getUberV1APIClient().getProfile(getAccessToken(), 103 | new UberCallback() { 104 | @Override 105 | public void success(Profile profile, Response response) { 106 | setupListAdapter("me", profile.toString()); 107 | } 108 | }); 109 | break; 110 | } 111 | } 112 | 113 | @Override 114 | public boolean onOptionsItemSelected(MenuItem item) { 115 | switch (item.getItemId()) { 116 | case android.R.id.home: 117 | onBackPressed(); 118 | return true; 119 | } 120 | return super.onOptionsItemSelected(item); 121 | } 122 | 123 | private void setupListAdapter(String endpoint, String response) { 124 | List options = new ArrayList(); 125 | options.add(getString(R.string.endpoint_list_header_text, endpoint)); 126 | options.add(getString(R.string.endpoint_list_result_text, endpoint)); 127 | options.add(response); 128 | 129 | ListView listView = (ListView) findViewById(R.id.list_view); 130 | listView.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, android.R.id.text1, options)); 131 | } 132 | 133 | 134 | private String getAccessToken() { 135 | return getIntent().getStringExtra("token_type") + " " + getIntent().getStringExtra("access_token"); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo; 2 | 3 | import android.net.Uri; 4 | import android.os.Bundle; 5 | import android.support.v7.app.ActionBarActivity; 6 | import android.view.Window; 7 | import android.webkit.WebChromeClient; 8 | import android.webkit.WebView; 9 | import android.webkit.WebViewClient; 10 | import android.widget.Toast; 11 | 12 | import com.rahul.uberapi.android.demo.api.UberAuthTokenClient; 13 | import com.rahul.uberapi.android.demo.api.UberCallback; 14 | import com.rahul.uberapi.android.demo.model.User; 15 | 16 | import retrofit.client.Response; 17 | 18 | 19 | public class MainActivity extends ActionBarActivity { 20 | 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | getWindow().requestFeature(Window.FEATURE_PROGRESS); 25 | 26 | super.onCreate(savedInstanceState); 27 | setContentView(R.layout.activity_main); 28 | 29 | WebView webView = (WebView) findViewById(R.id.web_view); 30 | webView.getSettings().setJavaScriptEnabled(true); 31 | 32 | webView.setWebChromeClient(new WebChromeClient() { 33 | public void onProgressChanged(WebView view, int progress) { 34 | MainActivity.this.setProgress(progress * 1000); 35 | } 36 | }); 37 | 38 | webView.setWebViewClient(new UberWebViewClient()); 39 | 40 | webView.loadUrl(buildUrl()); 41 | } 42 | 43 | private String buildUrl() { 44 | Uri.Builder uriBuilder = Uri.parse(Constants.AUTHORIZE_URL).buildUpon(); 45 | uriBuilder.appendQueryParameter("response_type", "code"); 46 | uriBuilder.appendQueryParameter("client_id", Constants.getUberClientId(this)); 47 | uriBuilder.appendQueryParameter("scope", Constants.SCOPES); 48 | uriBuilder.appendQueryParameter("redirect_uri", Constants.getUberRedirectUrl(this)); 49 | return uriBuilder.build().toString().replace("%20", "+"); 50 | } 51 | 52 | private class UberWebViewClient extends WebViewClient { 53 | @Override 54 | public boolean shouldOverrideUrlLoading(WebView view, String url) { 55 | return checkRedirect(url); 56 | } 57 | 58 | @Override 59 | public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { 60 | if (checkRedirect(failingUrl)) { 61 | return; 62 | } 63 | Toast.makeText(MainActivity.this, "Oh no! " + description, Toast.LENGTH_SHORT).show(); 64 | } 65 | 66 | private boolean checkRedirect(String url) { 67 | if (url.startsWith(Constants.getUberRedirectUrl(MainActivity.this))) { 68 | Uri uri = Uri.parse(url); 69 | UberAuthTokenClient.getUberAuthTokenClient().getAuthToken( 70 | Constants.getUberClientSecret(MainActivity.this), 71 | Constants.getUberClientId(MainActivity.this), 72 | "authorization_code", 73 | uri.getQueryParameter("code"), 74 | Constants.getUberRedirectUrl(MainActivity.this), 75 | new UberCallback() { 76 | @Override 77 | public void success(User user, Response response) { 78 | DemoActivity.start(MainActivity.this, user.getAccessToken(), user.getTokenType()); 79 | finish(); 80 | } 81 | }); 82 | return true; 83 | } 84 | return false; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/api/UberAPIClient.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo.api; 2 | 3 | import com.rahul.uberapi.android.demo.BuildConfig; 4 | import com.rahul.uberapi.android.demo.Constants; 5 | import com.rahul.uberapi.android.demo.model.PriceEstimateList; 6 | import com.rahul.uberapi.android.demo.model.ProductList; 7 | import com.rahul.uberapi.android.demo.model.Profile; 8 | import com.rahul.uberapi.android.demo.model.TimeEstimateList; 9 | import com.rahul.uberapi.android.demo.model.UserActivity; 10 | 11 | import retrofit.Callback; 12 | import retrofit.Endpoint; 13 | import retrofit.RestAdapter; 14 | import retrofit.http.GET; 15 | import retrofit.http.Header; 16 | import retrofit.http.Query; 17 | 18 | public class UberAPIClient { 19 | 20 | private static UberAPIInterface sUberAPIService; 21 | private static UberEndPoint sEndPoint = new UberEndPoint(Constants.BASE_UBER_URL_V1, Constants.BASE_UBER_URL_V1_1); 22 | 23 | private static UberAPIInterface getUberAPIClient() { 24 | if (sUberAPIService == null) { 25 | RestAdapter restAdapter = new RestAdapter.Builder() 26 | .setEndpoint(sEndPoint) 27 | .setLogLevel(BuildConfig.DEBUG ? RestAdapter.LogLevel.FULL : RestAdapter.LogLevel.NONE) 28 | .build(); 29 | 30 | sUberAPIService = restAdapter.create(UberAPIInterface.class); 31 | } 32 | 33 | return sUberAPIService; 34 | } 35 | 36 | public static UberAPIInterface getUberV1APIClient() { 37 | sEndPoint.setVersion(false); 38 | return getUberAPIClient(); 39 | } 40 | 41 | public static UberAPIInterface getUberV1_1APIClient() { 42 | sEndPoint.setVersion(true); 43 | return getUberAPIClient(); 44 | } 45 | 46 | public interface UberAPIInterface { 47 | 48 | /** 49 | * The Products endpoint returns information about the Uber products offered at a given 50 | * location. The response includes the display name and other details about each product, 51 | * and lists the products in the proper display order. 52 | * 53 | * @param authToken OAuth 2.0 bearer token with the profile scope. 54 | * @param latitude Latitude component of location. 55 | * @param longitude Longitude component of location. 56 | * @param callback 57 | */ 58 | @GET("/products") 59 | void getProducts(@Header("Authorization") String authToken, 60 | @Query("latitude") double latitude, 61 | @Query("longitude") double longitude, 62 | Callback callback); 63 | 64 | /** 65 | * The Time Estimates endpoint returns ETAs for all products offered at a given location, 66 | * with the responses expressed as integers in seconds. We recommend that this endpoint be 67 | * called every minute to provide the most accurate, up-to-date ETAs. 68 | * 69 | * @param authToken OAuth 2.0 bearer token or server_token 70 | * @param startLatitude Latitude component. 71 | * @param startLongitude Longitude component. 72 | * @param callback 73 | */ 74 | @GET("/estimates/time") 75 | void getTimeEstimates(@Header("Authorization") String authToken, 76 | @Query("start_latitude") double startLatitude, 77 | @Query("start_longitude") double startLongitude, 78 | Callback callback); 79 | 80 | /** 81 | * The Price Estimates endpoint returns an estimated price range for each product offered 82 | * at a given location. The price estimate is provided as a formatted string with the full 83 | * price range and the localized currency symbol. 84 | *

85 | * The response also includes low and high estimates, and the ISO 4217 currency code for 86 | * situations requiring currency conversion. When surge is active for a particular product, 87 | * its surge_multiplier will be greater than 1, but the price estimate already factors in 88 | * this multiplier. 89 | * 90 | * @param authToken OAuth 2.0 bearer token or server_token 91 | * @param startLatitude Latitude component of start location. 92 | * @param startLongitude Longitude component of start location. 93 | * @param endLatitude Longitude component of start location. 94 | * @param endLongitude Longitude component of end location. 95 | * @param callback 96 | */ 97 | @GET("/estimates/price") 98 | void getPriceEstimates(@Header("Authorization") String authToken, 99 | @Query("start_latitude") double startLatitude, 100 | @Query("start_longitude") double startLongitude, 101 | @Query("end_latitude") double endLatitude, 102 | @Query("end_longitude") double endLongitude, 103 | Callback callback); 104 | 105 | /** 106 | * The User Activity endpoint returns data about a user's lifetime activity with Uber. The 107 | * response will include pickup locations and times, dropoff locations and times, the 108 | * distance of past requests, and information about which products were requested. 109 | *

110 | * The history array in the response will have a maximum length based on the limit parameter. 111 | * The response value count may exceed limit, therefore subsequent API requests may be 112 | * necessary. 113 | * 114 | * @param authToken OAuth 2.0 bearer token with the history scope. 115 | * @param offset Offset the list of returned results by this amount. Default is zero. 116 | * @param limit Number of items to retrieve. Default is 5, maximum is 100. 117 | * @param callback 118 | */ 119 | @GET("/history") 120 | void getUserActivity(@Header("Authorization") String authToken, 121 | @Query("offset") int offset, 122 | @Query("limit") int limit, 123 | Callback callback); 124 | 125 | /** 126 | * The User Profile endpoint returns information about the Uber user that has authorized 127 | * with the application. 128 | * 129 | * @param authToken OAuth 2.0 bearer token with the profile scope. 130 | * @param callback 131 | */ 132 | @GET("/me") 133 | void getProfile(@Header("Authorization") String authToken, 134 | Callback callback); 135 | } 136 | 137 | private static class UberEndPoint implements Endpoint { 138 | 139 | private final String apiUrlV1, apiUrlV11; 140 | private boolean useV11 = false; 141 | 142 | private UberEndPoint(String apiUrlV1, String apiUrlV11) { 143 | this.apiUrlV1 = apiUrlV1; 144 | this.apiUrlV11 = apiUrlV11; 145 | } 146 | 147 | public void setVersion(boolean useV11) { 148 | this.useV11 = useV11; 149 | } 150 | 151 | @Override 152 | public String getUrl() { 153 | return useV11 ? apiUrlV11 : apiUrlV1; 154 | } 155 | 156 | @Override 157 | public String getName() { 158 | return "default"; 159 | } 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/api/UberAuthTokenClient.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo.api; 2 | 3 | import com.rahul.uberapi.android.demo.BuildConfig; 4 | import com.rahul.uberapi.android.demo.Constants; 5 | import com.rahul.uberapi.android.demo.model.User; 6 | 7 | import retrofit.Callback; 8 | import retrofit.RestAdapter; 9 | import retrofit.http.POST; 10 | import retrofit.http.Query; 11 | 12 | public class UberAuthTokenClient { 13 | 14 | private static UberAuthTokenInterface sUberAuthService; 15 | 16 | public static UberAuthTokenInterface getUberAuthTokenClient() { 17 | if (sUberAuthService == null) { 18 | RestAdapter restAdapter = new RestAdapter.Builder() 19 | .setEndpoint(Constants.BASE_URL) 20 | .setLogLevel(BuildConfig.DEBUG ? RestAdapter.LogLevel.FULL : RestAdapter.LogLevel.NONE) 21 | .build(); 22 | 23 | sUberAuthService = restAdapter.create(UberAuthTokenInterface.class); 24 | } 25 | 26 | return sUberAuthService; 27 | } 28 | 29 | public interface UberAuthTokenInterface { 30 | 31 | /** 32 | * Exchange this authorization code for an access_token, which will allow you to make 33 | * requests on behalf of a user. The access_token expires in 30 days. 34 | * 35 | * @param clientSecret A 40 character string. DO NOT SHARE. This should not be available on 36 | * any public facing server or web site. 37 | * @param clientId A 32 character string (public) 38 | * @param grantType May be authorization_code or refresh_token 39 | * @param code 40 | * @param redirectUrl 41 | * @param callback 42 | */ 43 | @POST("/oauth/token") 44 | void getAuthToken(@Query("client_secret") String clientSecret, 45 | @Query("client_id") String clientId, 46 | @Query("grant_type") String grantType, 47 | @Query("code") String code, 48 | @Query("redirect_uri") String redirectUrl, 49 | Callback callback); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/api/UberCallback.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo.api; 2 | 3 | import retrofit.Callback; 4 | import retrofit.RetrofitError; 5 | import retrofit.client.Response; 6 | 7 | /** 8 | * Helper class that extends the Retrofit Callback and implements the default failure method. 9 | */ 10 | public class UberCallback implements Callback { 11 | 12 | @Override 13 | public void success(T t, Response response) { 14 | 15 | } 16 | 17 | @Override 18 | public void failure(RetrofitError error) { 19 | error.printStackTrace(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/model/History.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo.model; 2 | 3 | /** 4 | * Used by the user activity endpoint and contains information including the pickup location, 5 | * dropoff location, request start time, request end time, and distance of requests (in miles), as 6 | * well as the product type that was requested. 7 | */ 8 | public class History extends UberModel { 9 | 10 | /** 11 | * Unique user identifier. 12 | */ 13 | String uuid; 14 | 15 | public String getUUID() { 16 | return uuid; 17 | } 18 | 19 | /** 20 | * Unix timestamp of trip request time. 21 | */ 22 | long request_time; 23 | 24 | public long getRequestTime() { 25 | return request_time; 26 | } 27 | 28 | /** 29 | * Unique identifier representing a specific product for a given latitude & longitude. For 30 | * example, uberX in San Francisco will have a different product_id than uberX in Los Angeles. 31 | */ 32 | String product_id; 33 | 34 | public String getProductId() { 35 | return product_id; 36 | } 37 | 38 | /** 39 | * Status of the trip. Only returns completed for now. 40 | */ 41 | String status; 42 | 43 | public String getStatus() { 44 | return status; 45 | } 46 | 47 | /** 48 | * Length of trip in miles. 49 | */ 50 | float distance; 51 | 52 | public float getDistance() { 53 | return distance; 54 | } 55 | 56 | /** 57 | * Unix timestamp of trip start time. 58 | */ 59 | long start_time; 60 | 61 | public long getStart_time() { 62 | return start_time; 63 | } 64 | 65 | /** 66 | * Latitude, longitude & address of the start location. 67 | */ 68 | Location start_location; 69 | 70 | public Location getStartLocation() { 71 | return start_location; 72 | } 73 | 74 | /** 75 | * Unix timestamp of trip end time. 76 | */ 77 | long end_time; 78 | 79 | public long getEndTime() { 80 | return end_time; 81 | } 82 | 83 | /** 84 | * Latitude, longitude & address of the end location. 85 | */ 86 | Location end_location; 87 | 88 | public Location getEndLocation() { 89 | return end_location; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/model/Location.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo.model; 2 | 3 | /** 4 | * Used by the user activity endpoint and contains information including the latitude, longitude & 5 | * address of a location. 6 | */ 7 | public class Location extends UberModel { 8 | 9 | /** 10 | * Human-readable address. 11 | */ 12 | String address; 13 | 14 | public String getAddress() { 15 | return address; 16 | } 17 | 18 | /** 19 | * Latitude component of location. 20 | */ 21 | double latitude; 22 | 23 | public double getLatitude() { 24 | return latitude; 25 | } 26 | 27 | /** 28 | * Longitude component of location. 29 | */ 30 | double longitude; 31 | 32 | public double getLongitude() { 33 | return longitude; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/model/PriceEstimate.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo.model; 2 | 3 | /** 4 | * Used by the price estimates endpoint and contains information about the estimated price range 5 | * for each product offered at a given location. The price estimate is provided as a formatted 6 | * string with the full price range and the localized currency symbol. 7 | *

8 | * It also includes low and high estimates, and the ISO 4217 currency code for situations requiring 9 | * currency conversion. When surge is active for a particular product, the surge_multiplier will be 10 | * greater than 1, but the price estimate already factors in this multiplier. 11 | */ 12 | public class PriceEstimate extends UberModel { 13 | 14 | /** 15 | * Unique identifier representing a specific product for a given latitude & longitude. For 16 | * example, uberX in San Francisco will have a different product_id than uberX in Los Angeles. 17 | */ 18 | String product_id; 19 | 20 | public String getProductId() { 21 | return product_id; 22 | } 23 | 24 | /** 25 | * ISO 4217 currency code. 26 | */ 27 | String currency_code; 28 | 29 | public String getCurrencyCode() { 30 | return currency_code; 31 | } 32 | 33 | /** 34 | * Localized display name of product. 35 | */ 36 | String localized_display_name; 37 | 38 | public String getLocalizedDisplayName() { 39 | return localized_display_name; 40 | } 41 | 42 | /** 43 | * Display name of product. 44 | */ 45 | String display_name; 46 | 47 | public String getDisplayName() { 48 | return display_name; 49 | } 50 | 51 | /** 52 | * Formatted string of estimate in local currency of the start location. Estimate could be a 53 | * range, a single number (flat rate) or "Metered" for TAXI. 54 | */ 55 | String estimate; 56 | 57 | public String getEstimate() { 58 | return estimate; 59 | } 60 | 61 | /** 62 | * Lower bound of the estimated price. 63 | */ 64 | int low_estimate; 65 | 66 | public int getLowEstimate() { 67 | return low_estimate; 68 | } 69 | 70 | /** 71 | * Upper bound of the estimated price. 72 | */ 73 | int high_estimate; 74 | 75 | public int getHighEstimate() { 76 | return high_estimate; 77 | } 78 | 79 | /** 80 | * Expected surge multiplier. Surge is active if surge_multiplier is greater than 1. Price 81 | * estimate already factors in the surge multiplier. 82 | */ 83 | float surge_multiplier; 84 | 85 | public float getSurgeMultiplier() { 86 | return surge_multiplier; 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/model/PriceEstimateList.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo.model; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Used by the price estimates endpoint and lists the estimated price range for each product 7 | * offered at a given location. 8 | */ 9 | public class PriceEstimateList extends UberModel { 10 | 11 | /** 12 | * List of the estimated price range for each product. 13 | */ 14 | List prices; 15 | 16 | public List getPrices() { 17 | return prices; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/model/Product.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo.model; 2 | 3 | /** 4 | * Used by the product endpoint and contains information about display name and other details about 5 | * each product. 6 | */ 7 | public class Product extends UberModel { 8 | 9 | /** 10 | * Unique identifier representing a specific product for a given latitude & longitude. For 11 | * example, uberX in San Francisco will have a different product_id than uberX in Los Angeles. 12 | */ 13 | String product_id; 14 | 15 | public String getProductId() { 16 | return product_id; 17 | } 18 | 19 | /** 20 | * Description of product. 21 | */ 22 | String description; 23 | 24 | public String getDescription() { 25 | return description; 26 | } 27 | 28 | /** 29 | * Display name of product. 30 | */ 31 | String display_name; 32 | 33 | public String getDisplayName() { 34 | return display_name; 35 | } 36 | 37 | /** 38 | * Capacity of product. For example, 4 people. 39 | */ 40 | int capacity; 41 | 42 | public int getCapacity() { 43 | return capacity; 44 | } 45 | 46 | /** 47 | * Image URL representing the product. 48 | */ 49 | String image; 50 | 51 | public String getImage() { 52 | return image; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/model/ProductList.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo.model; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Used by the product endpoint and lists the products in the proper display order. 7 | */ 8 | public class ProductList extends UberModel { 9 | 10 | /** 11 | * List of the products in the proper display order. 12 | */ 13 | List products; 14 | 15 | public List getProducts() { 16 | return products; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/model/Profile.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo.model; 2 | 3 | /** 4 | * Used by the profile endpoint and contains information about the Uber user that has authorized 5 | * with the application. 6 | */ 7 | public class Profile extends UberModel { 8 | 9 | /** 10 | * First name of the Uber user. 11 | */ 12 | String first_name; 13 | 14 | public String getFirstName() { 15 | return first_name; 16 | } 17 | 18 | /** 19 | * Last name of the Uber user. 20 | */ 21 | String last_name; 22 | 23 | public String getLastName() { 24 | return last_name; 25 | } 26 | 27 | /** 28 | * Email address of the Uber user 29 | */ 30 | String email; 31 | 32 | public String getEmail() { 33 | return email; 34 | } 35 | 36 | /** 37 | * Image URL of the Uber user. 38 | */ 39 | String picture; 40 | 41 | public String getPicture() { 42 | return picture; 43 | } 44 | 45 | /** 46 | * Promo code of the Uber user. 47 | */ 48 | String promo_code; 49 | 50 | public String getPromoCode() { 51 | return promo_code; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/model/TimeEstimate.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo.model; 2 | 3 | /** 4 | * Used by the time estimates endpoint and contains information about ETAs for all products offered 5 | * at a given location, with the responses expressed as integers in seconds. 6 | */ 7 | public class TimeEstimate extends UberModel { 8 | 9 | /** 10 | * Unique identifier representing a specific product for a given latitude & longitude. For 11 | * example, uberX in San Francisco will have a different product_id than uberX in Los Angeles. 12 | */ 13 | String product_id; 14 | 15 | public String getProductId() { 16 | return product_id; 17 | } 18 | 19 | /** 20 | * Localized display name of product. 21 | */ 22 | String localized_display_name; 23 | 24 | public String getLocalizedDisplayName() { 25 | return localized_display_name; 26 | } 27 | 28 | /** 29 | * Display name of product. 30 | */ 31 | String display_name; 32 | 33 | public String getDisplayName() { 34 | return display_name; 35 | } 36 | 37 | /** 38 | * ETA for the product (in seconds). Always show estimate in minutes. 39 | */ 40 | int estimate; 41 | 42 | public int getEstimate() { 43 | return estimate; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/model/TimeEstimateList.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo.model; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Used by the time estimates endpoint and lists the ETAs for all products offered at a given 7 | * location. 8 | */ 9 | public class TimeEstimateList extends UberModel { 10 | 11 | /** 12 | * List of the ETAs for all products offered at a given location. 13 | */ 14 | List times; 15 | 16 | public List getTimes() { 17 | return times; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/model/UberModel.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo.model; 2 | 3 | import com.rahul.uberapi.android.demo.Constants; 4 | 5 | /** 6 | * Helper class that overrides the {@link #toString()} method to print pretty json. All models 7 | * extend this class. 8 | */ 9 | public class UberModel { 10 | 11 | @Override 12 | public String toString() { 13 | return Constants.GSON.toJson(this); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/model/User.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo.model; 2 | 3 | /** 4 | * Used by the auth endpoint and contains information data about the current authenticated user. 5 | */ 6 | public class User extends UberModel { 7 | 8 | String access_token; 9 | 10 | public String getAccessToken() { 11 | return access_token; 12 | } 13 | 14 | String token_type; 15 | 16 | public String getTokenType() { 17 | return token_type; 18 | } 19 | 20 | String expires_in; 21 | 22 | public String getExpiresIn() { 23 | return expires_in; 24 | } 25 | 26 | String refresh_token; 27 | 28 | public String getRefreshToken() { 29 | return refresh_token; 30 | } 31 | 32 | String scope; 33 | 34 | public String getScope() { 35 | return scope; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/rahul/uberapi/android/demo/model/UserActivity.java: -------------------------------------------------------------------------------- 1 | package com.rahul.uberapi.android.demo.model; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Used by the user activity endpoint and contains information data about a user's lifetime 7 | * activity with Uber. It includes pickup locations and times, dropoff locations and times, the 8 | * distance of past requests, and information about which products were requested. 9 | */ 10 | public class UserActivity extends UberModel { 11 | 12 | /** 13 | * Position in pagination. 14 | */ 15 | int offset; 16 | 17 | public int getOffset() { 18 | return offset; 19 | } 20 | 21 | /** 22 | * Number of items to retrieve (100 max). 23 | */ 24 | int limit; 25 | 26 | public int getLimit() { 27 | return limit; 28 | } 29 | 30 | /** 31 | * Total number of items available. 32 | */ 33 | int count; 34 | 35 | public int getCount() { 36 | return count; 37 | } 38 | 39 | /** 40 | * Information including the pickup location, dropoff location, request start time, request end 41 | * time, and distance of requests (in miles), as well as the product type that was requested. 42 | */ 43 | List history; 44 | 45 | public List getHistory() { 46 | return history; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unrarp/UberAPI-Android-Demo/d503aa9bb270ae61e549ff4ece1c4c0a5f457009/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unrarp/UberAPI-Android-Demo/d503aa9bb270ae61e549ff4ece1c4c0a5f457009/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unrarp/UberAPI-Android-Demo/d503aa9bb270ae61e549ff4ece1c4c0a5f457009/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unrarp/UberAPI-Android-Demo/d503aa9bb270ae61e549ff4ece1c4c0a5f457009/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_list.xml: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | UberAPI-Android-Demo 5 | \nCongratulations! you have successfully authenticated and your token is: %s\n\nTest the following functions of the api!\n 6 | Products! 7 | Time Estimates! 8 | Price Estimates! 9 | History! (v1) 10 | History! (v1.1) 11 | Me! 12 | Welcome to the %s endpoint! 13 | Here is the result of a call to %s: 14 | 15 | 16 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:0.12.2' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Settings specified in this file will override any Gradle settings 5 | # configured through the IDE. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unrarp/UberAPI-Android-Demo/d503aa9bb270ae61e549ff4ece1c4c0a5f457009/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /screenshots/UberAPI-Android-Demo-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unrarp/UberAPI-Android-Demo/d503aa9bb270ae61e549ff4ece1c4c0a5f457009/screenshots/UberAPI-Android-Demo-1.png -------------------------------------------------------------------------------- /screenshots/UberAPI-Android-Demo-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unrarp/UberAPI-Android-Demo/d503aa9bb270ae61e549ff4ece1c4c0a5f457009/screenshots/UberAPI-Android-Demo-2.png -------------------------------------------------------------------------------- /screenshots/UberAPI-Android-Demo-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unrarp/UberAPI-Android-Demo/d503aa9bb270ae61e549ff4ece1c4c0a5f457009/screenshots/UberAPI-Android-Demo-3.png -------------------------------------------------------------------------------- /screenshots/UberAPI-Android-Demo-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unrarp/UberAPI-Android-Demo/d503aa9bb270ae61e549ff4ece1c4c0a5f457009/screenshots/UberAPI-Android-Demo-4.png -------------------------------------------------------------------------------- /screenshots/UberAPI-Android-Demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unrarp/UberAPI-Android-Demo/d503aa9bb270ae61e549ff4ece1c4c0a5f457009/screenshots/UberAPI-Android-Demo.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------