Giter VIP home page Giter VIP logo

skygear-sdk-android's Introduction

Skygear SDK for Android

Skygear Server is a cloud backend for making web and mobile app development easier. https://skygear.io

The Skygear Android SDK library that gives you access to the Skygear Server from your Android app.

Getting Started

To get started, you need to have the Skygear Server running and Android SDK installed into your app. You can see detailed procedure at the getting started guide at https://docs.skygear.io/android/guide.

You can sign up the Skygear Hosting at the Skygear Developer Portal at https://portal.skygear.io

Also, you can download the sample application to your Android devices to try it out.

Documentation

The full documentation for Skygear is available on our docs site. The Android SDK get started guide is a good place to get started.

Support

For implementation related questions or technical support, please find us on the official forum or community chat.

If you believe you've found an issue with Skygear Android SDK, please feel free to report an issue.

How to contribute

Pull Requests Welcome!

We really want to see Skygear grows and thrives in the open source community. If you have any fixes or suggestions, simply send us a pull request!

The current project setup assume Android Studio 3.0+. Download it here: https://developer.android.com/studio/index.html and start your contribution!

Continuous Delivery

Every release with version tagged will be push to jCenter.

License & Copyright

Copyright (c) 2015-present, Oursky Ltd.
All rights reserved.

This source code is licensed under the Apache License version 2.0
found in the LICENSE file in the root directory of this source tree.
An additional grant of patent rights can be found in the PATENTS
file in the same directory.

skygear-sdk-android's People

Contributors

b123400 avatar ben181231 avatar camerash avatar carmenlau avatar cheungpat avatar cychiuae avatar david90 avatar howawong avatar kaojohnny avatar m-sameer avatar mayyuen318 avatar rickmak avatar royuen avatar seventhmoon avatar steven-chan avatar tensiuyan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

skygear-sdk-android's Issues

Show request timeout error properly

Currently, error callback will be called with null error string when the volley library get request timeout error.

Expect to show something like Request timeout as error message.

Polish the example

  1. Login auto prompt back to main activity
  2. Logout can be inline at main activity
  3. Separate Save and Query
  4. Make Delete appear after save and query. Make the button to Delete the saved record, Delete all queried records

Upload the asset automatically at Record Save

Current SDK requires developer to have a separate API to upload the asset first before attach it to Record. If the developer attaches asset that not uploaded to Skyegar, following Exception will be thrown.

InvalidParameterException("Cannot save records with pending upload asset");

It is good to gives developer more control over the retry, and can pre-upload the asset before the Record save. It is essential for good UI and UX in case of large files too.

For small MVP that only need upload a small thumbnail, this control may not necessary. And SDK may do a favour for uploading the pending asset to server in one API call.

User Authentication

Utils

  • Request / Request Manager (Queue)

Actions

  • Signup
    • by username
    • by email
  • Login
    • by username
    • by email
  • Logout
  • Current User

Others

  • Test cases
  • Sample Code
  • Documentation

Support pubsub

Tasks

  • Bridging with the WebSocket Library
  • Subscribe / Unsubscribe
  • Publish
  • Reconnection after connection close
  • Queue up events (subs, unsubs and pubs) when not yet connected
  • Test Cases
  • Sample Project
  • Documentation

Record Create / Update / Delete

Basic

  • Database Class ( public / private )
  • Record Class
  • Deserialize metadata ( createdAt, updatedAt, creatorId, updaterId, ownerId)
  • Datetime Support
  • Default ACL
  • Save Record
  • Delete Record
  • Multiple Record Operations

Others

  • Test cases
  • Sample Code
  • Documentation

Support assets

Tasks

  • Add asset model
  • Add asset serialization in record serialization
  • Implement asset upload mechanism
  • Update sample project
  • Add test cases

Record query

Tasks

  • Query Class
  • Query Request
  • Support basic predicates
  • Query Or
  • Sort
  • Query Response Handler

Supporting Tasks

  • Test cases
  • Sample Project
  • Documentation

Supporting Operators

  • like
  • notLike
  • caseInsensitiveLike
  • caseInsensitiveNotLike
  • equalTo
  • notEqualTo
  • greaterThan
  • greaterThanOrEqualTo
  • lessThan
  • lessThanOrEqualTo
  • contains
  • notContains
  • containsValue
  • notContainsValue
  • addDescending
  • addAscending
  • or
  • negate
  • transientInclude
  • distanceLessThan
  • distanceGreaterThan
  • addDescendingByDistance
  • addAscendingByDistance
  • transientIncludeDistance
  • havingRelation
  • notHavingRelation

