use of com.globalcollect.gateway.sdk.client.android.sdk.manager.AssetManager in project connect-sdk-client-android by Ingenico-ePayments.
the class PaymentProductSelectionActivity method updateLogos.
private void updateLogos(Region region, EnvironmentType environment, List<BasicPaymentItem> basicPaymentItems) {
// if you want to specify the size of the logos you update, set resizedLogo to a size (width, height)
Size resizedLogo = new Size(100, 100);
// if you just want to get the default images, set
// resizedLogo = null;
AssetManager manager = AssetManager.getInstance(getApplicationContext());
manager.updateLogos(region, environment, basicPaymentItems, resizedLogo);
}
use of com.globalcollect.gateway.sdk.client.android.sdk.manager.AssetManager in project connect-sdk-client-android by Ingenico-ePayments.
the class DetailInputViewCreditCardImpl method renderCoBrandNotification.
@Override
public void renderCoBrandNotification(List<BasicPaymentItem> paymentProductsAllowedInContext, View.OnClickListener listener) {
// Show the user he can choose another cobrand if there are indeed more cobrands available
if (paymentProductsAllowedInContext.size() > 1) {
// Retrieve the logo from the top most PaymentProduct
AssetManager logoManager = AssetManager.getInstance(rootView.getContext().getApplicationContext());
coBrandRenderer.renderIinCoBrandNotification(rootView.getContext(), paymentProductsAllowedInContext, renderInputFieldsLayout, CREDIT_CARD_NUMBER_FIELD_ID, logoManager, listener);
}
}
use of com.globalcollect.gateway.sdk.client.android.sdk.manager.AssetManager in project connect-sdk-client-android by Ingenico-ePayments.
the class RenderAccountOnFile method renderAccountOnFile.
@SuppressWarnings("deprecation")
@Override
public void renderAccountOnFile(AccountOnFile accountOnFile, String productId, ViewGroup parent) {
if (accountOnFile == null) {
throw new InvalidParameterException("Error renderingAccountOnFile, accountOnFile may not be null");
}
if (productId == null) {
throw new InvalidParameterException("Error renderingAccountOnFile, productId may not be null");
}
if (parent == null) {
throw new InvalidParameterException("Error renderingAccountOnFile, parent may not be null");
}
// Inflate the activity_select_payment_product_render layout
LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View paymentProductLayout = inflater.inflate(R.layout.activity_render_payment_product, parent, false);
// Set the belonging accountOnFile on the tag of the row so we can retrieve it when clicked
paymentProductLayout.findViewById(R.id.paymentProductRow).setTag(accountOnFile);
// Get the TextView and ImageView which will be filled
TextView accountOnFileTextView = (TextView) paymentProductLayout.findViewById(R.id.paymentProductName);
ImageView accountOnFileLogoImageView = (ImageView) paymentProductLayout.findViewById(R.id.paymentProductLogo);
// Set the correct value
String formattedValue = null;
for (KeyValuePair attribute : accountOnFile.getAttributes()) {
for (AccountOnFileDisplay displayEntry : accountOnFile.getDisplayHints().getLabelTemplate()) {
if (attribute.getKey().equals(displayEntry.getKey())) {
// Format the value if there is a mask in the accountonfile text
if (displayEntry.getMask() != null) {
StringFormatter stringFormatter = new StringFormatter();
String maskedValue = stringFormatter.applyMask(displayEntry.getMask().replace("9", "*"), attribute.getValue());
formattedValue = maskedValue;
} else {
formattedValue = attribute.getValue();
}
}
}
}
accountOnFileTextView.setText(formattedValue);
// Set the logo via the AssetManager
AssetManager logoManager = AssetManager.getInstance(parent.getContext());
Drawable logo = logoManager.getLogo(productId);
if (Build.VERSION.SDK_INT < 16) {
accountOnFileLogoImageView.setBackgroundDrawable(logo);
} else {
accountOnFileLogoImageView.setBackground(logo);
}
parent.addView(paymentProductLayout);
}
use of com.globalcollect.gateway.sdk.client.android.sdk.manager.AssetManager in project connect-sdk-client-android by Ingenico-ePayments.
the class DetailInputViewCreditCardImpl method renderPaymentProductLogoInCreditCardField.
@Override
public void renderPaymentProductLogoInCreditCardField(String productId) {
// Retrieve the logo from the top most PaymentProduct
AssetManager logoManager = AssetManager.getInstance(rootView.getContext().getApplicationContext());
// Get the logo from backgroundimage
BitmapDrawable drawable = (BitmapDrawable) logoManager.getLogo(productId);
if (drawable != null) {
int scaledHeight = (int) creditCardField.getTextSize();
int scaledWidth = (int) (drawable.getIntrinsicWidth() * ((double) scaledHeight / (double) drawable.getIntrinsicHeight()));
Bitmap resizedBitmap = Bitmap.createScaledBitmap(drawable.getBitmap(), scaledWidth, scaledHeight, true);
Drawable resizedDrawable = new BitmapDrawable(rootView.getContext().getResources(), resizedBitmap);
// Set compoundDrawables allow you to place a image at a certain position
creditCardField.setCompoundDrawablesWithIntrinsicBounds(null, null, resizedDrawable, null);
}
}
use of com.globalcollect.gateway.sdk.client.android.sdk.manager.AssetManager in project connect-sdk-client-android by Ingenico-ePayments.
the class C2sCommunicator method getBasicPaymentProducts.
/**
* Retrieves a list of basicpaymentproducts from the GC gateway without any fields
*
* @param context, used for reading device metadata which is send to the GC gateway
* @param paymentContext, payment information that is used to retrieve the correct payment products
*
* @return list of BasicPaymentProducts, or null when an error has occured
*/
public BasicPaymentProducts getBasicPaymentProducts(PaymentContext paymentContext, Context context) {
if (paymentContext == null) {
throw new InvalidParameterException("Error getting BasicPaymentProducts, request may not be null");
}
HttpURLConnection connection = null;
try {
// Build the complete url which is called
String baseUrl = configuration.getBaseUrl();
String paymentProductPath = Constants.GC_GATEWAY_RETRIEVE_PAYMENTPRODUCTS_PATH.replace("[cid]", configuration.getCustomerId());
String completePath = baseUrl + paymentProductPath;
// Add query parameters
StringBuilder queryString = new StringBuilder();
queryString.append("?countryCode=").append(paymentContext.getCountryCode());
queryString.append("&amount=").append(paymentContext.getAmountOfMoney().getAmount());
queryString.append("&isRecurring=").append(paymentContext.isRecurring());
queryString.append("¤cyCode=").append(paymentContext.getAmountOfMoney().getCurrencyCode());
queryString.append("&hide=fields");
queryString.append("&").append(createCacheBusterParameter());
// Add query string to complete path
completePath += queryString.toString();
// Do the call and deserialise the result to BasicPaymentProducts
connection = doHTTPGetRequest(completePath, configuration.getClientSessionId(), configuration.getMetadata(context));
String responseBody = new Scanner(connection.getInputStream(), "UTF-8").useDelimiter("\\A").next();
// Log the response
if (Constants.ENABLE_REQUEST_LOGGING) {
logResponse(connection, responseBody);
}
BasicPaymentProducts basicPaymentProducts = gson.fromJson(responseBody, BasicPaymentProducts.class);
// Set the logos for all paymentproducts
for (BasicPaymentProduct paymentProduct : basicPaymentProducts.getBasicPaymentProducts()) {
AssetManager manager = AssetManager.getInstance(context);
Drawable logo = manager.getLogo(paymentProduct.getId());
paymentProduct.getDisplayHints().setLogo(logo);
}
return basicPaymentProducts;
} catch (CommunicationException e) {
Log.i(TAG, "Error while getting paymentproducts:" + e.getMessage());
return null;
} catch (Exception e) {
Log.i(TAG, "Error while getting paymentproducts:" + e.getMessage());
return null;
} finally {
try {
if (connection != null) {
connection.getInputStream().close();
connection.disconnect();
}
} catch (IOException e) {
Log.i(TAG, "Error while getting paymentproducts:" + e.getMessage());
}
}
}
Aggregations