Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_android_sdk_maven_plugin
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Panagiotis Triantafyllou
2025-03-17 12:37:44 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
039d031fa68d08d1d93c30d863027f168efb9744
039d031f
1 parent
190948c0
new version, locale and dark mode prefs
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
9 deletions
warply_android_sdk/build.gradle
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarpUtils.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyManagerHelper.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
warply_android_sdk/build.gradle
View file @
039d031
...
...
@@ -5,7 +5,7 @@ android.buildFeatures.buildConfig = true
ext
{
PUBLISH_GROUP_ID
=
'ly.warp'
PUBLISH_VERSION
=
'4.5.5.4m
1
'
PUBLISH_VERSION
=
'4.5.5.4m
2
'
PUBLISH_ARTIFACT_ID
=
'warply-android-sdk'
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarpUtils.java
View file @
039d031
...
...
@@ -43,6 +43,7 @@ import android.graphics.drawable.LayerDrawable;
import
android.graphics.drawable.ShapeDrawable
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.util.Base64
;
import
android.util.Log
;
import
android.view.Gravity
;
...
...
@@ -161,11 +162,39 @@ public class WarpUtils {
+
"steps_manually_stopped"
;
private
static
final
String
PREFERENCES_KEY_JWT_ENABLED
=
PREFERENCES_PREFIX
+
"jwt_enabled"
;
private
static
final
String
PREFERENCES_KEY_APP_LOCALE
=
PREFERENCES_PREFIX
+
"app_locale"
;
private
static
final
String
PREFERENCES_KEY_DARK_MODE_ENABLED
=
PREFERENCES_PREFIX
+
"dark_mode_enabled"
;
private
static
SharedPreferences
_prefs
;
/* Public methods */
public
static
String
getApplicationLocale
(
Context
context
)
{
return
getPreferences
(
context
).
getString
(
PREFERENCES_KEY_APP_LOCALE
,
"el"
);
}
public
static
void
setApplicationLocale
(
Context
context
,
String
localeParam
)
{
String
tempLocale
=
localeParam
.
toLowerCase
();
if
(
"gr"
.
equals
(
tempLocale
))
{
tempLocale
=
"el"
;
}
SharedPreferences
.
Editor
editor
=
getPreferences
(
context
).
edit
();
editor
.
putString
(
PREFERENCES_KEY_APP_LOCALE
,
TextUtils
.
isEmpty
(
tempLocale
)
?
"el"
:
tempLocale
);
editor
.
apply
();
}
public
static
boolean
getIsDarkModeEnabled
(
Context
context
)
{
return
getPreferences
(
context
).
getBoolean
(
PREFERENCES_KEY_DARK_MODE_ENABLED
,
false
);
}
public
static
void
setIsDarkModeEnabled
(
Context
context
,
boolean
isDarkModeEnabled
)
{
SharedPreferences
.
Editor
editor
=
getPreferences
(
context
).
edit
();
editor
.
putBoolean
(
PREFERENCES_KEY_DARK_MODE_ENABLED
,
isDarkModeEnabled
);
editor
.
apply
();
}
public
static
boolean
getIsSteps
(
Context
context
)
{
return
getPreferences
(
context
).
getBoolean
(
PREFERENCES_KEY_STEPS
,
false
);
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyManagerHelper.java
View file @
039d031
...
...
@@ -107,6 +107,8 @@ public class WarplyManagerHelper {
params
.
putOpt
(
"refresh_token"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"refresh_token"
));
params
.
putOpt
(
"client_id"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_id"
));
params
.
putOpt
(
"client_secret"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_secret"
));
params
.
putOpt
(
"lan"
,
WarpUtils
.
getApplicationLocale
(
Warply
.
getWarplyContext
()));
params
.
putOpt
(
"dark"
,
String
.
valueOf
(
WarpUtils
.
getIsDarkModeEnabled
(
Warply
.
getWarplyContext
())));
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -131,6 +133,8 @@ public class WarplyManagerHelper {
params
.
putOpt
(
"refresh_token"
,
WarplyDBHelper
.
getInstance
(
context
).
getAuthValue
(
"refresh_token"
));
params
.
putOpt
(
"client_id"
,
WarplyDBHelper
.
getInstance
(
context
).
getClientValue
(
"client_id"
));
params
.
putOpt
(
"client_secret"
,
WarplyDBHelper
.
getInstance
(
context
).
getClientValue
(
"client_secret"
));
params
.
putOpt
(
"lan"
,
WarpUtils
.
getApplicationLocale
(
context
));
params
.
putOpt
(
"dark"
,
String
.
valueOf
(
WarpUtils
.
getIsDarkModeEnabled
(
context
)));
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -152,6 +156,8 @@ public class WarplyManagerHelper {
params
.
putOpt
(
"client_id"
,
WarplyDBHelper
.
getInstance
(
context
).
getClientValue
(
"client_id"
));
params
.
putOpt
(
"client_secret"
,
WarplyDBHelper
.
getInstance
(
context
).
getClientValue
(
"client_secret"
));
params
.
putOpt
(
"map"
,
"true"
);
params
.
putOpt
(
"lan"
,
WarpUtils
.
getApplicationLocale
(
context
));
params
.
putOpt
(
"dark"
,
String
.
valueOf
(
WarpUtils
.
getIsDarkModeEnabled
(
context
)));
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
View file @
039d031
...
...
@@ -163,7 +163,26 @@ public class WarplyManager {
RequestBody
loginRequest
=
RequestBody
.
create
(
MediaType
.
get
(
"application/json; charset=utf-8"
),
(
new
JSONObject
(
jsonParams
)).
toString
());
Call
<
ResponseBody
>
logoutCall
=
WarpUtils
.
isJWTEnabled
(
Warply
.
getWarplyContext
())
?
service
.
logoutUserJwt
(
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()),
loginRequest
,
timeStamp
,
"android:"
+
Warply
.
getWarplyContext
().
getPackageName
(),
new
WarplyDeviceInfoCollector
(
Warply
.
getWarplyContext
()).
getUniqueDeviceId
(),
"mobile"
,
webId
,
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
))
:
service
.
logoutUser
(
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()),
loginRequest
,
timeStamp
,
"android:"
+
Warply
.
getWarplyContext
().
getPackageName
(),
new
WarplyDeviceInfoCollector
(
Warply
.
getWarplyContext
()).
getUniqueDeviceId
(),
"mobile"
,
webId
,
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
));
Call
<
ResponseBody
>
logoutCall
=
WarpUtils
.
isJWTEnabled
(
Warply
.
getWarplyContext
())
?
service
.
logoutUserJwt
(
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()),
loginRequest
,
timeStamp
,
"android:"
+
Warply
.
getWarplyContext
().
getPackageName
(),
new
WarplyDeviceInfoCollector
(
Warply
.
getWarplyContext
()).
getUniqueDeviceId
(),
"mobile"
,
webId
,
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
)
)
:
service
.
logoutUser
(
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()),
loginRequest
,
timeStamp
,
"android:"
+
Warply
.
getWarplyContext
().
getPackageName
(),
new
WarplyDeviceInfoCollector
(
Warply
.
getWarplyContext
()).
getUniqueDeviceId
(),
"mobile"
,
webId
,
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
)
);
logoutCall
.
enqueue
(
new
Callback
<
ResponseBody
>()
{
@Override
...
...
@@ -237,7 +256,17 @@ public class WarplyManager {
RequestBody
loginRequest
=
RequestBody
.
create
(
MediaType
.
get
(
"application/json; charset=utf-8"
),
(
new
JSONObject
(
jsonParams
)).
toString
());
Call
<
ResponseBody
>
loginCall
=
service
.
cosmoteUser
(
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()),
loginRequest
,
timeStamp
,
"android:"
+
Warply
.
getWarplyContext
().
getPackageName
(),
new
WarplyDeviceInfoCollector
(
Warply
.
getWarplyContext
()).
getUniqueDeviceId
(),
"mobile"
,
webId
,
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
),
"Basic MVBQNFhCQzhFYTJBaUdCNkJWZGFGUERlTTNLQ3kzMjU6YzViMzAyZDY5N2FiNGY3NzhiNThhMTg0YzBkZWRmNGU="
);
Call
<
ResponseBody
>
loginCall
=
service
.
cosmoteUser
(
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()),
loginRequest
,
timeStamp
,
"android:"
+
Warply
.
getWarplyContext
().
getPackageName
(),
new
WarplyDeviceInfoCollector
(
Warply
.
getWarplyContext
()).
getUniqueDeviceId
(),
"mobile"
,
webId
,
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
),
"Basic MVBQNFhCQzhFYTJBaUdCNkJWZGFGUERlTTNLQ3kzMjU6YzViMzAyZDY5N2FiNGY3NzhiNThhMTg0YzBkZWRmNGU="
);
loginCall
.
enqueue
(
new
Callback
<
ResponseBody
>()
{
@Override
...
...
@@ -323,7 +352,15 @@ public class WarplyManager {
RequestBody
loginRequest
=
RequestBody
.
create
(
MediaType
.
get
(
"application/json; charset=utf-8"
),
(
new
JSONObject
(
jsonParams
)).
toString
());
Call
<
ResponseBody
>
loginCall
=
service
.
verifyUser
(
loginRequest
,
timeStamp
,
"android:"
+
Warply
.
getWarplyContext
().
getPackageName
(),
new
WarplyDeviceInfoCollector
(
Warply
.
getWarplyContext
()).
getUniqueDeviceId
(),
"mobile"
,
webId
,
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
));
Call
<
ResponseBody
>
loginCall
=
service
.
verifyUser
(
loginRequest
,
timeStamp
,
"android:"
+
Warply
.
getWarplyContext
().
getPackageName
(),
new
WarplyDeviceInfoCollector
(
Warply
.
getWarplyContext
()).
getUniqueDeviceId
(),
"mobile"
,
webId
,
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
)
);
loginCall
.
enqueue
(
new
Callback
<
ResponseBody
>()
{
@Override
...
...
@@ -516,7 +553,7 @@ public class WarplyManager {
Map
<
String
,
Object
>
jsonParams
=
new
ArrayMap
<>();
jsonParams
.
put
(
"action"
,
"retrieve"
);
jsonParams
.
put
(
"filters"
,
new
JSONObject
());
jsonParams
.
put
(
"language"
,
Warp
lyProperty
.
getLanguag
e
(
Warply
.
getWarplyContext
()));
jsonParams
.
put
(
"language"
,
Warp
Utils
.
getApplicationLocal
e
(
Warply
.
getWarplyContext
()));
jsonParamsCampaigns
.
put
(
"campaigns"
,
jsonParams
);
RequestBody
campaignsRequest
=
RequestBody
.
create
(
MediaType
.
get
(
"application/json; charset=utf-8"
),
(
new
JSONObject
(
jsonParamsCampaigns
)).
toString
());
...
...
@@ -655,7 +692,7 @@ public class WarplyManager {
Map
<
String
,
Object
>
jsonParams
=
new
ArrayMap
<>();
jsonParams
.
put
(
"action"
,
"retrieve"
);
jsonParams
.
put
(
"filters"
,
new
JSONObject
());
jsonParams
.
put
(
"language"
,
Warp
lyProperty
.
getLanguag
e
(
Warply
.
getWarplyContext
()));
jsonParams
.
put
(
"language"
,
Warp
Utils
.
getApplicationLocal
e
(
Warply
.
getWarplyContext
()));
jsonParamsCampaigns
.
put
(
"campaigns"
,
jsonParams
);
RequestBody
campaignsPersonalizedRequest
=
RequestBody
.
create
(
MediaType
.
get
(
"application/json; charset=utf-8"
),
(
new
JSONObject
(
jsonParamsCampaigns
)).
toString
());
...
...
@@ -987,7 +1024,7 @@ public class WarplyManager {
jArr
.
put
(
"merchant"
);
jArr
.
put
(
"redemption"
);
jsonParams
.
put
(
"details"
,
jArr
);
jsonParams
.
put
(
"language"
,
Warp
lyProperty
.
getLanguag
e
(
Warply
.
getWarplyContext
()));
jsonParams
.
put
(
"language"
,
Warp
Utils
.
getApplicationLocal
e
(
Warply
.
getWarplyContext
()));
jsonParams
.
put
(
"couponset_types"
,
new
JSONArray
().
put
(
"supermarket"
));
jsonParamsCoupons
.
put
(
"coupon"
,
jsonParams
);
...
...
@@ -1113,7 +1150,7 @@ public class WarplyManager {
jArr
.
put
(
"merchant"
);
jArr
.
put
(
"redemption"
);
jsonParams
.
put
(
"details"
,
jArr
);
jsonParams
.
put
(
"language"
,
Warp
lyProperty
.
getLanguag
e
(
Warply
.
getWarplyContext
()));
jsonParams
.
put
(
"language"
,
Warp
Utils
.
getApplicationLocal
e
(
Warply
.
getWarplyContext
()));
// JSONObject jPagination= new JSONObject();
// try {
// jPagination.putOpt("page",1);
...
...
@@ -1316,7 +1353,7 @@ public class WarplyManager {
}
jsonParams
.
put
(
"action"
,
"retrieve"
);
jsonParams
.
put
(
"filters"
,
jFilters
);
jsonParams
.
put
(
"language"
,
Warp
lyProperty
.
getLanguag
e
(
Warply
.
getWarplyContext
()));
jsonParams
.
put
(
"language"
,
Warp
Utils
.
getApplicationLocal
e
(
Warply
.
getWarplyContext
()));
jsonParamsCampaigns
.
put
(
"campaigns"
,
jsonParams
);
RequestBody
campaignsRequest
=
RequestBody
.
create
(
MediaType
.
get
(
"application/json; charset=utf-8"
),
(
new
JSONObject
(
jsonParamsCampaigns
)).
toString
());
...
...
Please
register
or
login
to post a comment