Cheetah CES Docs Portal

Navigation
Home
GitHub
Email
Corporate Site


Challenges

« Back to Kits References

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:

  1. 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>
    
    
  2. 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"/>
      
  3. 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 challenge
  • activity_challenge_details - layout used for displaying details screen of a challenge
  • activity_challenge_response - base layout used for all challenges
  • activity_facebook_response - layout used for facebook challenge
  • activity_javascript_game - layout used for javascript game
  • activity_response_details - layout used for displaying response details
  • activity_scratcher - layout used for scratcher challenge
  • activity_social_instagram - layout used for instagram challenge
  • activity_social_twitter - layout used for twitter challenge
  • dialog_challenge_response - layout used for displaying alert dialog
  • dialog_multi_question - layout used for multiquestion challenge in alert dialog
  • fragment_challenge_response - parent layout for attaching rating, multiple choice, text, numeric challenge
  • fragment_multi_question - layout used for multiquestion challenge
  • fragment_survey_text - layout used for survey challenge
  • fragment_update_profile_challenge - layout used for update profile challenge
  • fragment_view_content - layout used for video, photo and url challenge
  • layout_challenge_meme - layout used for meme challenge with caption over the image
  • layout_challenge_meme_caption_separate - layout used for meme challenge with caption seperate from image
  • layout_challenge_multiple_choie_toggle_button - layout used by MultipleChoiceSurveyFragment for populating survey options
  • layout_challenge_photo - layout used for photo challenge
  • layout_challenge_survey_multiple_choice - layout used for multiple choice survey challenge
  • layout_challenge_survey_rating - layout used for rating survey challenge
  • fragment_challenge_video - layout used for video challenge
  • layout_meme_text_view - layout used for displaying the text in meme challenge
  • list_item_challenges - layout used for displaying an item in challenge list
  • list_item_prizes - layout used for displaying each prizes in ScratcherActvity
  • list_item_response_comments - layout used for displaying comment section in ResponseDetailsActivity
  • 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 and CheckinFragment - for displaying the check-in details and check-in points
  • JavascriptGameActivity and ScratcherActivity` - for displaying the game challenge using a webview or a scratcher view
  • FontSizePickerDialogFragment, MemeCaptionSeparateResponseFragment and MemeResponseFragment - for displaying the meme challenge page with the font size dialog and caption
  • MultiQuestionResponseActivity and MultiQuestionResponseFragment - for displaying multiple questions of text survey, rating survey, numeric survey or multiple choice survey
  • PhotoResponseFragment - for displaying a selected photo to respond on the challenge
  • FacebookResponseActivity - for displaying Facebook share, post, connect, like and follow
  • InstagramResponseActivity - for displaying Instagram post, connect, like and follow
  • TwitterResponseActivity - for displaying Twitter share, post, connect, like and follow
  • MultipleChoiceSurveyFragment - for displaying multiple choice survey page
  • NumericSurveyFragment - for displaying numeric survey page
  • RatingSurveyFragment - for displaying rating survey page
  • TextSurveyFragment - for displaying text survey page
  • PreferencesDetailFragment, UpdateProfileResponseFragment and UpdateProfileResponseActivity - for displaying preference details or profile details
  • VideoResponseFragment - for displaying a selected video to respond on the challenge
  • ViewContentActivity and ViewContentFragment - for displaying a page for viewing photo, video or url
  • ChallengeResponseActivity and ChallengeResponseTypeFragment - for displaying multiple choice survey, text survey, rating survey or numeric survey
  • ChallengeDetailsActivity - for displaying details of a challenge
  • ChallengeListFragment, ChallengesListActivity and ChallengesPagerFragment - for displaying list of challenges
  • ResponseDetailsActivity - for displaying details of a challenge already responded
  • ResponsesListFragment - 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 view
  • ResponsesAdapter - used for displaying list of responded challenges
  • ChallengesAdapter - 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)


« Back to Kits References