Skip to content

Commit

Permalink
Setup With FragmentActivity (#109)
Browse files Browse the repository at this point in the history
* Change setup method to take FragmentActivity and add local release task for testing

Signed-off-by: Sarah Koop <skoop@paypal.com>

* Add CardForm#setup(FragmentActivity) overload.

Signed-off-by: Steven Shropshire <steven.shropshire@getbraintree.com>

* Update CHANGELOG.

Signed-off-by: Steven Shropshire <steven.shropshire@getbraintree.com>

* Re-format CHANGELOG.

Co-authored-by: Steven Shropshire <steven.shropshire@getbraintree.com>
Co-authored-by: Steven <sshropshire@paypal.com>
  • Loading branch information
3 people authored Jul 9, 2021
1 parent 380eac0 commit 8110aed
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## unreleased
* Increase valid Discover card length to 19 digits
* Add `CardForm#setup(FragmentActivity)` overload

## 5.1.1
* Validate Cardholder Name field to prevent sensitive data from being input
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.braintreepayments.cardform.view;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build.VERSION_CODES;
import androidx.annotation.DrawableRes;
import androidx.annotation.IntDef;
Expand Down Expand Up @@ -40,6 +37,7 @@
import java.util.List;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentActivity;

public class CardForm extends LinearLayout implements OnCardTypeChangedListener, OnFocusChangeListener, OnClickListener,
OnEditorActionListener, TextWatcher {
Expand Down Expand Up @@ -265,12 +263,23 @@ public CardForm saveCardCheckBoxChecked(boolean checked) {

/**
* Sets up the card form for display to the user using the values provided in {@link CardForm#cardRequired(boolean)},
* {@link CardForm#expirationRequired(boolean)}, ect. If {@link CardForm#setup(AppCompatActivity)} is not called,
* the form will not be visible.
* {@link CardForm#expirationRequired(boolean)}, ect. If {@link CardForm#setup(AppCompatActivity)}
* or {@link CardForm#setup(FragmentActivity)} is not called, the form will not be visible.
*
* @param activity Used to set {@link android.view.WindowManager.LayoutParams#FLAG_SECURE} to prevent screenshots
* @param activity Used to set {@link WindowManager.LayoutParams#FLAG_SECURE} to prevent screenshots
*/
public void setup(AppCompatActivity activity) {
setup((FragmentActivity) activity);
}

/**
* Sets up the card form for display to the user using the values provided in {@link CardForm#cardRequired(boolean)},
* {@link CardForm#expirationRequired(boolean)}, ect. If {@link CardForm#setup(AppCompatActivity)}
* or {@link CardForm#setup(FragmentActivity)} is not called, the form will not be visible.
*
* @param activity Used to set {@link WindowManager.LayoutParams#FLAG_SECURE} to prevent screenshots
*/
public void setup(FragmentActivity activity) {
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
WindowManager.LayoutParams.FLAG_SECURE);

Expand Down
5 changes: 5 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ task :integration_tests do
end
end

desc "Interactive release to publish new version to maven local"
task :release_local do
sh "./gradlew clean publishToMavenLocal"
end

desc "Interactive release to publish new version"
task :release => :unit_tests do
Rake::Task["assumptions"].invoke
Expand Down

0 comments on commit 8110aed

Please sign in to comment.