Skip to content
GitLab
Menu
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
fe6e5c97
Commit
fe6e5c97
authored
Nov 21, 2017
by
Nastuzzi Samy
Browse files
Preparation of selling by QRCode
Add new class with better jackson management Introduce SellByQrCode
parent
1319d374
Changes
9
Hide whitespace changes
Inline
Side-by-side
app/src/main/AndroidManifest.xml
View file @
fe6e5c97
...
...
@@ -43,6 +43,9 @@
<activity
android:name=
"fr.utc.simde.jessy.SellActivity"
android:configChanges=
"orientation"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
"fr.utc.simde.jessy.SellByQRCodeActivity"
android:configChanges=
"orientation"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
"fr.utc.simde.jessy.EditActivity"
android:configChanges=
"orientation"
android:screenOrientation=
"portrait"
/>
...
...
app/src/main/java/fr/utc/simde/jessy/BaseActivity.java
View file @
fe6e5c97
...
...
@@ -248,6 +248,10 @@ public abstract class BaseActivity extends InternetActivity {
startArticleGroupActivity
(
activity
,
new
Intent
(
activity
,
SellActivity
.
class
));
}
public
void
startSellByQRCodeActivity
(
final
Activity
activity
)
{
startActivity
(
new
Intent
(
activity
,
SellByQRCodeActivity
.
class
));
}
public
void
startEditActivity
(
final
Activity
activity
)
{
startArticleGroupActivity
(
activity
,
new
Intent
(
activity
,
EditActivity
.
class
));
}
...
...
app/src/main/java/fr/utc/simde/jessy/MainActivity.java
View file @
fe6e5c97
...
...
@@ -102,6 +102,8 @@ public class MainActivity extends BaseActivity {
setConfig
();
checkUpdate
(
false
);
startSellByQRCodeActivity
(
MainActivity
.
this
);
}
@Override
...
...
app/src/main/java/fr/utc/simde/jessy/QRCodeReaderActivity.java
View file @
fe6e5c97
...
...
@@ -17,11 +17,10 @@ import static android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK;
* Created by Samy on 18/11/2017.
*/
public
class
QRCodeReaderActivity
extends
BaseActivity
{
public
class
QRCodeReaderActivity
extends
BaseActivity
implements
ZXingScannerView
.
ResultHandler
{
private
static
final
String
LOG_TAG
=
"_QRCodeReaderActivity"
;
protected
ZXingScannerView
scannerView
;
protected
ZXingScannerView
.
ResultHandler
cameraHandler
;
@Override
public
void
onCreate
(
final
Bundle
savedInstanceState
)
{
...
...
@@ -35,21 +34,7 @@ public class QRCodeReaderActivity extends BaseActivity {
};
setContentView
(
this
.
scannerView
);
this
.
cameraHandler
=
new
ZXingScannerView
.
ResultHandler
()
{
@Override
public
void
handleResult
(
Result
result
)
{
Log
.
d
(
LOG_TAG
,
result
.
getText
());
Log
.
d
(
LOG_TAG
,
result
.
getBarcodeFormat
().
toString
());
dialog
.
infoDialog
(
QRCodeReaderActivity
.
this
,
getString
(
R
.
string
.
qrcode_reading
),
result
.
getText
(),
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
scannerView
.
resumeCameraPreview
(
cameraHandler
);
}
});
}
};
this
.
scannerView
.
setResultHandler
(
this
.
cameraHandler
);
scannerView
.
setResultHandler
(
QRCodeReaderActivity
.
this
);
this
.
scannerView
.
startCamera
(
CAMERA_FACING_BACK
);
}
...
...
@@ -63,4 +48,20 @@ public class QRCodeReaderActivity extends BaseActivity {
}
});
}
@Override
public
void
handleResult
(
Result
result
)
{
Log
.
d
(
LOG_TAG
,
result
.
getText
());
Log
.
d
(
LOG_TAG
,
result
.
getBarcodeFormat
().
toString
());
dialog
.
infoDialog
(
QRCodeReaderActivity
.
this
,
getString
(
R
.
string
.
qrcode_reading
),
result
.
getText
(),
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
resumeReading
();
}
});
}
protected
void
resumeReading
()
{
scannerView
.
resumeCameraPreview
(
QRCodeReaderActivity
.
this
);
}
}
app/src/main/java/fr/utc/simde/jessy/SellActivity.java
View file @
fe6e5c97
...
...
@@ -31,8 +31,15 @@ public class SellActivity extends ArticleGroupActivity {
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
TextView
textView
=
findViewById
(
R
.
id
.
text_price
);
this
.
panier
=
new
Panier
(
textView
);
TextView
panierText
=
findViewById
(
R
.
id
.
text_price
);
this
.
panier
=
new
Panier
(
panierText
);
panierText
.
setOnClickListener
(
new
TextView
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
startSellByQRCodeActivity
(
SellActivity
.
this
);
}
});
generate
();
}
...
...
app/src/main/java/fr/utc/simde/jessy/SellByQRCodeActivity.java
0 → 100644
View file @
fe6e5c97
package
fr.utc.simde.jessy
;
import
android.content.DialogInterface
;
import
android.util.Log
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.google.zxing.Result
;
import
fr.utc.simde.jessy.objects.GingerResponse
;
import
fr.utc.simde.jessy.objects.QRCodeResponse
;
public
class
SellByQRCodeActivity
extends
QRCodeReaderActivity
{
private
static
final
String
LOG_TAG
=
"_SellByQRCodeActivity"
;
@Override
public
void
handleResult
(
Result
result
)
{
Log
.
d
(
LOG_TAG
,
result
.
getText
());
Log
.
d
(
LOG_TAG
,
result
.
getBarcodeFormat
().
toString
());
try
{
final
QRCodeResponse
qrCodeResponse
=
new
ObjectMapper
().
readValue
(
result
.
getText
(),
QRCodeResponse
.
class
);
dialog
.
startLoading
(
SellByQRCodeActivity
.
this
,
getString
(
R
.
string
.
qrcode_reading
),
getString
(
R
.
string
.
user_ginger_info_collecting
));
new
Thread
()
{
@Override
public
void
run
()
{
try
{
ginger
.
getInfo
(
qrCodeResponse
.
getUsername
());
Thread
.
sleep
(
100
);
}
catch
(
final
Exception
e
)
{
Log
.
e
(
LOG_TAG
,
e
.
getMessage
());
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
dialog
.
infoDialog
(
SellByQRCodeActivity
.
this
,
getString
(
R
.
string
.
qrcode_reading
),
e
.
getMessage
(),
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
resumeReading
();
}
});
}
});
}
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
dialog
.
infoDialog
(
SellByQRCodeActivity
.
this
,
getString
(
R
.
string
.
qrcode_reading
),
(
new
ObjectMapper
().
readValue
(
ginger
.
getRequest
().
getResponse
(),
GingerResponse
.
class
)).
toString
(),
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
resumeReading
();
}
});
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
});
}
}.
start
();
}
catch
(
Exception
e
)
{
Log
.
e
(
LOG_TAG
,
e
.
getMessage
());
dialog
.
infoDialog
(
SellByQRCodeActivity
.
this
,
getString
(
R
.
string
.
qrcode_reading
),
e
.
getMessage
(),
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
finish
();
}
});
}
}
}
app/src/main/java/fr/utc/simde/jessy/objects/GingerResponse.java
0 → 100644
View file @
fe6e5c97
package
fr.utc.simde.jessy.objects
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
/**
* Created by Samy on 10/11/2017.
*/
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
GingerResponse
{
protected
String
login
;
protected
String
nom
;
protected
String
prenom
;
protected
String
mail
;
protected
String
type
;
protected
boolean
is_adulte
;
protected
boolean
is_cotisant
;
protected
String
badge_uid
;
public
String
getUsername
()
{
return
login
;
}
public
String
getLastname
()
{
return
nom
;
}
public
String
getFirstname
()
{
return
prenom
;
}
public
String
getEmail
()
{
return
mail
;
}
public
String
getType
()
{
return
type
;
}
public
boolean
getIsAdult
()
{
return
is_adulte
;
}
public
boolean
getIsContributer
()
{
return
is_cotisant
;
}
public
String
getBadgeId
()
{
return
badge_uid
;
}
}
app/src/main/java/fr/utc/simde/jessy/objects/QRCodeResponse.java
0 → 100644
View file @
fe6e5c97
package
fr.utc.simde.jessy.objects
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
/**
* Created by Samy on 21/11/2017.
*/
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
QRCodeResponse
{
private
String
username
;
private
String
id
;
public
String
getUsername
()
{
return
this
.
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
getId
()
{
return
this
.
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
}
app/src/main/java/fr/utc/simde/jessy/tools/Ginger.java
View file @
fe6e5c97
...
...
@@ -10,10 +10,6 @@ import java.util.Map;
import
fr.utc.simde.jessy.R
;
/**
* Created by Samy on 10/11/2017.
*/
public
class
Ginger
{
private
static
final
String
LOG_TAG
=
"_Ginger"
;
private
static
final
String
url
=
"https://assos.utc.fr/ginger/v1/"
;
...
...
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