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
2023-12-05 11:54:05 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
822cef73e63867bb4575394b9182697cae7e2816
822cef73
1 parent
52cbbc8a
crash fixes
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
178 additions
and
157 deletions
warply_android_sdk/src/main/java/ly/warp/sdk/Warply.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyManagerHelper.java
warply_android_sdk/src/main/java/ly/warp/sdk/views/WarpView.java
warply_android_sdk/src/main/java/ly/warp/sdk/Warply.java
View file @
822cef7
...
...
@@ -1586,8 +1586,8 @@ public enum Warply {
}
}
if
(
INSTANCE
.
mRequestQueue
==
null
)
INSTANCE
.
mRequestQueue
=
Volley
.
newRequestQueue
(
mContext
);
if
(
INSTANCE
.
mRequestQueue
==
null
&&
INSTANCE
.
mContext
!=
null
)
INSTANCE
.
mRequestQueue
=
Volley
.
newRequestQueue
(
INSTANCE
.
mContext
);
if
(
tempAnalytics
!=
null
&&
tempAnalytics
.
length
()
>
0
)
{
String
urlAnalytics
=
WarplyProperty
.
getBaseUrl
(
mContext
)
+
WarpConstants
.
WARPLY_ASYNC
+
WarpConstants
.
WARPLY_ANALYTICS
+
WarplyProperty
.
getAppUuid
(
mContext
)
+
"/"
;
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyManagerHelper.java
View file @
822cef7
...
...
@@ -247,7 +247,7 @@ public class WarplyManagerHelper {
/**
* Handle sharing flow
*/
public
static
void
handleSharing
(
Context
context
,
String
sharingId
)
{
public
static
void
handleSharing
(
Activity
context
,
String
sharingId
)
{
WarpUtils
.
log
(
"SHARING_ID: "
+
sharingId
);
WarplyManager
.
cosmoteSharing
(
new
CosmoteSharingRequest
().
setSharingId
(
sharingId
),
new
CallbackReceiver
<
JSONObject
>()
{
@Override
...
...
@@ -292,205 +292,223 @@ public class WarplyManagerHelper {
/**
* First dialog when we handle the deeplink
*/
private
static
void
initialSharingDialog
(
Context
context
,
String
alertTitle
,
String
sharingId
,
boolean
isSupermarket
)
{
mAlertDialogSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cos_dlg_success_title
)
.
setMessage
(
alertTitle
)
.
setNegativeButton
(
R
.
string
.
cos_dlg_negative_button
,
(
dialogPositive
,
whichPositive
)
->
{
rejectSharingDialog
(
context
,
sharingId
);
})
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button
,
(
dialogNegative
,
whichNegative
)
->
{
WarplyManager
.
cosmoteRetrieveSharing
(
new
CosmoteRetrieveSharingRequest
()
.
setSharingId
(
sharingId
)
.
setAccept
(
true
),
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
int
status
=
result
.
optInt
(
"status"
,
2
);
if
(
status
==
1
)
{
WarplyManager
.
getUserCouponsWithCouponsets
(
new
CallbackReceiver
<
CouponList
>()
{
@Override
public
void
onSuccess
(
CouponList
result
)
{
WarplyCouponsChangedEventModel
couponsChanged
=
new
WarplyCouponsChangedEventModel
();
couponsChanged
.
setChanged
(
true
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
couponsChanged
));
}
@Override
public
void
onFailure
(
int
errorCode
)
{
}
});
acceptSharingDialog
(
context
,
isSupermarket
);
}
else
errorSharingDialog
(
context
);
}
private
static
void
initialSharingDialog
(
Activity
context
,
String
alertTitle
,
String
sharingId
,
boolean
isSupermarket
)
{
if
(!
context
.
isFinishing
())
{
mAlertDialogSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cos_dlg_success_title
)
.
setMessage
(
alertTitle
)
.
setNegativeButton
(
R
.
string
.
cos_dlg_negative_button
,
(
dialogPositive
,
whichPositive
)
->
{
rejectSharingDialog
(
context
,
sharingId
);
})
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button
,
(
dialogNegative
,
whichNegative
)
->
{
WarplyManager
.
cosmoteRetrieveSharing
(
new
CosmoteRetrieveSharingRequest
()
.
setSharingId
(
sharingId
)
.
setAccept
(
true
),
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
int
status
=
result
.
optInt
(
"status"
,
2
);
if
(
status
==
1
)
{
WarplyManager
.
getUserCouponsWithCouponsets
(
new
CallbackReceiver
<
CouponList
>()
{
@Override
public
void
onSuccess
(
CouponList
result
)
{
WarplyCouponsChangedEventModel
couponsChanged
=
new
WarplyCouponsChangedEventModel
();
couponsChanged
.
setChanged
(
true
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
couponsChanged
));
}
@Override
public
void
onFailure
(
int
errorCode
)
{
}
});
acceptSharingDialog
(
context
,
isSupermarket
);
}
else
errorSharingDialog
(
context
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
errorSharingDialog
(
context
);
}
});
})
.
show
();
@Override
public
void
onFailure
(
int
errorCode
)
{
errorSharingDialog
(
context
);
}
});
})
.
show
();
}
}
/**
* Dialog when we success get the sharing gift
*/
private
static
void
acceptSharingDialog
(
Context
context
,
boolean
isSupermarket
)
{
mAlertDialogAcceptSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cos_dlg_success_title
)
.
setMessage
(
isSupermarket
?
R
.
string
.
cos_dlg_positive_button_text2
:
R
.
string
.
cos_dlg_positive_button_text
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
})
.
show
();
private
static
void
acceptSharingDialog
(
Activity
context
,
boolean
isSupermarket
)
{
if
(!
context
.
isFinishing
())
{
mAlertDialogAcceptSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cos_dlg_success_title
)
.
setMessage
(
isSupermarket
?
R
.
string
.
cos_dlg_positive_button_text2
:
R
.
string
.
cos_dlg_positive_button_text
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
})
.
show
();
}
}
/**
* Dialog when we reject the sharing gift
*/
private
static
void
rejectSharingDialog
(
Context
context
,
String
sharingId
)
{
mAlertDialogRejectSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cos_dlg_reject_title
)
.
setMessage
(
R
.
string
.
cos_dlg_reject_text
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_negative_button
,
(
dialogPositive
,
whichPositive
)
->
{
WarplyManager
.
cosmoteRetrieveSharing
(
new
CosmoteRetrieveSharingRequest
()
.
setSharingId
(
sharingId
)
.
setAccept
(
false
),
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
int
status
=
result
.
optInt
(
"status"
,
2
);
if
(
status
==
1
)
returnSharingSuccessDialog
(
context
);
else
errorSharingDialog
(
context
);
}
private
static
void
rejectSharingDialog
(
Activity
context
,
String
sharingId
)
{
if
(!
context
.
isFinishing
())
{
mAlertDialogRejectSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cos_dlg_reject_title
)
.
setMessage
(
R
.
string
.
cos_dlg_reject_text
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_negative_button
,
(
dialogPositive
,
whichPositive
)
->
{
WarplyManager
.
cosmoteRetrieveSharing
(
new
CosmoteRetrieveSharingRequest
()
.
setSharingId
(
sharingId
)
.
setAccept
(
false
),
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
int
status
=
result
.
optInt
(
"status"
,
2
);
if
(
status
==
1
)
returnSharingSuccessDialog
(
context
);
else
errorSharingDialog
(
context
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
errorSharingDialog
(
context
);
}
});
})
.
setNegativeButton
(
R
.
string
.
cos_dlg_negative_button2
,
(
dialogNegative
,
whichNegative
)
->
{
dialogNegative
.
dismiss
();
})
.
show
();
@Override
public
void
onFailure
(
int
errorCode
)
{
errorSharingDialog
(
context
);
}
});
})
.
setNegativeButton
(
R
.
string
.
cos_dlg_negative_button2
,
(
dialogNegative
,
whichNegative
)
->
{
dialogNegative
.
dismiss
();
})
.
show
();
}
}
/**
* Dialog when the gift gets returned
*/
private
static
void
returnSharingDialog
(
Context
context
,
String
alertTitle
)
{
mAlertDialogReturnSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cod_dlg_return_title
)
.
setMessage
(
alertTitle
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
})
.
show
();
private
static
void
returnSharingDialog
(
Activity
context
,
String
alertTitle
)
{
if
(!
context
.
isFinishing
())
{
mAlertDialogReturnSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cod_dlg_return_title
)
.
setMessage
(
alertTitle
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
})
.
show
();
}
}
/**
* Dialog when the gift gets successfully returned
*/
private
static
void
returnSharingSuccessDialog
(
Context
context
)
{
mAlertDialogReturnSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cod_dlg_reject_title
)
.
setMessage
(
R
.
string
.
cod_dlg_reject_subtitle
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
})
.
show
();
private
static
void
returnSharingSuccessDialog
(
Activity
context
)
{
if
(!
context
.
isFinishing
())
{
mAlertDialogReturnSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cod_dlg_reject_title
)
.
setMessage
(
R
.
string
.
cod_dlg_reject_subtitle
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
})
.
show
();
}
}
/**
* Error dialog
*/
private
static
void
errorSharingDialog
(
Context
context
)
{
mAlertDialogErrorSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cos_dlg_error_title
)
.
setMessage
(
R
.
string
.
cos_dlg_error_subtitle
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
})
.
show
();
private
static
void
errorSharingDialog
(
Activity
context
)
{
if
(!
context
.
isFinishing
())
{
mAlertDialogErrorSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cos_dlg_error_title
)
.
setMessage
(
R
.
string
.
cos_dlg_error_subtitle
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
})
.
show
();
}
}
/**
* Return dialog
*/
private
static
void
returnDialog
(
Context
context
,
String
message
,
String
sharingId
)
{
mAlertDialogErrorSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cos_dlg_return_title
)
.
setMessage
(
message
)
.
setNegativeButton
(
R
.
string
.
cos_dlg_negative_button2
,
(
dialogPositive
,
whichPositive
)
->
{
private
static
void
returnDialog
(
Activity
context
,
String
message
,
String
sharingId
)
{
if
(!
context
.
isFinishing
())
{
mAlertDialogErrorSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cos_dlg_return_title
)
.
setMessage
(
message
)
.
setNegativeButton
(
R
.
string
.
cos_dlg_negative_button2
,
(
dialogPositive
,
whichPositive
)
->
{
// rejectSharingDialog(context, sharingId);
dialogPositive
.
dismiss
();
})
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button
,
(
dialogNegative
,
whichNegative
)
->
{
WarplyManager
.
cosmoteRetrieveSharing
(
new
CosmoteRetrieveSharingRequest
()
.
setSharingId
(
sharingId
)
.
setAccept
(
true
),
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
int
status
=
result
.
optInt
(
"status"
,
2
);
if
(
status
==
1
)
{
WarplyManager
.
getUserCouponsWithCouponsets
(
new
CallbackReceiver
<
CouponList
>()
{
@Override
public
void
onSuccess
(
CouponList
result
)
{
WarplyCouponsChangedEventModel
couponsChanged
=
new
WarplyCouponsChangedEventModel
();
couponsChanged
.
setChanged
(
true
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
couponsChanged
));
}
@Override
public
void
onFailure
(
int
errorCode
)
{
}
});
dialogPositive
.
dismiss
();
})
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button
,
(
dialogNegative
,
whichNegative
)
->
{
WarplyManager
.
cosmoteRetrieveSharing
(
new
CosmoteRetrieveSharingRequest
()
.
setSharingId
(
sharingId
)
.
setAccept
(
true
),
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
int
status
=
result
.
optInt
(
"status"
,
2
);
if
(
status
==
1
)
{
WarplyManager
.
getUserCouponsWithCouponsets
(
new
CallbackReceiver
<
CouponList
>()
{
@Override
public
void
onSuccess
(
CouponList
result
)
{
WarplyCouponsChangedEventModel
couponsChanged
=
new
WarplyCouponsChangedEventModel
();
couponsChanged
.
setChanged
(
true
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
couponsChanged
));
}
@Override
public
void
onFailure
(
int
errorCode
)
{
}
});
// acceptSharingDialog(context);
}
else
errorSharingDialog
(
context
);
}
}
else
errorSharingDialog
(
context
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
errorSharingDialog
(
context
);
}
});
})
.
show
();
@Override
public
void
onFailure
(
int
errorCode
)
{
errorSharingDialog
(
context
);
}
});
})
.
show
();
}
}
/**
* Expired dialog
*/
private
static
void
errorExpiredDialog
(
Context
context
,
String
message
)
{
mAlertDialogErrorExpiredSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cos_dlg_error_title
)
.
setMessage
(
message
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
})
.
show
();
private
static
void
errorExpiredDialog
(
Activity
context
,
String
message
)
{
if
(!
context
.
isFinishing
())
{
mAlertDialogErrorExpiredSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cos_dlg_error_title
)
.
setMessage
(
message
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
})
.
show
();
}
}
/**
* Used dialog
*/
private
static
void
errorUsedDialog
(
Context
context
,
String
message
)
{
mAlertDialogErrorUsedSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cos_dlg_error_title
)
.
setMessage
(
message
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
})
.
show
();
private
static
void
errorUsedDialog
(
Activity
context
,
String
message
)
{
if
(!
context
.
isFinishing
())
{
mAlertDialogErrorUsedSharing
=
new
AlertDialog
.
Builder
(
context
)
.
setTitle
(
R
.
string
.
cos_dlg_error_title
)
.
setMessage
(
message
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
})
.
show
();
}
}
/**
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/views/WarpView.java
View file @
822cef7
...
...
@@ -659,6 +659,7 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
private
void
checkForPermissions
(
String
origin
,
Callback
callback
)
{
String
perm
=
Manifest
.
permission
.
ACCESS_FINE_LOCATION
;
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
M
||
getContext
().
checkSelfPermission
(
perm
)
==
PackageManager
.
PERMISSION_GRANTED
)
{
geolocationCallback
=
callback
;
if
(
isGPSEnabled
())
{
callback
.
invoke
(
origin
,
true
,
false
);
}
else
{
...
...
@@ -678,6 +679,8 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
}
private
void
enableLocationSettings
()
{
if
(
geolocationCallback
==
null
)
return
;
GoogleApiClient
googleApiClient
=
new
GoogleApiClient
.
Builder
(
WarpActivity
)
.
addApi
(
LocationServices
.
API
)
.
build
();
...
...
Please
register
or
login
to post a comment