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 19:05:31 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8b0e3816e431665bd39c55f26c416f922275f820
8b0e3816
1 parent
302c79ed
questionnaire part2
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
221 additions
and
31 deletions
warply_android_sdk/src/main/java/ly/warp/sdk/activities/HomeActivity.java
warply_android_sdk/src/main/res/drawable/shape_popup_option.xml
warply_android_sdk/src/main/res/layout/item_questionnaire_list_custom.xml
warply_android_sdk/src/main/res/layout/item_questionnaire_list_header.xml
warply_android_sdk/src/main/res/layout/item_questionnaire_list_option.xml
warply_android_sdk/src/main/java/ly/warp/sdk/activities/HomeActivity.java
View file @
8b0e381
...
...
@@ -10,13 +10,18 @@ import android.util.TypedValue;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.AdapterView
;
import
android.widget.ArrayAdapter
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.ListPopupWindow
;
import
android.widget.RelativeLayout
;
import
android.widget.Spinner
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.appcompat.content.res.AppCompatResources
;
import
androidx.appcompat.widget.AppCompatSpinner
;
import
androidx.constraintlayout.widget.ConstraintLayout
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
...
...
@@ -77,7 +82,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
private
ConstraintLayout
mViewPager
;
private
LinearLayout
mSectionsContainer
;
private
RelativeLayout
mSectionsLoading
;
private
int
mCurrentQuestionIndex
=
1
;
private
int
mCurrentQuestionIndex
=
0
;
private
SettableFuture
<
ArrayList
<
CarouselItem
>>
carouselFuture
=
SettableFuture
.
create
();
private
SettableFuture
<
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>>
couponsetsFuture
=
SettableFuture
.
create
();
...
...
@@ -548,7 +553,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
ImageView
ivClose
=
dialogView
.
findViewById
(
R
.
id
.
iv_back
);
ivClose
.
setOnClickListener
(
v
->
bottomSheetDialog
.
dismiss
());
mCurrentQuestionIndex
=
1
;
mCurrentQuestionIndex
=
0
;
renderQuestion
(
questionnaire
,
dialogView
,
bottomSheetDialog
);
bottomSheetDialog
.
setOnShowListener
(
dialog
->
{
...
...
@@ -576,7 +581,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
}
TextView
tvQuestionCount
=
dialogView
.
findViewById
(
R
.
id
.
tv_question_count
);
tvQuestionCount
.
setText
(
String
.
valueOf
(
mCurrentQuestionIndex
)
+
"/"
+
String
.
valueOf
(
questionnaire
.
getQuestions
().
size
()-
1
));
tvQuestionCount
.
setText
(
String
.
valueOf
(
mCurrentQuestionIndex
+
1
)
+
"/"
+
String
.
valueOf
(
questionnaire
.
getQuestions
().
size
()
));
TextView
tvQuestionHeaderTitle
=
dialogView
.
findViewById
(
R
.
id
.
tv_question_header_title
);
TextView
tvQuestionHeaderSubtitle
=
dialogView
.
findViewById
(
R
.
id
.
tv_question_subtitle
);
...
...
@@ -600,54 +605,163 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
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
);
String
optionHeaderText
=
options
.
optString
(
0
);
View
dropdownHeader
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
item_questionnaire_list_header
,
llOptionsContainer
,
false
);
TextView
tvDropdownTitle
=
dropdownHeader
.
findViewById
(
R
.
id
.
tv_dropdown_option_header
);
ImageView
ivArrow
=
dropdownHeader
.
findViewById
(
R
.
id
.
iv_terms_arrow
);
String
optionHeaderText
=
options
!=
null
&&
options
.
length
()
>
0
?
options
.
optString
(
0
)
:
"Επιλέξτε"
;
tvDropdownTitle
.
setText
(
optionHeaderText
);
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
);
llOptionsContainer
.
addView
(
dropdownHeader
);
List
<
String
>
popupOptions
=
new
ArrayList
<>();
if
(
options
!=
null
)
{
for
(
int
i
=
1
;
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
);
TextView
tvOptionTitle
=
optionView
.
findViewById
(
R
.
id
.
tv_option_title
);
tvOptionTitle
.
setText
(
optionText
);
WarpUtils
.
renderCustomFont
(
this
,
R
.
font
.
ping_lcg_regular
,
tvOptionTitle
);
tvOptionTitle
.
setTextColor
(
getColor
(
R
.
color
.
custom_grey3
));
for
(
int
i
=
0
;
i
<
options
.
length
();
i
++)
{
popupOptions
.
add
(
options
.
optString
(
i
));
}
}
optionView
.
setOnClickListener
(
v
->
{
ArrayAdapter
<
String
>
adapter
=
new
ArrayAdapter
<
String
>(
this
,
R
.
layout
.
item_questionnaire_list_option
,
popupOptions
)
{
@Override
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
if
(
convertView
==
null
)
{
convertView
=
LayoutInflater
.
from
(
getContext
()).
inflate
(
R
.
layout
.
item_questionnaire_list_option
,
parent
,
false
);
}
TextView
tvOption
=
convertView
.
findViewById
(
R
.
id
.
tv_dropdown_option_title
);
if
(
tvOption
!=
null
)
{
tvOption
.
setText
(
getItem
(
position
));
WarpUtils
.
renderCustomFont
(
HomeActivity
.
this
,
R
.
font
.
ping_lcg_regular
,
tvOption
);
}
return
convertView
;
}
};
ListPopupWindow
listPopupWindow
=
new
ListPopupWindow
(
this
);
listPopupWindow
.
setAdapter
(
adapter
);
listPopupWindow
.
setAnchorView
(
dropdownHeader
);
listPopupWindow
.
setModal
(
true
);
listPopupWindow
.
setHeight
((
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
55
*
5
,
getResources
().
getDisplayMetrics
()));
dropdownHeader
.
setOnClickListener
(
v
->
{
ivArrow
.
animate
().
rotation
(
180
f
).
setDuration
(
200
).
start
();
listPopupWindow
.
setWidth
(
dropdownHeader
.
getWidth
());
listPopupWindow
.
show
();
});
listPopupWindow
.
setOnDismissListener
(()
->
{
ivArrow
.
animate
().
rotation
(
0
f
).
setDuration
(
200
).
start
();
});
listPopupWindow
.
setOnItemClickListener
((
parent
,
view
,
position
,
id
)
->
{
selectedPositions
.
clear
();
selectedPositions
.
add
(
position
);
tvDropdownTitle
.
setText
(
optionText
);
llDropdownList
.
setVisibility
(
View
.
GONE
);
llDropdownContainer
.
setBackground
(
AppCompatResources
.
getDrawable
(
this
,
R
.
drawable
.
shape_questionnaire_option_selected
));
tvDropdownTitle
.
setTextColor
(
getColor
(
R
.
color
.
black
));
tvDropdownTitle
.
setText
(
popupOptions
.
get
(
position
));
listPopupWindow
.
dismiss
();
});
llDropdownList
.
addView
(
optionView
);
}
else
if
(
"custom1"
.
equals
(
type
))
{
String
[]
headers
=
{
"Ενήλικες"
,
"Παιδιά έως 9 ετών"
,
"Παιδιά 10-18 ετών"
};
if
(
options
!=
null
)
{
for
(
int
i
=
0
;
i
<
options
.
length
();
i
++)
{
Object
outerItem
=
options
.
opt
(
i
);
if
(!(
outerItem
instanceof
JSONArray
))
continue
;
JSONArray
innerList
=
(
JSONArray
)
outerItem
;
List
<
String
>
popupOptions
=
new
ArrayList
<>();
for
(
int
j
=
0
;
j
<
innerList
.
length
();
j
++)
{
popupOptions
.
add
(
innerList
.
optString
(
j
));
}
// 1. Inflate header container
View
customContainer
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
item_questionnaire_list_custom
,
llOptionsContainer
,
false
);
LinearLayout
llCustomContainer
=
customContainer
.
findViewById
(
R
.
id
.
ll_option_container
);
TextView
tvHeaderTitle
=
customContainer
.
findViewById
(
R
.
id
.
tv_dropdown_option_header
);
// 2. Set header text and font
if
(
i
<
headers
.
length
)
{
tvHeaderTitle
.
setText
(
headers
[
i
]);
}
WarpUtils
.
renderCustomFont
(
this
,
R
.
font
.
ping_lcg_regular
,
tvHeaderTitle
);
// 3. Inflate dropdown button and add it inside the custom container
View
dropdownHeader
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
item_questionnaire_list_header
,
llCustomContainer
,
false
);
TextView
tvDropdownTitle
=
dropdownHeader
.
findViewById
(
R
.
id
.
tv_dropdown_option_header
);
ImageView
ivArrow
=
dropdownHeader
.
findViewById
(
R
.
id
.
iv_terms_arrow
);
LinearLayout
.
LayoutParams
dropdownParams
=
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
MATCH_PARENT
,
(
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
55
,
getResources
().
getDisplayMetrics
())
);
dropdownHeader
.
setLayoutParams
(
dropdownParams
);
tvDropdownTitle
.
setText
(
"Επιλέξτε"
);
WarpUtils
.
renderCustomFont
(
this
,
R
.
font
.
ping_lcg_regular
,
tvDropdownTitle
);
llCustomContainer
.
addView
(
dropdownHeader
);
// 4. Create ArrayAdapter for popup rows
ArrayAdapter
<
String
>
adapter
=
new
ArrayAdapter
<
String
>(
this
,
R
.
layout
.
item_questionnaire_list_option
,
popupOptions
)
{
@Override
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
if
(
convertView
==
null
)
{
convertView
=
LayoutInflater
.
from
(
getContext
()).
inflate
(
R
.
layout
.
item_questionnaire_list_option
,
parent
,
false
);
}
TextView
tvOption
=
convertView
.
findViewById
(
R
.
id
.
tv_dropdown_option_title
);
if
(
tvOption
!=
null
)
{
tvOption
.
setText
(
getItem
(
position
));
WarpUtils
.
renderCustomFont
(
HomeActivity
.
this
,
R
.
font
.
ping_lcg_regular
,
tvOption
);
}
return
convertView
;
}
};
// 5. Create ListPopupWindow
ListPopupWindow
listPopupWindow
=
new
ListPopupWindow
(
this
);
listPopupWindow
.
setAdapter
(
adapter
);
listPopupWindow
.
setAnchorView
(
dropdownHeader
);
listPopupWindow
.
setModal
(
true
);
listPopupWindow
.
setHeight
((
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
300
,
getResources
().
getDisplayMetrics
()));
dropdownHeader
.
setOnClickListener
(
v
->
{
boolean
isExpanded
=
llDropdownList
.
getVisibility
()
==
View
.
VISIBLE
;
llDropdownList
.
setVisibility
(
isExpanded
?
View
.
GONE
:
View
.
VISIBLE
);
ivArrow
.
animate
().
rotation
(
180
f
).
setDuration
(
200
).
start
();
listPopupWindow
.
setWidth
(
dropdownHeader
.
getWidth
());
listPopupWindow
.
show
();
});
llOptionsContainer
.
addView
(
dropdownHeader
);
llOptionsContainer
.
addView
(
llDropdownList
);
}
else
{
listPopupWindow
.
setOnDismissListener
(()
->
{
ivArrow
.
animate
().
rotation
(
0
f
).
setDuration
(
200
).
start
();
});
final
int
headerIndex
=
i
;
listPopupWindow
.
setOnItemClickListener
((
parent
,
view
,
position
,
id
)
->
{
selectedPositions
.
clear
();
selectedPositions
.
add
(
headerIndex
*
100
+
position
);
tvDropdownTitle
.
setText
(
popupOptions
.
get
(
position
));
listPopupWindow
.
dismiss
();
});
llOptionsContainer
.
addView
(
customContainer
);
}
}
}
else
if
(
"multi"
.
equals
(
type
)
||
"string"
.
equals
(
type
))
{
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
;
...
...
warply_android_sdk/src/main/res/drawable/shape_popup_option.xml
0 → 100644
View file @
8b0e381
<?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"
/>
</shape>
\ No newline at end of file
warply_android_sdk/src/main/res/layout/item_questionnaire_list_custom.xml
0 → 100644
View file @
8b0e381
<?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=
"wrap_content"
android:background=
"@color/white"
android:gravity=
"center_vertical"
android:orientation=
"vertical"
android:layout_marginTop=
"40dp"
>
<TextView
android:id=
"@+id/tv_dropdown_option_header"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:includeFontPadding=
"false"
android:layout_marginBottom=
"12dp"
android:paddingHorizontal=
"16dp"
android:textColor=
"@color/black"
android:textSize=
"15sp"
tools:text=
"Option Title"
/>
</LinearLayout>
\ No newline at end of file
warply_android_sdk/src/main/res/layout/item_questionnaire_list_header.xml
0 → 100644
View file @
8b0e381
<?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:background=
"@drawable/shape_questionnaire_option_unselected"
android:gravity=
"center_vertical"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
>
<TextView
android:id=
"@+id/tv_dropdown_option_header"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:includeFontPadding=
"false"
tools:text=
"Option Title"
android:textColor=
"@color/black"
android:textSize=
"15sp"
/>
<ImageView
android:id=
"@+id/iv_terms_arrow"
android:layout_width=
"10dp"
android:layout_height=
"10dp"
android:src=
"@drawable/ic_arrow_down"
/>
</LinearLayout>
\ No newline at end of file
warply_android_sdk/src/main/res/layout/item_questionnaire_list_option.xml
0 → 100644
View file @
8b0e381
<?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=
"@color/white"
android:gravity=
"center"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/tv_dropdown_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
Please
register
or
login
to post a comment