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
2c75015e
Commit
2c75015e
authored
Nov 05, 2017
by
Nastuzzi Samy
Browse files
Keyboard config
Add keyboard config Optimization
parent
ed56531e
Changes
6
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/fr/utc/simde/payutc/ArticleCategoryActivity.java
View file @
2c75015e
package
fr.utc.simde.payutc
;
import
android.os.Bundle
;
import
android.util.Log
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
...
...
@@ -43,8 +44,10 @@ public class ArticleCategoryActivity extends ArticleGroupActivity {
throw
new
Exception
(
"Unexpected JSON"
);
ArrayNode
articlesForThisCategory
=
articlesPerCategory
.
get
(
category
.
get
(
"id"
).
intValue
());
if
(
config
.
getFoundationId
()
!=
-
1
)
if
(!
authorizedList
.
has
(
Integer
.
toString
(
category
.
get
(
"id"
).
intValue
())))
continue
;
if
(
config
.
getFoundationId
()
!=
-
1
)
{
if
(!
authorizedList
.
has
(
Integer
.
toString
(
category
.
get
(
"id"
).
intValue
()))
||
articlesForThisCategory
==
null
)
continue
;
}
else
if
(
articlesForThisCategory
==
null
||
articlesForThisCategory
.
size
()
==
0
)
continue
;
...
...
app/src/main/java/fr/utc/simde/payutc/ArticleGroupActivity.java
View file @
2c75015e
...
...
@@ -134,8 +134,13 @@ public abstract class ArticleGroupActivity extends BaseActivity {
}
else
{
final
View
popupView
=
LayoutInflater
.
from
(
ArticleGroupActivity
.
this
).
inflate
(
R
.
layout
.
dialog_config_restore
,
null
,
false
);
final
Switch
switchCotisant
=
popupView
.
findViewById
(
R
.
id
.
swtich_cotisant
);
final
Switch
swtich18
=
popupView
.
findViewById
(
R
.
id
.
swtich_18
);
final
Button
configButton
=
popupView
.
findViewById
(
R
.
id
.
button_config
);
switchCotisant
.
setChecked
(
config
.
getPrintCotisant
());
swtich18
.
setChecked
(
config
.
getPrint18
());
configButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
...
...
@@ -152,8 +157,11 @@ public abstract class ArticleGroupActivity extends BaseActivity {
.
setTitle
(
R
.
string
.
configuration
)
.
setView
(
popupView
)
.
setCancelable
(
false
)
.
setPositiveButton
(
R
.
string
.
reload
,
new
DialogInterface
.
OnClickListener
()
{
.
setPositiveButton
(
R
.
string
.
applicate
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialogInterface
,
int
id
)
{
config
.
setPrintCotisant
(
switchCotisant
.
isChecked
());
config
.
setPrint18
(
swtich18
.
isChecked
());
startArticleGroupActivity
(
ArticleGroupActivity
.
this
);
}
})
...
...
@@ -193,36 +201,39 @@ public abstract class ArticleGroupActivity extends BaseActivity {
protected
abstract
void
createGroups
(
final
JsonNode
groupList
,
final
JsonNode
articleList
)
throws
Exception
;
protected
void
configApp
()
{
dialog
.
startLoading
(
ArticleGroupActivity
.
this
,
getResources
().
getString
(
R
.
string
.
information_collection
),
getString
(
R
.
string
.
category_list_collecting
));
dialog
.
startLoading
(
ArticleGroupActivity
.
this
,
getResources
().
getString
(
R
.
string
.
information_collection
),
getString
(
config
.
getInKeyboard
()
?
R
.
string
.
keyboard_list_collecting
:
R
.
string
.
category_list_collecting
));
new
Thread
()
{
@Override
public
void
run
()
{
try
{
nemopaySession
.
getCategories
();
if
(
config
.
getInKeyboard
())
nemopaySession
.
getKeyboards
();
else
nemopaySession
.
getCategories
();
Thread
.
sleep
(
100
);
final
HTTPRequest
request
=
nemopaySession
.
getRequest
();
final
JsonNode
category
List
=
request
.
getJSONResponse
();
final
JsonNode
group
List
=
request
.
getJSONResponse
();
if
(!
category
List
.
isArray
())
if
(!
group
List
.
isArray
())
throw
new
Exception
(
"Malformed JSON"
);
if
(
category
List
.
size
()
==
0
)
{
if
(
groupList
==
null
||
group
List
.
size
()
==
0
)
{
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
dialog
.
stopLoading
();
dialog
.
errorDialog
(
ArticleGroupActivity
.
this
,
getString
(
R
.
string
.
information_collection
),
nemopaySession
.
getFoundationName
()
+
" "
+
getString
(
R
.
string
.
category_error_0
));
dialog
.
errorDialog
(
ArticleGroupActivity
.
this
,
getString
(
R
.
string
.
information_collection
),
nemopaySession
.
getFoundationName
()
+
" "
+
getString
(
config
.
getInKeyboard
()
?
R
.
string
.
keyboard_error_0
:
R
.
string
.
category_error_0
));
}
});
return
;
}
for
(
final
JsonNode
category
:
category
List
)
{
if
(!
category
.
has
(
"id"
)
||
!
category
.
has
(
"name"
)
||
!
category
.
has
(
"fundation_id"
)
||
category
.
get
(
"fundation_id"
).
intValue
()
!=
nemopaySession
.
getFoundationId
(
))
for
(
final
JsonNode
group
:
group
List
)
{
if
(!
group
.
has
(
"id"
)
||
!
group
.
has
(
"name"
))
throw
new
Exception
(
"Unexpected JSON"
);
}
}
catch
(
final
Exception
e
)
{
...
...
@@ -231,7 +242,7 @@ public abstract class ArticleGroupActivity extends BaseActivity {
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
fatal
(
ArticleGroupActivity
.
this
,
getString
(
R
.
string
.
category_list_collecting
),
e
.
getMessage
());
fatal
(
ArticleGroupActivity
.
this
,
getString
(
config
.
getInKeyboard
()
?
R
.
string
.
keyboard_list_collecting
:
R
.
string
.
category_list_collecting
),
e
.
getMessage
());
}
});
}
...
...
@@ -247,17 +258,20 @@ public abstract class ArticleGroupActivity extends BaseActivity {
final
Switch
canCancelSwitch
=
popupView
.
findViewById
(
R
.
id
.
swtich_cancel
);
canCancelSwitch
.
setChecked
(
config
.
getCanCancel
());
JsonNode
categoryList
;
if
(
config
.
getInKeyboard
())
((
TextView
)
popupView
.
findViewById
(
R
.
id
.
text_to_print
)).
setText
(
R
.
string
.
keyboard_list
);
JsonNode
groupList
;
GroupAdapter
groupAdapter
=
null
;
try
{
category
List
=
nemopaySession
.
getRequest
().
getJSONResponse
();
groupAdapter
=
new
GroupAdapter
(
ArticleGroupActivity
.
this
,
category
List
);
group
List
=
nemopaySession
.
getRequest
().
getJSONResponse
();
groupAdapter
=
new
GroupAdapter
(
ArticleGroupActivity
.
this
,
group
List
);
listView
.
setAdapter
(
groupAdapter
);
}
catch
(
Exception
e
)
{
Log
.
e
(
LOG_TAG
,
"error: "
+
e
.
getMessage
());
fatal
(
ArticleGroupActivity
.
this
,
getString
(
R
.
string
.
category_list_collecting
),
e
.
getMessage
());
fatal
(
ArticleGroupActivity
.
this
,
getString
(
config
.
getInKeyboard
()
?
R
.
string
.
keyboard_list_collecting
:
R
.
string
.
category_list_collecting
),
e
.
getMessage
());
}
final
AlertDialog
.
Builder
alertDialogBuilder
=
new
AlertDialog
.
Builder
(
ArticleGroupActivity
.
this
);
...
...
@@ -269,9 +283,10 @@ public abstract class ArticleGroupActivity extends BaseActivity {
.
setPositiveButton
(
R
.
string
.
applicate
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialogInterface
,
int
id
)
{
config
.
setCanCancel
(
canCancelSwitch
.
isChecked
());
JsonNode
groupList
=
finalGroupAdapter
.
getList
();
if
(
finalGroupAdapter
.
get
List
()
.
size
()
==
0
)
{
Toast
.
makeText
(
ArticleGroupActivity
.
this
,
getString
(
R
.
string
.
category_0_selected
),
Toast
.
LENGTH_LONG
).
show
();
if
(
groupList
==
null
||
group
List
.
size
()
==
0
)
{
Toast
.
makeText
(
ArticleGroupActivity
.
this
,
getString
(
config
.
getInKeyboard
()
?
R
.
string
.
keyboard_0_selected
:
R
.
string
.
category_0_selected
),
Toast
.
LENGTH_LONG
).
show
();
configApp
();
}
else
{
...
...
app/src/main/java/fr/utc/simde/payutc/articles/GridAdapter.java
View file @
2c75015e
...
...
@@ -60,7 +60,7 @@ public class GridAdapter extends ArticlesAdapter {
RelativeLayout
.
LayoutParams
parms
=
new
RelativeLayout
.
LayoutParams
(
this
.
size
,
this
.
size
);
imageView
.
setLayoutParams
(
parms
);
if
(
article
.
size
()
==
0
)
if
(
article
==
null
||
article
.
size
()
==
0
)
view
.
setVisibility
(
View
.
INVISIBLE
);
else
{
if
(
clickViewList
[
position
]
==
null
)
...
...
app/src/main/java/fr/utc/simde/payutc/articles/GroupFragment.java
View file @
2c75015e
package
fr.utc.simde.payutc.articles
;
import
android.app.Activity
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.AdapterView
;
...
...
app/src/main/res/layout/dialog_config_restore.xml
View file @
2c75015e
...
...
@@ -10,15 +10,47 @@
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"25dp"
android:layout_marginLeft=
"25dp"
android:layout_marginRight=
"25dp"
android:text=
"@string/print_mode"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"25dp"
android:layout_marginRight=
"25dp"
android:textColor=
"#000000"
android:text=
"@string/app_configurated"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"25dp"
android:layout_marginLeft=
"25dp"
android:layout_marginRight=
"25dp"
android:text=
"@string/filters"
/>
<Switch
android:id=
"@+id/swtich_cotisant"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"25dp"
android:layout_marginRight=
"25dp"
android:text=
"@string/print_cotisant"
/>
<Switch
android:id=
"@+id/swtich_18"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"25dp"
android:layout_marginRight=
"25dp"
android:text=
"@string/print_18"
/>
<Button
android:id=
"@+id/button_config"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"25dp"
android:layout_marginLeft=
"25dp"
android:layout_marginRight=
"25dp"
android:text=
"@string/configurate_by_default"
/>
...
...
app/src/main/res/layout/dialog_group.xml
View file @
2c75015e
...
...
@@ -5,24 +5,24 @@
android:layout_height=
"match_parent"
>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"25dp"
android:layout_marginLeft=
"25dp"
android:layout_marginRight=
"25dp"
android:text=
"@string/filters"
/>
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"25dp"
android:layout_marginLeft=
"25dp"
android:layout_marginRight=
"25dp"
android:text=
"@string/filters"
/>
<Switch
android:id=
"@+id/swtich_cancel"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"25dp"
android:layout_marginRight=
"25dp"
android:checked=
"true"
android:text=
"@string/can_cancel"
/>
<Switch
android:id=
"@+id/swtich_cancel"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"25dp"
android:layout_marginRight=
"25dp"
android:checked=
"true"
android:text=
"@string/can_cancel"
/>
<TextView
android:id=
"@+id/text
View
"
android:id=
"@+id/text
_to_print
"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"25dp"
...
...
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