Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

From Api branchto test #433

Open
wants to merge 62 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
b4bb547
Merge pull request #7 from hngi/develop
JennySimen Jul 10, 2020
5b92245
Created the memories tab on the side nav bar and also created the xml…
JennySimen Jul 11, 2020
d3f7a22
fix: changed login and sign up xml to use color resource for dark mode
dapoanjorin Jul 12, 2020
5c88014
Update signup.xml
Michaelzy27 Jul 13, 2020
0d53a7f
Merge pull request #407 from Michaelzy27/develop
Michaelzy27 Jul 13, 2020
92b4014
Merge pull request #406 from dapoanjorin/develop
Michaelzy27 Jul 13, 2020
a54ff87
Pull From Develop
DevAdedoyin Jul 13, 2020
1438a58
Merge pull request #8 from hngi/develop
JennySimen Jul 14, 2020
48c7a0c
Created the memories tab on the side nav bar and also created the xml…
JennySimen Jul 14, 2020
b45a09b
Merge remote-tracking branch 'remotes/upstream/develop' into develop
JennySimen Jul 14, 2020
3230afd
Merge remote-tracking branch 'remotes/origin/develop' into develop
JennySimen Jul 14, 2020
0c14fda
Merge pull request #10 from allenbangai/test
allenbangai Jul 15, 2020
4f0832f
Merge pull request #410 from JennySimen/develop
Michaelzy27 Jul 15, 2020
5928532
Adjusted the designs for the dialog box in memories also created the…
JennySimen Jul 15, 2020
9968d2b
Merge pull request #12 from hngi/test
Michaelzy27 Jul 15, 2020
9b06ec4
Merge pull request #412 from JennySimen/develop
Michaelzy27 Jul 15, 2020
34ca62f
Merge pull request #13 from hngi/test
Michaelzy27 Jul 15, 2020
4ced481
Add review feature
Michaelzy27 Jul 16, 2020
6f3176a
Merge pull request #413 from Michaelzy27/develop
Michaelzy27 Jul 16, 2020
1da7e44
Merge pull request #414 from allenbangai/allenkamadje
allenbangai Jul 16, 2020
463ba60
Update on Memories.java
comfort4447 Jul 17, 2020
08c512c
Update on MyCustomDialog.xml
comfort4447 Jul 17, 2020
c5667a8
Update on Fragmentmemories.xml
comfort4447 Jul 17, 2020
2a8e458
Update on MyCustomDialog.java so as to save and retrieve on Shared pr…
comfort4447 Jul 17, 2020
6acc64e
Merge pull request #415 from comfort4447/test
Michaelzy27 Jul 17, 2020
0511721
Merge pull request #417 from hngi/test
Michaelzy27 Jul 17, 2020
662aa3d
api authentication
yetundeolubola Jul 17, 2020
f4d7001
Merge pull request #418 from yetundeolubola/auth
Michaelzy27 Jul 17, 2020
f32f2c9
Merge pull request #14 from hngi/ApiBranch
Michaelzy27 Jul 17, 2020
25eb31a
API SIGNUP fix
Michaelzy27 Jul 17, 2020
49a2b1b
Merge pull request #419 from Michaelzy27/develop
Michaelzy27 Jul 17, 2020
834050d
Login API fix
Michaelzy27 Jul 17, 2020
3cb780a
Merge pull request #420 from Michaelzy27/develop
Michaelzy27 Jul 17, 2020
2a4f993
Populating Popular Destination, Popular Destination Detail Overview A…
DevAdedoyin Jul 17, 2020
46686d6
fit log bug
yetundeolubola Jul 17, 2020
c2040f9
Merge pull request #422 from yetundeolubola/ApiBranch
Michaelzy27 Jul 17, 2020
a97f984
Merge pull request #15 from hngi/ApiBranch
Michaelzy27 Jul 17, 2020
8d9664e
Crash fix
Michaelzy27 Jul 17, 2020
79bcf57
Merge pull request #423 from Michaelzy27/develop
Michaelzy27 Jul 17, 2020
5bbef2e
Big fix
Michaelzy27 Jul 17, 2020
7f375c5
Populating Popular Destination, Popular Destination Detail Overview A…
DevAdedoyin Jul 17, 2020
6cd493f
Populating Popular Destination, Popular Destination Detail Overview A…
DevAdedoyin Jul 17, 2020
8dad9f0
Merge pull request #424 from Michaelzy27/develop
Michaelzy27 Jul 17, 2020
5a2fd1c
Populating Popular Destination, Popular Destination Detail Overview A…
DevAdedoyin Jul 17, 2020
1da7b90
Merge branch 'ApiBranch' of https://github.com/hngi/mobileforce-afriv…
DevAdedoyin Jul 17, 2020
bd6770e
Send Review
Michaelzy27 Jul 17, 2020
e3340cb
Merge pull request #425 from Michaelzy27/develop
Michaelzy27 Jul 17, 2020
ddc4c0f
Populating Popular Destination, Popular Destination Detail Overview A…
DevAdedoyin Jul 17, 2020
304547d
Memories fragment
Michaelzy27 Jul 18, 2020
93a8b77
Populating Popular Destination, Popular Destination Detail Overview A…
DevAdedoyin Jul 18, 2020
4515a3b
bug fix
Michaelzy27 Jul 18, 2020
c52d3fe
Merge pull request #427 from DevAdedoyin/Adedoyin
Michaelzy27 Jul 18, 2020
eb5c87d
Merge pull request #16 from hngi/ApiBranch
Michaelzy27 Jul 18, 2020
0e96a8a
Populating Popular Destination, Popular Destination Detail Overview A…
DevAdedoyin Jul 18, 2020
df8097d
Populating Popular Destination, Popular Destination Detail Overview A…
DevAdedoyin Jul 18, 2020
6ea5efa
Merge pull request #429 from DevAdedoyin/Adedoyin
Michaelzy27 Jul 18, 2020
8fd9b31
Merge pull request #17 from hngi/ApiBranch
Michaelzy27 Jul 18, 2020
562be5d
bug fix
Michaelzy27 Jul 18, 2020
b35f818
Bug fix
Michaelzy27 Jul 19, 2020
404941e
Merge pull request #436 from Michaelzy27/develop
Michaelzy27 Jul 19, 2020
42217bf
Bug fixes
Michaelzy27 Jul 19, 2020
312f4dc
Merge pull request #437 from Michaelzy27/develop
Michaelzy27 Jul 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down Expand Up @@ -91,10 +92,15 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.facebook.shimmer:shimmer:0.5.0'

