-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchanges.diff
More file actions
221 lines (212 loc) · 7.88 KB
/
changes.diff
File metadata and controls
221 lines (212 loc) · 7.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
diff --git a/app/build.gradle b/app/build.gradle
index f811d5a..b7d7107 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -56,6 +56,8 @@ dependencies {
testImplementation 'org.mockito:mockito-core:2.7.22'
// required if you want to use Mockito for Android tests
androidTestImplementation 'org.mockito:mockito-android:2.7.22'
+ implementation 'com.facebook.android:facebook-login:[4,5)'
+
}
repositories { mavenCentral() }
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b811b34..c588cab 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -8,7 +8,6 @@
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
-
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
@@ -37,13 +36,37 @@
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
- <meta-data
- android:name="com.google.android.geo.API_KEY"
- android:value="@string/google_maps_key" />
+
+
+
+
+ <!-- start of facebook metadata!! -->
+ <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=".controllers.Maps"
- android:label="@string/title_activity_maps"></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>
+
+ <!-- end of facebook meta data -->
+
+
</application>
+ <!-- added for facebook permissions -->
+ <uses-permission android:name="android.permission.INTERNET"/>
+ <!-- end of permission added for facebook -->
+
</manifest>
\ No newline at end of file
diff --git a/app/src/main/java/com/example/notphilphil/bob/controllers/LoginActivity.java b/app/src/main/java/com/example/notphilphil/bob/controllers/LoginActivity.java
index 37e9517..bc4de7a 100644
--- a/app/src/main/java/com/example/notphilphil/bob/controllers/LoginActivity.java
+++ b/app/src/main/java/com/example/notphilphil/bob/controllers/LoginActivity.java
@@ -7,12 +7,19 @@ import android.os.Bundle;
import android.util.Log;
import android.widget.Button;
import android.widget.EditText;
+import android.widget.TextView;
import com.example.notphilphil.bob.R;
import com.example.notphilphil.bob.models.Admin;
import com.example.notphilphil.bob.models.LocationEmployee;
import com.example.notphilphil.bob.models.Manager;
import com.example.notphilphil.bob.models.User;
+import com.facebook.CallbackManager;
+import com.facebook.FacebookCallback;
+import com.facebook.FacebookException;
+import com.facebook.FacebookSdk;
+import com.facebook.login.LoginResult;
+import com.facebook.login.widget.LoginButton;
import java.io.BufferedReader;
import java.io.File;
@@ -23,9 +30,17 @@ public class LoginActivity extends AppCompatActivity {
private EditText login_et;
private EditText password_et;
+ //for facebook
+ LoginButton loginButton;
+ TextView textView;
+ CallbackManager callbackManager;
+ //end of facebook items
+
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ FacebookSdk.sdkInitialize(getApplicationContext()); //initialize facebook SDK
setContentView(R.layout.activity_login);
login_et = findViewById(R.id.username_et);
@@ -54,8 +69,44 @@ public class LoginActivity extends AppCompatActivity {
LoggedUser.newInstance();
startActivity(intent);
});
+
+
+
+ /////////// start of facebook
+
+ loginButton = (LoginButton) findViewById(R.id.fblogin_button); //facebook
+ textView = (TextView) findViewById(R.id.textView); //facebook
+ callbackManager = CallbackManager.Factory.create(); //facebook
+ loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() { //facebook
+ @Override
+ public void onSuccess(LoginResult loginResult) {
+ Intent intent = new Intent(loginButton.getContext(),HomeActivity.class);
+ LoggedUser.newInstance();
+ startActivity(intent);
+ }
+
+ @Override
+ public void onCancel() {
+
+ }
+
+ @Override
+ public void onError(FacebookException error) {
+
+ }
+ });
+
+ //////////end of facebook inside the onCreate() method
}
+ //////method created for facebook activity
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ callbackManager.onActivityResult(requestCode, resultCode, data) ;
+ };
+ /////////// end of facebook method
+
+
boolean loginPressed(String curr_login, String curr_password, File regUsers, Context context) {
if (regUsers.exists()) {
try {
diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml
index 0d2543b..65ff634 100644
--- a/app/src/main/res/layout/activity_login.xml
+++ b/app/src/main/res/layout/activity_login.xml
@@ -46,7 +46,7 @@
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
- android:layout_marginTop="8dp"
+ android:layout_marginTop="16dp"
android:text="Register"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@@ -84,6 +84,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/username_et" />
+
<TextView
android:id="@+id/password_tv"
android:layout_width="wrap_content"
@@ -117,4 +118,14 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/register_button" />
+
+
+ <com.facebook.login.widget.LoginButton
+ android:id="@+id/fblogin_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ tools:layout_editor_absoluteX="16dp"
+ tools:layout_editor_absoluteY="16dp" />
+
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 3e7441a..72075ea 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -19,4 +19,10 @@
<string name="delete">Delete</string>
<string name="title_activity_maps">Map</string>
<string name="category">Category</string>
+
+<!-- added facebook login stuff -->
+ <string name="facebook_app_id">293524841279421</string>
+ <string name="fb_login_protocol_scheme">fb293524841279421</string>
+<!-- end of facebook stuff -->
+
</resources>
diff --git a/build.gradle b/build.gradle
index 82f8bf1..b831097 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,6 +5,8 @@ buildscript {
repositories {
google()
jcenter()
+ jcenter()
+
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'