-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
1,337 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/src/main/java/dk/adamino/rehabilitation/Callbacks/IFirebaseAuthenticationCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package dk.adamino.rehabilitation.Callbacks; | ||
|
||
/** | ||
* Created by Adamino. | ||
*/ | ||
public interface IFirebaseAuthenticationCallback { | ||
|
||
/*** | ||
* Handle client uid from login | ||
* @param clientUid | ||
*/ | ||
void onClientLoggedIn(String clientUid); | ||
|
||
/** | ||
* Handle failed login | ||
* @param error | ||
*/ | ||
void onFailedLogin(String error); | ||
} |
44 changes: 44 additions & 0 deletions
44
app/src/main/java/dk/adamino/rehabilitation/DAL/FirebaseAuthenticate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package dk.adamino.rehabilitation.DAL; | ||
|
||
import android.support.annotation.NonNull; | ||
|
||
import com.google.android.gms.tasks.OnCompleteListener; | ||
import com.google.android.gms.tasks.Task; | ||
import com.google.firebase.auth.AuthResult; | ||
import com.google.firebase.auth.FirebaseAuth; | ||
|
||
import dk.adamino.rehabilitation.Callbacks.IFirebaseAuthenticationCallback; | ||
|
||
/** | ||
* Created by Adamino. | ||
*/ | ||
public class FirebaseAuthenticate implements IFirebaseAuthenticate { | ||
|
||
private static final String TAG = "FirebaseAuth"; | ||
|
||
private FirebaseAuth mAuth; | ||
|
||
public FirebaseAuthenticate() { | ||
mAuth = FirebaseAuth.getInstance(); | ||
} | ||
|
||
@Override | ||
public void signInWithEmailAndPassword(String email, String password, final IFirebaseAuthenticationCallback callback) { | ||
mAuth.signInWithEmailAndPassword(email, password) | ||
.addOnCompleteListener(new OnCompleteListener<AuthResult>() { | ||
@Override | ||
public void onComplete(@NonNull Task<AuthResult> task) { | ||
if (task.isSuccessful()) { | ||
callback.onClientLoggedIn(mAuth.getCurrentUser().getUid()); | ||
} else { | ||
callback.onFailedLogin(task.getException().getMessage()); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void signout() { | ||
mAuth.signOut(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
app/src/main/java/dk/adamino/rehabilitation/DAL/IFirebaseAuthenticate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package dk.adamino.rehabilitation.DAL; | ||
|
||
import dk.adamino.rehabilitation.Callbacks.IFirebaseAuthenticationCallback; | ||
|
||
/** | ||
* Created by Adamino. | ||
*/ | ||
public interface IFirebaseAuthenticate { | ||
|
||
/*** | ||
* Sign in with provided email and password | ||
* @param email | ||
* @param password | ||
* @param callback | ||
*/ | ||
void signInWithEmailAndPassword(String email, String password, IFirebaseAuthenticationCallback callback); | ||
|
||
/** | ||
* Signout client | ||
*/ | ||
void signout(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.