implementation 'com.squareup.okhttp3:okhttp:4.8.0'
implementation 'com.hbb20:ccp:2.4.0'

implementation 'com.android.volley:volley:1.1.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.code.gson:gson:2.8.6'

//image loader
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

}

1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@style/AppTheme">
<activity android:name=".FindHotelDetails"></activity>
<activity
Expand Down
114 changes: 103 additions & 11 deletions app/src/main/java/com/michael/afrivac/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.util.Patterns;
import android.view.View;
Expand All @@ -23,15 +24,13 @@
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;
import com.facebook.login.Login;
import com.facebook.login.LoginResult;
import com.facebook.login.widget.LoginButton;
import com.github.aakira.compoundicontextview.CompoundIconTextView;
import com.google.android.gms.auth.api.signin.GoogleSignIn;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
Expand All @@ -41,30 +40,38 @@
import com.google.firebase.auth.FacebookAuthProvider;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.FirebaseDatabase;
import com.michael.afrivac.Auth.AuthViewModel;
import com.michael.afrivac.Util.Helper;

import org.json.JSONObject;

import java.util.Arrays;

import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

public class LoginActivity extends AppCompatActivity implements View.OnClickListener {

int RC_SIGN_IN = 0;
GoogleSignInClient mGoogleSignInClient;

private EditText email, password;
private String Email, Password;
private TextView sign_in, signUp, forgotPassword, resend_email_ver;
private TextView signUp, forgotPassword, resend_email_ver;
private FirebaseAuth mAuth;
private FirebaseUser user;
private AuthViewModel authViewModel;
private Helper helper;
private Button googleSignIn;
private Button googleSignIn,sign_in;
private Animation animation;
private FirebaseAuth.AuthStateListener mAuthStateListener;
private CallbackManager callbackManager;
private LoginButton loginButton;
private static final String EMAIL = "email";
private final String signIn_URL ="https://piscine-mandarine-32869.herokuapp.com/api/v1/auth/login";

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -80,8 +87,6 @@ protected void onCreate(Bundle savedInstanceState) {
signUp = findViewById(R.id.singin_goto_signup);
forgotPassword = findViewById(R.id.signin_forgot_password);

final String Email = email.getText().toString().trim();
final String Password = password.getText().toString().trim();

FacebookSdk.sdkInitialize(getApplicationContext());
loginButton = findViewById(R.id.signin_with_facebook);
Expand Down Expand Up @@ -134,13 +139,24 @@ public void onClick(View v) {
public void onClick(final View v) {
animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.button_anim);
sign_in.startAnimation(animation);
final String Email = email.getText().toString().trim();
final String Password = password.getText().toString().trim();
new LoginUser().execute(Email,Password);
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}

@Override
public void onAnimationEnd(Animation animation) {
if(!isEmpty(email.getText().toString()) && !isEmpty(password.getText().toString())){

String Email = email.getText().toString();
String Password = password.getText().toString();

LoginUser userLogin = new LoginUser();
userLogin.execute(Email, Password);


/*if(!isEmpty(email.getText().toString()) && !isEmpty(password.getText().toString())){
helper.progressDialogStart("Login to User Account", "Please wait while we log-in into your account");
FirebaseAuth.getInstance().signInWithEmailAndPassword(email.getText().toString(), password.getText().toString())
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
Expand All @@ -163,7 +179,7 @@ public void onFailure(@NonNull Exception e) {
Toast.makeText(LoginActivity.this, "Please enter password", Toast.LENGTH_SHORT).show();
} else if(!Patterns.EMAIL_ADDRESS.matcher(email.getText().toString()).matches()){
Toast.makeText(LoginActivity.this, "Please enter valid email", Toast.LENGTH_SHORT).show();
}
}*/
}

@Override
Expand All @@ -172,6 +188,18 @@ public void onAnimationRepeat(Animation animation) {}
}
});

