Uber SDK for Android


Source link: https://github.com/Neno0o/Uber-Android-SDK

Deprecated

Please refer to Uber official SDK https://github.com/uber/rides-android-sdk, as am not supporting this project anymore, but feel free to use the current version.

Uber SDK for Android

An unofficial Uber SDK for Android. This open-source library allows you to integrate Uber into your Android app.

Learn more about about Uber API, documentation, samples, and more at https://developer.uber.com/

Features

  • Rides By Uber Button
  • Authorization
  • User Profile
  • User History
  • Make a Request
  • Request Estimation
  • Request Cancellation
  • Request Map
  • Request Receipt
  • Uber Products
  • Price Estimation
  • Time Estimation
  • Promotions
  • Sandbox

Download

Gradle:

compile 'com.neno0o.ubersdk:ubersdk:0.2'

Maven:

<dependency>
<groupId>com.neno0o.ubersdk</groupId>
<artifactId>ubersdk</artifactId>
<version>0.2</version>
<type>aar</type> </dependency>

Usage

First, navigate over to https://developer.uber.com/, and sign up for an Uber developer account.

Initialize Uber

Call Uber.getInstance().init from the onCreate method of your Application class to set your client id, client secert, server token and redirect url:

Uber.getInstance().init("CLIENT_ID",

  "CLIENT_SECRET",

  "SERVER_TOKEN",

  "REDIRECT_URL");

Rides By Uber Button

Use this widget or use your own button

<com.neno0o.ubersdk.Widgets.UberButton

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/uberBtn"

android:layout_centerVertical="true"

android:layout_centerHorizontal="true"/>

User Authorization

If your application will access resources on behalf of an Uber user, such as with the Me and User Activity endpoints, you will need to follow the three-legged OAuth 2.0 flow in order to obtain an access_token.

Manifest.xml in Application tag

<activity android:name="com.neno0o.ubersdk.Activites.Authentication" />

Activity.java

UberButton uberButton = (UberButton) findViewById(R.id.uberBtn);
 uberButton.setOnClickListener(new View.OnClickListener() {

  @Override
  public void onClick(View view) {

Intent intent = new Intent(MainActivity.this, Authentication.class);

startActivityForResult(intent, UBER_AUTHENTICATION);

  
}
 
}
);

This will give you the access_token expires in 30 days. Call onActivityResult

@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {

  if (requestCode == UBER_AUTHENTICATION) {

// you have now access token

// you can access resources on behalf of an Uber use
  
}
 
}

User Profile (Authorization Required)

To return information about the Uber user that has authorized with the application.

Uber.getInstance().getUberAPIService().getMe(new Callback<User>() {

  @Override
  public void success(User user, Response response) {

Log.d("user", user.getFirstName());

  
}
 
}
);

User History v1.2 (Authorization Required)

To returns a limited amount of data about a user's lifetime activity with Uber.

Uber.getInstance().getUberAPIService().getUserActivity(offset, limit, new Callback<UserActivity>() {

  @Override
  public void success(UserActivity userActivity, Response response) {

 
}
 
}
);

Make a request (Authorization Required)

Allowing a ride to be requested on behalf of an Uber user given their desired product, start, and end locations.

UberRequestBody uberRequestBody = new UberRequestBody(productId,

startLatitude,

startLongitude,

endLatitude,

endLongitude,

surgeConfirmationId);

 Uber.getInstance().getUberAPIService().postRequest(uberRequestBody, new Callback<UberRequest>() {

  @Override
  public void success(UberRequest uberRequest, Response response) {

}
 
}
);

Request Estimation (Authorization Required)

Allowing a ride to be estimated given the desired product, start, and end locations.

UberEstimateBody uberEstimateBody = new UberEstimateBody(productId,

startLatitude,

startLongitude,

endLatitude,

endLongitude);

 Uber.getInstance().getUberAPIService().postEstimateRequest(uberEstimateBody, new Callback<UberEstimateRequest>() {

  @Override
  public void success(UberEstimateRequest uberEstimateRequest, Response response) {

}
 
}
);

Request Cancellation (Authorization Required)

Cancel an ongoing Request on behalf of a rider.

Uber.getInstance().getUberAPIService().deleteRequest(requestId);

Request Map (Authorization Required)

Get a map with a visual representation of a Request.

Uber.getInstance().getUberAPIService().getMapRequest(requestId);

Request Receipt (Authorization Required)

Get the receipt information of the completed request.

Uber.getInstance().getUberAPIService().getReceiptRequest(requestId, new Callback<UberReceiptRequest>() {

  @Override
  public void success(UberReceiptRequest uberReceiptRequest, Response response) {

 
}
 
}
);

Uber Products

Returns information about the Uber products offered at a given location.

Uber.getInstance().getUberAPIService().getProducts(latitude, longitude, new Callback<Products>() {

  @Override
  public void success(Products products, Response response) {

Log.d("Product", products.getProducts().get(0).getDisplayName());

  
}
 
}
);

Price Estimation

Returns an estimated price range for each product offered at a given location.

Uber.getInstance().getUberAPIService().getPriceEstimates(start_latitude,

 start_longitude,

 end_latitude,

 end_longitude,

 new Callback<Prices>() {

 @Override

 public void success(Prices prices, Response response) {

  
}
 
}
);

Time Estimation

Returns ETAs for all products offered at a given location.

Uber.getInstance().getUberAPIService().getTimeEstimates(start_latitude, start_longitude);

Promotions

The Promotions endpoint returns information about the promotion that will be available to a new user based on their activity's location

Uber.getInstance().getUberAPIService().getPromotions(startLatitude, startLongitude, endLatitude, endLongitude);

Contributing

All pull requests are welcome. If you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request.

When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible.

Todo

  • Style More Buttons
  • Unit Testing
  • Validation

Licence

Copyright 2015 Neno0o  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

Features built in:

  • ProgressBar while adapter hasn't been set
  • EmptyView if adapter is empty
  • SwipeRefreshLayout (Google's one)
  • Infinite scrolling, when you reach the X last item, load more of them
  • Swipe To Dismiss
  • Sticky headers

android-target-tooltip allows to create toasts like tooltips, but targets can be specified, plus custom properties and features.

TextViewWithLinks is a TextView With Link handler

Example Proguard configurations for common Android libraries.

This project assumes that your ProGuard configuration is based off of the latest official proguard-android.txt config as shown below. Each library configuration should only be the rules required for that specific library, not a complete Android ProGuard configuration. The various library configurations are combined by the Gradle build system. The library rules should be universal, any app specific rules (such as preserving model classes) should be added in a custom proguard-project.pro file.

Extend base components, use widgets, and call utility methods.

It is a tool for reverse engineering 3rd party, closed, binary Android apps. It can decode resources to nearly original form and rebuild them after making some modifications; it makes possible to debug smali code step by step. Also it makes working with app easier because of project-like files structure and automation of some repetitive tasks like building apk, etc.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes