Skip to content

Latest commit

 

History

History
231 lines (188 loc) · 8.1 KB

FeedbackUI.md

File metadata and controls

231 lines (188 loc) · 8.1 KB

Mappls Feedback Android SDK

Add the dependency

Add below dependency in app level build.gradle file

implementation 'com.mappls.sdk:feedback-ui:3.0.1'

Add your API keys to the SDK

Add your API keys to the SDK (in your application's onCreate() or before using map)

Java

MapplsAccountManager.getInstance().setRestAPIKey(getRestAPIKey());  	
MapplsAccountManager.getInstance().setMapSDKKey(getMapSDKKey());  		
MapplsAccountManager.getInstance().setAtlasClientId(getAtlasClientId());  	
MapplsAccountManager.getInstance().setAtlasClientSecret(getAtlasClientSecret());  	

Kotlin

MapplsAccountManager.getInstance().restAPIKey = getRestAPIKey()  	
MapplsAccountManager.getInstance().mapSDKKey = getMapSDKKey()  		
MapplsAccountManager.getInstance().atlasClientId = getAtlasClientId()  	
MapplsAccountManager.getInstance().atlasClientSecret = getAtlasClientSecret()	

Add Feedback Widget

There are two ways to implement Feedback UI widget:

  • Using FeedbackFragment
  • Using FeedbackActivity

Add FeedbackFragment in your activity

Java

FeedbackOptions feedbackOption =FeedbackOptions.builder()
        .latitude(<Latitude>)
        .longitude(<Longitude>)
        .build();
FeedbackFragment feedbackFragment = FeedbackFragment.newInstance(feedbackOption);

getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, feedbackFragment, FeedbackFragment.class.getSimpleName())  
        .commit();

Kotlin

val feedbackOption: FeedbackOptions = FeedbackOptions.builder()
   .latitude(< Latitude >)
   .longitude(< Longitude >)
   .build()

val feedbackFragment: FeedbackFragment = FeedbackFragment.newInstance(feedbackOption)
supportFragmentManager.beginTransaction().add(R.id.fragment_container, feedbackFragment, FeedbackFragment::class.java.simpleName)  
        .commit()  

To get the event of Report Submit use FeedbackCallback interface:

Java

feedbackFragment.setFeedbackCallback(new FeedbackCallback() {
    @Override
    public void onSubmittedReport() {
        // On Submitted Report Succssfully
    }

    @Override
    public void onCancel() {
        //on click of Cancel button
    }
});

Kotlin

feedbackFragment.setFeedbackCallback(object : FeedbackCallback {
  override fun onCancel() {
    //on click of Cancel button
  }

  override fun onSubmittedReport() {
    // On Submitted Report Succssfully
  }
})

Add FeedbackActivity in your activity:

Java

FeedbackOptions builder=FeedbackOptions.builder()
        .placeName(<name of place>)
        .latitude(<Latitude>)
        .longitude(<Longitude>)
        .build();
Intent intent = new MapplsFeedback.IntentBuilder().feedbackOptions(feedbackOptions)
                        .build(this);
startActivityForResult(intent, REQUEST_CODE);

Kotlin

val builder: FeedbackOptions = FeedbackOptions.builder()
   .placeName(< name of place >)
   .latitude(< Latitude >)
   .longitude(< Longitude >)
.build()

val intent = MapplsFeedback.IntentBuilder().feedbackOptions(feedbackOptions)
         .build(this);
startActivityForResult(intent, REQUEST_CODE);

To get the event of Report Submit:

Java

protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(requestCode == REQUEST_CODE) {
        if(resultCode == Activity.RESULT_OK) {
            //Report Submit Successfully
        }
    }
}

Kotlin

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
  super.onActivityResult(requestCode, resultCode, data)
  if(requestCode == REQUEST_CODE) {
    if(resultCode == Activity.RESULT_OK) {
            //Report Submit Successfully
    }
  }
}

You can use FeedbackOptions to set the properties of the widget:

Mandatory Parameters

  1. mapplsPin(string): Mappls Pin of the place.The 6-digit alphanumeric code for any location.
  2. latitude(Double) : Latitude of the user’s location.
  3. longitude(Double): longitude of the user’s location. ** Either the eloc or latitude & Longitude will be served. **

Optional Parameters

  1. placeName(string) : Name of the place where the event is taking place. It should be derived on the basis of Mappls Pin and coordinates.
  2. theme(Integer): To change the theme of the UI. Below are the available value:
    • FeedbackOptions.THEME_DAY (Default)
    • FeedbackOptions.THEME_NIGHT
  3. showStepProgress(boolean): To show/hide Circular Progress of steps
  4. showCompletedProgress(boolean): To show/hide Completed Progress text
  5. utc(Long): Date time in unix timestamp format.
  6. flag(Integer): If navroute is active then 1 else 0.
  7. expiry(Long): Date time in unix timestamp format to set expiry for the report.
  8. accuracy(Integer): Accuracy of user's location.
  9. altitude(Double): Altitude of the user’s location, in meters.
  10. bearing(Integer): Bearing of the user’s location, in degrees.
  11. quality(String): Quality of user's location.
  12. speed(String): User's speed in kilometers.

Custom Style - Feedback UI

You need to define the Custom Styles in styles.xml or themes.xml

For Day Theme

<style name="CustomFeedbackDay" parent="MapplsFeedbackLight">
  <item name="mapplsFeedbackToolbarSeperatorColor">#FFFFFF</item>
</style>

For Dark Theme

<style name="CustomFeedbackNight" parent="MapplsFeedbackNight">
  <item name="mapplsFeedbackToolbarSeperatorColor">#000000</item>
</style>

Set Custom style in FeedbackOption

To set custom style in FeedbackOption:

FeedbackOptions feedbackOptions = FeedbackOptions.builder()
   .dayTheme(R.style.CustomFeedbackDay)
   .darkTheme(R.style.CustomFeedbackNight)
   .build();

Style Attributes

  1. mapplsFeedbackToolbarBackground(color): To change the color of Toolbar Background
  2. mapplsFeedbackToolbarTextColor(color): To change the color of Toolbar Text
  3. mapplsFeedbackToolbarSeperatorColor(color): To change the Toolbar Seperator color
  4. mapplsFeedbackBackground(color): To change the Background color of Feedback Screen
  5. mapplsFeedbackStepsHeaderBackground(color): To change the Steps view Background color
  6. mapplsFeedbackStepsTextColor(color): To change the Steps text color
  7. mapplsFeedbackFooterBackground(color): To change Footer background color
  8. mapplsFeedbackBackBtnBackground(reference): To change Back button background
  9. mapplsFeedbackBackBtnTextColor(color): To change Back button text color
  10. mapplsFeedbackSubmitBtnBackground(reference): To change Submit Button Background
  11. mapplsFeedbackSubmitBtnTextColor(color): To change Submit Button Text color

For any queries and support, please contact:

Email us at apisupport@mappls.com

Support Need support? contact us!