Search in sources :

Example 6 with PreferenceManager

use of com.example.clown.utilities.PreferenceManager in project Skool by NhatTruongK15.

the class BaseActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferenceManager preferenceManager = new PreferenceManager(getApplicationContext());
    FirebaseFirestore database = FirebaseFirestore.getInstance();
    documentReference = database.collection(Constants.KEY_COLLECTION_USERS).document(preferenceManager.getString(Constants.KEY_DOCUMENT_REFERENCE_ID));
}
Also used : FirebaseFirestore(com.google.firebase.firestore.FirebaseFirestore) PreferenceManager(com.example.clown.utilities.PreferenceManager)

Example 7 with PreferenceManager

use of com.example.clown.utilities.PreferenceManager in project Skool by NhatTruongK15.

the class GroupChatActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_group_chat);
    binding = ActivityGroupChatBinding.inflate(getLayoutInflater());
    setContentView(binding.getRoot());
    preferenceManager = new PreferenceManager(getApplicationContext());
    getUsers();
    setListener();
}
Also used : PreferenceManager(com.example.clown.utilities.PreferenceManager)

Example 8 with PreferenceManager

use of com.example.clown.utilities.PreferenceManager in project Skool by NhatTruongK15.

the class ResetPasswordActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = ActivityResetPasswordBinding.inflate(getLayoutInflater());
    preferenceManager = new PreferenceManager(getApplicationContext());
    // set up progressdialog
    pd = new ProgressDialog(this);
    pd.setTitle("Please wait...");
    pd.setCanceledOnTouchOutside(false);
    final String TAG = "onCodeSent";
    // set up ui
    binding.waitForEnteringPhoneNumberLayout.setVisibility(View.VISIBLE);
    binding.verificationLayout.setVisibility(View.GONE);
    setContentView(binding.getRoot());
    mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {

        @Override
        public void onVerificationCompleted(PhoneAuthCredential credential) {
            // This callback will be invoked in two situations:
            // 1 - Instant verification. In some cases the phone number can be instantly
            // verified without needing to send or enter a verification code.
            // 2 - Auto-retrieval. On some devices Google Play services can automatically
            // detect the incoming verification SMS and perform verification without
            // user action.
            Log.d(TAG, "onVerificationCompleted:" + credential);
            ResetPhoneAuthCredential(credential);
        }

        @Override
        public void onVerificationFailed(FirebaseException e) {
            // This callback is invoked in an invalid request for verification is made,
            // for instance if the the phone number format is not valid.
            Log.w(TAG, "onVerificationFailed", e);
            if (e instanceof FirebaseAuthInvalidCredentialsException) {
            // Invalid request
            } else if (e instanceof FirebaseTooManyRequestsException) {
            // The SMS quota for the project has been exceeded
            }
        // Show a message and update the UI
        }

        @Override
        public void onCodeSent(@NonNull String verificationId, @NonNull PhoneAuthProvider.ForceResendingToken token) {
            // The SMS verification code has been sent to the provided phone number, we
            // now need to ask the user to enter the code and then construct a credential
            // by combining the code with a verification ID.
            Log.d(TAG, "onCodeSent:" + verificationId);
            // Save verification ID and resending token so we can use them later
            mVerificationId = verificationId;
            mResendToken = token;
            pd.dismiss();
            binding.verificationLayout.setVisibility(View.VISIBLE);
            binding.waitForEnteringPhoneNumberLayout.setVisibility(View.GONE);
        }
    };
    setListener();
}
Also used : FirebaseException(com.google.firebase.FirebaseException) FirebaseTooManyRequestsException(com.google.firebase.FirebaseTooManyRequestsException) FirebaseAuthInvalidCredentialsException(com.google.firebase.auth.FirebaseAuthInvalidCredentialsException) PhoneAuthCredential(com.google.firebase.auth.PhoneAuthCredential) PhoneAuthProvider(com.google.firebase.auth.PhoneAuthProvider) ProgressDialog(android.app.ProgressDialog) PreferenceManager(com.example.clown.utilities.PreferenceManager)

Example 9 with PreferenceManager

use of com.example.clown.utilities.PreferenceManager in project Skool by NhatTruongK15.

the class UsersActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = ActivityUsersBinding.inflate(getLayoutInflater());
    setContentView(binding.getRoot());
    preferenceManager = new PreferenceManager(getApplicationContext());
    setListener();
    getUsers();
}
Also used : PreferenceManager(com.example.clown.utilities.PreferenceManager)

Aggregations

PreferenceManager (com.example.clown.utilities.PreferenceManager)9 ProgressDialog (android.app.ProgressDialog)2 FirebaseException (com.google.firebase.FirebaseException)2 FirebaseTooManyRequestsException (com.google.firebase.FirebaseTooManyRequestsException)2 FirebaseAuthInvalidCredentialsException (com.google.firebase.auth.FirebaseAuthInvalidCredentialsException)2 PhoneAuthCredential (com.google.firebase.auth.PhoneAuthCredential)2 PhoneAuthProvider (com.google.firebase.auth.PhoneAuthProvider)2 Intent (android.content.Intent)1 ActivityResult (androidx.activity.result.ActivityResult)1 ActivityResultCallback (androidx.activity.result.ActivityResultCallback)1 ChatAdapter (com.example.clown.adapter.ChatAdapter)1 FirebaseFirestore (com.google.firebase.firestore.FirebaseFirestore)1