The Challenges kit engage users by challenging them to perform some activities on behalf of your brand. By entering a challenge, user acquires points or rewards in return. The Challenges
kit contains two type of challenges. An alert challenge that requires the user to respond on the challenge and a standard challenge that gives you the choice to respond or not on the challenge.
On this page:
To include the Challenges kit, open the Gradle Scripts | build.gradle (Module: app)
and add the following to the
dependencies section:
implementation 'com.cheetahdigital.android:challenges:<version>'
Alert Challenge
Alert Challenge is a type of challenge that requires the user to respond on the challenge. This is normally used after login or everytime homepage is called. Alert Challenge requires respondable
and show_as_alert
attribute set to true.
Types of Alert Challenge
FULL WINDOW CHALLENGE
DIALOG CHALLENGE
Challenge
The Challenges kit follows the Master / Detail
navigation flow
The Challenges Master > Detail > Response
Screens
Overview
Launching the Challenges Activities
Assuming that the Challenges kit will be launched from a MainActivity
, you can follow the succeeding steps to launch the ChallengesActivity
from a Button’s OnClickListener
:
- Add the following Challenge Activities to the Manifest:
- ChallengesActivity
- ChallengeDetailsActivity
- ChallengeResponsesDetailsActivity
<activity android:name="com.cheetahdigital.sdk.pager.ChallengesActivity" android:label="@string/challenges" /> <activity android:name="com.cheetahdigital.challenges.ui.challenges.ChallengeDetailsActivity"> <intent-filter> <action android:name="${applicationId}.CHALLENGE_DETAILS" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name="com.cheetahdigital.challenges.ui.responses.ChallengeResponseDetailsActivity"> <intent-filter> <action android:name="${applicationId}.CHALLENGE_RESPONSE_DETAILS" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>
- You need to declare some permissions for certain types of challenges in your
AndroidManifest.xml
.-
Photo and Video Challenge
<uses-permission android:name="android.permission.CAMERA"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
-
Check in Challenge
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
-
-
In your
MainActivity
, add a Button to launch the starting Activity -ChallengesActivity
:button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(MainActivity.this, ChallengesActivity.class))); } });
Theme Customization
The Kits leverage on Android’s support for Styles and Themes. Overriding Styles and Themes per Widget, Activity, or Application can change the app’s appearance. To read more about this, please visit our Styles and Themes document.
Layout Customization
###Customizing Layouts via XML You can customize the layouts of the different screens in the Challenges kit by copying the layout XML’s and overriding as desired. To read more about this, please visit the Layout Customization via XML document. The XML’s used are:
activity_checkin
- layout used for check-in challengeactivity_challenge_details
- layout used for displaying details screen of a challengeactivity_challenge_response
- base layout used for all challengesactivity_facebook_response
- layout used for facebook challengeactivity_javascript_game
- layout used for javascript gameactivity_response_details
- layout used for displaying response detailsactivity_scratcher
- layout used for scratcher challengeactivity_social_instagram
- layout used for instagram challengeactivity_social_twitter
- layout used for twitter challengedialog_challenge_response
- layout used for displaying alert dialogdialog_multi_question
- layout used for multiquestion challenge in alert dialogfragment_challenge_response
- parent layout for attaching rating, multiple choice, text, numeric challengefragment_multi_question
- layout used for multiquestion challengefragment_survey_text
- layout used for survey challengefragment_update_profile_challenge
- layout used for update profile challengefragment_view_content
- layout used for video, photo and url challengelayout_challenge_meme
- layout used for meme challenge with caption over the imagelayout_challenge_meme_caption_separate
- layout used for meme challenge with caption seperate from imagelayout_challenge_multiple_choie_toggle_button
- layout used byMultipleChoiceSurveyFragment
for populating survey optionslayout_challenge_photo
- layout used for photo challengelayout_challenge_survey_multiple_choice
- layout used for multiple choice survey challengelayout_challenge_survey_rating
- layout used for rating survey challengefragment_challenge_video
- layout used for video challengelayout_meme_text_view
- layout used for displaying the text in meme challengelist_item_challenges
- layout used for displaying an item in challenge listlist_item_prizes
- layout used for displaying each prizes inScratcherActvity
list_item_response_comments
- layout used for displaying comment section inResponseDetailsActivity
list_item_responses
- layout used for displaying an item in response list
Customizing Layouts via Code
There are certain cases that you may want to use a highly-customized layout for an Activity. To read more about this, please visit the Layout Customization via Code document. The classes used for the Challenges kit are:
CheckinActivity
andCheckinFragment
- for displaying the check-in details and check-in pointsJavascriptGameActivity
and ScratcherActivity` - for displaying the game challenge using a webview or a scratcher viewFontSizePickerDialogFragment
,MemeCaptionSeparateResponseFragment
andMemeResponseFragment
- for displaying the meme challenge page with the font size dialog and captionMultiQuestionResponseActivity
andMultiQuestionResponseFragment
- for displaying multiple questions of text survey, rating survey, numeric survey or multiple choice surveyPhotoResponseFragment
- for displaying a selected photo to respond on the challengeFacebookResponseActivity
- for displaying Facebook share, post, connect, like and followInstagramResponseActivity
- for displaying Instagram post, connect, like and followTwitterResponseActivity
- for displaying Twitter share, post, connect, like and followMultipleChoiceSurveyFragment
- for displaying multiple choice survey pageNumericSurveyFragment
- for displaying numeric survey pageRatingSurveyFragment
- for displaying rating survey pageTextSurveyFragment
- for displaying text survey pagePreferencesDetailFragment
,UpdateProfileResponseFragment
andUpdateProfileResponseActivity
- for displaying preference details or profile detailsVideoResponseFragment
- for displaying a selected video to respond on the challengeViewContentActivity
andViewContentFragment
- for displaying a page for viewing photo, video or urlChallengeResponseActivity
andChallengeResponseTypeFragment
- for displaying multiple choice survey, text survey, rating survey or numeric surveyChallengeDetailsActivity
- for displaying details of a challengeChallengeListFragment
,ChallengesListActivity
andChallengesPagerFragment
- for displaying list of challengesResponseDetailsActivity
- for displaying details of a challenge already respondedResponsesListFragment
- for displaying the list of responded challenges
Customizing Handlers
For cases that need changes in the default behavior of an Activity or Fragment, achieve that by extending the class that needs to be customized and override as necessary.
Handlers may occur in different places:
- Adapters - for lists
- Member variables inside Activities or Fragments
- Member variables inside custom Widgets - for stand-alone custom Widgets
To start with, look at the classes mentioned in Customizing Layouts via Code, along with the following:
ChallengeProfileAdapter
- used for displaying url, gender, postal code, country, email, date, phone, mailing state, mailing country, boolean, text viewResponsesAdapter
- used for displaying list of responded challengesChallengesAdapter
- used for displaying list of challenges
Fully Custom UI
If changing the layout does not meet the requirements of the app, create your own challenge activity. The following are the methods you can use from the ChallengesAPI
class:
Querying Challenges
getChallenges(ChallengeParams params, boolean clearCache, ListenerModel<BaseModel<Challenges>, Challenges> listener)
getChallenges(ChallengeParams params, boolean clearCache, ListenerModel<BaseModel<Challenges>, Challenges> listener)
Submit or Resubmit Challenge Response
postChallenge(ChallengeParams params, ChallengeFields fields, ListenerModel<BaseModel<Response>, Response> listener)
postChallenge(ChallengeParams params, ChallengeParts parts, ListenerModel<BaseModel<Response>, Response> listener)
postChallenge(ChallengeParams params, RequestBody body, ListenerModel<BaseModel<Response>, Response> listener)
putChallenge(ChallengeParams params, ChallengeFields fields, ListenerModel<BaseModel<Response>, Response> listener)
putChallenge(ChallengeParams params, ChallengeParts parts, ListenerModel<BaseModel<Response>, Response> listener)
putChallenge(ChallengeParams params, RequestBody body, ListenerModel<BaseModel<Response>, Response> listener)
Query Challenge Response
getChallengeResponses(ChallengeParams params, boolean clearCache, ListenerModel<BaseModel<ChallengeResponses>, ChallengeResponses> listener)
getChallengeResponse(ChallengeParams params, boolean clearCache, ListenerModel<BaseModel<ChallengeResponse>, ChallengeResponse> listener)