Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CS123-CanteeneoAndroid
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Willard Torres
CS123-CanteeneoAndroid
Commits
89e9deae
Commit
89e9deae
authored
Dec 06, 2016
by
Willard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactors to login activity
parent
d9af2f9d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
33 deletions
+27
-33
LoginActivity.java
app/src/main/java/com/canteeneo/LoginActivity.java
+7
-11
activity_login.xml
app/src/main/res/layout/activity_login.xml
+20
-22
No files found.
app/src/main/java/com/canteeneo/LoginActivity.java
View file @
89e9deae
...
@@ -37,6 +37,8 @@ public class LoginActivity extends AppCompatActivity {
...
@@ -37,6 +37,8 @@ public class LoginActivity extends AppCompatActivity {
setContentView
(
R
.
layout
.
activity_login
);
setContentView
(
R
.
layout
.
activity_login
);
mUsernameView
=
(
AutoCompleteTextView
)
findViewById
(
R
.
id
.
username
);
mUsernameView
=
(
AutoCompleteTextView
)
findViewById
(
R
.
id
.
username
);
mLoginFormView
=
findViewById
(
R
.
id
.
login_form
);
mProgressView
=
findViewById
(
R
.
id
.
login_progress
);
mPasswordView
=
(
EditText
)
findViewById
(
R
.
id
.
password
);
mPasswordView
=
(
EditText
)
findViewById
(
R
.
id
.
password
);
mPasswordView
.
setOnEditorActionListener
(
new
TextView
.
OnEditorActionListener
()
{
mPasswordView
.
setOnEditorActionListener
(
new
TextView
.
OnEditorActionListener
()
{
...
@@ -73,19 +75,14 @@ public class LoginActivity extends AppCompatActivity {
...
@@ -73,19 +75,14 @@ public class LoginActivity extends AppCompatActivity {
register
();
register
();
}
}
});
});
mLoginFormView
=
findViewById
(
R
.
id
.
login_form
);
mProgressView
=
findViewById
(
R
.
id
.
login_progress
);
}
}
public
void
register
()
{
public
void
register
()
{
Intent
intent
=
new
Intent
(
this
,
RegisterActivity
.
class
);
startActivity
(
new
Intent
(
this
,
RegisterActivity
.
class
));
startActivity
(
intent
);
}
}
public
void
guestLogin
()
{
public
void
guestLogin
()
{
Intent
intent
=
new
Intent
(
this
,
NavDrawerActivity
.
class
);
startActivity
(
new
Intent
(
this
,
NavDrawerActivity
.
class
));
startActivity
(
intent
);
}
}
private
void
attemptLogin
()
{
private
void
attemptLogin
()
{
...
@@ -121,15 +118,14 @@ public class LoginActivity extends AppCompatActivity {
...
@@ -121,15 +118,14 @@ public class LoginActivity extends AppCompatActivity {
@Override
@Override
public
void
onResponse
(
Call
<
Token
>
call
,
Response
<
Token
>
response
)
{
public
void
onResponse
(
Call
<
Token
>
call
,
Response
<
Token
>
response
)
{
showProgress
(
false
);
showProgress
(
false
);
if
(
response
.
code
()
==
401
)
{
if
(
response
.
code
()
==
401
)
{
mUsernameView
.
setError
(
""
);
mUsernameView
.
setError
(
""
);
mPasswordView
.
setError
(
""
);
mPasswordView
.
setError
(
""
);
Toast
.
makeText
(
LoginActivity
.
this
,
"Invalid credentials!"
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
LoginActivity
.
this
,
"Invalid credentials!"
,
Toast
.
LENGTH_LONG
).
show
();
}
else
{
}
else
{
Toast
.
makeText
(
LoginActivity
.
this
,
"Logged in as "
+
AppUtils
.
getUsername
()
+
" successfully."
,
Toast
.
LENGTH_LONG
).
show
();
AppUtils
.
login
(
username
,
password
,
response
.
body
().
getId
());
AppUtils
.
login
(
username
,
password
,
response
.
body
().
getId
());
Intent
intent
=
new
Intent
(
LoginActivity
.
this
,
NavDrawerActivity
.
class
);
startActivity
(
new
Intent
(
LoginActivity
.
this
,
NavDrawerActivity
.
class
)
);
startActivity
(
intent
);
Toast
.
makeText
(
LoginActivity
.
this
,
"Logged in as "
+
AppUtils
.
getUsername
()
+
" successfully."
,
Toast
.
LENGTH_LONG
).
show
(
);
}
}
}
}
...
...
app/src/main/res/layout/activity_login.xml
View file @
89e9deae
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:gravity=
"center_horizontal"
android:focusable=
"true"
android:orientation=
"vertical"
android:focusableInTouchMode=
"true"
android:paddingBottom=
"@dimen/activity_vertical_margin"
android:gravity=
"center_horizontal"
android:paddingLeft=
"@dimen/activity_horizontal_margin"
android:orientation=
"vertical"
android:paddingRight=
"@dimen/activity_horizontal_margin"
android:paddingBottom=
"@dimen/activity_vertical_margin"
android:paddingTop=
"@dimen/activity_vertical_margin"
android:paddingLeft=
"@dimen/activity_horizontal_margin"
android:focusable=
"true"
android:paddingRight=
"@dimen/activity_horizontal_margin"
android:focusableInTouchMode=
"true"
android:paddingTop=
"@dimen/activity_vertical_margin"
tools:context=
"com.canteeneo.LoginActivity"
>
tools:context=
"com.canteeneo.LoginActivity"
>
<!-- Login progress -->
<ProgressBar
<ProgressBar
android:id=
"@+id/login_progress"
android:id=
"@+id/login_progress"
...
@@ -21,7 +19,7 @@
...
@@ -21,7 +19,7 @@
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"8dp"
android:layout_marginBottom=
"8dp"
android:visibility=
"gone"
/>
android:visibility=
"gone"
/>
<ScrollView
<ScrollView
android:id=
"@+id/login_form"
android:id=
"@+id/login_form"
...
@@ -36,8 +34,8 @@
...
@@ -36,8 +34,8 @@
<ImageView
<ImageView
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"166dp"
android:layout_height=
"166dp"
a
pp:srcCompat=
"@drawable/temp_logo
"
a
ndroid:scaleType=
"fitCenter
"
a
ndroid:scaleType=
"fitCenter"
/>
a
pp:srcCompat=
"@drawable/temp_logo"
/>
<android.support.design.widget.TextInputLayout
<android.support.design.widget.TextInputLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
@@ -49,7 +47,7 @@
...
@@ -49,7 +47,7 @@
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:hint=
"@string/prompt_username"
android:hint=
"@string/prompt_username"
android:inputType=
"text"
android:inputType=
"text"
android:maxLines=
"1"
/>
android:maxLines=
"1"
/>
</android.support.design.widget.TextInputLayout>
</android.support.design.widget.TextInputLayout>
...
@@ -66,7 +64,7 @@
...
@@ -66,7 +64,7 @@
android:imeActionLabel=
"@string/action_sign_in_short"
android:imeActionLabel=
"@string/action_sign_in_short"
android:imeOptions=
"actionUnspecified"
android:imeOptions=
"actionUnspecified"
android:inputType=
"textPassword"
android:inputType=
"textPassword"
android:maxLines=
"1"
/>
android:maxLines=
"1"
/>
</android.support.design.widget.TextInputLayout>
</android.support.design.widget.TextInputLayout>
...
@@ -88,9 +86,9 @@
...
@@ -88,9 +86,9 @@
android:id=
"@+id/register_button"
android:id=
"@+id/register_button"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/action_register"
android:layout_marginTop=
"16dp"
android:layout_marginTop=
"16dp"
android:elevation=
"0dp"
/>
android:elevation=
"0dp"
android:text=
"@string/action_register"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</ScrollView>
...
...
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