Skip to content

Commit

Permalink
Add support for Footer in Landscape mode
Browse files Browse the repository at this point in the history
Changes
- Add support for Footer section in Landscape mode.
- Fix Wootric Sampling Rule property
- Add log message
- Fix opt-out button to retrieve text from server translations
- Change Enter button action on feedback screen to advance to next screen
  • Loading branch information
ambarwootric authored and diegoserranoa committed Jul 30, 2020
1 parent 1774dd7 commit e27b02d
Show file tree
Hide file tree
Showing 19 changed files with 95 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.DS_Store
/build
/projectfilesbackup
/bin
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 2.17.0 (2020-07-30)

- Add support to show Footer section in Landscape mode
- Fix Wootric Sampling Rule property
- Add log message
- Fix opt-out button to retrieve text from server translations
- Change Enter button action on feedback screen to advance to next screen

## 2.16.0 (2020-06-11)

- Add support for SamplingGroups
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.16.0</version>
<version>2.17.0</version>
</dependency>
```

### Using Gradle

```xml
compile 'com.wootric:wootric-sdk-android:2.16.0'
compile 'com.wootric:wootric-sdk-android:2.17.0'
```

## Initializing Wootric
Expand Down
2 changes: 1 addition & 1 deletion WootricSDK-Android.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="WootricSDK-Android" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<module external.linked.project.id="WootricSDK-Android" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
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.16.0
VERSION_CODE=2160
VERSION_NAME=2.17.0
VERSION_CODE=2170
GROUP=com.wootric

POM_DESCRIPTION=WootricSDK Android
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ public void survey(String eventName) {
* Starts the survey if configuration is correctly set and elibility returns true.
*/
public void survey() {
this.survey("");
this.survey(settings.getEventName());
}

public void showSurveyInActivity(Activity activity, String eventName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected void onSuccess(String response) {
JSONObject jsonObject = new JSONObject(response);

if (jsonObject.has("sampling_rule")) {
endUser.getProperties().put("Wootric sampling rule", jsonObject.getJSONObject("sampling_rule").getString("name"));
endUser.getProperties().put("Wootric Sampling Rule", jsonObject.getJSONObject("sampling_rule").getString("name"));
}

if (Utils.isNotEmpty(eventName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ public abstract class WootricRemoteRequestTask extends AsyncTask<Void, Void, Str

protected static final String API_ENDPOINT = "https://api.wootric.com";
protected static final String SURVEY_ENDPOINT = "https://survey.wootric.com";


protected static final String END_USERS_URL = API_ENDPOINT + "/v1/end_users";
protected static final String OAUTH_URL = API_ENDPOINT + "/oauth/token";
protected static final String ELIGIBLE_URL = SURVEY_ENDPOINT + "/eligible.json";
Expand Down Expand Up @@ -104,6 +102,7 @@ protected String doInBackground(Void... params) {
return readInput(is);

} catch (IOException e) {
Log.d("WOOTRIC_SDK", "Request failed with error: " + e.getMessage());
onError(e);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class LocalizedTexts implements Parcelable {
private String send;
private String dismiss;
private String editScore;
private String optOut;
private HashMap<String, String> socialShare;

public LocalizedTexts() {}
Expand All @@ -63,6 +64,7 @@ public LocalizedTexts(LocalizedTexts localizedTexts) {
this.send = localizedTexts.send;
this.dismiss = localizedTexts.dismiss;
this.editScore = localizedTexts.editScore;
this.optOut = localizedTexts.optOut;
this.socialShare = localizedTexts.socialShare;
}

Expand Down Expand Up @@ -102,6 +104,8 @@ public String getEditScore() {
return editScore;
}

public String getOptOut() {return optOut; }

public String getSocialShareQuestion() {
return socialShare.get(SOCIAL_SHARE_QUESTION_KEY);
}
Expand All @@ -125,6 +129,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.send);
dest.writeString(this.dismiss);
dest.writeString(this.editScore);
dest.writeString(this.optOut);
dest.writeSerializable(this.socialShare);
}

Expand All @@ -137,6 +142,7 @@ private LocalizedTexts(Parcel in) {
this.send = in.readString();
this.dismiss = in.readString();
this.editScore = in.readString();
this.optOut = in.readString();
this.socialShare = (HashMap<String, String>) in.readSerializable();
}

Expand Down Expand Up @@ -185,6 +191,7 @@ static LocalizedTexts fromJson(JSONObject localizedTextsJson, String surveyType)
localizedTexts.send = localizedTextsJson.optString("send");
localizedTexts.dismiss = localizedTextsJson.optString("dismiss");
localizedTexts.editScore = localizedTextsJson.optString("edit_score");
localizedTexts.optOut = localizedTextsJson.optString("opt_out_button");

JSONObject socialShareJson = localizedTextsJson.getJSONObject("social_share");
localizedTexts.socialShare = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ public String getBtnEditScore() {
return localizedTexts.getEditScore().toUpperCase();
}

public String getBtnOptOut() { return localizedTexts.getOptOut().toUpperCase(); }

public String getFollowupQuestion(int score) {
String followupQuestion = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

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

if (mSettings.isShowOptOut()) {
mBtnOptOut.setVisibility(View.VISIBLE);
Expand Down Expand Up @@ -212,7 +213,7 @@ private void measurePhoneDialog() {
lp.height = screenHeight*4/5;
lp.width = screenWidth;
} else {
lp.height = screenWidth;
lp.height = screenWidth*19/20;
lp.width = screenHeight*4/5;
}
} else {
Expand All @@ -226,7 +227,6 @@ private void measurePhoneDialog() {
}

window.setAttributes(lp);
mFooter.setVisibility(isPortraitMode ? View.VISIBLE : View.GONE);
}

private void setupState(Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.LinearLayout;
Expand Down Expand Up @@ -189,6 +191,17 @@ private void initFeedbackViewElements() {
etFeedbackBackground.setColorFilter(mColorBlack, PorterDuff.Mode.SRC_ATOP);
etFeedbackBackground.setAlpha(26);
mEtFeedback.setOnFocusChangeListener(onEtFeedbackFocusChanged());
mEtFeedback.setImeActionLabel(mSettings.getBtnSubmit(), KeyEvent.KEYCODE_ENTER);
mEtFeedback.setImeOptions(EditorInfo.IME_ACTION_DONE);
mEtFeedback.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View view, int keyCode, KeyEvent keyevent) {
if ((keyevent.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
submitSurvey();
return true;
}
return false;
}
});

mBtnEditScore = (TextView) findViewById(R.id.wootric_btn_edit_score);
mBtnEditScore.setOnClickListener(onEditScoreClick());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

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

if (mSettings.isShowOptOut()) {
mBtnOptOut.setVisibility(View.VISIBLE);
Expand Down Expand Up @@ -213,7 +214,7 @@ private void measurePhoneDialog() {
lp.height = screenHeight*4/5;
lp.width = screenWidth;
} else {
lp.height = screenWidth;
lp.height = screenWidth*19/20;
lp.width = screenHeight*4/5;
}
} else {
Expand All @@ -227,7 +228,6 @@ private void measurePhoneDialog() {
}

window.setAttributes(lp);
mFooter.setVisibility(isPortraitMode ? View.VISIBLE : View.GONE);
}

private void setupState(Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
Expand Down Expand Up @@ -137,6 +139,18 @@ private void init(Context context) {
mLayoutFollowup = (RelativeLayout) findViewById(R.id.wootric_layout_followup);
mTvFollowupQuestion = (TextView) mLayoutFollowup.findViewById(R.id.wootric_tv_followup);
mEtFeedback = (EditText) mLayoutFollowup.findViewById(R.id.wootric_et_feedback);
mEtFeedback.setImeOptions(EditorInfo.IME_ACTION_DONE);
mEtFeedback.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View view, int keyCode, KeyEvent keyevent) {
if ((keyevent.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
submitSurvey();
return true;
}
return false;
}
});


mBtnSubmit = (Button) mLayoutFollowup.findViewById(R.id.wootric_btn_submit);
mBtnSubmit.setOnClickListener(new OnClickListener() {
@Override
Expand Down Expand Up @@ -261,6 +275,7 @@ private void setTexts() {
mTvAnchorLikely.setText(mSettings.getAnchorLikely());
mTvAnchorNotLikely.setText(mSettings.getAnchorNotLikely());
mBtnSubmit.setText(mSettings.getBtnSubmit());
mEtFeedback.setImeActionLabel(mSettings.getBtnSubmit(), KeyEvent.KEYCODE_ENTER);
}
}

Expand Down
2 changes: 2 additions & 0 deletions androidsdk/src/main/res/layout-sw600dp/wootric_nps_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
android:textCursorDrawable="@drawable/wootric_tablet_feedback_cursor"
android:textColor="#78000000"
android:background="@null"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="16dp"
android:textSize="14sp"
android:maxLines="2"
Expand Down
63 changes: 32 additions & 31 deletions androidsdk/src/main/res/layout/wootric_survey_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,39 @@
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/wootric_btn_edit_score"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/wootric_survey_layout_header_background"
android:drawableLeft="@drawable/ic_wootric_left_arrow"
android:drawableStart="@drawable/ic_wootric_left_arrow"
android:drawablePadding="@dimen/wootric_edit_button_drawable_padding"
android:paddingStart="@dimen/wootric_edit_button_padding_left"
android:gravity="center_vertical"
android:includeFontPadding="false"
android:paddingLeft="@dimen/wootric_edit_button_padding_left"
android:paddingTop="@dimen/wootric_edit_button_padding_top"
android:text="@string/wootric_example_btn_edit_score"
android:textColor="@color/edit_score_color"
android:textSize="@dimen/wootric_button_text" />
<TextView
android:id="@+id/wootric_btn_edit_score"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/wootric_survey_layout_header_background"
android:drawableLeft="@drawable/ic_wootric_left_arrow"
android:drawableStart="@drawable/ic_wootric_left_arrow"
android:drawablePadding="@dimen/wootric_edit_button_drawable_padding"
android:paddingStart="@dimen/wootric_edit_button_padding_left"
android:gravity="center_vertical"
android:includeFontPadding="false"
android:paddingLeft="@dimen/wootric_edit_button_padding_left"
android:paddingTop="@dimen/wootric_edit_button_padding_top"
android:text="@string/wootric_example_btn_edit_score"
android:textColor="@color/edit_score_color"
android:textSize="@dimen/wootric_button_text" />

<TextView
android:id="@+id/wootric_survey_layout_tv_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/wootric_survey_layout_header_background"
android:padding="@dimen/wootric_survey_layout_header_padding"
android:text="@string/wootric_example_nps_question"
android:textColor="@android:color/white"
android:textSize="@dimen/wootric_survey_layout_header_text_size" />
</LinearLayout>
<TextView
android:id="@+id/wootric_survey_layout_tv_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/wootric_survey_layout_header_background"
android:padding="@dimen/wootric_survey_layout_header_padding"
android:text="@string/wootric_example_nps_question"
android:textColor="@android:color/white"
android:textSize="@dimen/wootric_survey_layout_header_text_size" />
</LinearLayout>

<com.wootric.androidsdk.views.phone.ThankYouLayout
android:id="@+id/wootric_thank_you_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<com.wootric.androidsdk.views.phone.ThankYouLayout
android:id="@+id/wootric_thank_you_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/wootric_survey_layout_body"
Expand Down Expand Up @@ -133,6 +133,7 @@
android:layout_marginTop="@dimen/wootric_et_feedback_margin_top"
android:hint="@string/wootric_example_followup_placeholder"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLines="1"
android:nextFocusLeft="@id/wootric_et_feedback"
android:nextFocusUp="@id/wootric_et_feedback"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public void showSurvey(View view) {
}

private void startSurvey() {

Wootric wootric = Wootric.init(this, ACCOUNT_TOKEN);
wootric.setEndUserEmail("[email protected]");
wootric.setSurveyImmediately(true);
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.github.dcendents:android-maven-plugin:1.2'

// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Feb 27 18:28:46 ECT 2020
#Wed Jul 22 15:06:10 NPT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

0 comments on commit e27b02d

Please sign in to comment.