Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hds
flexin
android-app
Commits
af5a4c5d
Commit
af5a4c5d
authored
Oct 27, 2017
by
Nastuzzi Samy
Browse files
Merge branch 'release/0.2.4'
parents
d2065184
682e29d9
Changes
6
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/fr/utc/simde/payutc/BaseActivity.java
View file @
af5a4c5d
package
fr.utc.simde.payutc
;
import
android.app.Activity
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.util.Log
;
...
...
@@ -16,7 +17,7 @@ import fr.utc.simde.payutc.tools.NemopaySession;
*/
public
abstract
class
BaseActivity
extends
NFCActivity
{
private
static
final
String
LOG_TAG
=
"_
LOG_TAG
"
;
private
static
final
String
LOG_TAG
=
"_
BaseActivity
"
;
protected
static
Dialog
dialog
;
protected
static
NemopaySession
nemopaySession
;
protected
static
CASConnexion
casConnexion
;
...
...
@@ -33,6 +34,19 @@ public abstract class BaseActivity extends NFCActivity {
dialog
.
errorDialog
(
activity
,
getString
(
R
.
string
.
key_registration
),
getString
(
R
.
string
.
key_remove_temp
));
}
protected
void
fatal
(
final
Activity
activity
,
final
String
title
,
final
String
message
)
{
dialog
.
fatalDialog
(
activity
,
title
,
message
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
Intent
intent
=
new
Intent
(
activity
,
MainActivity
.
class
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
|
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
activity
.
startActivity
(
intent
);
}
});
disconnect
();
}
protected
void
startFoundationListActivity
(
final
Activity
activity
)
{
dialog
.
startLoading
(
activity
,
getString
(
R
.
string
.
information_collection
),
getString
(
R
.
string
.
foundation_list_collecting
));
new
Thread
()
{
...
...
@@ -51,6 +65,7 @@ public abstract class BaseActivity extends NFCActivity {
HTTPRequest
request
=
nemopaySession
.
getRequest
();
try
{
// Tout une série de vérifications avant de lancer l'activité
if
(
request
.
getResponseCode
()
!=
200
)
throw
new
Exception
(
"Malformed JSON"
);
...
...
@@ -60,12 +75,24 @@ public abstract class BaseActivity extends NFCActivity {
if
(!
request
.
isJsonResponse
()
||
!
foundationList
.
isArray
())
throw
new
Exception
(
"JSON unexpected"
);
if
(
foundationList
.
size
()
==
0
)
{
dialog
.
stopLoading
();
fatal
(
activity
,
getString
(
R
.
string
.
information_collection
),
nemopaySession
.
getUsername
()
+
" "
+
getString
(
R
.
string
.
user_no_rights
));
return
;
}
for
(
final
JsonNode
foundation
:
foundationList
)
{
if
(!
foundation
.
has
(
"name"
)
||
!
foundation
.
has
(
"fun_id"
))
throw
new
Exception
(
"Unexpected JSON"
);
}
getIntent
().
getSerializableExtra
(
"MyClass"
);
if
(
foundationList
.
size
()
==
1
)
{
dialog
.
stopLoading
();
nemopaySession
.
setFoundation
(
foundationList
.
get
(
0
).
get
(
"fun_id"
).
intValue
());
Log
.
d
(
LOG_TAG
,
String
.
valueOf
(
foundationList
.
get
(
0
).
get
(
"fun_id"
).
intValue
()));
return
;
}
Intent
intent
=
new
Intent
(
activity
,
FoundationListActivity
.
class
);
intent
.
putExtra
(
"foundationList"
,
response
);
...
...
app/src/main/java/fr/utc/simde/payutc/FoundationListActivity.java
View file @
af5a4c5d
...
...
@@ -62,15 +62,24 @@ public class FoundationListActivity extends BaseActivity {
throw
new
Exception
(
"Unexpected JSON"
);
foundationButton
.
setText
(
foundation
.
get
(
"name"
).
textValue
());
final
String
idFoundation
=
foundation
.
get
(
"fun_id"
).
textValue
();
foundationButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
//Log.d(LOG_TAG, idFoundation);
}
});
foundationButton
.
setOnClickListener
(
new
onClickFoundation
(
foundation
.
get
(
"fun_id"
).
intValue
()));
linearLayout
.
addView
(
foundationButton
);
}
}
public
class
onClickFoundation
implements
View
.
OnClickListener
{
final
int
idFoundation
;
public
onClickFoundation
(
int
idFoundation
)
{
this
.
idFoundation
=
idFoundation
;
}
@Override
public
void
onClick
(
View
view
)
{
nemopaySession
.
setFoundation
(
this
.
idFoundation
);
Log
.
d
(
LOG_TAG
,
String
.
valueOf
(
this
.
idFoundation
));
}
};
}
app/src/main/java/fr/utc/simde/payutc/NFCActivity.java
View file @
af5a4c5d
...
...
@@ -70,7 +70,7 @@ public abstract class NFCActivity extends Activity {
}
protected
void
onNewIntent
(
Intent
intent
)
{
if
(
intent
.
getAction
().
equals
(
NFCAdapter
.
ACTION_TAG_DISCOVERED
))
{
if
(
intent
.
getAction
()
!=
null
&&
intent
.
getAction
()
.
equals
(
NFCAdapter
.
ACTION_TAG_DISCOVERED
))
{
String
idBadge
=
ByteArrayToHexString
(((
Tag
)
intent
.
getParcelableExtra
(
NfcAdapter
.
EXTRA_TAG
)).
getId
());
Log
.
d
(
LOG_TAG
,
"ID: "
+
idBadge
);
onIdentification
(
idBadge
);
...
...
app/src/main/java/fr/utc/simde/payutc/tools/Dialog.java
View file @
af5a4c5d
...
...
@@ -4,10 +4,12 @@ import android.app.Activity;
import
android.app.ProgressDialog
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.support.v7.app.AlertDialog
;
import
android.view.inputmethod.InputMethodManager
;
import
android.widget.EditText
;
import
fr.utc.simde.payutc.MainActivity
;
import
fr.utc.simde.payutc.R
;
/**
...
...
@@ -73,8 +75,8 @@ public class Dialog {
}
}
public
void
error
Dialog
(
final
Activity
activity
,
final
String
title
,
final
String
message
)
{
errorDialog
(
activity
,
title
,
message
,
null
);
}
public
void
error
Dialog
(
final
Activity
activity
,
final
String
title
,
final
String
message
,
final
DialogInterface
.
OnClickListener
onClickListener
)
{
public
void
info
Dialog
(
final
Activity
activity
,
final
String
title
,
final
String
message
)
{
errorDialog
(
activity
,
title
,
message
,
null
);
}
public
void
info
Dialog
(
final
Activity
activity
,
final
String
title
,
final
String
message
,
final
DialogInterface
.
OnClickListener
onClickListener
)
{
this
.
alertDialogBuilder
=
new
AlertDialog
.
Builder
(
activity
);
this
.
alertDialogBuilder
.
setTitle
(
title
)
...
...
@@ -85,6 +87,16 @@ public class Dialog {
createDialog
();
}
public
void
errorDialog
(
final
Activity
activity
,
final
String
title
,
final
String
message
)
{
errorDialog
(
activity
,
title
,
message
,
null
);
}
public
void
errorDialog
(
final
Activity
activity
,
final
String
title
,
final
String
message
,
final
DialogInterface
.
OnClickListener
onClickListener
)
{
infoDialog
(
activity
,
title
,
message
,
onClickListener
);
}
public
void
fatalDialog
(
final
Activity
activity
,
final
String
title
,
final
String
message
)
{
errorDialog
(
activity
,
title
,
message
,
null
);
}
public
void
fatalDialog
(
final
Activity
activity
,
final
String
title
,
final
String
message
,
final
DialogInterface
.
OnClickListener
onClickListener
)
{
infoDialog
(
activity
,
title
,
message
,
onClickListener
);
}
public
void
startLoading
(
Activity
activity
,
final
String
title
,
final
String
message
)
{
dismiss
();
this
.
loading
=
ProgressDialog
.
show
(
activity
,
title
,
message
,
true
,
false
);
...
...
app/src/main/java/fr/utc/simde/payutc/tools/NemopaySession.java
View file @
af5a4c5d
...
...
@@ -25,6 +25,7 @@ public class NemopaySession {
private
String
key
;
private
String
session
;
private
String
username
;
private
int
idFoundation
;
private
HTTPRequest
request
;
private
String
[]
rightsNeeded
;
...
...
@@ -63,6 +64,10 @@ public class NemopaySession {
disconnect
();
}
public
void
setFoundation
(
final
int
idFoundation
)
{
this
.
idFoundation
=
idFoundation
;
}
public
String
getName
()
{
return
this
.
name
;
}
public
String
getKey
()
{
return
this
.
key
;
}
public
String
getUsername
()
{
return
username
;
}
...
...
app/src/main/res/values/strings.xml
View file @
af5a4c5d
...
...
@@ -61,6 +61,7 @@
<string
name=
"information_collection"
>
Récupération d\'informations
</string>
<string
name=
"foundation_list_collecting"
>
Récupération de la liste des fondations
</string>
<string
name=
"foundation_error_get_list"
>
Impossible de récupérer la liste des fondations
</string>
<string
name=
"user_no_rights"
>
n\'a aucun droit. L\'utilisateur a été automatiquement déconnecté
</string>
<string
name=
"no_right"
>
Il est nécessaire d\'avoir au moins le droit suivant:
</string>
<string
name=
"no_rights"
>
Il est nécessaire d\'avoir au moins les droits suivants:
</string>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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