├── .gitignore
├── .idea
└── runConfigurations.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── google-services.json
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── tapglue
│ │ └── example
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── tapglue
│ │ │ └── example
│ │ │ ├── MainActivity.java
│ │ │ └── PasswordHasher.java
│ └── res
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── content_main.xml
│ │ ├── menu
│ │ └── menu_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-v21
│ │ └── styles.xml
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── tapglue
│ └── example
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
├── tapglue-android-sdk
├── .gitignore
├── build.gradle
├── distribution
│ ├── bintray.gradle
│ └── maven.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── tapglue
│ │ └── android
│ │ ├── CommentIntegrationTest.java
│ │ ├── ConnectionIntegrationTest.java
│ │ ├── FeedIntegrationTest.java
│ │ ├── IntegrationObserver.java
│ │ ├── LikeIntegrationTest.java
│ │ ├── LoginIntegrationTest.java
│ │ ├── PasswordHasher.java
│ │ ├── PostIntegrationTest.java
│ │ ├── RxLoginIntegrationTest.java
│ │ └── TestData.java
│ ├── integration-test
│ └── java
│ │ └── com
│ │ └── tapglue
│ │ └── tapgluesdk
│ │ └── TapglueIntegrationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── tapglue
│ │ │ └── android
│ │ │ ├── Configuration.java
│ │ │ ├── RxPage.java
│ │ │ ├── RxTapglue.java
│ │ │ ├── RxWrapper.java
│ │ │ ├── Tapglue.java
│ │ │ ├── TapglueSchedulers.java
│ │ │ ├── entities
│ │ │ ├── Comment.java
│ │ │ ├── Connection.java
│ │ │ ├── ConnectionList.java
│ │ │ ├── Event.java
│ │ │ ├── Follow.java
│ │ │ ├── Friend.java
│ │ │ ├── Like.java
│ │ │ ├── NewsFeed.java
│ │ │ ├── Post.java
│ │ │ ├── Reaction.java
│ │ │ └── User.java
│ │ │ ├── http
│ │ │ ├── ApiPage.java
│ │ │ ├── Base64Encoder.java
│ │ │ ├── ClientFactory.java
│ │ │ ├── CommentsFeed.java
│ │ │ ├── ConnectionsFeed.java
│ │ │ ├── ErrorFeed.java
│ │ │ ├── ErrorInterceptor.java
│ │ │ ├── EventFeedToList.java
│ │ │ ├── EventListFeed.java
│ │ │ ├── FlattenableFeed.java
│ │ │ ├── HeaderInterceptor.java
│ │ │ ├── LikesFeed.java
│ │ │ ├── LikesFeedToList.java
│ │ │ ├── Network.java
│ │ │ ├── PaginatedService.java
│ │ │ ├── PaginationInterceptor.java
│ │ │ ├── PostFeedToList.java
│ │ │ ├── PostListFeed.java
│ │ │ ├── RawNewsFeed.java
│ │ │ ├── ServiceFactory.java
│ │ │ ├── TapglueError.java
│ │ │ ├── TapglueService.java
│ │ │ ├── UsersFeed.java
│ │ │ └── payloads
│ │ │ │ ├── EmailLoginPayload.java
│ │ │ │ ├── EmailSearchPayload.java
│ │ │ │ ├── SocialConnections.java
│ │ │ │ ├── SocialSearchPayload.java
│ │ │ │ └── UsernameLoginPayload.java
│ │ │ ├── internal
│ │ │ ├── NotificationServiceIdStore.java
│ │ │ ├── SessionStore.java
│ │ │ ├── Store.java
│ │ │ ├── UUIDStore.java
│ │ │ └── UserStore.java
│ │ │ └── sims
│ │ │ ├── DevicePayload.java
│ │ │ ├── NotificationServiceIdListener.java
│ │ │ ├── SimsIdListenerService.java
│ │ │ ├── SimsMessagingService.java
│ │ │ ├── SimsService.java
│ │ │ ├── SimsServiceFactory.java
│ │ │ └── TapglueSims.java
│ └── res
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── tapglue
│ └── android
│ ├── ConfigurationTest.java
│ ├── RxTapglueTest.java
│ ├── RxWrapperTest.java
│ ├── TapglueSchedulersTest.java
│ ├── TapglueTest.java
│ ├── http
│ ├── ClientFactoryTest.java
│ ├── CommentsFeedTest.java
│ ├── ConnectionFeedTest.java
│ ├── ErrorInterceptorTest.java
│ ├── EventListFeedTest.java
│ ├── HeaderInterceptorTest.java
│ ├── LikesFeedTest.java
│ ├── NetworkTest.java
│ ├── PostFeedToListTest.java
│ ├── RawNewsFeedTest.java
│ ├── ServiceFactoryTest.java
│ └── payloads
│ │ ├── EmailLoginPayloadTest.java
│ │ ├── EmailSearchPayloadTest.java
│ │ ├── SocialConnectionsTest.java
│ │ └── UsernameLoginPayloadTest.java
│ ├── internal
│ ├── NotificationServiceIdStoreTest.java
│ ├── SessionStoreTest.java
│ ├── StoreTest.java
│ ├── TestEntity.java
│ ├── UUIDStoreTest.java
│ └── UserStoreTest.java
│ └── sims
│ └── TapglueSimsTest.java
└── v1
├── LICENSE
├── README.md
├── app
├── .gitignore
├── README.md
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── tapglue
│ │ └── tapgluetests
│ │ └── ActivityTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── tapglue
│ │ │ └── tapgluetests
│ │ │ ├── TestActivity.java
│ │ │ ├── TestApplication.java
│ │ │ └── TestController.java
│ └── res
│ │ ├── layout
│ │ └── activity_test.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── tapglue
│ └── tapgluetests
│ └── ExampleUnitTest.java
├── build.gradle
├── circle.yml
├── gradle.properties
├── gradle
├── lint.xml
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── install_deps.sh
├── run_tests.sh
├── settings.gradle
└── tapglue-android-sdk
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
├── vcs.xml
└── workspace.xml
├── README.md
├── build.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── proguard-rules.pro
├── src
├── androidTest
│ └── java
│ │ └── com
│ │ └── tapglue
│ │ ├── ApplicationTest.java
│ │ ├── networking
│ │ └── TGCustomCacheObjectTest.java
│ │ └── utils
│ │ └── TGPasswordHasherTest.java
├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── tapglue
│ │ ├── Tapglue.java
│ │ ├── managers
│ │ ├── AbstractTGManager.java
│ │ ├── TGConnectionManager.java
│ │ ├── TGConnectionManagerImpl.java
│ │ ├── TGEventManager.java
│ │ ├── TGEventManagerImpl.java
│ │ ├── TGFeedManager.java
│ │ ├── TGFeedManagerImpl.java
│ │ ├── TGPostManager.java
│ │ ├── TGPostManagerImpl.java
│ │ ├── TGRecommendationManager.java
│ │ ├── TGRecommendationManagerImpl.java
│ │ ├── TGUserManager.java
│ │ └── TGUserManagerImpl.java
│ │ ├── model
│ │ ├── TGAttachment.java
│ │ ├── TGBaseObject.java
│ │ ├── TGBaseObjectWithId.java
│ │ ├── TGComment.java
│ │ ├── TGCommentsList.java
│ │ ├── TGConnection.java
│ │ ├── TGError.java
│ │ ├── TGErrorList.java
│ │ ├── TGEvent.java
│ │ ├── TGEventObject.java
│ │ ├── TGEventsList.java
│ │ ├── TGFeed.java
│ │ ├── TGFeedCount.java
│ │ ├── TGImage.java
│ │ ├── TGLike.java
│ │ ├── TGLikesList.java
│ │ ├── TGLoginUser.java
│ │ ├── TGPendingConnections.java
│ │ ├── TGPost.java
│ │ ├── TGPostsList.java
│ │ ├── TGRecommendedUsers.java
│ │ ├── TGSearchCriteria.java
│ │ ├── TGSocialConnections.java
│ │ ├── TGUser.java
│ │ ├── TGUsersList.java
│ │ ├── TGVisibility.java
│ │ └── queries
│ │ │ ├── TGQuery.java
│ │ │ ├── TGQueryObjectField.java
│ │ │ ├── TGQueryScalarField.java
│ │ │ └── TGQueryTGObject.java
│ │ ├── networking
│ │ ├── TGApi.java
│ │ ├── TGCacheRequest.java
│ │ ├── TGCustomCacheObject.java
│ │ ├── TGNetworkManager.java
│ │ ├── TGRequest.java
│ │ ├── TGRequests.java
│ │ ├── TGRequestsImpl.java
│ │ └── requests
│ │ │ ├── TGRequestCallback.java
│ │ │ ├── TGRequestErrorType.java
│ │ │ └── TGRequestType.java
│ │ └── utils
│ │ ├── TGErrorUtil.java
│ │ ├── TGLog.java
│ │ └── TGPasswordHasher.java
└── test
│ └── java
│ └── com
│ └── tapglue
│ └── ExampleUnitTest.java
└── tapglue-android-sdk
├── README.md
├── android_sdk.iml
├── build.gradle
├── proguard-rules.pro
├── src
├── androidTest
│ └── java
│ │ └── com
│ │ └── tapglue
│ │ ├── ApplicationTest.java
│ │ ├── networking
│ │ └── TGCustomCacheObjectTest.java
│ │ └── utils
│ │ └── TGPasswordHasherTest.java
├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── tapglue
│ │ ├── Tapglue.java
│ │ ├── managers
│ │ ├── AbstractTGManager.java
│ │ ├── TGConnectionManager.java
│ │ ├── TGConnectionManagerImpl.java
│ │ ├── TGEventManager.java
│ │ ├── TGEventManagerImpl.java
│ │ ├── TGFeedManager.java
│ │ ├── TGFeedManagerImpl.java
│ │ ├── TGPostManager.java
│ │ ├── TGPostManagerImpl.java
│ │ ├── TGRecommendationManager.java
│ │ ├── TGRecommendationManagerImpl.java
│ │ ├── TGUserManager.java
│ │ └── TGUserManagerImpl.java
│ │ ├── model
│ │ ├── TGAttachment.java
│ │ ├── TGBaseObject.java
│ │ ├── TGBaseObjectWithId.java
│ │ ├── TGComment.java
│ │ ├── TGCommentsList.java
│ │ ├── TGConnection.java
│ │ ├── TGError.java
│ │ ├── TGErrorList.java
│ │ ├── TGEvent.java
│ │ ├── TGEventObject.java
│ │ ├── TGEventsList.java
│ │ ├── TGFeed.java
│ │ ├── TGFeedCount.java
│ │ ├── TGImage.java
│ │ ├── TGLike.java
│ │ ├── TGLikesList.java
│ │ ├── TGLoginUser.java
│ │ ├── TGPendingConnections.java
│ │ ├── TGPost.java
│ │ ├── TGPostsList.java
│ │ ├── TGRecommendedUsers.java
│ │ ├── TGSearchCriteria.java
│ │ ├── TGSocialConnections.java
│ │ ├── TGUser.java
│ │ ├── TGUsersList.java
│ │ ├── TGVisibility.java
│ │ └── queries
│ │ │ ├── TGQuery.java
│ │ │ ├── TGQueryObjectField.java
│ │ │ ├── TGQueryScalarField.java
│ │ │ └── TGQueryTGObject.java
│ │ ├── networking
│ │ ├── TGApi.java
│ │ ├── TGCacheRequest.java
│ │ ├── TGCustomCacheObject.java
│ │ ├── TGNetworkManager.java
│ │ ├── TGRequest.java
│ │ ├── TGRequests.java
│ │ ├── TGRequestsImpl.java
│ │ └── requests
│ │ │ ├── TGRequestCallback.java
│ │ │ ├── TGRequestErrorType.java
│ │ │ └── TGRequestType.java
│ │ └── utils
│ │ ├── TGErrorUtil.java
│ │ ├── TGLog.java
│ │ └── TGPasswordHasher.java
└── test
│ └── java
│ └── com
│ └── tapglue
│ └── ExampleUnitTest.java
└── tapglue.iml
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | build/
18 | */build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 | .idea/workspace.xml
35 | .idea/modules.xml
36 | .idea/misc.xml
37 | .idea/gradle.xml
38 | .idea/compiler.xml
39 | .idea/shelf/
40 | .idea/libraries/
41 | .idea/copyright/
42 | .idea/.name
43 | .idea/*.xml
44 | .idea/**
45 | app/app.iml
46 | tapglue-android-sdk/tapglue-android-sdk.iml
47 | *.iml
48 |
49 | #file system
50 | .DS_Store
51 | sdk/.DS_Store
52 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'com.getkeepsafe.dexcount'
3 |
4 | android {
5 | compileSdkVersion 23
6 | buildToolsVersion "23.0.3"
7 |
8 | defaultConfig {
9 | applicationId "com.tapglue.example"
10 | minSdkVersion 15
11 | targetSdkVersion 23
12 | versionCode 1
13 | versionName "1.0"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | compile fileTree(dir: 'libs', include: ['*.jar'])
25 | testCompile 'junit:junit:4.12'
26 | compile 'com.android.support:appcompat-v7:23.2.1'
27 | compile 'com.android.support:design:23.2.1'
28 | compile 'io.reactivex:rxandroid:1.1.0'
29 | compile 'io.reactivex:rxjava:1.1.2'
30 | compile project(':tapglue-android-sdk')
31 | }
32 | apply plugin: 'com.google.gms.google-services'
33 |
--------------------------------------------------------------------------------
/app/google-services.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_info": {
3 | "project_number": "658935390011",
4 | "firebase_url": "https://sims-example.firebaseio.com",
5 | "project_id": "sims-example",
6 | "storage_bucket": "sims-example.appspot.com"
7 | },
8 | "client": [
9 | {
10 | "client_info": {
11 | "mobilesdk_app_id": "1:658935390011:android:cb409d7eaa838d78",
12 | "android_client_info": {
13 | "package_name": "com.tapglue.example"
14 | }
15 | },
16 | "oauth_client": [
17 | {
18 | "client_id": "658935390011-ibqkngilb0ebkh08fevm4e3a82s4r7vf.apps.googleusercontent.com",
19 | "client_type": 3
20 | }
21 | ],
22 | "api_key": [
23 | {
24 | "current_key": "AIzaSyBUg3-0IqoP5B4TycFL_mM3HQejo1wQJTA"
25 | }
26 | ],
27 | "services": {
28 | "analytics_service": {
29 | "status": 1
30 | },
31 | "appinvite_service": {
32 | "status": 1,
33 | "other_platform_oauth_client": []
34 | },
35 | "ads_service": {
36 | "status": 2
37 | }
38 | }
39 | }
40 | ],
41 | "configuration_version": "1"
42 | }
--------------------------------------------------------------------------------
/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/John/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/tapglue/example/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.example;
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 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
23 |
24 |
25 |
26 |
27 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
5 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tapglue/android_sdk/4e5c5c77e888c68e00835cdf19703223a41cd306/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tapglue/android_sdk/4e5c5c77e888c68e00835cdf19703223a41cd306/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tapglue/android_sdk/4e5c5c77e888c68e00835cdf19703223a41cd306/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tapglue/android_sdk/4e5c5c77e888c68e00835cdf19703223a41cd306/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tapglue/android_sdk/4e5c5c77e888c68e00835cdf19703223a41cd306/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 | >
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Example
3 | Settings
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/test/java/com/tapglue/example/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.example;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/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.2.2'
9 | classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.4.4'
10 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
11 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
12 | classpath 'com.google.gms:google-services:3.0.0'
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | jcenter()
21 | }
22 | }
23 |
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
27 |
--------------------------------------------------------------------------------
/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/tapglue/android_sdk/4e5c5c77e888c68e00835cdf19703223a41cd306/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Sep 07 16:51:45 CEST 2016
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-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':tapglue-android-sdk'
2 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/distribution/bintray.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.jfrog.bintray'
2 |
3 |
4 | version = libraryVersion
5 |
6 | task sourcesJar(type: Jar) {
7 | from android.sourceSets.main.java.srcDirs
8 | classifier = 'sources'
9 | }
10 |
11 | task javadoc(type: Javadoc) {
12 | source = android.sourceSets.main.java.srcDirs
13 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
14 | }
15 |
16 | task javadocJar(type: Jar, dependsOn: javadoc) {
17 | classifier = 'javadoc'
18 | from javadoc.destinationDir
19 | }
20 | artifacts {
21 | //archives javadocJar
22 | archives sourcesJar
23 | }
24 |
25 | // Bintray
26 | Properties properties = new Properties()
27 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
28 |
29 | bintray {
30 | user = properties.getProperty("bintray.user")
31 | key = properties.getProperty("bintray.apikey")
32 |
33 | configurations = ['archives']
34 | pkg {
35 | repo = bintrayRepo
36 | name = bintrayName
37 | userOrg = bintrayUserOrg
38 | desc = libraryDescription
39 | websiteUrl = siteUrl
40 | vcsUrl = gitUrl
41 | licenses = allLicenses
42 | publish = true
43 | publicDownloadNumbers = true
44 | version {
45 | desc = libraryDescription
46 | gpg {
47 | sign = true //Determines whether to GPG sign the files. The default is false
48 | passphrase = properties.getProperty("bintray.gpg.password")
49 | //Optional. The passphrase for GPG signing'
50 | }
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/distribution/maven.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.github.dcendents.android-maven'
2 |
3 | group = publishedGroupId /*
4 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */ // Maven Group ID for the artifact
18 |
19 | install {
20 | repositories.mavenInstaller {
21 | // This generates POM.xml with proper parameters
22 | pom {
23 | project {
24 | packaging 'aar'
25 | groupId publishedGroupId
26 | artifactId artifact
27 |
28 | // Add your description here
29 | name libraryName
30 | description libraryDescription
31 | url siteUrl
32 |
33 | // Set your license
34 | licenses {
35 | license {
36 | name licenseName
37 | url licenseUrl
38 | }
39 | }
40 | developers {
41 | developer {
42 | id developerId
43 | name developerName
44 | email developerEmail
45 | }
46 | }
47 | scm {
48 | connection gitUrl
49 | developerConnection gitUrl
50 | url siteUrl
51 |
52 | }
53 | }
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/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/John/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 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/androidTest/java/com/tapglue/android/IntegrationObserver.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android;
2 |
3 | import rx.Observer;
4 |
5 | /**
6 | * Created by John on 4/6/16.
7 | */
8 | public abstract class IntegrationObserver implements Observer {
9 | @Override
10 | public void onCompleted() {
11 |
12 | }
13 |
14 | @Override
15 | public void onError(Throwable e) {
16 | throw new AssertionError(e);
17 | }
18 |
19 | @Override
20 | public abstract void onNext(T t);
21 | }
22 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/androidTest/java/com/tapglue/android/TestData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android;
18 |
19 | public class TestData {
20 | public static final String URL = "https://api.tapglue.com";
21 | public static final String TOKEN = "1ecd50ce4700e0c8f501dee1fb271344";
22 | }
23 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/integration-test/java/com/tapglue/tapgluesdk/TapglueIntegrationTest.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.hamcrest.MatcherAssert.assertThat;
6 | import static org.hamcrest.core.IsEqual.equalTo;
7 |
8 | /**
9 | * Created by John on 3/29/16.
10 | */
11 | public class TapglueIntegrationTest {
12 |
13 | @Test
14 | public void failingTest(){
15 | Tapglue tapglue = new Tapglue();
16 | assertThat(true, equalTo(false));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/Configuration.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.android;
18 |
19 | /**
20 | * The configuration class is where things such as base URLs, client token and logging are
21 | * configured to the SDK
22 | */
23 | public class Configuration {
24 |
25 | private final String baseUrl;
26 | private final String token;
27 | private boolean isLogging = false;
28 | private int pageSize = 25;
29 |
30 | /**
31 | * @param baseUrl URL provided by tapglue to be used for all requests done by the SDK
32 | * @param token Token provided by tapglue for authentication of the client
33 | */
34 | public Configuration(String baseUrl, String token) {
35 | this.token = token;
36 | this.baseUrl = baseUrl;
37 | }
38 |
39 | public String getToken() {
40 | return token;
41 | }
42 |
43 | public String getBaseUrl() {
44 | return baseUrl;
45 | }
46 |
47 | /**
48 | * Toggles logging
49 | * @param isLogging if true then output of all http requests will be printed to the log
50 | */
51 | public void setLogging(boolean isLogging) {
52 | this.isLogging = isLogging;
53 | }
54 | public boolean isLogging() {
55 | return isLogging;
56 | }
57 |
58 | /**
59 | * sets page size for paginated endpoints
60 | * @param pageSize
61 | */
62 | public void setPageSize(int pageSize) {
63 | this.pageSize = pageSize;
64 | }
65 |
66 | public int getPageSize() {
67 | return pageSize;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/RxPage.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android;
2 |
3 | import com.google.gson.JsonObject;
4 | import com.tapglue.android.http.FlattenableFeed;
5 | import com.tapglue.android.http.Network;
6 |
7 | import okhttp3.RequestBody;
8 | import rx.Observable;
9 | import rx.functions.Func1;
10 |
11 | public class RxPage {
12 | FlattenableFeed feed;
13 | Network network;
14 | RequestBody payload;
15 |
16 | public RxPage(FlattenableFeed feed, Network network) {
17 | this.feed = feed;
18 | this.network = network;
19 | }
20 |
21 | public RxPage(FlattenableFeed feed, Network network, RequestBody payload) {
22 | this.feed = feed;
23 | this.network = network;
24 | this.payload = payload;
25 | }
26 |
27 | public T getData() {
28 | return feed.flatten();
29 | }
30 |
31 | public Observable> getPrevious() {
32 | if(payload == null) {
33 | return network.paginatedGet(feed.previousPointer()).map(new PreviousPageGenerator());
34 | } else {
35 | return network.paginatedPost(feed.previousPointer(), payload)
36 | .map(new PreviousPageGenerator());
37 | }
38 | }
39 |
40 | private class PreviousPageGenerator implements Func1> {
41 |
42 | @Override
43 | public RxPage call(JsonObject jsonObject) {
44 | FlattenableFeed previousFeed = feed.parse(jsonObject);
45 | if(payload == null) {
46 | return new RxPage<>(previousFeed, network);
47 | } else {
48 | return new RxPage<>(previousFeed, network, payload);
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/RxWrapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android;
18 |
19 | import java.io.IOException;
20 |
21 | import rx.Observable;
22 | import rx.functions.Action1;
23 |
24 | public class RxWrapper {
25 | public T unwrap(Observable observable) throws IOException {
26 | final Holder holder = new Holder<>();
27 | final Throwable[] throwable = new Throwable[1];
28 |
29 | observable.toBlocking().subscribe(new Action1() {
30 | @Override
31 | public void call(T t) {
32 | holder.obj = t;
33 | }
34 | }, new Action1() {
35 | @Override
36 | public void call(Throwable t) {
37 | throwable[0] = t;
38 | }
39 | });
40 |
41 | if(throwable[0] != null) {
42 | if(throwable[0] instanceof IOException) {
43 | throw (IOException) throwable[0];
44 | } else {
45 | throw new RuntimeException(throwable[0]);
46 | }
47 | } else {
48 | return holder.obj;
49 | }
50 | }
51 |
52 | static class Holder {
53 | T obj;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/TapglueSchedulers.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android;
18 |
19 | import rx.Scheduler;
20 | import rx.schedulers.Schedulers;
21 |
22 | class TapglueSchedulers {
23 |
24 | private TapglueSchedulers() {}
25 |
26 | public static Scheduler analytics() {
27 | return Schedulers.io();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/entities/Comment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android.entities;
18 |
19 | import com.google.gson.annotations.SerializedName;
20 |
21 | import java.util.Map;
22 |
23 | public class Comment {
24 | private String id;
25 | @SerializedName("post_id")
26 | private String postId;
27 | @SerializedName("user_id")
28 | private String userId;
29 | private Map contents;
30 | private String createdAt;
31 | private String updatedAt;
32 | private User user;
33 |
34 | public Comment(Map contents) {
35 | this.contents = contents;
36 | }
37 |
38 | public String getId() {
39 | return id;
40 | }
41 |
42 | public Map getContents() {
43 | return contents;
44 | }
45 |
46 | public String getUserId() {
47 | return userId;
48 | }
49 |
50 | public String getPostId() {
51 | return postId;
52 | }
53 |
54 | public String getCreatedAt() {
55 | return createdAt;
56 | }
57 |
58 | public String getUpdatedAt() {
59 | return updatedAt;
60 | }
61 |
62 | public User getUser() {
63 | return user;
64 | }
65 |
66 | @Override
67 | public boolean equals(Object o) {
68 | if (this == o) return true;
69 | if (o == null || getClass() != o.getClass()) return false;
70 |
71 | Comment comment = (Comment) o;
72 |
73 | return id != null ? id.equals(comment.id) : comment.id == null;
74 |
75 | }
76 |
77 | @Override
78 | public int hashCode() {
79 | return id != null ? id.hashCode() : 0;
80 | }
81 |
82 | public void setUser(User user) {
83 | this.user = user;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/entities/ConnectionList.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.entities;
2 |
3 | import java.util.List;
4 |
5 | public class ConnectionList {
6 | private final List incoming;
7 | private final List outgoing;
8 |
9 | public ConnectionList(List incoming, List outgoing) {
10 | this.incoming = incoming;
11 | this.outgoing = outgoing;
12 | }
13 |
14 | public List getIncomingConnections() {
15 | return incoming;
16 | }
17 |
18 | public List getOutgoingConnections() {
19 | return outgoing;
20 | }
21 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/entities/Follow.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.entities;
2 |
3 | public class Follow extends Connection {
4 | public Follow(User user) {
5 | super(user, Type.FOLLOW, State.CONFIRMED);
6 | }
7 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/entities/Friend.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.entities;
2 |
3 | public class Friend extends Connection {
4 | public Friend(User user) {
5 | super(user, Type.FRIEND, State.PENDING);
6 | }
7 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/entities/Like.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.entities;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | public class Like {
6 | private String id;
7 | @SerializedName("post_id")
8 | private String postId;
9 | @SerializedName("user_id")
10 | private String userId;
11 | private String createdAt;
12 | private String updatedAt;
13 | private User user;
14 | private Post post;
15 |
16 | public void setUser(User user) {
17 | this.user = user;
18 | }
19 |
20 | public User getUser() {
21 | return user;
22 | }
23 |
24 | public String getUserId() {
25 | return userId;
26 | }
27 |
28 | public String getPostId() {
29 | return postId;
30 | }
31 |
32 | public void setPost(Post post) {
33 | this.post = post;
34 | }
35 |
36 | public Post getPost() {
37 | return post;
38 | }
39 |
40 | public String getCreatedAt() {
41 | return createdAt;
42 | }
43 |
44 | public String getUpdatedAt() {
45 | return updatedAt;
46 | }
47 |
48 |
49 | @Override
50 | public boolean equals(Object o) {
51 | if (this == o) return true;
52 | if (o == null || getClass() != o.getClass()) return false;
53 |
54 | Like like = (Like) o;
55 |
56 | return id != null ? id.equals(like.id) : like.id == null;
57 |
58 | }
59 |
60 | @Override
61 | public int hashCode() {
62 | return id != null ? id.hashCode() : 0;
63 | }
64 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/entities/NewsFeed.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android.entities;
18 |
19 | import java.util.List;
20 |
21 | public class NewsFeed {
22 | private List events;
23 | private List posts;
24 |
25 | public NewsFeed(List events, List posts) {
26 | this.events = events;
27 | this.posts = posts;
28 | }
29 |
30 | public List getEvents() {
31 | return events;
32 | }
33 |
34 | public List getPosts() {
35 | return posts;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/entities/Reaction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.tapglue.android.entities;
17 |
18 | import com.google.gson.annotations.SerializedName;
19 |
20 | public enum Reaction {
21 | @SerializedName("like")
22 | LIKE,
23 | @SerializedName("love")
24 | LOVE,
25 | @SerializedName("wow")
26 | WOW,
27 | @SerializedName("haha")
28 | HAHA,
29 | @SerializedName("angry")
30 | ANGRY,
31 | @SerializedName("sad")
32 | SAD;
33 |
34 | @Override
35 | public String toString() {
36 | return this.name().toLowerCase();
37 | }
38 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/ApiPage.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.http;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | class ApiPage {
6 | @SerializedName("previous")
7 | String beforePointer;
8 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/Base64Encoder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.android.http;
18 |
19 | import android.util.Base64;
20 |
21 | import java.io.IOException;
22 |
23 | class Base64Encoder {
24 |
25 | public String encode(String encode) throws IOException{
26 | return Base64.encodeToString(encode.getBytes("UTF-8"), Base64.NO_WRAP);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/ClientFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.android.http;
18 |
19 | import com.tapglue.android.Configuration;
20 |
21 | import okhttp3.Interceptor;
22 | import okhttp3.OkHttpClient;
23 | import okhttp3.logging.HttpLoggingInterceptor;
24 |
25 | public class ClientFactory {
26 |
27 | private ClientFactory() {}
28 |
29 | public static OkHttpClient createClient(Configuration configuration, String sessionToken, String uuid) {
30 | return new OkHttpClient.Builder()
31 | .addInterceptor(new HeaderInterceptor(configuration.getToken(), sessionToken, uuid))
32 | .addInterceptor(new ErrorInterceptor())
33 | .addInterceptor(createLoggignInterceptor(configuration))
34 | .build();
35 | }
36 |
37 | public static OkHttpClient createPaginatedClient(Configuration configuration, String sessionToken, String uuid) {
38 | return new OkHttpClient.Builder()
39 | .addInterceptor(new HeaderInterceptor(configuration.getToken(), sessionToken, uuid))
40 | .addInterceptor(new PaginationInterceptor(configuration.getPageSize()))
41 | .addInterceptor(new ErrorInterceptor())
42 | .addInterceptor(createLoggignInterceptor(configuration))
43 | .build();
44 | }
45 |
46 | private static Interceptor createLoggignInterceptor(Configuration configuration) {
47 | HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
48 | loggingInterceptor.setLevel(configuration.isLogging() ? HttpLoggingInterceptor.Level.BODY: HttpLoggingInterceptor.Level.NONE);
49 | return loggingInterceptor;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/CommentsFeed.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android.http;
18 |
19 | import com.google.gson.Gson;
20 | import com.google.gson.JsonObject;
21 | import com.tapglue.android.entities.Comment;
22 | import com.tapglue.android.entities.User;
23 |
24 | import java.util.ArrayList;
25 | import java.util.List;
26 | import java.util.Map;
27 |
28 | class CommentsFeed extends FlattenableFeed> {
29 | List comments;
30 | Map users;
31 |
32 | @Override
33 | public List flatten() {
34 | if(comments == null) {
35 | return new ArrayList<>();
36 | }
37 | for(Comment comment: comments) {
38 | comment.setUser(users.get(comment.getUserId()));
39 | }
40 | return comments;
41 | }
42 |
43 | @Override
44 | FlattenableFeed> constructDefaultFeed() {
45 | CommentsFeed feed = new CommentsFeed();
46 | feed.comments = new ArrayList<>();
47 | return feed;
48 | }
49 |
50 | @Override
51 | FlattenableFeed> parseJson(JsonObject jsonObject) {
52 | Gson g = new Gson();
53 | CommentsFeed feed = g.fromJson(jsonObject, CommentsFeed.class);
54 | return feed;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/ConnectionsFeed.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.http;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.JsonObject;
5 |
6 | import com.tapglue.android.entities.Connection;
7 | import com.tapglue.android.entities.ConnectionList;
8 | import com.tapglue.android.entities.User;
9 |
10 | import java.util.ArrayList;
11 | import java.util.HashMap;
12 | import java.util.List;
13 | import java.util.Map;
14 |
15 | class ConnectionsFeed extends FlattenableFeed {
16 | List incoming;
17 | List outgoing;
18 | List users;
19 |
20 | @Override
21 | public ConnectionList flatten() {
22 | if(incoming == null) {
23 | incoming = new ArrayList<>();
24 | }
25 | if(outgoing == null) {
26 | outgoing = new ArrayList<>();
27 | }
28 | if(users == null) {
29 | users = new ArrayList<>();
30 | }
31 | Map userMap = new HashMap<>();
32 | for(User user: users) {
33 | userMap.put(user.getId(), user);
34 | }
35 | for(Connection connection: incoming){
36 | User user = userMap.get(connection.getUserFromId());
37 | connection.setUserFrom(user);
38 | }
39 | for(Connection connection: outgoing) {
40 | User user = userMap.get(connection.getUserToId());
41 | connection.setUserTo(user);
42 | }
43 | return new ConnectionList(incoming, outgoing);
44 | }
45 |
46 | @Override
47 | FlattenableFeed constructDefaultFeed() {
48 | ConnectionsFeed feed = new ConnectionsFeed();
49 | feed.incoming = new ArrayList<>();
50 | feed.outgoing = new ArrayList<>();
51 | return feed;
52 | }
53 |
54 | @Override
55 | FlattenableFeed parseJson(JsonObject jsonObject) {
56 | Gson g = new Gson();
57 | return g.fromJson(jsonObject, ConnectionsFeed.class);
58 | }
59 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/ErrorFeed.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android.http;
18 |
19 | import java.util.List;
20 |
21 | class ErrorFeed {
22 | List errors;
23 | }
24 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/ErrorInterceptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android.http;
18 |
19 | import com.google.gson.Gson;
20 |
21 | import java.io.IOException;
22 |
23 | import okhttp3.Interceptor;
24 | import okhttp3.Request;
25 | import okhttp3.Response;
26 |
27 | class ErrorInterceptor implements Interceptor {
28 | @Override
29 | public Response intercept(Chain chain) throws IOException {
30 | Request request = chain.request();
31 | Response response = chain.proceed(request);
32 |
33 | if (response.code() >= 200 && response.code() <= 299) {
34 | return response;
35 | }
36 | ErrorFeed errorFeed = new Gson().fromJson(response.body().charStream(), ErrorFeed.class);
37 |
38 | if (errorFeed != null && errorFeed.errors != null && !errorFeed.errors.isEmpty()) {
39 | response.body().close();
40 | throw errorFeed.errors.get(0);
41 | }
42 |
43 | return response;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/EventFeedToList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android.http;
18 |
19 | import com.tapglue.android.entities.Event;
20 | import com.tapglue.android.entities.Post;
21 | import com.tapglue.android.entities.User;
22 |
23 | import java.util.ArrayList;
24 | import java.util.List;
25 | import java.util.Map;
26 |
27 | import rx.functions.Func1;
28 |
29 | class EventFeedToList implements Func1> {
30 | @Override
31 | public List call(EventListFeed feed) {
32 | if(feed == null || feed.events == null) {
33 | return new ArrayList<>();
34 | }
35 | Map users = feed.users;
36 | Map posts = feed.posts;
37 | for(Event event : feed.events) {
38 | event.setUser(users.get(event.getUserId()));
39 | event.setPost(posts.get(event.getPostId()));
40 | }
41 | return feed.events;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/EventListFeed.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android.http;
18 |
19 | import com.google.gson.Gson;
20 | import com.google.gson.JsonObject;
21 | import com.google.gson.annotations.SerializedName;
22 |
23 | import com.tapglue.android.entities.Event;
24 | import com.tapglue.android.entities.Post;
25 | import com.tapglue.android.entities.User;
26 |
27 | import java.util.ArrayList;
28 | import java.util.List;
29 | import java.util.Map;
30 |
31 | class EventListFeed extends FlattenableFeed> {
32 | List events;
33 | Map users;
34 | @SerializedName("post_map")
35 | Map posts;
36 |
37 | @Override
38 | public List flatten() {
39 | if(events == null) {
40 | return new ArrayList<>();
41 | }
42 | for(Event event : events) {
43 | event.setUser(users.get(event.getUserId()));
44 | event.setPost(posts.get(event.getPostId()));
45 | }
46 | return events;
47 | }
48 |
49 | @Override
50 | FlattenableFeed> constructDefaultFeed() {
51 | EventListFeed feed = new EventListFeed();
52 | feed.events = new ArrayList<>();
53 | return feed;
54 | }
55 |
56 | @Override
57 | FlattenableFeed> parseJson(JsonObject jsonObject) {
58 | Gson g = new Gson();
59 | EventListFeed feed = g.fromJson(jsonObject, EventListFeed.class);
60 | return feed;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/FlattenableFeed.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.http;
2 |
3 | import com.google.gson.JsonObject;
4 | import com.google.gson.annotations.SerializedName;
5 |
6 | public abstract class FlattenableFeed {
7 | @SerializedName("paging")
8 | ApiPage page;
9 |
10 | public FlattenableFeed() {
11 |
12 | }
13 |
14 | public abstract T flatten();
15 |
16 | public final FlattenableFeed parse(JsonObject jsonObject) {
17 | if(jsonObject == null) {
18 | FlattenableFeed feed = constructDefaultFeed();
19 | feed.page = page;
20 | return feed;
21 | }
22 | return parseJson(jsonObject);
23 | }
24 |
25 | public String previousPointer() {
26 | return page.beforePointer;
27 | }
28 |
29 | abstract FlattenableFeed constructDefaultFeed();
30 | abstract FlattenableFeed parseJson(JsonObject jsonObject);
31 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/LikesFeed.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android.http;
18 |
19 | import com.google.gson.Gson;
20 | import com.google.gson.JsonObject;
21 | import com.google.gson.annotations.SerializedName;
22 |
23 | import com.tapglue.android.entities.Like;
24 | import com.tapglue.android.entities.Post;
25 | import com.tapglue.android.entities.User;
26 |
27 | import java.util.List;
28 | import java.util.ArrayList;
29 | import java.util.Map;
30 |
31 | class LikesFeed extends FlattenableFeed> {
32 | List likes;
33 | Map users;
34 | @SerializedName("post_map")
35 | Map posts;
36 |
37 | @Override
38 | public List flatten() {
39 | if(users == null) {
40 | return new ArrayList<>();
41 | }
42 | for(Like like: likes) {
43 | like.setUser(users.get(like.getUserId()));
44 | like.setPost(posts.get(like.getPostId()));
45 | }
46 | return likes;
47 | }
48 |
49 | @Override
50 | FlattenableFeed> constructDefaultFeed() {
51 | LikesFeed feed = new LikesFeed();
52 | feed.likes = new ArrayList<>();
53 | return feed;
54 | }
55 |
56 | @Override
57 | FlattenableFeed> parseJson(JsonObject jsonObject) {
58 | Gson g = new Gson();
59 | LikesFeed feed = g.fromJson(jsonObject, LikesFeed.class);
60 | return feed;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/LikesFeedToList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android.http;
18 |
19 | import com.tapglue.android.entities.Like;
20 |
21 | import java.util.ArrayList;
22 | import java.util.List;
23 |
24 | import rx.functions.Func1;
25 |
26 | class LikesFeedToList implements Func1> {
27 | public List call(LikesFeed feed) {
28 | if(feed == null) {
29 | return new ArrayList<>();
30 | }
31 | for(Like like: feed.likes) {
32 | like.setUser(feed.users.get(like.getUserId()));
33 | like.setPost(feed.posts.get(like.getPostId()));
34 | }
35 | return feed.likes;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/PaginatedService.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.http;
2 |
3 | import com.tapglue.android.http.payloads.EmailSearchPayload;
4 | import com.tapglue.android.http.payloads.SocialSearchPayload;
5 |
6 | import retrofit2.http.Body;
7 | import retrofit2.http.GET;
8 | import retrofit2.http.POST;
9 | import retrofit2.http.Path;
10 | import retrofit2.http.Query;
11 | import rx.Observable;
12 |
13 | interface PaginatedService {
14 |
15 | @GET("/0.4/users/{id}/likes")
16 | Observable retrieveLikesByUser(@Path("id") String userId);
17 |
18 | @GET("/0.4/me/feed")
19 | Observable retrieveNewsFeed();
20 |
21 | @GET("/0.4/users/search")
22 | Observable searchUsers(@Query("q") String searchTerm);
23 |
24 | @POST("/0.4/users/search/emails")
25 | Observable searchUsersByEmail(@Body EmailSearchPayload payload);
26 |
27 | @POST("/0.4/users/search/{platform}")
28 | Observable searchUsersBySocialIds(@Path("platform") String platform,
29 | @Body SocialSearchPayload payload);
30 |
31 | @GET("/0.4/me/friends")
32 | Observable retrieveFriends();
33 |
34 | @GET("/0.4/users/{id}/friends")
35 | Observable retrieveUserFriends(@Path("id") String id);
36 |
37 | @GET("/0.4/me/connections/pending")
38 | Observable retrievePendingConnections();
39 |
40 | @GET("/0.4/me/connections/rejected")
41 | Observable retrieveRejectedConnections();
42 |
43 | @GET("/0.4/posts/{id}/comments")
44 | Observable retrieveCommentsForPost(@Path("id") String postId);
45 |
46 | @GET("/0.4/posts/{id}/likes")
47 | Observable retrieveLikesForPost(@Path("id") String postId);
48 |
49 | @GET("/0.4/posts")
50 | Observable retrievePosts();
51 |
52 | @GET("/0.4/users/{id}/posts")
53 | Observable retrievePostsByUser(@Path("id") String id);
54 |
55 | @GET("/0.4/me/feed/posts")
56 | Observable retrievePostFeed();
57 |
58 | @GET("/0.4/me/feed/notifications/self")
59 | Observable retrieveMeFeed();
60 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/PaginationInterceptor.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.http;
2 |
3 | import java.io.IOException;
4 |
5 | import okhttp3.HttpUrl;
6 | import okhttp3.Interceptor;
7 | import okhttp3.Request;
8 | import okhttp3.Response;
9 |
10 | class PaginationInterceptor implements Interceptor {
11 | int pageSize;
12 |
13 | PaginationInterceptor(int pageSize) {
14 | this.pageSize = pageSize;
15 | }
16 |
17 | @Override
18 | public Response intercept(Chain chain) throws IOException {
19 | Request original = chain.request();
20 | HttpUrl originalUrl = original.url();
21 |
22 | HttpUrl url = originalUrl.newBuilder()
23 | .addQueryParameter("limit", Integer.toString(pageSize))
24 | .build();
25 |
26 | Request.Builder requestBuilder = original.newBuilder()
27 | .url(url);
28 |
29 | Request request = requestBuilder.build();
30 |
31 | return chain.proceed(request);
32 | }
33 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/PostFeedToList.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.http;
2 |
3 | import com.tapglue.android.entities.Post;
4 | import com.tapglue.android.entities.User;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 | import java.util.Map;
9 |
10 | import rx.functions.Func1;
11 |
12 | class PostFeedToList implements Func1> {
13 |
14 | @Override
15 | public List call(PostListFeed feed) {
16 | if(feed == null || feed.posts == null) {
17 | return new ArrayList<>();
18 | }
19 | List posts = feed.posts;
20 | Map users = feed.users;
21 | for(Post post: posts) {
22 | post.setUser(users.get(post.getUserId()));
23 | }
24 | return posts;
25 | }
26 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/PostListFeed.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.http;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.JsonObject;
5 |
6 | import com.tapglue.android.entities.Post;
7 | import com.tapglue.android.entities.User;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 | import java.util.Map;
12 |
13 | class PostListFeed extends FlattenableFeed> {
14 | List posts;
15 | Map users;
16 |
17 | @Override
18 | public List flatten() {
19 | if(posts == null) {
20 | return new ArrayList<>();
21 | }
22 | for(Post post: posts) {
23 | post.setUser(users.get(post.getUserId()));
24 | }
25 | return posts;
26 | }
27 |
28 | @Override
29 | FlattenableFeed> constructDefaultFeed() {
30 | PostListFeed feed = new PostListFeed();
31 | feed.posts = new ArrayList<>();
32 | return feed;
33 | }
34 |
35 | @Override
36 | FlattenableFeed> parseJson(JsonObject jsonObject) {
37 | Gson g = new Gson();
38 | PostListFeed feed = g.fromJson(jsonObject, PostListFeed.class);
39 | return feed;
40 | }
41 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/RawNewsFeed.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.http;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.JsonObject;
5 | import com.google.gson.annotations.SerializedName;
6 | import com.tapglue.android.entities.Event;
7 | import com.tapglue.android.entities.NewsFeed;
8 | import com.tapglue.android.entities.Post;
9 | import com.tapglue.android.entities.User;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 | import java.util.Map;
14 |
15 | class RawNewsFeed extends FlattenableFeed {
16 | List events;
17 | List posts;
18 | Map users;
19 | @SerializedName("post_map")
20 | Map postMap;
21 |
22 | @Override
23 | public NewsFeed flatten() {
24 | EventListFeed eventFeed = new EventListFeed();
25 | eventFeed.events = events;
26 | eventFeed.users = users;
27 | eventFeed.posts = postMap;
28 | List events = new EventFeedToList().call(eventFeed);
29 |
30 | PostListFeed postFeed = new PostListFeed();
31 | postFeed.posts = posts;
32 | postFeed.users = users;
33 | List posts = new PostFeedToList().call(postFeed);
34 | return new NewsFeed(events, posts);
35 | }
36 |
37 | @Override
38 | FlattenableFeed constructDefaultFeed() {
39 | RawNewsFeed feed = new RawNewsFeed();
40 | feed.events = new ArrayList<>();
41 | feed.posts = new ArrayList<>();
42 | return feed;
43 | }
44 |
45 | @Override
46 | FlattenableFeed parseJson(JsonObject jsonObject) {
47 | Gson g = new Gson();
48 | RawNewsFeed feed = g.fromJson(jsonObject, RawNewsFeed.class);
49 | return feed;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/ServiceFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.android.http;
18 |
19 | import com.tapglue.android.Configuration;
20 |
21 | import okhttp3.OkHttpClient;
22 | import retrofit2.Retrofit;
23 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
24 | import retrofit2.converter.gson.GsonConverterFactory;
25 |
26 | public class ServiceFactory {
27 | String sessionToken = "";
28 | Configuration configuration;
29 | String userUUID = "";
30 |
31 | public ServiceFactory(Configuration configuration) {
32 | this.configuration = configuration;
33 | }
34 |
35 | public TapglueService createTapglueService() {
36 | OkHttpClient client = ClientFactory.createClient(configuration, sessionToken, userUUID);
37 |
38 | Retrofit retrofit = buildRetrofit(client);
39 | return retrofit.create(TapglueService.class);
40 | }
41 |
42 | public PaginatedService createPaginatedService() {
43 | OkHttpClient client = ClientFactory
44 | .createPaginatedClient(configuration, sessionToken, userUUID);
45 |
46 | Retrofit retrofit = buildRetrofit(client);
47 | return retrofit.create(PaginatedService.class);
48 | }
49 |
50 | private Retrofit buildRetrofit(OkHttpClient client) {
51 | return new Retrofit.Builder().client(client)
52 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
53 | .addConverterFactory(GsonConverterFactory.create())
54 | .baseUrl(configuration.getBaseUrl()).build();
55 | }
56 |
57 | public void setSessionToken(String token) {
58 | this.sessionToken = token;
59 | }
60 |
61 | public void setUserUUID(String userUUID) {
62 | this.userUUID = userUUID;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/TapglueError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android.http;
18 |
19 | import com.google.gson.annotations.SerializedName;
20 |
21 | import java.io.IOException;
22 |
23 | /**
24 | * Specifies errors returned by the web API.
25 | */
26 | public class TapglueError extends IOException{
27 | @SerializedName("code")
28 | private final int code;
29 | @SerializedName("message")
30 | private final String message;
31 |
32 | public TapglueError(int code, String message) {
33 | this.code = code;
34 | this.message = message;
35 | }
36 |
37 | /**
38 | * The error code specifies what the error means. For more documentation
39 | * please refer to the documentation of the web API.
40 | * @return error code returned by the web API
41 | * @see error handling documentation
42 | */
43 | public int getCode() {
44 | return code;
45 | }
46 |
47 | /**
48 | * @return the error message from the API.
49 | */
50 | @Override
51 | public String getMessage() {
52 | return message;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/UsersFeed.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.http;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.JsonObject;
5 | import com.tapglue.android.entities.User;
6 |
7 | import com.google.gson.annotations.SerializedName;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | class UsersFeed extends FlattenableFeed> {
13 | @SerializedName("users")
14 | private List users;
15 |
16 | public List getUsers() {
17 | return users;
18 | }
19 |
20 | @Override
21 | public List flatten() {
22 | if(getUsers() == null) {
23 | return new ArrayList<>();
24 | }
25 | return getUsers();
26 | }
27 |
28 | @Override
29 | FlattenableFeed> constructDefaultFeed() {
30 | UsersFeed feed = new UsersFeed();
31 | feed.users = new ArrayList<>();
32 | return feed;
33 | }
34 |
35 | @Override
36 | FlattenableFeed> parseJson(JsonObject jsonObject) {
37 | Gson g = new Gson();
38 | UsersFeed feed = g.fromJson(jsonObject, UsersFeed.class);
39 | return feed;
40 | }
41 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/payloads/EmailLoginPayload.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.android.http.payloads;
18 |
19 | import com.google.gson.annotations.SerializedName;
20 |
21 | public class EmailLoginPayload {
22 |
23 | @SerializedName("email")
24 | private final String email;
25 | @SerializedName("password")
26 | private final String password;
27 |
28 | public EmailLoginPayload(String email, String password) {
29 | this.email = email;
30 | this.password = password;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/payloads/EmailSearchPayload.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.http.payloads;
2 |
3 | import java.util.List;
4 |
5 | public class EmailSearchPayload {
6 | List emails;
7 |
8 | public EmailSearchPayload(List emails) {
9 | this.emails = emails;
10 | }
11 |
12 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/payloads/SocialConnections.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android.http.payloads;
18 |
19 | import java.util.List;
20 |
21 | import com.google.gson.annotations.SerializedName;
22 |
23 | import static com.tapglue.android.entities.Connection.Type;
24 |
25 | public class SocialConnections {
26 | @SerializedName("platform")
27 | private final String platform;
28 | @SerializedName("type")
29 | private final Type type;
30 | @SerializedName("platform_user_id")
31 | private final String userSocialId;
32 | @SerializedName("connection_ids")
33 | private final List socialIds;
34 |
35 | public SocialConnections(String platform, Type type, String userSocialId, List socialIds) {
36 | this.platform = platform;
37 | this.type = type;
38 | this.userSocialId = userSocialId;
39 | this.socialIds = socialIds;
40 | }
41 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/payloads/SocialSearchPayload.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.http.payloads;
2 |
3 | import java.util.List;
4 |
5 | public class SocialSearchPayload {
6 | List ids;
7 |
8 | public SocialSearchPayload(List ids) {
9 | this.ids = ids;
10 | }
11 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/http/payloads/UsernameLoginPayload.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.android.http.payloads;
18 |
19 | import com.google.gson.annotations.SerializedName;
20 |
21 | public class UsernameLoginPayload {
22 | @SerializedName("user_name")
23 | private final String username;
24 | @SerializedName("password")
25 | private final String password;
26 |
27 | public UsernameLoginPayload(String username, String password) {
28 | this.username = username;
29 | this.password = password;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/internal/NotificationServiceIdStore.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.internal;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | import rx.Observable;
7 |
8 | public class NotificationServiceIdStore {
9 | private static final String NOTIFICATION_ID = "notificationServiceId";
10 | Store store;
11 |
12 | public NotificationServiceIdStore(Context context) {
13 | SharedPreferences prefs = context.getSharedPreferences(NOTIFICATION_ID, Context.MODE_PRIVATE);
14 | store = new Store<>(prefs, String.class);
15 | }
16 |
17 | public void store(String id) {
18 | store.store().call(id);
19 | }
20 |
21 | public Observable get() {
22 | return store.get();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/internal/SessionStore.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android.internal;
18 |
19 | import android.content.Context;
20 | import android.content.SharedPreferences;
21 |
22 | import com.tapglue.android.entities.User;
23 | import com.tapglue.android.internal.Store;
24 |
25 | import rx.Observable;
26 | import rx.functions.Action0;
27 | import rx.functions.Func1;
28 |
29 | public class SessionStore {
30 |
31 | Store store;
32 |
33 | public SessionStore(Context context) {
34 | SharedPreferences prefs = context.getSharedPreferences("sessionToken", Context.MODE_PRIVATE);
35 | store = new Store<>(prefs, User.class);
36 | }
37 |
38 | public Observable get() {
39 | return store.get();
40 | }
41 |
42 | public Func1 store() {
43 | return store.store();
44 | }
45 |
46 | public Action0 clear() {
47 | return store.clear();
48 | }
49 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/internal/UUIDStore.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android.internal;
18 |
19 | import android.content.Context;
20 |
21 | import java.util.UUID;
22 |
23 | import rx.Observable;
24 |
25 | public class UUIDStore {
26 | private static final String UUID_TAG = "uuid";
27 | Store store;
28 |
29 | public UUIDStore(Context context) {
30 | store = new Store<>(context.getSharedPreferences(UUID_TAG, Context.MODE_PRIVATE), String.class);
31 | }
32 |
33 | public Observable get() {
34 | if(store.isEmpty()) {
35 | return generateUUIDAndStore();
36 | }
37 | return store.get();
38 | }
39 |
40 | private Observable generateUUIDAndStore() {
41 | String uuid = UUID.randomUUID().toString();
42 | store.store().call(uuid);
43 |
44 | return store.get();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/internal/UserStore.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android.internal;
18 |
19 | import android.content.Context;
20 | import android.content.SharedPreferences;
21 |
22 | import com.tapglue.android.entities.User;
23 |
24 | import rx.Observable;
25 | import rx.functions.Action0;
26 | import rx.functions.Func1;
27 |
28 | public class UserStore {
29 |
30 | private static final String USER_TAG = "user";
31 |
32 | Store store;
33 |
34 | public UserStore(Context context) {
35 | SharedPreferences prefs = context.getSharedPreferences(USER_TAG, Context.MODE_PRIVATE);
36 | store = new Store(prefs, User.class);
37 | }
38 |
39 | public Func1 store() {
40 | return store.store();
41 | }
42 |
43 | public Observable get() {
44 | return store.get();
45 | }
46 |
47 | public Action0 clear() {
48 | return store.clear();
49 | }
50 |
51 | public boolean isEmpty() {
52 | return store.isEmpty();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/sims/DevicePayload.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.sims;
2 |
3 | public class DevicePayload {
4 | final int platform = 3;
5 | String token;
6 | String language;
7 | }
8 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/sims/NotificationServiceIdListener.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.sims;
2 |
3 | public interface NotificationServiceIdListener {
4 | void idChanged(String id);
5 | }
6 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/sims/SimsIdListenerService.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.sims;
2 |
3 | import android.util.Log;
4 |
5 | import com.google.firebase.iid.FirebaseInstanceId;
6 | import com.google.firebase.iid.FirebaseInstanceIdService;
7 |
8 | public class SimsIdListenerService extends FirebaseInstanceIdService {
9 | private static NotificationServiceIdListener listener;
10 | private static String notificationServiceInstanceId;
11 | @Override
12 | public void onTokenRefresh() {
13 | super.onTokenRefresh();
14 | notificationServiceInstanceId = FirebaseInstanceId.getInstance().getToken();
15 | notifyListener();
16 | Log.d("Token listener: ", notificationServiceInstanceId);
17 | }
18 |
19 | public static void setListener(NotificationServiceIdListener listener) {
20 | SimsIdListenerService.listener = listener;
21 | notifyListener();
22 | }
23 |
24 | private static void notifyListener() {
25 | if(listener == null) {
26 | return;
27 | }
28 | if(notificationServiceInstanceId != null &&
29 | !notificationServiceInstanceId.isEmpty()) {
30 | listener.idChanged(notificationServiceInstanceId);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/sims/SimsMessagingService.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.sims;
2 |
3 | import com.google.firebase.messaging.FirebaseMessagingService;
4 |
5 | public class SimsMessagingService extends FirebaseMessagingService {
6 | }
7 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/sims/SimsService.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.sims;
2 |
3 | import retrofit2.http.Body;
4 | import retrofit2.http.DELETE;
5 | import retrofit2.http.PUT;
6 | import retrofit2.http.Path;
7 | import rx.Observable;
8 |
9 | public interface SimsService {
10 | @PUT("/0.4/me/devices/{deviceId}")
11 | Observable registerDevice(@Path("deviceId") String deviceUUID, @Body DevicePayload payload);
12 |
13 | @DELETE("/0.4/me/devices/{deviceId}")
14 | Observable deleteDevice(@Path("deviceId") String deviceUUID);
15 | }
16 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/java/com/tapglue/android/sims/SimsServiceFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.android.sims;
18 |
19 | import com.tapglue.android.Configuration;
20 | import com.tapglue.android.http.ClientFactory;
21 |
22 | import okhttp3.OkHttpClient;
23 | import retrofit2.Retrofit;
24 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
25 | import retrofit2.converter.gson.GsonConverterFactory;
26 |
27 | public class SimsServiceFactory {
28 | String sessionToken = "";
29 | Configuration configuration;
30 | String userUUID = "";
31 |
32 | public SimsServiceFactory(Configuration configuration) {
33 | this.configuration = configuration;
34 | }
35 |
36 | public SimsService createService() {
37 | OkHttpClient client = ClientFactory.createClient(configuration, sessionToken, userUUID);
38 |
39 | Retrofit retrofit = new Retrofit.Builder().client(client)
40 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
41 | .addConverterFactory(GsonConverterFactory.create())
42 | .baseUrl(configuration.getBaseUrl()).build();
43 | return retrofit.create(SimsService.class);
44 | }
45 |
46 | public void setSessionToken(String token) {
47 | this.sessionToken = token;
48 | }
49 |
50 | public void setUserUUID(String userUUID) {
51 | this.userUUID = userUUID;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Tapglue sdk
3 |
4 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/test/java/com/tapglue/android/ConfigurationTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.android;
18 |
19 | import org.junit.Test;
20 |
21 | import static org.hamcrest.MatcherAssert.assertThat;
22 | import static org.hamcrest.core.IsEqual.equalTo;
23 |
24 | public class ConfigurationTest {
25 |
26 | private static final String URL = "https://api.tapglue.com";
27 | private static final String TOKEN = "token";
28 |
29 | Configuration configuration = new Configuration(URL, TOKEN);
30 |
31 | @Test
32 | public void configurationHasCorrectDefaultURL() {
33 | assertThat(configuration.getBaseUrl(), equalTo(URL));
34 | }
35 |
36 | @Test
37 | public void configurationHasCorrectToken() {
38 | assertThat(configuration.getToken(), equalTo(TOKEN));
39 | }
40 |
41 | @Test
42 | public void loggingIsFalseByDefault() {
43 | assertThat(configuration.isLogging(), equalTo(false));
44 | }
45 |
46 | @Test
47 | public void loggingSetsToTrue() {
48 | configuration.setLogging(true);
49 |
50 | assertThat(configuration.isLogging(), equalTo(true));
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/test/java/com/tapglue/android/RxWrapperTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android;
18 |
19 | import com.tapglue.android.internal.TestEntity;
20 |
21 | import org.junit.Test;
22 |
23 | import java.io.IOException;
24 |
25 | import rx.Observable;
26 |
27 | import static org.hamcrest.MatcherAssert.assertThat;
28 | import static org.hamcrest.core.IsEqual.equalTo;
29 | import static org.hamcrest.core.IsNull.nullValue;
30 |
31 | public class RxWrapperTest {
32 |
33 | RxWrapper wrapper = new RxWrapper<>();
34 |
35 | @Test
36 | public void unwrapsObservable() throws IOException {
37 | TestEntity entity = new TestEntity(10);
38 |
39 | assertThat(wrapper.unwrap(Observable.just(entity)), equalTo(entity));
40 | }
41 |
42 | @Test (expected = IOException.class)
43 | public void throwsExceptionOnError() throws IOException {
44 | wrapper.unwrap(Observable.error(new IOException()));
45 | }
46 |
47 | @Test
48 | public void emptyObservableReturnsNull() throws IOException {
49 | TestEntity entity = wrapper.unwrap(Observable.empty());
50 |
51 | assertThat(entity, nullValue());
52 | }
53 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/test/java/com/tapglue/android/TapglueSchedulersTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android;
18 |
19 | import org.junit.Test;
20 |
21 | import rx.Scheduler;
22 |
23 | import static org.hamcrest.CoreMatchers.instanceOf;
24 | import static org.hamcrest.MatcherAssert.assertThat;
25 |
26 | public class TapglueSchedulersTest {
27 |
28 | @Test
29 | public void analyticsReturnsScheduler() {
30 | assertThat(TapglueSchedulers.analytics(), instanceOf(Scheduler.class));
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/test/java/com/tapglue/android/http/ServiceFactoryTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.android.http;
18 |
19 | import com.tapglue.android.Configuration;
20 |
21 | import org.junit.Before;
22 | import org.junit.Test;
23 | import org.junit.runner.RunWith;
24 | import org.mockito.Mock;
25 | import org.mockito.runners.MockitoJUnitRunner;
26 |
27 | import static org.hamcrest.MatcherAssert.assertThat;
28 | import static org.hamcrest.core.IsNull.notNullValue;
29 | import static org.mockito.Mockito.verify;
30 | import static org.mockito.Mockito.when;
31 |
32 | @RunWith(MockitoJUnitRunner.class)
33 | public class ServiceFactoryTest {
34 |
35 | @Mock
36 | Configuration configuration;
37 |
38 | //SUT
39 | ServiceFactory serviceFactory;
40 |
41 | @Before public void setup() {
42 | when(configuration.getBaseUrl()).thenReturn("https://someapi.tapglue.com");
43 | serviceFactory = new ServiceFactory(configuration);
44 | }
45 |
46 | @Test
47 | public void serviceForIsNotNull() {
48 | TapglueService service = serviceFactory.createTapglueService();
49 | assertThat(service, notNullValue());
50 | }
51 |
52 | @Test
53 | public void createServiceAsksForBaseUrl() {
54 | serviceFactory.createTapglueService();
55 | verify(configuration).getBaseUrl();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/test/java/com/tapglue/android/http/payloads/EmailLoginPayloadTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.android.http.payloads;
18 |
19 | import com.google.gson.Gson;
20 |
21 | import org.junit.Test;
22 |
23 | import static org.hamcrest.MatcherAssert.assertThat;
24 | import static org.hamcrest.core.IsEqual.equalTo;
25 |
26 | public class EmailLoginPayloadTest {
27 | @Test
28 | public void constructsCorrectJson() {
29 | String expectedJson = "{\"email\":\"user@domain.com\",\"password\":\"password\"}";
30 | String json = new Gson().toJson(new EmailLoginPayload("user@domain.com", "password"));
31 | assertThat(json, equalTo(expectedJson));
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/test/java/com/tapglue/android/http/payloads/EmailSearchPayloadTest.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.http.payloads;
2 |
3 | import com.google.gson.Gson;
4 |
5 | import org.junit.Test;
6 |
7 | import java.util.Arrays;
8 | import java.util.List;
9 |
10 | import static org.hamcrest.MatcherAssert.assertThat;
11 | import static org.hamcrest.core.IsEqual.equalTo;
12 |
13 | public class EmailSearchPayloadTest {
14 |
15 | @Test
16 | public void payloadProducesCorrectPayload() {
17 | String expectedJson = "{\"emails\":[\"email1\",\"email2\"]}";
18 |
19 | List emails = Arrays.asList("email1", "email2");
20 | String actualJson = new Gson().toJson(new EmailSearchPayload(emails));
21 |
22 | assertThat(actualJson, equalTo(expectedJson));
23 | }
24 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/test/java/com/tapglue/android/http/payloads/SocialConnectionsTest.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.http.payloads;
2 |
3 | import com.google.gson.Gson;
4 | import com.tapglue.android.entities.Connection;
5 |
6 | import org.junit.Test;
7 |
8 | import java.util.Arrays;
9 | import java.util.List;
10 |
11 | import static org.hamcrest.MatcherAssert.assertThat;
12 | import static org.hamcrest.core.IsEqual.equalTo;
13 |
14 | public class SocialConnectionsTest {
15 |
16 | @Test
17 | public void generatesCorrectJson() {
18 | String platform = "platform";
19 | Connection.Type type = Connection.Type.FOLLOW;
20 | String userSocialId = "id1";
21 | List socialIds = Arrays.asList("id4", "id5");
22 |
23 | String expectedJson = "{\"platform\":\"platform\",\"type\":\"follow\",\"platform_user_id\":\"id1\",\"connection_ids\":[\"id4\",\"id5\"]}";
24 |
25 | String actualJson = new Gson().toJson(new SocialConnections(platform, type, userSocialId, socialIds));
26 |
27 | assertThat(actualJson, equalTo(expectedJson));
28 | }
29 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/test/java/com/tapglue/android/http/payloads/UsernameLoginPayloadTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.android.http.payloads;
18 |
19 | import com.google.gson.Gson;
20 |
21 | import org.junit.Test;
22 |
23 | import static org.hamcrest.MatcherAssert.assertThat;
24 | import static org.hamcrest.core.IsEqual.equalTo;
25 |
26 | public class UsernameLoginPayloadTest {
27 |
28 | @Test
29 | public void constructsCorrectJson() {
30 | String expectedJson = "{\"user_name\":\"user\",\"password\":\"password\"}";
31 | String json = new Gson().toJson(new UsernameLoginPayload("user", "password"));
32 | assertThat(json, equalTo(expectedJson));
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/test/java/com/tapglue/android/internal/NotificationServiceIdStoreTest.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.internal;
2 |
3 | import android.content.Context;
4 |
5 | import org.junit.Before;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 | import org.mockito.Mock;
9 | import org.mockito.runners.MockitoJUnitRunner;
10 |
11 | import rx.Observable;
12 | import rx.functions.Func1;
13 |
14 | import static org.hamcrest.MatcherAssert.assertThat;
15 | import static org.hamcrest.core.IsEqual.equalTo;
16 | import static org.mockito.Mockito.verify;
17 | import static org.mockito.Mockito.when;
18 |
19 | @RunWith(MockitoJUnitRunner.class)
20 | public class NotificationServiceIdStoreTest {
21 |
22 | private static final String ID = "someId";
23 | @Mock
24 | Context context;
25 | @Mock
26 | Store internalStore;
27 | @Mock
28 | Func1 storeFunc;
29 | @Mock
30 | Observable getObservable;
31 |
32 | NotificationServiceIdStore store;
33 |
34 | @Before
35 | public void setUp() {
36 | store = new NotificationServiceIdStore(context);
37 | store.store = internalStore;
38 | }
39 |
40 | @Test
41 | public void storeStoresOnInternalStore() {
42 | when(internalStore.store()).thenReturn(storeFunc);
43 |
44 | store.store(ID);
45 |
46 | verify(storeFunc).call(ID);
47 | }
48 |
49 | @Test
50 | public void getGetsFromInternalStore() {
51 | when(internalStore.get()).thenReturn(getObservable);
52 |
53 | assertThat(store.get(), equalTo(getObservable));
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/test/java/com/tapglue/android/internal/TestEntity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.tapglue.android.internal;
18 |
19 | public class TestEntity{
20 | long id;
21 |
22 | public TestEntity(long id) {
23 | this.id = id;
24 | }
25 |
26 | @Override
27 | public boolean equals(Object o) {
28 | if (this == o) return true;
29 | if (o == null || getClass() != o.getClass()) return false;
30 |
31 | TestEntity that = (TestEntity) o;
32 |
33 | return id == that.id;
34 |
35 | }
36 |
37 | @Override
38 | public int hashCode() {
39 | return (int) (id ^ (id >>> 32));
40 | }
41 | }
--------------------------------------------------------------------------------
/tapglue-android-sdk/src/test/java/com/tapglue/android/sims/TapglueSimsTest.java:
--------------------------------------------------------------------------------
1 | package com.tapglue.android.sims;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 |
6 | import com.tapglue.android.Configuration;
7 | import com.tapglue.android.internal.NotificationServiceIdStore;
8 |
9 | import org.junit.Test;
10 | import org.junit.runner.RunWith;
11 | import org.mockito.Mock;
12 | import org.mockito.runners.MockitoJUnitRunner;
13 |
14 | import static org.mockito.Mockito.verify;
15 |
16 | @RunWith(MockitoJUnitRunner.class)
17 | public class TapglueSimsTest {
18 |
19 | @Mock
20 | Context context;
21 | @Mock
22 | Configuration configuration;
23 | @Mock
24 | NotificationServiceIdStore notificationIdStore;
25 | private static final String ID = "someID";
26 |
27 | @Test
28 | public void storesNotificationServiceIdOnChanged() {
29 | // TapglueSims sims = new TapglueSims(configuration, context);
30 | // sims.notificationIdStore = notificationIdStore;
31 | // sims.idChanged(ID);
32 | //
33 | // verify(notificationIdStore).store(ID);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/v1/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/v1/app/README.md:
--------------------------------------------------------------------------------
1 | # Test app
2 |
3 | This is a sample app to perform various tests against the SDK and Tapglue API.
--------------------------------------------------------------------------------
/v1/app/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | apply plugin: 'com.android.application'
19 |
20 | android {
21 | compileSdkVersion 23
22 | buildToolsVersion '23.0.2'
23 |
24 | defaultConfig {
25 | applicationId "com.tapglue.tapgluetests"
26 | minSdkVersion 15
27 | targetSdkVersion 23
28 | versionCode 1
29 | versionName "1.0"
30 |
31 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
32 | }
33 |
34 | compileOptions {
35 | sourceCompatibility JavaVersion.VERSION_1_7
36 | targetCompatibility JavaVersion.VERSION_1_7
37 | }
38 |
39 | lintOptions {
40 | lintConfig file('../gradle/lint.xml')
41 | }
42 |
43 | buildTypes {
44 | release {
45 | minifyEnabled false
46 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
47 | }
48 | }
49 | }
50 |
51 | dependencies {
52 | compile fileTree(include: ['*.jar'], dir: 'libs')
53 | testCompile 'junit:junit:4.12'
54 | compile 'com.android.support:appcompat-v7:23.1.1'
55 | compile project(':tapglue-android-sdk')
56 |
57 | androidTestCompile 'com.android.support:support-v4:23.1.1'
58 | androidTestCompile 'com.android.support.test:runner:0.4.1'
59 | androidTestCompile 'com.android.support.test:rules:0.4.1'
60 | androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
61 | }
62 |
--------------------------------------------------------------------------------
/v1/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 /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 |
--------------------------------------------------------------------------------
/v1/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
21 |
22 |
23 |
24 |
25 |
34 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/v1/app/src/main/java/com/tapglue/tapgluetests/TestApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.tapgluetests;
19 |
20 | import android.app.Application;
21 |
22 | import com.tapglue.Tapglue;
23 |
24 | public class TestApplication extends Application {
25 | @Override
26 | public void onCreate() {
27 | super.onCreate();
28 |
29 | Tapglue.TGConfiguration config = new Tapglue.TGConfiguration()
30 | .setDebugMode(true)
31 | .setToken("ad8acb4d3fb4ff5435a3680802c4f093");
32 | Tapglue.initialize(this, config);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/v1/app/src/main/res/layout/activity_test.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/v1/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tapglue/android_sdk/4e5c5c77e888c68e00835cdf19703223a41cd306/v1/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/v1/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tapglue/android_sdk/4e5c5c77e888c68e00835cdf19703223a41cd306/v1/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/v1/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tapglue/android_sdk/4e5c5c77e888c68e00835cdf19703223a41cd306/v1/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/v1/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tapglue/android_sdk/4e5c5c77e888c68e00835cdf19703223a41cd306/v1/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/v1/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tapglue/android_sdk/4e5c5c77e888c68e00835cdf19703223a41cd306/v1/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/v1/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
22 | 64dp
23 |
24 |
--------------------------------------------------------------------------------
/v1/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 | #3F51B5
20 | #303F9F
21 | #FF4081
22 |
23 |
--------------------------------------------------------------------------------
/v1/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 | 16dp
21 | 16dp
22 |
23 |
--------------------------------------------------------------------------------
/v1/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 | TapGlueTests
20 |
21 |
--------------------------------------------------------------------------------
/v1/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/v1/app/src/test/java/com/tapglue/tapgluetests/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.tapgluetests;
19 |
20 | import org.junit.Test;
21 |
22 | import static org.junit.Assert.assertEquals;
23 |
24 | /**
25 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
26 | */
27 | public class ExampleUnitTest {
28 | @Test
29 | public void addition_isCorrect() throws Exception {
30 | assertEquals(4, 2 + 2);
31 | }
32 | }
--------------------------------------------------------------------------------
/v1/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
19 |
20 | buildscript {
21 | repositories {
22 | jcenter()
23 | }
24 | dependencies {
25 | classpath 'com.android.tools.build:gradle:2.2.2'
26 |
27 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.5'
28 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
29 | }
30 | }
31 |
32 | project.ext {
33 | project.ext.preDexLibs = project.properties['preDexEnable'].equals('true')
34 | if (project.hasProperty('disablePreDex')) {
35 | project.ext.preDexLibs = false
36 | }
37 |
38 | println('PREDEX ' + (project.ext.preDexLibs ? 'ENABLED' : 'DISABLED'))
39 | }
40 |
41 | allprojects {
42 | repositories {
43 | jcenter()
44 | }
45 |
46 | project.plugins.whenPluginAdded { plugin ->
47 | if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
48 | project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
49 | } else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
50 | project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
51 | }
52 | }
53 | }
54 |
55 | task clean(type: Delete) {
56 | delete rootProject.buildDir
57 | }
58 |
--------------------------------------------------------------------------------
/v1/circle.yml:
--------------------------------------------------------------------------------
1 | machine:
2 | environment:
3 | _JAVA_OPTIONS: "-Xms512m -Xmx1024m"
4 | GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xms512m -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError"'
5 | java:
6 | version: oraclejdk8
7 | dependencies:
8 | pre:
9 | - sudo chown -R ubuntu:ubuntu /usr/local/android-sdk-linux
10 | override:
11 | - ./install_deps.sh
12 | cache_directories:
13 | - /usr/local/android-sdk-linux
14 | test:
15 | override:
16 | - emulator -avd tapglue -no-audio -no-window :
17 | background: true
18 | parallel: true
19 | - ./gradlew clean -PdisablePreDex --stacktrace
20 | - ./gradlew assembleDebug -PdisablePreDex --stacktrace
21 | - ./gradlew assembleDebugAndroidTest -PdisablePreDex --stacktrace
22 | - circle-android wait-for-boot
23 | - adb kill-server
24 | - adb devices
25 | - adb install -r app/build/outputs/apk/app-debug.apk
26 | - adb install -r app/build/outputs/apk/app-debug-androidTest-unaligned.apk
27 | - ./run_tests.sh
28 |
--------------------------------------------------------------------------------
/v1/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 | #
17 |
18 | # Project-wide Gradle settings.
19 |
20 | # IDE (e.g. Android Studio) users:
21 | # Gradle settings configured through the IDE *will override*
22 | # any settings specified in this file.
23 |
24 | # For more details on how to configure your build environment visit
25 | # http://www.gradle.org/docs/current/userguide/build_environment.html
26 |
27 | # Specifies the JVM arguments used for the daemon process.
28 | # The setting is particularly useful for tweaking memory settings.
29 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
30 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
31 |
32 | # When configured, Gradle will run in incubating parallel mode.
33 | # This option should only be used with decoupled projects. More details, visit
34 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
35 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/v1/gradle/lint.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/v1/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tapglue/android_sdk/4e5c5c77e888c68e00835cdf19703223a41cd306/v1/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/v1/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Jan 18 11:46:06 CET 2016
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-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/v1/install_deps.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | if [ ! -d ${ANDROID_HOME}/build-tools/23.0.2 ]; then
4 | echo y | android update sdk --no-ui --all --filter "tool"
5 | echo y | android update sdk --no-ui --all --filter "build-tools-23.0.2"
6 | fi
7 |
8 | echo n | android create avd -n tapglue -f -t android-23
--------------------------------------------------------------------------------
/v1/run_tests.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -ex
4 |
5 | adb kill-server
6 | adb devices
7 | (adb logcat > logcat.out) &
8 | LOGCAT_PID=$!
9 | adb shell am start -n com.tapglue.tapgluetests/.TestActivity
10 | sleep 60
11 | kill -9 ${LOGCAT_PID}
12 | cat logcat.out | grep -i 'Tests finished correctly'
13 |
--------------------------------------------------------------------------------
/v1/settings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | include ':app', ':tapglue-android-sdk'
19 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/.idea/.name:
--------------------------------------------------------------------------------
1 | tapglue-android-sdk
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/.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 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/.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 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tapglue/android_sdk/4e5c5c77e888c68e00835cdf19703223a41cd306/v1/tapglue-android-sdk/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Oct 21 11:34:03 PDT 2015
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-2.8-all.zip
7 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/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 /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 | -dontwarn retrofit.**
19 | -keep class retrofit.** { *; }
20 | -keepattributes Signature
21 | -keepattributes Exceptions
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/androidTest/java/com/tapglue/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue;
19 |
20 | import android.app.Application;
21 | import android.test.ApplicationTestCase;
22 |
23 | /**
24 | * Testing Fundamentals
25 | */
26 |
27 | public class ApplicationTest extends ApplicationTestCase {
28 | public ApplicationTest() {
29 | super(Application.class);
30 | }
31 | }
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/androidTest/java/com/tapglue/utils/TGPasswordHasherTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.utils;
19 |
20 | import android.test.suitebuilder.annotation.SmallTest;
21 |
22 | import junit.framework.TestCase;
23 |
24 | public class TGPasswordHasherTest extends TestCase {
25 |
26 | @SmallTest
27 | public void test01() {
28 | assertEquals(TGPasswordHasher.hashPassword("password"), "89b1af261b009d79687506151b0367edabaae9ae");
29 | assertEquals(TGPasswordHasher.hashPassword("LongPasswordWithMoreText123"), "21cf9aa2a27f3bd5b9dce6b9b4cd903d2997c314");
30 | assertEquals(TGPasswordHasher.hashPassword("viJyFK%XuW=&K6mEh8mgA>eVjMAMFUzGcnn7yv"), "19b38a4d4fd0fbb198828da47f6585523d472feb");
31 | }
32 |
33 | }
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/managers/AbstractTGManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.managers;
19 |
20 | import com.tapglue.Tapglue;
21 |
22 | abstract class AbstractTGManager {
23 | final Tapglue instance;
24 |
25 | AbstractTGManager(Tapglue instance) {
26 | this.instance = instance;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/managers/TGEventManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.managers;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.tapglue.model.TGEvent;
23 | import com.tapglue.model.TGEventObject;
24 | import com.tapglue.networking.requests.TGRequestCallback;
25 |
26 | public interface TGEventManager {
27 | /**
28 | * Create event with selected type
29 | *
30 | * @param type
31 | * @param callback
32 | */
33 | void createEvent(@NonNull String type, @NonNull final TGRequestCallback callback);
34 |
35 | /**
36 | * Create event with selected type and object
37 | *
38 | * @param type
39 | * @param object
40 | * @param callback
41 | */
42 | void createEvent(@NonNull String type, @NonNull TGEventObject object, @NonNull final TGRequestCallback callback);
43 |
44 | /**
45 | * Create event with selected type and object ID
46 | *
47 | * @param type
48 | * @param objectId
49 | * @param callback
50 | */
51 | void createEvent(@NonNull String type, @NonNull String objectId, @NonNull final TGRequestCallback callback);
52 |
53 | /**
54 | * Create event with custom params
55 | *
56 | * @param event
57 | * @param callback
58 | */
59 | void createEvent(@NonNull TGEvent event, @NonNull final TGRequestCallback callback);
60 |
61 | /**
62 | * Delete an event by ID
63 | *
64 | * @param id
65 | * @param callback
66 | */
67 | void removeEvent(@NonNull Long id, @NonNull final TGRequestCallback callback);
68 | }
69 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/managers/TGRecommendationManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.managers;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.tapglue.model.TGRecommendedUsers.TGRecommendationPeriod;
23 | import com.tapglue.model.TGRecommendedUsers.TGRecommendationType;
24 | import com.tapglue.model.TGUsersList;
25 | import com.tapglue.networking.requests.TGRequestCallback;
26 |
27 | public interface TGRecommendationManager {
28 | /**
29 | * Get recommended users
30 | *
31 | * @param type
32 | * @param period
33 | * @param callback
34 | */
35 | void getUsers(TGRecommendationType type, TGRecommendationPeriod period, @NonNull final TGRequestCallback callback);
36 | }
37 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/managers/TGRecommendationManagerImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.managers;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.tapglue.Tapglue;
23 | import com.tapglue.model.TGRecommendedUsers.TGRecommendationPeriod;
24 | import com.tapglue.model.TGRecommendedUsers.TGRecommendationType;
25 | import com.tapglue.model.TGUsersList;
26 | import com.tapglue.networking.requests.TGRequestCallback;
27 | import com.tapglue.networking.requests.TGRequestErrorType;
28 |
29 | public class TGRecommendationManagerImpl extends AbstractTGManager implements TGRecommendationManager {
30 |
31 | public TGRecommendationManagerImpl(Tapglue tgInstance) {
32 | super(tgInstance);
33 | }
34 |
35 | /**
36 | * Get the recommended active users for the last day
37 | *
38 | * @param callback
39 | */
40 | public void getUsers(TGRecommendationType type, TGRecommendationPeriod period, @NonNull final TGRequestCallback callback) {
41 | if (instance.getUserManager().getCurrentUser() == null) {
42 | callback.onRequestError(new TGRequestErrorType(TGRequestErrorType.ErrorType.USER_NOT_LOGGED_IN));
43 | return;
44 | }
45 |
46 | instance.createRequest().getRecommendedUsers(type, period, callback);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/model/TGBaseObjectWithId.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.model;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.google.gson.annotations.Expose;
23 | import com.google.gson.annotations.SerializedName;
24 | import com.tapglue.networking.TGCustomCacheObject.TGCacheObjectType;
25 |
26 | /**
27 | * Base for all API-synchronized objects containing ID
28 | */
29 | public abstract class TGBaseObjectWithId, IDTYPE> extends TGBaseObject {
30 |
31 | @Expose
32 | @SerializedName("id")
33 | private IDTYPE id;
34 |
35 | TGBaseObjectWithId(@NonNull TGCacheObjectType type) {
36 | super(type);
37 | }
38 |
39 | /**
40 | * Get ID used for network connections
41 | *
42 | * @return ID
43 | */
44 | @NonNull
45 | final public IDTYPE getID() {
46 | return id;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/model/TGCommentsList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.model;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import com.google.gson.annotations.Expose;
22 | import com.google.gson.annotations.SerializedName;
23 | import com.tapglue.networking.TGCustomCacheObject.TGCacheObjectType;
24 |
25 | import java.util.List;
26 |
27 | public class TGCommentsList extends TGBaseObject {
28 | @Expose
29 | @SerializedName("comments")
30 | private List comments;
31 |
32 | @Expose
33 | @SerializedName("comments_count")
34 | private Integer commentsCount;
35 |
36 | @Expose
37 | @SerializedName("post")
38 | private TGPost post;
39 |
40 | public TGCommentsList() {
41 | super(TGCacheObjectType.CommentsList);
42 | }
43 |
44 | /**
45 | * Get comments
46 | *
47 | * @return List with comments
48 | */
49 | public List getComments() {
50 | return comments;
51 | }
52 |
53 | /**
54 | * Get amount of comments
55 | *
56 | * @return Comments counter
57 | */
58 | public Integer getCommentsCount() {
59 | return commentsCount;
60 | }
61 |
62 | /**
63 | * Get post which comments are in list
64 | *
65 | * @return Post
66 | */
67 | public TGPost getPost() {
68 | return post;
69 | }
70 |
71 | @NonNull
72 | @Override
73 | protected TGCommentsList getThis() {
74 | return this;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/model/TGError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.model;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.google.gson.annotations.Expose;
23 | import com.google.gson.annotations.SerializedName;
24 | import com.tapglue.networking.TGCustomCacheObject.TGCacheObjectType;
25 |
26 | public class TGError extends TGBaseObject {
27 | /**
28 | * Error code
29 | */
30 |
31 | @Expose
32 | @SerializedName("code")
33 | private Long errorCode;
34 |
35 | @Expose
36 | @SerializedName("message")
37 | private String message;
38 |
39 | public TGError() {
40 | super(TGCacheObjectType.Error);
41 | }
42 |
43 | /**
44 | * Get error code
45 | *
46 | * @return Error code
47 | */
48 | final public Long getErrorCode() {
49 | return errorCode;
50 | }
51 |
52 |
53 | /**
54 | * Get error message from server
55 | *
56 | * @return
57 | */
58 | final public String getMessage() {
59 | return message;
60 | }
61 |
62 | @NonNull
63 | @Override
64 | protected TGError getThis() {
65 | return this;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/model/TGErrorList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.model;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.google.gson.annotations.Expose;
23 | import com.google.gson.annotations.SerializedName;
24 | import com.tapglue.networking.TGCustomCacheObject.TGCacheObjectType;
25 |
26 | import java.util.List;
27 |
28 | public class TGErrorList extends TGBaseObject {
29 |
30 | @Expose
31 | @SerializedName("errors")
32 | private List errorList;
33 |
34 | public TGErrorList() {
35 | super(TGCacheObjectType.Error);
36 | }
37 |
38 | /**
39 | * Get list of error
40 | *
41 | * @return List of errors
42 | */
43 | public List getErrors() {
44 | return errorList;
45 | }
46 |
47 | @NonNull
48 | @Override
49 | protected TGErrorList getThis() {
50 | return this;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/model/TGFeedCount.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.model;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.google.gson.annotations.Expose;
23 | import com.google.gson.annotations.SerializedName;
24 | import com.tapglue.networking.TGCustomCacheObject.TGCacheObjectType;
25 |
26 | public class TGFeedCount extends TGBaseObject {
27 | @Expose
28 | @SerializedName("unread_events_count")
29 | private Long unreadCounter;
30 |
31 | public TGFeedCount() {
32 | super(TGCacheObjectType.FeedCount);
33 | }
34 |
35 | @NonNull
36 | @Override
37 | protected TGFeedCount getThis() {
38 | return this;
39 | }
40 |
41 | /**
42 | * Get amount of unread events from feed
43 | *
44 | * @return
45 | */
46 | public Long getUnreadCount() {
47 | return unreadCounter;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/model/TGLike.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.model;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import com.google.gson.annotations.Expose;
22 | import com.google.gson.annotations.SerializedName;
23 | import com.tapglue.networking.TGCustomCacheObject.TGCacheObjectType;
24 |
25 | public class TGLike extends TGBaseObjectWithId {
26 | @Expose
27 | @SerializedName("post_id")
28 | private String postId;
29 |
30 | @Expose
31 | @SerializedName("user_id")
32 | private String userId;
33 |
34 | public TGLike() {
35 | super(TGCacheObjectType.Like);
36 | }
37 |
38 | /**
39 | * Get ID of post
40 | *
41 | * @return post id
42 | */
43 | public String getPostId() {
44 | return postId;
45 | }
46 |
47 | /**
48 | * Set ID of post Setting this won't change server value - use only for ui updates if needed
49 | *
50 | * @param postId
51 | *
52 | * @return
53 | */
54 | @NonNull
55 | public TGLike setPostId(String postId) {
56 | this.postId = postId;
57 | return this;
58 | }
59 |
60 | @NonNull
61 | @Override
62 | protected TGLike getThis() {
63 | return this;
64 | }
65 |
66 | /**
67 | * Get ID of user
68 | *
69 | * @return
70 | */
71 | public String getUserId() {
72 | return userId;
73 | }
74 |
75 | /**
76 | * Set id of user assigned to like Setting this won't change server value - use only for ui
77 | * updates if needed
78 | *
79 | * @param userId
80 | *
81 | * @return
82 | */
83 | @NonNull
84 | public TGLike setUserId(String userId) {
85 | this.userId = userId;
86 | return this;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/model/TGLikesList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.model;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import com.google.gson.annotations.Expose;
22 | import com.google.gson.annotations.SerializedName;
23 | import com.tapglue.networking.TGCustomCacheObject.TGCacheObjectType;
24 |
25 | import java.util.List;
26 |
27 | public class TGLikesList extends TGBaseObject {
28 | @Expose
29 | @SerializedName("likes")
30 | private List likes;
31 |
32 | @Expose
33 | @SerializedName("likes_count")
34 | private Integer likesCount;
35 |
36 | @Expose
37 | @SerializedName("post")
38 | private TGPost post;
39 |
40 | public TGLikesList() {
41 | super(TGCacheObjectType.LikesList);
42 | }
43 |
44 | /**
45 | * Get list of likes
46 | *
47 | * @return Likes details
48 | */
49 | public List getLikes() {
50 | return likes;
51 | }
52 |
53 | /**
54 | * Get amount of likes
55 | *
56 | * @return Likes counter
57 | */
58 | public Integer getLikesCount() {
59 | return likesCount;
60 | }
61 |
62 | /**
63 | * Get post to which likes are assigned to
64 | *
65 | * @return Post
66 | */
67 | public TGPost getPost() {
68 | return post;
69 | }
70 |
71 | @NonNull
72 | @Override
73 | protected TGLikesList getThis() {
74 | return this;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/model/TGLoginUser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.model;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.google.gson.annotations.Expose;
23 | import com.google.gson.annotations.SerializedName;
24 | import com.tapglue.networking.TGCustomCacheObject;
25 |
26 | public class TGLoginUser> extends TGBaseObjectWithId {
27 | @Expose
28 | @SerializedName("email")
29 | String email;
30 |
31 | @NonNull
32 | @Expose
33 | @SerializedName("password")
34 | String password;
35 |
36 | @Expose
37 | @SerializedName("user_name")
38 | String userName;
39 |
40 | public TGLoginUser(String userName, String email, @NonNull String password) {
41 | super(TGCustomCacheObject.TGCacheObjectType.LoginUser);
42 | this.userName = userName;
43 | this.email = email;
44 | this.password = password;
45 | }
46 |
47 | /**
48 | * Get user email
49 | *
50 | * @return user email
51 | */
52 | public String getEmail() {
53 | return email;
54 | }
55 |
56 | /**
57 | * Get user password
58 | *
59 | * @return user password
60 | */
61 | @NonNull
62 | public String getPassword() {
63 | return password;
64 | }
65 |
66 | @NonNull
67 | @Override
68 | protected T getThis() {
69 | return (T) this;
70 | }
71 |
72 | /**
73 | * Get user name
74 | *
75 | * @return user name
76 | */
77 | public String getUserName() {
78 | return userName;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/model/TGPostsList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.model;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import com.google.gson.annotations.Expose;
22 | import com.google.gson.annotations.SerializedName;
23 | import com.tapglue.networking.TGCustomCacheObject.TGCacheObjectType;
24 |
25 | import java.util.List;
26 |
27 | public class TGPostsList extends TGBaseObject {
28 | @Expose
29 | @SerializedName("posts")
30 | private List posts;
31 |
32 | @Expose
33 | @SerializedName("posts_count")
34 | private Integer postsCount;
35 |
36 | public TGPostsList() {
37 | super(TGCacheObjectType.PostList);
38 | }
39 |
40 | /**
41 | * Get posts count
42 | *
43 | * @return Posts Count
44 | */
45 | public Integer getCount() {
46 | return postsCount;
47 | }
48 |
49 | /**
50 | * Get posts
51 | *
52 | * @return Posts
53 | */
54 | public List getPosts() {
55 | return posts;
56 | }
57 |
58 | @NonNull
59 | @Override
60 | protected TGPostsList getThis() {
61 | return this;
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/model/TGUsersList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.model;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.google.gson.annotations.Expose;
23 | import com.google.gson.annotations.SerializedName;
24 | import com.tapglue.networking.TGCustomCacheObject.TGCacheObjectType;
25 |
26 | import java.util.List;
27 |
28 | public class TGUsersList extends TGBaseObject {
29 |
30 | @Expose
31 | @SerializedName("users")
32 | private List users;
33 |
34 | public TGUsersList(@NonNull TGCacheObjectType type) {
35 | super(type);
36 | }
37 |
38 | public TGUsersList() {
39 | super(TGCacheObjectType.ConnectionUserList);
40 | }
41 |
42 | @NonNull
43 | @Override
44 | protected TGUsersList getThis() {
45 | return this;
46 | }
47 |
48 | /**
49 | * Get list of connection users
50 | *
51 | * @return List of connection users
52 | */
53 | public List getUsers() {
54 | return users;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/model/TGVisibility.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.model;
18 |
19 | import android.support.annotation.NonNull;
20 | import android.support.annotation.Nullable;
21 |
22 | public enum TGVisibility {
23 | // TODO document these
24 | Private(10), Connections(20), Public(30), Global(40);
25 |
26 | private final int value;
27 |
28 | @NonNull
29 | public static TGVisibility fromValue(@Nullable Integer valueToFind) {
30 | if (valueToFind == null) {
31 | return Private;
32 | }
33 | for (TGVisibility value : values()) {
34 | if (value.asValue().intValue() == valueToFind.intValue()) {
35 | return value;
36 | }
37 | }
38 | return Private;
39 | }
40 |
41 | TGVisibility(int realValue) {
42 | value = realValue;
43 | }
44 |
45 | public Integer asValue() {
46 | return value;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/model/queries/TGQueryObjectField.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.model.queries;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | class TGQueryObjectField {
23 |
24 | @NonNull
25 | private transient String name = "";
26 |
27 | @NonNull
28 | String getName() {
29 | return name;
30 | }
31 |
32 | TGQueryObjectField setName(@NonNull String name) {
33 | this.name = name;
34 | return this;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/networking/TGCacheRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.networking;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.tapglue.model.TGBaseObject;
23 | import com.tapglue.networking.requests.TGRequestCallback;
24 | import com.tapglue.networking.requests.TGRequestErrorType;
25 | import com.tapglue.networking.requests.TGRequestType;
26 |
27 | class TGCacheRequest {
28 | private static final TGRequestCallback dummyCallback = new TGRequestCallback() {
29 | @Override
30 | public boolean callbackIsEnabled() {
31 | return true;
32 | }
33 |
34 | @Override
35 | public void onRequestError(TGRequestErrorType cause) {
36 |
37 | }
38 |
39 | @Override
40 | public void onRequestFinished(Object output, boolean changeDoneOnline) {
41 |
42 | }
43 | };
44 |
45 | /**
46 | * Request object
47 | */
48 | private final T object;
49 |
50 | /**
51 | * Request type
52 | */
53 | private final TGRequestType type;
54 |
55 | public TGCacheRequest(@NonNull TGRequest req) {
56 | type = req.getRequestType();
57 | object = req.getObject();
58 | }
59 |
60 | /**
61 | * Convert cache request to standard request Those requests will always receive generic
62 | * callback
63 | * method, that is never outdated, but it also won't do any changes in UI due to always
64 | * outdated
65 | * old callbacks
66 | *
67 | * @return Converted Tapglue request
68 | */
69 | @NonNull
70 | public TGRequest toTGRequest() {
71 | return new TGRequest(object, type, true, dummyCallback);
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/networking/requests/TGRequestCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.networking.requests;
19 |
20 | public interface TGRequestCallback {
21 | /**
22 | * Information if request callback is not outdated / is active
23 | */
24 | boolean callbackIsEnabled();
25 |
26 | /**
27 | * Request couldn't be finished At most cases this will happen when no internet connection is
28 | * available, and request would require to be done live
29 | *
30 | * @param cause Cause of error
31 | */
32 | void onRequestError(TGRequestErrorType cause);
33 |
34 | /**
35 | * Request was finished with success
36 | *
37 | * @param output Return object or status object
38 | * @param changeDoneOnline Flag with information if request was done online or just queued in
39 | * cache
40 | */
41 | void onRequestFinished(OBJECT output, boolean changeDoneOnline);
42 | }
43 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/networking/requests/TGRequestType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.networking.requests;
19 |
20 | /**
21 | * Request types supported by factory
22 | */
23 | public enum TGRequestType {
24 | CREATE, READ, UPDATE, DELETE, LOGIN, LOGOUT, SEARCH
25 | }
26 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/main/java/com/tapglue/utils/TGLog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.utils;
19 |
20 | import android.support.annotation.NonNull;
21 | import android.util.Log;
22 |
23 | public class TGLog {
24 |
25 | private static final String LOG_TAG = "Tapglue";
26 |
27 | /**
28 | * Should logger do its work?
29 | */
30 | private boolean isEnabled = false;
31 |
32 | public TGLog(boolean enabled) {
33 | isEnabled = enabled;
34 | }
35 |
36 | /**
37 | * Log information
38 | *
39 | * @param what What should be logged
40 | */
41 | public void log(String what) {
42 | if (!isEnabled) { return; }
43 | Log.d(LOG_TAG, what);
44 | }
45 |
46 | /**
47 | * Log error
48 | *
49 | * @param t Throwable to log
50 | */
51 | public void logE(@NonNull Throwable t) {
52 | if (!isEnabled) { return; }
53 | Log.e(LOG_TAG, t.getMessage());
54 | t.printStackTrace();
55 | }
56 |
57 | /**
58 | * Log warning
59 | *
60 | * @param what What should be logged
61 | */
62 | public void logW(String what) {
63 | Log.w(LOG_TAG, what);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/src/test/java/com/tapglue/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue;
19 |
20 | import org.junit.Test;
21 |
22 | import static org.junit.Assert.assertEquals;
23 |
24 | /**
25 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
26 | */
27 | public class ExampleUnitTest {
28 | @Test
29 | public void addition_isCorrect() throws Exception {
30 | assertEquals(4, 2 + 2);
31 | }
32 | }
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/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 /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 | -dontwarn retrofit.**
19 | -keep class retrofit.** { *; }
20 | -keepattributes Signature
21 | -keepattributes Exceptions
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/androidTest/java/com/tapglue/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue;
19 |
20 | import android.app.Application;
21 | import android.test.ApplicationTestCase;
22 |
23 | /**
24 | * Testing Fundamentals
25 | */
26 |
27 | public class ApplicationTest extends ApplicationTestCase {
28 | public ApplicationTest() {
29 | super(Application.class);
30 | }
31 | }
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/androidTest/java/com/tapglue/utils/TGPasswordHasherTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.utils;
19 |
20 | import android.test.suitebuilder.annotation.SmallTest;
21 |
22 | import junit.framework.TestCase;
23 |
24 | public class TGPasswordHasherTest extends TestCase {
25 |
26 | @SmallTest
27 | public void test01() {
28 | assertEquals(TGPasswordHasher.hashPassword("password"), "89b1af261b009d79687506151b0367edabaae9ae");
29 | assertEquals(TGPasswordHasher.hashPassword("LongPasswordWithMoreText123"), "21cf9aa2a27f3bd5b9dce6b9b4cd903d2997c314");
30 | assertEquals(TGPasswordHasher.hashPassword("viJyFK%XuW=&K6mEh8mgA>eVjMAMFUzGcnn7yv"), "19b38a4d4fd0fbb198828da47f6585523d472feb");
31 | }
32 |
33 | }
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/managers/AbstractTGManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.managers;
19 |
20 | import com.tapglue.Tapglue;
21 |
22 | abstract class AbstractTGManager {
23 | final Tapglue instance;
24 |
25 | AbstractTGManager(Tapglue instance) {
26 | this.instance = instance;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/managers/TGEventManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.managers;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.tapglue.model.TGEvent;
23 | import com.tapglue.model.TGEventObject;
24 | import com.tapglue.networking.requests.TGRequestCallback;
25 |
26 | public interface TGEventManager {
27 | /**
28 | * Create event with selected type
29 | *
30 | * @param type
31 | * @param callback
32 | */
33 | void createEvent(@NonNull String type, @NonNull final TGRequestCallback callback);
34 |
35 | /**
36 | * Create event with selected type and object
37 | *
38 | * @param type
39 | * @param object
40 | * @param callback
41 | */
42 | void createEvent(@NonNull String type, @NonNull TGEventObject object, @NonNull final TGRequestCallback callback);
43 |
44 | /**
45 | * Create event with selected type and object ID
46 | *
47 | * @param type
48 | * @param objectId
49 | * @param callback
50 | */
51 | void createEvent(@NonNull String type, @NonNull String objectId, @NonNull final TGRequestCallback callback);
52 |
53 | /**
54 | * Create event with custom params
55 | *
56 | * @param event
57 | * @param callback
58 | */
59 | void createEvent(@NonNull TGEvent event, @NonNull final TGRequestCallback callback);
60 |
61 | /**
62 | * Delete an event by ID
63 | *
64 | * @param id
65 | * @param callback
66 | */
67 | void removeEvent(@NonNull Long id, @NonNull final TGRequestCallback callback);
68 | }
69 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/managers/TGRecommendationManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.managers;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.tapglue.model.TGRecommendedUsers.TGRecommendationPeriod;
23 | import com.tapglue.model.TGRecommendedUsers.TGRecommendationType;
24 | import com.tapglue.model.TGUsersList;
25 | import com.tapglue.networking.requests.TGRequestCallback;
26 |
27 | public interface TGRecommendationManager {
28 | /**
29 | * Get recommended users
30 | *
31 | * @param type
32 | * @param period
33 | * @param callback
34 | */
35 | void getUsers(TGRecommendationType type, TGRecommendationPeriod period, @NonNull final TGRequestCallback callback);
36 | }
37 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/managers/TGRecommendationManagerImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.managers;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.tapglue.Tapglue;
23 | import com.tapglue.model.TGRecommendedUsers.TGRecommendationPeriod;
24 | import com.tapglue.model.TGRecommendedUsers.TGRecommendationType;
25 | import com.tapglue.model.TGUsersList;
26 | import com.tapglue.networking.requests.TGRequestCallback;
27 | import com.tapglue.networking.requests.TGRequestErrorType;
28 |
29 | public class TGRecommendationManagerImpl extends AbstractTGManager implements TGRecommendationManager {
30 |
31 | public TGRecommendationManagerImpl(Tapglue tgInstance) {
32 | super(tgInstance);
33 | }
34 |
35 | /**
36 | * Get the recommended active users for the last day
37 | *
38 | * @param callback
39 | */
40 | public void getUsers(TGRecommendationType type, TGRecommendationPeriod period, @NonNull final TGRequestCallback callback) {
41 | if (instance.getUserManager().getCurrentUser() == null) {
42 | callback.onRequestError(new TGRequestErrorType(TGRequestErrorType.ErrorType.USER_NOT_LOGGED_IN));
43 | return;
44 | }
45 |
46 | instance.createRequest().getRecommendedUsers(type, period, callback);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/model/TGBaseObjectWithId.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.model;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.google.gson.annotations.Expose;
23 | import com.google.gson.annotations.SerializedName;
24 | import com.tapglue.networking.TGCustomCacheObject.TGCacheObjectType;
25 |
26 | /**
27 | * Base for all API-synchronized objects containing ID
28 | */
29 | public abstract class TGBaseObjectWithId, IDTYPE> extends TGBaseObject {
30 |
31 | @Expose
32 | @SerializedName("id")
33 | private IDTYPE id;
34 |
35 | TGBaseObjectWithId(@NonNull TGCacheObjectType type) {
36 | super(type);
37 | }
38 |
39 | /**
40 | * Get ID used for network connections
41 | *
42 | * @return ID
43 | */
44 | @NonNull
45 | final public IDTYPE getID() {
46 | return id;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/model/TGCommentsList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.model;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import com.google.gson.annotations.Expose;
22 | import com.google.gson.annotations.SerializedName;
23 | import com.tapglue.networking.TGCustomCacheObject.TGCacheObjectType;
24 |
25 | import java.util.List;
26 |
27 | public class TGCommentsList extends TGBaseObject {
28 | @Expose
29 | @SerializedName("comments")
30 | private List comments;
31 |
32 | @Expose
33 | @SerializedName("comments_count")
34 | private Integer commentsCount;
35 |
36 | @Expose
37 | @SerializedName("post")
38 | private TGPost post;
39 |
40 | public TGCommentsList() {
41 | super(TGCacheObjectType.CommentsList);
42 | }
43 |
44 | /**
45 | * Get comments
46 | *
47 | * @return List with comments
48 | */
49 | public List getComments() {
50 | return comments;
51 | }
52 |
53 | /**
54 | * Get amount of comments
55 | *
56 | * @return Comments counter
57 | */
58 | public Integer getCommentsCount() {
59 | return commentsCount;
60 | }
61 |
62 | /**
63 | * Get post which comments are in list
64 | *
65 | * @return Post
66 | */
67 | public TGPost getPost() {
68 | return post;
69 | }
70 |
71 | @NonNull
72 | @Override
73 | protected TGCommentsList getThis() {
74 | return this;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/model/TGError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.model;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.google.gson.annotations.Expose;
23 | import com.google.gson.annotations.SerializedName;
24 | import com.tapglue.networking.TGCustomCacheObject.TGCacheObjectType;
25 |
26 | public class TGError extends TGBaseObject {
27 | /**
28 | * Error code
29 | */
30 |
31 | @Expose
32 | @SerializedName("code")
33 | private Long errorCode;
34 |
35 | @Expose
36 | @SerializedName("message")
37 | private String message;
38 |
39 | public TGError() {
40 | super(TGCacheObjectType.Error);
41 | }
42 |
43 | /**
44 | * Get error code
45 | *
46 | * @return Error code
47 | */
48 | final public Long getErrorCode() {
49 | return errorCode;
50 | }
51 |
52 |
53 | /**
54 | * Get error message from server
55 | *
56 | * @return
57 | */
58 | final public String getMessage() {
59 | return message;
60 | }
61 |
62 | @NonNull
63 | @Override
64 | protected TGError getThis() {
65 | return this;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/model/TGErrorList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.model;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.google.gson.annotations.Expose;
23 | import com.google.gson.annotations.SerializedName;
24 | import com.tapglue.networking.TGCustomCacheObject.TGCacheObjectType;
25 |
26 | import java.util.List;
27 |
28 | public class TGErrorList extends TGBaseObject {
29 |
30 | @Expose
31 | @SerializedName("errors")
32 | private List errorList;
33 |
34 | public TGErrorList() {
35 | super(TGCacheObjectType.Error);
36 | }
37 |
38 | /**
39 | * Get list of error
40 | *
41 | * @return List of errors
42 | */
43 | public List getErrors() {
44 | return errorList;
45 | }
46 |
47 | @NonNull
48 | @Override
49 | protected TGErrorList getThis() {
50 | return this;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/model/TGFeedCount.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.model;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.google.gson.annotations.Expose;
23 | import com.google.gson.annotations.SerializedName;
24 | import com.tapglue.networking.TGCustomCacheObject.TGCacheObjectType;
25 |
26 | public class TGFeedCount extends TGBaseObject {
27 | @Expose
28 | @SerializedName("unread_events_count")
29 | private Long unreadCounter;
30 |
31 | public TGFeedCount() {
32 | super(TGCacheObjectType.FeedCount);
33 | }
34 |
35 | @NonNull
36 | @Override
37 | protected TGFeedCount getThis() {
38 | return this;
39 | }
40 |
41 | /**
42 | * Get amount of unread events from feed
43 | *
44 | * @return
45 | */
46 | public Long getUnreadCount() {
47 | return unreadCounter;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/model/TGLikesList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.model;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import com.google.gson.annotations.Expose;
22 | import com.google.gson.annotations.SerializedName;
23 | import com.tapglue.networking.TGCustomCacheObject.TGCacheObjectType;
24 |
25 | import java.util.List;
26 |
27 | public class TGLikesList extends TGBaseObject {
28 | @Expose
29 | @SerializedName("likes")
30 | private List likes;
31 |
32 | @Expose
33 | @SerializedName("likes_count")
34 | private Integer likesCount;
35 |
36 | @Expose
37 | @SerializedName("post")
38 | private TGPost post;
39 |
40 | public TGLikesList() {
41 | super(TGCacheObjectType.LikesList);
42 | }
43 |
44 | /**
45 | * Get list of likes
46 | *
47 | * @return Likes details
48 | */
49 | public List getLikes() {
50 | return likes;
51 | }
52 |
53 | /**
54 | * Get amount of likes
55 | *
56 | * @return Likes counter
57 | */
58 | public Integer getLikesCount() {
59 | return likesCount;
60 | }
61 |
62 | /**
63 | * Get post to which likes are assigned to
64 | *
65 | * @return Post
66 | */
67 | public TGPost getPost() {
68 | return post;
69 | }
70 |
71 | @NonNull
72 | @Override
73 | protected TGLikesList getThis() {
74 | return this;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/model/TGLoginUser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.model;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.google.gson.annotations.Expose;
23 | import com.google.gson.annotations.SerializedName;
24 | import com.tapglue.networking.TGCustomCacheObject;
25 |
26 | public class TGLoginUser> extends TGBaseObjectWithId {
27 | @Expose
28 | @SerializedName("email")
29 | String email;
30 |
31 | @NonNull
32 | @Expose
33 | @SerializedName("password")
34 | String password;
35 |
36 | @Expose
37 | @SerializedName("user_name")
38 | String userName;
39 |
40 | public TGLoginUser(String userName, String email, @NonNull String password) {
41 | super(TGCustomCacheObject.TGCacheObjectType.LoginUser);
42 | this.userName = userName;
43 | this.email = email;
44 | this.password = password;
45 | }
46 |
47 | /**
48 | * Get user email
49 | *
50 | * @return user email
51 | */
52 | public String getEmail() {
53 | return email;
54 | }
55 |
56 | /**
57 | * Get user password
58 | *
59 | * @return user password
60 | */
61 | @NonNull
62 | public String getPassword() {
63 | return password;
64 | }
65 |
66 | @NonNull
67 | @Override
68 | protected T getThis() {
69 | return (T) this;
70 | }
71 |
72 | /**
73 | * Get user name
74 | *
75 | * @return user name
76 | */
77 | public String getUserName() {
78 | return userName;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/model/TGPostsList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.model;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import com.google.gson.annotations.Expose;
22 | import com.google.gson.annotations.SerializedName;
23 | import com.tapglue.networking.TGCustomCacheObject.TGCacheObjectType;
24 |
25 | import java.util.List;
26 |
27 | public class TGPostsList extends TGBaseObject {
28 | @Expose
29 | @SerializedName("posts")
30 | private List posts;
31 |
32 | @Expose
33 | @SerializedName("posts_count")
34 | private Integer postsCount;
35 |
36 | public TGPostsList() {
37 | super(TGCacheObjectType.PostList);
38 | }
39 |
40 | /**
41 | * Get posts count
42 | *
43 | * @return Posts Count
44 | */
45 | public Integer getCount() {
46 | return postsCount;
47 | }
48 |
49 | /**
50 | * Get posts
51 | *
52 | * @return Posts
53 | */
54 | public List getPosts() {
55 | return posts;
56 | }
57 |
58 | @NonNull
59 | @Override
60 | protected TGPostsList getThis() {
61 | return this;
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/model/TGUsersList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.model;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.google.gson.annotations.Expose;
23 | import com.google.gson.annotations.SerializedName;
24 | import com.tapglue.networking.TGCustomCacheObject.TGCacheObjectType;
25 |
26 | import java.util.List;
27 |
28 | public class TGUsersList extends TGBaseObject {
29 |
30 | @Expose
31 | @SerializedName("users")
32 | private List users;
33 |
34 | public TGUsersList(@NonNull TGCacheObjectType type) {
35 | super(type);
36 | }
37 |
38 | public TGUsersList() {
39 | super(TGCacheObjectType.ConnectionUserList);
40 | }
41 |
42 | @NonNull
43 | @Override
44 | protected TGUsersList getThis() {
45 | return this;
46 | }
47 |
48 | /**
49 | * Get list of connection users
50 | *
51 | * @return List of connection users
52 | */
53 | public List getUsers() {
54 | return users;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/model/TGVisibility.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package com.tapglue.model;
18 |
19 | import android.support.annotation.NonNull;
20 | import android.support.annotation.Nullable;
21 |
22 | public enum TGVisibility {
23 | // TODO document these
24 | Private(10), Connections(20), Public(30), Global(40);
25 |
26 | private final int value;
27 |
28 | @NonNull
29 | public static TGVisibility fromValue(@Nullable Integer valueToFind) {
30 | if (valueToFind == null) {
31 | return Private;
32 | }
33 | for (TGVisibility value : values()) {
34 | if (value.asValue().intValue() == valueToFind.intValue()) {
35 | return value;
36 | }
37 | }
38 | return Private;
39 | }
40 |
41 | TGVisibility(int realValue) {
42 | value = realValue;
43 | }
44 |
45 | public Integer asValue() {
46 | return value;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/model/queries/TGQueryObjectField.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.model.queries;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | class TGQueryObjectField {
23 |
24 | @NonNull
25 | private transient String name = "";
26 |
27 | @NonNull
28 | String getName() {
29 | return name;
30 | }
31 |
32 | TGQueryObjectField setName(@NonNull String name) {
33 | this.name = name;
34 | return this;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/networking/TGCacheRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.networking;
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import com.tapglue.model.TGBaseObject;
23 | import com.tapglue.networking.requests.TGRequestCallback;
24 | import com.tapglue.networking.requests.TGRequestErrorType;
25 | import com.tapglue.networking.requests.TGRequestType;
26 |
27 | class TGCacheRequest {
28 | private static final TGRequestCallback dummyCallback = new TGRequestCallback() {
29 | @Override
30 | public boolean callbackIsEnabled() {
31 | return true;
32 | }
33 |
34 | @Override
35 | public void onRequestError(TGRequestErrorType cause) {
36 |
37 | }
38 |
39 | @Override
40 | public void onRequestFinished(Object output, boolean changeDoneOnline) {
41 |
42 | }
43 | };
44 |
45 | /**
46 | * Request object
47 | */
48 | private final T object;
49 |
50 | /**
51 | * Request type
52 | */
53 | private final TGRequestType type;
54 |
55 | public TGCacheRequest(@NonNull TGRequest req) {
56 | type = req.getRequestType();
57 | object = req.getObject();
58 | }
59 |
60 | /**
61 | * Convert cache request to standard request Those requests will always receive generic
62 | * callback
63 | * method, that is never outdated, but it also won't do any changes in UI due to always
64 | * outdated
65 | * old callbacks
66 | *
67 | * @return Converted Tapglue request
68 | */
69 | @NonNull
70 | public TGRequest toTGRequest() {
71 | return new TGRequest(object, type, true, dummyCallback);
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/networking/requests/TGRequestCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.networking.requests;
19 |
20 | public interface TGRequestCallback {
21 | /**
22 | * Information if request callback is not outdated / is active
23 | */
24 | boolean callbackIsEnabled();
25 |
26 | /**
27 | * Request couldn't be finished At most cases this will happen when no internet connection is
28 | * available, and request would require to be done live
29 | *
30 | * @param cause Cause of error
31 | */
32 | void onRequestError(TGRequestErrorType cause);
33 |
34 | /**
35 | * Request was finished with success
36 | *
37 | * @param output Return object or status object
38 | * @param changeDoneOnline Flag with information if request was done online or just queued in
39 | * cache
40 | */
41 | void onRequestFinished(OBJECT output, boolean changeDoneOnline);
42 | }
43 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/networking/requests/TGRequestType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.networking.requests;
19 |
20 | /**
21 | * Request types supported by factory
22 | */
23 | public enum TGRequestType {
24 | CREATE, READ, UPDATE, DELETE, LOGIN, LOGOUT, SEARCH
25 | }
26 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/main/java/com/tapglue/utils/TGLog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue.utils;
19 |
20 | import android.support.annotation.NonNull;
21 | import android.util.Log;
22 |
23 | public class TGLog {
24 |
25 | private static final String LOG_TAG = "Tapglue";
26 |
27 | /**
28 | * Should logger do its work?
29 | */
30 | private boolean isEnabled = false;
31 |
32 | public TGLog(boolean enabled) {
33 | isEnabled = enabled;
34 | }
35 |
36 | /**
37 | * Log information
38 | *
39 | * @param what What should be logged
40 | */
41 | public void log(String what) {
42 | if (!isEnabled) { return; }
43 | Log.d(LOG_TAG, what);
44 | }
45 |
46 | /**
47 | * Log error
48 | *
49 | * @param t Throwable to log
50 | */
51 | public void logE(@NonNull Throwable t) {
52 | if (!isEnabled) { return; }
53 | Log.e(LOG_TAG, t.getMessage());
54 | t.printStackTrace();
55 | }
56 |
57 | /**
58 | * Log warning
59 | *
60 | * @param what What should be logged
61 | */
62 | public void logW(String what) {
63 | Log.w(LOG_TAG, what);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/v1/tapglue-android-sdk/tapglue-android-sdk/src/test/java/com/tapglue/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-2016 Tapglue (https://www.tapglue.com/). All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.tapglue;
19 |
20 | import org.junit.Test;
21 |
22 | import static org.junit.Assert.assertEquals;
23 |
24 | /**
25 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
26 | */
27 | public class ExampleUnitTest {
28 | @Test
29 | public void addition_isCorrect() throws Exception {
30 | assertEquals(4, 2 + 2);
31 | }
32 | }
--------------------------------------------------------------------------------