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-06-05 16:22:35 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
82ad1b7a2049c9e62a1da8bc922efaa580c18d08
82ad1b7a
1 parent
8be1f5ea
fixed logout
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
4 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/managers/WarplyManager.java
warply_android_sdk/build.gradle
View file @
82ad1b7
...
...
@@ -5,7 +5,7 @@ android.buildFeatures.buildConfig = true
ext
{
PUBLISH_GROUP_ID
=
'ly.warp'
PUBLISH_VERSION
=
'4.5.5.4m
3
'
PUBLISH_VERSION
=
'4.5.5.4m
4
'
PUBLISH_ARTIFACT_ID
=
'warply-android-sdk'
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarpUtils.java
View file @
82ad1b7
...
...
@@ -166,6 +166,14 @@ public class WarpUtils {
+
"app_locale"
;
private
static
final
String
PREFERENCES_KEY_DARK_MODE_ENABLED
=
PREFERENCES_PREFIX
+
"dark_mode_enabled"
;
private
static
final
String
PREFERENCES_KEY_CLIENT_ID
=
PREFERENCES_PREFIX
+
"client_id"
;
private
static
final
String
PREFERENCES_KEY_CLIENT_SECRET
=
PREFERENCES_PREFIX
+
"client_secret"
;
private
static
final
String
PREFERENCES_KEY_ACCESS_TOKEN
=
PREFERENCES_PREFIX
+
"access_token"
;
private
static
final
String
PREFERENCES_KEY_REFRESH_TOKEN
=
PREFERENCES_PREFIX
+
"refresh_token"
;
private
static
SharedPreferences
_prefs
;
...
...
@@ -758,6 +766,81 @@ public class WarpUtils {
}
/**
* Client and Auth Access Methods
*/
public
static
void
saveClientAccess
(
Context
context
,
String
clientId
,
String
clientSecret
)
{
SharedPreferences
.
Editor
editor
=
getPreferences
(
context
).
edit
();
if
(!
TextUtils
.
isEmpty
(
clientId
))
{
editor
.
putString
(
PREFERENCES_KEY_CLIENT_ID
,
clientId
);
}
if
(!
TextUtils
.
isEmpty
(
clientSecret
))
{
editor
.
putString
(
PREFERENCES_KEY_CLIENT_SECRET
,
clientSecret
);
}
editor
.
apply
();
}
public
static
void
saveAuthAccess
(
Context
context
,
String
accessToken
,
String
refreshToken
)
{
SharedPreferences
.
Editor
editor
=
getPreferences
(
context
).
edit
();
if
(!
TextUtils
.
isEmpty
(
accessToken
))
{
editor
.
putString
(
PREFERENCES_KEY_ACCESS_TOKEN
,
accessToken
);
}
if
(!
TextUtils
.
isEmpty
(
refreshToken
))
{
editor
.
putString
(
PREFERENCES_KEY_REFRESH_TOKEN
,
refreshToken
);
}
editor
.
apply
();
}
public
static
String
getClientValue
(
Context
context
,
String
key
)
{
SharedPreferences
prefs
=
getPreferences
(
context
);
switch
(
key
)
{
case
"client_id"
:
return
prefs
.
getString
(
PREFERENCES_KEY_CLIENT_ID
,
""
);
case
"client_secret"
:
return
prefs
.
getString
(
PREFERENCES_KEY_CLIENT_SECRET
,
""
);
default
:
return
""
;
}
}
public
static
String
getAuthValue
(
Context
context
,
String
key
)
{
SharedPreferences
prefs
=
getPreferences
(
context
);
switch
(
key
)
{
case
"access_token"
:
return
prefs
.
getString
(
PREFERENCES_KEY_ACCESS_TOKEN
,
""
);
case
"refresh_token"
:
return
prefs
.
getString
(
PREFERENCES_KEY_REFRESH_TOKEN
,
""
);
default
:
return
""
;
}
}
public
static
boolean
hasClientAccess
(
Context
context
)
{
SharedPreferences
prefs
=
getPreferences
(
context
);
return
!
TextUtils
.
isEmpty
(
prefs
.
getString
(
PREFERENCES_KEY_CLIENT_ID
,
""
))
&&
!
TextUtils
.
isEmpty
(
prefs
.
getString
(
PREFERENCES_KEY_CLIENT_SECRET
,
""
));
}
public
static
boolean
hasAuthAccess
(
Context
context
)
{
SharedPreferences
prefs
=
getPreferences
(
context
);
return
!
TextUtils
.
isEmpty
(
prefs
.
getString
(
PREFERENCES_KEY_ACCESS_TOKEN
,
""
))
&&
!
TextUtils
.
isEmpty
(
prefs
.
getString
(
PREFERENCES_KEY_REFRESH_TOKEN
,
""
));
}
public
static
void
clearClientAccess
(
Context
context
)
{
SharedPreferences
.
Editor
editor
=
getPreferences
(
context
).
edit
();
editor
.
remove
(
PREFERENCES_KEY_CLIENT_ID
);
editor
.
remove
(
PREFERENCES_KEY_CLIENT_SECRET
);
editor
.
apply
();
}
public
static
void
clearAuthAccess
(
Context
context
)
{
SharedPreferences
.
Editor
editor
=
getPreferences
(
context
).
edit
();
editor
.
remove
(
PREFERENCES_KEY_ACCESS_TOKEN
);
editor
.
remove
(
PREFERENCES_KEY_REFRESH_TOKEN
);
editor
.
apply
();
}
/**
* END
* New checks for sending logs to server
*/
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
View file @
82ad1b7
...
...
@@ -152,14 +152,14 @@ public class WarplyManager {
String
webId
=
WarpUtils
.
getWebId
(
Warply
.
getWarplyContext
());
Map
<
String
,
Object
>
jsonParams
=
new
ArrayMap
<>();
if
(
WarpUtils
.
isJWTEnabled
(
Warply
.
getWarplyContext
()))
{
//
if (WarpUtils.isJWTEnabled(Warply.getWarplyContext())) {
jsonParams
.
put
(
"access_token"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"access_token"
));
jsonParams
.
put
(
"refresh_token"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"refresh_token"
));
}
else
{
//
} else {
jsonParams
.
put
(
"token"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"access_token"
));
jsonParams
.
put
(
"client_id"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_id"
));
jsonParams
.
put
(
"client_secret"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_secret"
));
}
//
}
RequestBody
loginRequest
=
RequestBody
.
create
(
MediaType
.
get
(
"application/json; charset=utf-8"
),
(
new
JSONObject
(
jsonParams
)).
toString
());
...
...
Please
register
or
login
to post a comment