initial commit
11
.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
.gradle
|
||||
local.properties
|
||||
.idea
|
||||
.DS_Store
|
||||
build/
|
||||
*.aar
|
||||
*.iml
|
||||
*.jks
|
||||
*.apk
|
||||
|
||||
*.pem
|
23
CONTRIBUTING.md
Normal file
@ -0,0 +1,23 @@
|
||||
# How to Contribute
|
||||
|
||||
We'd love to accept your patches and contributions to this project. There are
|
||||
just a few small guidelines you need to follow.
|
||||
|
||||
## Contributor License Agreement
|
||||
|
||||
Contributions to this project must be accompanied by a Contributor License
|
||||
Agreement. You (or your employer) retain the copyright to your contribution,
|
||||
this simply gives us permission to use and redistribute your contributions as
|
||||
part of the project. Head over to <https://cla.developers.google.com/> to see
|
||||
your current agreements on file or to sign a new one.
|
||||
|
||||
You generally only need to submit a CLA once, so if you've already submitted one
|
||||
(even if it was for a different project), you probably don't need to do it
|
||||
again.
|
||||
|
||||
## Code reviews
|
||||
|
||||
All submissions, including submissions by project members, require review. We
|
||||
use GitHub pull requests for this purpose. Consult
|
||||
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
|
||||
information on using pull requests.
|
202
LICENSE
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2017 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
13
README.md
Normal file
@ -0,0 +1,13 @@
|
||||
# paymentsapi-quickstart
|
||||
|
||||
## Overview
|
||||
This sample demonstrates basic usage of the Google Payment API. For more
|
||||
information, visit the following link:
|
||||
|
||||
https://developers.google.com/payments/overview
|
||||
|
||||
## Instructions
|
||||
|
||||
Make sure you read the comments in Constants.java and PaymentsUtil.java before
|
||||
you continue. These files **must** be modified prior to running the app, as per
|
||||
the instructions provided in the comments.
|
1
app/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build
|
29
app/build.gradle
Normal file
@ -0,0 +1,29 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 26
|
||||
buildToolsVersion "26.0.0"
|
||||
defaultConfig {
|
||||
applicationId "com.google.android.gms.samples.wallet"
|
||||
minSdkVersion 26
|
||||
targetSdkVersion 26
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
shrinkResources true
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.android.support:appcompat-v7:26.0.2'
|
||||
compile 'com.google.android.gms:play-services-wallet:11.4.0'
|
||||
compile 'com.google.android.gms:play-services-tasks:11.4.0'
|
||||
compile 'com.google.android.gms:play-services-base:11.4.0'
|
||||
compile 'com.google.android.gms:play-services-basement:11.4.0'
|
||||
}
|
28
app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
|
||||
package="com.google.android.gms.samples.wallet">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true">
|
||||
|
||||
<activity
|
||||
android:name="CheckoutActivity"
|
||||
android:label="@string/store_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- This element is required in order to use the PaymentsClient -->
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.wallet.api.enabled"
|
||||
android:value="true" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -0,0 +1,185 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.gms.samples.wallet;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.gms.common.api.ApiException;
|
||||
import com.google.android.gms.common.api.Status;
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.google.android.gms.wallet.AutoResolveHelper;
|
||||
import com.google.android.gms.wallet.PaymentData;
|
||||
import com.google.android.gms.wallet.PaymentDataRequest;
|
||||
import com.google.android.gms.wallet.PaymentMethodToken;
|
||||
import com.google.android.gms.wallet.PaymentsClient;
|
||||
import com.google.android.gms.wallet.TransactionInfo;
|
||||
import com.google.android.gms.wallet.WalletConstants;
|
||||
|
||||
public class CheckoutActivity extends Activity {
|
||||
// Arbitrarily-picked result code.
|
||||
private static final int LOAD_PAYMENT_DATA_REQUEST_CODE = 991;
|
||||
|
||||
private PaymentsClient mPaymentsClient;
|
||||
|
||||
private View mPwgButton;
|
||||
private TextView mPwgStatusText;
|
||||
|
||||
private ItemInfo mBikeItem = new ItemInfo("Simple Bike", 300 * 1000000, R.drawable.bike);
|
||||
private long mShippingCost = 90 * 1000000;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_checkout);
|
||||
|
||||
// Set up the mock information for our item in the UI.
|
||||
initItemUI();
|
||||
|
||||
mPwgButton = findViewById(R.id.pwg_button);
|
||||
mPwgStatusText = findViewById(R.id.pwg_status);
|
||||
|
||||
mPwgButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
requestPayment(view);
|
||||
}
|
||||
});
|
||||
|
||||
// It's recommended to create the PaymentsClient object inside of the onCreate method.
|
||||
mPaymentsClient = PaymentsUtil.createPaymentsClient(this);
|
||||
checkIsReadyToPay();
|
||||
}
|
||||
|
||||
private void checkIsReadyToPay() {
|
||||
// The call to isReadyToPay is asynchronous and returns a Task. We need to provide an
|
||||
// OnCompleteListener to be triggered when the result of the call is known.
|
||||
PaymentsUtil.isReadyToPay(mPaymentsClient).addOnCompleteListener(
|
||||
new OnCompleteListener<Boolean>() {
|
||||
public void onComplete(Task<Boolean> task) {
|
||||
try {
|
||||
boolean result = task.getResult(ApiException.class);
|
||||
setPwgAvailable(result);
|
||||
} catch (ApiException exception) {
|
||||
// Process error
|
||||
Log.w("isReadyToPay failed", exception);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setPwgAvailable(boolean available) {
|
||||
// If isReadyToPay returned true, show the button and hide the "checking" text. Otherwise,
|
||||
// notify the user that Pay with Google is not available.
|
||||
// Please adjust to fit in with your current user flow. You are not required to explicitly
|
||||
// let the user know if isReadyToPay returns false.
|
||||
if (available) {
|
||||
mPwgStatusText.setVisibility(View.GONE);
|
||||
mPwgButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mPwgStatusText.setText(R.string.pwg_status_unavailable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
case LOAD_PAYMENT_DATA_REQUEST_CODE:
|
||||
switch (resultCode) {
|
||||
case Activity.RESULT_OK:
|
||||
PaymentData paymentData = PaymentData.getFromIntent(data);
|
||||
handlePaymentSuccess(paymentData);
|
||||
break;
|
||||
case Activity.RESULT_CANCELED:
|
||||
// Nothing to here normally - the user simply cancelled without selecting a
|
||||
// payment method.
|
||||
break;
|
||||
case AutoResolveHelper.RESULT_ERROR:
|
||||
Status status = AutoResolveHelper.getStatusFromIntent(data);
|
||||
handleError(status.getStatusCode());
|
||||
break;
|
||||
}
|
||||
|
||||
// Re-enables the Pay with Google button.
|
||||
mPwgButton.setClickable(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handlePaymentSuccess(PaymentData paymentData) {
|
||||
// PaymentMethodToken contains the payment information, as well as any additional
|
||||
// requested information, such as billing and shipping address.
|
||||
//
|
||||
// Refer to your processor's documentation on how to proceed from here.
|
||||
PaymentMethodToken token = paymentData.getPaymentMethodToken();
|
||||
|
||||
// getPaymentMethodToken will only return null if PaymentMethodTokenizationParameters was
|
||||
// not set in the PaymentRequest.
|
||||
if (token != null) {
|
||||
String billingName = paymentData.getCardInfo().getBillingAddress().getName();
|
||||
Toast.makeText(this, getString(R.string.payments_show_name, billingName), Toast.LENGTH_LONG).show();
|
||||
|
||||
// Use token.getToken() to get the token string.
|
||||
Log.d("PaymentData", "PaymentMethodToken received");
|
||||
}
|
||||
}
|
||||
|
||||
private void handleError(int statusCode) {
|
||||
// At this stage, the user has already seen a popup informing them an error occurred.
|
||||
// Normally, only logging is required.
|
||||
// statusCode will hold the value of any constant from CommonStatusCode or one of the
|
||||
// WalletConstants.ERROR_CODE_* constants.
|
||||
Log.w("loadPaymentData failed", String.format("Error code: %d", statusCode));
|
||||
}
|
||||
|
||||
// This method is called when the Pay with Google button is clicked.
|
||||
public void requestPayment(View view) {
|
||||
// Disables the button to prevent multiple clicks.
|
||||
mPwgButton.setClickable(false);
|
||||
|
||||
// The price provided to the API should include taxes and shipping.
|
||||
// This price is not displayed to the user.
|
||||
String price = PaymentsUtil.microsToString(mBikeItem.getPriceMicros() + mShippingCost);
|
||||
|
||||
TransactionInfo transaction = PaymentsUtil.createTransaction(price);
|
||||
PaymentDataRequest request = PaymentsUtil.createPaymentDataRequest(transaction);
|
||||
Task<PaymentData> futurePaymentData = mPaymentsClient.loadPaymentData(request);
|
||||
|
||||
// Since loadPaymentData may show the UI asking the user to select a payment method, we use
|
||||
// AutoResolveHelper to wait for the user interacting with it. Once completed,
|
||||
// onActivityResult will be called with the result.
|
||||
AutoResolveHelper.resolveTask(futurePaymentData, this, LOAD_PAYMENT_DATA_REQUEST_CODE);
|
||||
}
|
||||
|
||||
private void initItemUI() {
|
||||
TextView itemName = findViewById(R.id.text_item_name);
|
||||
ImageView itemImage = findViewById(R.id.image_item_image);
|
||||
TextView itemPrice = findViewById(R.id.text_item_price);
|
||||
|
||||
itemName.setText(mBikeItem.getName());
|
||||
itemImage.setImageResource(mBikeItem.getImageResourceId());
|
||||
itemPrice.setText(PaymentsUtil.microsToString(mBikeItem.getPriceMicros()));
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.gms.samples.wallet;
|
||||
|
||||
import android.util.Pair;
|
||||
|
||||
import com.google.android.gms.wallet.WalletConstants;
|
||||
|
||||
import java.io.UncheckedIOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Constants {
|
||||
// This file contains several constants you must edit before proceeding. Once you're done,
|
||||
// remove this static block and run the sample.
|
||||
// Before you start, please take a look at PaymentsUtil.java to see where the constants are used
|
||||
// and to potentially remove ones not relevant to your integration.
|
||||
// Required changes:
|
||||
// 1. Update SUPPORTED_NETWORKS and SUPPORTED_METHODS if required (consult your processor if
|
||||
// unsure).
|
||||
// 2. Update CURRENCY_CODE to the currency you use.
|
||||
// 3. Update SHIPPING_SUPPORTED_COUNTRIES to list the countries where you currently ship. If
|
||||
// this is not applicable to your app, remove the relevant bits from PaymentsUtil.java.
|
||||
// 4. If you're integrating with your processor / gateway directly, update
|
||||
// GATEWAY_TOKENIZATION_NAME and GATEWAY_TOKENIZATION_PARAMETERS per the instructions they
|
||||
// provided. You don't need to update DIRECT_TOKENIZATION_PUBLIC_KEY.
|
||||
// 5. If you're using direct integration, please consult the documentation to learn about
|
||||
// next steps.
|
||||
static {
|
||||
if (true) {
|
||||
throw new RuntimeException("[REMOVE ME] Please edit the Constants.java file per the"
|
||||
+ " instructions inside before trying to run this sample.");
|
||||
}
|
||||
}
|
||||
|
||||
// Changing this to ENVIRONMENT_PRODUCTION will make the API return real card information.
|
||||
// Please refer to the documentation to read about the required steps needed to enable
|
||||
// ENVIRONMENT_PRODUCTION.
|
||||
public static final int PAYMENTS_ENVIRONMENT = WalletConstants.ENVIRONMENT_TEST;
|
||||
|
||||
// The allowed networks to be requested from the API. If the user has cards from networks not
|
||||
// specified here in their account, these will not be offered for them to choose in the popup.
|
||||
public static final List<Integer> SUPPORTED_NETWORKS = Arrays.asList(
|
||||
WalletConstants.CARD_NETWORK_AMEX,
|
||||
WalletConstants.CARD_NETWORK_DISCOVER,
|
||||
WalletConstants.CARD_NETWORK_VISA,
|
||||
WalletConstants.CARD_NETWORK_MASTERCARD
|
||||
);
|
||||
|
||||
public static final List<Integer> SUPPORTED_METHODS = Arrays.asList(
|
||||
// PAYMENT_METHOD_CARD returns to any card the user has stored in their Google Account.
|
||||
WalletConstants.PAYMENT_METHOD_CARD,
|
||||
|
||||
// PAYMENT_METHOD_TOKENIZED_CARD refers to cards added to Android Pay, assuming Android
|
||||
// Pay is installed.
|
||||
// Please keep in mind cards may exist in Android Pay without being added to the Google
|
||||
// Account.
|
||||
WalletConstants.PAYMENT_METHOD_TOKENIZED_CARD
|
||||
);
|
||||
|
||||
// Required by the API, but not visible to the user.
|
||||
public static final String CURRENCY_CODE = "USD";
|
||||
|
||||
// Supported countries for shipping (use ISO 3166-1 alpha-2 country codes).
|
||||
// Relevant only when requesting a shipping address.
|
||||
public static final List<String> SHIPPING_SUPPORTED_COUNTRIES = Arrays.asList(
|
||||
"US",
|
||||
"GB"
|
||||
);
|
||||
|
||||
// The name of your payment processor / gateway. Please refer to their documentation for
|
||||
// more information.
|
||||
public static final String GATEWAY_TOKENIZATION_NAME = "stripe";
|
||||
|
||||
// Custom parameters required by the processor / gateway. Please refer to your processor's
|
||||
// documentation for more information. The number of parameters required and their names vary
|
||||
// depending on the processor.
|
||||
public static final List<Pair<String, String>> GATEWAY_TOKENIZATION_PARAMETERS = Arrays.asList(
|
||||
Pair.create("stripe:version", "5"),
|
||||
Pair.create("stripe:publishableKey", "REPLACE_ME")
|
||||
);
|
||||
// In many cases, your processor / gateway will only require a gatewayMerchantId.
|
||||
//public static final List<Pair<String, String>> GATEWAY_TOKENIZATION_PARAMETERS = Arrays.asList(
|
||||
// Pair.create("gatewayMerchantId", "REPLACE_ME")
|
||||
//);
|
||||
|
||||
// Only used for DIRECT tokenization. Can be removed when using GATEWAY tokenization.
|
||||
public static final String DIRECT_TOKENIZATION_PUBLIC_KEY = "REPLACE_ME";
|
||||
|
||||
private Constants() {
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.gms.samples.wallet;
|
||||
|
||||
/**
|
||||
* Used for storing the (hard coded) info about the item we're selling.
|
||||
* <p>
|
||||
* This POJO class is used only for example purposes - you don't need need it in your code.
|
||||
*/
|
||||
public class ItemInfo {
|
||||
private final String name;
|
||||
private final int imageResourceId;
|
||||
|
||||
// Micros are used for prices to avoid rounding errors when converting between currencies.
|
||||
private final long priceMicros;
|
||||
|
||||
public ItemInfo(String name, long price, int imageResourceId) {
|
||||
this.name = name;
|
||||
this.priceMicros = price;
|
||||
this.imageResourceId = imageResourceId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getImageResourceId() {
|
||||
return imageResourceId;
|
||||
}
|
||||
|
||||
public long getPriceMicros() {
|
||||
return priceMicros;
|
||||
}
|
||||
}
|
@ -0,0 +1,185 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.gms.samples.wallet;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.google.android.gms.wallet.CardRequirements;
|
||||
import com.google.android.gms.wallet.IsReadyToPayRequest;
|
||||
import com.google.android.gms.wallet.PaymentDataRequest;
|
||||
import com.google.android.gms.wallet.PaymentMethodTokenizationParameters;
|
||||
import com.google.android.gms.wallet.PaymentsClient;
|
||||
import com.google.android.gms.wallet.ShippingAddressRequirements;
|
||||
import com.google.android.gms.wallet.TransactionInfo;
|
||||
import com.google.android.gms.wallet.Wallet;
|
||||
import com.google.android.gms.wallet.WalletConstants;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
/**
|
||||
* Contains helper static methods for dealing with the Payments API.
|
||||
* <p>
|
||||
* Many of the parameters used in the code are optional and are set here merely to call out their
|
||||
* existence. Please consult the documentation to learn more and feel free to remove ones not
|
||||
* relevant to your implementation.
|
||||
*/
|
||||
public class PaymentsUtil {
|
||||
private static final BigDecimal MICROS = new BigDecimal(1000000d);
|
||||
|
||||
private PaymentsUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link PaymentsClient} for use in an {@link Activity} using the
|
||||
* environment and theme set in {@link Constants}.
|
||||
*
|
||||
* @param activity is the caller's activity.
|
||||
*/
|
||||
public static PaymentsClient createPaymentsClient(Activity activity) {
|
||||
Wallet.WalletOptions walletOptions = new Wallet.WalletOptions.Builder()
|
||||
.setEnvironment(Constants.PAYMENTS_ENVIRONMENT)
|
||||
.build();
|
||||
return Wallet.getPaymentsClient(activity, walletOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds {@link PaymentDataRequest} to be consumed by {@link PaymentsClient#loadPaymentData}.
|
||||
*
|
||||
* @param transactionInfo contains the price for this transaction.
|
||||
*/
|
||||
public static PaymentDataRequest createPaymentDataRequest(TransactionInfo transactionInfo) {
|
||||
PaymentMethodTokenizationParameters.Builder paramsBuilder =
|
||||
PaymentMethodTokenizationParameters.newBuilder()
|
||||
.setPaymentMethodTokenizationType(
|
||||
WalletConstants.PAYMENT_METHOD_TOKENIZATION_TYPE_PAYMENT_GATEWAY)
|
||||
.addParameter("gateway", Constants.GATEWAY_TOKENIZATION_NAME);
|
||||
for (Pair<String, String> param : Constants.GATEWAY_TOKENIZATION_PARAMETERS) {
|
||||
paramsBuilder.addParameter(param.first, param.second);
|
||||
}
|
||||
|
||||
return createPaymentDataRequest(transactionInfo, paramsBuilder.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds {@link PaymentDataRequest} for use with DIRECT integration to be consumed by
|
||||
* {@link PaymentsClient#loadPaymentData}.
|
||||
* <p>
|
||||
* Please refer to the documentation for more information about DIRECT integration. The type of
|
||||
* integration you use depends on your payment processor.
|
||||
*
|
||||
* @param transactionInfo contains the price for this transaction.
|
||||
*/
|
||||
public static PaymentDataRequest createPaymentDataRequestDirect(TransactionInfo transactionInfo) {
|
||||
PaymentMethodTokenizationParameters params =
|
||||
PaymentMethodTokenizationParameters.newBuilder()
|
||||
.setPaymentMethodTokenizationType(
|
||||
WalletConstants.PAYMENT_METHOD_TOKENIZATION_TYPE_DIRECT)
|
||||
|
||||
// Omitting the publicKey will result in a request for unencrypted data.
|
||||
// Please refer to the documentation for more information on unencrypted
|
||||
// requests.
|
||||
.addParameter("publicKey", Constants.DIRECT_TOKENIZATION_PUBLIC_KEY)
|
||||
.build();
|
||||
|
||||
return createPaymentDataRequest(transactionInfo, params);
|
||||
}
|
||||
|
||||
private static PaymentDataRequest createPaymentDataRequest(TransactionInfo transactionInfo, PaymentMethodTokenizationParameters params) {
|
||||
PaymentDataRequest request =
|
||||
PaymentDataRequest.newBuilder()
|
||||
.setPhoneNumberRequired(false)
|
||||
.setEmailRequired(true)
|
||||
.setShippingAddressRequired(true)
|
||||
|
||||
// Omitting ShippingAddressRequirements all together means all countries are
|
||||
// supported.
|
||||
.setShippingAddressRequirements(
|
||||
ShippingAddressRequirements.newBuilder()
|
||||
.addAllowedCountryCodes(Constants.SHIPPING_SUPPORTED_COUNTRIES)
|
||||
.build())
|
||||
|
||||
.setTransactionInfo(transactionInfo)
|
||||
.addAllowedPaymentMethods(Constants.SUPPORTED_METHODS)
|
||||
.setCardRequirements(
|
||||
CardRequirements.newBuilder()
|
||||
.addAllowedCardNetworks(Constants.SUPPORTED_NETWORKS)
|
||||
.setAllowPrepaidCards(true)
|
||||
.setBillingAddressRequired(true)
|
||||
|
||||
// Omitting this parameter will result in the API returning
|
||||
// only a "minimal" billing address (post code only).
|
||||
.setBillingAddressFormat(WalletConstants.BILLING_ADDRESS_FORMAT_FULL)
|
||||
.build())
|
||||
.setPaymentMethodTokenizationParameters(params)
|
||||
|
||||
// If the UI is not required, a returning user will not be asked to select
|
||||
// a card. Instead, the card they previously used will be returned
|
||||
// automatically (if still available).
|
||||
// Prior whitelisting is required to use this feature.
|
||||
.setUiRequired(true)
|
||||
.build();
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the user is eligible to Pay with Google by calling
|
||||
* {@link PaymentsClient#isReadyToPay}. The nature of this check depends on the methods set in
|
||||
* {@link Constants#SUPPORTED_METHODS}.
|
||||
* <p>
|
||||
* If {@link WalletConstants#PAYMENT_METHOD_CARD} is specified among supported methods, this
|
||||
* function will return true even if the user has no cards stored. Please refer to the
|
||||
* documentation for more information on how the check is performed.
|
||||
*
|
||||
* @param client used to send the request.
|
||||
*/
|
||||
public static Task<Boolean> isReadyToPay(PaymentsClient client) {
|
||||
IsReadyToPayRequest.Builder request = IsReadyToPayRequest.newBuilder();
|
||||
for (Integer allowedMethod : Constants.SUPPORTED_METHODS) {
|
||||
request.addAllowedPaymentMethod(allowedMethod);
|
||||
}
|
||||
return client.isReadyToPay(request.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds {@link TransactionInfo} for use with {@link PaymentsUtil#createPaymentDataRequest}.
|
||||
* <p>
|
||||
* The price is not displayed to the user and must be in the following format: "12.34".
|
||||
* {@link PaymentsUtil#microsToString} can be used to format the string.
|
||||
*
|
||||
* @param price total of the transaction.
|
||||
*/
|
||||
public static TransactionInfo createTransaction(String price) {
|
||||
return TransactionInfo.newBuilder()
|
||||
.setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL)
|
||||
.setTotalPrice(price)
|
||||
.setCurrencyCode(Constants.CURRENCY_CODE)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts micros to a string format accepted by {@link PaymentsUtil#createTransaction}.
|
||||
*
|
||||
* @param micros value of the price.
|
||||
*/
|
||||
public static String microsToString(long micros) {
|
||||
return new BigDecimal(micros).divide(MICROS).setScale(2, RoundingMode.HALF_EVEN).toString();
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 526 B |
After Width: | Height: | Size: 668 B |
After Width: | Height: | Size: 750 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 504 B |
After Width: | Height: | Size: 683 B |
After Width: | Height: | Size: 533 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 264 B |
After Width: | Height: | Size: 263 B |
After Width: | Height: | Size: 974 B |
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) Google
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="#1f000000">
|
||||
<item>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item
|
||||
android:state_enabled="false"
|
||||
android:state_focused="true"
|
||||
android:drawable="@drawable/pay_with_google_button_background_image_focused" />
|
||||
<item
|
||||
android:state_enabled="false"
|
||||
android:drawable="@drawable/pay_with_google_button_background_image" />
|
||||
<!-- Skipping state_pressed="true" because the ripple effect is sufficient feedback -->
|
||||
<item
|
||||
android:state_focused="true"
|
||||
android:drawable="@drawable/pay_with_google_button_background_image_focused" />
|
||||
<item
|
||||
android:drawable="@drawable/pay_with_google_button_background_image" />
|
||||
</selector>
|
||||
</item>
|
||||
</ripple>
|
||||
|
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="#1f000000">
|
||||
<item>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item
|
||||
android:state_enabled="false"
|
||||
android:state_focused="true"
|
||||
android:drawable="@drawable/pay_with_google_button_no_shadow_background_image_focused" />
|
||||
<item
|
||||
android:state_enabled="false"
|
||||
android:drawable="@drawable/pay_with_google_button_no_shadow_background_image" />
|
||||
<!-- Skipping state_pressed="true" because the ripple effect is sufficient feedback -->
|
||||
<item
|
||||
android:state_focused="true"
|
||||
android:drawable="@drawable/pay_with_google_button_no_shadow_background_image_focused" />
|
||||
<item
|
||||
android:drawable="@drawable/pay_with_google_button_no_shadow_background_image" />
|
||||
</selector>
|
||||
</item>
|
||||
</ripple>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 452 B |
After Width: | Height: | Size: 754 B |
After Width: | Height: | Size: 815 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 7.7 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 3.4 KiB |
BIN
app/src/main/res/drawable/bike.png
Normal file
After Width: | Height: | Size: 120 KiB |
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) Google
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item
|
||||
android:state_enabled="false"
|
||||
android:state_focused="true"
|
||||
android:drawable="@drawable/pay_with_google_button_background_image_focused" />
|
||||
<item
|
||||
android:state_enabled="false"
|
||||
android:drawable="@drawable/pay_with_google_button_background_image" />
|
||||
<item
|
||||
android:state_pressed="true"
|
||||
android:drawable="@drawable/pay_with_google_button_background_image_pressed" />
|
||||
<item
|
||||
android:state_focused="true"
|
||||
android:drawable="@drawable/pay_with_google_button_background_image_focused" />
|
||||
<item
|
||||
android:drawable="@drawable/pay_with_google_button_background_image" />
|
||||
</selector>
|
||||
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item
|
||||
android:state_enabled="false"
|
||||
android:state_focused="true"
|
||||
android:drawable="@drawable/pay_with_google_button_no_shadow_background_image_focused" />
|
||||
<item
|
||||
android:state_enabled="false"
|
||||
android:drawable="@drawable/pay_with_google_button_no_shadow_background_image" />
|
||||
<item
|
||||
android:state_pressed="true"
|
||||
android:drawable="@drawable/pay_with_google_button_no_shadow_background_image_pressed" />
|
||||
<item
|
||||
android:state_focused="true"
|
||||
android:drawable="@drawable/pay_with_google_button_no_shadow_background_image_focused" />
|
||||
<item
|
||||
android:drawable="@drawable/pay_with_google_button_no_shadow_background_image" />
|
||||
</selector>
|
||||
|
27
app/src/main/res/drawable/pay_with_google_button_overlay.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) Google
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:state_enabled="false">
|
||||
<shape
|
||||
android:shape="rectangle" >
|
||||
<corners android:radius="4dp"/>
|
||||
<solid android:color="#7FFFFFFF"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item android:drawable="@android:color/transparent" />
|
||||
</selector>
|
87
app/src/main/res/layout/activity_checkout.xml
Normal file
@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) Google
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:fillViewport="true"
|
||||
tools:context="com.google.android.gms.samples.wallet.CheckoutActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/padding_small"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_item_name"
|
||||
style="@android:style/TextAppearance.Large"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/padding_small" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/padding_small"
|
||||
android:minHeight="300dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_item_image"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:adjustViewBounds="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_item_price"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="@dimen/margin_xlarge">
|
||||
|
||||
<include
|
||||
android:id="@+id/pwg_button"
|
||||
layout="@layout/pay_with_google_button"
|
||||
android:layout_width="@dimen/buy_button_width"
|
||||
android:layout_height="@dimen/buy_button_height"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pwg_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:text="@string/pwg_status_checking" />
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
47
app/src/main/res/layout/pay_with_google_button.xml
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) Google
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48sp"
|
||||
android:background="@drawable/pay_with_google_button_background"
|
||||
android:padding="4dp"
|
||||
android:contentDescription="@string/pay_with_google_content_description">
|
||||
<LinearLayout
|
||||
android:duplicateParentState="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:weightSum="2"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
<ImageView
|
||||
android:layout_weight="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:duplicateParentState="true"
|
||||
android:src="@drawable/pay_with_google_button_content"/>
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitXY"
|
||||
android:duplicateParentState="true"
|
||||
android:src="@drawable/pay_with_google_button_overlay"/>
|
||||
</RelativeLayout>
|
46
app/src/main/res/layout/pay_with_google_button_no_shadow.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) Google
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40sp"
|
||||
android:background="@drawable/pay_with_google_button_no_shadow_background"
|
||||
android:contentDescription="@string/pay_with_google_content_description">
|
||||
<LinearLayout
|
||||
android:duplicateParentState="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:weightSum="2"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
<ImageView
|
||||
android:layout_weight="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:duplicateParentState="true"
|
||||
android:src="@drawable/pay_with_google_button_content"/>
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitXY"
|
||||
android:duplicateParentState="true"
|
||||
android:src="@drawable/pay_with_google_button_overlay"/>
|
||||
</RelativeLayout>
|
47
app/src/main/res/layout/pay_with_google_button_short.xml
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) Google
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48sp"
|
||||
android:background="@drawable/pay_with_google_button_background"
|
||||
android:padding="4dp"
|
||||
android:contentDescription="@string/pay_with_google_content_description">
|
||||
<LinearLayout
|
||||
android:duplicateParentState="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:weightSum="2"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
<ImageView
|
||||
android:layout_weight="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:duplicateParentState="true"
|
||||
android:src="@drawable/pay_with_google_button_short_content"/>
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitXY"
|
||||
android:duplicateParentState="true"
|
||||
android:src="@drawable/pay_with_google_button_overlay"/>
|
||||
</RelativeLayout>
|
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) Google
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40sp"
|
||||
android:background="@drawable/pay_with_google_button_no_shadow_background"
|
||||
android:contentDescription="@string/pay_with_google_content_description">
|
||||
<LinearLayout
|
||||
android:duplicateParentState="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:weightSum="2"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
<ImageView
|
||||
android:layout_weight="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:duplicateParentState="true"
|
||||
android:src="@drawable/pay_with_google_button_short_content"/>
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitXY"
|
||||
android:duplicateParentState="true"
|
||||
android:src="@drawable/pay_with_google_button_overlay"/>
|
||||
</RelativeLayout>
|
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 9.8 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 14 KiB |
28
app/src/main/res/values/dimens.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) Google
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<dimen name="padding_small">5dp</dimen>
|
||||
<dimen name="margin_large">10dp</dimen>
|
||||
<dimen name="margin_xlarge">30dp</dimen>
|
||||
|
||||
<dimen name="buy_button_width">300dp</dimen>
|
||||
<dimen name="buy_button_height">48sp</dimen>
|
||||
<dimen name="buy_button_min_width">200dp</dimen>
|
||||
|
||||
</resources>
|
20
app/src/main/res/values/pay_with_google_strings.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) Google
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<string name="pay_with_google_content_description">Pay with Google</string>
|
||||
</resources>
|
24
app/src/main/res/values/strings.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) Google
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<string name="app_name">My Online Store App</string>
|
||||
<string name="store_name">My Online Store</string>
|
||||
<string name="pwg_status_unavailable">Unfortunately, Pay with Google is not available on this phone.</string>
|
||||
<string name="pwg_status_checking">Checking if Pay with Google is available...</string>
|
||||
<string name="payments_show_name">Successfully received payment data for %s!</string>
|
||||
</resources>
|
25
build.gradle
Normal file
@ -0,0 +1,25 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.3.3'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenLocal()
|
||||
maven { url 'https://maven.google.com' }
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
17
gradle.properties
Normal file
@ -0,0 +1,17 @@
|
||||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
#Fri Sep 08 11:03:33 BST 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
|
160
gradlew
vendored
Executable file
@ -0,0 +1,160 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
90
gradlew.bat
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
1
settings.gradle
Normal file
@ -0,0 +1 @@
|
||||
include ':app'
|