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

Develop #11

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 5 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test:runner:1.0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
testImplementation 'junit:junit:4.12'
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.google.firebase:firebase-auth:11.6.2'
androidTestCompile 'com.android.support.test:runner:1.0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>

<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>

<activity android:name=".activities.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.example.nviller.projetm2psav.activities;


import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
Expand All @@ -11,11 +13,11 @@
import android.widget.Toast;

import com.example.nviller.projetm2psav.R;
import com.example.nviller.projetm2psav.dao.DAOUser;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.example.nviller.projetm2psav.model.User;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
//import com.google.firebase.database.DatabaseReference;
//import com.google.firebase.database.FirebaseDatabase;

/**
* Created by nviller on 19/01/2018.
Expand All @@ -34,10 +36,24 @@ public class CreateUserActivity extends AppCompatActivity {
private FirebaseAuth firebaseAuth;
private DAOUser daoUser;

private EditText emailUser;
private EditText mdpUser;
private EditText loginUser;
private EditText firstnameUser;
private EditText lastnameUser;
private User newUser;
private FirebaseAuth mFirebaseAuth;
private FirebaseUser mFirebaseUser;
// private DatabaseReference database;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.create_user);
mFirebaseAuth = FirebaseAuth.getInstance();
mFirebaseUser = mFirebaseAuth.getCurrentUser();
//database = FirebaseDatabase.getInstance().getReference("users");


editTextFirstName = (EditText) findViewById(R.id.create_user_first_name);
editTextLastName = (EditText) findViewById(R.id.create_user_last_name);
Expand All @@ -59,12 +75,12 @@ public void onClick(View v) {
final String email = editTextEmail.getText().toString().trim();
final String password = editTextPassword.getText().toString().trim();

if ( !daoUser.validateUser(email, password, firstName, lastName)) {
showAlertDialogError(R.string.signup_error_title,
getResources().getString(R.string.signup_error_message));
} else {
signUp(email, password, firstName, lastName,pseudo);
}

mFirebaseAuth.createUserWithEmailAndPassword(emailUser.getText().toString().trim(),mdpUser.getText().toString().trim());


}


}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,25 @@
import android.widget.EditText;
import android.widget.ListView;

import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;

import com.example.nviller.projetm2psav.R;
import com.example.nviller.projetm2psav.adapter.SlidingMenuAdapter;
import com.example.nviller.projetm2psav.model.ItemSlideMenu;
import com.google.firebase.auth.FirebaseAuth;

import java.util.List;

import com.facebook.login.LoginResult;
import com.facebook.login.widget.LoginButton;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;



public class MainActivity extends AppCompatActivity {

Expand All @@ -30,10 +42,13 @@ public class MainActivity extends AppCompatActivity {
private DrawerLayout drawerLayout;
//private RelativeLayout mainContent;
private ActionBarDrawerToggle actionBarDrawerToggle;
private CallbackManager callbackManager;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
setContentView(R.layout.activity_main);
firebaseAuth = FirebaseAuth.getInstance();

Expand All @@ -47,6 +62,57 @@ public void onClick(View v) {
}

});
// buttonLogFacebook.setOnClickListener();

callbackManager = CallbackManager.Factory.create();
final LoginButton loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton.setReadPermissions("email");

// Callback registration
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// App code
System.out.println("MON LOGIN : "+ loginResult);

}



@Override
public void onCancel() {
// App code
}

@Override
public void onError(FacebookException exception) {
// App code
}
});


/* Soit on utilise loginButton soit on utilise loginManager


LoginManager.getInstance().registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// App code
}

@Override
public void onCancel() {
// App code
}

@Override
public void onError(FacebookException exception) {
// App code
}
});*/



final Button buttonLogIn = (Button) findViewById(R.id.activity_main_login_button);
buttonLogIn.setOnClickListener(new View.OnClickListener() {
Expand All @@ -58,4 +124,12 @@ public void onClick(View view) {
});

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
callbackManager.onActivityResult(requestCode, resultCode, data);
super.onActivityResult(requestCode, resultCode, data);
}


}
27 changes: 24 additions & 3 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,23 @@
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:gravity="top|center_vertical|center_horizontal|center"
android:text="Bienvenue dans FunEvent"
android:textSize="50sp"
android:layout_marginTop="10dp"/>
android:text="Bienvenue dans notre appli"
android:textSize="50dp" />
<EditText
android:id="@+id/email_user_ma"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Email" />

<EditText
android:id="@+id/password_user_ma"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Mot de passe" />
<Button
android:id="@+id/activity_main_login_button"
android:layout_width="150dp"
Expand All @@ -44,6 +57,14 @@
android:layout_marginTop="10dp"
android:text="Créer un compte"/>

<com.facebook.login.widget.LoginButton
android:id="@+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp" />


</LinearLayout>

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<string name="app_name">ProjetM2PSAV</string>
<string name="drawer_opened">Opened</string>
<string name="drawer_closed">Closed</string>
<string name="facebook_app_id">1492207237571556</string>
<string name="fb_login_protocol_scheme">fb1492207237571556</string>


<!-- Signup -->
<string name="sign_up_button_label">Sign Up</string>
Expand Down Expand Up @@ -37,4 +40,5 @@
<string name="create_event_heure_fin">Heure de Fin</string>
<string name="create_event_submit_date_error_message">La date de fin ne peut pas être antérieure à celle du début !</string>


</resources>
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
Expand Down