├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
├── scopes
│ └── scope_settings.xml
└── vcs.xml
├── README.md
├── android.iml
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── oneall
│ │ └── oneallsample
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── oneall
│ │ └── oneallsample
│ │ ├── ImageDownloader.java
│ │ ├── OAMainActivity.java
│ │ └── PostActivity.java
│ └── res
│ ├── drawable
│ └── button_background.xml
│ ├── layout
│ ├── activity_oamain.xml
│ └── activity_post.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── oneallsdk
├── .gitignore
├── build.gradle
├── gradle.properties
├── libs
│ └── logentries-android-2.1.4.jar
├── maven-push.gradle
├── oneallsdk.iml
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── oneall
│ │ └── oneallsdk
│ │ ├── FacebookWrapper.java
│ │ ├── MessagePostResult.java
│ │ ├── OAError.java
│ │ ├── OALog.java
│ │ ├── OAManager.java
│ │ ├── ProviderFragment.java
│ │ ├── ProviderManager.java
│ │ ├── ProviderSelectActivity.java
│ │ ├── Settings.java
│ │ ├── TwitterWrapper.java
│ │ ├── UserInputDialog.java
│ │ ├── WebLoginActivity.java
│ │ └── rest
│ │ ├── ItemTypeAdapterFactory.java
│ │ ├── ServiceCallback.java
│ │ ├── ServiceManagerProvider.java
│ │ ├── models
│ │ ├── NativeLoginRequest.java
│ │ ├── PostMessageRequest.java
│ │ ├── PostMessageResponse.java
│ │ ├── Provider.java
│ │ ├── ResponseConnection.java
│ │ ├── ResponseProvidersList.java
│ │ ├── ServiceResponseBase.java
│ │ └── User.java
│ │ └── service
│ │ ├── ConnectionService.java
│ │ ├── MessagePostService.java
│ │ ├── ProviderService.java
│ │ └── UserService.java
│ └── res
│ ├── drawable
│ ├── button_login_amazon.png
│ ├── button_login_blogger.png
│ ├── button_login_devianart.png
│ ├── button_login_disqus.png
│ ├── button_login_facebook.png
│ ├── button_login_foursquare.png
│ ├── button_login_github.png
│ ├── button_login_google.png
│ ├── button_login_instagram.png
│ ├── button_login_linkedin.png
│ ├── button_login_livejournal.png
│ ├── button_login_mailru.png
│ ├── button_login_msn.png
│ ├── button_login_myspace.png
│ ├── button_login_odnoklassniki.png
│ ├── button_login_openid.png
│ ├── button_login_paypal.png
│ ├── button_login_reddit.png
│ ├── button_login_skyrock.png
│ ├── button_login_stackexchange.png
│ ├── button_login_steam.png
│ ├── button_login_twitch.png
│ ├── button_login_twitter.png
│ ├── button_login_vimeo.png
│ ├── button_login_vkontakte.png
│ ├── button_login_windowslive.png
│ ├── button_login_wordpress.png
│ ├── button_login_yahoo.png
│ └── button_login_youtube.png
│ ├── layout
│ ├── activity_provider_select.xml
│ ├── activity_web_login.xml
│ ├── fragment_provider.xml
│ └── user_input_dialog.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── dimens.xml
│ └── strings.xml
├── proguard-com.twitter.sdk.android.twitter.txt
├── screenshots
└── login_providers_selector.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/scopes/scope_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Developing Android application with OneAll SDK
2 |
3 | OneAll SDK provides tools to use OneAll Social Login features on Android Platform. It allows logging in users and posting messages on social networks using existing OneAll connectors. The library is integrated in a few lines of code and uses native Android integration with Facebook and Twitter where possible.
4 |
5 | ## Integrating SDK
6 |
7 | ### Running Sample Application
8 |
9 | In order to run sample application, number of specific settings have to be updated in the code. Open `app/src/main/res/values/strings.xml` file and update the following values:
10 | - `oneall_subdomain`- OneAll application subdomain from your [application dashboard](https://app.oneall.com/applications/).
11 | - `facebook_app_id`- Facebook application ID used for authentication.
12 | - `fb_login_protocol_scheme`- Facebook login protol scheme. generally should be in format "fb", i.e. "fb1234567890"
13 | - `twitter_consumer_key`- Twitter application consumer key from [Twitter Application Settings](http://apps.twitter.com/).
14 | - `twitter_consumer_secret`- Twitter application consumer secrect from [Twitter Application Settings](http://apps.twitter.com/).
15 |
16 | Twitter consumer key and twitter consumer secret are optional and may be omitted if you don't want to use native Android Twitter authentication.
17 |
18 |
19 | ### Including Libraries
20 |
21 | SDK added to the project with a few lines of code using Gradle.
22 |
23 | After opening the project, edit `build.gradle` file. Add this to Module-level `/app/build.gradle` before `dependencies`:
24 | ```groovy
25 | repositories {
26 | mavenCentral()
27 | maven { 'https://maven.fabric.io/public' }
28 | }
29 | ```
30 | Add the compile dependency with the latest version of the OneAll SDK in the `build.gradle` file:
31 | ```groovy
32 | dependencies {
33 | compile 'com.oneall:oneall-sdk:1.0'
34 | }
35 | ```
36 | Sync Gradle and build your project. Now you will be able to use `com.oneall.OAManager` in your code:
37 |
38 | ```java
39 | OAManager
40 | .getInstance()
41 | .setup(this, "demo", TWITTER_KEY_OR_NULL, TWITTER_SECRET_OR_NULL);
42 | ```
43 | Of course, replace "demo" with the subdomain of your OneAll application.
44 |
45 | ### Setting Up Facebook Integration
46 |
47 | This part is required in order for Facebook login to work correct. The instructions here are similar to [Facebook Android Getting Started Guide](https://developers.facebook.com/docs/android/getting-started) .
48 |
49 | Add your Facebook App ID to your project's strings file and update your Android manifest:
50 |
51 | 1. Open `res/values/strings.xml`
52 | 2. Add a new string with the name `facebook_app_id` and value as your Facebook App ID
53 | 3. Open `AndroidManifest.xml`
54 | 4. Add a uses-permission element to the manifest: ` `
55 | 5. Add a meta-data element to the application element:
56 |
57 | ```xml
58 |
59 | ...
60 |
61 | ...
62 |
63 | ```
64 |
65 | Next, setup your Facebook application by creating and setting up development hash as described in **"Create a Development Key Hash**" and **"Setting a Release Key Hash**" sections of [Getting Started Guide](https://developers.facebook.com/docs/android/getting-started)
66 |
67 | ### Code Integration
68 |
69 | Open the activity class that will use OneAll integration. Add the following into `onCreate`
70 | ```java
71 | import com.oneall.oneallsdk.OAManager;
72 | import com.oneall.oneallsdk.rest.models.User;
73 | import com.oneall.oneallsdk.OAError;
74 | @Override
75 | protected void onCreate(Bundle savedInstanceState) {
76 | super.onCreate(savedInstanceState);
77 | // Your initialization code
78 | OAManager
79 | .getInstance()
80 | .setup(this, "demo", TWITTER_KEY_OR_NULL, TWITTER_SECRET_OR_NULL);
81 | OAManager.getInstance().onCreate(this, savedInstanceState);
82 | }
83 | ```
84 | This will initialize OneAll module and set it up with your subdomain settings.
85 |
86 | Now, pass all activity creation events to the manager:
87 | ```java
88 | @Override
89 | protected void onResume() {
90 | super.onResume();
91 | OAManager.getInstance().onResume();
92 | }
93 | @Override
94 | protected void onPostResume() {
95 | super.onPostResume();
96 | OAManager.getInstance().onPostResume(this);
97 | }
98 | @Override
99 | protected void onPause() {
100 | super.onPause();
101 | OAManager.getInstance().onPause();
102 | }
103 | @Override
104 | protected void onDestroy() {
105 | super.onDestroy();
106 | OAManager.getInstance().onDestroy();
107 | }
108 | @Override
109 | protected void onSaveInstanceState(Bundle outState) {
110 | super.onSaveInstanceState(outState);
111 | OAManager.getInstance().onSaveInstanceState(outState);
112 | }
113 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
114 | super.onActivityResult(requestCode, resultCode, data);
115 | OAManager.getInstance().onActivityResult(requestCode, resultCode, data);
116 | }
117 | ```
118 | Next, use the manager to login into OneAll:
119 | ```java
120 | OAManager.getInstance().login(this, new OAManager.LoginHandler() {
121 | @Override
122 | public void loginSuccess(User user, Boolean newUser) {
123 | Log.v("tag", String.format("OA user %s", user.identity.name.formatted));
124 | }
125 | @Override
126 | public void loginFailure(OAError error) {
127 | Log.v("tag", String.format("Failed to login into OA: %s", error.getMessage()));
128 | }
129 | });
130 | ```
131 | The SDK will show selector of platforms configured for specified OneAll subdomain:
132 |
133 | 
134 |
135 | You can use your own native design and login without activating the selector:
136 |
137 | OAManager.getInstance().login(this, "facebook", loginHandler);
138 |
139 | ### Posting Messages onto Wall
140 |
141 | In order to post message `OAManager` provides `postMessage` method:
142 | ```java
143 | public void postMessage(
144 | String text,
145 | String pictureUrl,
146 | String videoUrl,
147 | String linkUrl,
148 | String linkName,
149 | String linkCaption,
150 | String linkDescription,
151 | Boolean enableTracking,
152 | String userToken,
153 | String publishToken,
154 | final Collection providers,
155 | final OAManagerPostHandler handler)
156 | ```
157 | Example usage:
158 | ```java
159 | OAManager.getInstance().postMessage(
160 | "Me and the elephant",
161 | "[](https://drscdn.500px.org/photo/57410272/m%3D2048/9e1b37755cc09022b7eb0993379cc6f6)https://drscdn.500px.org/photo/57410272/m%3D2048/9e1b37755cc09022b7eb0993379cc6f6",
162 | null,
163 | null,
164 | null,
165 | null,
166 | null,
167 | true,
168 | user.userToken,
169 | user.publishToken.key,
170 | new string[] { "facebook" },
171 | new OAManager.OAManagerPostHandler() {
172 | @Override
173 | public void postComplete(Boolean success, PostMessageResponse response) {
174 | if (success) {
175 | Log.v("posted message to user wall");
176 | } else {
177 | Log.v("failed to post message to user wall");
178 | }
179 | }
180 | }
181 | );
182 | ```
183 | Where `user` object is the same user object that was received via callback on user authentication earlier in the process. This object implements `Serializable` interface and can be serialized and cached between session to avoid repeated logins on every application run.
184 |
--------------------------------------------------------------------------------
/android.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | maven { url 'https://maven.fabric.io/public' }
4 | }
5 |
6 | dependencies {
7 | classpath 'io.fabric.tools:gradle:1.21.7'
8 | }
9 | }
10 | apply plugin: 'com.android.application'
11 | apply plugin: 'io.fabric'
12 |
13 | android {
14 | compileSdkVersion 26
15 | buildToolsVersion "25.0.3"
16 | defaultConfig {
17 | applicationId "com.oneall.oneallsample"
18 | minSdkVersion 15
19 | targetSdkVersion 26
20 | versionName '1.1'
21 | versionCode 1
22 | }
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 | productFlavors {
30 | }
31 | }
32 |
33 | repositories {
34 | mavenCentral()
35 | maven { url 'https://maven.fabric.io/public' }
36 | }
37 |
38 | dependencies {
39 | compile fileTree(dir: 'libs', include: ['*.jar'])
40 | compile 'com.android.support:appcompat-v7:25.3.1'
41 | compile project(':oneallsdk')
42 | }
43 |
--------------------------------------------------------------------------------
/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 /Users/urk/Library/Android/sdk/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/androidTest/java/com/oneall/oneallsample/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsample;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
34 |
35 |
38 |
39 |
41 |
42 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/oneall/oneallsample/ImageDownloader.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsample;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.BitmapFactory;
5 | import android.os.AsyncTask;
6 | import android.util.Log;
7 | import android.widget.ImageView;
8 |
9 | import java.io.InputStream;
10 | import java.net.HttpURLConnection;
11 | import java.net.URL;
12 |
13 | /**
14 | * Download image in background and put downloaded image into ImageView
15 | */
16 | class ImageDownloader extends AsyncTask {
17 |
18 | private final static String TAG = ImageDownloader.class.toString();
19 |
20 | private ImageView bmImage;
21 |
22 | ImageDownloader(ImageView bmImage) {
23 | this.bmImage = bmImage;
24 | }
25 |
26 | protected Bitmap doInBackground(String... urls) {
27 | String urldisplay = urls[0];
28 | Bitmap mIcon11 = null;
29 |
30 | Log.i(TAG, String.format("Downloading image from %s", urldisplay));
31 |
32 | HttpURLConnection conn = null;
33 | try {
34 | URL url = new URL(urldisplay);
35 | conn = (HttpURLConnection) url.openConnection();
36 | if (conn.getResponseCode() == 200) {
37 | InputStream is = conn.getInputStream();
38 | mIcon11 = BitmapFactory.decodeStream(is);
39 |
40 | Log.i(TAG, String.format("Image downloaded from %s", urldisplay));
41 | } else {
42 | Log.i(TAG, String.format("Failed to download image from %s with status code %d",
43 | urldisplay, conn.getResponseCode()));
44 | }
45 |
46 | Log.i(TAG, String.format("Image downloaded from %s", urldisplay));
47 | } catch (Exception e) {
48 | Log.e(TAG, e.getMessage());
49 | } finally {
50 | if (conn != null) {
51 | conn.disconnect();
52 | }
53 | }
54 | return mIcon11;
55 | }
56 |
57 | protected void onPostExecute(Bitmap result) {
58 | bmImage.setImageBitmap(result);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/java/com/oneall/oneallsample/OAMainActivity.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsample;
2 |
3 | import com.oneall.oneallsdk.OAError;
4 | import com.oneall.oneallsdk.OAManager;
5 | import com.oneall.oneallsdk.rest.models.User;
6 |
7 | import android.content.Intent;
8 | import android.os.Bundle;
9 | import android.support.v7.app.ActionBarActivity;
10 | import android.util.Log;
11 | import android.view.View;
12 | import android.widget.Button;
13 | import android.widget.ImageView;
14 | import android.widget.TextView;
15 |
16 | public class OAMainActivity extends ActionBarActivity {
17 |
18 | // Note: Your consumer key and secret should be obfuscated in your source code before shipping.
19 | private String mTwitterKey;
20 | private String mTwitterSecret;
21 | private String mSubdomain;
22 |
23 | // region Properties
24 |
25 | private User user;
26 | private Button buttonPost;
27 | private ImageView imageUserAvatar;
28 | private TextView textUserName;
29 |
30 | // endregion
31 |
32 | private OAManager.LoginHandler loginHandler = new OAManager.LoginHandler() {
33 | @Override
34 | public void loginSuccess(User user, Boolean newUser) {
35 | Log.v(OAMainActivity.class.toString(), "successfully logged into OA");
36 | textUserName.setText(user.identity.name.formatted);
37 | new ImageDownloader(imageUserAvatar).execute(user.identity.pictureUrl);
38 | OAMainActivity.this.user = user;
39 |
40 | buttonPost.setEnabled(true);
41 | }
42 |
43 | @Override
44 | public void loginFailure(OAError error) {
45 | Log.v(OAMainActivity.class.toString(), "Failed to login into OA");
46 | buttonPost.setEnabled(false);
47 | textUserName.setText(null);
48 | imageUserAvatar.setImageDrawable(null);
49 | }
50 | };
51 |
52 | @Override
53 | protected void onResume() {
54 | super.onResume();
55 | OAManager.getInstance().onResume();
56 | }
57 |
58 | @Override
59 | protected void onPause() {
60 | super.onPause();
61 | OAManager.getInstance().onPause();
62 | }
63 |
64 | @Override
65 | protected void onDestroy() {
66 | super.onDestroy();
67 | OAManager.getInstance().onDestroy();
68 | OAManager.destroyInstance();
69 | }
70 |
71 | @Override
72 | protected void onSaveInstanceState(Bundle outState) {
73 | super.onSaveInstanceState(outState);
74 | OAManager.getInstance().onSaveInstanceState(outState);
75 | }
76 |
77 | @Override
78 | protected void onCreate(Bundle savedInstanceState) {
79 | super.onCreate(savedInstanceState);
80 |
81 | setContentView(R.layout.activity_oamain);
82 |
83 | mTwitterKey = getString(R.string.twitter_consumer_key);
84 | mTwitterSecret = getString(R.string.twitter_consumer_secret);
85 | mSubdomain = getString(R.string.oneall_subdomain);
86 |
87 | OAManager.getInstance().setup(this, mSubdomain, mTwitterKey, mTwitterSecret);
88 | OAManager.getInstance().onCreate(this, savedInstanceState);
89 |
90 | imageUserAvatar = (ImageView) findViewById(R.id.main_activity_user_avatar);
91 | textUserName = (TextView) findViewById(R.id.main_activity_user_name);
92 |
93 | findViewById(R.id.button_login).setOnClickListener(new View.OnClickListener() {
94 | @Override
95 | public void onClick(View v) {
96 | OAManager.getInstance().login(OAMainActivity.this, loginHandler);
97 | }
98 | });
99 |
100 | findViewById(R.id.button_main_login_facebook).setOnClickListener(new View.OnClickListener() {
101 | @Override
102 | public void onClick(View v) {
103 | OAManager.getInstance().login(OAMainActivity.this, "facebook", loginHandler);
104 | }
105 | });
106 |
107 | findViewById(R.id.button_main_login_foursquare).setOnClickListener(new View.OnClickListener() {
108 | @Override
109 | public void onClick(View v) {
110 | OAManager.getInstance().login(OAMainActivity.this, "foursquare", loginHandler);
111 | }
112 | });
113 |
114 | buttonPost = (Button) findViewById(R.id.button_post);
115 | buttonPost.setOnClickListener(new View.OnClickListener() {
116 | @Override
117 | public void onClick(View v) {
118 | handlerButtonPost();
119 | }
120 | });
121 | }
122 |
123 | @Override
124 | protected void onPostResume() {
125 | super.onPostResume();
126 | OAManager.getInstance().onPostResume(this);
127 | }
128 |
129 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
130 | super.onActivityResult(requestCode, resultCode, data);
131 | OAManager.getInstance().onActivityResult(requestCode, resultCode, data);
132 | }
133 |
134 | private void handlerButtonPost() {
135 | Intent intent = new Intent(this, PostActivity.class);
136 | intent.putExtra(PostActivity.INTENT_EXTRA_USER, user);
137 | startActivity(intent);
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/app/src/main/java/com/oneall/oneallsample/PostActivity.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsample;
2 |
3 | import android.app.AlertDialog;
4 | import android.app.Dialog;
5 | import android.content.DialogInterface;
6 | import android.support.v7.app.ActionBarActivity;
7 | import android.os.Bundle;
8 | import android.util.Log;
9 | import android.view.Menu;
10 | import android.view.MenuItem;
11 | import android.view.View;
12 | import android.widget.EditText;
13 |
14 | import com.oneall.oneallsdk.OAError;
15 | import com.oneall.oneallsdk.OAManager;
16 | import com.oneall.oneallsdk.rest.models.PostMessageResponse;
17 | import com.oneall.oneallsdk.rest.models.User;
18 |
19 | import java.util.ArrayList;
20 | import java.util.Arrays;
21 | import java.util.Collection;
22 |
23 |
24 | public class PostActivity extends ActionBarActivity {
25 |
26 | // region Constants
27 |
28 | public final static String INTENT_EXTRA_USER = "user";
29 |
30 | private final static String TAG = PostActivity.class.toString();
31 |
32 | // endregion
33 |
34 | @Override
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setContentView(R.layout.activity_post);
38 |
39 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
40 |
41 | if (getIntent().getExtras().get(INTENT_EXTRA_USER) == null) {
42 | finish();
43 | }
44 |
45 | findViewById(R.id.post_activity_button_post).setOnClickListener(new View.OnClickListener() {
46 | @Override
47 | public void onClick(View v) {
48 | handlerButtonPost();
49 | }
50 | });
51 | }
52 |
53 | @Override
54 | public boolean onOptionsItemSelected(MenuItem item) {
55 | if (item.getItemId() == android.R.id.home) {
56 | finish();
57 | return true;
58 | }
59 | return super.onOptionsItemSelected(item);
60 | }
61 |
62 | private void handlerButtonPost() {
63 | User user = (User) getIntent().getExtras().get(INTENT_EXTRA_USER);
64 |
65 | OAManager.getInstance().postMessage(
66 | ((EditText) findViewById(R.id.post_activity_text_text)).getText().toString(),
67 | ((EditText) findViewById(R.id.post_activity_text_picture)).getText().toString(),
68 | ((EditText) findViewById(R.id.post_activity_text_video)).getText().toString(),
69 | ((EditText) findViewById(R.id.post_activity_text_link)).getText().toString(),
70 | ((EditText) findViewById(R.id.post_activity_text_link_name)).getText().toString(),
71 | ((EditText) findViewById(R.id.post_activity_text_link_caption)).getText().toString(),
72 | ((EditText) findViewById(R.id.post_activity_text_link_description)).getText().toString(),
73 | true,
74 | user.userToken,
75 | user.publishToken.key,
76 | getProvidersForUser(user),
77 | new OAManager.OAManagerPostHandler() {
78 | @Override
79 | public void postComplete(Boolean success, PostMessageResponse response) {
80 | postResponseComplete(success, response);
81 | }
82 | }
83 | );
84 | }
85 |
86 | private Collection getProvidersForUser(User user) {
87 | ArrayList rv = new ArrayList<>();
88 | rv.add(user.identity.provider);
89 | return rv;
90 | }
91 |
92 | private void postResponseComplete(Boolean success, PostMessageResponse response) {
93 | ArrayList failures = new ArrayList<>();
94 | for (PostMessageResponse.Data.Message.Publication pub : response.data.message.publications) {
95 | if (pub.status == null ||
96 | pub.status.flag == null ||
97 | !pub.status.flag.equals("success")) {
98 | failures.add(pub.provider);
99 | }
100 | }
101 |
102 | DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
103 | @Override
104 | public void onClick(DialogInterface dialog, int which) {
105 | finish();
106 | }
107 | };
108 |
109 | if (failures.size() > 0) {
110 | new AlertDialog.Builder(this)
111 | .setTitle("Oops")
112 | .setMessage("Failed providers list: " + failures)
113 | .setPositiveButton("OK", listener)
114 | .show();
115 |
116 | } else {
117 | new AlertDialog.Builder(this)
118 | .setTitle("Posted")
119 | .setMessage("Message has been posted")
120 | .setPositiveButton("OK", listener)
121 | .show();
122 | }
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/button_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_oamain.xml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
22 |
27 |
30 |
38 |
39 |
48 |
49 |
50 |
51 |
59 |
64 |
68 |
76 |
84 |
85 |
86 |
87 |
100 |
105 |
112 |
118 |
119 |
120 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_post.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
14 |
15 |
21 |
22 |
28 |
29 |
34 |
35 |
41 |
42 |
48 |
49 |
54 |
55 |
61 |
62 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #444
4 | #F9930E
5 | #E98300
6 | @android:color/white
7 | #5C8900
8 | #777
9 | #222
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | OneAll Social Login Sample
3 |
4 | Hello world!
5 | Settings
6 | User avatar
7 | ]]>
8 | Post Message to Networks
9 | Link: http://www.oneall.com
10 | Link name: e.g. OneAll Main Site
11 | Link caption
12 | Link Description
13 | http://www.oneall.com
14 |
15 | OneAll Social Login is used by more than 250,000 websites worldwide, including small blogs, growing startups and large corporate enterprises.
16 | http://public.oneallcdn.com/img/oneall_header_logo.png
17 | Link to posted picture
18 | Link to Video
19 | Text
20 | OneAll Social Login is used by more than 250,000 websites worldwide, including small blogs, growing startups and large corporate enterprises.
21 | Share
22 | Facebook
23 | SDK Buttons
24 | Foursquare
25 | Native buttons
26 | User Information
27 |
28 | YOUR ONEALL SUBDOMAIN HERE
29 | YOUR FACEBOOK APP ID HERE
30 | YOUR TWITTER CONSUMER KEY HERE
31 | YOUR TWITTER CONSUMER SECRET HERE
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/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:2.3.3'
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 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
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/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Jul 01 23:32:56 IDT 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-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 |
--------------------------------------------------------------------------------
/oneallsdk/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/oneallsdk/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 26
5 | buildToolsVersion "25.0.3"
6 | defaultConfig {
7 | minSdkVersion 15
8 | versionCode 4
9 | versionName '0.9'
10 | targetSdkVersion 26
11 | }
12 | buildTypes {
13 | release {
14 | minifyEnabled false
15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
16 | }
17 | }
18 | productFlavors {
19 | }
20 | }
21 |
22 | repositories {
23 | mavenCentral()
24 | maven { url 'https://maven.fabric.io/public' }
25 | }
26 |
27 | dependencies {
28 | compile fileTree(dir: 'libs', include: ['*.jar'])
29 | compile 'com.android.support:appcompat-v7:25.3.1'
30 | compile 'com.squareup.retrofit:retrofit:1.9.0'
31 | compile 'com.facebook.android:facebook-android-sdk:[4,5)'
32 | compile('com.twitter.sdk.android:twitter-core:1.6.0@aar') {
33 | transitive = true;
34 | }
35 | }
36 |
37 | def isReleaseBuild() {
38 | return version.contains("SNAPSHOT") == false
39 | }
40 |
41 | apply from: 'maven-push.gradle'
--------------------------------------------------------------------------------
/oneallsdk/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=oneall-sdk
2 | POM_ARTIFACT_ID=oneall-sdk
3 | POM_PACKAGING=aar
4 | VERSION_NAME=1.0
5 | VERSION_CODE=5
6 | GROUP=com.oneall
7 |
8 | POM_DESCRIPTION=OneAll Android SDK
9 | POM_URL=https://www.oneall.com
10 | POM_SCM_URL=https://github.com/oneall/ios-sdk
11 | POM_SCM_CONNECTION=scm:git@github.com:oneall/android-sdk.git
12 | POM_SCM_DEV_CONNECTION=scm:git@github.com:oneall/android-sdk.git
13 | POM_LICENCE_NAME=The Apache Software License, Version 2.0
14 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
15 | POM_LICENCE_DIST=repo
16 | POM_DEVELOPER_ID=urk
17 | POM_DEVELOPER_NAME=Uri Kogan - See more at http://ukogan.com
18 |
19 | SNAPSHOT_REPOSITORY_URL=https://oss.sonatype.org/content/repositories/snapshots
20 | RELEASE_REPOSITORY_URL=https://oss.sonatype.org/service/local/staging/deploy/maven2
21 |
--------------------------------------------------------------------------------
/oneallsdk/libs/logentries-android-2.1.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/libs/logentries-android-2.1.4.jar
--------------------------------------------------------------------------------
/oneallsdk/maven-push.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'maven'
2 | apply plugin: 'signing'
3 |
4 | def sonatypeRepositoryUrl
5 |
6 | if (version.is('unspecified') && hasProperty('VERSION_NAME')) {
7 | version = VERSION_NAME;
8 | }
9 |
10 | println 'Version: ' + version
11 |
12 | /* select repository URL according to the type of the build */
13 | if (isReleaseBuild()) {
14 | println 'RELEASE BUILD'
15 | sonatypeRepositoryUrl = hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
16 | : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
17 | } else {
18 | println 'DEBUG BUILD'
19 | sonatypeRepositoryUrl = hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
20 | : "https://oss.sonatype.org/content/repositories/snapshots/"
21 | }
22 |
23 | def getRepositoryUsername() {
24 | return hasProperty('nexusUsername') ? nexusUsername : ""
25 | }
26 |
27 | def getRepositoryPassword() {
28 | return hasProperty('nexusPassword') ? nexusPassword : ""
29 | }
30 |
31 | afterEvaluate { project ->
32 | uploadArchives {
33 | repositories {
34 | mavenDeployer {
35 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
36 |
37 | pom.artifactId = POM_ARTIFACT_ID
38 | pom.groupId = GROUP
39 |
40 | repository(url: sonatypeRepositoryUrl) {
41 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
42 | }
43 |
44 | pom.project {
45 | name POM_NAME
46 | packaging POM_PACKAGING
47 | description POM_DESCRIPTION
48 | url POM_URL
49 | version project.version
50 |
51 | scm {
52 | url POM_SCM_URL
53 | connection POM_SCM_CONNECTION
54 | developerConnection POM_SCM_DEV_CONNECTION
55 | }
56 |
57 | licenses {
58 | license {
59 | name POM_LICENCE_NAME
60 | url POM_LICENCE_URL
61 | distribution POM_LICENCE_DIST
62 | }
63 | }
64 |
65 | developers {
66 | developer {
67 | id POM_DEVELOPER_ID
68 | name POM_DEVELOPER_NAME
69 | }
70 | }
71 | }
72 | }
73 | }
74 | }
75 |
76 | signing {
77 | required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
78 | sign configurations.archives
79 | }
80 |
81 | task androidJavadocs(type: Javadoc) {
82 | source = android.sourceSets.main.java.sourceFiles
83 | }
84 |
85 | task androidJavadocsJar(type: Jar) {
86 | classifier = 'javadoc'
87 | //basename = artifact_id
88 | from androidJavadocs.destinationDir
89 | }
90 |
91 | task androidSourcesJar(type: Jar) {
92 | classifier = 'sources'
93 | //basename = artifact_id
94 | from android.sourceSets.main.java.sourceFiles
95 | }
96 |
97 | artifacts {
98 | //archives packageReleaseJar
99 | archives androidSourcesJar
100 | archives androidJavadocsJar
101 | }
102 | }
--------------------------------------------------------------------------------
/oneallsdk/oneallsdk.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/oneallsdk/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 /Users/urk/Library/Android/sdk/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 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
10 |
13 |
14 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
27 |
28 |
29 |
30 |
33 |
34 |
35 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/FacebookWrapper.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk;
2 |
3 | import com.facebook.CallbackManager;
4 | import com.facebook.FacebookCallback;
5 | import com.facebook.FacebookException;
6 | import com.facebook.login.LoginManager;
7 | import com.facebook.login.LoginResult;
8 |
9 | import android.app.Activity;
10 | import android.content.Intent;
11 | import android.content.pm.ApplicationInfo;
12 | import android.content.pm.PackageManager;
13 | import android.os.Bundle;
14 | import android.support.annotation.NonNull;
15 |
16 | import java.util.Collections;
17 |
18 | /** This class wraps interface to Facebook and hides implementation details */
19 | class FacebookWrapper {
20 | // region Helper classes and interfaces
21 |
22 | interface SessionStateListener {
23 |
24 | void success(String accessToken);
25 |
26 | void failure(OAError error);
27 | }
28 |
29 | // endregion
30 |
31 | // region Properties
32 |
33 | /** callback manager used to take care of session state changes */
34 | @NonNull
35 | private CallbackManager callbackManager;
36 |
37 | // endregion
38 |
39 | // region Lifecycle
40 |
41 | private static FacebookWrapper mInstance = null;
42 |
43 | private FacebookWrapper() {
44 | this.callbackManager = CallbackManager.Factory.create();
45 | }
46 |
47 | public static FacebookWrapper getInstance() {
48 | if (mInstance == null) {
49 | synchronized (FacebookWrapper.class) {
50 | if (mInstance == null) {
51 | mInstance = new FacebookWrapper();
52 | }
53 | }
54 | }
55 | return mInstance;
56 | }
57 |
58 | // endregion
59 |
60 | // region Interface methods
61 |
62 | void login(@NonNull Activity activity, @NonNull final SessionStateListener listener) {
63 | LoginManager.getInstance().registerCallback(
64 | callbackManager,
65 | new FacebookCallback() {
66 | @Override
67 | public void onSuccess(LoginResult loginResult) {
68 | listener.success(loginResult.getAccessToken().getToken());
69 | }
70 |
71 | @Override
72 | public void onCancel() {
73 | listener.failure(
74 | new OAError(OAError.ErrorCode.OA_ERROR_CANCELLED, "Cancelled"));
75 | }
76 |
77 | @Override
78 | public void onError(FacebookException error) {
79 | listener.failure(new OAError(
80 | OAError.ErrorCode.OA_ERROR_AUTH_FAIL, error.getMessage()));
81 | }
82 | });
83 |
84 | LoginManager
85 | .getInstance()
86 | .logInWithReadPermissions(activity, Collections.singletonList("public_profile"));
87 | }
88 |
89 | // endregion
90 |
91 | // region Utilities
92 |
93 | private void storeFacebookAppId(String appId, Activity activity) {
94 | try {
95 | ApplicationInfo info = activity
96 | .getPackageManager()
97 | .getApplicationInfo(activity.getPackageName(), PackageManager.GET_META_DATA);
98 |
99 | Bundle bundle = info.metaData;
100 | bundle.putString("com.facebook.sdk.ApplicationId", appId);
101 | } catch (PackageManager.NameNotFoundException e) {
102 | OALog.warn("Unable to set Facebook Application ID");
103 | }
104 | }
105 |
106 | // endregion
107 |
108 | // region Activity lifecycle responders
109 |
110 | void onActivityResult(int requestCode, int resultCode, Intent data) {
111 | callbackManager.onActivityResult(requestCode, resultCode, data);
112 | }
113 |
114 | // endregion
115 | }
116 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/MessagePostResult.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk;
2 |
3 | import java.util.Collection;
4 |
5 | /**
6 | * Class wrapping response for message posting API request. Mirrors JSON response described here:
7 | * {@link https://docs.oneall.com/api/resources/social-sharing/publish-new-message/ }
8 | */
9 | public class MessagePostResult {
10 | /** Class wrapping result of posting message to wall for single provider. */
11 | public class MessagePostProviderResult {
12 | public Boolean success;
13 | public String flag;
14 | public Integer code;
15 | public String message;
16 | public String provider;
17 |
18 | public MessagePostProviderResult(
19 | Boolean success,
20 | String flag,
21 | Integer code,
22 | String message,
23 | String provider) {
24 | this.success = success;
25 | this.flag = flag;
26 | this.code = code;
27 | this.message = message;
28 | this.provider = provider;
29 | }
30 | }
31 |
32 | public Object wholeResponse;
33 | public String messageToken;
34 | public Collection providerResults;
35 |
36 | public MessagePostResult(
37 | Object wholeResponse,
38 | String messageToken,
39 | Collection providerResults) {
40 | this.wholeResponse = wholeResponse;
41 | this.messageToken = messageToken;
42 | this.providerResults = providerResults;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/OAError.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.annotation.Nullable;
5 |
6 | /**
7 | * Common error type returned by the manager and passing message between modules
8 | */
9 | public class OAError {
10 | /** error codes */
11 | public enum ErrorCode {
12 | /** login has been cancelled by user */
13 | OA_ERROR_CANCELLED,
14 |
15 | /** authentication failed */
16 | OA_ERROR_AUTH_FAIL,
17 |
18 | /** failed to post message */
19 | OA_ERROR_MESSAGE_POST_FAIL,
20 |
21 | /** communication with server timeout */
22 | OA_ERROR_TIMEOUT,
23 |
24 | /** failure to retrieve user details after successful authentication */
25 | OA_ERROR_CONNECTION_ERROR
26 | }
27 |
28 | /** detailed human readable message */
29 | @Nullable private String message;
30 |
31 | /** error code */
32 | @NonNull private ErrorCode code;
33 |
34 | /**
35 | * default constructor
36 | *
37 | * @param code error code
38 | *
39 | * @param message human readable message
40 | */
41 |
42 | public OAError(@NonNull ErrorCode code, @Nullable String message) {
43 | this.message = message;
44 | this.code = code;
45 | }
46 |
47 | /**
48 | * getter of human readable error message
49 | *
50 | * @return a message
51 | */
52 | @Nullable public String getMessage() {
53 | return message;
54 | }
55 |
56 | /**
57 | * getter of error code
58 | *
59 | * @return an error code
60 | */
61 | @NonNull public ErrorCode getCode() {
62 | return code;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/OALog.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk;
2 |
3 | import com.logentries.android.AndroidLogger;
4 |
5 | import android.content.Context;
6 | import android.util.Log;
7 |
8 | /**
9 | * Wrapper class for error logger, able to handle multiple types of logs: LogEntries, regular
10 | * Android log. The class is used internally by OneAll SDK and should not be used by the external
11 | * application.
12 | */
13 | class OALog {
14 |
15 | // region Constants
16 |
17 | private final static String TAG = "oneall";
18 |
19 | // endregion
20 |
21 | // region Properties
22 |
23 | private static OALog mInstance = null;
24 |
25 | private AndroidLogger logger = null;
26 |
27 | // endregion
28 |
29 | // region Lifecycle
30 |
31 | /** block creation of log using {@code new OALog()} by making constructor private */
32 | private OALog() {
33 | }
34 |
35 | /**
36 | * constructor of the instance
37 | *
38 | * @param context context to use for logging operations
39 | */
40 | private OALog(Context context) {
41 | if (BuildConfig.DEBUG) {
42 | logger = AndroidLogger.getLogger(context, context.getString(R.string.logentries_token));
43 | }
44 | }
45 |
46 | /**
47 | * initialization method, should be called before using {@code OALog}
48 | *
49 | * @param context context under which the log should run
50 | */
51 | public static void init(Context context) {
52 | synchronized (OALog.class) {
53 | mInstance = new OALog(context);
54 | }
55 | }
56 |
57 | /**
58 | * get instance of the log
59 | *
60 | * @return a log
61 | */
62 | public static OALog getInstance() {
63 | if (mInstance == null) {
64 | synchronized (OALog.class) {
65 | if (mInstance == null) {
66 | mInstance = new OALog();
67 | }
68 | }
69 | }
70 | return mInstance;
71 | }
72 |
73 | // endregion
74 |
75 | // region Interface methods
76 |
77 | /**
78 | * post message with information level to log
79 | *
80 | * @param logMessage message to post
81 | */
82 | public static void info(String logMessage) {
83 | Log.i(TAG, logMessage);
84 | if (getInstance().logger != null) {
85 | getInstance().logger.info(logMessage);
86 | }
87 | }
88 |
89 | /**
90 | * post message with warning level to log
91 | *
92 | * @param logMessage message to post
93 | */
94 | public static void warn(String logMessage) {
95 | Log.w(TAG, logMessage);
96 | if (getInstance().logger != null) {
97 | getInstance().logger.warn(logMessage);
98 | }
99 | }
100 |
101 | /**
102 | * post message with error level to log
103 | *
104 | * @param logMessage message to post
105 | */
106 | public static void error(String logMessage) {
107 | Log.e(TAG, logMessage);
108 | if (getInstance().logger != null) {
109 | getInstance().logger.error(logMessage);
110 | }
111 | }
112 |
113 | // endregion
114 | }
115 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/OAManager.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk;
2 |
3 | import com.oneall.oneallsdk.OAError.ErrorCode;
4 | import com.oneall.oneallsdk.rest.ServiceCallback;
5 | import com.oneall.oneallsdk.rest.ServiceManagerProvider;
6 | import com.oneall.oneallsdk.rest.models.NativeLoginRequest;
7 | import com.oneall.oneallsdk.rest.models.PostMessageRequest;
8 | import com.oneall.oneallsdk.rest.models.PostMessageResponse;
9 | import com.oneall.oneallsdk.rest.models.Provider;
10 | import com.oneall.oneallsdk.rest.models.ResponseConnection;
11 | import com.oneall.oneallsdk.rest.models.User;
12 | import com.oneall.oneallsdk.rest.service.ConnectionService;
13 | import com.oneall.oneallsdk.rest.service.MessagePostService;
14 | import com.oneall.oneallsdk.rest.service.UserService;
15 | import com.twitter.sdk.android.core.TwitterAuthConfig;
16 | import com.twitter.sdk.android.core.TwitterCore;
17 |
18 | import android.app.Activity;
19 | import android.app.FragmentManager;
20 | import android.app.ProgressDialog;
21 | import android.content.Context;
22 | import android.content.Intent;
23 | import android.net.Uri;
24 | import android.os.Bundle;
25 | import android.view.WindowManager;
26 |
27 | import java.util.ArrayList;
28 | import java.util.Collection;
29 | import java.util.UUID;
30 |
31 | import io.fabric.sdk.android.Fabric;
32 | import retrofit.Callback;
33 | import retrofit.RetrofitError;
34 | import retrofit.client.Response;
35 |
36 | /**
37 | * Main manager providing interface to all OneAll operations and the whole API
38 | */
39 | public class OAManager {
40 |
41 | // region Constants
42 |
43 | private static final Integer INTENT_REQUEST_CODE_SELECT_ACTIVITY = 0;
44 | private static final Integer INTENT_REQUEST_CODE_LOGIN = 1;
45 |
46 | // endregion
47 |
48 | // region Helper classes and interfaces
49 |
50 | public interface LoginHandler {
51 |
52 | void loginSuccess(User user, Boolean newUser);
53 |
54 | void loginFailure(OAError error);
55 | }
56 |
57 | public interface OAManagerPostHandler {
58 |
59 | void postComplete(Boolean success, PostMessageResponse response);
60 | }
61 |
62 | // endregion
63 |
64 | // region Properties
65 |
66 | /** singleton instance variable */
67 | private static OAManager mInstance = null;
68 |
69 | /** application context */
70 | private Context mAppContext = null;
71 |
72 | /** login handler to call back */
73 | private LoginHandler loginHandler;
74 |
75 | /** nonce generated by the last login request */
76 | private String lastNonce;
77 |
78 | /** state flag, bad, bad, bad, see onPostResume() for explanation */
79 | private Boolean loginOnResume = false;
80 |
81 | /** key of the provider selected */
82 | private String loginOnResumeProvider;
83 |
84 | // endregion
85 |
86 | // region Lifecycle
87 |
88 | /**
89 | * gets a manager instance
90 | *
91 | * @return a OAManager instance
92 | */
93 | public static OAManager getInstance() {
94 | if (mInstance == null) {
95 | synchronized (OAManager.class) {
96 | if (mInstance == null) {
97 | mInstance = new OAManager();
98 | }
99 | }
100 | }
101 | return mInstance;
102 | }
103 |
104 | /**
105 | * destroys the current instance and its dependencies,
106 | * opening them up for garbage collection
107 | */
108 | public static void destroyInstance() {
109 | synchronized (OAManager.class) {
110 | if (mInstance != null) {
111 | // clean up
112 | TwitterWrapper.destroyInstance();
113 | // allow instance to be GCed
114 | mInstance = null;
115 | }
116 | }
117 | }
118 |
119 | // endregion
120 |
121 | // region Interface methods
122 |
123 | /**
124 | * setup manager instance. should be called before using the manager. Otherwise the manager will
125 | * not function.
126 | *
127 | * @param context context
128 | * @param subdomain subdomain of your OneAll application
129 | * @param twitterConsumerKey (optional) Twitter consumer key from
130 | * {@link https://apps.twitter.com/ }
131 | * @param twitterSecret (optional) Twitter secret key from
132 | * {@link https://apps.twitter.com/ }
133 | * @throws java.lang.NullPointerException if {@code context} is null
134 | * @throws java.lang.IllegalArgumentException if {@code subdomain} is null or empty
135 | */
136 | public void setup(
137 | Context context,
138 | String subdomain,
139 | String twitterConsumerKey,
140 | String twitterSecret) {
141 |
142 | if (context == null) {
143 | throw new NullPointerException("context cannot be null");
144 | }
145 |
146 | if (subdomain == null || subdomain.trim().length() == 0) {
147 | throw new IllegalArgumentException("Subdomain cannot be empty");
148 | }
149 |
150 | // make sure the ref we hold is from the application context
151 | mAppContext = context.getApplicationContext();
152 |
153 | OALog.init(mAppContext);
154 |
155 | // if the parent app already initialized Fabric for some of its other modules
156 | // make sure it includes the required TwitterCore. Otherwise, init it ourselves
157 | if (!Fabric.isInitialized()) {
158 | TwitterAuthConfig authConfig = new TwitterAuthConfig(twitterConsumerKey, twitterSecret);
159 | Fabric.with(this.mAppContext, new TwitterCore(authConfig));
160 | } else {
161 | if (Fabric.getKit(TwitterCore.class) == null) {
162 | OALog.error("Twitter's Fabric is already initialized but it doesn't include TwitterCore kit which is" +
163 | "required for Auth calls");
164 | } else {
165 | OALog.warn("Twitter's Fabric was already initialized with a TwitterCore kit. Reusing existing kit");
166 | }
167 | }
168 |
169 | OALog.info(String.format("SDK init with subdomain %s", subdomain));
170 |
171 | Settings.getInstance().setSubdomain(subdomain);
172 | ProviderManager.getInstance().refreshProviders(mAppContext);
173 | }
174 |
175 | /**
176 | * Starts authentication with OneAll using selected social network. If additional information is
177 | * required for provider, the user is shown a dialog with request for additional data. When all
178 | * the data is provided to the library, authentication process continues using OneAll API
179 | * servers. Upon completion {@code handler} will be used to inform the caller on operation
180 | * result. Information about the user is retrieved as part of the authentication process and
181 | * returned to {@code handler} callback.
182 | *
183 | * If the provider specified is "{@code facebook}" native device Facebook authentication is
184 | * used to login the user by using Facebook SDK for Android. If the provider specified is
185 | * "{@code twitter}" native device authentication is used to login the user with help of
186 | * Twitter SDK.
187 | *
188 | * @param activity current activity
189 | * @param provider provider to use for authentication; list of supported providers can be
190 | * retrieved using {@link #getProviders()}
191 | * @param handler completion handler, will be used to inform the caller about the end of the
192 | * authentication (either success or failure)
193 | * @return {@code true} if the login process has started successfully, {@code false} otherwise;
194 | * in case of {@code false} return code, {@code handler} will not be called
195 | * @throws java.lang.IllegalStateException if the manager has not been initialized
196 | */
197 | public Boolean login(final Activity activity, String provider, LoginHandler handler) {
198 | validateInitialization();
199 |
200 | loginHandler = handler;
201 |
202 | /* currently selected provider */
203 | Provider selectedProvider = ProviderManager.getInstance().findByKey(provider);
204 |
205 | if (selectedProvider == null) {
206 | throw new IllegalArgumentException("Specified provider does not exist");
207 | }
208 |
209 | lastNonce = UUID.randomUUID().toString();
210 |
211 | switch (provider) {
212 | case "facebook":
213 | FacebookWrapper.getInstance().login(
214 | activity,
215 | new FacebookWrapper.SessionStateListener() {
216 | @Override
217 | public void success(String accessToken) {
218 | facebookLoginSuccess(activity, accessToken);
219 | }
220 |
221 | @Override
222 | public void failure(OAError error) {
223 | facebookLoginFailure(error);
224 | }
225 | });
226 |
227 | break;
228 | case "twitter":
229 | TwitterWrapper.getInstance().login(activity, new TwitterWrapper.LoginComplete() {
230 | @Override
231 | public void success(String accessToken, String secret) {
232 | twitterLoginSuccess(activity, accessToken, secret);
233 | }
234 |
235 | @Override
236 | public void failure(OAError error) {
237 | twitterLoginFailure(error);
238 | }
239 | });
240 | break;
241 | default:
242 | webLoginWithProvider(activity, selectedProvider);
243 | break;
244 | }
245 |
246 | return true;
247 | }
248 |
249 | /**
250 | * Starts authentication with OneAll. In order to know which method to use for authentication
251 | * new activity is opened with selection of providers that are setup with current provider.
252 | * After the user selects one of the methods using this activity, the result is returned to
253 | * {@link #onActivityResult(int, int, android.content.Intent)} which, in turn, continues
254 | * authentication using selected social network. Upon completion {@code handler} will be used
255 | * to inform the caller on operation result. Information about the user is retrieved as part of
256 | * the authentication process and returned to {@code handler} callback.
257 | *
258 | * If the provider specified is "{@code facebook}" native device Facebook authentication is
259 | * used to login the user by using Facebook SDK for Android. If the provider specified is
260 | * "{@code twitter}" native device authentication is used to login the user with help of
261 | * Twitter SDK.
262 | *
263 | * @param activity current activity
264 | * @param handler completion handler, will be used to inform the caller about the end of the
265 | * authentication (either success or failure)
266 | * @return {@code true} if the login process has started successfully, {@code false} otherwise;
267 | * in case of {@code false} return code, {@code handler} will not be called
268 | * @throws java.lang.IllegalStateException if the manager has not been initialized
269 | */
270 | public Boolean login(Activity activity, LoginHandler handler) {
271 | validateInitialization();
272 |
273 | loginHandler = handler;
274 |
275 | Intent intent = new Intent(activity, ProviderSelectActivity.class);
276 | activity.startActivityForResult(intent, INTENT_REQUEST_CODE_SELECT_ACTIVITY);
277 | return true;
278 | }
279 |
280 | /**
281 | * Method used to post message to user wall. Response will include general {@code success} flag
282 | * as well as detailed result as received from the server ({@link com.oneall.oneallsdk.MessagePostResult}
283 | *
284 | * @param text body of the message to be posted
285 | * @param pictureUrl (optional) url of the image to be posted
286 | * @param videoUrl (optional) URL of video to be post
287 | * @param linkUrl (optional) URL to attach to the post
288 | * @param linkName (optional) name of the link posted; has no effect if {@code linkUrl} is {@code null}
289 | * @param linkCaption (optional) caption of the link posted; has no effect if {@code linkUrl} is {@code null}
290 | * @param linkDescription (optional) description of the link posted; has no effect if {@code linkUrl} is {@code null}
291 | * @param enableTracking should the {@code linkUrl} posted use OneAll link tracking?; has no effect if {@code linkUrl} is {@code null}
292 | * @param userToken user token received as part of {@link com.oneall.oneallsdk.rest.models.User#userToken} object received during
293 | * authentication
294 | * @param publishToken publish token received as part of {@link com.oneall.oneallsdk.rest.models.User#publishToken} object received during
295 | * authentication
296 | * @param providers array of provider identifiers; list of providers can be obtained by {@link #getProviders()}
297 | * @param handler response handler called on either posting success of failure
298 | * @throws java.lang.IllegalStateException if the manager has not been initialized
299 | * @see #getProviders()
300 | * @see com.oneall.oneallsdk.rest.models.User
301 | * @see com.oneall.oneallsdk.MessagePostResult
302 | */
303 | public void postMessage(
304 | String text,
305 | String pictureUrl,
306 | String videoUrl,
307 | String linkUrl,
308 | String linkName,
309 | String linkCaption,
310 | String linkDescription,
311 | Boolean enableTracking,
312 | String userToken,
313 | String publishToken,
314 | final Collection providers,
315 | final OAManagerPostHandler handler) {
316 |
317 | validateInitialization();
318 |
319 | MessagePostService service = ServiceManagerProvider.getInstance().getPostService();
320 | PostMessageRequest request = new PostMessageRequest(
321 | providers,
322 | text,
323 | pictureUrl,
324 | videoUrl,
325 | linkUrl,
326 | linkName,
327 | linkCaption,
328 | linkDescription,
329 | enableTracking);
330 |
331 | OALog.info("Posting message to providers");
332 |
333 | service.post(
334 | userToken,
335 | ServiceManagerProvider.buildPublishAuthHeader(publishToken),
336 | request,
337 | new ServiceCallback() {
338 | @Override
339 | public void success(PostMessageResponse postMessageResponse, Response response) {
340 | OALog.info(String.format("Message post succeeded: %s", response.toString()));
341 | if (handler != null) {
342 | handler.postComplete(true, postMessageResponse);
343 | }
344 | }
345 |
346 | @Override
347 | public void failure(ServiceError error) {
348 | //noinspection ThrowableResultOfMethodCallIgnored
349 | OALog.warn(String.format(
350 | "Message post failed: %s", error.getRetrofitError().getMessage()));
351 |
352 | if (handler != null) {
353 | handler.postComplete(false, error.getResponse());
354 | }
355 | }
356 | });
357 | }
358 |
359 | /**
360 | * handler of onPostResume signal of parent activity
361 | */
362 | public void onPostResume(Activity activity) {
363 | /* it is impossible to work with GUI (specifically Fragments) from onActivityResult():
364 | * http://stackoverflow.com/questions/16265733/
365 | *
366 | * In order to overcome this, onActivityResult() stores the required operation in queue and
367 | * onPostResume() takes care of this when the state has been restored. An ugly solution for an
368 | * ugly problem.
369 | */
370 | if (loginOnResume) {
371 | String providerKey = loginOnResumeProvider;
372 | loginOnResume = false;
373 | loginOnResumeProvider = null;
374 |
375 | login(activity, providerKey, loginHandler);
376 | }
377 | }
378 |
379 | /**
380 | * Get list of supported providers. All providers are returned and not only ones configured for
381 | * specified application
382 | *
383 | * @return array of providers supported by OneAll API
384 | */
385 | public Collection getProviders() {
386 | validateInitialization();
387 |
388 | ArrayList rv = new ArrayList<>();
389 | for (Provider p : ProviderManager.getInstance().getProviders()) {
390 | rv.add(p.getKey());
391 | }
392 | return rv;
393 | }
394 |
395 | // endregion
396 |
397 | // region Utilities
398 |
399 | /**
400 | * callback taking care of connection details retrieval. This is the end of authentication
401 | * process, so the user of {@code OAManager} is informed using {@link #loginHandler} listener
402 | */
403 | private Callback connectionCallback = new Callback() {
404 | @Override
405 | public void success(ResponseConnection connection, Response response) {
406 | if (loginHandler != null) {
407 | loginHandler.loginSuccess(connection.data.user, false);
408 | loginHandler = null;
409 | }
410 | }
411 |
412 | @Override
413 | public void failure(RetrofitError error) {
414 | if (loginHandler != null) {
415 | loginHandler.loginFailure(new OAError(
416 | OAError.ErrorCode.OA_ERROR_CONNECTION_ERROR,
417 | mAppContext.getResources().getString(R.string.connection_failure)));
418 | loginHandler = null;
419 | }
420 | }
421 | };
422 |
423 | /**
424 | * handler of login completion by {@link com.oneall.oneallsdk.WebLoginActivity}
425 | *
426 | * @param data intent data filled in with login result
427 | */
428 | private void webLoginComplete(Intent data) {
429 | String url = data.getExtras().getString(WebLoginActivity.INTENT_EXTRA_URL);
430 |
431 | OALog.info(String.format("Web login completed with URL %s", url));
432 |
433 | ConnectionService service = ServiceManagerProvider.getInstance().getConnectionService();
434 |
435 | service.info(
436 | ServiceManagerProvider.buildAuthHeader(lastNonce),
437 | Uri.parse(url).getQueryParameter("connection_token"),
438 | connectionCallback);
439 | }
440 |
441 | /**
442 | * actual login with user information already filled in
443 | *
444 | * @param userInput user information if required by this provider, can be null
445 | */
446 | private void webLoginWithLoginData(Activity activity, Provider provider, String userInput) {
447 | String url = getApiUrlForProvider(provider, lastNonce, userInput);
448 | OALog.info(String.format(
449 | "Web login with provider %s and url: %s", provider.getKey(), url));
450 | Intent i = new Intent(activity, WebLoginActivity.class);
451 | i.putExtra(WebLoginActivity.INTENT_EXTRA_URL, url);
452 |
453 | activity.startActivityForResult(i, INTENT_REQUEST_CODE_LOGIN);
454 | }
455 |
456 | /**
457 | * starts actual web login with selected provider by opening web view with provider relevant
458 | * URL
459 | */
460 | private void webLoginWithProvider(Activity activity, final Provider provider) {
461 | OALog.info(String.format("Login with provider %s", provider));
462 |
463 | if (provider.getAuthentication().getIsUserInputRequired()) {
464 | FragmentManager fm = activity.getFragmentManager();
465 | final UserInputDialog dialog = new UserInputDialog();
466 | dialog.setListener(new UserInputDialog.DialogListener() {
467 | @Override
468 | public void onCancel() { }
469 |
470 | @Override
471 | public void onAccept(String userInput) {
472 | webLoginWithLoginData(dialog.getActivity(), provider, userInput);
473 | }
474 | });
475 |
476 | Bundle args = new Bundle();
477 | args.putString(UserInputDialog.ARGUMENT_USER_INPUT_TYPE, provider.getAuthentication().getUserInputType());
478 | args.putString(UserInputDialog.ARGUMENT_PROVIDER_NAME, provider.getName());
479 |
480 | dialog.setArguments(args);
481 | dialog.show(fm, "user_input_dialog");
482 | } else {
483 | webLoginWithLoginData(activity, provider, null);
484 | }
485 | }
486 |
487 | /**
488 | * build URL used to start authentication process with specified provider
489 | *
490 | * @param provider provider to use for login
491 | * @param nonce nonce generated at the start of authentication process
492 | * @param loginData additional login data to be added to URL parameter
493 | * @return URL to open for user authentication
494 | */
495 | private String getApiUrlForProvider(Provider provider, String nonce, String loginData) {
496 | String url = String.format(
497 | "https://%s.api.oneall.com/socialize/connect/mobile/%s/?nonce=%s&callback_uri=oneall://%s",
498 | Settings.getInstance().getSubdomain(),
499 | provider.getKey(),
500 | nonce,
501 | provider.getKey());
502 | Uri.Builder uriBuilder = Uri.parse(url).buildUpon();
503 | if (loginData != null) {
504 | uriBuilder.appendQueryParameter("login_data", loginData);
505 | }
506 |
507 | return uriBuilder.build().toString();
508 | }
509 |
510 | /**
511 | * handler of native Facebook authentication failure
512 | *
513 | * @param error detailed error
514 | */
515 | private void facebookLoginFailure(OAError error) {
516 | OALog.warn(String.format("Failed to login with Facebook: %s", error.getMessage()));
517 | if (loginHandler != null) {
518 | loginHandler.loginFailure(error);
519 | }
520 | }
521 |
522 | /**
523 | * handler of successful native Facebook authentication
524 | *
525 | * @param guiContext context used for GUI tasks
526 | * @param accessToken Facebook access token received during authentication
527 | */
528 | private void facebookLoginSuccess(Context guiContext, String accessToken) {
529 | OALog.info("Logged in with Facebook");
530 | retrieveConnectionInfo(guiContext, "facebook", accessToken, null);
531 | }
532 |
533 | /**
534 | * handler of native Twitter authentication failure
535 | *
536 | * @param error detailed error
537 | */
538 | private void twitterLoginFailure(OAError error) {
539 | OALog.warn(String.format("Failed to login with Twitter: %s", error.getMessage()));
540 | if (loginHandler != null) {
541 | loginHandler.loginFailure(
542 | new OAError(OAError.ErrorCode.OA_ERROR_AUTH_FAIL,
543 | error.getMessage()));
544 | }
545 | }
546 |
547 | /**
548 | * handler of successful authentication using native Twitter SDK
549 | *
550 | * @param guiContext context used for GUI tasks
551 | * @param accessToken Twitter access token received after authentication process
552 | * @param secret Twitter secret key received after authentication process
553 | */
554 | private void twitterLoginSuccess(Context guiContext, String accessToken, String secret) {
555 | OALog.info("Logged in with Twitter");
556 | retrieveConnectionInfo(guiContext, "twitter", accessToken, secret);
557 | }
558 |
559 | /**
560 | * after successful login, user information has to be retrieved, which is the responsibility of
561 | * this method
562 | *
563 | * @param guiContext context used for GUI tasks
564 | * @param platform platform with which the authentication is performed
565 | * @param accessToken (optional) access token received during native authentication (e.g.
566 | * Facebook or Twitter)
567 | * @param secret (optional) secret key received during native authentication (e.g. Twitter)
568 | */
569 | private void retrieveConnectionInfo(
570 | Context guiContext, String platform, String accessToken, String secret) {
571 |
572 | try {
573 | final ProgressDialog pd = ProgressDialog.show(
574 | guiContext,
575 | guiContext.getString(R.string.reading_user_info_title),
576 | guiContext.getString(R.string.reading_user_info_message),
577 | true,
578 | true);
579 |
580 | UserService service = ServiceManagerProvider.getInstance().getUserService();
581 | NativeLoginRequest request = new NativeLoginRequest(platform, accessToken, secret);
582 |
583 | service.info(request, new Callback() {
584 | @Override
585 | public void success(ResponseConnection connection, Response response) {
586 | // dismiss the dialog: since we created it with an app context
587 | // we must explicitly request it to destroy itself
588 | pd.dismiss();
589 |
590 | if (loginHandler != null) {
591 | loginHandler.loginSuccess(connection.data.user, false);
592 | loginHandler = null;
593 | }
594 | }
595 |
596 | @Override
597 | public void failure(RetrofitError error) {
598 | pd.dismiss();
599 |
600 | if (loginHandler != null) {
601 | loginHandler.loginFailure(new OAError(
602 | OAError.ErrorCode.OA_ERROR_CONNECTION_ERROR,
603 | mAppContext.getResources().getString(R.string.connection_failure)));
604 | loginHandler = null;
605 | }
606 | }
607 | });
608 | } catch (WindowManager.BadTokenException e) {
609 | // the user backed out of the calling activity so we failed to show the loading view
610 | // notify the handler of a generic connection failure either way
611 | if (loginHandler != null) {
612 | loginHandler.loginFailure(new OAError(
613 | ErrorCode.OA_ERROR_CONNECTION_ERROR,
614 | mAppContext.getResources().getString(R.string.connection_failure)));
615 | loginHandler = null;
616 | }
617 | }
618 | }
619 |
620 | /** validate initialization state, throws an exception if the manager is not initialized */
621 | void validateInitialization() {
622 | if (mAppContext == null) {
623 | throw new IllegalStateException("Manager not initialized");
624 | }
625 | }
626 |
627 | // endregion
628 |
629 | // region Activity lifecycle responders
630 |
631 | /**
632 | * should be called by the using activity to process onCreate signal
633 | */
634 | @SuppressWarnings("UnusedParameters")
635 | public void onCreate(Activity activity, Bundle savedInstanceState) {
636 | }
637 |
638 | /**
639 | * should be called by the using activity to process onResume signal
640 | */
641 | public void onResume() {
642 | }
643 |
644 | /**
645 | * should be called by the using activity to process onPause signal
646 | */
647 | public void onPause() {
648 | }
649 |
650 | /**
651 | * should be called by the using activity to process onActivityResult signal
652 | */
653 | public void onActivityResult(int requestCode, int resultCode, Intent data) {
654 | switch (resultCode) {
655 | case Activity.RESULT_OK:
656 | if (requestCode == INTENT_REQUEST_CODE_SELECT_ACTIVITY) {
657 | loginOnResumeProvider = data.getExtras().getString(ProviderSelectActivity.INTENT_EXTRA_PROVIDER);
658 | loginOnResume = true;
659 | } else if (requestCode == INTENT_REQUEST_CODE_LOGIN) {
660 | webLoginComplete(data);
661 | } else {
662 | FacebookWrapper.getInstance().onActivityResult(requestCode, resultCode, data);
663 | TwitterWrapper.getInstance().onActivityResult(requestCode, resultCode, data);
664 | }
665 | break;
666 | case Activity.RESULT_CANCELED:
667 | // let the native sdk's handle the result cancelled ev
668 | FacebookWrapper.getInstance().onActivityResult(requestCode, resultCode, data);
669 | TwitterWrapper.getInstance().onActivityResult(requestCode, resultCode, data);
670 | /* fall through */
671 | case WebLoginActivity.RESULT_FAILED:
672 | if (loginHandler != null) {
673 | loginHandler.loginFailure(new OAError(OAError.ErrorCode.OA_ERROR_CANCELLED, null));
674 | loginHandler = null;
675 | }
676 | }
677 | }
678 |
679 | /**
680 | * should be called by the using activity to process onSaveInstanceState signal
681 | */
682 | @SuppressWarnings("UnusedParameters")
683 | public void onSaveInstanceState(Bundle outState) {
684 | }
685 |
686 | /**
687 | * should be called by the using activity to process onDestroy signal
688 | */
689 | public void onDestroy() {
690 | }
691 |
692 | // endregion
693 |
694 | }
695 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/ProviderFragment.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.Activity;
5 | import android.graphics.Color;
6 | import android.graphics.drawable.Drawable;
7 | import android.os.Build;
8 | import android.os.Bundle;
9 | import android.support.v4.app.Fragment;
10 | import android.view.LayoutInflater;
11 | import android.view.MotionEvent;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.widget.ImageView;
15 | import android.widget.TextView;
16 |
17 |
18 | /**
19 | * A simple {@link Fragment} subclass.
20 | * Activities that contain this fragment must implement the
21 | * {@link ProviderFragment.OnFragmentInteractionListener} interface
22 | * to handle interaction events.
23 | * Use the {@link ProviderFragment#newInstance} factory method to
24 | * create an instance of this fragment.
25 | */
26 | public class ProviderFragment extends Fragment {
27 |
28 | // region constants
29 |
30 | private static final String ARG_PARAM_PROVIDER_NAME = "mProviderName";
31 | private static final String ARG_PARAM_PROVIDER_KEY = "mProviderKey";
32 |
33 | // endregion
34 |
35 | // region Helper interfaces and classes
36 | /**
37 | * This interface must be implemented by activities that contain this
38 | * fragment to allow an interaction in this fragment to be communicated
39 | * to the activity and potentially other fragments contained in that
40 | * activity.
41 | */
42 | public interface OnFragmentInteractionListener {
43 | public void onFragmentInteraction(String providerKey);
44 | }
45 |
46 | // endregion
47 |
48 |
49 | // region Properties
50 |
51 | private String mProviderName;
52 |
53 | private String mProviderKey;
54 |
55 | private OnFragmentInteractionListener mListener;
56 |
57 | // endregion
58 |
59 | // region Lifecycle
60 |
61 | /**
62 | * Use this factory method to create a new instance of
63 | * this fragment using the provided parameters.
64 | *
65 | * @param providerName Name fo the provider which will be put on screen
66 | *
67 | * @param providerKey Unique identifier of provider which will be used in call-back
68 | *
69 | * @return A new instance of fragment ProviderFragment.
70 | */
71 | public static ProviderFragment newInstance(
72 | String providerName,
73 | String providerKey) {
74 | ProviderFragment fragment = new ProviderFragment();
75 | Bundle args = new Bundle();
76 | args.putString(ARG_PARAM_PROVIDER_NAME, providerName);
77 | args.putString(ARG_PARAM_PROVIDER_KEY, providerKey);
78 | fragment.setArguments(args);
79 | return fragment;
80 | }
81 |
82 | public ProviderFragment() {
83 | // Required empty public constructor
84 | }
85 |
86 | // endregion
87 |
88 | // region Fragment overrides
89 |
90 | @Override
91 | public void onCreate(Bundle savedInstanceState) {
92 | super.onCreate(savedInstanceState);
93 | if (getArguments() != null) {
94 | mProviderName = getArguments().getString(ARG_PARAM_PROVIDER_NAME);
95 | mProviderKey = getArguments().getString(ARG_PARAM_PROVIDER_KEY);
96 | }
97 | }
98 |
99 | @Override
100 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
101 | Bundle savedInstanceState) {
102 | // Inflate the layout for this fragment
103 | View rv = inflater.inflate(R.layout.fragment_provider, container, false);
104 |
105 | TextView textName = (TextView) rv.findViewById(R.id.provider_fragment_text_name);
106 | textName.setText(mProviderName);
107 |
108 | ImageView imageIcon = (ImageView) rv.findViewById(R.id.provider_fragment_image_view);
109 | imageIcon.setImageDrawable(getDrawable(mProviderKey));
110 |
111 | rv.setOnClickListener(new View.OnClickListener() {
112 | @Override
113 | public void onClick(View v) {
114 | mListener.onFragmentInteraction(mProviderKey);
115 | }
116 | });
117 |
118 | rv.setOnTouchListener(new View.OnTouchListener() {
119 | private Drawable mDefaultBackground;
120 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
121 | @Override
122 | public boolean onTouch(View v, MotionEvent event) {
123 | if (event.getAction() == android.view.MotionEvent.ACTION_DOWN) {
124 | mDefaultBackground = v.getBackground();
125 | v.setBackgroundColor(Color.LTGRAY);
126 | } else if (Build.VERSION.SDK_INT < 15) {
127 | //noinspection deprecation
128 | v.setBackgroundDrawable(mDefaultBackground);
129 | } else {
130 | v.setBackground(mDefaultBackground);
131 | }
132 | return false;
133 | }
134 | });
135 |
136 | return rv;
137 | }
138 |
139 | @Override
140 | public void onAttach(Activity activity) {
141 | super.onAttach(activity);
142 | try {
143 | mListener = (OnFragmentInteractionListener) activity;
144 | } catch (ClassCastException e) {
145 | throw new ClassCastException(activity.toString()
146 | + " must implement OnFragmentInteractionListener");
147 | }
148 | }
149 |
150 | @Override
151 | public void onDetach() {
152 | super.onDetach();
153 | mListener = null;
154 | }
155 |
156 | // endregion
157 |
158 | // region Utilities
159 |
160 | private Drawable getDrawable(String providerKey) {
161 | int rid = 0;
162 |
163 | if (providerKey.equals("amazon")) rid = R.drawable.button_login_amazon;
164 | if (providerKey.equals("blogger")) rid = R.drawable.button_login_blogger;
165 | if (providerKey.equals("disqus")) rid = R.drawable.button_login_disqus;
166 | if (providerKey.equals("facebook")) rid = R.drawable.button_login_facebook;
167 | if (providerKey.equals("foursquare")) rid = R.drawable.button_login_foursquare;
168 | if (providerKey.equals("github")) rid = R.drawable.button_login_github;
169 | if (providerKey.equals("google")) rid = R.drawable.button_login_google;
170 | if (providerKey.equals("instagram")) rid = R.drawable.button_login_instagram;
171 | if (providerKey.equals("linkedin")) rid = R.drawable.button_login_linkedin;
172 | if (providerKey.equals("livejournal")) rid = R.drawable.button_login_livejournal;
173 | if (providerKey.equals("mailru")) rid = R.drawable.button_login_mailru;
174 | if (providerKey.equals("odnoklassniki")) rid = R.drawable.button_login_odnoklassniki;
175 | if (providerKey.equals("openid")) rid = R.drawable.button_login_openid;
176 | if (providerKey.equals("paypal")) rid = R.drawable.button_login_paypal;
177 | if (providerKey.equals("reddit")) rid = R.drawable.button_login_reddit;
178 | if (providerKey.equals("skyrock")) rid = R.drawable.button_login_skyrock;
179 | if (providerKey.equals("stackexchange")) rid = R.drawable.button_login_stackexchange;
180 | if (providerKey.equals("steam")) rid = R.drawable.button_login_steam;
181 | if (providerKey.equals("twitch")) rid = R.drawable.button_login_twitch;
182 | if (providerKey.equals("twitter")) rid = R.drawable.button_login_twitter;
183 | if (providerKey.equals("vimeo")) rid = R.drawable.button_login_vimeo;
184 | if (providerKey.equals("vkontakte")) rid = R.drawable.button_login_vkontakte;
185 | if (providerKey.equals("windowslive")) rid = R.drawable.button_login_windowslive;
186 | if (providerKey.equals("wordpress")) rid = R.drawable.button_login_wordpress;
187 | if (providerKey.equals("yahoo")) rid = R.drawable.button_login_yahoo;
188 | if (providerKey.equals("youtube")) rid = R.drawable.button_login_youtube;
189 |
190 | if (rid != 0) {
191 | return getResources().getDrawable(rid);
192 | }
193 | return null;
194 | }
195 |
196 | // endregion
197 | }
198 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/ProviderManager.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk;
2 |
3 | import com.oneall.oneallsdk.rest.ServiceManagerProvider;
4 | import com.oneall.oneallsdk.rest.models.Provider;
5 | import com.oneall.oneallsdk.rest.models.ResponseProvidersList;
6 |
7 | import android.content.Context;
8 |
9 | import java.io.FileInputStream;
10 | import java.io.FileNotFoundException;
11 | import java.io.FileOutputStream;
12 | import java.io.IOException;
13 | import java.io.ObjectInputStream;
14 | import java.io.ObjectOutputStream;
15 | import java.util.ArrayList;
16 | import java.util.Collection;
17 | import java.util.List;
18 |
19 | import retrofit.Callback;
20 | import retrofit.RetrofitError;
21 | import retrofit.client.Response;
22 |
23 | /**
24 | * Access to providers list. Retrieves list of providers asynchronously at the initialization and
25 | * stores in local cache. Retrieval is performed on every start and can be triggered by calling
26 | * {@link #refreshProviders(android.content.Context)}
27 | */
28 | public class ProviderManager {
29 |
30 | // region constants
31 |
32 | private final String PROVIDERS_CACHE_FILE = "providers_cache";
33 |
34 | // endregion
35 |
36 | // region Properties
37 |
38 | private static ProviderManager mInstance;
39 |
40 | private Collection providers;
41 |
42 | // endregion
43 |
44 | // region Lifecycle
45 |
46 | /**
47 | * get instance of {@code ProviderManager}
48 | *
49 | * @return a provider manager
50 | */
51 | public static ProviderManager getInstance() {
52 | if (mInstance == null) {
53 | synchronized (ProviderManager.class) {
54 | if (mInstance == null) {
55 | mInstance = new ProviderManager();
56 | }
57 | }
58 | }
59 | return mInstance;
60 | }
61 |
62 | // endregion
63 |
64 | // region Interface methods
65 |
66 | /**
67 | * Updates the list of providers without any additional changes.
68 | *
69 | * @param providers The new list of providers
70 | */
71 | void updateProviders(List providers) {
72 | this.providers = providers;
73 | }
74 |
75 | /**
76 | * force providers refresh. Should be executed as early as possible during application start
77 | *
78 | * @param context context to use for cache storage
79 | */
80 | public void refreshProviders(final Context context) {
81 | loadCachedProviders(context);
82 |
83 | ServiceManagerProvider.getInstance().getService().listProviders(new Callback() {
84 | @Override
85 | public void success(ResponseProvidersList responseProvidersList, Response response) {
86 | List pps = responseProvidersList
87 | .getData()
88 | .getProviders()
89 | .getEntries();
90 |
91 | if(pps != null) {
92 | cacheProviders(context, pps);
93 | providers = pps;
94 | OALog.info(String.format("Parsed %d providers from server", pps.size()));
95 | } else {
96 | OALog.error("Failed to parse providers from server: got null");
97 | }
98 | }
99 |
100 | @Override
101 | public void failure(RetrofitError error) {
102 | OALog.warn(String.format("Failure to read providers list: %s", error.getMessage()));
103 | }
104 | });
105 | }
106 |
107 | /**
108 | * get cached list of providers
109 | *
110 | * @return list of providers if available; empty list if providers have not been cached yet
111 | */
112 | public Collection getProviders() {
113 | if (providers != null) {
114 | return new ArrayList<>(providers);
115 | } else {
116 | return new ArrayList<>();
117 | }
118 | }
119 |
120 | /**
121 | * find provider object by its unique key
122 | *
123 | * @param key key to look up with (e.g. "{@code facebook}"
124 | *
125 | * @return provider with specified key or {@code null} on failure
126 | */
127 | public Provider findByKey(String key) {
128 | if (providers == null) {
129 | return null;
130 | }
131 | for (Provider p : providers) {
132 | if (p.getKey().equals(key)) {
133 | return p;
134 | }
135 | }
136 | return null;
137 | }
138 |
139 | // endregion
140 |
141 | // region Utilities
142 |
143 | /**
144 | * cache providers on local store to be saved between sessions
145 | *
146 | * @param context context to use for file storage
147 | *
148 | * @param providers providers collection to cache
149 | */
150 | private void cacheProviders(Context context, Collection providers) {
151 | FileOutputStream fos = null;
152 | ObjectOutputStream os = null;
153 | try {
154 | fos = context.openFileOutput(PROVIDERS_CACHE_FILE, Context.MODE_PRIVATE);
155 | os = new ObjectOutputStream(fos);
156 | os.writeObject(providers);
157 | } catch (IOException e) {
158 | OALog.error("Cannot cache providers: " + e.getMessage());
159 | } finally {
160 | if (os != null) {
161 | try { os.close(); } catch (IOException ignored) { }
162 | }
163 | if (fos != null) {
164 | try { fos.close(); } catch (IOException ignored) { }
165 | }
166 | }
167 | }
168 |
169 | /**
170 | * load cached providers from local store. The result is stored in local property and can be
171 | * retrieved using {@link #getProviders()}
172 | *
173 | * @param context context to use for file load
174 | */
175 | private void loadCachedProviders(Context context) {
176 | FileInputStream fis = null;
177 | ObjectInputStream is = null;
178 | if (context == null) {
179 | return;
180 | }
181 | try {
182 | fis = context.openFileInput(PROVIDERS_CACHE_FILE);
183 | is = new ObjectInputStream(fis);
184 | Collection tmp = (Collection) is.readObject();
185 |
186 | if (tmp != null && !tmp.isEmpty()) {
187 | providers = tmp;
188 | OALog.info(String.format("Loaded %d cached providers", providers.size()));
189 | }
190 | } catch (FileNotFoundException ignored) {
191 | /* do nothing, no cached version of providers list */
192 | } catch (IOException | ClassNotFoundException e) {
193 | OALog.error(String.format("Could not load cached providers list %s", e.getMessage()));
194 | } finally {
195 | if (is != null) {
196 | try { is.close(); }
197 | catch (IOException ignored) { }
198 | }
199 | if (fis != null) {
200 | try { fis.close(); }
201 | catch (IOException ignored) { }
202 | }
203 | }
204 | }
205 |
206 | // endregion
207 | }
208 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/ProviderSelectActivity.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk;
2 |
3 | import android.content.Intent;
4 | import android.support.v4.app.FragmentTransaction;
5 | import android.support.v7.app.ActionBarActivity;
6 | import android.os.Bundle;
7 | import android.view.Menu;
8 | import android.view.MenuItem;
9 | import android.widget.TableLayout;
10 | import android.widget.TableRow;
11 | import android.widget.TextView;
12 |
13 | import com.oneall.oneallsdk.rest.models.Provider;
14 |
15 | import java.util.Collection;
16 |
17 |
18 | public class ProviderSelectActivity
19 | extends ActionBarActivity
20 | implements ProviderFragment.OnFragmentInteractionListener {
21 |
22 | // region Constants
23 |
24 | private static final String TAG = ProviderSelectActivity.class.toString();
25 |
26 | public static final String INTENT_EXTRA_PROVIDER = "provider";
27 |
28 | // endregion
29 |
30 | // region Properties
31 | // endregion
32 |
33 | // region Lifecycle
34 | // endregion
35 |
36 | // region Activity Lifecycle
37 | @Override
38 | protected void onCreate(Bundle savedInstanceState) {
39 | super.onCreate(savedInstanceState);
40 | setContentView(R.layout.activity_provider_select);
41 |
42 | setupTable();
43 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
44 | }
45 |
46 | @Override
47 | public boolean onOptionsItemSelected(MenuItem item) {
48 | if (item.getItemId() == android.R.id.home) {
49 | setResult(RESULT_CANCELED, new Intent());
50 | finish();
51 | }
52 |
53 | return super.onOptionsItemSelected(item);
54 | }
55 |
56 | // endregion
57 |
58 | // region Activity setup
59 |
60 | private void setupTable() {
61 | TableLayout table = (TableLayout) findViewById(R.id.activity_provider_select_table_view);
62 |
63 | FragmentTransaction fTrans = getSupportFragmentManager().beginTransaction();
64 |
65 | Collection providers = ProviderManager.getInstance().getProviders();
66 |
67 | if (providers != null && !providers.isEmpty()) {
68 | setupFullTable(table, fTrans, providers);
69 | } else {
70 | setupEmptyTable(table);
71 | }
72 |
73 | fTrans.commit();
74 | }
75 |
76 | private void setupEmptyTable(TableLayout table) {
77 | TableRow tableRow = new TableRow(this);
78 | TextView tv = new TextView(this);
79 | tv.setText(getResources().getString(R.string.providers_not_ready_try_again));
80 | tableRow.addView(tv);
81 | table.addView(tableRow);
82 | }
83 |
84 | private void setupFullTable(TableLayout table, FragmentTransaction fTrans, Collection providers) {
85 | for (Provider p : providers) {
86 | if (p.getConfiguration() != null && p.getConfiguration().getIsCompleted()) {
87 | TableRow tableRow = new TableRow(this);
88 | tableRow.setTag(p.getKey());
89 | tableRow.setId(p.getKey().hashCode());
90 | table.addView(tableRow);
91 |
92 |
93 | /* add provider fragment to table row */
94 | ProviderFragment pf = ProviderFragment.newInstance(p.getName(), p.getKey());
95 | fTrans.add(R.id.activity_provider_select_table_view, pf);
96 | }
97 | }
98 | }
99 |
100 | // endregion
101 |
102 | // region UI Events handler
103 | // endregion
104 |
105 | // region ProviderFragment.OnFragmentInteractionListener
106 |
107 | @Override
108 | public void onFragmentInteraction(String providerKey) {
109 | OALog.info("Selected provider: " + providerKey);
110 |
111 | Intent response = new Intent();
112 | response.putExtra(INTENT_EXTRA_PROVIDER, providerKey);
113 | setResult(RESULT_OK, response);
114 | finish();
115 |
116 | }
117 |
118 | // endregion
119 | }
120 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/Settings.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk;
2 |
3 | /**
4 | * Shared settings wrapper
5 | */
6 | public class Settings {
7 |
8 | // region Properties
9 |
10 | private static Settings mInstance = null;
11 |
12 | // endregion
13 |
14 | // region Settings properties
15 |
16 | private String subdomain;
17 |
18 | // endregion
19 |
20 | // region Lifecycle
21 |
22 | public static Settings getInstance() {
23 | if (mInstance == null) {
24 | synchronized (Settings.class) {
25 | if (mInstance == null) {
26 | mInstance = new Settings();
27 | }
28 | }
29 | }
30 | return mInstance;
31 | }
32 |
33 |
34 | // endregion
35 |
36 | // region Settings getters/setters
37 |
38 | public String getSubdomain() {
39 | return subdomain;
40 | }
41 | public void setSubdomain(String subdomain) {
42 | this.subdomain = subdomain;
43 | }
44 |
45 | // endregion
46 | }
47 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/TwitterWrapper.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk;
2 |
3 | import com.twitter.sdk.android.core.Callback;
4 | import com.twitter.sdk.android.core.Result;
5 | import com.twitter.sdk.android.core.TwitterException;
6 | import com.twitter.sdk.android.core.TwitterSession;
7 | import com.twitter.sdk.android.core.identity.TwitterAuthClient;
8 |
9 | import android.app.Activity;
10 | import android.content.Intent;
11 |
12 | /**
13 | * Class used to take care of Twitter authentication
14 | */
15 | public class TwitterWrapper {
16 |
17 | // region Helper classes and interfaces
18 |
19 | /**
20 | * interface used for callbacks to the calling application
21 | */
22 | public interface LoginComplete {
23 | void success(String accessToken, String secret);
24 | void failure(OAError error);
25 | }
26 |
27 | // endregion
28 |
29 | // region Properties
30 |
31 | /** twitter authentication client */
32 | private TwitterAuthClient client;
33 |
34 | // endregion
35 |
36 | // region Lifecycle
37 |
38 | private static TwitterWrapper mInstance = null;
39 |
40 | private TwitterWrapper() {
41 | client = new TwitterAuthClient();
42 | }
43 |
44 | /**
45 | * get instance of this wrapper
46 | *
47 | * @return a wrapper of Twitter client
48 | */
49 | public static TwitterWrapper getInstance() {
50 | if (mInstance == null) {
51 | synchronized (TwitterWrapper.class) {
52 | if (mInstance == null) {
53 | mInstance = new TwitterWrapper();
54 | }
55 | }
56 | }
57 | return mInstance;
58 | }
59 |
60 | public static void destroyInstance() {
61 | synchronized (TwitterWrapper.class) {
62 | if (mInstance != null) {
63 | mInstance = null;
64 | }
65 | }
66 | }
67 |
68 | // endregion
69 |
70 | // region Interface methods
71 |
72 | /**
73 | * Login into Twitter using native Android method and Twitter SDK
74 | *
75 | * @param activity activity to use during login
76 | *
77 | * @param callback callback to use to inform the caller about operation completion
78 | */
79 | public void login(Activity activity, final LoginComplete callback) {
80 | client.authorize(activity, new Callback() {
81 | @Override
82 | public void success(Result twitterSessionResult) {
83 | if (callback != null) {
84 | callback.success(
85 | twitterSessionResult.data.getAuthToken().token,
86 | twitterSessionResult.data.getAuthToken().secret);
87 | }
88 | }
89 |
90 | @Override
91 | public void failure(TwitterException e) {
92 | if (callback != null) {
93 | callback.failure(
94 | new OAError(OAError.ErrorCode.OA_ERROR_AUTH_FAIL, e.getMessage()));
95 | }
96 | }
97 | });
98 | }
99 |
100 | /**
101 | * should be called by the user to process response callbacks from Twitter window
102 | */
103 | public void onActivityResult(int requestCode, int resultCode, Intent data) {
104 | client.onActivityResult(requestCode, resultCode, data);
105 | }
106 |
107 | // endregion
108 | }
109 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/UserInputDialog.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk;
2 |
3 | import android.app.DialogFragment;
4 | import android.os.Bundle;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.EditText;
9 | import android.widget.TextView;
10 |
11 | /**
12 | * dialog used to get additional information about the provider from the user before login
13 | */
14 | public class UserInputDialog extends DialogFragment {
15 |
16 | // region Helper classes
17 | public interface DialogListener {
18 | void onCancel();
19 | void onAccept(String userInput);
20 | }
21 | // endregion
22 |
23 | // region Constants
24 |
25 | public final static String ARGUMENT_PROVIDER_NAME = "provider";
26 | public final static String ARGUMENT_USER_INPUT_TYPE = "user_input_type";
27 |
28 | // endregion
29 |
30 | // region Properties
31 |
32 | private DialogListener listener;
33 |
34 | // endregion
35 |
36 | public UserInputDialog() {
37 | }
38 |
39 | public void setListener(DialogListener listener) {
40 | this.listener = listener;
41 | }
42 |
43 | @Override
44 | public View onCreateView(
45 | LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
46 |
47 | final View view = inflater.inflate(R.layout.user_input_dialog, container);
48 |
49 | getDialog().setTitle(getArguments().getString(ARGUMENT_PROVIDER_NAME));
50 |
51 | String message = String.format(
52 | getActivity().getResources().getString(R.string.login_user_input_message),
53 | getArguments().getString(ARGUMENT_PROVIDER_NAME),
54 | getArguments().getString(ARGUMENT_USER_INPUT_TYPE));
55 |
56 |
57 | ((TextView) view.findViewById(R.id.edit_user_input_message)).setText(message);
58 |
59 | view.findViewById(R.id.edit_user_input_button_ok).setOnClickListener(
60 | new View.OnClickListener() {
61 | @Override
62 | public void onClick(View v) {
63 | if (listener != null) {
64 | String text = ((EditText) view.findViewById(R.id.edit_user_input_text))
65 | .getText().toString();
66 | listener.onAccept(text);
67 | }
68 | dismiss();
69 | }
70 | }
71 | );
72 |
73 | view.findViewById(R.id.edit_user_input_button_cancel).setOnClickListener(
74 | new View.OnClickListener() {
75 | @Override
76 | public void onClick(View v) {
77 | if (listener != null) {
78 | listener.onCancel();
79 | }
80 | dismiss();
81 | }
82 | }
83 | );
84 |
85 | return view;
86 | }
87 | }
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/WebLoginActivity.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.DialogInterface;
5 | import android.content.DialogInterface.OnCancelListener;
6 | import android.content.Intent;
7 | import android.graphics.Bitmap;
8 | import android.net.Uri;
9 | import android.os.Bundle;
10 | import android.support.v7.app.ActionBar;
11 | import android.support.v7.app.AppCompatActivity;
12 | import android.view.MenuItem;
13 | import android.view.WindowManager;
14 | import android.webkit.WebView;
15 | import android.webkit.WebViewClient;
16 |
17 | /**
18 | * Web view activity used to take the user through authentication
19 | */
20 | public class WebLoginActivity extends AppCompatActivity {
21 |
22 | // region Properties
23 |
24 | private ProgressDialog progressDialog;
25 |
26 | private WebView mWebView;
27 | // endregion
28 |
29 | // region Constants
30 |
31 | public final static String INTENT_EXTRA_URL = "url";
32 |
33 | private final static String CUSTOM_URL_SCHEME = "oneall";
34 |
35 | public final static int RESULT_FAILED = 0x80;
36 |
37 | // endregion
38 |
39 | @Override
40 | protected void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | setContentView(R.layout.activity_web_login);
43 |
44 | final ActionBar supportActionBar = getSupportActionBar();
45 | if (supportActionBar != null) {
46 | supportActionBar.setDisplayHomeAsUpEnabled(true);
47 | }
48 |
49 | mWebView = (WebView) findViewById(R.id.web_login_web_view);
50 | mWebView.getSettings().setJavaScriptEnabled(true);
51 | mWebView.setWebViewClient(new WebViewClient() {
52 |
53 | @Override
54 | public boolean shouldOverrideUrlLoading(WebView view, String url) {
55 | return WebLoginActivity.this.shouldOverrideUrlLoading(view, url);
56 | }
57 |
58 | @Override
59 | public void onPageStarted(WebView view, String url, Bitmap favicon) {
60 | OALog.info(String.format("Page loading started: %s", url));
61 | try {
62 | if (progressDialog == null) {
63 | progressDialog = ProgressDialog.show(
64 | WebLoginActivity.this,
65 | "",
66 | getResources().getString(R.string.web_login_progress_title),
67 | true,
68 | true,
69 | new OnCancelListener() {
70 | @Override
71 | public void onCancel(DialogInterface dialog) {
72 | pageLoadFailed(null);
73 | }
74 | });
75 | }
76 | } catch (WindowManager.BadTokenException e) {
77 | //ignore: the user backed out but we still got the onPageStarted event
78 | }
79 |
80 | super.onPageStarted(view, url, favicon);
81 | }
82 |
83 | @Override
84 | public void onPageFinished(WebView view, String url) {
85 | pageLoadFinished(url);
86 | super.onPageFinished(view, url);
87 | }
88 |
89 | @Override
90 | public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
91 | super.onReceivedError(view, errorCode, description, failingUrl);
92 | pageLoadFailed(failingUrl);
93 | }
94 | });
95 | mWebView.loadUrl(getIntent().getExtras().getString(INTENT_EXTRA_URL));
96 | }
97 |
98 | @Override
99 | protected void onDestroy() {
100 | if (progressDialog != null) {
101 | // avoid leaking the progress window
102 | progressDialog.dismiss();
103 | }
104 |
105 | if (mWebView != null) {
106 | mWebView.stopLoading();
107 | mWebView.destroy();
108 | }
109 |
110 | super.onDestroy();
111 | }
112 |
113 | private void pageLoadFailed(String url) {
114 | if (progressDialog != null) {
115 | progressDialog.dismiss();
116 | progressDialog = null;
117 | }
118 |
119 | setResult(RESULT_FAILED);
120 | finish();
121 | }
122 |
123 | private void pageLoadFinished(String url) {
124 | OALog.info(String.format("Page loading complete: %s", url));
125 | if (progressDialog != null) {
126 | progressDialog.dismiss();
127 | progressDialog = null;
128 | }
129 | }
130 |
131 | private boolean shouldOverrideUrlLoading(WebView view, String url) {
132 | OALog.info(String.format("Loading web request: %s", url));
133 |
134 | if (Uri.parse(url).getScheme().equalsIgnoreCase(CUSTOM_URL_SCHEME)) {
135 | OALog.info("OA Auth complete");
136 |
137 | view.stopLoading();
138 |
139 | Intent i = new Intent();
140 | i.putExtra(INTENT_EXTRA_URL, url);
141 |
142 | setResult(RESULT_OK, i);
143 | finish();
144 | }
145 | return false;
146 | }
147 |
148 | @Override
149 | public boolean onOptionsItemSelected(MenuItem item) {
150 | switch (item.getItemId()) {
151 | case android.R.id.home:
152 | setResult(RESULT_CANCELED);
153 | finish();
154 | return true;
155 | default:
156 | return super.onOptionsItemSelected(item);
157 | }
158 | }
159 | }
160 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/rest/ItemTypeAdapterFactory.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk.rest;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.JsonElement;
5 | import com.google.gson.JsonObject;
6 | import com.google.gson.TypeAdapter;
7 | import com.google.gson.TypeAdapterFactory;
8 | import com.google.gson.reflect.TypeToken;
9 | import com.google.gson.stream.JsonReader;
10 | import com.google.gson.stream.JsonWriter;
11 |
12 | import java.io.IOException;
13 |
14 | /**
15 | * Created by urk on 9/3/15.
16 | */
17 | public class ItemTypeAdapterFactory implements TypeAdapterFactory {
18 |
19 | public TypeAdapter create(Gson gson, final TypeToken type) {
20 |
21 | final TypeAdapter delegate = gson.getDelegateAdapter(this, type);
22 | final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
23 |
24 | return new TypeAdapter() {
25 |
26 | public void write(JsonWriter out, T value) throws IOException {
27 | delegate.write(out, value);
28 | }
29 |
30 | public T read(JsonReader in) throws IOException {
31 |
32 | JsonElement jsonElement = elementAdapter.read(in);
33 | if (jsonElement.isJsonObject()) {
34 | JsonObject responseJobj = jsonElement.getAsJsonObject();
35 | if (responseJobj.has("response") && responseJobj.get("response").isJsonObject()) {
36 | jsonElement = responseJobj.get("response");
37 | if (jsonElement.isJsonObject()) {
38 | JsonObject resultJobj = jsonElement.getAsJsonObject();
39 | if (resultJobj.has("result") && resultJobj.get("result").isJsonObject()) {
40 | jsonElement = resultJobj.get("result");
41 | } else if (resultJobj.has("request") && resultJobj.get("request").isJsonObject()) {
42 | jsonElement = resultJobj.get("request");
43 | }
44 | }
45 | }
46 | }
47 |
48 | return delegate.fromJsonTree(jsonElement);
49 | }
50 | }.nullSafe();
51 | }
52 | }
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/rest/ServiceCallback.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk.rest;
2 |
3 | import com.oneall.oneallsdk.rest.models.PostMessageResponse;
4 |
5 | import retrofit.Callback;
6 | import retrofit.RetrofitError;
7 |
8 |
9 | /** callback processor of serrvice API */
10 | public abstract class ServiceCallback implements Callback {
11 |
12 | public class ServiceError {
13 | private RetrofitError retrofitError;
14 | private PostMessageResponse response;
15 |
16 | public ServiceError(RetrofitError retrofitError, PostMessageResponse response) {
17 | this.retrofitError = retrofitError;
18 | this.response = response;
19 | }
20 |
21 | public RetrofitError getRetrofitError() {
22 | return retrofitError;
23 | }
24 |
25 | public PostMessageResponse getResponse() {
26 | return response;
27 | }
28 | }
29 |
30 | public abstract void failure(ServiceError restError);
31 |
32 | @Override
33 | @SuppressWarnings("unchecked")
34 | public void failure(RetrofitError error)
35 | {
36 | PostMessageResponse msgResp =
37 | (PostMessageResponse) error.getBodyAs(PostMessageResponse.class);
38 |
39 | ServiceError postError = new ServiceError(error, msgResp);
40 | failure(postError);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/rest/ServiceManagerProvider.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk.rest;
2 |
3 | import com.google.gson.FieldNamingPolicy;
4 | import com.google.gson.Gson;
5 | import com.google.gson.GsonBuilder;
6 | import com.oneall.oneallsdk.Settings;
7 | import com.oneall.oneallsdk.rest.models.PostMessageRequest;
8 | import com.oneall.oneallsdk.rest.service.ConnectionService;
9 | import com.oneall.oneallsdk.rest.service.MessagePostService;
10 | import com.oneall.oneallsdk.rest.service.ProviderService;
11 | import com.oneall.oneallsdk.rest.service.UserService;
12 |
13 | import retrofit.RestAdapter;
14 | import retrofit.converter.GsonConverter;
15 |
16 | /**
17 | * Manager of services creates API access services
18 | */
19 | public class ServiceManagerProvider {
20 |
21 | // region Properties
22 |
23 | private static ServiceManagerProvider mInstance = null;
24 |
25 | private final RestAdapter restAdapter;
26 |
27 | // endregion
28 |
29 | // region Lifecycle
30 |
31 | private ServiceManagerProvider() {
32 | String endpoint =
33 | String.format("https://%s.api.oneall.com", Settings.getInstance().getSubdomain());
34 |
35 | Gson gson = new GsonBuilder()
36 | .registerTypeAdapterFactory(new ItemTypeAdapterFactory())
37 | .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
38 | .setDateFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'SSS'Z'")
39 | .create();
40 |
41 | restAdapter = new RestAdapter.Builder()
42 | .setLogLevel(RestAdapter.LogLevel.FULL)
43 | .setEndpoint(endpoint)
44 | .setConverter(new GsonConverter(gson))
45 | .build();
46 | }
47 |
48 | public static ServiceManagerProvider getInstance() {
49 | if (mInstance == null) {
50 | synchronized (ServiceManagerProvider.class) {
51 | if (mInstance == null && Settings.getInstance().getSubdomain() != null) {
52 | mInstance = new ServiceManagerProvider();
53 | }
54 | }
55 | }
56 | return mInstance;
57 | }
58 |
59 | // endregion
60 |
61 | // region Interface methods
62 |
63 | public ProviderService getService() {
64 | return restAdapter.create(ProviderService.class);
65 | }
66 |
67 | public ConnectionService getConnectionService() {
68 | return restAdapter.create(ConnectionService.class);
69 | }
70 |
71 | public MessagePostService getPostService() {
72 | return restAdapter.create(MessagePostService.class);
73 | }
74 |
75 | public UserService getUserService() {
76 | return restAdapter.create(UserService.class);
77 | }
78 |
79 | public static String buildAuthHeader(String nonce) {
80 | return String.format("OneAllNonce %s", nonce);
81 | }
82 |
83 | public static String buildPublishAuthHeader(String token) {
84 | return String.format("OneAllPublishToken %s", token);
85 | }
86 |
87 | // endregion
88 | }
89 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/rest/models/NativeLoginRequest.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk.rest.models;
2 |
3 | import com.google.gson.JsonElement;
4 | import com.google.gson.JsonObject;
5 | import com.google.gson.JsonSerializationContext;
6 | import com.google.gson.JsonSerializer;
7 |
8 | import java.lang.reflect.Type;
9 |
10 | /** model of object sent to OneAll API server to login using access token received from native
11 | * authentication */
12 | public class NativeLoginRequest {
13 | public class Request {
14 | public class User {
15 | public class Identity {
16 | public class Source {
17 | public class AccessToken {
18 | public String key;
19 | public String secret;
20 |
21 | public AccessToken(String accessToken, String secret) {
22 | this.key = accessToken;
23 | this.secret = secret;
24 | }
25 | }
26 | public String key;
27 | public AccessToken accessToken;
28 |
29 | public Source(String provider, String accessToken, String secret) {
30 | this.key = provider;
31 | this.accessToken = new AccessToken(accessToken, secret);
32 | }
33 | }
34 | public Source source;
35 |
36 | public Identity(String provider, String accessToken, String secret) {
37 | this.source = new Source(provider, accessToken, secret);
38 | }
39 | }
40 | public String action = "import_from_access_token";
41 | public Identity identity;
42 |
43 | public User(String provider, String accessToken, String secret) {
44 | this.identity = new Identity(provider, accessToken, secret);
45 | }
46 | }
47 | public User user;
48 |
49 | public Request(String provider, String accessToken, String secret) {
50 | this.user = new User(provider, accessToken, secret);
51 | }
52 | }
53 | public Request request;
54 |
55 | public NativeLoginRequest(String provider, String accessToken, String secret) {
56 | this.request = new Request(provider, accessToken, secret);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/rest/models/PostMessageRequest.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk.rest.models;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Collection;
5 |
6 | public class PostMessageRequest {
7 | public static class Request {
8 | public static class Message {
9 | public static class Parts {
10 |
11 | private static class Link {
12 | public String url;
13 | public String name;
14 | public String caption;
15 | public String description;
16 | }
17 |
18 | public static class Text {
19 | public String body;
20 | }
21 |
22 | public static class Flags {
23 | public Integer enableTracking;
24 | }
25 |
26 | public Text text;
27 | public Link picture;
28 | public Link video;
29 | public Link link;
30 | public Flags flags;
31 | }
32 |
33 | public Parts parts;
34 | public Collection providers;
35 | }
36 | public Message message;
37 | }
38 |
39 | public Request request;
40 |
41 | public PostMessageRequest(
42 | Collection providers,
43 | String text,
44 | String pictureUrl,
45 | String videoUrl,
46 | String linkUrl,
47 | String linkName,
48 | String linkCaption,
49 | String linkDescription,
50 | Boolean enableTracking) {
51 | this.request = new Request();
52 | this.request.message = new Request.Message();
53 | this.request.message.providers = new ArrayList<>(providers);
54 | this.request.message.parts = new Request.Message.Parts();
55 | this.request.message.parts.text = new Request.Message.Parts.Text();
56 | this.request.message.parts.text.body = text;
57 | if (pictureUrl != null && pictureUrl.length() > 0) {
58 | this.request.message.parts.picture = new Request.Message.Parts.Link();
59 | this.request.message.parts.picture.url = pictureUrl;
60 | }
61 | if (videoUrl != null && videoUrl.length() > 0) {
62 | this.request.message.parts.video = new Request.Message.Parts.Link();
63 | this.request.message.parts.video.url = videoUrl;
64 | }
65 | if (linkUrl != null && linkUrl.length() > 0) {
66 | this.request.message.parts.link = new Request.Message.Parts.Link();
67 | this.request.message.parts.link.url = linkUrl;
68 | if (linkName != null && linkName.length() > 0) {
69 | this.request.message.parts.link.name = linkName;
70 | }
71 | if (linkCaption != null && linkCaption.length() > 0) {
72 | this.request.message.parts.link.caption = linkCaption;
73 | }
74 | if (linkDescription != null && linkDescription.length() > 0) {
75 | this.request.message.parts.link.description = linkDescription;
76 | }
77 | }
78 | this.request.message.parts.flags = new Request.Message.Parts.Flags();
79 | this.request.message.parts.flags.enableTracking = enableTracking ? 1 : 0;
80 | }
81 | }
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/rest/models/PostMessageResponse.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk.rest.models;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import java.util.Collection;
6 |
7 | /**
8 | * Created by urk on 15/3/15.
9 | */
10 | public class PostMessageResponse {
11 | public static class Data {
12 | public static class Message {
13 | public static class Publication {
14 | public static class Status {
15 | public String flag;
16 | public Integer code;
17 | public String message;
18 | }
19 |
20 | public Status status;
21 | public String provider;
22 | public String userToken;
23 | public String identityToken;
24 | public String datePublication;
25 | }
26 |
27 | @SerializedName("sharing_message_token")
28 | public String sharingMessageToken;
29 |
30 | @SerializedName("publications")
31 | public Collection publications;
32 |
33 | @SerializedName("date_creation")
34 | public String dateCreation;
35 |
36 | @SerializedName("date_last_published")
37 | public String dateLastPublished;
38 | }
39 |
40 | @SerializedName("message")
41 | public Message message;
42 | }
43 |
44 | @SerializedName("data")
45 | public Data data;
46 | }
47 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/rest/models/Provider.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk.rest.models;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * Created by urk on 9/3/15.
7 | */
8 | public class Provider implements Serializable {
9 | public class Configuration implements Serializable {
10 | private Boolean isRequired;
11 | private Boolean isCompleted;
12 |
13 | public Boolean getIsRequired() {
14 | return isRequired;
15 | }
16 |
17 | public void setIsRequired(Boolean isRequired) {
18 | this.isRequired = isRequired;
19 | }
20 |
21 | public Boolean getIsCompleted() {
22 | return isCompleted;
23 | }
24 |
25 | public void setIsCompleted(Boolean isCompleted) {
26 | this.isCompleted = isCompleted;
27 | }
28 | }
29 |
30 | public class Authentication implements Serializable {
31 | private Boolean isUserInputRequired;
32 | private String userInputType;
33 |
34 | public Boolean getIsUserInputRequired() {
35 | return isUserInputRequired;
36 | }
37 |
38 | public void setIsUserInputRequired(Boolean isUserInputRequired) {
39 | this.isUserInputRequired = isUserInputRequired;
40 | }
41 |
42 | public String getUserInputType() {
43 | return userInputType;
44 | }
45 |
46 | public void setUserInputType(String userInputType) {
47 | this.userInputType = userInputType;
48 | }
49 | }
50 |
51 | private String key;
52 | private String name;
53 | private Boolean isConfigurable;
54 | private Configuration configuration;
55 | private Authentication authentication;
56 |
57 | public String getKey() {
58 | return key;
59 | }
60 |
61 | public void setKey(String key) {
62 | this.key = key;
63 | }
64 |
65 | public String getName() {
66 | return name;
67 | }
68 |
69 | public void setName(String name) {
70 | this.name = name;
71 | }
72 |
73 | public Boolean getIsConfigurable() {
74 | return isConfigurable;
75 | }
76 |
77 | public void setIsConfigurable(Boolean isConfigurable) {
78 | this.isConfigurable = isConfigurable;
79 | }
80 |
81 | public Configuration getConfiguration() {
82 | return configuration;
83 | }
84 |
85 | public void setConfiguration(Configuration configuration) {
86 | this.configuration = configuration;
87 | }
88 |
89 | public Authentication getAuthentication() {
90 | return authentication;
91 | }
92 |
93 | public void setAuthentication(Authentication authentication) {
94 | this.authentication = authentication;
95 | }
96 |
97 | @Override
98 | public String toString() {
99 | return String.format("%s- %s", super.toString(), key);
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/rest/models/ResponseConnection.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk.rest.models;
2 |
3 | import java.io.Serializable;
4 | import java.util.List;
5 |
6 | /**
7 | * data model for connection
8 | */
9 | public class ResponseConnection implements Serializable {
10 |
11 | public class Status {
12 | public String flag;
13 | public Integer code;
14 | public String info;
15 | }
16 |
17 | public class Data {
18 | public class Connection implements Serializable {
19 | public String connectionToken;
20 | public String date;
21 | public String plugin;
22 | }
23 |
24 | public Connection connection;
25 | public User user;
26 | }
27 |
28 | public Status status;
29 | public Data data;
30 | }
31 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/rest/models/ResponseProvidersList.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk.rest.models;
2 |
3 | import java.io.Serializable;
4 | import java.util.List;
5 |
6 | /**
7 | * Created by urk on 9/3/15.
8 | */
9 | public class ResponseProvidersList implements Serializable {
10 |
11 | public class Data implements Serializable {
12 | public class Providers implements Serializable {
13 | private Integer count;
14 | private List entries;
15 |
16 | public Integer getCount() {
17 | return count;
18 | }
19 |
20 | public void setCount(Integer count) {
21 | this.count = count;
22 | }
23 |
24 | public List getEntries() {
25 | return entries;
26 | }
27 |
28 | public void setEntries(List entries) {
29 | this.entries = entries;
30 | }
31 | }
32 |
33 | private Providers providers;
34 |
35 | public Providers getProviders() {
36 | return providers;
37 | }
38 |
39 | public void setProviders(Providers providers) {
40 | this.providers = providers;
41 | }
42 | }
43 |
44 | private Data data;
45 |
46 | public Data getData() {
47 | return data;
48 | }
49 |
50 | public void setData(Data data) {
51 | this.data = data;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/rest/models/ServiceResponseBase.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk.rest.models;
2 |
3 | import java.util.Date;
4 |
5 | /**
6 | * Created by urk on 9/3/15.
7 | */
8 | public class ServiceResponseBase {
9 |
10 | public class Request {
11 | public class Status {
12 | public String flag;
13 | public Integer code;
14 | public String info;
15 | }
16 |
17 | public Date date;
18 | public String resource;
19 | public Status status;
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/rest/models/User.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk.rest.models;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import java.io.Serializable;
6 | import java.util.Collection;
7 | import java.util.List;
8 |
9 | /**
10 | * This class represents user object and mirrors JSON object returned by either connection.json or
11 | * user.json
12 | *
13 | * @author Uri Kogan
14 | *
15 | * @see OneAll- read connection details
16 | *
17 | * @see OneAll- read user details
18 | */
19 | public class User implements Serializable {
20 | public class Identity implements Serializable{
21 |
22 | public class Name implements Serializable {
23 | public String formatted;
24 | }
25 |
26 | public class IdentityUrl implements Serializable {
27 | public String value;
28 | public String type;
29 | }
30 |
31 | public class Account implements Serializable {
32 | public String domain;
33 | public String userId;
34 | public String username;
35 | }
36 |
37 | public class Photo implements Serializable {
38 | public String value;
39 | public String type;
40 | public String size;
41 | }
42 |
43 | public class Email implements Serializable {
44 | public String value;
45 | public Boolean isVerified;
46 | }
47 |
48 | public String identityToken;
49 |
50 | public String provider;
51 |
52 | public String id;
53 |
54 | @SerializedName("displayName")
55 | public String displayName;
56 |
57 | public Name name;
58 |
59 | @SerializedName("preferredUsername")
60 | public String preferredUsername;
61 |
62 | @SerializedName("thumbnailUrl")
63 | public String thumbnailUrl;
64 |
65 | @SerializedName("pictureUrl")
66 | public String pictureUrl;
67 |
68 | @SerializedName("profileUrl")
69 | public String profileUrl;
70 |
71 | public String gender;
72 |
73 | public String birthday;
74 |
75 | @SerializedName("utcOffset")
76 | public String utcOffset;
77 |
78 | public List emails;
79 |
80 | public List urls;
81 |
82 | public List accounts;
83 |
84 | public List photos;
85 | }
86 |
87 | public class PublishToken implements Serializable {
88 | public String key;
89 |
90 | public String date_creation;
91 |
92 | public String date_expiration;
93 | }
94 |
95 | public String uuid;
96 |
97 | public String userToken;
98 |
99 | public PublishToken publishToken;
100 |
101 | public Identity identity;
102 |
103 | public Collection identies;
104 | }
105 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/rest/service/ConnectionService.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk.rest.service;
2 |
3 | import com.oneall.oneallsdk.rest.models.ResponseConnection;
4 |
5 | import retrofit.Callback;
6 | import retrofit.http.GET;
7 | import retrofit.http.Header;
8 | import retrofit.http.Path;
9 |
10 | /**
11 | * Interface used to pull connection information from OneAll:
12 | * http://docs.oneall.com/api/resources/connections/read-connection-details/
13 | */
14 | public interface ConnectionService {
15 | @GET("/connection/{token}.json")
16 | void info(
17 | @Header("Authorization") String nonce,
18 | @Path("token") String token,
19 | Callback cb);
20 | }
21 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/rest/service/MessagePostService.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk.rest.service;
2 |
3 | import com.oneall.oneallsdk.rest.ServiceCallback;
4 | import com.oneall.oneallsdk.rest.models.PostMessageRequest;
5 | import com.oneall.oneallsdk.rest.models.PostMessageResponse;
6 |
7 | import retrofit.http.Body;
8 | import retrofit.http.Header;
9 | import retrofit.http.POST;
10 | import retrofit.http.Path;
11 |
12 | /**
13 | * Created by urk on 15/3/15.
14 | */
15 | public interface MessagePostService {
16 | @POST("/users/{token}/publish.json")
17 | void post(
18 | @Path("token") String userToken,
19 | @Header("Authorization") String publishToken,
20 | @Body PostMessageRequest message,
21 | ServiceCallback callback);
22 | }
23 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/rest/service/ProviderService.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk.rest.service;
2 |
3 | import com.oneall.oneallsdk.rest.models.ResponseProvidersList;
4 |
5 | import retrofit.Callback;
6 | import retrofit.http.GET;
7 |
8 | /**
9 | * Service used to retrieve list of providers from OneAll API
10 | */
11 | public interface ProviderService {
12 |
13 | // region providers list API
14 |
15 | @GET("/providers.json")
16 | void listProviders(Callback cb);
17 |
18 | // endregion
19 | }
20 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/java/com/oneall/oneallsdk/rest/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.oneall.oneallsdk.rest.service;
2 |
3 | import com.oneall.oneallsdk.rest.models.NativeLoginRequest;
4 | import com.oneall.oneallsdk.rest.models.ResponseConnection;
5 |
6 | import retrofit.Callback;
7 | import retrofit.http.Body;
8 | import retrofit.http.PUT;
9 |
10 | /**
11 | * interface used to retrieve user information form OneAll API
12 | */
13 | public interface UserService {
14 | @PUT("/users.json")
15 | void info(@Body NativeLoginRequest requestBody, Callback callback);
16 | }
17 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_amazon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_amazon.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_blogger.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_blogger.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_devianart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_devianart.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_disqus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_disqus.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_facebook.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_facebook.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_foursquare.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_foursquare.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_github.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_google.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_google.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_instagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_instagram.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_linkedin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_linkedin.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_livejournal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_livejournal.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_mailru.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_mailru.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_msn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_msn.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_myspace.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_myspace.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_odnoklassniki.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_odnoklassniki.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_openid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_openid.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_paypal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_paypal.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_reddit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_reddit.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_skyrock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_skyrock.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_stackexchange.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_stackexchange.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_steam.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_steam.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_twitch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_twitch.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_twitter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_twitter.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_vimeo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_vimeo.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_vkontakte.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_vkontakte.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_windowslive.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_windowslive.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_wordpress.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_wordpress.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_yahoo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_yahoo.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/drawable/button_login_youtube.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/oneallsdk/src/main/res/drawable/button_login_youtube.png
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/layout/activity_provider_select.xml:
--------------------------------------------------------------------------------
1 |
10 |
15 |
16 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/layout/activity_web_login.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/layout/fragment_provider.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
9 |
10 |
17 |
18 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/layout/user_input_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
21 |
22 |
27 |
32 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/oneallsdk/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | OneAll SDK
3 | dummy
4 | Login with a social network
5 |
6 | Hello world!
7 | Settings
8 | Login
9 | Cancel
10 | Please, enter your %1$s %2$s to login with
11 | OK
12 | Cancel
13 | Login
14 | Loading…
15 | Connection failure
16 |
17 | Hello blank fragment
18 | Provider icon
19 | Providers are not ready. Try again in a few seconds.
20 | TwitterLoginActivity
21 | Retrieving information
22 | Patience
23 |
24 |
--------------------------------------------------------------------------------
/proguard-com.twitter.sdk.android.twitter.txt:
--------------------------------------------------------------------------------
1 | # Twitter Core proguard configuration
2 | # '-include' this file in your proguard config
3 | # Autogenerated file -- Do not modify
4 |
5 | # retrofit specific
6 | -dontwarn com.squareup.okhttp.**
7 | -dontwarn com.google.appengine.api.urlfetch.**
8 | -dontwarn rx.**
9 | -dontwarn retrofit.**
10 | -keepattributes Signature
11 | -keepattributes *Annotation*
12 | -keep class com.squareup.okhttp.** { *; }
13 | -keep interface com.squareup.okhttp.** { *; }
14 | -keep class retrofit.** { *; }
15 | -keepclasseswithmembers class * {
16 | @retrofit.http.* ;
17 | }
18 |
--------------------------------------------------------------------------------
/screenshots/login_providers_selector.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oneall/android-sdk/1edb1bfa66dd549929d5b0edf6a90e3774da7497/screenshots/login_providers_selector.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':oneallsdk'
2 |
--------------------------------------------------------------------------------