├── .gitignore
├── .idea
├── .name
├── codeStyleSettings.xml
├── copyright
│ ├── OPF.xml
│ └── profiles_settings.xml
├── dictionaries
│ └── rzhilich.xml
├── findbugs-idea.xml
└── inspectionProfiles
│ ├── OPF.xml
│ └── profiles_settings.xml
├── LICENSE
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── opfiab-providers
├── amazon
│ ├── .gitignore
│ ├── README.md
│ ├── build.gradle
│ ├── gradle.properties
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── org
│ │ └── onepf
│ │ └── opfiab
│ │ └── amazon
│ │ ├── AmazonBillingHelper.java
│ │ ├── AmazonBillingProvider.java
│ │ ├── AmazonUtils.java
│ │ └── model
│ │ ├── AmazonModel.java
│ │ ├── AmazonPurchase.java
│ │ └── AmazonSkuDetails.java
├── google
│ ├── .gitignore
│ ├── README.md
│ ├── build.gradle
│ ├── gradle.properties
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── aidl
│ │ └── com
│ │ │ └── android
│ │ │ └── vending
│ │ │ └── billing
│ │ │ └── IInAppBillingService.aidl
│ │ └── java
│ │ └── org
│ │ └── onepf
│ │ └── opfiab
│ │ └── google
│ │ ├── GoogleBillingHelper.java
│ │ ├── GoogleBillingProvider.java
│ │ ├── GoogleMapSkuResolver.java
│ │ ├── GoogleSkuResolver.java
│ │ ├── GoogleUtils.java
│ │ ├── Response.java
│ │ ├── SimpleGooglePurchaseVerifier.java
│ │ └── model
│ │ ├── GoogleModel.java
│ │ ├── GooglePurchase.java
│ │ ├── GoogleSkuDetails.java
│ │ ├── ItemType.java
│ │ └── PurchaseState.java
├── openstore
│ ├── .gitignore
│ ├── build.gradle
│ ├── gradle.properties
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── aidl
│ │ └── org
│ │ │ └── onepf
│ │ │ └── oms
│ │ │ ├── IOpenAppstore.aidl
│ │ │ └── IOpenInAppBillingService.aidl
│ │ └── java
│ │ └── org
│ │ └── onepf
│ │ └── opfiab
│ │ └── openstore
│ │ ├── ApplandBillingProvider.java
│ │ ├── AptoideBillingProvider.java
│ │ ├── OpenStoreBillingHelper.java
│ │ ├── OpenStoreBillingProvider.java
│ │ ├── OpenStoreIntentMaker.java
│ │ ├── OpenStoreUtils.java
│ │ ├── Response.java
│ │ ├── SlideMEBillingProvider.java
│ │ ├── YandexBillingProvider.java
│ │ └── model
│ │ ├── ItemType.java
│ │ ├── OpenBillingModel.java
│ │ ├── OpenPurchase.java
│ │ ├── OpenSkuDetails.java
│ │ └── PurchaseState.java
└── samsung
│ ├── .gitignore
│ ├── README.md
│ ├── build.gradle
│ ├── gradle.properties
│ ├── proguard-rules.pro
│ └── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── aidl
│ └── com
│ │ └── sec
│ │ └── android
│ │ └── iap
│ │ ├── IAPConnector.aidl
│ │ └── IAPServiceCallback.aidl
│ └── java
│ └── org
│ └── onepf
│ └── opfiab
│ └── samsung
│ ├── BillingMode.java
│ ├── Response.java
│ ├── SamsungBillingHelper.java
│ ├── SamsungBillingProvider.java
│ ├── SamsungMapSkuResolver.java
│ ├── SamsungPurchaseVerifier.java
│ ├── SamsungSkuResolver.java
│ ├── SamsungUtils.java
│ └── model
│ ├── ItemType.java
│ ├── SamsungBillingModel.java
│ ├── SamsungModel.java
│ ├── SamsungPurchase.java
│ ├── SamsungPurchasedItem.java
│ ├── SamsungSkuDetails.java
│ └── SamsungVerification.java
├── opfiab
├── .gitignore
├── build.gradle
├── gradle.properties
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── org
│ └── onepf
│ └── opfiab
│ ├── ActivityIabHelperImpl.java
│ ├── ActivityMonitor.java
│ ├── AdvancedIabHelperImpl.java
│ ├── BillingBase.java
│ ├── BillingEventDispatcher.java
│ ├── BillingRequestScheduler.java
│ ├── ComponentIabHelper.java
│ ├── FragmentIabHelperImpl.java
│ ├── IabHelperImpl.java
│ ├── OPFIab.java
│ ├── SetupManager.java
│ ├── SimpleIabHelperImpl.java
│ ├── android
│ ├── OPFIabActivity.java
│ ├── OPFIabFragment.java
│ └── OPFIabSupportFragment.java
│ ├── api
│ ├── ActivityIabHelper.java
│ ├── ActivityResultSupport.java
│ ├── AdvancedIabHelper.java
│ ├── FragmentIabHelper.java
│ ├── IabHelper.java
│ ├── ListenersSupport.java
│ └── SimpleIabHelper.java
│ ├── billing
│ ├── AidlBillingHelper.java
│ ├── BaseBillingProvider.java
│ ├── BaseBillingProviderBuilder.java
│ ├── BillingProvider.java
│ └── Compatibility.java
│ ├── listener
│ ├── BillingListener.java
│ ├── BillingListenerCompositor.java
│ ├── DefaultBillingListener.java
│ ├── OnConsumeListener.java
│ ├── OnInventoryListener.java
│ ├── OnPurchaseListener.java
│ ├── OnSetupListener.java
│ ├── OnSkuDetailsListener.java
│ └── SimpleBillingListener.java
│ ├── model
│ ├── ComponentState.java
│ ├── Configuration.java
│ ├── JsonCompatible.java
│ ├── JsonModel.java
│ ├── billing
│ │ ├── BillingModel.java
│ │ ├── Purchase.java
│ │ ├── SignedPurchase.java
│ │ ├── SkuDetails.java
│ │ └── SkuType.java
│ └── event
│ │ ├── ActivityResultRequest.java
│ │ ├── RequestHandledEvent.java
│ │ ├── SetupResponse.java
│ │ ├── SetupStartedEvent.java
│ │ ├── android
│ │ ├── ActivityEvent.java
│ │ ├── ActivityLifecycleEvent.java
│ │ ├── ActivityNewIntentEvent.java
│ │ ├── ActivityResult.java
│ │ ├── FragmentLifecycleEvent.java
│ │ ├── LifecycleEvent.java
│ │ └── SupportFragmentLifecycleEvent.java
│ │ └── billing
│ │ ├── BillingEvent.java
│ │ ├── BillingEventType.java
│ │ ├── BillingRequest.java
│ │ ├── BillingResponse.java
│ │ ├── ConsumeRequest.java
│ │ ├── ConsumeResponse.java
│ │ ├── InventoryRequest.java
│ │ ├── InventoryResponse.java
│ │ ├── PurchaseRequest.java
│ │ ├── PurchaseResponse.java
│ │ ├── SkuDetailsRequest.java
│ │ ├── SkuDetailsResponse.java
│ │ └── Status.java
│ ├── sku
│ ├── MapSkuResolver.java
│ ├── SkuResolver.java
│ ├── TypedMapSkuResolver.java
│ └── TypedSkuResolver.java
│ ├── util
│ ├── ActivityForResultLauncher.java
│ ├── BillingUtils.java
│ ├── OPFIabUtils.java
│ └── SyncedReference.java
│ └── verification
│ ├── PublicKeyPurchaseVerifier.java
│ ├── PurchaseVerifier.java
│ ├── SimplePublicKeyPurchaseVerifier.java
│ └── VerificationResult.java
├── samples
└── trivialdrive
│ ├── .gitignore
│ ├── README.md
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ ├── androidTest
│ └── java
│ │ └── org
│ │ └── onepf
│ │ └── trivialdrive
│ │ └── LaunchTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── org
│ │ └── onepf
│ │ └── trivialdrive
│ │ ├── Helper.java
│ │ ├── OnProviderPickerListener.java
│ │ ├── Provider.java
│ │ ├── TrivialApplication.java
│ │ ├── TrivialBilling.java
│ │ ├── TrivialBillingListener.java
│ │ ├── TrivialData.java
│ │ └── ui
│ │ ├── activity
│ │ ├── ActivityHelperActivity.java
│ │ ├── AdvancedHelperActivity.java
│ │ ├── FragmentHelperActivity.java
│ │ ├── LauncherActivity.java
│ │ └── TrivialActivity.java
│ │ ├── fragment
│ │ ├── ProviderPickerDialogFragment.java
│ │ └── TrivialFragment.java
│ │ └── view
│ │ ├── AdvancedTrivialView.java
│ │ ├── SkuDetailsView.java
│ │ └── TrivialView.java
│ └── res
│ ├── drawable-hdpi
│ ├── ic_add.png
│ ├── ic_check_off.png
│ ├── ic_check_on.png
│ ├── img_car.png
│ ├── img_car_premium.png
│ ├── img_gas_0.png
│ ├── img_gas_1.png
│ ├── img_gas_2.png
│ ├── img_gas_3.png
│ ├── img_gas_4.png
│ └── img_gas_inf.png
│ ├── drawable-xhdpi
│ ├── btn_buy_gas_default.png
│ ├── btn_buy_premium.png
│ ├── btn_buy_subscription.png
│ ├── btn_drive.png
│ ├── ic_action_delete.png
│ └── ic_action_swap.png
│ ├── drawable
│ ├── btn_buy_gas.xml
│ ├── btn_buy_gas_disabled.xml
│ ├── img_gas_level.xml
│ └── tv_check.xml
│ ├── layout-land
│ ├── include_trivial_info.xml
│ └── view_trivial.xml
│ ├── layout
│ ├── activity_trivial.xml
│ ├── include_content.xml
│ ├── include_trivial.xml
│ ├── include_trivial_advanced.xml
│ ├── include_trivial_billing.xml
│ ├── include_trivial_info.xml
│ ├── item_drawer.xml
│ ├── item_drawer_footer.xml
│ ├── item_drawer_header.xml
│ ├── view_sku_details.xml
│ └── view_trivial.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
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── settings.gradle
└── test
└── opfiab-uitest
├── .gitignore
├── build.gradle
├── lint.xml
├── proguard-rules.pro
└── src
├── androidTest
└── java
│ └── org
│ └── onepf
│ └── opfiab
│ └── opfiab_uitest
│ ├── manager
│ ├── BillingManagerAdapter.java
│ ├── TestManager.java
│ └── TestManagerAdapter.java
│ ├── tests
│ ├── ActivityHelperTest.java
│ ├── AdvancedHelperTest.java
│ ├── SimpleHelperTest.java
│ └── ui
│ │ ├── ActivityHelperOnViewTest.java
│ │ ├── ActivityHelperTest.java
│ │ ├── FragmentHelperTest.java
│ │ ├── SupportFragmentHelperTest.java
│ │ └── UnifiedFragmentHelperTest.java
│ └── util
│ ├── AbortableCountDownLatch.java
│ ├── Constants.java
│ ├── MockBillingProviderBuilder.java
│ ├── TestBillingListener.java
│ ├── fragments
│ ├── SupportTestFragment.java
│ └── TestFragment.java
│ └── validators
│ ├── AlwaysFailValidator.java
│ ├── ConsumeResponseValidator.java
│ ├── EventValidator.java
│ ├── InventoryResponseValidator.java
│ ├── PurchaseRequestValidator.java
│ ├── PurchaseResponseValidator.java
│ ├── SetupResponseValidator.java
│ ├── SetupStartedEventValidator.java
│ ├── SkuDetailsResponseValidator.java
│ └── TypedEventValidator.java
└── main
├── AndroidManifest.xml
├── java
└── org
│ └── onepf
│ └── opfiab
│ └── opfiab_uitest
│ ├── ActivityHelperActivity.java
│ ├── EmptyActivity.java
│ ├── EmptyFragmentActivity.java
│ └── mock
│ ├── MockBillingProvider.java
│ ├── MockFailBillingProvider.java
│ └── MockOkBillingProvider.java
└── res
├── layout
├── activity_empty.xml
├── activity_main.xml
└── fragment_empty.xml
├── mipmap-hdpi
└── ic_launcher.png
├── mipmap-mdpi
└── ic_launcher.png
├── mipmap-xhdpi
└── ic_launcher.png
├── mipmap-xxhdpi
└── ic_launcher.png
├── values-w820dp
└── dimens.xml
└── values
├── colors.xml
├── dimens.xml
├── strings.xml
└── styles.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Android template
2 | # Built application files
3 | *.apk
4 | *.ap_
5 |
6 | # Files for the Dalvik VM
7 | *.dex
8 |
9 | # Java class files
10 | *.class
11 |
12 | # Generated files
13 | bin/
14 | gen/
15 |
16 | # Gradle files
17 | .gradle/
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 | ### JetBrains template
30 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
31 |
32 | ## Directory-based project format
33 | *.iml
34 | .idea/workspace.xml
35 | .idea/misc.xml
36 | .idea/tasks.xml
37 | .idea/libraries
38 | .idea/scopes
39 | .idea/compiler.xml
40 | .idea/encodings.xml
41 | .idea/vcs.xml
42 | # .idea/dictionaries
43 | # and these sensitive or high-churn files:
44 | .idea/dataSources.ids
45 | .idea/dataSources.xml
46 | .idea/sqlDataSources.xml
47 | .idea/dynamic.xml
48 | # and, if using gradle::
49 | .idea/gradle.xml
50 | .idea/modules.xml
51 |
52 |
53 | ## File-based project format
54 | *.ipr
55 | *.iws
56 |
57 | ## Additional for IntelliJ
58 | out/
59 |
60 | # generated by mpeltonen/sbt-idea plugin
61 | .idea_modules/
62 |
63 | # generated by JIRA plugin
64 | atlassian-ide-plugin.xml
65 |
66 | # generated by Crashlytics plugin (for Android Studio and Intellij)
67 | com_crashlytics_export_strings.xml
68 |
69 | # Apple crap
70 | .DS_Store
71 | .AppleDouble
72 | .LSOverride
73 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | OPFIab
--------------------------------------------------------------------------------
/.idea/copyright/OPF.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/dictionaries/rzhilich.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | acem
5 | appland
6 | aptoide
7 | asyc
8 | checkstyle
9 | fortumo
10 | inapp
11 | infos
12 | onepf
13 | opfiab
14 | packageless
15 | samsung
16 | samsungapps
17 | sdktestclient
18 | serialversionid
19 | trivialdrive
20 | umac
21 | unbox
22 | uncallable
23 | unregistrer
24 | unregistring
25 | unsubscribe
26 | unsubscribed
27 | unsubscriber
28 | venezia
29 | yandex
30 |
31 |
32 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 | task wrapper(type: Wrapper) {
18 | gradleVersion '2.2.1'
19 | }
20 |
21 | buildscript {
22 | repositories {
23 | jcenter()
24 | }
25 |
26 | dependencies {
27 | classpath 'com.android.tools.build:gradle:1.2.3'
28 | classpath 'com.noveogroup.android:check:1.1.2'
29 | classpath 'net.ltgt.gradle:gradle-errorprone-plugin:latest.release'
30 | classpath 'com.kageiit:url-cache-plugin:1.0.0'
31 | }
32 | }
33 |
34 | allprojects {
35 | apply plugin: 'com.kageiit.url-cache'
36 |
37 | repositories {
38 | jcenter()
39 | }
40 |
41 | ext {
42 | compileSdkVersion = 22
43 | buildToolsVersion = "22.0.1"
44 | }
45 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2012-2015 One Platform Foundation
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 | # Project-wide Gradle settings.
18 |
19 | # IDE (e.g. Android Studio) users:
20 | # Gradle settings configured through the IDE *will override*
21 | # any settings specified in this file.
22 |
23 | # For more details on how to configure your build environment visit
24 | # http://www.gradle.org/docs/current/userguide/build_environment.html
25 |
26 | # The Gradle daemon aims to improve the startup and execution time of Gradle.
27 | # When set to true the Gradle daemon is to run the build.
28 | # TODO: disable daemon on CI, since builds should be clean and reliable on servers
29 | org.gradle.daemon=true
30 |
31 | # Specifies the JVM arguments used for the daemon process.
32 | # The setting is particularly useful for tweaking memory settings.
33 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
34 | org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
35 |
36 | # When configured, Gradle will run in incubating parallel mode.
37 | # This option should only be used with decoupled projects. More details, visit
38 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
39 | #org.gradle.parallel=true
40 |
41 | POM_URL = https://github.com/onepf/OPFIab
42 | POM_SCM_URL = https://github.com/onepf/OPFIab
43 | POM_SCM_CONNECTION = scm:git@github.com:onepf/OPFIab.git
44 | POM_SCM_DEV_CONNECTION = scm:git@github.com:onepf/OPFIab.git
45 |
46 | SNAPSHOT_REPOSITORY_URL = https://oss.sonatype.org/content/repositories/snapshots/
47 | RELEASE_REPOSITORY_URL = https://oss.sonatype.org/service/local/staging/deploy/maven2/
48 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2012-2015 One Platform Foundation
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 | #Thu Nov 27 00:30:16 MSK 2014
18 | distributionBase=GRADLE_USER_HOME
19 | distributionPath=wrapper/dists
20 | zipStoreBase=GRADLE_USER_HOME
21 | zipStorePath=wrapper/dists
22 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
23 |
--------------------------------------------------------------------------------
/opfiab-providers/amazon/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/opfiab-providers/amazon/README.md:
--------------------------------------------------------------------------------
1 | [Documentation](https://github.com/onepf/OPFIab/wiki/Amazon)
2 |
--------------------------------------------------------------------------------
/opfiab-providers/amazon/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 | apply plugin: 'idea'
18 | apply plugin: 'com.android.library'
19 | apply from: urlCache.get('https://raw.githubusercontent.com/onepf/OPF-mvn-repo/master/opf-commons.gradle')
20 |
21 | android {
22 | defaultConfig {
23 | minSdkVersion 15
24 | targetSdkVersion 22
25 | versionCode 1
26 | versionName "0.4.0"
27 | }
28 | }
29 |
30 | dependencies {
31 | compile 'org.onepf:opfiab:0.4.0@aar'
32 | provided 'org.onepf:opfutils:0.1.23'
33 | provided 'com.amazon:in-app-purchasing:2.0.61'
34 | }
35 |
--------------------------------------------------------------------------------
/opfiab-providers/amazon/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2012-2015 One Platform Foundation
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 | POM_ARTIFACT_ID = opfiab-amazon
18 | POM_NAME = OPFIab Amazon module
19 | POM_DESCRIPTION = Adds Amazon billing provider
--------------------------------------------------------------------------------
/opfiab-providers/amazon/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 /opt/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 |
--------------------------------------------------------------------------------
/opfiab-providers/amazon/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
22 |
23 |
24 |
25 |
26 |
30 |
31 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/opfiab-providers/amazon/src/main/java/org/onepf/opfiab/amazon/model/AmazonModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.amazon.model;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.json.JSONException;
22 | import org.onepf.opfiab.model.JsonModel;
23 |
24 | abstract class AmazonModel extends JsonModel {
25 |
26 | private static final String NAME_SKU = "sku";
27 |
28 | @NonNull
29 | protected final String sku;
30 |
31 | public AmazonModel(@NonNull final String originalJson) throws JSONException {
32 | super(originalJson);
33 | this.sku = jsonObject.getString(NAME_SKU);
34 | }
35 |
36 | @NonNull
37 | public abstract String getSku();
38 | }
39 |
--------------------------------------------------------------------------------
/opfiab-providers/google/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/opfiab-providers/google/README.md:
--------------------------------------------------------------------------------
1 | [Documentation](https://github.com/onepf/OPFIab/wiki/Google)
2 |
--------------------------------------------------------------------------------
/opfiab-providers/google/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 | apply plugin: 'idea'
18 | apply plugin: 'com.android.library'
19 | apply from: urlCache.get('https://raw.githubusercontent.com/onepf/OPF-mvn-repo/master/opf-commons.gradle')
20 |
21 | android {
22 | defaultConfig {
23 | minSdkVersion 15
24 | targetSdkVersion 22
25 | versionCode 1
26 | versionName "0.4.0"
27 | }
28 | }
29 |
30 | dependencies {
31 | compile 'org.onepf:opfiab:0.4.0@aar'
32 | provided 'org.onepf:opfutils:0.1.23'
33 | }
34 |
--------------------------------------------------------------------------------
/opfiab-providers/google/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2012-2015 One Platform Foundation
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 | POM_ARTIFACT_ID = opfiab-google
18 | POM_NAME = OPFIab Google module
19 | POM_DESCRIPTION = Adds Google billing provider
--------------------------------------------------------------------------------
/opfiab-providers/google/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 /opt/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 |
--------------------------------------------------------------------------------
/opfiab-providers/google/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/opfiab-providers/google/src/main/java/org/onepf/opfiab/google/GoogleSkuResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.google;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.onepf.opfiab.model.billing.SkuType;
22 | import org.onepf.opfiab.sku.SkuResolver;
23 |
24 | /**
25 | * This Google specific {@link SkuResolver} must be used with {@link GoogleBillingProvider} since
26 | * it's necessary to be able to resolve SKU type.
27 | */
28 | public interface GoogleSkuResolver extends SkuResolver {
29 |
30 | /**
31 | * Resolves type of supplied SKU. SKU should not yet be resolved.
32 | *
33 | * @param sku SKU to resolve type for.
34 | *
35 | * @return SKU type, can't be null.
36 | */
37 | @NonNull
38 | SkuType resolveType(@NonNull final String sku);
39 | }
40 |
--------------------------------------------------------------------------------
/opfiab-providers/google/src/main/java/org/onepf/opfiab/google/Response.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.google;
18 |
19 | import android.support.annotation.Nullable;
20 |
21 | /**
22 | * All possible responses from Google service.
23 | */
24 | enum Response {
25 |
26 | OK(0),
27 | USER_CANCELED(1),
28 | SERVICE_UNAVAILABLE(2),
29 | BILLING_UNAVAILABLE(3),
30 | ITEM_UNAVAILABLE(4),
31 | DEVELOPER_ERROR(5),
32 | ERROR(6),
33 | ITEM_ALREADY_OWNED(7),
34 | ITEM_NOT_OWNED(8);
35 |
36 | @Nullable
37 | static Response fromCode(final int code) {
38 | for (final Response response : values()) {
39 | if (response.code == code) {
40 | return response;
41 | }
42 | }
43 | return null;
44 | }
45 |
46 |
47 | private final int code;
48 |
49 | Response(final int code) {
50 | this.code = code;
51 | }
52 |
53 | public int code() {
54 | return code;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/opfiab-providers/google/src/main/java/org/onepf/opfiab/google/SimpleGooglePurchaseVerifier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.google;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.onepf.opfiab.verification.PublicKeyPurchaseVerifier;
22 |
23 | /**
24 | * Simple implementation of {@link PublicKeyPurchaseVerifier} that stores public key in insecure way.
25 | *
26 | * It's strongly recommended to make your own implementation that doesn't store key as a plain
27 | * string.
28 | */
29 | public class SimpleGooglePurchaseVerifier extends PublicKeyPurchaseVerifier {
30 |
31 | @NonNull
32 | private final String publicKey;
33 |
34 | public SimpleGooglePurchaseVerifier(@NonNull final String publicKey) {
35 | super();
36 | this.publicKey = publicKey;
37 | }
38 |
39 | @NonNull
40 | @Override
41 | protected String getPublicKey() {
42 | return publicKey;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/opfiab-providers/google/src/main/java/org/onepf/opfiab/google/model/GoogleModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.google.model;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.json.JSONException;
22 | import org.onepf.opfiab.model.JsonModel;
23 |
24 | /**
25 | * Parent of a few Google billing model classes.
26 | */
27 | public class GoogleModel extends JsonModel {
28 |
29 | private static final String NAME_PRODUCT_ID = "productId";
30 |
31 |
32 | @NonNull
33 | private final String productId;
34 |
35 | protected GoogleModel(@NonNull final String originalJson) throws JSONException {
36 | super(originalJson);
37 | this.productId = jsonObject.getString(NAME_PRODUCT_ID);
38 | }
39 |
40 | /**
41 | * Gets item's product identifier. Every item has a product ID which you must specify in the
42 | * application's product list in the Google Play Developer Console.
43 | *
44 | * @return Unique product ID, can't be null.
45 | */
46 | @NonNull
47 | public String getProductId() {
48 | return productId;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/opfiab-providers/google/src/main/java/org/onepf/opfiab/google/model/PurchaseState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.google.model;
18 |
19 | import android.support.annotation.Nullable;
20 |
21 | public enum PurchaseState {
22 |
23 | PURCHASED(0),
24 | CANCELED(1),
25 | REFUNDED(2);
26 |
27 | /**
28 | * Gets purchase state from code.
29 | *
30 | * @param code Code to convert.
31 | *
32 | * @return Purchase state if code is recognized, null otherwise.
33 | */
34 | @Nullable
35 | public static PurchaseState fromCode(final int code) {
36 | for (final PurchaseState purchaseState : values()) {
37 | if (purchaseState.code == code) {
38 | return purchaseState;
39 | }
40 | }
41 | return null;
42 | }
43 |
44 |
45 | private final int code;
46 |
47 | PurchaseState(final int code) {
48 | this.code = code;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/opfiab-providers/openstore/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/opfiab-providers/openstore/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 | apply plugin: 'idea'
18 | apply plugin: 'com.android.library'
19 | apply from: urlCache.get('https://raw.githubusercontent.com/onepf/OPF-mvn-repo/gradle-commons/opf-commons.gradle')
20 |
21 | android {
22 | defaultConfig {
23 | minSdkVersion 15
24 | targetSdkVersion 22
25 | versionCode 1
26 | versionName "0.4.0"
27 | }
28 | }
29 |
30 | dependencies {
31 | compile 'org.onepf:opfiab:0.4.0@aar'
32 | provided 'org.onepf:opfutils:0.1.23'
33 | }
34 |
--------------------------------------------------------------------------------
/opfiab-providers/openstore/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2012-2015 One Platform Foundation
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 | POM_ARTIFACT_ID = opfiab-openstore
18 | POM_NAME = OPFIab Openstore module
19 | POM_DESCRIPTION = Adds support for openstores
--------------------------------------------------------------------------------
/opfiab-providers/openstore/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 /usr/local/Cellar/android-sdk/24.2/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 |
--------------------------------------------------------------------------------
/opfiab-providers/openstore/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/opfiab-providers/openstore/src/main/aidl/org/onepf/oms/IOpenAppstore.aidl:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2013 One Platform Foundation
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 org.onepf.oms;
17 |
18 | import android.content.Intent;
19 |
20 | /**
21 | * Service interface to implement by OpenStore implementation
22 | *
23 | * @author Boris Minaev, Oleg Orlov
24 | * @since 29.04.2013
25 | */
26 | interface IOpenAppstore {
27 |
28 | /**
29 | * Every OpenStore implementation must provide their name. It's required for core OpenIAB functions
30 | */
31 | String getAppstoreName();
32 |
33 | /**
34 | * OpenStores must provide information about packages it installed. If OpenStore is installer
35 | * and supports In-App billing it will be used for purchases
36 | */
37 | boolean isPackageInstaller(String packageName);
38 |
39 | /**
40 | * If true OpenIAB assumes In-App items (SKU) for app are published and ready to use
41 | */
42 | boolean isBillingAvailable(String packageName);
43 |
44 | /**
45 | * Provides android:versionCode of .apk published in OpenStore
46 | * @return -1 if UNDEFINED
47 | */
48 | int getPackageVersion(String packageName);
49 |
50 | /**
51 | * Should provide Intent to be used for binding IOpenInAppBillingService
52 | */
53 | Intent getBillingServiceIntent();
54 |
55 | Intent getProductPageIntent(String packageName);
56 |
57 | Intent getRateItPageIntent(String packageName);
58 |
59 | Intent getSameDeveloperPageIntent(String packageName);
60 |
61 | boolean areOutsideLinksAllowed();
62 | }
63 |
--------------------------------------------------------------------------------
/opfiab-providers/openstore/src/main/java/org/onepf/opfiab/openstore/ApplandBillingProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.openstore;
18 |
19 | import android.content.Context;
20 | import android.support.annotation.NonNull;
21 | import android.support.annotation.Nullable;
22 |
23 | import org.onepf.opfiab.billing.BaseBillingProvider;
24 | import org.onepf.opfiab.sku.TypedSkuResolver;
25 | import org.onepf.opfiab.verification.PurchaseVerifier;
26 |
27 | public class ApplandBillingProvider extends OpenStoreBillingProvider {
28 |
29 | public static final String NAME = "APPLAND";
30 | protected static final String[] PACKAGES = new String[]{"se.appland.market.android"};
31 |
32 |
33 | public ApplandBillingProvider(@NonNull final Context context,
34 | @NonNull final TypedSkuResolver skuResolver,
35 | @NonNull final PurchaseVerifier purchaseVerifier,
36 | @Nullable final OpenStoreIntentMaker intentMaker) {
37 | super(context, skuResolver, purchaseVerifier, intentMaker);
38 | }
39 |
40 | public static class Builder extends OpenStoreBuilder {
41 |
42 | public Builder(@NonNull final Context context) {
43 | super(context);
44 | setIntentMaker(OpenStoreUtils.getIntentMaker(NAME, PACKAGES));
45 | }
46 |
47 | @Override
48 | public BaseBillingProvider build() {
49 | if (skuResolver == null) {
50 | throw new IllegalStateException();
51 | }
52 | return new ApplandBillingProvider(context, skuResolver,
53 | purchaseVerifier == null ? PurchaseVerifier.DEFAULT : purchaseVerifier,
54 | intentMaker);
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/opfiab-providers/openstore/src/main/java/org/onepf/opfiab/openstore/AptoideBillingProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.openstore;
18 |
19 | import android.content.Context;
20 | import android.support.annotation.NonNull;
21 | import android.support.annotation.Nullable;
22 |
23 | import org.onepf.opfiab.billing.BaseBillingProvider;
24 | import org.onepf.opfiab.sku.TypedSkuResolver;
25 | import org.onepf.opfiab.verification.PurchaseVerifier;
26 |
27 | public class AptoideBillingProvider extends OpenStoreBillingProvider {
28 |
29 | public static final String NAME = "APTOIDE";
30 | protected static final String[] PACKAGES = new String[]{"cm.aptoide.pt"};
31 |
32 |
33 | public AptoideBillingProvider(@NonNull final Context context,
34 | @NonNull final TypedSkuResolver skuResolver,
35 | @NonNull final PurchaseVerifier purchaseVerifier,
36 | @Nullable final OpenStoreIntentMaker intentMaker) {
37 | super(context, skuResolver, purchaseVerifier, intentMaker);
38 | }
39 |
40 | public static class Builder extends OpenStoreBillingProvider.OpenStoreBuilder {
41 |
42 | public Builder(@NonNull final Context context) {
43 | super(context);
44 | setIntentMaker(OpenStoreUtils.getIntentMaker(NAME, PACKAGES));
45 | }
46 |
47 | @Override
48 | public BaseBillingProvider build() {
49 | if (skuResolver == null) {
50 | throw new IllegalStateException();
51 | }
52 | return new AptoideBillingProvider(context, skuResolver,
53 | purchaseVerifier == null ? PurchaseVerifier.DEFAULT : purchaseVerifier,
54 | intentMaker);
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/opfiab-providers/openstore/src/main/java/org/onepf/opfiab/openstore/OpenStoreIntentMaker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.openstore;
18 |
19 | import android.content.Context;
20 | import android.content.Intent;
21 | import android.support.annotation.NonNull;
22 | import android.support.annotation.Nullable;
23 |
24 | import org.onepf.oms.IOpenAppstore;
25 |
26 | public interface OpenStoreIntentMaker {
27 |
28 | @Nullable
29 | Intent makeIntent(@NonNull final Context context);
30 |
31 | /**
32 | * Returns string that should uniquely identify OpenStore.
33 | *
34 | * Please note that it can differ from name returned by {@link IOpenAppstore#getAppstoreName()}.
35 | *
36 | * @return OpenStore name. Can't be null.
37 | */
38 | @NonNull
39 | String getProviderName();
40 | }
41 |
--------------------------------------------------------------------------------
/opfiab-providers/openstore/src/main/java/org/onepf/opfiab/openstore/Response.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.openstore;
18 |
19 | import android.support.annotation.Nullable;
20 |
21 | public enum Response {
22 |
23 | OK(0),
24 | USER_CANCELED(1),
25 | SERVICE_UNAVAILABLE(2),
26 | BILLING_UNAVAILABLE(3),
27 | ITEM_UNAVAILABLE(4),
28 | DEVELOPER_ERROR(5),
29 | ERROR(6),
30 | ITEM_ALREADY_OWNED(7),
31 | ITEM_NOT_OWNED(8);
32 |
33 | @Nullable
34 | static Response fromCode(final int code) {
35 | for (final Response response : values()) {
36 | if (response.code == code) {
37 | return response;
38 | }
39 | }
40 | return null;
41 | }
42 |
43 |
44 | private final int code;
45 |
46 | Response(final int code) {
47 | this.code = code;
48 | }
49 |
50 | public int code() {
51 | return code;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/opfiab-providers/openstore/src/main/java/org/onepf/opfiab/openstore/SlideMEBillingProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.openstore;
18 |
19 | import android.content.Context;
20 | import android.support.annotation.NonNull;
21 | import android.support.annotation.Nullable;
22 |
23 | import org.onepf.opfiab.billing.BaseBillingProvider;
24 | import org.onepf.opfiab.sku.TypedSkuResolver;
25 | import org.onepf.opfiab.verification.PurchaseVerifier;
26 |
27 | public class SlideMEBillingProvider extends OpenStoreBillingProvider {
28 |
29 | public static final String NAME = "SlideME";
30 | protected static final String[] PACKAGES = new String[]{"com.slideme.sam.manager"};
31 |
32 |
33 | public SlideMEBillingProvider(@NonNull final Context context,
34 | @NonNull final TypedSkuResolver skuResolver,
35 | @NonNull final PurchaseVerifier purchaseVerifier,
36 | @Nullable final OpenStoreIntentMaker intentMaker) {
37 | super(context, skuResolver, purchaseVerifier, intentMaker);
38 | }
39 |
40 | public static class Builder extends OpenStoreBuilder {
41 |
42 | public Builder(@NonNull final Context context) {
43 | super(context);
44 | setIntentMaker(OpenStoreUtils.getIntentMaker(NAME, PACKAGES));
45 | }
46 |
47 | @Override
48 | public BaseBillingProvider build() {
49 | if (skuResolver == null) {
50 | throw new IllegalStateException();
51 | }
52 | return new SlideMEBillingProvider(context, skuResolver,
53 | purchaseVerifier == null ? PurchaseVerifier.DEFAULT : purchaseVerifier,
54 | intentMaker);
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/opfiab-providers/openstore/src/main/java/org/onepf/opfiab/openstore/YandexBillingProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.openstore;
18 |
19 | import android.content.Context;
20 | import android.support.annotation.NonNull;
21 | import android.support.annotation.Nullable;
22 |
23 | import org.onepf.opfiab.sku.TypedSkuResolver;
24 | import org.onepf.opfiab.verification.PurchaseVerifier;
25 |
26 | public class YandexBillingProvider extends OpenStoreBillingProvider {
27 |
28 | public static final String NAME = "Yandex";
29 | protected static final String[] PACKAGES = new String[]{"com.yandex.store"};
30 |
31 |
32 | public YandexBillingProvider(@NonNull final Context context,
33 | @NonNull final TypedSkuResolver skuResolver,
34 | @NonNull final PurchaseVerifier purchaseVerifier,
35 | @Nullable final OpenStoreIntentMaker intentMaker) {
36 | super(context, skuResolver, purchaseVerifier, intentMaker);
37 | }
38 |
39 |
40 | public static class Builder extends OpenStoreBillingProvider.OpenStoreBuilder {
41 |
42 | public Builder(@NonNull final Context context) {
43 | super(context);
44 | setIntentMaker(OpenStoreUtils.getIntentMaker(NAME, PACKAGES));
45 | }
46 |
47 | @Override
48 | public YandexBillingProvider build() {
49 | if (skuResolver == null) {
50 | throw new IllegalStateException();
51 | }
52 | return new YandexBillingProvider(context, skuResolver,
53 | purchaseVerifier == null ? PurchaseVerifier.DEFAULT : purchaseVerifier,
54 | intentMaker);
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/opfiab-providers/openstore/src/main/java/org/onepf/opfiab/openstore/model/OpenBillingModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.openstore.model;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.json.JSONException;
22 | import org.onepf.opfiab.model.JsonModel;
23 |
24 | public class OpenBillingModel extends JsonModel {
25 |
26 | private static final String NAME_PRODUCT_ID = "productId";
27 |
28 |
29 | @NonNull
30 | private final String productId;
31 |
32 | protected OpenBillingModel(@NonNull final String originalJson) throws JSONException {
33 | super(originalJson);
34 | this.productId = jsonObject.getString(NAME_PRODUCT_ID);
35 | }
36 |
37 | /**
38 | * @return Unique product ID, can't be null.
39 | */
40 | @NonNull
41 | public String getProductId() {
42 | return productId;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/opfiab-providers/openstore/src/main/java/org/onepf/opfiab/openstore/model/PurchaseState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.openstore.model;
18 |
19 | import android.support.annotation.Nullable;
20 |
21 | public enum PurchaseState {
22 |
23 | PURCHASED(0),
24 | CANCELED(1),
25 | REFUNDED(2);
26 |
27 | /**
28 | * Gets purchase state from code.
29 | *
30 | * @param code Code to convert.
31 | *
32 | * @return Purchase state if code is recognized, null otherwise.
33 | */
34 | @Nullable
35 | public static PurchaseState fromCode(final int code) {
36 | for (final PurchaseState purchaseState : values()) {
37 | if (purchaseState.code == code) {
38 | return purchaseState;
39 | }
40 | }
41 | return null;
42 | }
43 |
44 |
45 | private final int code;
46 |
47 | PurchaseState(final int code) {
48 | this.code = code;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/opfiab-providers/samsung/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/opfiab-providers/samsung/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/opfiab-providers/samsung/README.md
--------------------------------------------------------------------------------
/opfiab-providers/samsung/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 | apply plugin: 'idea'
18 | apply plugin: 'com.android.library'
19 | apply from: urlCache.get('https://raw.githubusercontent.com/onepf/OPF-mvn-repo/master/opf-commons.gradle')
20 |
21 | android {
22 | defaultConfig {
23 | minSdkVersion 15
24 | targetSdkVersion 22
25 | versionCode 1
26 | versionName "0.4.0"
27 | }
28 | }
29 |
30 | dependencies {
31 | compile 'org.onepf:opfiab:0.4.0@aar'
32 | provided 'org.onepf:opfutils:0.1.23'
33 | }
34 |
--------------------------------------------------------------------------------
/opfiab-providers/samsung/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2012-2015 One Platform Foundation
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 | POM_ARTIFACT_ID = opfiab-samsung
18 | POM_NAME = OPFIab Samsung module
19 | POM_DESCRIPTION = Adds Samsung billing provider
--------------------------------------------------------------------------------
/opfiab-providers/samsung/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 /opt/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 |
--------------------------------------------------------------------------------
/opfiab-providers/samsung/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/opfiab-providers/samsung/src/main/aidl/com/sec/android/iap/IAPConnector.aidl:
--------------------------------------------------------------------------------
1 | package com.sec.android.iap;
2 |
3 | import com.sec.android.iap.IAPServiceCallback;
4 |
5 | interface IAPConnector {
6 |
7 | boolean requestCmd(IAPServiceCallback callback, in Bundle bundle);
8 |
9 | boolean unregisterCallback(IAPServiceCallback callback);
10 |
11 | Bundle init(int mode);
12 |
13 | Bundle getItemList(int mode, String packageName, String itemGroupId, int startNum, int endNum, String itemType);
14 |
15 | Bundle getItemsInbox(String packageName, String itemGroupId, int startNum, int endNum, String startDate, String endDate);
16 | }
--------------------------------------------------------------------------------
/opfiab-providers/samsung/src/main/aidl/com/sec/android/iap/IAPServiceCallback.aidl:
--------------------------------------------------------------------------------
1 | package com.sec.android.iap;
2 |
3 | import android.os.Bundle;
4 |
5 | interface IAPServiceCallback {
6 | oneway void responseCallback(in Bundle bundle);
7 | }
--------------------------------------------------------------------------------
/opfiab-providers/samsung/src/main/java/org/onepf/opfiab/samsung/BillingMode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.samsung;
18 |
19 | public enum BillingMode {
20 |
21 | TEST_SUCCESS(1),
22 | TEST_FAIL(-1),
23 | PRODUCTION(0);
24 |
25 | private final int code;
26 |
27 | BillingMode(final int code) {
28 | this.code = code;
29 | }
30 |
31 | public int getCode() {
32 | return code;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/opfiab-providers/samsung/src/main/java/org/onepf/opfiab/samsung/Response.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.samsung;
18 |
19 | import android.support.annotation.Nullable;
20 |
21 | @SuppressWarnings("MagicNumber")
22 | enum Response {
23 |
24 | ERROR_NONE(0),
25 | PAYMENT_IS_CANCELED(1),
26 | ERROR_INITIALIZATION(-1000),
27 | ERROR_NEED_APP_UPGRADE(-1001),
28 | ERROR_COMMON(-1002),
29 | ERROR_ALREADY_PURCHASED(-1003),
30 | ERROR_WHILE_RUNNING(-1004),
31 | ERROR_PRODUCT_DOES_NOT_EXIST(-1005),
32 | ERROR_CONFIRM_INBOX(-1006),
33 | ERROR_ITEM_GROUP_ID_DOES_NOT_EXIST(-1007),
34 | ERROR_NETWORK_NOT_AVAILABLE(-1008),
35 | ERROR_IOEXCEPTION_ERROR(-1009),
36 | ERROR_SOCKET_TIMEOUT(-1010),
37 | ERROR_CONNECT_TIMEOUT(-1011);
38 |
39 | @Nullable
40 | public static Response fromCode(final int code) {
41 | for (final Response response : values()) {
42 | if (response.code == code) {
43 | return response;
44 | }
45 | }
46 | return null;
47 | }
48 |
49 |
50 | private final int code;
51 |
52 | Response(final int code) {
53 | this.code = code;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/opfiab-providers/samsung/src/main/java/org/onepf/opfiab/samsung/SamsungMapSkuResolver.java:
--------------------------------------------------------------------------------
1 | package org.onepf.opfiab.samsung;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import org.onepf.opfiab.sku.TypedMapSkuResolver;
6 |
7 | public class SamsungMapSkuResolver extends TypedMapSkuResolver implements SamsungSkuResolver {
8 |
9 | @NonNull
10 | private final String groupId;
11 |
12 | public SamsungMapSkuResolver(@NonNull final String groupId) {
13 | super();
14 | this.groupId = groupId;
15 | }
16 |
17 | @NonNull
18 | @Override
19 | public String getGroupId() {
20 | return groupId;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/opfiab-providers/samsung/src/main/java/org/onepf/opfiab/samsung/SamsungSkuResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.samsung;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.onepf.opfiab.sku.TypedSkuResolver;
22 |
23 | public interface SamsungSkuResolver extends TypedSkuResolver {
24 |
25 | @NonNull
26 | String getGroupId();
27 | }
28 |
--------------------------------------------------------------------------------
/opfiab-providers/samsung/src/main/java/org/onepf/opfiab/samsung/model/ItemType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.samsung.model;
18 |
19 | import android.support.annotation.NonNull;
20 | import android.support.annotation.Nullable;
21 |
22 | import org.onepf.opfiab.model.billing.SkuType;
23 |
24 | public enum ItemType {
25 |
26 | CONSUMABLE("00"),
27 | NON_CONSUMABLE("01"),
28 | SUBSCRIPTION("02"),
29 | ALL("10");
30 |
31 | @Nullable
32 | public static ItemType fromCode(@NonNull final String code) {
33 | for (final ItemType itemType : values()) {
34 | if (itemType.code.equals(code)) {
35 | return itemType;
36 | }
37 | }
38 | return null;
39 | }
40 |
41 | @NonNull
42 | public static ItemType fromSkuType(@NonNull final SkuType type) {
43 | switch (type) {
44 | case CONSUMABLE:
45 | return CONSUMABLE;
46 | case ENTITLEMENT:
47 | return NON_CONSUMABLE;
48 | case SUBSCRIPTION:
49 | return SUBSCRIPTION;
50 | default:
51 | throw new IllegalArgumentException("Can't convert SkyType: " + type);
52 | }
53 |
54 | }
55 |
56 | @NonNull
57 | private final String code;
58 |
59 | ItemType(@NonNull final String code) {
60 | this.code = code;
61 | }
62 |
63 | @NonNull
64 | public String getCode() {
65 | return code;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/opfiab-providers/samsung/src/main/java/org/onepf/opfiab/samsung/model/SamsungBillingModel.java:
--------------------------------------------------------------------------------
1 | package org.onepf.opfiab.samsung.model;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import org.json.JSONException;
6 | import org.onepf.opfiab.samsung.SamsungUtils;
7 |
8 | import java.util.Date;
9 |
10 | abstract class SamsungBillingModel extends SamsungModel {
11 |
12 | private static final String KEY_PURCHASE_ID = "mPurchaseId";
13 | private static final String KEY_PAYMENT_ID = "mPaymentId";
14 | private static final String KEY_PURCHASE_DATE = "mPurchaseDate";
15 |
16 | @NonNull
17 | private final String purchaseId;
18 | @NonNull
19 | private final String paymentId;
20 | @NonNull
21 | private final Date purchaseDate;
22 |
23 | public SamsungBillingModel(@NonNull final String originalJson) throws JSONException {
24 | super(originalJson);
25 | this.purchaseId = jsonObject.getString(KEY_PURCHASE_ID);
26 | this.paymentId = jsonObject.getString(KEY_PAYMENT_ID);
27 |
28 | final String dateString = jsonObject.getString(KEY_PURCHASE_DATE);
29 | final Date date = SamsungUtils.parseDate(dateString);
30 | if (date == null) {
31 | throw new JSONException("Invalid purchase date: " + dateString);
32 | }
33 | this.purchaseDate = date;
34 | }
35 |
36 | @NonNull
37 | public String getPurchaseId() {
38 | return purchaseId;
39 | }
40 |
41 | @NonNull
42 | public String getPaymentId() {
43 | return paymentId;
44 | }
45 |
46 | @NonNull
47 | public Date getPurchaseDate() {
48 | return purchaseDate;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/opfiab-providers/samsung/src/main/java/org/onepf/opfiab/samsung/model/SamsungPurchase.java:
--------------------------------------------------------------------------------
1 | package org.onepf.opfiab.samsung.model;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import org.json.JSONException;
6 |
7 | /**
8 | * Model representing purchased item returned in user inventory.
9 | */
10 | public class SamsungPurchase extends SamsungBillingModel {
11 |
12 | private static final String KEY_VERIFY_URL = "mVerifyUrl";
13 |
14 |
15 | @NonNull
16 | private final String verifyUrl;
17 |
18 | public SamsungPurchase(@NonNull final String originalJson) throws JSONException {
19 | super(originalJson);
20 | this.verifyUrl = jsonObject.getString(KEY_VERIFY_URL);
21 | }
22 |
23 | @NonNull
24 | public String getVerifyUrl() {
25 | return verifyUrl;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/opfiab-providers/samsung/src/main/java/org/onepf/opfiab/samsung/model/SamsungPurchasedItem.java:
--------------------------------------------------------------------------------
1 | package org.onepf.opfiab.samsung.model;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.annotation.Nullable;
5 |
6 | import org.json.JSONException;
7 | import org.onepf.opfiab.samsung.SamsungUtils;
8 |
9 | import java.util.Date;
10 |
11 | public class SamsungPurchasedItem extends SamsungBillingModel {
12 |
13 | private static final String KEY_SUBSCRIPTION_END_DATE = "mSubscriptionEndDate";
14 |
15 |
16 | @NonNull
17 | private final ItemType itemType;
18 | @Nullable
19 | private final Date subscriptionEndDate;
20 |
21 | public SamsungPurchasedItem(@NonNull final String originalJson) throws JSONException {
22 | super(originalJson);
23 | this.itemType = SamsungUtils.getItemType(jsonObject);
24 |
25 | final String dateString = jsonObject.optString(KEY_SUBSCRIPTION_END_DATE);
26 | this.subscriptionEndDate = SamsungUtils.parseDate(dateString);
27 | }
28 |
29 | @NonNull
30 | public ItemType getItemType() {
31 | return itemType;
32 | }
33 |
34 | @Nullable
35 | public Date getSubscriptionEndDate() {
36 | return subscriptionEndDate;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/opfiab-providers/samsung/src/main/java/org/onepf/opfiab/samsung/model/SamsungSkuDetails.java:
--------------------------------------------------------------------------------
1 | package org.onepf.opfiab.samsung.model;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import org.json.JSONException;
6 | import org.onepf.opfiab.samsung.SamsungUtils;
7 |
8 | public class SamsungSkuDetails extends SamsungModel {
9 |
10 | private static final String KEY_SUBSCRIPTION_UNIT = "mSubscriptionDurationUnit";
11 | private static final String KEY_SUBSCRIPTION_MULTIPLIER = "mSubscriptionDurationMultiplier";
12 |
13 |
14 | @NonNull
15 | private final ItemType itemType;
16 | @NonNull
17 | private final String subscriptionUnit;
18 | @NonNull
19 | private final String subscriptionMultiplier;
20 |
21 | public SamsungSkuDetails(@NonNull final String originalJson) throws JSONException {
22 | super(originalJson);
23 | this.subscriptionUnit = jsonObject.getString(KEY_SUBSCRIPTION_UNIT);
24 | this.subscriptionMultiplier = jsonObject.getString(KEY_SUBSCRIPTION_MULTIPLIER);
25 | this.itemType = SamsungUtils.getItemType(jsonObject);
26 | }
27 |
28 | @NonNull
29 | public ItemType getItemType() {
30 | return itemType;
31 | }
32 |
33 | @NonNull
34 | public String getSubscriptionUnit() {
35 | return subscriptionUnit;
36 | }
37 |
38 | @NonNull
39 | public String getSubscriptionMultiplier() {
40 | return subscriptionMultiplier;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/opfiab/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/opfiab/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 | buildscript {
18 | repositories {
19 | jcenter()
20 | }
21 |
22 | dependencies {
23 | classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
24 | }
25 | }
26 |
27 | apply plugin: 'android-sdk-manager'
28 | apply plugin: 'idea'
29 | apply plugin: 'com.android.library'
30 | apply from: urlCache.get('https://raw.githubusercontent.com/onepf/OPF-mvn-repo/master/opf-commons.gradle')
31 |
32 | android {
33 | defaultConfig {
34 | minSdkVersion 15
35 | targetSdkVersion 22
36 | versionCode 1
37 | versionName "0.4.0"
38 | }
39 | }
40 |
41 | dependencies {
42 | compile 'com.android.support:support-annotations:22.2.0'
43 | provided 'de.greenrobot:eventbus:2.4.0'
44 | provided 'org.onepf:opfutils:0.1.23'
45 | //noinspection GradleDependency,GradleCompatible
46 | provided 'com.android.support:support-v4:13.0.0'
47 | }
48 |
--------------------------------------------------------------------------------
/opfiab/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2012-2015 One Platform Foundation
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 | POM_ARTIFACT_ID = opfiab
18 | POM_NAME = OPFIab Library
19 | POM_DESCRIPTION = In-App Billing Library for Android
--------------------------------------------------------------------------------
/opfiab/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 /opt/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 |
--------------------------------------------------------------------------------
/opfiab/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
20 |
21 |
22 |
23 |
24 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/api/ActivityIabHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.api;
18 |
19 | import android.app.Activity;
20 |
21 | /**
22 | * Version of {@link IabHelper} designed to be used from {@link Activity}.
23 | *
24 | * Supports all {@link AdvancedIabHelper} features.
25 | */
26 | public interface ActivityIabHelper extends IabHelper, ActivityResultSupport, ListenersSupport { }
27 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/api/ActivityResultSupport.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.api;
18 |
19 | import android.app.Activity;
20 | import android.content.Intent;
21 | import android.support.annotation.NonNull;
22 | import android.support.annotation.Nullable;
23 |
24 | interface ActivityResultSupport {
25 |
26 | /**
27 | * Notifies library about received activity result.
28 | *
29 | * Intended to be called from {@link Activity} used for
30 | * {@link SimpleIabHelper#purchase(Activity, String)}.
31 | *
32 | * @param activity Activity object which received
33 | * {@link Activity#onActivityResult(int, int, Intent)} call.
34 | */
35 | void onActivityResult(@NonNull final Activity activity, final int requestCode,
36 | final int resultCode, @Nullable final Intent data);
37 | }
38 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/api/FragmentIabHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.api;
18 |
19 | import android.app.Fragment;
20 |
21 | /**
22 | * Version of {@link IabHelper} designed to be used from {@link Fragment}.
23 | *
24 | * Supports all {@link AdvancedIabHelper} features.
25 | */
26 | public interface FragmentIabHelper extends IabHelper, ListenersSupport { }
27 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/billing/Compatibility.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.billing;
18 |
19 | public enum Compatibility {
20 |
21 | COMPATIBLE,
22 | INCOMPATIBLE,
23 | PREFERRED,
24 | }
25 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/listener/BillingListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.listener;
18 |
19 |
20 | import android.support.annotation.NonNull;
21 |
22 | import org.onepf.opfiab.billing.BillingProvider;
23 | import org.onepf.opfiab.model.event.billing.BillingRequest;
24 | import org.onepf.opfiab.model.event.billing.BillingResponse;
25 |
26 | /**
27 | * Listener for all library events.
28 | */
29 | public interface BillingListener
30 | extends OnSetupListener, OnPurchaseListener, OnConsumeListener, OnInventoryListener,
31 | OnSkuDetailsListener {
32 |
33 | /**
34 | * Called on every {@link BillingRequest} handled by library.
35 | *
36 | * @param billingRequest Request being handled.
37 | */
38 | void onRequest(@NonNull final BillingRequest billingRequest);
39 |
40 | /**
41 | * Called on every {@link BillingResponse} sent by {@link BillingProvider}.
42 | *
43 | * @param billingResponse Response being send.
44 | */
45 | void onResponse(@NonNull final BillingResponse billingResponse);
46 | }
47 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/listener/OnConsumeListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.listener;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.onepf.opfiab.billing.BillingProvider;
22 | import org.onepf.opfiab.model.event.billing.BillingResponse;
23 | import org.onepf.opfiab.model.event.billing.ConsumeResponse;
24 |
25 | /**
26 | * Listener for consume billing events.
27 | */
28 | public interface OnConsumeListener {
29 |
30 | /**
31 | * Called every time ConsumeResponse is sent by current {@link BillingProvider}.
32 | *
33 | * @param consumeResponse {@link BillingResponse} object sent by BillingProvider.
34 | */
35 | void onConsume(@NonNull final ConsumeResponse consumeResponse);
36 | }
37 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/listener/OnInventoryListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.listener;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.onepf.opfiab.billing.BillingProvider;
22 | import org.onepf.opfiab.model.event.billing.BillingResponse;
23 | import org.onepf.opfiab.model.event.billing.InventoryResponse;
24 |
25 | /**
26 | * Listener for inventory billing events.
27 | */
28 | public interface OnInventoryListener {
29 |
30 | /**
31 | * Called every time InventoryResponse is sent by current {@link BillingProvider}.
32 | *
33 | * @param inventoryResponse {@link BillingResponse} object sent by BillingProvider.
34 | */
35 | void onInventory(@NonNull final InventoryResponse inventoryResponse);
36 | }
37 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/listener/OnPurchaseListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.listener;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.onepf.opfiab.billing.BillingProvider;
22 | import org.onepf.opfiab.model.event.billing.BillingResponse;
23 | import org.onepf.opfiab.model.event.billing.PurchaseResponse;
24 |
25 | /**
26 | * Listener for purchase billing events.
27 | */
28 | public interface OnPurchaseListener {
29 |
30 | /**
31 | * Called every time PurchaseResponse is sent by current {@link BillingProvider}.
32 | *
33 | * @param purchaseResponse {@link BillingResponse} object sent by BillingProvider.
34 | */
35 | void onPurchase(@NonNull final PurchaseResponse purchaseResponse);
36 | }
37 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/listener/OnSetupListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.listener;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.onepf.opfiab.model.event.SetupResponse;
22 | import org.onepf.opfiab.model.event.SetupStartedEvent;
23 |
24 | /**
25 | * Listener for library setup event.
26 | */
27 | public interface OnSetupListener {
28 |
29 | /**
30 | * Called when library is being set up.
31 | *
32 | * @param setupStartedEvent Setup event sent by library.
33 | */
34 | void onSetupStarted(@NonNull final SetupStartedEvent setupStartedEvent);
35 |
36 | /**
37 | * Called when library setup is finished.
38 | *
39 | * @param setupResponse Setup event sent by library.
40 | */
41 | void onSetupResponse(@NonNull final SetupResponse setupResponse);
42 | }
43 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/listener/OnSkuDetailsListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.listener;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.onepf.opfiab.billing.BillingProvider;
22 | import org.onepf.opfiab.model.event.billing.BillingResponse;
23 | import org.onepf.opfiab.model.event.billing.SkuDetailsResponse;
24 |
25 | /**
26 | * Listener for SKU details billing events.
27 | */
28 | public interface OnSkuDetailsListener {
29 |
30 | /**
31 | * Called every time SkuDetailsResponse is sent by current {@link BillingProvider}.
32 | *
33 | * @param skuDetailsResponse {@link BillingResponse} object sent by BillingProvider.
34 | */
35 | void onSkuDetails(@NonNull final SkuDetailsResponse skuDetailsResponse);
36 | }
37 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/listener/SimpleBillingListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.listener;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.onepf.opfiab.model.event.SetupResponse;
22 | import org.onepf.opfiab.model.event.SetupStartedEvent;
23 | import org.onepf.opfiab.model.event.billing.BillingRequest;
24 | import org.onepf.opfiab.model.event.billing.BillingResponse;
25 | import org.onepf.opfiab.model.event.billing.ConsumeResponse;
26 | import org.onepf.opfiab.model.event.billing.InventoryResponse;
27 | import org.onepf.opfiab.model.event.billing.PurchaseResponse;
28 | import org.onepf.opfiab.model.event.billing.SkuDetailsResponse;
29 |
30 | /**
31 | * Stub implementation of {@link BillingListener} interface.
32 | */
33 | @SuppressWarnings("PMD.UncommentedEmptyMethod")
34 | public class SimpleBillingListener implements BillingListener {
35 |
36 | @Override
37 | public void onSetupStarted(@NonNull final SetupStartedEvent setupStartedEvent) { }
38 |
39 | @Override
40 | public void onSetupResponse(@NonNull final SetupResponse setupResponse) { }
41 |
42 | @Override
43 | public void onRequest(@NonNull final BillingRequest billingRequest) { }
44 |
45 | @Override
46 | public void onResponse(@NonNull final BillingResponse billingResponse) { }
47 |
48 | @Override
49 | public void onConsume(@NonNull final ConsumeResponse consumeResponse) { }
50 |
51 | @Override
52 | public void onPurchase(@NonNull final PurchaseResponse purchaseResponse) { }
53 |
54 | @Override
55 | public void onInventory(@NonNull final InventoryResponse inventoryResponse) { }
56 |
57 | @Override
58 | public void onSkuDetails(@NonNull final SkuDetailsResponse skuDetailsResponse) { }
59 | }
60 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/model/ComponentState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.model;
18 |
19 | /**
20 | * Android component state.
21 | *
22 | * Intended for internal use.
23 | */
24 | public enum ComponentState {
25 | ATTACH,
26 | CREATE,
27 | CREATE_VIEW,
28 | START,
29 | RESUME,
30 | PAUSE,
31 | STOP,
32 | DESTROY_VIEW,
33 | DESTROY,
34 | DETACH,
35 | }
36 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/model/JsonCompatible.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.model;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.json.JSONObject;
22 |
23 | public interface JsonCompatible {
24 |
25 | /**
26 | * Gets JSON representation of this object data.
27 | *
28 | * @return JSON object, can't be null.
29 | */
30 | @NonNull
31 | JSONObject toJson();
32 | }
33 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/model/billing/SkuType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.model.billing;
18 |
19 | /**
20 | * SKU type represented by {@link BillingModel}.
21 | */
22 | public enum SkuType {
23 |
24 | CONSUMABLE,
25 | ENTITLEMENT,
26 | SUBSCRIPTION,
27 | UNKNOWN,
28 | }
29 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/model/event/ActivityResultRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.model.event;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.onepf.opfiab.model.event.android.ActivityResult;
22 | import org.onepf.opfiab.model.event.billing.BillingRequest;
23 | import org.onepf.opfiab.util.ActivityForResultLauncher;
24 | import org.onepf.opfiab.util.SyncedReference;
25 |
26 | public final class ActivityResultRequest {
27 |
28 | @NonNull
29 | private final BillingRequest request;
30 | @NonNull
31 | private final ActivityForResultLauncher launcher;
32 | @NonNull
33 | private final SyncedReference syncActivityResult;
34 |
35 | public ActivityResultRequest(@NonNull final BillingRequest request,
36 | @NonNull final ActivityForResultLauncher launcher,
37 | @NonNull final SyncedReference syncActivityResult) {
38 | this.request = request;
39 | this.launcher = launcher;
40 | this.syncActivityResult = syncActivityResult;
41 | }
42 |
43 | @NonNull
44 | public BillingRequest getRequest() {
45 | return request;
46 | }
47 |
48 | @NonNull
49 | public ActivityForResultLauncher getLauncher() {
50 | return launcher;
51 | }
52 |
53 | @NonNull
54 | public SyncedReference getSyncActivityResult() {
55 | return syncActivityResult;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/model/event/RequestHandledEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.model.event;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.onepf.opfiab.billing.BillingProvider;
22 | import org.onepf.opfiab.model.event.billing.BillingRequest;
23 |
24 | /**
25 | * Class intended to indicate that {@link BillingProvider} finished handling {@link BillingRequest}.
26 | *
27 | * Intended for internal usage.
28 | *
29 | * @see BillingProvider#onBillingRequest(BillingRequest)
30 | */
31 | public class RequestHandledEvent {
32 |
33 | @NonNull
34 | private final BillingRequest billingRequest;
35 |
36 | public RequestHandledEvent(@NonNull final BillingRequest billingRequest) {
37 | this.billingRequest = billingRequest;
38 | }
39 |
40 | /**
41 | * Gets request that was handled by {@link BillingProvider}.
42 | *
43 | * @return BillingRequest object.
44 | */
45 | @NonNull
46 | public BillingRequest getBillingRequest() {
47 | return billingRequest;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/model/event/SetupStartedEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.model.event;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.onepf.opfiab.OPFIab;
22 | import org.onepf.opfiab.model.Configuration;
23 |
24 | /**
25 | * Class intended to indicate that setup process was started.
26 | *
27 | * @see OPFIab#setup()
28 | */
29 | public class SetupStartedEvent {
30 |
31 | @NonNull
32 | private final Configuration configuration;
33 |
34 | public SetupStartedEvent(@NonNull final Configuration configuration) {
35 | this.configuration = configuration;
36 | }
37 |
38 | /**
39 | * Gets configuration used for the setup.
40 | *
41 | * @return Configuration object.
42 | */
43 | @NonNull
44 | public Configuration getConfiguration() {
45 | return configuration;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/model/event/android/ActivityEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.model.event.android;
18 |
19 | import android.app.Activity;
20 | import android.support.annotation.NonNull;
21 |
22 | /**
23 | * Parent class for any activity related events.
24 | */
25 | class ActivityEvent {
26 |
27 | @NonNull
28 | protected final Activity activity;
29 |
30 | protected ActivityEvent(@NonNull final Activity activity) {
31 | this.activity = activity;
32 | }
33 |
34 | /**
35 | * Gets activity associated with this event.
36 | *
37 | * @return Activity object, can't be null.
38 | */
39 | @NonNull
40 | public Activity getActivity() {
41 | return activity;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/model/event/android/ActivityLifecycleEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.model.event.android;
18 |
19 | import android.app.Activity;
20 | import android.support.annotation.NonNull;
21 |
22 | import org.onepf.opfiab.model.ComponentState;
23 |
24 | import java.util.Arrays;
25 |
26 | import static org.onepf.opfiab.model.ComponentState.CREATE;
27 | import static org.onepf.opfiab.model.ComponentState.DESTROY;
28 | import static org.onepf.opfiab.model.ComponentState.PAUSE;
29 | import static org.onepf.opfiab.model.ComponentState.RESUME;
30 | import static org.onepf.opfiab.model.ComponentState.START;
31 | import static org.onepf.opfiab.model.ComponentState.STOP;
32 |
33 | /**
34 | * Event indicating {@link Activity} lifecycle state change.
35 | */
36 | public class ActivityLifecycleEvent extends LifecycleEvent {
37 |
38 | @NonNull
39 | private final Activity activity;
40 |
41 | public ActivityLifecycleEvent(@NonNull final ComponentState type,
42 | @NonNull final Activity activity) {
43 | super(type);
44 | if (!Arrays.asList(CREATE, START, RESUME, PAUSE, STOP, DESTROY).contains(type)) {
45 | throw new IllegalArgumentException("Illegal lifecycle callback for Activity");
46 | }
47 | this.activity = activity;
48 | }
49 |
50 | /**
51 | * Gets activity associated with this event.
52 | *
53 | * @return Activity object, can't be null.
54 | */
55 | @NonNull
56 | public Activity getActivity() {
57 | return activity;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/model/event/android/ActivityNewIntentEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.model.event.android;
18 |
19 | import android.app.Activity;
20 | import android.content.Intent;
21 | import android.support.annotation.NonNull;
22 |
23 | /**
24 | * Event indicating {@link Activity#onNewIntent(Intent)} call.
25 | */
26 | public class ActivityNewIntentEvent extends ActivityEvent {
27 |
28 | @NonNull
29 | private final Intent intent;
30 |
31 | public ActivityNewIntentEvent(@NonNull final Activity activity,
32 | @NonNull final Intent intent) {
33 | super(activity);
34 | this.intent = intent;
35 | }
36 |
37 | /**
38 | * Gets intent associated with this event.
39 | *
40 | * @return Intent object, can't be null.
41 | */
42 | @NonNull
43 | public Intent getIntent() {
44 | return intent;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/model/event/android/FragmentLifecycleEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.model.event.android;
18 |
19 | import android.app.Fragment;
20 | import android.support.annotation.NonNull;
21 |
22 | import org.onepf.opfiab.model.ComponentState;
23 |
24 | /**
25 | * Event that indicates {@link Fragment} lifecycle state change.
26 | */
27 | public class FragmentLifecycleEvent extends LifecycleEvent {
28 |
29 | @NonNull
30 | private final Fragment fragment;
31 |
32 | public FragmentLifecycleEvent(@NonNull final ComponentState type,
33 | @NonNull final Fragment fragment) {
34 | super(type);
35 | this.fragment = fragment;
36 | }
37 |
38 | /**
39 | * Gets fragment associated with this event.
40 | *
41 | * @return Fragment object, can't be null.
42 | */
43 | @NonNull
44 | public Fragment getFragment() {
45 | return fragment;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/model/event/android/LifecycleEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.model.event.android;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.onepf.opfiab.model.ComponentState;
22 |
23 | /**
24 | * Event that indicates an android component lifecycle state change.
25 | */
26 | public abstract class LifecycleEvent {
27 |
28 | @NonNull
29 | private final ComponentState type;
30 |
31 | public LifecycleEvent(@NonNull final ComponentState type) {
32 | this.type = type;
33 | }
34 |
35 | /**
36 | * Gets lifecycle type associated with this event.
37 | *
38 | * @return Lifecycle type, can't be null.
39 | */
40 | @NonNull
41 | public ComponentState getType() {
42 | return type;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/model/event/android/SupportFragmentLifecycleEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.model.event.android;
18 |
19 | import android.support.annotation.NonNull;
20 | import android.support.v4.app.Fragment;
21 |
22 | import org.onepf.opfiab.model.ComponentState;
23 |
24 | /**
25 | * Event that indicates {@link Fragment} lifecycle state change.
26 | */
27 | public class SupportFragmentLifecycleEvent extends LifecycleEvent {
28 |
29 | @NonNull
30 | private final Fragment fragment;
31 |
32 | public SupportFragmentLifecycleEvent(
33 | @NonNull final ComponentState type, @NonNull final Fragment fragment) {
34 | super(type);
35 | this.fragment = fragment;
36 | }
37 |
38 | /**
39 | * Gets support fragment associated with this event.
40 | *
41 | * @return SupportFragment object, can't be null.
42 | */
43 | @NonNull
44 | public Fragment getFragment() {
45 | return fragment;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/model/event/billing/BillingEventType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.model.event.billing;
18 |
19 | /**
20 | * Type of billing event.
21 | */
22 | public enum BillingEventType {
23 |
24 | CONSUME,
25 | PURCHASE,
26 | SKU_DETAILS,
27 | INVENTORY,
28 | }
29 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/model/event/billing/ConsumeResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.model.event.billing;
18 |
19 | import android.support.annotation.NonNull;
20 | import android.support.annotation.Nullable;
21 |
22 | import org.json.JSONException;
23 | import org.json.JSONObject;
24 | import org.onepf.opfiab.billing.BillingProvider;
25 | import org.onepf.opfiab.model.billing.Purchase;
26 | import org.onepf.opfutils.OPFLog;
27 |
28 | /**
29 | * Response from {@link BillingProvider} for corresponding {@link ConsumeRequest}.
30 | */
31 | public class ConsumeResponse extends BillingResponse {
32 |
33 | private static final String NAME_PURCHASE = "purchase";
34 |
35 | @NonNull
36 | private final Purchase purchase;
37 |
38 | public ConsumeResponse(@NonNull final Status status,
39 | @Nullable final String providerName,
40 | @NonNull final Purchase purchase) {
41 | super(BillingEventType.CONSUME, status, providerName);
42 | this.purchase = purchase;
43 | }
44 |
45 | /**
46 | * Gets Purchase intended for consumption.
47 | *
48 | * @return Purchase object. Can't be null.
49 | */
50 | @NonNull
51 | public Purchase getPurchase() {
52 | return purchase;
53 | }
54 |
55 | @NonNull
56 | @Override
57 | public JSONObject toJson() {
58 | final JSONObject jsonObject = super.toJson();
59 | try {
60 | jsonObject.put(NAME_PURCHASE, purchase.toJson());
61 | } catch (JSONException exception) {
62 | OPFLog.e("", exception);
63 | }
64 | return jsonObject;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/model/event/billing/Status.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.model.event.billing;
18 |
19 | import org.onepf.opfiab.api.IabHelper;
20 | import org.onepf.opfiab.billing.BillingProvider;
21 | import org.onepf.opfiab.model.billing.Purchase;
22 |
23 | public enum Status {
24 |
25 | /**
26 | * Everything is OK.
27 | */
28 | SUCCESS,
29 | /**
30 | * Request was handled successfully, but takes considerable time to process.
31 | */
32 | PENDING,
33 | /**
34 | * {@link BillingProvider} requires authorization.
35 | */
36 | UNAUTHORISED,
37 | /**
38 | * Library is busy with another request.
39 | */
40 | BUSY,
41 | /**
42 | * User canceled billing request.
43 | */
44 | USER_CANCELED,
45 | /**
46 | * {@link BillingProvider} reported that it can't handle billing.
47 | */
48 | BILLING_UNAVAILABLE,
49 | /**
50 | * Library has no working billing provider.
51 | */
52 | NO_BILLING_PROVIDER,
53 | /**
54 | * Request can't be handled at a time.
55 | *
56 | * Most likely - connection went down.
57 | */
58 | SERVICE_UNAVAILABLE,
59 | /**
60 | * Requested sku is unavailable from current {@link BillingProvider}.
61 | */
62 | ITEM_UNAVAILABLE,
63 | /**
64 | * Item is already owned by user.
65 | *
66 | * If it's {@link org.onepf.opfiab.model.billing.SkuType#CONSUMABLE} - purchase must be consumed
67 | * using {@link IabHelper#consume(Purchase)}.
68 | */
69 | ITEM_ALREADY_OWNED,
70 | /**
71 | * For some reason {@link BillingProvider} refused to handle request.
72 | */
73 | UNKNOWN_ERROR,
74 | }
75 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/sku/MapSkuResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.sku;
18 |
19 | import android.support.annotation.NonNull;
20 | import android.text.TextUtils;
21 |
22 | import java.util.HashMap;
23 | import java.util.Map;
24 |
25 |
26 | /**
27 | * Simple map-based implementation of {@link SkuResolver} interface.
28 | */
29 | public class MapSkuResolver implements SkuResolver {
30 |
31 | protected final Map direct = new HashMap<>();
32 | protected final Map reverse = new HashMap<>();
33 |
34 | public MapSkuResolver() {
35 | super();
36 | }
37 |
38 | /**
39 | * Adds SKU mapping.
40 | *
41 | * @param sku Original SKU value.
42 | * @param resolvedSku SKU value to which original one should be mapped.
43 | */
44 | public void add(@NonNull final String sku, @NonNull final String resolvedSku) {
45 | if (!TextUtils.equals(sku, resolvedSku)) {
46 | direct.put(sku, resolvedSku);
47 | reverse.put(resolvedSku, sku);
48 | }
49 | }
50 |
51 | @NonNull
52 | @Override
53 | public String resolve(@NonNull final String sku) {
54 | return direct.containsKey(sku)
55 | ? direct.get(sku)
56 | : DEFAULT.resolve(sku);
57 | }
58 |
59 | @NonNull
60 | @Override
61 | public String revert(@NonNull final String resolvedSku) {
62 | return reverse.containsKey(resolvedSku)
63 | ? reverse.get(resolvedSku)
64 | : DEFAULT.revert(resolvedSku);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/sku/SkuResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.sku;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.onepf.opfiab.billing.BillingProvider;
22 |
23 | /**
24 | * Interface intended to help resolve {@link BillingProvider} specific SKUs.
25 | */
26 | public interface SkuResolver {
27 |
28 | /**
29 | * Default implementation of {@link SkuResolver}.
30 | *
31 | * Maps all SKUs to themselves.
32 | */
33 | @NonNull
34 | SkuResolver DEFAULT = new SkuResolver() {
35 | @NonNull
36 | @Override
37 | public String resolve(@NonNull final String sku) {
38 | return sku;
39 | }
40 |
41 | @NonNull
42 | @Override
43 | public String revert(@NonNull final String resolvedSku) {
44 | return resolvedSku;
45 | }
46 | };
47 |
48 |
49 | /**
50 | * Gets {@link BillingProvider} specific SKU value.
51 | *
52 | * @param sku SKU to resolve.
53 | * @return Resolved SKU value.
54 | */
55 | @NonNull
56 | String resolve(@NonNull final String sku);
57 |
58 | /**
59 | * Gets original SKU value from {@link BillingProvider} specific one.
60 | *
61 | * @param resolvedSku SKU to revert.
62 | * @return Reverted SKU value.
63 | */
64 | @NonNull
65 | String revert(@NonNull final String resolvedSku);
66 | }
67 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/sku/TypedSkuResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.sku;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.onepf.opfiab.model.billing.SkuType;
22 |
23 | /**
24 | * Resolves {@link SkuType} for supplied SKU.
25 | */
26 | public interface TypedSkuResolver extends SkuResolver {
27 |
28 | /**
29 | * Resolves type of supplied SKU. SKU should not yet be resolved.
30 | *
31 | * @param sku SKU to resolve type for.
32 | *
33 | * @return SKU type, can't be null.
34 | * @see #resolve(String)
35 | */
36 | @NonNull
37 | SkuType resolveType(@NonNull final String sku);
38 | }
39 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/util/ActivityForResultLauncher.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.util;
18 |
19 | import android.app.Activity;
20 | import android.content.IntentSender;
21 | import android.support.annotation.NonNull;
22 |
23 | public abstract class ActivityForResultLauncher {
24 |
25 | private final int requestCode;
26 |
27 | public ActivityForResultLauncher(final int requestCode) {
28 | this.requestCode = requestCode;
29 | }
30 |
31 | public abstract void onStartForResult(@NonNull final Activity activity) throws IntentSender.SendIntentException;
32 |
33 | public int getRequestCode() {
34 | return requestCode;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/util/SyncedReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.util;
18 |
19 | import android.support.annotation.Nullable;
20 |
21 | import org.onepf.opfutils.OPFChecks;
22 | import org.onepf.opfutils.OPFLog;
23 |
24 | import java.util.concurrent.CountDownLatch;
25 | import java.util.concurrent.TimeUnit;
26 |
27 | public class SyncedReference {
28 |
29 | private final CountDownLatch latch = new CountDownLatch(1);
30 | private boolean isSet;
31 |
32 | @Nullable
33 | private volatile E model;
34 |
35 | @SuppressWarnings("PMD.AvoidSynchronizedAtMethodLevel")
36 | public synchronized void set(@Nullable final E model) {
37 | if (isSet) {
38 | OPFLog.logMethod(model);
39 | OPFLog.e("Attempt to re-set SyncedReference value.");
40 | return;
41 | }
42 | this.isSet = true;
43 | this.model = model;
44 | latch.countDown();
45 | }
46 |
47 | @Nullable
48 | public E get(final long timeout) {
49 | OPFChecks.checkThread(false);
50 | try {
51 | latch.await(timeout, TimeUnit.MILLISECONDS);
52 | } catch (InterruptedException exception) {
53 | OPFLog.e("", exception);
54 | }
55 | return model;
56 | }
57 |
58 | @Nullable
59 | public E get() {
60 | OPFChecks.checkThread(false);
61 | try {
62 | latch.await();
63 | } catch (InterruptedException exception) {
64 | OPFLog.e("", exception);
65 | }
66 | return model;
67 | }
68 |
69 | @Nullable
70 | public E getNow() {
71 | return model;
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/verification/PurchaseVerifier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.verification;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.onepf.opfiab.model.billing.Purchase;
22 |
23 | /**
24 | * Interface intended to define purchase verification algorithm.
25 | *
26 | * Verification process is supposed to confirm the fact that user acquired purchase legitimately.
27 | *
28 | * Typically some cryptography checks or external server requests.
29 | */
30 | public interface PurchaseVerifier {
31 |
32 | /**
33 | * Default implementation of {@link PurchaseVerifier} which always return
34 | * {@link VerificationResult#SUCCESS} from {@link #verify(Purchase)} call.
35 | */
36 | @NonNull
37 | PurchaseVerifier DEFAULT = new PurchaseVerifier() {
38 |
39 | @NonNull
40 | @Override
41 | public VerificationResult verify(@NonNull final Purchase purchase) {
42 | return VerificationResult.SUCCESS;
43 | }
44 | };
45 |
46 | /**
47 | * Attempts to verify that purchase is owned by user.
48 | *
49 | * Intended to be called from background thread, because it may perform long time operations.
50 | *
51 | * @param purchase Purchase object to verify.
52 | * @return Verification result.
53 | */
54 | @NonNull
55 | VerificationResult verify(@NonNull final Purchase purchase);
56 | }
57 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/verification/SimplePublicKeyPurchaseVerifier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.verification;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | /**
22 | * Simple implementation of {@link PublicKeyPurchaseVerifier} that stores public key in insecure way.
23 | *
24 | * It's strongly recommended to make your own implementation that doesn't store key as a plain
25 | * string.
26 | */
27 | public class SimplePublicKeyPurchaseVerifier extends PublicKeyPurchaseVerifier {
28 |
29 | @NonNull
30 | private final String publicKey;
31 |
32 | public SimplePublicKeyPurchaseVerifier(@NonNull final String publicKey) {
33 | super();
34 | this.publicKey = publicKey;
35 | }
36 |
37 | @NonNull
38 | @Override
39 | protected String getPublicKey() {
40 | return publicKey;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/opfiab/src/main/java/org/onepf/opfiab/verification/VerificationResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.verification;
18 |
19 | public enum VerificationResult {
20 |
21 | /**
22 | * Purchase is legitimate.
23 | */
24 | SUCCESS,
25 | /**
26 | * Purchase is fake and wasn't acquired legitimately.
27 | */
28 | FAILED,
29 | /**
30 | * There was an error during verification process.
31 | */
32 | ERROR,
33 | }
34 |
--------------------------------------------------------------------------------
/samples/trivialdrive/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/samples/trivialdrive/README.md:
--------------------------------------------------------------------------------
1 | Simple app showcasing OPFIab library usage.
2 |
3 | ### Google Play
4 | * [Install](https://play.google.com/store/apps/details?id=org.onepf.opfiab.trivialdrive)
5 | * Public [Google Group](https://groups.google.com/forum/#!members/opfiab_testers) for testers.
6 |
7 | Google [wiki page](https://github.com/onepf/OPFIab/wiki/Google) for details and testing tips.
8 |
9 | ### Amazon
10 | * [Install](http://www.amazon.com/OPF-Test-Account-OPFIab-Trivial/dp/B00W9TY70E)
11 |
12 | Amazon [wiki page](https://github.com/onepf/OPFIab/wiki/Amazon).
13 |
14 | **Please be carefull, you might actually get charged.**
15 |
--------------------------------------------------------------------------------
/samples/trivialdrive/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 /opt/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 |
19 | -keepclassmembers class ** {
20 | public void onEvent*(**);
21 | }
22 | -keepattributes InnerClasses
23 | -keep class com.android.vending.billing.** {*;}
24 | -keep class com.sec.android.iap.** {*;}
25 | -optimizationpasses 1
26 | -dontwarn com.amazon.**
27 | -keep class com.amazon.** {*;}
28 | -keepattributes *Annotation*
--------------------------------------------------------------------------------
/samples/trivialdrive/src/androidTest/java/org/onepf/trivialdrive/LaunchTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.trivialdrive;
18 |
19 | import android.app.Activity;
20 | import android.support.test.InstrumentationRegistry;
21 | import android.support.test.runner.AndroidJUnit4;
22 | import android.test.ActivityInstrumentationTestCase2;
23 | import android.util.Log;
24 |
25 | import org.junit.After;
26 | import org.junit.Before;
27 | import org.junit.Test;
28 | import org.junit.runner.RunWith;
29 | import org.onepf.trivialdrive.ui.activity.LauncherActivity;
30 |
31 | /**
32 | * @author antonpp
33 | * @since 08.05.15
34 | */
35 | @RunWith(AndroidJUnit4.class)
36 | public class LaunchTest extends ActivityInstrumentationTestCase2 {
37 |
38 | private static final String TAG = LaunchTest.class.getSimpleName();
39 |
40 | private Activity activity;
41 |
42 | public LaunchTest() {
43 | super(LauncherActivity.class);
44 | }
45 |
46 | @Before
47 | @Override
48 | public void setUp() throws Exception {
49 | super.setUp();
50 |
51 | injectInstrumentation(InstrumentationRegistry.getInstrumentation());
52 |
53 | activity = getActivity();
54 | }
55 |
56 | @Test
57 | public void testCorrectSetup() throws Exception {
58 | Log.v(TAG, "LauncherActivity has started");
59 | }
60 |
61 | @After
62 | @Override
63 | public void tearDown() throws Exception {
64 | super.tearDown();
65 | activity = null;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
19 |
24 |
25 |
28 |
29 |
35 |
36 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
47 |
48 |
50 |
51 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/java/org/onepf/trivialdrive/Helper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.trivialdrive;
18 |
19 | import android.app.Activity;
20 | import android.support.annotation.StringRes;
21 |
22 | import org.onepf.trivialdrive.R;
23 | import org.onepf.trivialdrive.ui.activity.ActivityHelperActivity;
24 | import org.onepf.trivialdrive.ui.activity.FragmentHelperActivity;
25 | import org.onepf.trivialdrive.ui.activity.AdvancedHelperActivity;
26 |
27 | public enum Helper {
28 |
29 | ACTIVITY(R.string.helper_activity, ActivityHelperActivity.class),
30 | FRAGMENT(R.string.helper_fragment, FragmentHelperActivity.class),
31 | ADVANCED(R.string.helper_advanced, AdvancedHelperActivity.class),;
32 |
33 | @StringRes
34 | private final int nameId;
35 | private final Class extends Activity> activityClass;
36 |
37 | Helper(final int nameId, final Class extends Activity> activityClass) {
38 | this.nameId = nameId;
39 | this.activityClass = activityClass;
40 | }
41 |
42 | public int getNameId() {
43 | return nameId;
44 | }
45 |
46 | public Class extends Activity> getActivityClass() {
47 | return activityClass;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/java/org/onepf/trivialdrive/OnProviderPickerListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.trivialdrive;
18 |
19 | public interface OnProviderPickerListener {
20 |
21 | void onProviderPicked(final Provider provider);
22 | }
23 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/java/org/onepf/trivialdrive/Provider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.trivialdrive;
18 |
19 | import android.support.annotation.StringRes;
20 |
21 | import org.onepf.opfiab.amazon.AmazonBillingProvider;
22 | import org.onepf.opfiab.google.GoogleBillingProvider;
23 | import org.onepf.opfiab.openstore.ApplandBillingProvider;
24 | import org.onepf.opfiab.openstore.AptoideBillingProvider;
25 | import org.onepf.opfiab.openstore.SlideMEBillingProvider;
26 | import org.onepf.opfiab.openstore.YandexBillingProvider;
27 | import org.onepf.opfiab.samsung.SamsungBillingProvider;
28 |
29 | public enum Provider {
30 | AMAZON(R.string.name_amazon, AmazonBillingProvider.NAME),
31 | GOOGLE(R.string.name_google, GoogleBillingProvider.NAME),
32 | SAMSUNG(R.string.name_samsung, SamsungBillingProvider.NAME),
33 | YANDEX(R.string.name_yandex, YandexBillingProvider.NAME),
34 | APPLAND(R.string.name_appland, ApplandBillingProvider.NAME),
35 | APTOIDE(R.string.name_aptoide, AptoideBillingProvider.NAME),
36 | SLIDEME(R.string.name_slideme, SlideMEBillingProvider.NAME),
37 | OPENSTORE(R.string.name_openstore, "Open Store");
38 |
39 |
40 | public static Provider getByName(final String name) {
41 | for (final Provider provider : values()) {
42 | if (provider.name.equals(name)) {
43 | return provider;
44 | }
45 | }
46 | return null;
47 | }
48 |
49 | private final String name;
50 | @StringRes
51 | private final int nameId;
52 |
53 | Provider(final int nameId, final String name) {
54 | this.nameId = nameId;
55 | this.name = name;
56 | }
57 |
58 | public int getNameId() {
59 | return nameId;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/java/org/onepf/trivialdrive/TrivialApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.trivialdrive;
18 |
19 | import android.app.Application;
20 | import android.content.Context;
21 |
22 | import com.squareup.leakcanary.LeakCanary;
23 | import com.squareup.leakcanary.RefWatcher;
24 |
25 | import org.onepf.opfiab.OPFIab;
26 | import org.onepf.opfutils.OPFLog;
27 |
28 |
29 | public class TrivialApplication extends Application {
30 |
31 | public static RefWatcher getRefWatcher(final Context context) {
32 | final Context applicationContext = context.getApplicationContext();
33 | final TrivialApplication application = (TrivialApplication) applicationContext;
34 | return application.refWatcher;
35 | }
36 |
37 |
38 | private RefWatcher refWatcher;
39 |
40 | @Override
41 | public void onCreate() {
42 | super.onCreate();
43 | TrivialData.init(this);
44 | TrivialBilling.init(this);
45 |
46 | OPFLog.setEnabled(true, true);
47 | OPFIab.init(this, TrivialBilling.getRelevantConfiguration(this));
48 |
49 | refWatcher = LeakCanary.install(this);
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/java/org/onepf/trivialdrive/ui/activity/AdvancedHelperActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.trivialdrive.ui.activity;
18 |
19 | import android.os.Bundle;
20 |
21 | import org.onepf.trivialdrive.R;
22 |
23 | public class AdvancedHelperActivity extends TrivialActivity {
24 |
25 | @Override
26 | protected void onCreate(final Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.include_trivial_advanced);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/java/org/onepf/trivialdrive/ui/activity/FragmentHelperActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.trivialdrive.ui.activity;
18 |
19 | import android.os.Bundle;
20 |
21 | import org.onepf.trivialdrive.R;
22 | import org.onepf.trivialdrive.ui.fragment.TrivialFragment;
23 |
24 |
25 | public class FragmentHelperActivity extends TrivialActivity {
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | setContentView(R.layout.include_content);
31 | if (savedInstanceState == null) {
32 | getSupportFragmentManager().beginTransaction()
33 | .replace(R.id.content, TrivialFragment.newInstance())
34 | .commit();
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/java/org/onepf/trivialdrive/ui/activity/LauncherActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.trivialdrive.ui.activity;
18 |
19 | import android.app.Activity;
20 | import android.content.Intent;
21 | import android.os.Bundle;
22 |
23 | import org.onepf.trivialdrive.Helper;
24 | import org.onepf.trivialdrive.TrivialBilling;
25 |
26 |
27 | public class LauncherActivity extends Activity {
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | final Helper helper = TrivialBilling.getHelper();
33 | startActivity(new Intent(this, helper.getActivityClass()));
34 | finish();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable-hdpi/ic_add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/drawable-hdpi/ic_add.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable-hdpi/ic_check_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/drawable-hdpi/ic_check_off.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable-hdpi/ic_check_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/drawable-hdpi/ic_check_on.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable-hdpi/img_car.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/drawable-hdpi/img_car.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable-hdpi/img_car_premium.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/drawable-hdpi/img_car_premium.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable-hdpi/img_gas_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/drawable-hdpi/img_gas_0.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable-hdpi/img_gas_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/drawable-hdpi/img_gas_1.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable-hdpi/img_gas_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/drawable-hdpi/img_gas_2.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable-hdpi/img_gas_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/drawable-hdpi/img_gas_3.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable-hdpi/img_gas_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/drawable-hdpi/img_gas_4.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable-hdpi/img_gas_inf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/drawable-hdpi/img_gas_inf.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable-xhdpi/btn_buy_gas_default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/drawable-xhdpi/btn_buy_gas_default.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable-xhdpi/btn_buy_premium.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/drawable-xhdpi/btn_buy_premium.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable-xhdpi/btn_buy_subscription.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/drawable-xhdpi/btn_buy_subscription.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable-xhdpi/btn_drive.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/drawable-xhdpi/btn_drive.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable-xhdpi/ic_action_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/drawable-xhdpi/ic_action_delete.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable-xhdpi/ic_action_swap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/drawable-xhdpi/ic_action_swap.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable/btn_buy_gas.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable/btn_buy_gas_disabled.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable/img_gas_level.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
23 |
26 |
29 |
32 |
35 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/drawable/tv_check.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
23 |
24 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/layout-land/include_trivial_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
24 |
25 |
30 |
31 |
38 |
39 |
46 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/layout-land/view_trivial.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
20 |
21 |
25 |
26 |
30 |
31 |
34 |
35 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/layout/activity_trivial.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
24 |
30 |
31 |
35 |
36 |
37 |
38 |
46 |
47 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/layout/include_content.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/layout/include_trivial.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/layout/include_trivial_advanced.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/layout/include_trivial_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
24 |
25 |
30 |
31 |
38 |
39 |
45 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/layout/item_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
24 |
25 |
34 |
35 |
45 |
46 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/layout/item_drawer_footer.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
22 |
23 |
31 |
32 |
38 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/layout/view_sku_details.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
20 |
21 |
28 |
29 |
38 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/layout/view_trivial.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
20 |
21 |
25 |
26 |
29 |
30 |
34 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/samples/trivialdrive/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 | 16dp
19 | 16dp
20 |
21 | 5dp
22 | 16dp
23 |
24 | 40dp
25 |
26 | 50dp
27 | 320dp
28 |
29 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | Loreum Impsum
20 |
21 | Trivial Drive
22 |
23 | Google Play
24 | Amazon Appstore
25 | Samsung Galaxy Store
26 | Yandex Store
27 | Appland
28 | Aptoide
29 | SlideME
30 | Open Store
31 |
32 | forget\nlast\nprovider
33 | init()
34 | setup()
35 | Auto-Recover
36 |
37 | Helper Type
38 | Setup Status
39 | Add Provider
40 |
41 | No Billing Provider
42 |
43 | No SKU data
44 |
45 | Activity Helper
46 | Fragment Helper
47 | Advanced Helper
48 |
49 | You drove a few miles!
50 | %1$s : %2$s
51 |
52 | Pick Provider To Add
53 |
54 |
--------------------------------------------------------------------------------
/samples/trivialdrive/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
21 |
22 |
24 |
25 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 | include ':opfiab',
18 | ':opfiab-amazon',
19 | ':opfiab-google',
20 | ':opfiab-samsung',
21 | ':opfiab-openstore',
22 | ':opfiab-uitest',
23 | ':trivialdrive'
24 |
25 | project(':opfiab-amazon').projectDir = new File('opfiab-providers/amazon')
26 | project(':opfiab-google').projectDir = new File('opfiab-providers/google')
27 | project(':opfiab-samsung').projectDir = new File('opfiab-providers/samsung')
28 | project(':opfiab-openstore').projectDir = new File('opfiab-providers/openstore')
29 |
30 | project(':opfiab-uitest').projectDir = new File('test/opfiab-uitest')
31 |
32 | project(':trivialdrive').projectDir = new File('samples/trivialdrive')
33 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 | apply plugin: 'idea'
18 | apply plugin: 'com.android.application'
19 | apply from: urlCache.get('https://raw.githubusercontent.com/onepf/OPF-mvn-repo/gradle-commons/opf-commons.gradle')
20 |
21 | android {
22 | defaultConfig {
23 | applicationId "org.onepf.opfiab.opfiab_uitest"
24 | minSdkVersion 18
25 | targetSdkVersion 22
26 | versionCode 1
27 | versionName "0.3.0"
28 |
29 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
30 | }
31 |
32 | lintOptions {
33 | abortOnError false
34 | }
35 | }
36 |
37 | check {
38 | abortOnError true
39 | }
40 |
41 | dependencies {
42 | compile 'com.android.support:appcompat-v7:22.2.0'
43 | // OPFIab
44 | compile 'de.greenrobot:eventbus:2.4.0'
45 | //noinspection GradleDynamicVersion
46 | compile 'org.onepf:opfutils:0.1.+'
47 | compile project(':opfiab')
48 | // compile('org.onepf:opfiab:0.3.+@aar') {
49 | // changing = true
50 | // }
51 |
52 | // Testing-only dependencies
53 | androidTestCompile 'com.android.support:appcompat-v7:22.2.0'
54 | androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
55 | androidTestCompile 'com.android.support.test:runner:0.2'
56 | androidTestCompile 'com.android.support.test:rules:0.2'
57 | androidTestCompile 'org.mockito:mockito-core:1.10.19'
58 | androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
59 | androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
60 | androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.0'
61 | }
--------------------------------------------------------------------------------
/test/opfiab-uitest/lint.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/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 /usr/local/Cellar/android-sdk/24.0.2/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 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/androidTest/java/org/onepf/opfiab/opfiab_uitest/manager/TestManagerAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.opfiab_uitest.manager;
18 |
19 | import java.util.Collection;
20 | import java.util.HashSet;
21 |
22 | /**
23 | * @author antonpp
24 | * @since 29.05.15
25 | */
26 | public abstract class TestManagerAdapter {
27 |
28 | private final Collection testManagers = new HashSet<>();
29 |
30 | public TestManagerAdapter(TestManager testManager) {
31 | testManagers.add(testManager);
32 | }
33 |
34 | public TestManagerAdapter() {
35 | // TestManager should be added later
36 | }
37 |
38 | public void validateEvent(Object event) {
39 | for (TestManager testManager: testManagers) {
40 | testManager.validateEvent(event);
41 | }
42 | }
43 |
44 | public void addTestManager(TestManager testManager) {
45 | testManagers.add(testManager);
46 | }
47 |
48 | public void removeTestManager(TestManager testManager) {
49 | testManagers.remove(testManager);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/androidTest/java/org/onepf/opfiab/opfiab_uitest/util/Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.opfiab_uitest.util;
18 |
19 | /**
20 | * @author antonpp
21 | * @since 09.06.15
22 | */
23 | public final class Constants {
24 |
25 | public static final String TEST_APP_PKG = "org.onepf.opfiab.opfiab_uitest";
26 | public static final String TEST_PROVIDER_PACKAGE = "org.onepf.opfiab.uitest";
27 | public static final String TEST_PROVIDER_NAME = "TEST_PROVIDER_NAME";
28 | public static final String TEST_PROVIDER_NAME_FMT = "TEST_PROVIDER_NAME_%s";
29 |
30 | public static final String SKU_CONSUMABLE = "org.onepf.opfiab.consumable";
31 | public static final String SKU_ENTITY = "org.onepf.opfiab.entity";
32 | public static final String SKU_SUBSCRIPTION = "org.onepf.opfiab.subscription";
33 |
34 | public static final long WAIT_LAUNCH_SCREEN = 5000L;
35 | public static final long WAIT_REOPEN_ACTIVITY = 2000L;
36 | public static final long WAIT_BILLING_PROVIDER = 1000L;
37 | public static final long WAIT_PURCHASE = 2 * WAIT_BILLING_PROVIDER;
38 | public static final long WAIT_INIT = 2 * WAIT_BILLING_PROVIDER;
39 | public static final long WAIT_TEST_MANAGER = 2 * WAIT_BILLING_PROVIDER;
40 |
41 | private Constants() {
42 | throw new UnsupportedOperationException();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/androidTest/java/org/onepf/opfiab/opfiab_uitest/util/validators/AlwaysFailValidator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.opfiab_uitest.util.validators;
18 |
19 | import org.onepf.opfutils.OPFLog;
20 |
21 | /**
22 | * @author antonpp
23 | * @since 03.06.15
24 | */
25 | public class AlwaysFailValidator implements EventValidator {
26 | private static final StopObject STOP_OBJECT = new StopObject();
27 |
28 | public static StopObject getStopObject() {
29 | return STOP_OBJECT;
30 | }
31 |
32 | @Override
33 | public boolean validate(final Object event, final boolean isLogging, final String logTag) {
34 | final boolean result = event.equals(STOP_OBJECT);
35 | if (isLogging && !result) {
36 | OPFLog.e(String.format("[%s]: Received %s when STOP_OBJECT was expected", logTag,
37 | event.getClass().getSimpleName()));
38 | }
39 | return result;
40 | }
41 |
42 | private static final class StopObject {
43 | public StopObject() {
44 | super();
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/androidTest/java/org/onepf/opfiab/opfiab_uitest/util/validators/EventValidator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.opfiab_uitest.util.validators;
18 |
19 | /**
20 | * @author antonpp
21 | * @since 15.05.15
22 | */
23 | public interface EventValidator {
24 | boolean validate(Object event, final boolean isLogging, final String logTag);
25 | }
26 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/androidTest/java/org/onepf/opfiab/opfiab_uitest/util/validators/PurchaseRequestValidator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.opfiab_uitest.util.validators;
18 |
19 | import org.onepf.opfiab.model.event.billing.PurchaseRequest;
20 | import org.onepf.opfutils.OPFLog;
21 |
22 | /**
23 | * @author antonpp
24 | * @since 28.05.15
25 | */
26 | public class PurchaseRequestValidator extends TypedEventValidator {
27 |
28 | private final String sku;
29 |
30 | public PurchaseRequestValidator(String sku) {
31 | super(PurchaseRequest.class);
32 | this.sku = sku;
33 | }
34 |
35 | @Override
36 | public boolean validate(Object event, final boolean isLogging, final String logTag) {
37 | if (!super.validate(event, isLogging, logTag)) {
38 | return false;
39 | }
40 | final PurchaseRequest request = (PurchaseRequest) event;
41 | if (request.getSku().equals(sku)) {
42 | return true;
43 | } else {
44 | if (isLogging) {
45 | OPFLog.e(String.format("[%s]: %s", logTag, "Wrong provider's sku"));
46 | }
47 | return false;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/androidTest/java/org/onepf/opfiab/opfiab_uitest/util/validators/SetupResponseValidator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.opfiab_uitest.util.validators;
18 |
19 | import org.onepf.opfiab.model.event.SetupResponse;
20 | import org.onepf.opfutils.OPFLog;
21 |
22 | /**
23 | * @author antonpp
24 | * @since 15.05.15
25 | */
26 | public class SetupResponseValidator extends TypedEventValidator {
27 |
28 | private final String name;
29 |
30 | public SetupResponseValidator(String name) {
31 | super(SetupResponse.class);
32 | this.name = name;
33 | }
34 |
35 | @Override
36 | public boolean validate(Object event, final boolean isLogging, final String logTag) {
37 | if (!super.validate(event, isLogging, logTag)) {
38 | return false;
39 | }
40 | final SetupResponse setupResponse = (SetupResponse) event;
41 | final boolean result;
42 | final String msg;
43 | if (setupResponse.getBillingProvider() == null) {
44 | msg = "Billing provider is set to null";
45 | result = false;
46 | } else if (setupResponse.getBillingProvider().getName().equals(name)) {
47 | msg = "";
48 | result = true;
49 | } else {
50 | msg = "Wrong provider's name";
51 | result = false;
52 | }
53 | if (isLogging && !msg.isEmpty()) {
54 | OPFLog.e(String.format("[%s]: %s", logTag, msg));
55 | }
56 | return result;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/androidTest/java/org/onepf/opfiab/opfiab_uitest/util/validators/SetupStartedEventValidator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.opfiab_uitest.util.validators;
18 |
19 | import org.onepf.opfiab.model.event.SetupStartedEvent;
20 |
21 | /**
22 | * @author antonpp
23 | * @since 25.05.15
24 | */
25 | public class SetupStartedEventValidator extends TypedEventValidator {
26 |
27 | public SetupStartedEventValidator() {
28 | super(SetupStartedEvent.class);
29 | }
30 |
31 | @Override
32 | public boolean validate(Object event, final boolean isLogging, final String logTag) {
33 | return super.validate(event, isLogging, logTag);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/androidTest/java/org/onepf/opfiab/opfiab_uitest/util/validators/TypedEventValidator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.opfiab_uitest.util.validators;
18 |
19 | import org.onepf.opfutils.OPFLog;
20 |
21 | /**
22 | * @author antonpp
23 | * @since 25.05.15
24 | */
25 | public abstract class TypedEventValidator implements EventValidator {
26 |
27 | protected final Class clazz;
28 |
29 | protected TypedEventValidator(Class clazz) {
30 | this.clazz = clazz;
31 | }
32 |
33 | @Override
34 | public boolean validate(Object event, final boolean isLogging, final String logTag) {
35 | final boolean result = clazz.isInstance(event);
36 | if (isLogging && !result) {
37 | OPFLog.e(String.format("[%s]: Wrong Type Event. Expected: %s. Received: %s", logTag,
38 | clazz.getSimpleName(), event.getClass().getSimpleName()));
39 | }
40 | return result;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
21 |
22 |
23 |
24 |
29 |
31 |
32 |
33 |
34 |
35 |
36 |
38 |
39 |
40 |
41 |
42 |
43 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/main/java/org/onepf/opfiab/opfiab_uitest/EmptyActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.opfiab_uitest;
18 |
19 | import android.app.Activity;
20 | import android.content.Intent;
21 | import android.os.Bundle;
22 |
23 | import org.onepf.opfiab.OPFIab;
24 | import org.onepf.opfiab.model.event.android.ActivityResult;
25 |
26 | /**
27 | * @author antonpp
28 | * @since 26.05.15
29 | */
30 | @SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod")
31 | public class EmptyActivity extends Activity {
32 |
33 | private static EmptyActivity lastInstance;
34 |
35 | public static EmptyActivity getLastInstance() {
36 | return lastInstance;
37 | }
38 |
39 | @Override
40 | protected void onCreate(final Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | setContentView(R.layout.activity_empty);
43 | lastInstance = this;
44 | }
45 |
46 | @Override
47 | protected void onActivityResult(final int requestCode, final int resultCode,
48 | final Intent data) {
49 | super.onActivityResult(requestCode, resultCode, data);
50 | OPFIab.post(new ActivityResult(this, requestCode, resultCode, data));
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/main/java/org/onepf/opfiab/opfiab_uitest/EmptyFragmentActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.opfiab_uitest;
18 |
19 | import android.content.Intent;
20 | import android.os.Bundle;
21 | import android.support.v4.app.FragmentActivity;
22 |
23 | import org.onepf.opfiab.OPFIab;
24 | import org.onepf.opfiab.model.event.android.ActivityResult;
25 |
26 | /**
27 | * @author antonpp
28 | * @since 26.05.15
29 | */
30 | @SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod")
31 | public class EmptyFragmentActivity extends FragmentActivity {
32 |
33 | private static EmptyFragmentActivity lastInstance;
34 |
35 | public static EmptyFragmentActivity getLastInstance() {
36 | return lastInstance;
37 | }
38 |
39 | @Override
40 | protected void onActivityResult(final int requestCode, final int resultCode,
41 | final Intent data) {
42 | super.onActivityResult(requestCode, resultCode, data);
43 | OPFIab.post(new ActivityResult(this, requestCode, resultCode, data));
44 | }
45 |
46 | @Override
47 | protected void onCreate(final Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 | setContentView(R.layout.activity_empty);
50 | lastInstance = this;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/main/java/org/onepf/opfiab/opfiab_uitest/mock/MockBillingProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.opfiab_uitest.mock;
18 |
19 | import android.support.annotation.NonNull;
20 |
21 | import org.onepf.opfiab.billing.BillingProvider;
22 | import org.onepf.opfiab.billing.Compatibility;
23 | import org.onepf.opfiab.model.billing.SkuType;
24 | import org.onepf.opfutils.OPFLog;
25 |
26 | import java.util.Random;
27 |
28 | /**
29 | * @author antonpp
30 | * @since 14.05.15
31 | */
32 | public abstract class MockBillingProvider implements BillingProvider {
33 |
34 | public static final long SLEEP_TIME = 50;
35 | private static final Random RND = new Random();
36 |
37 | protected void sleep() {
38 | try {
39 | Thread.sleep((SLEEP_TIME + RND.nextLong() % SLEEP_TIME) / 2);
40 | } catch (InterruptedException e) {
41 | OPFLog.e(e.getMessage());
42 | }
43 | }
44 |
45 | @NonNull
46 | @Override
47 | public Compatibility checkCompatibility() {
48 | return Compatibility.COMPATIBLE;
49 | }
50 |
51 | @Override
52 | public boolean skuTypeSupported(@NonNull final SkuType skuType) {
53 | return true;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/main/java/org/onepf/opfiab/opfiab_uitest/mock/MockOkBillingProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2015 One Platform Foundation
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 org.onepf.opfiab.opfiab_uitest.mock;
18 |
19 | import android.content.Intent;
20 | import android.support.annotation.NonNull;
21 | import android.support.annotation.Nullable;
22 |
23 | import org.onepf.opfiab.OPFIab;
24 | import org.onepf.opfiab.model.event.RequestHandledEvent;
25 | import org.onepf.opfiab.model.event.billing.BillingRequest;
26 | import org.onepf.opfiab.model.event.billing.PurchaseResponse;
27 | import org.onepf.opfiab.verification.VerificationResult;
28 |
29 | import static org.onepf.opfiab.model.event.billing.Status.SUCCESS;
30 |
31 | /**
32 | * @author antonpp
33 | * @since 14.05.15
34 | */
35 | public class MockOkBillingProvider extends MockBillingProvider {
36 |
37 | private static final String NAME = MockOkBillingProvider.class.getSimpleName();
38 |
39 | @NonNull
40 | @Override
41 | public String getName() {
42 | return NAME;
43 | }
44 |
45 | @Override
46 | public void checkManifest() {
47 | // nothing
48 | }
49 |
50 | @Override
51 | public boolean isAvailable() {
52 | sleep();
53 | return true;
54 | }
55 |
56 | @Override
57 | public void onBillingRequest(@NonNull BillingRequest billingRequest) {
58 | OPFIab.post(new RequestHandledEvent(billingRequest));
59 | sleep();
60 | OPFIab.post(new PurchaseResponse(SUCCESS, getName(), null, VerificationResult.SUCCESS));
61 | }
62 |
63 | @Nullable
64 | @Override
65 | public Intent getStorePageIntent() {
66 | return null;
67 | }
68 |
69 | @Nullable
70 | @Override
71 | public Intent getRateIntent() {
72 | return null;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/main/res/layout/activity_empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
24 |
25 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/main/res/layout/fragment_empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
22 |
23 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/test/opfiab-uitest/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/test/opfiab-uitest/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/test/opfiab-uitest/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OPFIab/1922fa18eb7ca6ae4c97d169b007342e647aea5c/test/opfiab-uitest/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
21 |
22 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 | #FF0000
21 | #00FF00
22 | #0000FF
23 |
24 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 | opfiab-uitest
19 |
20 | init OK
21 | init fail
22 | init with custom BP
23 | setup
24 | buy consumable
25 | buy nonconsumable
26 | buy subscription
27 |
28 |
29 |
--------------------------------------------------------------------------------
/test/opfiab-uitest/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
25 |
--------------------------------------------------------------------------------