use of com.example.clown.utilities.PreferenceManager in project Skool by NhatTruongK15.
the class SignInActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
launcher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback<ActivityResult>() {
@Override
public void onActivityResult(ActivityResult result) {
}
});
preferenceManager = new PreferenceManager(getApplicationContext());
// check if we've already logined
if (preferenceManager.getBoolean(Constants.KEY_IS_SIGNED_IN)) {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
finish();
}
binding = ActivitySignInBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
setListener();
}
use of com.example.clown.utilities.PreferenceManager in project Skool by NhatTruongK15.
the class SignUpActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
final String TAG = "mCallBack";
super.onCreate(savedInstanceState);
binding = ActivitySignUpBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
preferenceManager = new PreferenceManager(getApplicationContext());
mAuth = FirebaseAuth.getInstance();
// set up mCallback
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);
signInWithPhoneAuthCredential(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.userInfoLayout.setVisibility(View.GONE);
binding.resendContent.setText("didn't see smsCode?");
binding.verificationCodeEditText.setHint("Please enter your smsCode we sent \n +84" + binding.inputPhoneNumb.getText().subSequence(1, binding.inputPhoneNumb.getText().length()));
}
};
// set up progressdialog
pd = new ProgressDialog(this);
pd.setTitle("Please wait...");
pd.setCanceledOnTouchOutside(false);
// setup view
binding.verificationLayout.setVisibility(View.GONE);
binding.userInfoLayout.setVisibility(View.VISIBLE);
// listener
setListener();
}
use of com.example.clown.utilities.PreferenceManager in project Skool by NhatTruongK15.
the class ChatActivity method init.
private void init() {
preferenceManager = new PreferenceManager(getApplicationContext());
chatMessages = new ArrayList<>();
chatAdapter = new ChatAdapter(chatMessages, preferenceManager.getString(Constants.KEY_DOCUMENT_REFERENCE_ID), getBitmapFromEncodeString(receiverUser.image));
binding.chatRecyclerView.setAdapter(chatAdapter);
database = FirebaseFirestore.getInstance();
}
use of com.example.clown.utilities.PreferenceManager in project Skool by NhatTruongK15.
the class GroupActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_group);
binding = ActivityGroupBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
preferenceManager = new PreferenceManager(getApplicationContext());
setListener();
}
use of com.example.clown.utilities.PreferenceManager in project Skool by NhatTruongK15.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
preferenceManager = new PreferenceManager(getApplicationContext());
init();
loadUserDetails();
getToken();
setListener();
listenConversation();
}
Aggregations