Support ACL

  • Access Model
  • Add Access to Record Model
  • Default Access

Public Access

  • Set Public Access (No, ReadOnly, ReadWrite)

User Management

  • User Query (by email)
  • Save User

Role Management

  • Role Model
  • Set Admin Role
  • Set Default Role
  • Add / Remove Role

Role-based Access

  • Set Role Access (No, ReadOnly, ReadWrite)

User-based Access

  • Set User Access (No, ReadOnly, ReadWrite)

Others

  • Test Cases
  • Sample Code
  • Documentation

Transient query support

Tasks

  • Reference model
  • Support Transient Include in Query
  • Parse Transient on Query Result
  • Test cases
  • Update documentation

Support Amazon CloudFront for assets

Currently when we use s3 as upload handler, the URL returned is always from aws. We would need to add an option to allow user entering the cloudfront domain in order to return the cloudfront URL

Setup Travis

  • Run test
  • Push to bintray when it is tagged (release)

Better error handling

Expected behaviour

Give the user following error

401 Unauthorized, trying to save record without login

Current behaviour

/com.skygeario.cloudservicesdemo E/Volley: [16286] BasicNetwork.performRequest: Unexpected response code 401 for https://xxx.skygeario.com/record/save
/com.skygeario.cloudservicesdemo I/Skygear Record Save: Fail to save: io.skygear.skygear.Error: write is not allowed

Skygear Initialization

  • Container
  • Configuration (builder)
  • SkygearApplication
  • Documentation
import io.skygear.skygear.Container;
import io.skygear.skygear.Configuration;

Configuration config = 
  new Configuration.Builder()
    .endPoint("http://your-end-point.skygeario.com")
    .apiKey("26c81a78-03dd-4ec9-aa24-71e2237017ba")
    .context(getApplicationContext())
    .build();

// Create an instance
Container container = new Container(config);

// Singleton
Container defaultContainer = Container.defaultContainer();
defaultContainer.configure(config);

RecordSerializer fails on empty array

The RecordSerializer failed to parse an empty json array. e.g. for a json response {"participant_ids":[]} the SDK will throw InvalidParameterException at io.skygear.skygear.Record@set(String, Object), when it parse the "[]",

But it parse okay on non empty array.

Failed to re-construct a Record from json string produced by SDK

After we serialize a Record into a JSONObject (and/or further encode it as a json-string), it is unable to re-construct the same Record.

  • Skygear Android SDK: 0.16.0

Steps to reproduce:

Followed is just sample code to illustrate the issue; not a usual practice in reality.

    Record source = new Record("user"); // simply create a record of any record type
    JSONObject jsonObject = source.toJson();

    try {
        Record destination = Record.fromJson(jsonObject);
    } catch (JSONException e) {
        Log.e(LOG_TAG, e.getMessage(), e);
    }

Above code yields below error:

 org.json.JSONException: No value for _created_at
     at org.json.JSONObject.get(JSONObject.java:354)
     at org.json.JSONObject.getString(JSONObject.java:514)
     at io.skygear.skygear.RecordSerializer.deserialize(RecordSerializer.java:148)
     at io.skygear.skygear.Record.fromJson(Record.java:404)
     ....

Guess that RecordSerializer#serialize didn't serialize _created_at, _updated_at, _created_by, _updated_by, _ownerID, etc....
But RecordSerializer#deserialize will (try to) deserialize these fields, resulting org.json.JSONException: No value for _created_at

Real use case

Sometime we need to pass Record via Intent, between Activitys / Fragments:

    Record source = new Record("user");
    String jsonString = source.toJson().toString();

    Bundle bundle = new Bundle();
    bundle.putString("jsonString", jsonString);

    Intent intent = new Intent(getContext(), NextActivity.class);
    startActivity(intent);

Then in NextActivity#onCreate, we extract the string and re-construct the Record:

    try {
        Record destination = Record.fromJson(new JSONObject(getIntent().getStringExtra("jsonString")));
    } catch (JSONException e) {
        Log.e(LOG_TAG, e.getMessage(), e);
    }

The same error would occur.

Unable to complete Sign Up/In procedure, due to request timeouted

At Sign Up procedure, SDK invoked onAuthFail callback while a user record is created on server DB.
From logcat, such error message appears after android fire a web service request:

06-29 17:22:56.714 11386-11386/io.skygear.skygear_example I/dalvikvm: DexOpt: illegal method access (call Lcom/android/volley/Request;.finish (Ljava/lang/String;)V from Lio/skygear/skygear/RequestManager$JsonRequest;)
06-29 17:22:56.714 11386-11386/io.skygear.skygear_example I/dalvikvm: Could not find method com.android.volley.Request.finish, referenced from method io.skygear.skygear.RequestManager$JsonRequest.access$super

Steps to reproduce:

  1. Clone this repo and open the project using Android Studio
  2. At io.skygear.skygear_example.MyApplication, specify the correct Endpoint and API Key.
  3. Build and launch the app into an android phone
  4. On the phone, click into SignupActivity, fill the username and password.
  5. After a while, the above error messages appear (at logcat console) and the app displayed a dialog, with message (tracing the code reveal that the dialog is displayed from SignupActivity#doSignup, at the onAuthFail callback):
Signup failed
Fail with reason
null

Server DB Data

However, when I log into server's postgresql, I see that the user record with my username was created.
I am not sure whether the SDK really faced some (network) error

Control Trial

The same outcome would occur even I created a new Android Studio project and import the SDK via gradle:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'

    compile 'io.skygear:skygear:0.0.1'
}

Query on publicDB failed due to parsing on null value of _access field failed

After successful log-on, it is unable to retrieve the record owned by currentUser, from user table in publicDB.

  • Skygear Android SDK: 0.16.0
  • Skygear Server: 0.16.0

Steps to reproduce

After successful log-on, we performed following:

        Container.defaultContainer(this);
        Query query = new Query("user");
        query.equalTo("_id", skygear.getCurrentUser().getId());
        skygear.getPublicDatabase().query(query, new RecordQueryResponseHandler() {
            @Override
            public void onQuerySuccess(Record[] records) {
                // Although the record exists on server database,
                // the SDK cannot reach here
            }

            @Override
            public void onQueryError(String reason) {
                Log.d(TAG, "error = " + reason);
            }
        });

Actual Results

The onQueryError callback was invoked, the reason is Malformed server response. Following the stack trace, this reason string came from RecordQueryResponseHandler#onSuccess since its caught an exception from Record#fromJson and RecordSerializer#deserialize.

Response

Below is the json response:

{
   "result":[
      {
         "display_name":"Coffee Can",
         "_type":"record",
         "username":"ryanpang",
         "_updated_by":"aed464a7-45b8-4fde-b59b-3c131d996b84",
         "_ownerID":"aed464a7-45b8-4fde-b59b-3c131d996b84",
         "_id":"user\/aed464a7-45b8-4fde-b59b-3c131d996b84",
         "is_active":true,
         "_created_at":"2016-06-29T07:28:37.903873Z",
         "_created_by":"aed464a7-45b8-4fde-b59b-3c131d996b84",
         "_access":null,
         "_updated_at":"2016-06-29T07:28:37.903873Z"
      }
   ]
}

(My record on server table user really has a null value at field _access.)

More Error Logs

By adding some Log.e calls into SDK, it reveals that the exception is raised from RecordSerializer, line 164 (some line numbers may differ from yours as I added Log.e):

09-06 11:51:13.247 3074-3074/io.skygear.skygear_example E/RecordQueryResHdl: Value null at _access of type org.json.JSONObject$1 cannot be converted to JSONArray
org.json.JSONException: Value null at _access of type org.json.JSONObject$1 cannot be converted to JSONArray
    at org.json.JSON.typeMismatch(JSON.java:100)
    at org.json.JSONObject.getJSONArray(JSONObject.java:552)
    at io.skygear.skygear.RecordSerializer$override.deserialize(RecordSerializer.java:164)
    at io.skygear.skygear.RecordSerializer$override.access$dispatch(RecordSerializer.java)
    at io.skygear.skygear.RecordSerializer.deserialize(RecordSerializer.java:0)
    at io.skygear.skygear.Record.fromJson(Record.java:404)
    at io.skygear.skygear.RecordQueryResponseHandler.onSuccess(RecordQueryResponseHandler.java:36)
    at io.skygear.skygear.Request.onResponse(Request.java:101)
    at io.skygear.skygear.Request.onResponse(Request.java:16)
    at com.android.volley.toolbox.JsonRequest.deliverResponse(JsonRequest.java:65)
    at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
    at android.os.Handler.handleCallback(Handler.java:730)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:213)
    at android.app.ActivityThread.main(ActivityThread.java:5225)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
    at dalvik.system.NativeStart.main(Native Method)

The essential parts:

        // RecordSerializer.java:164
        JSONArray accessJsonArray = null;
        if (jsonObject.has("_access")) {
            accessJsonArray = jsonObject.getJSONArray("_access");
        }

Support Geo Data in Record

Tasks

  • Support Location Field in Records
  • Support distance related query predicate
  • Support distance related sorting
  • Support transient includes distance
  • Update Sample Project
  • Documentation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.