Skip to content

Commit

Permalink
Add Opt Out Link
Browse files Browse the repository at this point in the history
- "opt out" view is now at the bottom left along with "Powered by Wootric" on right
- add "optOut" method set as on click listener for "opt out" textView which generates url(opt out link) and redirects user to web view of options

Trello: https://trello.com/c/zfh6LtQh/17-2-gdpr-android-sdk
  • Loading branch information
ambarwootric committed May 17, 2018
1 parent 8e57711 commit 9f2498f
Show file tree
Hide file tree
Showing 15 changed files with 153 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.8.0 (2018-05-18)

- Add new method to show opt out link

## 2.7.0 (2018-05-08)

- Add new method that just needs client_id & doesn't require the client_secret
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ If you use Maven, you can include this library as a dependency:
<dependency>
<groupId>com.wootric</groupId>
<artifactId>wootric-sdk-android</artifactId>
<version>2.7.0</version>
<version>2.8.0</version>
</dependency>
```

### Using Gradle

```xml
compile 'com.wootric:wootric-sdk-android:2.7.0'
compile 'com.wootric:wootric-sdk-android:2.8.0'
```

## Initializing Wootric
Expand Down
4 changes: 2 additions & 2 deletions androidsdk/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION_NAME=2.7.0
VERSION_CODE=270
VERSION_NAME=2.8.0
VERSION_CODE=280
GROUP=com.wootric

POM_DESCRIPTION=WootricSDK Android
Expand Down
9 changes: 9 additions & 0 deletions androidsdk/src/main/java/com/wootric/androidsdk/Wootric.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,15 @@ public void setSurveyImmediately(boolean surveyImmediately) {
this.settings.setSurveyImmediately(surveyImmediately);
}

/**
* If showOptOut is set to YES then opt out link will be shown
* return "true" and opt out link will be shown
* @param showOptOut A boolean to set if opt out link is to be shown.
*/
public void setShowOptOut(boolean showOptOut) {
this.settings.setShowOptOut(showOptOut);
}

/**
* Wootric provides designated class for providing custom messages
* @param customMessage WootricCustomMessage object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class Settings implements Parcelable {
private int timeDelay = Constants.NOT_SET;

private boolean surveyImmediately;
private boolean showOptOut;
private boolean skipFollowupScreenForPromoters;

private Integer dailyResponseCap;
Expand Down Expand Up @@ -110,6 +111,12 @@ public void setSurveyImmediately(boolean surveyImmediately) {
this.surveyImmediately = surveyImmediately;
}

public void setShowOptOut(boolean showOptOut) {
this.showOptOut = showOptOut;
}

public boolean isShowOptOut() { return showOptOut; }

public boolean isSurveyImmediately() {
return surveyImmediately;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.wootric.androidsdk.OfflineDataHandler;
import com.wootric.androidsdk.R;
Expand Down Expand Up @@ -76,6 +78,8 @@ public class SurveyFragment extends DialogFragment
private String mAccessToken;
private String mUniqueLink;
private Settings mSettings;
private LinearLayout mPoweredBy;
private TextView mBtnOptOut;

private boolean mResponseSent;

Expand Down Expand Up @@ -123,6 +127,7 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.wootric_fragment_survey, container, false);
mPoweredBy = (LinearLayout) view.findViewById(R.id.wootric_powered_by);

if (!mIsTablet) {
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
Expand All @@ -132,6 +137,24 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
mSurveyLayout.setSurveyLayoutListener(this);

mFooter = (LinearLayout) view.findViewById(R.id.wootric_footer);
mBtnOptOut = (TextView) view.findViewById(R.id.wootric_btn_opt_out);

if (mSettings.isShowOptOut()) {
mBtnOptOut.setVisibility(View.VISIBLE);
mBtnOptOut.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
optOut();
}
});

if(!mIsTablet) {
mPoweredBy.setGravity(Gravity.RIGHT);
} else {
TextView mDotSeparator = (TextView) view.findViewById(R.id.footer_dot_separator);
mDotSeparator.setVisibility(View.VISIBLE);
}
}

return view;
}
Expand Down Expand Up @@ -221,6 +244,14 @@ public void onSurveySubmit(int score, String text) {
priority++;
}

@Override
public void onHideOptOut() {
if (mSettings.isShowOptOut() && mBtnOptOut != null && !mIsTablet) {
mPoweredBy.setGravity(Gravity.CENTER);
mBtnOptOut.setVisibility(View.GONE);
}
}

@Override
public void onFacebookLikeBtnClick() {
if (mSocialHandler == null) return;
Expand Down Expand Up @@ -313,4 +344,19 @@ private void notifySurveyFinished() {
Integer resurvey_days = mResponseSent ? mSettings.getResurveyThrottle() : mSettings.getDeclineResurveyThrottle();
Wootric.notifySurveyFinished(true, mResponseSent, resurvey_days);
}


private void optOut() {
String optOutUrl = "https://app.wootric.com/opt_out?token=" + mUser.getAccountToken()
+ "&metric_type=" + mSettings.getSurveyType()
+ "&end_user_id=" + Long.toString(mEndUser.getId())
+ "&end_user_email=" + mEndUser.getEmail()
+ "&unique_link=" + mUniqueLink
+ "&opt_out_token=" + mAccessToken;

Intent optOut = new Intent(Intent.ACTION_VIEW, Uri.parse(optOutUrl));
startActivity(optOut);

dismiss();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ public interface SurveyLayoutListener extends ThankYouLayoutListener {
void onSurveySubmit(int score, String text);

void onDismissClick();

void onHideOptOut();
}
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,12 @@ private void dismissSurvey() {
}
}

private void hideOptOut() {
if(mSurveyLayoutListener != null) {
mSurveyLayoutListener.onHideOptOut();
}
}

private OnClickListener onEditScoreClick() {
return new OnClickListener() {
@Override
Expand Down Expand Up @@ -407,6 +413,7 @@ private void setupThankYouState() {
setViewsVisibility(mCommonSurveyViews, false);
setViewsVisibility(mFeedbackViews, false);
setViewsVisibility(mSurveyViews, false);
hideOptOut();
setKeyboardVisibility(false);

mThankYouLayout.setVisibility(VISIBLE);
Expand Down
11 changes: 11 additions & 0 deletions androidsdk/src/main/res/drawable/footer_dot_separator.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<solid
android:color="@android:color/black"
android:paddingTop="10dp"></solid>
<corners android:radius="50dp"></corners>

</shape>
20 changes: 20 additions & 0 deletions androidsdk/src/main/res/layout-sw600dp/wootric_footer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,24 @@
android:layout_height="wrap_content"
android:text="@string/wootric"
android:textColor="@color/wootric_survey_layout_header_background" />

<TextView
android:id="@+id/footer_dot_separator"
android:layout_width="@dimen/wootric_footer_layout_dot_separator_width"
android:layout_height="@dimen/wootric_footer_layout_dot_separator_height"
android:gravity="center"
android:layout_margin="@dimen/wootric_footer_layout_dot_separator_margin"
android:background="@drawable/footer_dot_separator"
android:alpha="0.3"
android:visibility="gone"/>

<TextView
android:id="@+id/wootric_btn_opt_out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/wootric_opt_out"
android:clickable="true"
android:textColor="@android:color/black"
android:alpha="0.3"
android:visibility="gone"/>
</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@
android:layout_margin="8dp"/>
</LinearLayout>

<include layout="@layout/wootric_footer"
<include android:id="@+id/wootric_footer"
layout="@layout/wootric_footer"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center"
Expand Down
36 changes: 29 additions & 7 deletions androidsdk/src/main/res/layout/wootric_footer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,43 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="center"
android:gravity="left"
android:padding="4dp"
android:layout_marginLeft="@dimen/wootric_footer_layout_margin_left"
android:layout_marginStart="@dimen/wootric_footer_layout_margin_start"
android:orientation="horizontal">

<TextView
android:id="@+id/wootric_btn_opt_out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/wootric_powered_by"
android:text="@string/wootric_opt_out"
android:textColor="@android:color/black"
android:alpha="0.3"/>
android:alpha="0.3"
android:visibility="gone"/>

<TextView
android:layout_width="wrap_content"
<LinearLayout
android:id="@+id/wootric_powered_by"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/wootric"
android:textColor="@color/wootric_brand_color" />
android:background="@android:color/white"
android:gravity="center"
android:layout_marginEnd="@dimen/wootric_footer_layout_margin_end"
android:layout_marginRight="@dimen/wootric_footer_layout_margin_right"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/wootric_powered_by"
android:textColor="@android:color/black"
android:alpha="0.3"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/wootric"
android:textColor="@color/wootric_brand_color" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
2 changes: 2 additions & 0 deletions androidsdk/src/main/res/layout/wootric_thank_you_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,14 @@
android:id="@+id/wootric_btn_thank_you_done"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/wootric_tv_thank_you"
android:layout_gravity="end"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textSize="@dimen/wootric_button_text"
android:textColor="@color/wootric_survey_layout_header_background"
android:padding="@dimen/wootric_btn_padding"
android:layout_marginTop="280dp"
android:text="@string/wootric_example_btn_dismiss"/>
</RelativeLayout>
9 changes: 9 additions & 0 deletions androidsdk/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,13 @@
<dimen name="wootric_social_text_size">18sp</dimen>
<dimen name="wootric_social_drawable_padding">8dp</dimen>
<dimen name="wootric_thank_you_action_button_margin">16dp</dimen>

<!-- Footer Layout -->
<dimen name="wootric_footer_layout_margin_left">24dp</dimen>
<dimen name="wootric_footer_layout_margin_right">24dp</dimen>
<dimen name="wootric_footer_layout_margin_start">24dp</dimen>
<dimen name="wootric_footer_layout_margin_end">24dp</dimen>
<dimen name="wootric_footer_layout_dot_separator_width">4dp</dimen>
<dimen name="wootric_footer_layout_dot_separator_height">4dp</dimen>
<dimen name="wootric_footer_layout_dot_separator_margin">8dp</dimen>
</resources>
1 change: 1 addition & 0 deletions androidsdk/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<string name="wootric_example_nps_question">How likely are you to recommend Wootric to a friend or coworker?</string>
<string name="wootric_example_anchor_not_likely">Not at all likely</string>
<string name="wootric_example_anchor_likely">Extremely likely</string>
<string name="wootric_opt_out">"opt out"</string>
<string name="wootric_powered_by">"Powered by "</string>
<string name="wootric">"Wootric"</string>
<string name="wootric_example_btn_dismiss">DISMISS</string>
Expand Down

0 comments on commit 9f2498f

Please sign in to comment.