Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
BIDL
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Christof Wolke
BIDL
Commits
4f98dde5
Commit
4f98dde5
authored
Aug 04, 2016
by
Christof Wolke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Login Activity + Login request
parent
4cd8f919
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
321 additions
and
5 deletions
+321
-5
BIDL/BIDL/app/src/main/AndroidManifest.xml
BIDL/BIDL/app/src/main/AndroidManifest.xml
+10
-2
BIDL/BIDL/app/src/main/java/classes/User.java
BIDL/BIDL/app/src/main/java/classes/User.java
+85
-0
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/base_view/SplashActivity.java
.../java/de/uni_oldenburg/bidl/base_view/SplashActivity.java
+4
-3
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/guest_view/LoginActivity.java
.../java/de/uni_oldenburg/bidl/guest_view/LoginActivity.java
+93
-0
BIDL/BIDL/app/src/main/java/services/servercommunication/NetworkService.java
...ain/java/services/servercommunication/NetworkService.java
+59
-0
BIDL/BIDL/app/src/main/res/layout/activity_login.xml
BIDL/BIDL/app/src/main/res/layout/activity_login.xml
+62
-0
BIDL/BIDL/app/src/main/res/values/strings.xml
BIDL/BIDL/app/src/main/res/values/strings.xml
+8
-0
No files found.
BIDL/BIDL/app/src/main/AndroidManifest.xml
View file @
4f98dde5
...
...
@@ -2,8 +2,14 @@
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"de.uni_oldenburg.bidl"
>
<uses-permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission
android:name=
"android.permission.GET_ACCOUNTS"
/>
<uses-permission
android:name=
"android.permission.READ_PROFILE"
/>
<uses-permission
android:name=
"android.permission.READ_CONTACTS"
/>
<application
android:allowBackup=
"true"
android:icon=
"@mipmap/ic_launcher"
...
...
@@ -20,12 +26,14 @@
</activity>
<activity
android:name=
".base_view.SplashActivity"
android:screenOrientation=
"sensorPortrait"
>
android:screenOrientation=
"sensorPortrait"
android:parentActivityName=
".base_view.SplashActivity"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/
>
<category
android:name=
"android.intent.category.LAUNCHER"
></category
>
</intent-filter>
</activity>
<activity
android:name=
".guest_view.LoginActivity"
></activity>
</application>
</manifest>
\ No newline at end of file
BIDL/BIDL/app/src/main/java/classes/User.java
0 → 100644
View file @
4f98dde5
package
classes
;
import
com.bluelinelabs.logansquare.annotation.JsonField
;
import
com.bluelinelabs.logansquare.annotation.JsonObject
;
/**
* Represent a User and al important informations
* Created by Christof on 04.08.2016.
*/
@JsonObject
public
class
User
{
@JsonField
(
name
=
"id"
)
private
long
userId
;
@JsonField
(
name
=
"name"
)
private
String
username
;
@JsonField
(
name
=
"email"
)
private
String
email
;
@JsonField
(
name
=
"image"
)
private
String
imagePath
;
public
User
(){
}
/**
*
* @param username Name des Users
* @param email Email-Adresse des Users
* @param userId ID des Users
* @param imagePath Pfad zum Profilbild des Users
*/
public
User
(
String
username
,
String
email
,
long
userId
,
String
imagePath
)
{
this
.
username
=
username
;
this
.
email
=
email
;
this
.
userId
=
userId
;
this
.
imagePath
=
imagePath
;
}
public
long
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
long
userId
)
{
this
.
userId
=
userId
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
public
String
getImagePath
()
{
return
imagePath
;
}
public
void
setImagePath
(
String
imagePath
)
{
this
.
imagePath
=
imagePath
;
}
@Override
public
String
toString
()
{
return
"User{"
+
"userId="
+
userId
+
", username='"
+
username
+
'\''
+
", email='"
+
email
+
'\''
+
", imagePath='"
+
imagePath
+
'\''
+
'}'
;
}
}
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/base_view/SplashActivity.java
View file @
4f98dde5
...
...
@@ -17,6 +17,7 @@ import java.util.List;
import
java.util.UUID
;
import
de.uni_oldenburg.bidl.R
;
import
de.uni_oldenburg.bidl.guest_view.LoginActivity
;
import
pl.droidsonroids.gif.GifImageView
;
import
static
de
.
uni_oldenburg
.
bidl
.
R
.
string
.
noBeaconFound
;
...
...
@@ -69,7 +70,7 @@ public class SplashActivity extends AppCompatActivity {
public
void
onBeaconsDiscovered
(
Region
region
,
List
<
Beacon
>
list
)
{
if
(!
list
.
isEmpty
()){
Beacon
nearestBeacon
=
list
.
get
(
0
);
to
Ma
inActivity
();
to
Log
inActivity
();
// TODO: 30.07.2016 save the Beacon in the database and overwrite the DB, when the nearestBeacon != the saved beacon.
}
if
(
list
.
isEmpty
()){
// TODO: 30.07.2016 toScrenn beacon not found...
...
...
@@ -113,8 +114,8 @@ public class SplashActivity extends AppCompatActivity {
super
.
onPause
();
}
private
void
to
Ma
inActivity
()
{
startActivity
(
new
Intent
(
this
,
Ma
inActivity
.
class
));
private
void
to
Log
inActivity
()
{
startActivity
(
new
Intent
(
this
,
Log
inActivity
.
class
));
}
private
void
showMessage
()
{
...
...
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/guest_view/LoginActivity.java
0 → 100644
View file @
4f98dde5
package
de.uni_oldenburg.bidl.guest_view
;
import
android.content.Intent
;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.CheckBox
;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
classes.User
;
import
de.uni_oldenburg.bidl.R
;
import
de.uni_oldenburg.bidl.base_view.MainActivity
;
import
services.servercommunication.NetworkService
;
public
class
LoginActivity
extends
AppCompatActivity
{
/** GUI **/
private
ImageView
unilogo
;
private
EditText
etEmail
;
private
EditText
etPassword
;
private
CheckBox
stayLoggedIn
;
private
Button
btLogin
;
private
TextView
tvRegister
;
/** values **/
private
String
email
;
private
String
password
;
private
boolean
keepLoggedIn
;
private
static
final
String
TOAST_ERROR_MESSAGE
=
"Falsche Login Daten"
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_login
);
/** init **/
unilogo
=
(
ImageView
)
findViewById
(
R
.
id
.
uniLogo
);
etEmail
=
(
EditText
)
findViewById
(
R
.
id
.
email
);
etPassword
=
(
EditText
)
findViewById
(
R
.
id
.
password
);
stayLoggedIn
=
(
CheckBox
)
findViewById
(
R
.
id
.
keepingLoggedIn
);
btLogin
=
(
Button
)
findViewById
(
R
.
id
.
loginButton
);
tvRegister
=
(
TextView
)
findViewById
(
R
.
id
.
register
);
/** Fullscreen modus **/
getWindow
().
getDecorView
().
setSystemUiVisibility
(
View
.
SYSTEM_UI_FLAG_LAYOUT_STABLE
|
View
.
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
View
.
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
View
.
SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
View
.
SYSTEM_UI_FLAG_FULLSCREEN
);
/** Login **/
btLogin
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
final
View
view
)
{
view
.
setEnabled
(
false
);
email
=
etEmail
.
getText
().
toString
();
password
=
etPassword
.
getText
().
toString
();
keepLoggedIn
=
stayLoggedIn
.
isChecked
();
NetworkService
.
login
(
email
,
password
,
new
NetworkService
.
RequestLoginHandler
()
{
@Override
public
void
done
(
User
user
)
{
//User cannot be null and cannot have the ID 0.
if
(
user
!=
null
&&
user
.
getUserId
()
>
0
){
toMainActivity
();
}
else
{
LoginActivity
.
this
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
Toast
.
makeText
(
getApplicationContext
(),
TOAST_ERROR_MESSAGE
,
Toast
.
LENGTH_SHORT
).
show
();
view
.
setEnabled
(
true
);
}
});
}
}
});
}
});
}
private
void
toMainActivity
()
{
startActivity
(
new
Intent
(
this
,
MainActivity
.
class
));
}
}
BIDL/BIDL/app/src/main/java/services/servercommunication/NetworkService.java
View file @
4f98dde5
package
services.servercommunication
;
import
com.bluelinelabs.logansquare.LoganSquare
;
import
com.squareup.okhttp.Call
;
import
com.squareup.okhttp.Callback
;
import
com.squareup.okhttp.FormEncodingBuilder
;
import
com.squareup.okhttp.OkHttpClient
;
import
com.squareup.okhttp.Request
;
import
com.squareup.okhttp.RequestBody
;
import
com.squareup.okhttp.Response
;
import
java.io.IOException
;
import
java.util.concurrent.TimeUnit
;
import
classes.User
;
/**
* Helfer Klasse, die häufig verwendete I/O Operationen im Netzwerk und der Datenbank erleichtert
...
...
@@ -23,4 +35,51 @@ public abstract class NetworkService {
* @param password Passwort des Nutzers
* @param handler Callback handler
*/
public
static
void
login
(
String
email
,
String
password
,
final
RequestLoginHandler
handler
){
okHttpClient
.
setReadTimeout
(
15
,
TimeUnit
.
SECONDS
);
/* okHTTPClient
Request body mit POST params
*/
RequestBody
requestBody
=
new
FormEncodingBuilder
()
.
add
(
"email"
,
email
)
.
add
(
"pass"
,
password
)
.
build
();
//add body to POST-request
Request
req
=
new
Request
.
Builder
()
.
url
(
REST
.
SPRING_LOGIN
)
.
post
(
requestBody
)
.
build
();
//Server call preparation
Call
call
=
okHttpClient
.
newCall
(
req
);
//ASync call
call
.
enqueue
(
new
Callback
()
{
@Override
public
void
onFailure
(
Request
request
,
IOException
e
)
{
handler
.
done
(
null
);
e
.
printStackTrace
();
}
@Override
public
void
onResponse
(
Response
response
)
throws
IOException
{
try
{
//server response parsing
if
(
response
.
isSuccessful
()){
String
responseString
=
response
.
body
().
string
();
//Userobject
User
user
=
LoganSquare
.
parse
(
responseString
,
User
.
class
);
handler
.
done
(
user
);
}
}
catch
(
IOException
e
){
handler
.
done
(
null
);
e
.
printStackTrace
();
}
}
});
}
public
interface
RequestLoginHandler
{
void
done
(
User
user
);
}
}
BIDL/BIDL/app/src/main/res/layout/activity_login.xml
0 → 100644
View file @
4f98dde5
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/activity_login"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
"de.uni_oldenburg.bidl.guest_view.LoginActivity"
android:orientation=
"vertical"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:id=
"@+id/uniLogo"
android:src=
"@drawable/unilogo"
android:layout_margin=
"10dp"
/>
<EditText
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:inputType=
"textEmailAddress"
android:layout_gravity=
"center"
android:id=
"@+id/email"
android:hint=
"@string/hintTextEmail"
android:layout_marginTop=
"30dp"
/>
<EditText
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:inputType=
"textPassword"
android:layout_gravity=
"center"
android:id=
"@+id/password"
android:hint=
"@string/hintTextPass"
android:layout_marginTop=
"10dp"
/>
<CheckBox
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/checkBoxDescription"
android:layout_gravity=
"center"
android:id=
"@+id/keepingLoggedIn"
android:checked=
"true"
android:layout_marginTop=
"10dp"
/>
<Button
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/buttonDescription"
android:layout_gravity=
"center"
android:id=
"@+id/loginButton"
android:layout_marginTop=
"20dp"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/registerDescription"
android:textColor=
"@color/colorPrimary"
android:layout_gravity=
"center"
android:id=
"@+id/register"
android:layout_marginTop=
"5dp"
/>
</LinearLayout>
BIDL/BIDL/app/src/main/res/values/strings.xml
View file @
4f98dde5
...
...
@@ -7,6 +7,14 @@
<string
name=
"imageViewDescription"
>
University Logo
</string>
<string
name=
"gifImageViewDescription"
>
Loadingspinner
</string>
<string
name=
"noBeaconFound"
>
Kein Beacon in der Nähe!
</string>
<string
name=
"title_activity_login"
>
Sign in
</string>
<!-- Login Activity !-->
<string
name=
"hintTextEmail"
>
E-Mail Adresse
</string>
<string
name=
"hintTextPass"
>
Passwort
</string>
<string
name=
"checkBoxDescription"
>
Eingeloggt bleiben
</string>
<string
name=
"buttonDescription"
>
Login
</string>
<string
name=
"registerDescription"
>
Registrieren
</string>
</resources>
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