Skip to content

Commit

Permalink
Version 4.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
samtstern authored Mar 26, 2019
2 parents 610d9f3 + ca22ae6 commit 3a24b1d
Show file tree
Hide file tree
Showing 99 changed files with 500 additions and 469 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ libraries.
```groovy
dependencies {
// FirebaseUI for Firebase Realtime Database
implementation 'com.firebaseui:firebase-ui-database:4.3.1'
implementation 'com.firebaseui:firebase-ui-database:4.3.2'
// FirebaseUI for Cloud Firestore
implementation 'com.firebaseui:firebase-ui-firestore:4.3.1'
implementation 'com.firebaseui:firebase-ui-firestore:4.3.2'
// FirebaseUI for Firebase Auth
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
implementation 'com.firebaseui:firebase-ui-auth:4.3.2'
// FirebaseUI for Firebase Auth (GitHub provider)
implementation 'com.firebaseui:firebase-ui-auth-github:4.3.1'
implementation 'com.firebaseui:firebase-ui-auth-github:4.3.2'
// FirebaseUI for Cloud Storage
implementation 'com.firebaseui:firebase-ui-storage:4.3.1'
implementation 'com.firebaseui:firebase-ui-storage:4.3.2'
}
```

Expand Down
4 changes: 2 additions & 2 deletions auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ Gradle, add the dependency:
```groovy
dependencies {
// ...
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
implementation 'com.firebaseui:firebase-ui-auth:4.3.2'
// Required only if GitHub OAuth support is required
implementation 'com.firebaseui:firebase-ui-auth-github:4.3.1'
implementation 'com.firebaseui:firebase-ui-auth-github:4.3.2'
// Required only if Facebook login support is required
// Find the latest Facebook SDK releases here: https://goo.gl/Ce5L94
Expand Down
22 changes: 1 addition & 21 deletions auth/src/main/java/com/firebase/ui/auth/KickoffActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.arch.lifecycle.ViewModelProviders;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
Expand Down Expand Up @@ -62,12 +61,7 @@ public void onSuccess(Void aVoid) {
return;
}

if (isOffline()) {
finish(RESULT_CANCELED, IdpResponse.getErrorIntent(
new FirebaseUiException(ErrorCodes.NO_NETWORK)));
} else {
mKickstarter.start();
}
mKickstarter.start();
}
})
.addOnFailureListener(this, new OnFailureListener() {
Expand Down Expand Up @@ -98,18 +92,4 @@ public void invalidateEmailLink() {
setIntent(getIntent().putExtra(ExtraConstants.FLOW_PARAMS,
flowParameters));
}

/**
* Check if there is an active or soon-to-be-active network connection.
*
* @return true if there is no network connection, false otherwise.
*/
private boolean isOffline() {
ConnectivityManager manager = (ConnectivityManager) getApplicationContext()
.getSystemService(Context.CONNECTIVITY_SERVICE);

return !(manager != null
&& manager.getActiveNetworkInfo() != null
&& manager.getActiveNetworkInfo().isConnectedOrConnecting());
}
}
15 changes: 15 additions & 0 deletions auth/src/main/java/com/firebase/ui/auth/ui/HelperActivityBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;
Expand Down Expand Up @@ -75,4 +76,18 @@ public void startSaveCredentials(
this, getFlowParams(), credential, response);
startActivityForResult(intent, RequestCodes.CRED_SAVE_FLOW);
}

/**
* Check if there is an active or soon-to-be-active network connection.
*
* @return true if there is no network connection, false otherwise.
*/
protected boolean isOffline() {
ConnectivityManager manager = (ConnectivityManager) getApplicationContext()
.getSystemService(Context.CONNECTIVITY_SERVICE);

return !(manager != null
&& manager.getActiveNetworkInfo() != null
&& manager.getActiveNetworkInfo().isConnectedOrConnecting());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,16 @@ protected void onFailure(@NonNull Exception e) {

@Override
public void onClick(View view) {
if (view.getId() == R.id.button_done
&& mEmailFieldValidator.validate(mEmailEditText.getText())) {
if (view.getId() == R.id.button_done) {
onDonePressed();
}
}

@Override
public void onDonePressed() {
mHandler.startReset(mEmailEditText.getText().toString());
if (mEmailFieldValidator.validate(mEmailEditText.getText())) {
mHandler.startReset(mEmailEditText.getText().toString());
}
}

private void showEmailSentDialog(String email) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ private void handleResponse(@NonNull IdpResponse response) {
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (isOffline()) {
Toast.makeText(AuthMethodPickerActivity.this, getString(R.string.fui_no_internet), Toast.LENGTH_SHORT).show();
return;
}

provider.startSignIn(AuthMethodPickerActivity.this);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mVerificationHandler = ViewModelProviders.of(requireActivity())
.get(PhoneNumberVerificationHandler.class);
mCheckPhoneHandler = ViewModelProviders.of(requireActivity())
mCheckPhoneHandler = ViewModelProviders.of(this)
.get(CheckPhoneHandler.class);
}

Expand Down Expand Up @@ -124,6 +124,9 @@ protected void onFailure(@NonNull Exception e) {
// Fragment back stacks are the stuff of nightmares (what's new?): the fragment isn't
// destroyed so its state isn't saved and we have to rely on an instance field. Sigh.
mCalled = true;

// DON'T REMOVE
setDefaultCountryForSpinner();
}

@Override
Expand Down Expand Up @@ -202,8 +205,6 @@ private void setupCountrySpinner() {
Bundle params = getArguments().getBundle(ExtraConstants.PARAMS);
mCountryListSpinner.init(params);

setDefaultCountryForSpinner();

// Clear error when spinner is clicked on
mCountryListSpinner.setOnClickListener(new View.OnClickListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;
import android.support.design.widget.TextInputLayout;
import android.support.v4.app.FragmentManager;
import android.widget.Toast;

import com.firebase.ui.auth.ErrorCodes;
Expand Down Expand Up @@ -83,7 +84,18 @@ protected void onFailure(@NonNull Exception e) {
protected void onSuccess(@NonNull PhoneVerification verification) {
if (verification.isAutoVerified()) {
Toast.makeText(
PhoneActivity.this, R.string.fui_auto_verified, Toast.LENGTH_LONG).show();
PhoneActivity.this,
R.string.fui_auto_verified,
Toast.LENGTH_LONG
).show();

FragmentManager manager = getSupportFragmentManager();
if (manager.findFragmentByTag(SubmitConfirmationCodeFragment.TAG) != null) {
// Ensure the submit code screen isn't visible if there's no code to submit.
// It's possible to get into this state when an SMS is sent, but then
// automatically retrieved.
manager.popBackStack();
}
}

handler.startSignIn(verification.getCredential(), new IdpResponse.Builder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,45 @@

package com.firebase.ui.auth.ui.phone;

import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.firebase.ui.auth.IdpResponse;
import com.firebase.ui.auth.R;
import com.firebase.ui.auth.data.model.Resource;
import com.firebase.ui.auth.data.model.State;
import com.firebase.ui.auth.ui.FragmentBase;
import com.firebase.ui.auth.util.ExtraConstants;
import com.firebase.ui.auth.util.data.PrivacyDisclosureUtils;
import com.firebase.ui.auth.util.ui.BucketedTextChangeListener;
import com.firebase.ui.auth.util.ui.ImeHelper;
import com.firebase.ui.auth.viewmodel.phone.PhoneProviderResponseHandler;

import java.util.concurrent.TimeUnit;

/**
* Display confirmation code to verify phone numbers input in {{@link CheckPhoneNumberFragment}}
* Display confirmation code to verify phone numbers input in {@link CheckPhoneNumberFragment}
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public class SubmitConfirmationCodeFragment extends FragmentBase {

public static final String TAG = "SubmitConfirmationCodeFragment";

private static final int VERIFICATION_CODE_LENGTH = 6;
private static final long RESEND_WAIT_MILLIS = 15000;
private static final long TICK_INTERVAL_MILLIS = 500;
private static final String EXTRA_MILLIS_UNTIL_FINISHED = "millis_until_finished";
Expand All @@ -66,9 +73,10 @@ public void run() {
private TextView mResendCodeTextView;
private TextView mCountDownTextView;
private SpacedEditText mConfirmationCodeEditText;
private Button mSubmitConfirmationButton;
private long mMillisUntilFinished = RESEND_WAIT_MILLIS;

private boolean mHasResumed;

public static SubmitConfirmationCodeFragment newInstance(String phoneNumber) {
SubmitConfirmationCodeFragment fragment = new SubmitConfirmationCodeFragment();
Bundle args = new Bundle();
Expand Down Expand Up @@ -103,11 +111,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
mCountDownTextView = view.findViewById(R.id.ticker);
mResendCodeTextView = view.findViewById(R.id.resend_code);
mConfirmationCodeEditText = view.findViewById(R.id.confirmation_code);
mSubmitConfirmationButton = view.findViewById(R.id.submit_confirmation_code);

requireActivity().setTitle(getString(R.string.fui_verify_your_phone_title));
processCountdownTick();
setupSubmitConfirmationButton();
setupConfirmationCodeEditText();
setupEditPhoneNumberTextView();
setupResendConfirmationCodeTextView();
Expand All @@ -117,6 +123,22 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
view.<TextView>findViewById(R.id.email_footer_tos_and_pp_text));
}

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ViewModelProviders.of(requireActivity())
.get(PhoneProviderResponseHandler.class)
.getOperation()
.observe(this, new Observer<Resource<IdpResponse>>() {
@Override
public void onChanged(@Nullable Resource<IdpResponse> resource) {
if (resource.getState() == State.FAILURE) {
mConfirmationCodeEditText.setText("");
}
}
});
}

@Override
public void onStart() {
super.onStart();
Expand All @@ -125,6 +147,32 @@ public void onStart() {
.showSoftInput(mConfirmationCodeEditText, 0);
}

@Override
public void onResume() {
super.onResume();
if (!mHasResumed) {
// Don't check for codes before we've even had the chance to send one.
mHasResumed = true;
return;
}

ClipData clip = ContextCompat.getSystemService(requireContext(), ClipboardManager.class)
.getPrimaryClip();
if (clip != null && clip.getItemCount() == 1) {
CharSequence candidate = clip.getItemAt(0).getText();
if (candidate != null && candidate.length() == VERIFICATION_CODE_LENGTH) {
try {
Integer.parseInt(candidate.toString());

// We have a number! Try to submit it.
mConfirmationCodeEditText.setText(candidate);
} catch (NumberFormatException ignored) {
// Turns out it wasn't a number
}
}
}
}

@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
mLooper.removeCallbacks(mCountdown);
Expand All @@ -139,41 +187,19 @@ public void onDestroy() {
mLooper.removeCallbacks(mCountdown);
}

private void setupSubmitConfirmationButton() {
mSubmitConfirmationButton.setEnabled(false);
mSubmitConfirmationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
submitCode();
}
});
}

private void setupConfirmationCodeEditText() {
mConfirmationCodeEditText.setText("------");
mConfirmationCodeEditText.addTextChangedListener(new BucketedTextChangeListener(
mConfirmationCodeEditText, 6, "-",
mConfirmationCodeEditText, VERIFICATION_CODE_LENGTH, "-",
new BucketedTextChangeListener.ContentChangeCallback() {
@Override
public void whileComplete() {
mSubmitConfirmationButton.setEnabled(true);
public void whenComplete() {
submitCode();
}

@Override
public void whileIncomplete() {
mSubmitConfirmationButton.setEnabled(false);
}
public void whileIncomplete() {}
}));

ImeHelper.setImeOnDoneListener(mConfirmationCodeEditText,
new ImeHelper.DonePressedListener() {
@Override
public void onDonePressed() {
if (mSubmitConfirmationButton.isEnabled()) {
submitCode();
}
}
});
}

private void setupEditPhoneNumberTextView() {
Expand Down Expand Up @@ -222,13 +248,11 @@ private void submitCode() {

@Override
public void showProgress(int message) {
mSubmitConfirmationButton.setEnabled(false);
mProgressBar.setVisibility(View.VISIBLE);
}

@Override
public void hideProgress() {
mSubmitConfirmationButton.setEnabled(true);
mProgressBar.setVisibility(View.INVISIBLE);
}
}
Loading

0 comments on commit 3a24b1d

Please sign in to comment.