<commit_before>Chute-SDK-V2-Android
====================

This is the official Android SDK for www.getchute.com API version 2.


You can use it as a Maven dependency by adding the following to your list of dependencies in your pom.xml:

    <dependency>
      <groupId>com.getchute.android.sdk.v2</groupId>
      <artifactId>chute-sdk-v2-android</artifactId>
      <version>2.2.0</version>
    </dependency>


Or use the jar with dependencies from target in your regular non-maven projects.

# Changelog

## 2.2.0

	- Migrated Auth code to V2 of API
	- Added Chute.init to inititialize Chute inside the APP class

## 2.1.1

	- Removed Account Store
	- Initialization should always go through Chute.init(context,authConstants); A recommended way of doing this is by extending the Application class and adding this piece of code inside onCreate();

Setup
====

1. Register AuthenticationActivity and HTTP Service in Manifest:

    ```
        <activity
            android:name="com.chute.sdk.v2.api.authentication.AuthenticationActivity"
             android:configChanges="orientation|screenSize" 
            android:theme="@android:style/Theme.Light.NoTitleBar" >
        </activity>
        <service android:name="com.dg.libs.rest.services.HTTPRequestExecutorService" />
    ```
2. Add the required permissions in the Manifest:

    ```
	<uses-permission android:name="android.permission.INTERNET" />
	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
	<uses-permission android:name="android.permission.READ_PHONE_STATE" />
	<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
	<uses-permission android:name="android.permission.WAKE_LOCK" />
    ```
3. Add the Client ID and Client Secret that are listed in your Chute app using the following code in the Application class:
   <pre><code>
     @Override
     public void onCreate() {
     super.onCreate();
     Chute.init(this, new AuthConstants(CLIENT_ID, CLIENT_SECRET));
  </code></pre>
	
4. Use the following code in your application to launch the Authentication screen:

    <pre><code>
         /**
          * AccountType is the type of the service you wish to authenticate to
          */
          AuthenticationFactory.getInstance().startAuthenticationActivity(
          ServicesActivity.this, AccountType.FACEBOOK);
    </code></pre>

   This will return a result in onActivityResult according to the status of the sign in.
   The Authentication token will be persisted and used from inside GCAccount in every request towards the Chute API.


## Request execution and callback

1. Every request can be either:  
-synchronous (it executes in the same thread as the <code>execute()</code> method was called  
-asynchronous (it executes in the Background and it is started by calling <code>executeAsync()</code>);

2. Every request can accept a suitable callback which returns an object or list depending on the response type.
3. The callback has two possible outcomes:

	<pre>
	// returns the parsed response according to the parsers return type.
	<code>public void onSuccess(T responseData); </code>
    
        // returns ResponseStatus containing HTTP status code and error message explaining the reason that caused the error to occur  
<code>public void onHttpError(ResponseStatus responseStatus); </code>
       </pre>

Basic Tasks
=========

## Uploading Assets

Use the folowing code to execute an upload request. This method needs an asset collection that will contain the paths to the photos that you want to upload and a collection of chutes you want the assets to be linked to.


<pre><code>
        /** @param context
	      *            The application context
	      *  @param uploadListener<commit_msg>readme small changes<commit_after>Chute-SDK-V2-Android
====================

This is the official Android SDK for www.getchute.com API version 2.


You can use it as a Maven dependency by adding the following to your list of dependencies in your pom.xml:

    <dependency>
      <groupId>com.getchute.android.sdk.v2</groupId>
      <artifactId>chute-sdk-v2-android</artifactId>
      <version>2.2.0</version>
    </dependency>


Or use the jar with dependencies from target in your regular non-maven projects.

# Changelog

## 2.2.0

	- Migrated Auth code to V2 of API
	- Added Chute.init to inititialize Chute inside the APP class

## 2.1.1

	- Removed Account Store
	- Initialization should always go through <code>Chute.init(context,authConstants);</code> A recommended way of doing this is by extending the Application class and adding this piece of code in <code>onCreate();</code>

Setup
====

1. Register AuthenticationActivity and HTTP Service in Manifest:

    ```
        <activity
            android:name="com.chute.sdk.v2.api.authentication.AuthenticationActivity"
             android:configChanges="orientation|screenSize" 
            android:theme="@android:style/Theme.Light.NoTitleBar" >
        </activity>
        <service android:name="com.dg.libs.rest.services.HTTPRequestExecutorService" />
    ```
2. Add the required permissions in the Manifest:

    ```
	<uses-permission android:name="android.permission.INTERNET" />
	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
	<uses-permission android:name="android.permission.READ_PHONE_STATE" />
	<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
	<uses-permission android:name="android.permission.WAKE_LOCK" />
    ```
3. Add the Client ID and Client Secret that are listed in your Chute app using the following code in the Application class:
   <pre><code>
     @Override
     public void onCreate() {
     super.onCreate();
     Chute.init(this, new AuthConstants(CLIENT_ID, CLIENT_SECRET));
  </code></pre>
	
4. Use the following code in your application to launch the Authentication screen:

    <pre><code>
         /**
          * AccountType is the type of the service you wish to authenticate to
          */
          AuthenticationFactory.getInstance().startAuthenticationActivity(
          ServicesActivity.this, AccountType.FACEBOOK);
    </code></pre>

   This will return a result in onActivityResult according to the status of the sign in.
   The Authentication token will be persisted and used from GCAccount in every request towards the Chute API.


## Request execution and callback

1. Every request can be either:  
-synchronous (it executes in the same thread as the <code>execute()</code> method was called  
-asynchronous (it executes in the Background and it is started by calling <code>executeAsync()</code>);

2. Every request can accept a suitable callback which returns an object or list depending on the response type.
3. The callback has two possible outcomes:

	<pre>
	// returns the parsed response according to the parsers return type.
	<code>public void onSuccess(T responseData); </code>
    
        // returns ResponseStatus containing HTTP status code and error message explaining the reason that caused the error to occur  
<code>public void onHttpError(ResponseStatus responseStatus); </code>
       </pre>

Basic Tasks
=========

## Uploading Assets

Use the folowing code to execute an upload request. This method needs an asset collection that will contain the paths to the photos that you want to upload and a collection of chutes you want the assets to be linked to.


<pre><code>
        /** @param context
	      *            The application context
	      *  @param uploadListener
{'fraction_non_alphanumeric': 0.09067085953878407, 'fraction_numerical': 0.005765199161425576, 'mean_word_length': 3.63730255164034, 'pattern_counts': {'":': 0, '<': 81, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6730668', 'n_tokens_mistral': 2093, 'n_tokens_neox': 1997, 'n_words': 772}