diff --git a/CHANGELOG.md b/CHANGELOG.md
index d70bafa..8017f0e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 2.27.0 (2024-07-17)
+
+- Add survey customizations
+
## 2.26.1 (2024-03-01)
- Fix disclaimer's TextView gravity for ReactNative & Flutter
diff --git a/README.md b/README.md
index 58b1e06..234a0b9 100644
--- a/README.md
+++ b/README.md
@@ -28,14 +28,14 @@ If you use Maven, you can include this library as a dependency:
com.wootric
wootric-sdk-android
- 2.26.1
+ 2.27.0
```
### Using Gradle
```xml
-implementation 'com.wootric:wootric-sdk-android:2.26.1'
+implementation 'com.wootric:wootric-sdk-android:2.27.0'
```
## Initializing Wootric
diff --git a/androidsdk/gradle.properties b/androidsdk/gradle.properties
index c37edcb..a019c7c 100644
--- a/androidsdk/gradle.properties
+++ b/androidsdk/gradle.properties
@@ -1,5 +1,5 @@
-VERSION_NAME=2.26.1
-VERSION_CODE=2261
+VERSION_NAME=2.27.0
+VERSION_CODE=2270
GROUP=com.wootric
POM_DESCRIPTION=WootricSDK Android
diff --git a/androidsdk/src/main/java/com/wootric/androidsdk/objects/Settings.java b/androidsdk/src/main/java/com/wootric/androidsdk/objects/Settings.java
index 04caf77..21239f5 100644
--- a/androidsdk/src/main/java/com/wootric/androidsdk/objects/Settings.java
+++ b/androidsdk/src/main/java/com/wootric/androidsdk/objects/Settings.java
@@ -53,6 +53,8 @@ public class Settings implements Parcelable {
private WootricSocial adminPanelSocial;
private WootricSocial localSocial;
+ private WootricCustomColor adminPanelCustomColors;
+
private WootricCustomThankYou localCustomThankYou;
private WootricCustomThankYou adminPanelCustomThankYou;
@@ -87,6 +89,8 @@ public class Settings implements Parcelable {
private int socialSharingColor = Constants.NOT_SET;
private int surveyTypeScale = 0;
+ private String scoreScaleType = "filled";
+
private String clientID;
private String accountToken;
@@ -105,6 +109,7 @@ public Settings(Settings settings) {
this.localCustomMessage = new WootricCustomMessage(settings.getLocalCustomMessage());
this.adminPanelSocial = new WootricSocial(settings.adminPanelSocial);
this.localSocial = new WootricSocial(settings.localSocial);
+ this.adminPanelCustomColors = new WootricCustomColor(settings.adminPanelCustomColors);
this.localCustomThankYou = new WootricCustomThankYou(settings.localCustomThankYou);
this.adminPanelCustomThankYou = new WootricCustomThankYou(settings.adminPanelCustomThankYou);
this.timeDelay = settings.timeDelay;
@@ -151,6 +156,7 @@ public void mergeWithSurveyServerSettings(Settings settings) {
this.adminPanelTimeDelay = settings.adminPanelTimeDelay;
this.adminPanelCustomThankYou = settings.adminPanelCustomThankYou;
this.adminPanelSocial = settings.adminPanelSocial;
+ this.adminPanelCustomColors = settings.adminPanelCustomColors;
this.driverPicklist = settings.driverPicklist;
this.localizedTexts = settings.localizedTexts;
this.userID = settings.userID;
@@ -725,6 +731,8 @@ public void setCustomSurveyTypeScale(int customSurveyTypeScale) {
public int getSurveyColor() {
if (surveyColor != Constants.NOT_SET){
return surveyColor;
+ } else if (adminPanelCustomColors != null && adminPanelCustomColors.getCustomPrimaryColor() != Constants.NOT_SET) {
+ return adminPanelCustomColors.getCustomPrimaryColor();
}
return R.color.wootric_survey_layout_header_background;
}
@@ -736,6 +744,8 @@ public void setSurveyColor(int surveyColor) {
public int getScoreColor() {
if (scoreColor != Constants.NOT_SET){
return scoreColor;
+ } else if (adminPanelCustomColors != null && adminPanelCustomColors.getCustomSecondaryColor() != Constants.NOT_SET) {
+ return adminPanelCustomColors.getCustomSecondaryColor();
}
return R.color.wootric_score_color;
}
@@ -744,6 +754,13 @@ public void setScoreColor(int scoreColor) {
this.scoreColor = scoreColor;
}
+ public String getScoreScaleType() {
+ if (adminPanelCustomColors != null && this.adminPanelCustomColors.getCustomScoreScaleType() != "") {
+ return this.adminPanelCustomColors.getCustomScoreScaleType();
+ }
+ return "unfilled";
+ }
+
public void setDisclaimer(String disclaimerText, Uri disclaimerLinkURL, String disclaimerLinkText) {
if (isBlank(disclaimerText)) {
Log.w(Constants.TAG, "setDisclaimer - disclaimerText cannot be blank.");
@@ -765,6 +782,8 @@ public void setDisclaimer(String disclaimerText, Uri disclaimerLinkURL, String d
public int getThankYouButtonBackgroundColor () {
if (thankYouButtonBackgroundColor != Constants.NOT_SET) {
return thankYouButtonBackgroundColor;
+ } else if (adminPanelCustomColors != null && adminPanelCustomColors.getCustomSecondaryColor() != Constants.NOT_SET) {
+ return adminPanelCustomColors.getCustomSecondaryColor();
}
return R.color.wootric_score_color;
}
@@ -776,6 +795,8 @@ public void setThankYouButtonBackgroundColor (int thankYouButtonBackgroundColor)
public int getSocialSharingColor () {
if (socialSharingColor != Constants.NOT_SET) {
return socialSharingColor;
+ } else if (adminPanelCustomColors != null && adminPanelCustomColors.getCustomSecondaryColor() != Constants.NOT_SET) {
+ return adminPanelCustomColors.getCustomSecondaryColor();
}
return R.color.wootric_social;
}
@@ -784,6 +805,13 @@ public void setSocialSharingColor (int socialSharingColor) {
this.socialSharingColor = socialSharingColor;
}
+ public int getDriverPicklistColor () {
+ if (adminPanelCustomColors != null && adminPanelCustomColors.getCustomSecondaryColor() != Constants.NOT_SET) {
+ return adminPanelCustomColors.getCustomSecondaryColor();
+ }
+ return R.color.wootric_score_color;
+ }
+
public String getAccountToken() {
return this.accountToken;
}
@@ -826,6 +854,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(this.adminPanelCustomThankYou, 0);
dest.writeParcelable(this.localSocial, 0);
dest.writeParcelable(this.adminPanelSocial, 0);
+ dest.writeParcelable(this.adminPanelCustomColors, 0);
dest.writeString(this.accountToken);
dest.writeString(this.clientID);
dest.writeByte(this.showDisclaimer ? (byte) 1 : (byte) 0);
@@ -862,6 +891,7 @@ private Settings(Parcel in) {
this.adminPanelCustomThankYou = in.readParcelable(WootricCustomThankYou.class.getClassLoader());
this.localSocial = in.readParcelable(WootricSocial.class.getClassLoader());
this.adminPanelSocial = in.readParcelable(WootricSocial.class.getClassLoader());
+ this.adminPanelCustomColors = in.readParcelable(WootricCustomColor.class.getClassLoader());
this.accountToken = in.readString();
this.clientID = in.readString();
this.showDisclaimer = in.readByte() != 0;
@@ -932,6 +962,9 @@ public static Settings fromJson(JSONObject settingsObject) throws JSONException
JSONObject socialJson = settingsObject.optJSONObject("social");
settings.adminPanelSocial = WootricSocial.fromJson(socialJson);
+ JSONObject customColorsJson = settingsObject.optJSONObject("custom_colors");
+ settings.adminPanelCustomColors = WootricCustomColor.fromJson(customColorsJson);
+
return settings;
}
}
diff --git a/androidsdk/src/main/java/com/wootric/androidsdk/objects/WootricCustomColor.java b/androidsdk/src/main/java/com/wootric/androidsdk/objects/WootricCustomColor.java
new file mode 100644
index 0000000..acefa6a
--- /dev/null
+++ b/androidsdk/src/main/java/com/wootric/androidsdk/objects/WootricCustomColor.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2024 Wootric (https://wootric.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package com.wootric.androidsdk.objects;
+
+import android.graphics.Color;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Log;
+
+import com.wootric.androidsdk.utils.Utils;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ * Created by diegoserranoa on 3/28/24.
+ */
+public class WootricCustomColor implements Parcelable {
+ private static final String CUSTOM_PRIMARY_COLOR_KEY = "custom_primary_color";
+ private static final String CUSTOM_SECONDARY_COLOR_KEY = "custom_secondary_color";
+ private static final String SCORE_SCALE_TYPE_KEY = "score_scale_type";
+ private String customPrimaryColor;
+ private String customSecondaryColor;
+ private String customScoreScaleType;
+
+ public WootricCustomColor() {}
+
+ public WootricCustomColor(WootricCustomColor wootricCustomColor) {
+ if (wootricCustomColor == null) return;
+ this.customPrimaryColor = wootricCustomColor.customPrimaryColor;
+ this.customSecondaryColor = wootricCustomColor.customSecondaryColor;
+ this.customScoreScaleType = wootricCustomColor.customScoreScaleType;
+ }
+
+ public int getCustomPrimaryColor() {
+ if (this.customPrimaryColor != "null") {
+ try {
+ return Color.parseColor(this.customPrimaryColor);
+ } catch (IllegalArgumentException ex) {
+ return Color.parseColor("#253746");
+ }
+ }
+ return Color.parseColor("#253746");
+ }
+
+ public int getCustomSecondaryColor() {
+ if (Utils.isNotEmpty(this.customSecondaryColor) && this.customSecondaryColor != "null") {
+ try {
+ return Color.parseColor(this.customSecondaryColor);
+ } catch (IllegalArgumentException ex) {
+ return Color.parseColor("#B3CDFF");
+ }
+ }
+ return Color.parseColor("#B3CDFF");
+ }
+
+ public String getCustomScoreScaleType() {
+ return customScoreScaleType;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(this.customPrimaryColor);
+ dest.writeString(this.customSecondaryColor);
+ dest.writeString(this.customScoreScaleType);
+ }
+
+ private WootricCustomColor(Parcel in) {
+ this.customPrimaryColor = in.readString();
+ this.customSecondaryColor = in.readString();
+ this.customScoreScaleType = in.readString();
+ }
+
+ public static final Creator CREATOR = new Creator() {
+ public WootricCustomColor createFromParcel(Parcel source) {
+ return new WootricCustomColor(source);
+ }
+ public WootricCustomColor[] newArray(int size) {
+ return new WootricCustomColor[size];
+ }
+ };
+
+ public static WootricCustomColor fromJson(JSONObject customColorsJson) throws JSONException {
+ if(customColorsJson == null) return null;
+
+ WootricCustomColor wootricCustomColor = new WootricCustomColor();
+ wootricCustomColor.customPrimaryColor = customColorsJson.optString(CUSTOM_PRIMARY_COLOR_KEY);
+ wootricCustomColor.customSecondaryColor = customColorsJson.optString(CUSTOM_SECONDARY_COLOR_KEY);
+ wootricCustomColor.customScoreScaleType = customColorsJson.optString(SCORE_SCALE_TYPE_KEY);
+
+ return wootricCustomColor;
+ }
+}
diff --git a/androidsdk/src/main/java/com/wootric/androidsdk/utils/Utils.java b/androidsdk/src/main/java/com/wootric/androidsdk/utils/Utils.java
index 380a174..18abe01 100644
--- a/androidsdk/src/main/java/com/wootric/androidsdk/utils/Utils.java
+++ b/androidsdk/src/main/java/com/wootric/androidsdk/utils/Utils.java
@@ -27,9 +27,12 @@
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ClickableSpan;
+import android.graphics.Color;
import android.util.Log;
import android.view.View;
+import androidx.core.graphics.ColorUtils;
+
import com.wootric.androidsdk.Constants;
import java.util.Date;
@@ -95,4 +98,53 @@ public static SpannableString getSpannableString(ClickableSpan clickableSpan, St
ss.setSpan(clickableSpan, disclaimerText.length() + 1, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
return ss;
}
+
+ public static int getDarkerColor(int color, float percentage) {
+ return ColorUtils.blendARGB(color, Color.BLACK, percentage);
+ }
+
+ public static int getLighterColor(int color, float percentage) {
+ return ColorUtils.blendARGB(color, Color.WHITE, percentage);
+ }
+
+ private static int fontColor(String color) {
+ int num = Integer.parseInt(color.substring(1, 7), 16);
+ int red = (num >> 16) & 0xFF;
+ int green = (num >> 8) & 0xFF;
+ int blue = num & 0xFF;
+ double alpha = color.length() > 7 ? Integer.parseInt(color.substring(7, 9), 16) / 255.0 : 1;
+
+ red = (int) Math.round((1 - alpha) * 255 + alpha * red);
+ green = (int) Math.round((1 - alpha) * 255 + alpha * green);
+ blue = (int) Math.round((1 - alpha) * 255 + alpha * blue);
+
+ double yiq = ((red * 299) + (green * 587) + (blue * 114)) / 1000.0;
+ return yiq >= 128 ? Color.BLACK : Color.WHITE;
+ }
+
+ private static int fontColor(int color) {
+ int num = color;
+ int red = (num >> 16) & 0xFF;
+ int green = (num >> 8) & 0xFF;
+ int blue = num & 0xFF;
+ double alpha = 1;
+
+ red = (int) Math.round((1 - alpha) * 255 + alpha * red);
+ green = (int) Math.round((1 - alpha) * 255 + alpha * green);
+ blue = (int) Math.round((1 - alpha) * 255 + alpha * blue);
+
+ double yiq = ((red * 299) + (green * 587) + (blue * 114)) / 1000.0;
+ return yiq >= 128 ? Color.BLACK : Color.WHITE;
+ }
+
+ public static int getTextColor(int color, String scoreScaleType, boolean isSelected) {
+ if (isSelected || scoreScaleType.equals("filled")) {
+ if (color != 0) {
+ return fontColor(color);
+ } else {
+ return fontColor("#253746");
+ }
+ }
+ return Color.BLACK;
+ }
}
diff --git a/androidsdk/src/main/java/com/wootric/androidsdk/views/phone/SurveyLayoutPhone.java b/androidsdk/src/main/java/com/wootric/androidsdk/views/phone/SurveyLayoutPhone.java
index 2bf6dcd..06d67a3 100644
--- a/androidsdk/src/main/java/com/wootric/androidsdk/views/phone/SurveyLayoutPhone.java
+++ b/androidsdk/src/main/java/com/wootric/androidsdk/views/phone/SurveyLayoutPhone.java
@@ -25,13 +25,20 @@
import static com.wootric.androidsdk.utils.ScreenUtils.setViewsVisibility;
import android.content.Context;
+import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffColorFilter;
import android.graphics.Typeface;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
+import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent;
@@ -44,12 +51,15 @@
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
+import androidx.core.content.ContextCompat;
+import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.widget.TextViewCompat;
import com.wootric.androidsdk.R;
import com.wootric.androidsdk.objects.Score;
import com.wootric.androidsdk.objects.Settings;
import com.wootric.androidsdk.utils.ScreenUtils;
+import com.wootric.androidsdk.utils.Utils;
import com.wootric.androidsdk.views.SurveyLayout;
import com.wootric.androidsdk.views.SurveyLayoutListener;
import com.wootric.androidsdk.views.ThankYouLayoutListener;
@@ -177,9 +187,9 @@ private void initViews() {
new DriverPicklist.Configure()
.driverPicklist(mDriverPicklist)
.selectedColor(mColorSelected)
- .selectedFontColor(Color.parseColor("#ffffff"))
+ .selectedFontColor(Utils.getTextColor(mColorSelected, mSettings.getScoreScaleType(), true))
.deselectedColor(Color.parseColor("#ffffff"))
- .deselectedFontColor(Color.parseColor("#253746"))
+ .deselectedFontColor(Utils.getTextColor(mColorSelected, mSettings.getScoreScaleType(), false))
.selectTransitionMS(100)
.deselectTransitionMS(100)
.labels(null)
@@ -240,6 +250,8 @@ private void initFeedbackViewElements() {
mEtFeedback = (EditText) mLayoutBody.findViewById(R.id.wootric_et_feedback);
mEtFeedback.setImeActionLabel(mSettings.getBtnSubmit(), KeyEvent.KEYCODE_ENTER);
mEtFeedback.setImeOptions(EditorInfo.IME_ACTION_DONE);
+ Drawable background = mEtFeedback.getBackground();
+ background.setColorFilter(new PorterDuffColorFilter(mSettings.getSurveyColor(), PorterDuff.Mode.SRC_IN));
mEtFeedback.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View view, int keyCode, KeyEvent keyevent) {
if ((keyevent.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
@@ -400,7 +412,9 @@ private void setTexts() {
mAnchorLikely.setText(mSettings.getAnchorLikely());
mAnchorNotLikely.setText(mSettings.getAnchorNotLikely());
mBtnSubmit.setText(mSettings.getBtnSubmit());
+ mBtnSubmit.setPaintFlags(mBtnSubmit.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
mBtnDismiss.setText(mSettings.getBtnDismiss());
+ mBtnDismiss.setPaintFlags(mBtnDismiss.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
mBtnEditScore.setText(mSettings.getBtnEditScore());
mEtFeedback.setHint(mSettings.getFollowupPlaceholder(mRatingBar.getSelectedScore()));
}
@@ -408,9 +422,25 @@ private void setTexts() {
private void setColors() {
mRatingBar.setSelectedColor(mColorSelected);
- mBtnDismiss.setTextColor(mColorEnabled);
+ mBtnDismiss.setTextColor(Color.BLACK);
+ mBtnEditScore.setTextColor(Utils.getTextColor(mColorEnabled, "filled", true));
mBtnEditScore.setBackgroundColor(mColorEnabled);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ for (Drawable drawable : mBtnEditScore.getCompoundDrawablesRelative()) {
+ if (drawable != null) {
+ drawable.setColorFilter(new PorterDuffColorFilter(Utils.getTextColor(mColorEnabled, "filled", true), PorterDuff.Mode.SRC_IN));
+ }
+ }
+ } else {
+ for (Drawable drawable : mBtnEditScore.getCompoundDrawables()) {
+ if (drawable != null) {
+ drawable.setColorFilter(new PorterDuffColorFilter(Utils.getTextColor(mColorEnabled, "filled", true), PorterDuff.Mode.SRC_IN));
+ }
+ }
+ }
+
mTvSurveyHeader.setBackgroundColor(mColorEnabled);
+ mTvSurveyHeader.setTextColor(Utils.getTextColor(mColorEnabled, "filled", true));
}
private void updateState(int state) {
@@ -506,7 +536,7 @@ private void setupThankYouState() {
}
private void updateSubmitBtn(boolean enable) {
- mBtnSubmit.setTextColor(enable ? mColorEnabled : mColorBlack);
+ mBtnSubmit.setTextColor(mColorBlack);
mBtnSubmit.setAlpha(enable ? 1f : 0.26f);
mBtnSubmit.setEnabled(enable);
}
diff --git a/androidsdk/src/main/java/com/wootric/androidsdk/views/phone/ThankYouDialogFactory.java b/androidsdk/src/main/java/com/wootric/androidsdk/views/phone/ThankYouDialogFactory.java
index 5f05f43..9b12b2e 100644
--- a/androidsdk/src/main/java/com/wootric/androidsdk/views/phone/ThankYouDialogFactory.java
+++ b/androidsdk/src/main/java/com/wootric/androidsdk/views/phone/ThankYouDialogFactory.java
@@ -27,7 +27,10 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.ColorStateList;
+import android.graphics.Color;
+import android.graphics.Paint;
import android.os.Build;
+import android.widget.Button;
import com.wootric.androidsdk.WootricSurveyCallback;
import com.wootric.androidsdk.objects.Settings;
@@ -51,7 +54,7 @@ public static Dialog create(final Context context, final Settings settings, fina
thankYouDialog.setMessage(thankYouText);
thankYouDialog.setCanceledOnTouchOutside(true);
- thankYouDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "OK", new DialogInterface.OnClickListener() {
+ thankYouDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "dismiss", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
@@ -74,16 +77,11 @@ public void onClick(DialogInterface dialog, int which) {
thankYouDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
- int thankYouBackgroundColor;
- try {
- thankYouBackgroundColor = context.getResources().getColor(settings.getThankYouButtonBackgroundColor());
- } catch(Exception e) {
- thankYouBackgroundColor = settings.getThankYouButtonBackgroundColor();
- }
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- ColorStateList csl = ColorStateList.valueOf(thankYouBackgroundColor);
- thankYouDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(csl);
+ ColorStateList csl = ColorStateList.valueOf(Color.BLACK);
+ Button dismissButton = thankYouDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
+ dismissButton.setTextColor(csl);
+ dismissButton.setPaintFlags(dismissButton.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
}
}
});
diff --git a/androidsdk/src/main/java/com/wootric/androidsdk/views/phone/ThankYouLayout.java b/androidsdk/src/main/java/com/wootric/androidsdk/views/phone/ThankYouLayout.java
index 18d990a..a9ebaaf 100644
--- a/androidsdk/src/main/java/com/wootric/androidsdk/views/phone/ThankYouLayout.java
+++ b/androidsdk/src/main/java/com/wootric/androidsdk/views/phone/ThankYouLayout.java
@@ -24,9 +24,13 @@
import android.content.Context;
import android.content.res.ColorStateList;
+import android.graphics.Color;
+import android.graphics.Paint;
import android.graphics.Typeface;
+import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.util.AttributeSet;
+import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
@@ -39,14 +43,15 @@
import com.wootric.androidsdk.objects.Settings;
import com.wootric.androidsdk.utils.FontManager;
import com.wootric.androidsdk.utils.ScreenUtils;
+import com.wootric.androidsdk.utils.Utils;
import com.wootric.androidsdk.views.ThankYouLayoutListener;
/**
* Created by maciejwitowski on 9/18/15.
*/
-public class ThankYouLayout extends RelativeLayout {
+public class ThankYouLayout extends LinearLayout {
- private RelativeLayout mLayoutBody;
+ private LinearLayout mLayoutBody;
private LinearLayout mLayoutFacebookLike;
private LinearLayout mLayoutFacebook;
@@ -90,7 +95,7 @@ private void init(Context context) {
Typeface iconFont = FontManager.getTypeface(context, FontManager.FONTAWESOME);
- mLayoutBody = (RelativeLayout) findViewById(R.id.wootric_thank_you_layout_body);
+ mLayoutBody = (LinearLayout) findViewById(R.id.wootric_thank_you_layout_body);
mTvThankYou = (TextView) mLayoutBody.findViewById(R.id.wootric_tv_thank_you);
mTvThankYouSetup = (TextView) mLayoutBody.findViewById(R.id.wootric_tv_thank_you_setup);
mFaFacebookLike = (TextView) mLayoutBody.findViewById(R.id.wootric_fa_facebook_like);
@@ -205,8 +210,9 @@ private void initValues() {
mTvThankYouSetup.setText(thankYouSetupText);
}
- mBtnDone.setTextColor(buttonColor);
+ mBtnDone.setTextColor(Color.BLACK);
mBtnDone.setText(mSettings.getBtnDismiss());
+ mBtnDone.setPaintFlags(mBtnDone.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
initSocialLinks();
initThankYouActionBtn();
@@ -224,8 +230,10 @@ private void initThankYouActionBtn() {
} catch(Exception e) {
thankYouBackgroundColor = mSettings.getThankYouButtonBackgroundColor();
}
+
mBtnThankYouAction.setVisibility(shouldShowThankYouAction ? VISIBLE : GONE);
mBtnThankYouAction.setText(thankYouLinkText);
+ mBtnThankYouAction.setTextColor(Utils.getTextColor(thankYouBackgroundColor, "filled", false));
mBtnThankYouAction.setBackgroundColor(thankYouBackgroundColor);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ColorStateList csl = ColorStateList.valueOf(thankYouBackgroundColor);
diff --git a/androidsdk/src/main/java/com/wootric/androidsdk/views/tablet/ScoreView.java b/androidsdk/src/main/java/com/wootric/androidsdk/views/tablet/ScoreView.java
index 204926a..166e4fe 100644
--- a/androidsdk/src/main/java/com/wootric/androidsdk/views/tablet/ScoreView.java
+++ b/androidsdk/src/main/java/com/wootric/androidsdk/views/tablet/ScoreView.java
@@ -24,11 +24,14 @@
import android.content.Context;
import android.content.res.Resources;
+import android.graphics.Color;
+import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
+import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;
@@ -36,6 +39,7 @@
import com.wootric.androidsdk.R;
import com.wootric.androidsdk.utils.ScreenUtils;
+import com.wootric.androidsdk.utils.Utils;
/**
* Created by maciejwitowski on 10/8/15.
@@ -43,11 +47,15 @@
public class ScoreView extends TextView implements View.OnClickListener{
private int mTextColor;
+ private int mBackgroundColor;
+ private String mScoreScaleType;
private OnScoreClickListener onScoreClickListener;
- public ScoreView(Context context) {
+ public ScoreView(Context context, int color, String scoreScaleType) {
super(context);
+ mBackgroundColor = color;
+ mScoreScaleType = scoreScaleType;
init();
}
@@ -67,7 +75,7 @@ private void init() {
final Context context = getContext();
final Resources res = context.getResources();
- mTextColor = res.getColor(R.color.wootric_tablet_text_score_color);
+ mTextColor = Utils.getTextColor(mBackgroundColor, mScoreScaleType, false);
final Resources resources = getResources();
Drawable drawable;
@@ -78,6 +86,9 @@ private void init() {
drawable = resources.getDrawable(R.drawable.score);
}
+ if (mScoreScaleType.equals("filled")) {
+ drawable.setColorFilter(mBackgroundColor, PorterDuff.Mode.MULTIPLY);
+ }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
setBackground(drawable);
}
@@ -98,6 +109,7 @@ private void init() {
llp.setMargins(margin, 0, 0, 0);
setLayoutParams(llp);
+ setTextColor(mTextColor);
setOnClickListener(this);
}
@@ -114,8 +126,27 @@ public void onClick(View v) {
@Override
public void setSelected(boolean selected) {
super.setSelected(selected);
+ final Resources resources = getResources();
+ Drawable drawable;
+
+ if (selected) {
+ mTextColor = Utils.getTextColor(mBackgroundColor, mScoreScaleType, selected);
+ } else {
+ mTextColor = Color.BLACK;
+ }
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ drawable = resources.getDrawable(R.drawable.score, null);
+ } else {
+ drawable = resources.getDrawable(R.drawable.score);
+ }
+ drawable.setColorFilter(mBackgroundColor, PorterDuff.Mode.MULTIPLY);
+ if (!isSelected()) {
+ drawable.setColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY);
+ }
+ setBackground(drawable);
setTypeface(null, isSelected() ? Typeface.BOLD : Typeface.NORMAL);
+ setTextColor(mTextColor);
}
public void setOnScoreClickListener(OnScoreClickListener onScoreClickListener) {
diff --git a/androidsdk/src/main/java/com/wootric/androidsdk/views/tablet/SurveyLayoutTablet.java b/androidsdk/src/main/java/com/wootric/androidsdk/views/tablet/SurveyLayoutTablet.java
index 95f7ca6..93d7dfa 100644
--- a/androidsdk/src/main/java/com/wootric/androidsdk/views/tablet/SurveyLayoutTablet.java
+++ b/androidsdk/src/main/java/com/wootric/androidsdk/views/tablet/SurveyLayoutTablet.java
@@ -27,10 +27,16 @@
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
+import android.graphics.PorterDuff;
import android.graphics.Typeface;
+import android.graphics.drawable.GradientDrawable;
+import android.graphics.drawable.ShapeDrawable;
+import android.graphics.drawable.shapes.RectShape;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
+import android.util.Log;
+import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
@@ -48,6 +54,7 @@
import com.wootric.androidsdk.objects.Settings;
import com.wootric.androidsdk.utils.FontManager;
import com.wootric.androidsdk.utils.ScreenUtils;
+import com.wootric.androidsdk.utils.Utils;
import com.wootric.androidsdk.views.SurveyLayout;
import com.wootric.androidsdk.views.SurveyLayoutListener;
import com.wootric.androidsdk.views.ThankYouLayoutListener;
@@ -91,6 +98,9 @@ public class SurveyLayoutTablet extends LinearLayout
private Button mBtnSubmit;
private Button mBtnSubmit2;
private TextView mBtnDismiss;
+
+ private int mPrimaryColor;
+ private int mSecondaryColor;
private DriverPicklist mDriverPicklist;
private RelativeLayout mThankYouLayout;
@@ -115,6 +125,7 @@ public class SurveyLayoutTablet extends LinearLayout
private String mSurveyType;
private int mScaleMinimum;
private int mScaleMaximum;
+ private int mDriverPicklistColor;
private Score mScore;
private int mScoresTop;
@@ -265,24 +276,40 @@ public void onClick(View v) {
setPadding(CONTAINER_PADDING, CONTAINER_PADDING, CONTAINER_PADDING, CONTAINER_PADDING);
- initScoreLayout();
updateState(mCurrentState);
}
private void initResources() {
final Resources res = getResources();
-
mScaleMinimum = mSurveyType == null ? 0 : mScore.minimumScore();
mScaleMaximum = mSurveyType == null ? 10 : mScore.maximumScore();
mScoresTop = mScaleMaximum + 1;
+ try {
+ mPrimaryColor = res.getColor(mSettings.getSurveyColor());
+ mSecondaryColor = res.getColor(mSettings.getScoreColor());
+ } catch(Exception e) {
+ mPrimaryColor = mSettings.getSurveyColor();
+ mSecondaryColor = mSettings.getScoreColor();
+ }
+
+ mBtnFacebookLike.setTextColor(mSecondaryColor);
+ mBtnTwitter.setTextColor(mSecondaryColor);
+ mBtnFacebook.setTextColor(mSecondaryColor);
+ mBtnThankYouAction.setTextColor(Utils.getTextColor(mSecondaryColor, "filled", false));
+ GradientDrawable drawable = (GradientDrawable)mBtnThankYouAction.getBackground();
+ drawable.mutate();
+ int stroke = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
+ drawable.setStroke(stroke, Utils.getDarkerColor(mSecondaryColor, 0.2f));
+ drawable.setColor(mSecondaryColor);
+
new DriverPicklist.Configure()
.driverPicklist(mDriverPicklist)
- .selectedColor(Color.parseColor("#024ea9"))
- .selectedFontColor(Color.parseColor("#ffffff"))
+ .selectedColor(mPrimaryColor)
+ .selectedFontColor(Utils.getTextColor(mPrimaryColor, mSettings.getScoreScaleType(), true))
.deselectedColor(Color.parseColor("#ffffff"))
- .deselectedFontColor(Color.parseColor("#253746"))
+ .deselectedFontColor(Utils.getTextColor(mPrimaryColor, mSettings.getScoreScaleType(), false))
.selectTransitionMS(100)
.deselectTransitionMS(100)
.labels(null)
@@ -308,7 +335,7 @@ private void initScoreLayout() {
mScoreViews = new ScoreView[mScoresTop];
for(int score = mScaleMinimum; score < mScoresTop; score++) {
- ScoreView scoreView = new ScoreView(mContext);
+ ScoreView scoreView = new ScoreView(mContext, mPrimaryColor, mSettings.getScoreScaleType());
scoreView.setText(String.valueOf(score));
scoreView.setOnScoreClickListener(this);
mScoreViews[score] = scoreView;
@@ -338,6 +365,7 @@ public void initWithSettings(Settings settings, String email) {
initScoreLayout();
updateState(mCurrentState);
setTexts();
+ setColors();
}
private void setTexts() {
@@ -351,6 +379,14 @@ private void setTexts() {
}
}
+ private void setColors() {
+ final Resources res = getResources();
+ mBtnSubmit.setBackgroundColor(mSecondaryColor);
+ mBtnSubmit.setTextColor(Utils.getTextColor(mSecondaryColor, "filled", false));
+ mBtnSubmit2.setBackgroundColor(mSecondaryColor);
+ mBtnSubmit2.setTextColor(Utils.getTextColor(mSecondaryColor, "filled", false));
+ }
+
private void updateState(int state) {
mCurrentState = state;
@@ -563,12 +599,14 @@ public void showThankYouLayout() {
@Override
public void onScoreClick(int scoreValue) {
- if(mCurrentScore != -1) {
- mScoreViews[mCurrentScore].setSelected(false);
- }
-
mCurrentScore = scoreValue;
+ for(int score = mScaleMinimum; score < mScoresTop; score++) {
+ if (score != mCurrentScore) {
+ mScoreViews[score].setSelected(false);
+ }
+ }
+
Score score = new Score(mCurrentScore, mSettings.getSurveyType(), mSettings.getSurveyTypeScale());
boolean shouldSkipFeedbackScreen = mSettings.skipFeedbackScreen() ||
(score.isPromoter() && mSettings.shouldSkipFollowupScreenForPromoters());
diff --git a/androidsdk/src/main/res/drawable/score.xml b/androidsdk/src/main/res/drawable/score.xml
index 27cf5ce..bfcbb51 100644
--- a/androidsdk/src/main/res/drawable/score.xml
+++ b/androidsdk/src/main/res/drawable/score.xml
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/androidsdk/src/main/res/layout-sw600dp/wootric_thank_you_layout.xml b/androidsdk/src/main/res/layout-sw600dp/wootric_thank_you_layout.xml
index 3a8cba8..accd744 100644
--- a/androidsdk/src/main/res/layout-sw600dp/wootric_thank_you_layout.xml
+++ b/androidsdk/src/main/res/layout-sw600dp/wootric_thank_you_layout.xml
@@ -103,7 +103,8 @@
android:textColor="@color/wootric_tablet_cta_color"
android:text="@string/wootric_btn_thank_you_action"
android:fontFamily="@font/ibmplexsans"
- android:layout_margin="8dp"/>
+ android:layout_margin="8dp"
+ android:stateListAnimator="@null"/>
-
@@ -61,7 +60,6 @@
android:id="@+id/wootric_layout_facebook"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_below="@+id/wootric_layout_facebook_like"
android:orientation="horizontal"
android:gravity="center_vertical">
@@ -91,7 +89,6 @@
android:id="@+id/wootric_layout_twitter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_below="@+id/wootric_layout_facebook"
android:orientation="horizontal"
android:gravity="center_vertical">
@@ -126,7 +123,6 @@
android:background="@color/wootric_score_color"
android:textColor="@android:color/white"
android:fontFamily="@font/ibmplexsans"
- android:layout_below="@+id/wootric_layout_twitter"
android:layout_marginTop="@dimen/wootric_thank_you_action_button_margin"
android:gravity="center"
android:text="@string/wootric_btn_thank_you_action"/>
@@ -135,16 +131,12 @@
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:fontFamily="@font/ibmplexsans"
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:layout_marginTop="12dp"
android:text="@string/wootric_example_btn_dismiss"/>
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 1a6a015..0d6c85a 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Mon Dec 14 17:57:04 ECT 2020
+#Thu May 23 16:25:10 PDT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip