Skip to content
mscherrer edited this page Nov 7, 2016 · 4 revisions

Usage

An application has exactly 1 PUSH configuration and 0 to n PULL configurations. See Feedback gathering mechanisms as well as configuration parameters for more detailed information.

PUSH configuration
A PUSH configuration, also referred as PUSH feedback, represents the configuration which is loaded if feedback application is started on behalf of the user, e.g., via a 'Feedback'-Button on the web page.
PULL configuration
A PULL configuration, also referred as PULL feedback, represents a configuration which is loaded on behalf of the developer, e.g., start a PULL feedback if the user repeatedly tried to perfom an invalid operation.

Android client

This section gives a brief instruction on how to user the Android library. A complete code example is given in the StartActivity as well as other resources in the hostapplication application.

PUSH feedback

When a PUSH feedback is started by the user, permissions to read the external storage are needed, because the library automatically takes a screenshot of the current screen before opening the feedback application. Hence, the developer must define a unique integer variable, henceforth referred as UIV, which will later be used in the onRequestPermissionsResult method. Since Android Marshmallow version 6.0, permissions can be changed at runtime. Therefore, the onRequestPermissionsResult method must be overridden wherever a PUSH feedback is started in the activity. The following code snippet shows the correct way for starting a PUSH feedback.

/*
 * this           the activity from where the feedback is started
 * UIV            the unique integer variable
 * baseURL        the URL
 * appliactionId  the application id
 * language       the language
 */
boolean result = Utils.checkSinglePermission(this, UIV, Manifest.permission.READ_EXTERNAL_STORAGE, null, null, false);
if (result) {
   // See http://docs.supersedeorchestratorapi.apiary.io/#reference for further information
   Utils.startActivityWithScreenshotCapture(baseURL, this, applicationId, language);
}

@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        switch (requestCode) {
                // other cases
                UIV:            
                Utils.onRequestPermissionsResultCase(requestCode, permissions, grantResults, this, Manifest.permission.READ_EXTERNAL_STORAGE,
                        ch.uzh.supersede.feedbacklibrary.R.string.supersede_feedbacklibrary_permission_request_title,
                        ch.uzh.supersede.feedbacklibrary.R.string.supersede_feedbacklibrary_external_storage_permission_text_automatic_screenshot_rationale,
                        applicationId, baseURL, language);
                break;
                // other cases
        }
    }

PULL feedback

A PULL feedback can be triggered by the developer everywhere in the code and no permissions are needed by the user. The developer needs to provide the id of the PULL configuration as well as the dialog text presented to the user if an intermediate dialog is shown (in addition to the baseURL, the application id and language). The following code snippet shows the correct way for triggering a PULL feedback.

/*
 * Activity.this    the activity from where the feedback is started
 * UIV              the unique integer variable
 * baseURL          the URL
 * appliactionId    the application id
 * language         the language
 * configurationID  the configuration id
 * text             the dialog text
 */
// See http://docs.supersedeorchestratorapi.apiary.io/#reference for further information
Utils.triggerSpecificPullFeedback(baseURL, Activity.this, applicationId, language, configurationId, text);

Additionally, it is possible to trigger a random PULL feedback out of all available PULL configurations as follows.

Utils.triggerSpecificPullFeedback(baseURL, Activity.this, applicationId, language);

Error handling

The Android library takes care of the error handling concerning the sending of a feedback as well as retrieval of a configuration. An error upon sending a feedback can occur if the feedback repository is down or if the POST request failed, e.g., due to a wrong response code or if there is no internet connection. The user will then be prompted an appropriate error message.
Regarding the retrieval of a configuration, there is a difference between a PUSH and PULL feedback. In the case the user triggers a PUSH feedback and an error occurs, e.g., if the feedback orchestrator is down or an invalid configuration is retrieved, the user will then be prompted an appropriate error message and redirected back to the host application. If an error occurs during retrieving a PULL configuration, nothing happens because an error message prompted to the user would be confusing and very misleading.

Resources

The following resources, such as colorPrimary or colorAccent, can be overridden so the feedback application has the same look and feel as the host application.

feedbacklibrary/src/main/res/values/colors.xml

    <!--
    Colors used in the feedback library.
    In order to use other colors simply uncomment the specific color and choose the appropriate color.
    -->

    <color name="colorPrimary">#3F51B5</color>
    <color name="colorPrimaryDark">#303F9F</color>
    <color name="colorAccent">#FF4081</color>
    <color name="whiteColor">#FFFFFF</color>

    <color name="supersede_feedbacklibrary_annotate_image_layout_background_color">#4D4D4D</color>

    <color name="supersede_feedbacklibrary_audio_timer_record_indicator_start_animation_color">
        #000000
    </color>
    <color name="supersede_feedbacklibrary_audio_timer_record_indicator_end_animation_color">
        #FF4081
    </color>
    <color name="progress_start">#009933</color>
    <color name="progress_end">#996633</color>

feedbacklibrary/src/main/res/values/strings.xml

    <!--
    Strings used in the feedback library.
    Override the strings for multi-language support.
    -->

    <!-- Activity names -->
    <string name="supersede_feedbacklibrary_feedback_library_name">Feedback Library</string>
    <string name="supersede_feedbacklibrary_feedback_activity_name">Feedback</string>
    <string name="supersede_feedbacklibrary_annotate_image_activity_name">Annotate Image</string>

    <!-- Audio mechanism -->
    <string name="supersede_feedbacklibrary_audio_default_current_duration">0:00</string>
    <string name="supersede_feedbacklibrary_audio_default_total_duration">0:00/-</string>
    <string name="supersede_feedbacklibrary_audio_record_indicator">RECORDING!</string>
    <string name="supersede_feedbacklibrary_audio_maximum_length_text">Maximum %1$d seconds can be recorded</string>
    <string name="supersede_feedbacklibrary_audio_maximum_length_reached_text">"Recording stopped because the limit of %1$d seconds is reached"</string>
    <string name="supersede_feedbacklibrary_audio_stopped_recording_text">Stopped recording</string>

    <!-- Category mechanism -->
    <string name="supersede_feedbacklibrary_single_option_dialog_title">Please select an option</string>
    <string name="supersede_feedbacklibrary_multiple_options_dialog_title">Please select one or multiple options</string>
    <string name="supersede_feedbacklibrary_other_option_string">Other</string>
    <string name="supersede_feedbacklibrary_other_options_string">Others</string>
    <string name="supersede_feedbacklibrary_own_category_dialog_label">Category</string>
    <string name="supersede_feedbacklibrary_own_category_dialog_hint">Please enter your own category</string>

    <!-- Image annotation-->
    <string name="supersede_feedbacklibrary_colorpickerbutton_text">Color Picker</string>
    <string name="supersede_feedbacklibrary_blurbutton_text">Blur</string>
    <string name="supersede_feedbacklibrary_unblurbutton_text">Unblur</string>
    <string name="supersede_feedbacklibrary_fillbutton_text">Fill</string>
    <string name="supersede_feedbacklibrary_strokebutton_text">Stroke</string>
    <string name="supersede_feedbacklibrary_blackbutton_text">Black</string>
    <string name="supersede_feedbacklibrary_colorbutton_text">Color</string>
    <string name="supersede_feedbacklibrary_finishannotation_title">Finish annotation</string>
    <string name="supersede_feedbacklibrary_cancelannotation_title">Cancel annotation</string>
    <string name="supersede_feedbacklibrary_chosencolor_string">Chosen color</string>
    <string name="supersede_feedbacklibrary_photo_capture_text">Take a photo</string>
    <string name="supersede_feedbacklibrary_library_chooser_text">Choose from library</string>
    <string name="supersede_feedbacklibrary_image_selection_dialog_title">Select an image</string>
    <string name="supersede_feedbacklibrary_crop_string">Crop</string>
    <string name="supersede_feedbacklibrary_sticker_dialog_title">Express your sentiment</string>
    <string name="supersede_feedbacklibrary_sticker_dialog_smiley_title">Smiley</string>
    <string name="supersede_feedbacklibrary_sticker_dialog_thumb_up_title">Thumb up</string>
    <string name="supersede_feedbacklibrary_sticker_dialog_thumb_down_title">Thumb down</string>
    <string name="supersede_feedbacklibrary_sticker_dialog_dissatisfied_title">Dissatisfied</string>
    <string name="supersede_feedbacklibrary_sticker_dialog_neutral_title">Neutral</string>
    <string name="supersede_feedbacklibrary_sticker_dialog_satisfied_title">Satisfied</string>
    <string name="supersede_feedbacklibrary_text_annotation_dialog_label">Text annotation</string>
    <string name="supersede_feedbacklibrary_text_annotation_dialog_hint">Please enter your text annotation</string>
    <string name="supersede_feedbacklibrary_text_processing_dialog">Please wait. Processing image</string>

    <!-- Miscellaneous -->
    <string name="supersede_feedbacklibrary_sendconfirmation_text">By sending the feedback, you agree with the terms and conditions.</string>
    <string name="supersede_feedbacklibrary_sendbutton_text">Send feedback</string>
    <string name="supersede_feedbacklibrary_remove_string">Remove</string>
    <string name="supersede_feedbacklibrary_off_string">Off</string>
    <string name="supersede_feedbacklibrary_on_string">On</string>
    <string name="supersede_feedbacklibrary_yes_string">Yes</string>
    <string name="supersede_feedbacklibrary_no_string">No</string>
    <string name="supersede_feedbacklibrary_ok_string">OK</string>
    <string name="supersede_feedbacklibrary_cancel_string">Cancel</string>
    <string name="supersede_feedbacklibrary_discard_string">Discard</string>
    <string name="supersede_feedbacklibrary_close_string">Close</string>
    <string name="supersede_feedbacklibrary_loading_string">Loading. Please wait.</string>
    <string name="supersede_feedbacklibrary_error_text">Oops. Something went wrong! Please try again later.</string>
    <string name="supersede_feedbacklibrary_success_text">Your feedback was successfully sent. Thank you!</string>
    <string name="supersede_feedbacklibrary_feedback_application_unavailable_text">We apologize that the feedback tool is not available at the moment. Please try again later.</string>
    <string name="supersede_feedbacklibrary_feedback_title_text">Feedback title at the current time of %1$d milliseconds</string>

    <!-- Permissions -->
    <string name="supersede_feedbacklibrary_permission_request_title">Permission request</string>
    <string name="supersede_feedbacklibrary_record_audio_permission_granted_text">You can now capture your audio message by pressing the record button</string>
    <string name="supersede_feedbacklibrary_record_audio_permission_text">Audio permission is necessary in order to record audio</string>
    <string name="supersede_feedbacklibrary_record_audio_permission_text_instructions">Audio permission is necessary in order to record audio. You can grant access in the application\'s settings to use this feature.</string>
    <string name="supersede_feedbacklibrary_external_storage_permission_text">External storage permission is necessary in order to choose a picture</string>
    <string name="supersede_feedbacklibrary_external_storage_permission_text_instructions">External storage permission is necessary in order to choose a picture. You can grant access in the application\'s settings to use this feature.</string>
    <string name="supersede_feedbacklibrary_external_storage_permission_text_automatic_screenshot_rationale">The application takes a screenshot of the current screen and external storage permission is necessary to do so</string>
    <string name="supersede_feedbacklibrary_retry_string">Re-try</string>
    <string name="supersede_feedbacklibrary_not_now_text">Not now</string>

    <!-- Pull feedback -->
    <string name="supersede_feedbacklibrary_pull_feedback_question_string">Would you like to give feedback?</string>

    <!-- Screenshot mechanism -->
    <string name="supersede_feedbacklibrary_screenshotbutton_text">Screenshot</string>
    <string name="supersede_feedbacklibrary_annotatebutton_text">Annotate</string>
    <string name="supersede_feedbacklibrary_previewbutton_text">Preview</string>
    <string name="supersede_feedbacklibrary_erasebutton_text">Erase</string>

    <!-- Text mechanism -->
    <string name="supersede_feedbacklibrary_maximum_character_hint">"Text cannot be longer than %1$d characters"</string>

    <!-- Overriding string resources in com.theartofdev.edmodo:android-image-cropper -->
    <string name="crop_image_menu_crop">@string/supersede_feedbacklibrary_crop_string</string>