//This Sign in button works for Api authentication

// sign_in.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// final String Email = email.getText().toString().trim();
// final String Password = password.getText().toString().trim();
// new LoginUser().execute(Email,Password);
//
// }
// });

googleSignIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down Expand Up @@ -371,6 +399,70 @@ private boolean isEmpty(String string) {
return string.equals("");
}

//code to login user with inputed email and password
public class LoginUser extends AsyncTask<String,Void ,String>{

@Override
protected String doInBackground(String... strings) {
String email = strings[0];
String password = strings[1];
OkHttpClient okHttpClient = new OkHttpClient();
RequestBody formBody = new FormBody.Builder()
.add("email", email)
.add("password",password).build();
Request request = new Request.Builder()
.url(signIn_URL)
.post(formBody)
.build();

//sends the email and Password to the db

try{
Response response = okHttpClient.newCall(request).execute(); //gets a response from the server
if(response.isSuccessful()){
showToast("Successful Login");
startActivity(new Intent(getApplicationContext(), MainActivity.class));
finish();
String result = response.body().string();
Log.i("loginResponse", "yes");
Log.i("responseBody", result);
//Log.i("resultResponsee", result);

JSONObject jsonObject = new JSONObject(result);
String resultData = jsonObject.getString("data"); //gets the data array in string format from the response body

JSONObject jsonObject1 = new JSONObject(resultData);
String resultToken = jsonObject1.getString("token"); //gets the token string from the data array
helper.token(resultToken); //sends token to the helper class to be used through out the app

SharedPreferences sharedPreferences = getSharedPreferences("TOKEN", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("token", resultToken);
editor.apply();

Log.d("TOKEN", resultToken);

if(!response.isSuccessful()){

Toast.makeText(LoginActivity.this,"Email or Password Mismatch",Toast.LENGTH_SHORT).show();
}
}else{
Log.i("loginResponse", "Unsuccessful");
}
}catch (Exception e){
e.printStackTrace();
}
return null;
}
}
public void showToast(final String Text){
this.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(LoginActivity.this,Text,Toast.LENGTH_SHORT).show();
}
});
}

}

19 changes: 12 additions & 7 deletions app/src/main/java/com/michael/afrivac/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.michael.afrivac.ui.account.AccountFragment;
import com.michael.afrivac.ui.findHotel.FindHotelFragment;
import com.michael.afrivac.ui.home.HomeFragment;
import com.michael.afrivac.ui.memories.MemoriesFragment;
import com.michael.afrivac.ui.popular_destination.PopularDestinationFragment;
import com.michael.afrivac.ui.support.SupportFragment;
import com.google.firebase.auth.FirebaseAuth;
Expand Down Expand Up @@ -61,7 +62,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private AppBarConfiguration mAppBarConfiguration;
private ActionBarDrawerToggle toggle;
private Helper helper;
FirebaseAuth mAuth;
//FirebaseAuth mAuth;
Toolbar toolbar;

@Override
Expand Down Expand Up @@ -94,7 +95,7 @@ protected void onCreate(Bundle savedInstanceState) {
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
// }

mAuth = FirebaseAuth.getInstance();
//mAuth = FirebaseAuth.getInstance();

// FloatingActionButton fab = findViewById(R.id.fab);
// fab.setOnClickListener(new View.OnClickListener() {
Expand Down Expand Up @@ -147,9 +148,9 @@ protected void onCreate(Bundle savedInstanceState) {


private void logout() {
FirebaseAuth.getInstance().signOut();
helper.gotoLoginAcitivity(this);
finish();
// FirebaseAuth.getInstance().signOut();
// helper.gotoLoginAcitivity(this);
// finish();
}

@Override
Expand Down Expand Up @@ -219,10 +220,10 @@ public void reLoadMainActivity(){
@Override
protected void onStart() {
super.onStart();
FirebaseUser currentUser = mAuth.getCurrentUser();
/* FirebaseUser currentUser = mAuth.getCurrentUser();
if(currentUser == null){
helper.gotoLoginAcitivity(this);
}
} */

}

Expand Down Expand Up @@ -268,6 +269,10 @@ private void displaySelectedScreen(int itemId) {
fragment = new SupportFragment();
fragment_tag = "SupportFragment";
break;
case R.id.nav_memories:
fragment = new MemoriesFragment();
fragment_tag = "MemoriesFragment";
break;
case R.id.nav_logout:
logout();
break;
Expand Down
Loading