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
2026-03-19 16:13:01 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b9ccce092b9d348ac6200c171891004b1d6b1f31
b9ccce09
1 parent
c0fee354
questionnaire part1
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
587 additions
and
29 deletions
warply_android_sdk/src/main/java/ly/warp/sdk/activities/HomeActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/activities/SingleCouponActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/adapters/CouponAdapter.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/User.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/volley/ApiService.java
warply_android_sdk/src/main/res/drawable/shape_questionnaire_option_selected.xml
warply_android_sdk/src/main/res/drawable/shape_questionnaire_option_unselected.xml
warply_android_sdk/src/main/res/layout/dialog_fullscreen_questionnaire.xml
warply_android_sdk/src/main/res/layout/dl_filter.xml
warply_android_sdk/src/main/res/layout/item_questionnaire_option.xml
warply_android_sdk/src/main/res/layout/item_questionnaire_separator.xml
warply_android_sdk/src/main/res/values/colors.xml
warply_android_sdk/src/main/res/values/strings.xml
warply_android_sdk/src/main/java/ly/warp/sdk/activities/HomeActivity.java
View file @
b9ccce0
package
ly
.
warp
.
sdk
.
activities
;
import
android.app.Activity
;
import
android.content.ActivityNotFoundException
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Parcelable
;
import
android.text.TextUtils
;
import
android.util.TypedValue
;
...
...
@@ -21,12 +20,16 @@ import androidx.appcompat.content.res.AppCompatResources;
import
androidx.constraintlayout.widget.ConstraintLayout
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
androidx.viewpager2.widget.ViewPager2
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
import
com.google.android.material.bottomsheet.BottomSheetBehavior
;
import
com.google.android.material.bottomsheet.BottomSheetDialog
;
import
com.google.common.util.concurrent.FutureCallback
;
import
com.google.common.util.concurrent.Futures
;
import
com.google.common.util.concurrent.ListenableFuture
;
import
com.google.common.util.concurrent.MoreExecutors
;
import
com.google.common.util.concurrent.SettableFuture
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
...
...
@@ -46,7 +49,6 @@ import ly.warp.sdk.utils.WarpUtils;
import
ly.warp.sdk.utils.WarplyManagerHelper
;
import
ly.warp.sdk.utils.managers.WarplyManager
;
import
ly.warp.sdk.views.HorizontalSpaceItemDecoration
;
import
ly.warp.sdk.views.VerticalSpaceItemDecoration
;
public
class
HomeActivity
extends
Activity
implements
View
.
OnClickListener
,
CouponsetAdapter
.
OnCouponsetClickListener
{
// ===========================================================
...
...
@@ -73,6 +75,9 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
private
ConstraintLayout
mViewPager
;
private
LinearLayout
mSectionsContainer
;
private
RelativeLayout
mSectionsLoading
;
private
int
mCurrentQuestionIndex
=
1
;
private
SettableFuture
<
ArrayList
<
CarouselItem
>>
carouselFuture
=
SettableFuture
.
create
();
private
SettableFuture
<
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>>
couponsetsFuture
=
SettableFuture
.
create
();
// ===========================================================
// Methods for/from SuperClass/Interfaces
...
...
@@ -89,15 +94,36 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
findViewById
(
R
.
id
.
header_layout
),
null
);
setUpUser
();
mPbLoading
.
setVisibility
(
View
.
VISIBLE
);
mSectionsLoading
.
setVisibility
(
View
.
VISIBLE
);
setUpUser
();
WarplyManager
.
getCoupons
(
mCouponsCallback
);
WarplyManager
.
getCarousel
(
mCarouselCallback
);
WarplyManager
.
getCouponsets
(
null
,
null
,
mCouponsetsCallback
);
// WarplyManager.getFilters(mFiltersCallback);
ListenableFuture
<
List
<
Object
>>
allFutures
=
Futures
.
successfulAsList
(
carouselFuture
,
couponsetsFuture
);
Futures
.
addCallback
(
allFutures
,
new
FutureCallback
<
List
<
Object
>>()
{
@Override
public
void
onSuccess
(
List
<
Object
>
result
)
{
runOnUiThread
(()
->
{
User
user
=
WarplyManagerHelper
.
getUser
();
if
(
user
!=
null
&&
user
.
getQuestionnaireAnswers
()
==
null
&&
user
.
getQuestionnaire
()
!=
null
)
{
new
Handler
(
getMainLooper
()).
postDelayed
(()
->
showQuestionnaireDialog
(
user
.
getQuestionnaire
()),
1000
);
}
});
}
@Override
public
void
onFailure
(
Throwable
t
)
{
}
},
MoreExecutors
.
directExecutor
());
}
@Override
...
...
@@ -489,6 +515,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
behavior
.
setSkipCollapsed
(
true
);
behavior
.
setPeekHeight
(
screenHeight
);
behavior
.
setState
(
BottomSheetBehavior
.
STATE_EXPANDED
);
behavior
.
setDraggable
(
false
);
});
}
});
...
...
@@ -509,6 +536,170 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
return
null
;
}
private
void
showQuestionnaireDialog
(
User
.
Questionnaire
questionnaire
)
{
if
(
questionnaire
.
getQuestions
()
==
null
||
questionnaire
.
getQuestions
().
isEmpty
())
return
;
BottomSheetDialog
bottomSheetDialog
=
new
BottomSheetDialog
(
this
,
R
.
style
.
FullScreenBottomSheetDialog
);
View
dialogView
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
dialog_fullscreen_questionnaire
,
null
);
bottomSheetDialog
.
setContentView
(
dialogView
);
ImageView
ivClose
=
dialogView
.
findViewById
(
R
.
id
.
iv_back
);
ivClose
.
setOnClickListener
(
v
->
bottomSheetDialog
.
dismiss
());
mCurrentQuestionIndex
=
1
;
renderQuestion
(
questionnaire
,
dialogView
,
bottomSheetDialog
);
bottomSheetDialog
.
setOnShowListener
(
dialog
->
{
View
bottomSheet
=
bottomSheetDialog
.
findViewById
(
com
.
google
.
android
.
material
.
R
.
id
.
design_bottom_sheet
);
if
(
bottomSheet
!=
null
)
{
bottomSheet
.
post
(()
->
{
int
screenHeight
=
getResources
().
getDisplayMetrics
().
heightPixels
;
ViewGroup
.
LayoutParams
lp
=
bottomSheet
.
getLayoutParams
();
lp
.
height
=
screenHeight
;
bottomSheet
.
setLayoutParams
(
lp
);
BottomSheetBehavior
<
View
>
behavior
=
BottomSheetBehavior
.
from
(
bottomSheet
);
behavior
.
setSkipCollapsed
(
true
);
behavior
.
setPeekHeight
(
screenHeight
);
behavior
.
setState
(
BottomSheetBehavior
.
STATE_EXPANDED
);
behavior
.
setDraggable
(
false
);
});
}
});
bottomSheetDialog
.
show
();
}
private
void
renderQuestion
(
User
.
Questionnaire
questionnaire
,
View
dialogView
,
BottomSheetDialog
dialog
)
{
if
(
mCurrentQuestionIndex
>=
questionnaire
.
getQuestions
().
size
())
{
return
;
}
TextView
tvQuestionCount
=
dialogView
.
findViewById
(
R
.
id
.
tv_question_count
);
tvQuestionCount
.
setText
(
String
.
valueOf
(
mCurrentQuestionIndex
)
+
"/"
+
String
.
valueOf
(
questionnaire
.
getQuestions
().
size
()));
TextView
tvQuestionHeaderTitle
=
dialogView
.
findViewById
(
R
.
id
.
tv_question_header_title
);
TextView
tvQuestionHeaderSubtitle
=
dialogView
.
findViewById
(
R
.
id
.
tv_question_subtitle
);
User
.
Question
question
=
questionnaire
.
getQuestions
().
get
(
mCurrentQuestionIndex
);
TextView
tvQuestionTitle
=
dialogView
.
findViewById
(
R
.
id
.
tv_question_title
);
LinearLayout
llOptionsContainer
=
dialogView
.
findViewById
(
R
.
id
.
ll_options_container
);
LinearLayout
llNextButton
=
dialogView
.
findViewById
(
R
.
id
.
ll_next_button
);
tvQuestionTitle
.
setText
(
question
.
getQuestion
());
WarpUtils
.
renderCustomFont
(
this
,
R
.
font
.
ping_lcg_bold
,
tvQuestionTitle
,
tvQuestionCount
,
tvQuestionHeaderTitle
);
WarpUtils
.
renderCustomFont
(
this
,
R
.
font
.
ping_lcg_regular
,
tvQuestionHeaderSubtitle
);
llOptionsContainer
.
removeAllViews
();
org
.
json
.
JSONArray
options
=
question
.
getOptions
();
String
type
=
question
.
getType
();
List
<
Integer
>
selectedPositions
=
new
ArrayList
<>();
if
(
"select"
.
equals
(
type
))
{
tvQuestionHeaderSubtitle
.
setVisibility
(
View
.
GONE
);
View
dropdownHeader
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
item_questionnaire_option
,
llOptionsContainer
,
false
);
LinearLayout
llDropdownContainer
=
dropdownHeader
.
findViewById
(
R
.
id
.
ll_option_container
);
TextView
tvDropdownTitle
=
dropdownHeader
.
findViewById
(
R
.
id
.
tv_option_title
);
tvDropdownTitle
.
setText
(
getString
(
R
.
string
.
demo_region_title
));
WarpUtils
.
renderCustomFont
(
this
,
R
.
font
.
ping_lcg_regular
,
tvDropdownTitle
);
llDropdownContainer
.
setBackground
(
AppCompatResources
.
getDrawable
(
this
,
R
.
drawable
.
shape_questionnaire_option_unselected
));
tvDropdownTitle
.
setTextColor
(
getColor
(
R
.
color
.
custom_black2
));
LinearLayout
llDropdownList
=
new
LinearLayout
(
this
);
llDropdownList
.
setOrientation
(
LinearLayout
.
VERTICAL
);
llDropdownList
.
setVisibility
(
View
.
GONE
);
if
(
options
!=
null
)
{
for
(
int
i
=
0
;
i
<
options
.
length
();
i
++)
{
final
int
position
=
i
;
String
optionText
=
options
.
optString
(
i
);
View
optionView
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
item_questionnaire_option
,
llDropdownList
,
false
);
LinearLayout
llOptionContainer
=
optionView
.
findViewById
(
R
.
id
.
ll_option_container
);
TextView
tvOptionTitle
=
optionView
.
findViewById
(
R
.
id
.
tv_option_title
);
tvOptionTitle
.
setText
(
optionText
);
WarpUtils
.
renderCustomFont
(
this
,
R
.
font
.
ping_lcg_regular
,
tvOptionTitle
);
llOptionContainer
.
setBackground
(
AppCompatResources
.
getDrawable
(
this
,
R
.
drawable
.
shape_questionnaire_option_unselected
));
tvOptionTitle
.
setTextColor
(
getColor
(
R
.
color
.
custom_black2
));
optionView
.
setOnClickListener
(
v
->
{
selectedPositions
.
clear
();
selectedPositions
.
add
(
position
);
tvDropdownTitle
.
setText
(
optionText
);
llDropdownList
.
setVisibility
(
View
.
GONE
);
llDropdownContainer
.
setBackground
(
AppCompatResources
.
getDrawable
(
this
,
R
.
drawable
.
shape_rectangle_rounded_light_blue_tr
));
tvDropdownTitle
.
setTextColor
(
getColor
(
R
.
color
.
white
));
});
llDropdownList
.
addView
(
optionView
);
}
}
dropdownHeader
.
setOnClickListener
(
v
->
{
boolean
isExpanded
=
llDropdownList
.
getVisibility
()
==
View
.
VISIBLE
;
llDropdownList
.
setVisibility
(
isExpanded
?
View
.
GONE
:
View
.
VISIBLE
);
});
llOptionsContainer
.
addView
(
dropdownHeader
);
llOptionsContainer
.
addView
(
llDropdownList
);
}
else
{
if
(
"string"
.
equals
(
type
))
{
tvQuestionHeaderSubtitle
.
setVisibility
(
View
.
GONE
);
}
else
if
(
"multi"
.
equals
(
type
))
{
tvQuestionHeaderSubtitle
.
setVisibility
(
View
.
VISIBLE
);
}
if
(
options
!=
null
)
{
for
(
int
i
=
0
;
i
<
options
.
length
();
i
++)
{
final
int
position
=
i
;
String
optionText
=
options
.
optString
(
i
);
if
(
optionText
.
startsWith
(
"["
))
continue
;
View
optionView
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
item_questionnaire_option
,
llOptionsContainer
,
false
);
// View separator = LayoutInflater.from(this).inflate(R.layout.item_questionnaire_separator, llOptionsContainer, false);
LinearLayout
llOptionContainer
=
optionView
.
findViewById
(
R
.
id
.
ll_option_container
);
TextView
tvOptionTitle
=
optionView
.
findViewById
(
R
.
id
.
tv_option_title
);
tvOptionTitle
.
setText
(
optionText
);
WarpUtils
.
renderCustomFont
(
this
,
R
.
font
.
ping_lcg_bold
,
tvOptionTitle
);
llOptionContainer
.
setBackground
(
AppCompatResources
.
getDrawable
(
this
,
R
.
drawable
.
shape_questionnaire_option_unselected
));
optionView
.
setOnClickListener
(
v
->
{
if
(
"string"
.
equals
(
type
))
{
selectedPositions
.
clear
();
selectedPositions
.
add
(
position
);
}
else
if
(
"multi"
.
equals
(
type
))
{
if
(
selectedPositions
.
contains
(
position
))
{
selectedPositions
.
remove
(
Integer
.
valueOf
(
position
));
}
else
{
selectedPositions
.
add
(
position
);
}
}
for
(
int
j
=
0
;
j
<
llOptionsContainer
.
getChildCount
();
j
++)
{
View
childView
=
llOptionsContainer
.
getChildAt
(
j
);
LinearLayout
childContainer
=
childView
.
findViewById
(
R
.
id
.
ll_option_container
);
if
(
childContainer
==
null
)
continue
;
if
(
selectedPositions
.
contains
(
j
))
{
childContainer
.
setBackground
(
AppCompatResources
.
getDrawable
(
this
,
R
.
drawable
.
shape_questionnaire_option_selected
));
}
else
{
childContainer
.
setBackground
(
AppCompatResources
.
getDrawable
(
this
,
R
.
drawable
.
shape_questionnaire_option_unselected
));
}
}
});
llOptionsContainer
.
addView
(
optionView
);
// llOptionsContainer.addView(separator);
}
}
}
llNextButton
.
setOnClickListener
(
v
->
{
if
(
mCurrentQuestionIndex
<
questionnaire
.
getQuestions
().
size
()
-
1
)
{
mCurrentQuestionIndex
++;
renderQuestion
(
questionnaire
,
dialogView
,
dialog
);
}
else
{
// Final screen, leave action empty as requested
}
});
}
private
final
CallbackReceiver
<
ArrayList
<
CarouselItem
>>
mCarouselCallback
=
new
CallbackReceiver
<
ArrayList
<
CarouselItem
>>()
{
@Override
public
void
onSuccess
(
ArrayList
<
CarouselItem
>
result
)
{
...
...
@@ -526,12 +717,14 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
}
else
{
mViewPager
.
setVisibility
(
View
.
GONE
);
}
carouselFuture
.
set
(
result
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
mPbLoading
.
setVisibility
(
View
.
GONE
);
mViewPager
.
setVisibility
(
View
.
GONE
);
carouselFuture
.
set
(
new
ArrayList
<
CarouselItem
>());
}
};
...
...
@@ -542,11 +735,14 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
if
(
result
!=
null
&&
!
result
.
isEmpty
())
{
setupCouponsetSections
(
result
);
}
couponsetsFuture
.
set
(
result
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
mSectionsLoading
.
setVisibility
(
View
.
GONE
);
couponsetsFuture
.
set
(
new
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>());
}
};
...
...
@@ -567,16 +763,4 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
Toast
.
makeText
(
HomeActivity
.
this
,
"COUPONS ERROR"
,
Toast
.
LENGTH_SHORT
).
show
();
}
};
// private final CallbackReceiver<Filter> mFiltersCallback = new CallbackReceiver<Filter>() {
// @Override
// public void onSuccess(Filter result) {
// Toast.makeText(HomeActivity.this, "FILTERS SUCCESS", Toast.LENGTH_SHORT).show();
// }
//
// @Override
// public void onFailure(int errorCode) {
// Toast.makeText(HomeActivity.this, "FILTERS ERROR", Toast.LENGTH_SHORT).show();
// }
// };
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/SingleCouponActivity.java
View file @
b9ccce0
...
...
@@ -221,8 +221,8 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen
.
into
(
mIvImage
);
}
if
(
mOfferItem
.
get
CouponsetDetails
()
!=
null
&&
mOfferItem
.
getCouponsetDetails
().
getMerchantAdminName
()
!=
null
&&
!
TextUtils
.
isEmpty
(
mOfferItem
.
getCouponsetDetails
().
getMerchantAdmin
Name
()))
mTvMerchantName
.
setText
(
mOfferItem
.
get
CouponsetDetails
().
getMerchantAdmin
Name
());
if
(
mOfferItem
.
get
MerchantDetails
()
!=
null
&&
mOfferItem
.
getMerchantDetails
().
getName
()
!=
null
&&
!
TextUtils
.
isEmpty
(
mOfferItem
.
getMerchantDetails
().
get
Name
()))
mTvMerchantName
.
setText
(
mOfferItem
.
get
MerchantDetails
().
get
Name
());
if
(
mOfferItem
.
getCouponsetDetails
()
!=
null
&&
mOfferItem
.
getCouponsetDetails
().
getName
()
!=
null
&&
!
TextUtils
.
isEmpty
(
mOfferItem
.
getCouponsetDetails
().
getName
()))
mTvValue
.
setText
(
mOfferItem
.
getCouponsetDetails
().
getName
());
if
(
mOfferItem
.
getCouponsetDetails
()
!=
null
&&
mOfferItem
.
getCouponsetDetails
().
getShort_description
()
!=
null
&&
!
TextUtils
.
isEmpty
(
mOfferItem
.
getCouponsetDetails
().
getShort_description
()))
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/adapters/CouponAdapter.java
View file @
b9ccce0
...
...
@@ -170,7 +170,7 @@ public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponView
llDateExpired
.
setVisibility
(
View
.
GONE
);
}
tvMerchant
.
setText
(!
TextUtils
.
isEmpty
(
couponItem
.
get
CouponsetDetails
().
getMerchantAdminName
())
?
couponItem
.
getCouponsetDetails
().
getMerchantAdmin
Name
().
trim
()
:
""
);
tvMerchant
.
setText
(!
TextUtils
.
isEmpty
(
couponItem
.
get
MerchantDetails
().
getName
())
?
couponItem
.
getMerchantDetails
().
get
Name
().
trim
()
:
""
);
tvTitle
.
setText
(!
TextUtils
.
isEmpty
(
couponItem
.
getCouponsetDetails
().
getName
())
?
couponItem
.
getCouponsetDetails
().
getName
().
trim
()
:
""
);
tvDescription
.
setText
(!
TextUtils
.
isEmpty
(
couponItem
.
getCouponsetDetails
().
getShort_description
())
?
couponItem
.
getCouponsetDetails
().
getShort_description
().
trim
()
:
""
);
if
(
couponItem
.
getExpiration
()
!=
null
&&
!
couponItem
.
getExpiration
().
isEmpty
())
{
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/User.java
View file @
b9ccce0
...
...
@@ -71,7 +71,7 @@ public class User implements Parcelable, Serializable {
private
boolean
isEligible
=
false
;
private
String
msisdn
;
private
String
profileMetadata
;
private
JSONObject
questionnaire
;
private
Questionnaire
questionnaire
;
private
JSONObject
questionnaireAnswers
;
private
JSONObject
userAnswers
;
private
String
userId
;
...
...
@@ -127,7 +127,7 @@ public class User implements Parcelable, Serializable {
this
.
isEligible
=
json
.
optBoolean
(
IS_ELIGIBLE
);
this
.
msisdn
=
optNullableString
(
json
,
MSISDN
);
this
.
profileMetadata
=
optNullableString
(
json
,
PROFILE_METADATA
);
this
.
questionnaire
=
json
.
optJSONObject
(
QUESTIONNAIRE
);
this
.
questionnaire
=
json
.
isNull
(
QUESTIONNAIRE
)
?
null
:
new
Questionnaire
(
json
.
optJSONObject
(
QUESTIONNAIRE
)
);
this
.
questionnaireAnswers
=
json
.
optJSONObject
(
QUESTIONNAIRE_ANSWERS
);
this
.
userAnswers
=
json
.
optJSONObject
(
USER_ANSWERS
);
this
.
userId
=
optNullableString
(
json
,
USER_ID
);
...
...
@@ -158,7 +158,7 @@ public class User implements Parcelable, Serializable {
}
try
{
String
questionnaireStr
=
source
.
readString
();
this
.
questionnaire
=
questionnaireStr
!=
null
?
new
JSONObject
(
questionnaireStr
)
:
null
;
this
.
questionnaire
=
questionnaireStr
!=
null
?
new
Questionnaire
(
new
JSONObject
(
questionnaireStr
)
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
questionnaire
=
null
;
}
...
...
@@ -214,7 +214,7 @@ public class User implements Parcelable, Serializable {
jObj
.
putOpt
(
IS_ELIGIBLE
,
this
.
isEligible
);
jObj
.
put
(
MSISDN
,
this
.
msisdn
!=
null
?
this
.
msisdn
:
JSONObject
.
NULL
);
jObj
.
put
(
PROFILE_METADATA
,
this
.
profileMetadata
!=
null
?
this
.
profileMetadata
:
JSONObject
.
NULL
);
jObj
.
put
(
QUESTIONNAIRE
,
this
.
questionnaire
!=
null
?
this
.
questionnaire
:
JSONObject
.
NULL
);
jObj
.
put
(
QUESTIONNAIRE
,
this
.
questionnaire
!=
null
?
this
.
questionnaire
.
toJSONObject
()
:
JSONObject
.
NULL
);
jObj
.
put
(
QUESTIONNAIRE_ANSWERS
,
this
.
questionnaireAnswers
!=
null
?
this
.
questionnaireAnswers
:
JSONObject
.
NULL
);
jObj
.
put
(
USER_ANSWERS
,
this
.
userAnswers
!=
null
?
this
.
userAnswers
:
JSONObject
.
NULL
);
jObj
.
put
(
USER_ID
,
this
.
userId
!=
null
?
this
.
userId
:
JSONObject
.
NULL
);
...
...
@@ -308,7 +308,7 @@ public class User implements Parcelable, Serializable {
return
profileMetadata
;
}
public
JSONObject
getQuestionnaire
()
{
public
Questionnaire
getQuestionnaire
()
{
return
questionnaire
;
}
...
...
@@ -368,7 +368,7 @@ public class User implements Parcelable, Serializable {
this
.
profileMetadata
=
profileMetadata
;
}
public
void
setQuestionnaire
(
JSONObject
questionnaire
)
{
public
void
setQuestionnaire
(
Questionnaire
questionnaire
)
{
this
.
questionnaire
=
questionnaire
;
}
...
...
@@ -416,4 +416,190 @@ public class User implements Parcelable, Serializable {
}
return
listData
;
}
public
static
class
Questionnaire
implements
Parcelable
,
Serializable
{
private
String
questionnaireId
;
private
ArrayList
<
Question
>
questions
;
public
Questionnaire
()
{
this
.
questionnaireId
=
null
;
this
.
questions
=
new
ArrayList
<>();
}
public
Questionnaire
(
JSONObject
json
)
{
if
(
json
!=
null
)
{
this
.
questionnaireId
=
json
.
isNull
(
"questionnaire_id"
)
?
null
:
json
.
optString
(
"questionnaire_id"
);
this
.
questions
=
new
ArrayList
<>();
JSONArray
questionsArr
=
json
.
optJSONArray
(
"questions"
);
if
(
questionsArr
!=
null
)
{
for
(
int
i
=
0
;
i
<
questionsArr
.
length
();
i
++)
{
JSONObject
qJson
=
questionsArr
.
optJSONObject
(
i
);
if
(
qJson
!=
null
)
{
this
.
questions
.
add
(
new
Question
(
qJson
));
}
}
}
}
}
protected
Questionnaire
(
Parcel
in
)
{
questionnaireId
=
in
.
readString
();
questions
=
in
.
createTypedArrayList
(
Question
.
CREATOR
);
}
@Override
public
void
writeToParcel
(
Parcel
dest
,
int
flags
)
{
dest
.
writeString
(
questionnaireId
);
dest
.
writeTypedList
(
questions
);
}
@Override
public
int
describeContents
()
{
return
0
;
}
public
static
final
Creator
<
Questionnaire
>
CREATOR
=
new
Creator
<
Questionnaire
>()
{
@Override
public
Questionnaire
createFromParcel
(
Parcel
in
)
{
return
new
Questionnaire
(
in
);
}
@Override
public
Questionnaire
[]
newArray
(
int
size
)
{
return
new
Questionnaire
[
size
];
}
};
public
JSONObject
toJSONObject
()
{
JSONObject
jObj
=
new
JSONObject
();
try
{
jObj
.
put
(
"questionnaire_id"
,
this
.
questionnaireId
!=
null
?
this
.
questionnaireId
:
JSONObject
.
NULL
);
JSONArray
qArr
=
new
JSONArray
();
if
(
this
.
questions
!=
null
)
{
for
(
Question
q
:
this
.
questions
)
{
qArr
.
put
(
q
.
toJSONObject
());
}
}
jObj
.
put
(
"questions"
,
qArr
);
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
e
.
printStackTrace
();
}
return
jObj
;
}
public
String
getQuestionnaireId
()
{
return
questionnaireId
;
}
public
void
setQuestionnaireId
(
String
questionnaireId
)
{
this
.
questionnaireId
=
questionnaireId
;
}
public
ArrayList
<
Question
>
getQuestions
()
{
return
questions
;
}
public
void
setQuestions
(
ArrayList
<
Question
>
questions
)
{
this
.
questions
=
questions
;
}
}
public
static
class
Question
implements
Parcelable
,
Serializable
{
private
String
adminName
;
private
int
id
;
private
JSONArray
options
;
private
String
question
;
private
JSONObject
settings
;
private
int
sorting
;
private
String
type
;
private
int
version
;
public
Question
()
{}
public
Question
(
JSONObject
json
)
{
if
(
json
!=
null
)
{
this
.
adminName
=
json
.
isNull
(
"admin_name"
)
?
null
:
json
.
optString
(
"admin_name"
);
this
.
id
=
json
.
optInt
(
"id"
,
-
1
);
this
.
options
=
json
.
optJSONArray
(
"options"
);
this
.
question
=
json
.
isNull
(
"question"
)
?
null
:
json
.
optString
(
"question"
);
this
.
settings
=
json
.
optJSONObject
(
"settings"
);
this
.
sorting
=
json
.
optInt
(
"sorting"
,
0
);
this
.
type
=
json
.
isNull
(
"type"
)
?
null
:
json
.
optString
(
"type"
);
this
.
version
=
json
.
optInt
(
"version"
,
0
);
}
}
protected
Question
(
Parcel
in
)
{
adminName
=
in
.
readString
();
id
=
in
.
readInt
();
try
{
String
optionsStr
=
in
.
readString
();
options
=
optionsStr
!=
null
?
new
JSONArray
(
optionsStr
)
:
null
;
}
catch
(
JSONException
e
)
{
options
=
null
;
}
question
=
in
.
readString
();
try
{
String
settingsStr
=
in
.
readString
();
settings
=
settingsStr
!=
null
?
new
JSONObject
(
settingsStr
)
:
null
;
}
catch
(
JSONException
e
)
{
settings
=
null
;
}
sorting
=
in
.
readInt
();
type
=
in
.
readString
();
version
=
in
.
readInt
();
}
@Override
public
void
writeToParcel
(
Parcel
dest
,
int
flags
)
{
dest
.
writeString
(
adminName
);
dest
.
writeInt
(
id
);
dest
.
writeString
(
options
!=
null
?
options
.
toString
()
:
null
);
dest
.
writeString
(
question
);
dest
.
writeString
(
settings
!=
null
?
settings
.
toString
()
:
null
);
dest
.
writeInt
(
sorting
);
dest
.
writeString
(
type
);
dest
.
writeInt
(
version
);
}
@Override
public
int
describeContents
()
{
return
0
;
}
public
static
final
Creator
<
Question
>
CREATOR
=
new
Creator
<
Question
>()
{
@Override
public
Question
createFromParcel
(
Parcel
in
)
{
return
new
Question
(
in
);
}
@Override
public
Question
[]
newArray
(
int
size
)
{
return
new
Question
[
size
];
}
};
public
JSONObject
toJSONObject
()
{
JSONObject
jObj
=
new
JSONObject
();
try
{
jObj
.
put
(
"admin_name"
,
this
.
adminName
!=
null
?
this
.
adminName
:
JSONObject
.
NULL
);
jObj
.
put
(
"id"
,
this
.
id
);
jObj
.
put
(
"options"
,
this
.
options
!=
null
?
this
.
options
:
JSONObject
.
NULL
);
jObj
.
put
(
"question"
,
this
.
question
!=
null
?
this
.
question
:
JSONObject
.
NULL
);
jObj
.
put
(
"settings"
,
this
.
settings
!=
null
?
this
.
settings
:
JSONObject
.
NULL
);
jObj
.
put
(
"sorting"
,
this
.
sorting
);
jObj
.
put
(
"type"
,
this
.
type
!=
null
?
this
.
type
:
JSONObject
.
NULL
);
jObj
.
put
(
"version"
,
this
.
version
);
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
e
.
printStackTrace
();
}
return
jObj
;
}
public
String
getAdminName
()
{
return
adminName
;
}
public
void
setAdminName
(
String
adminName
)
{
this
.
adminName
=
adminName
;
}
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
JSONArray
getOptions
()
{
return
options
;
}
public
void
setOptions
(
JSONArray
options
)
{
this
.
options
=
options
;
}
public
String
getQuestion
()
{
return
question
;
}
public
void
setQuestion
(
String
question
)
{
this
.
question
=
question
;
}
public
JSONObject
getSettings
()
{
return
settings
;
}
public
void
setSettings
(
JSONObject
settings
)
{
this
.
settings
=
settings
;
}
public
int
getSorting
()
{
return
sorting
;
}
public
void
setSorting
(
int
sorting
)
{
this
.
sorting
=
sorting
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
int
getVersion
()
{
return
version
;
}
public
void
setVersion
(
int
version
)
{
this
.
version
=
version
;
}
}
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/volley/ApiService.java
View file @
b9ccce0
...
...
@@ -192,6 +192,18 @@ public interface ApiService {
@Header
(
WarpConstants
.
HEADER_SIGNATURE
)
String
signature
,
@Header
(
WarpConstants
.
HEADER_AUTHORIZATION
)
String
bearer
);
@Headers
(
"Content-Type: application/json"
)
@POST
(
"/oauth/{appUuid}/context"
)
Call
<
ResponseBody
>
getQuestionnaire
(
@Path
(
"appUuid"
)
String
appUuid
,
@Body
RequestBody
request
,
@Header
(
WarpConstants
.
HEADER_DATE
)
String
timeStamp
,
@Header
(
WarpConstants
.
HEADER_LOYALTY_BUNDLE_ID
)
String
bundleId
,
@Header
(
WarpConstants
.
HEADER_UNIQUE_DEVICE_ID
)
String
deviceId
,
@Header
(
WarpConstants
.
HEADER_CHANNEL
)
String
channel
,
@Header
(
WarpConstants
.
HEADER_WEB_ID
)
String
webId
,
@Header
(
WarpConstants
.
HEADER_SIGNATURE
)
String
signature
,
@Header
(
WarpConstants
.
HEADER_AUTHORIZATION
)
String
bearer
);
// ===========================================================
// Getter & Setter
// ===========================================================
...
...
warply_android_sdk/src/main/res/drawable/shape_questionnaire_option_selected.xml
0 → 100644
View file @
b9ccce0
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<corners
android:radius=
"14dp"
/>
<solid
android:color=
"@color/white"
/>
<stroke
android:width=
"2dp"
android:color=
"@color/custom_black7"
/>
</shape>
\ No newline at end of file
warply_android_sdk/src/main/res/drawable/shape_questionnaire_option_unselected.xml
0 → 100644
View file @
b9ccce0
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<corners
android:radius=
"14dp"
/>
<solid
android:color=
"@color/white"
/>
<stroke
android:width=
"1dp"
android:color=
"@color/custom_grey7"
/>
</shape>
\ No newline at end of file
warply_android_sdk/src/main/res/layout/dialog_fullscreen_questionnaire.xml
0 → 100644
View file @
b9ccce0
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/white"
>
<LinearLayout
android:id=
"@+id/header_layout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:background=
"@color/white"
android:gravity=
"center_vertical"
android:orientation=
"horizontal"
android:padding=
"16dp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<LinearLayout
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center_vertical"
android:orientation=
"horizontal"
>
<ImageView
android:id=
"@+id/iv_back"
android:layout_width=
"16dp"
android:layout_height=
"16dp"
android:layout_marginEnd=
"24dp"
android:src=
"@drawable/ic_back"
/>
</LinearLayout>
<TextView
android:id=
"@+id/tv_question_count"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/custom_black4"
android:textSize=
"18sp"
tools:text=
"1/7"
/>
</LinearLayout>
<ScrollView
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:fillViewport=
"true"
android:scrollbars=
"none"
app:layout_constraintBottom_toTopOf=
"@id/ll_next_container"
app:layout_constraintTop_toBottomOf=
"@id/header_layout"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:paddingHorizontal=
"16dp"
android:paddingBottom=
"32dp"
>
<TextView
android:id=
"@+id/tv_question_header_title"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:includeFontPadding=
"false"
android:text=
"@string/demo_questionnaire_title"
android:textColor=
"@color/custom_black4"
android:textSize=
"22sp"
/>
<TextView
android:id=
"@+id/tv_question_title"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:includeFontPadding=
"false"
android:textColor=
"@color/custom_black4"
android:textSize=
"18sp"
android:layout_marginTop=
"40dp"
tools:text=
"Question Title?"
/>
<TextView
android:id=
"@+id/tv_question_subtitle"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:includeFontPadding=
"false"
android:textColor=
"@color/custom_black2"
android:textSize=
"14sp"
android:layout_marginTop=
"8dp"
android:text=
"@string/demo_questionnaire_subtitle"
android:visibility=
"gone"
/>
<LinearLayout
android:id=
"@+id/ll_options_container"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"24dp"
android:orientation=
"vertical"
/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id=
"@+id/ll_next_container"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:padding=
"16dp"
app:layout_constraintBottom_toBottomOf=
"parent"
>
<LinearLayout
android:id=
"@+id/ll_next_button"
android:layout_width=
"match_parent"
android:layout_height=
"55dp"
android:background=
"@drawable/shape_rectangle_rounded_light_blue_tr"
android:gravity=
"center"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/tv_next"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:includeFontPadding=
"false"
android:text=
"Next"
android:textColor=
"@color/white"
android:textSize=
"16sp"
/>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
warply_android_sdk/src/main/res/layout/dl_filter.xml
View file @
b9ccce0
...
...
@@ -42,7 +42,8 @@
<androidx.core.widget.NestedScrollView
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
android:scrollbars=
"none"
>
<LinearLayout
android:id=
"@+id/ll_filter_container"
...
...
warply_android_sdk/src/main/res/layout/item_questionnaire_option.xml
0 → 100644
View file @
b9ccce0
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/ll_option_container"
android:layout_width=
"match_parent"
android:layout_height=
"55dp"
android:layout_marginBottom=
"8dp"
android:background=
"@drawable/shape_questionnaire_option_unselected"
android:gravity=
"center"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/tv_option_title"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:includeFontPadding=
"false"
tools:text=
"Option Title"
android:textColor=
"@color/black"
android:textSize=
"15sp"
/>
</LinearLayout>
\ No newline at end of file
warply_android_sdk/src/main/res/layout/item_questionnaire_separator.xml
0 → 100644
View file @
b9ccce0
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/ll_option_separator"
android:layout_width=
"match_parent"
android:layout_height=
"8dp"
android:orientation=
"horizontal"
>
</LinearLayout>
\ No newline at end of file
warply_android_sdk/src/main/res/values/colors.xml
View file @
b9ccce0
...
...
@@ -8,6 +8,7 @@
<color
name=
"custom_orange"
>
#FF9933
</color>
<color
name=
"custom_skyblue2"
>
#22A9B5
</color>
<color
name=
"custom_blue_dark"
>
#3A5266
</color>
<color
name=
"black"
>
#000000
</color>
<color
name=
"white"
>
#FFFFFF
</color>
<color
name=
"white_tr"
>
#66FFFFFF
</color>
<color
name=
"custom_green5"
>
#79BF14
</color>
...
...
warply_android_sdk/src/main/res/values/strings.xml
View file @
b9ccce0
...
...
@@ -43,4 +43,7 @@
<string
name=
"demo_search_title"
>
Αναζήτηση
</string>
<string
name=
"lbl_directions"
>
Οδηγίες
</string>
<string
name=
"lbl_top_offers"
>
Top offers
</string>
<string
name=
"demo_questionnaire_title"
>
Questionnaire
</string>
<string
name=
"demo_questionnaire_subtitle"
>
(You can select more than one answer)
</string>
<string
name=
"demo_region_title"
>
Region
</string>
</resources>
...
...
Please
register
or
login
to post a comment