Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InstiLostAndFound
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
MUTTINENI NAVYA
InstiLostAndFound
Commits
35e5c552
Commit
35e5c552
authored
Oct 25, 2019
by
ankitasingh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Firebase login authentication added
parent
a3845c69
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
20 deletions
+74
-20
app/src/main/java/com/example/instilostandfound/LostItem.java
...src/main/java/com/example/instilostandfound/LostItem.java
+2
-2
app/src/main/java/com/example/instilostandfound/MainActivity.java
...main/java/com/example/instilostandfound/MainActivity.java
+60
-4
app/src/main/res/layout/activity_main.xml
app/src/main/res/layout/activity_main.xml
+12
-14
No files found.
app/src/main/java/com/example/instilostandfound/LostItem.java
View file @
35e5c552
...
...
@@ -19,14 +19,14 @@ public class LostItem extends AppCompatActivity {
Toolbar
toolbar
=
findViewById
(
R
.
id
.
toolbar
);
setSupportActionBar
(
toolbar
);
FloatingActionButton
fab
=
findViewById
(
R
.
id
.
fab
);
/*
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
});
*/
}
}
app/src/main/java/com/example/instilostandfound/MainActivity.java
View file @
35e5c552
package
com.example.instilostandfound
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
com.google.android.material.floatingactionbutton.FloatingActionButton
;
import
com.google.android.gms.tasks.OnCompleteListener
;
import
com.google.android.gms.tasks.Task
;
import
com.google.android.material.snackbar.Snackbar
;
import
com.google.firebase.auth.AuthResult
;
import
com.google.firebase.auth.FirebaseAuth
;
import
androidx.annotation.NonNull
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.appcompat.widget.Toolbar
;
import
android.view.View
;
import
android.view.Menu
;
import
android.view.MenuItem
;
import
android.widget.EditText
;
import
android.widget.Toast
;
public
class
MainActivity
extends
AppCompatActivity
{
public
class
MainActivity
extends
AppCompatActivity
implements
View
.
OnClickListener
{
private
FirebaseAuth
mAuth
;
EditText
ldap_id
;
EditText
ldap_password
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
// ...
// Initialize Firebase Auth
mAuth
=
FirebaseAuth
.
getInstance
();
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
Toolbar
toolbar
=
findViewById
(
R
.
id
.
toolbar
);
ldap_id
=
findViewById
(
R
.
id
.
LDAP_ID
);
ldap_password
=
findViewById
(
R
.
id
.
LDAP_PASSWORD
);
setSupportActionBar
(
toolbar
);
findViewById
(
R
.
id
.
login_btn
).
setOnClickListener
(
this
);
FloatingActionButton
fab
=
findViewById
(
R
.
id
.
fab
);
/*
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
});
*/
}
@Override
...
...
@@ -55,4 +69,46 @@ public class MainActivity extends AppCompatActivity {
return
super
.
onOptionsItemSelected
(
item
);
}
private
void
LDAPLogin
()
{
String
id
=
ldap_id
.
getText
().
toString
().
trim
()+
"@iitb.ac.in"
;
String
password
=
ldap_password
.
getText
().
toString
().
trim
();
if
(
id
.
isEmpty
())
{
ldap_id
.
setError
(
"Please enter your ldap id"
);
ldap_id
.
requestFocus
();
return
;
}
if
(
password
.
isEmpty
())
{
ldap_password
.
setError
(
"Please enter your ldap password "
);
ldap_password
.
requestFocus
();
return
;
}
mAuth
.
signInWithEmailAndPassword
(
id
,
password
).
addOnCompleteListener
(
new
OnCompleteListener
<
AuthResult
>()
{
@Override
public
void
onComplete
(
@NonNull
Task
<
AuthResult
>
task
)
{
if
(
task
.
isSuccessful
())
{
Toast
.
makeText
(
MainActivity
.
this
,
"LOGIN SUCCESSFUL"
,
Toast
.
LENGTH_LONG
).
show
();
}
else
{
ldap_password
.
setText
(
""
);
Toast
.
makeText
(
MainActivity
.
this
,
"INVALID CREDENTIALS"
,
Toast
.
LENGTH_LONG
).
show
();
}
}
});
}
public
void
onClick
(
View
view
)
{
switch
(
view
.
getId
())
{
case
R
.
id
.
login_btn
:
LDAPLogin
();
break
;
}
}
}
app/src/main/res/layout/activity_main.xml
View file @
35e5c552
...
...
@@ -20,7 +20,7 @@
<EditText
android:layout_width =
"wrap_content"
android:layout_height =
"wrap_content"
android:id =
"@+id/
editText
"
android:id =
"@+id/
LDAP_ID
"
android:hint =
"@string/ldap_id"
android:focusable =
"true"
android:textColorHighlight =
"#ff7eff15"
...
...
@@ -41,28 +41,26 @@
android:layout_centerHorizontal=
"true"
/>
<EditText
android:id=
"@+id/LDAP_PASSWORD"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:inputType=
"textPassword"
android:ems=
"10"
android:id=
"@+id/editText2"
android:layout_below=
"@+id/editText"
android:layout_alignParentLeft=
"true"
android:layout_below=
"@+id/LDAP_ID"
android:layout_alignEnd=
"@+id/LDAP_ID"
android:layout_alignLeft=
"@+id/LDAP_ID"
android:layout_alignParentStart=
"true"
android:layout_alignRight=
"@+id/editText"
android:layout_alignEnd=
"@+id/editText"
android:textColorHint=
"#ffff299f"
android:hint=
"@string/password"
/>
android:layout_alignParentLeft=
"true"
android:ems=
"10"
android:hint=
"@string/password"
android:inputType=
"textPassword"
android:textColorHint=
"#ffff299f"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/login"
android:id=
"@+id/
butto
n"
android:id=
"@+id/
login_bt
n"
android:layout_alignParentBottom=
"true"
android:layout_centerHorizontal=
"true"
android:background=
"@color/colorPrimary"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment