Showing
14 changed files
with
342 additions
and
184 deletions
... | @@ -47,7 +47,7 @@ dependencies { | ... | @@ -47,7 +47,7 @@ dependencies { |
47 | api group: 'com.google.zxing', name: 'core', version: '3.4.1' | 47 | api group: 'com.google.zxing', name: 'core', version: '3.4.1' |
48 | api group: 'com.google.zxing', name: 'javase', version: '3.4.1' | 48 | api group: 'com.google.zxing', name: 'javase', version: '3.4.1' |
49 | api 'com.github.siyamed:android-shape-imageview:0.9.3' | 49 | api 'com.github.siyamed:android-shape-imageview:0.9.3' |
50 | - | 50 | + api 'org.greenrobot:eventbus:3.3.1' |
51 | 51 | ||
52 | //------------------------------ Firebase -----------------------------// | 52 | //------------------------------ Firebase -----------------------------// |
53 | api platform('com.google.firebase:firebase-bom:29.0.3') | 53 | api platform('com.google.firebase:firebase-bom:29.0.3') | ... | ... |
... | @@ -27,10 +27,10 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { | ... | @@ -27,10 +27,10 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { |
27 | // =========================================================== | 27 | // =========================================================== |
28 | 28 | ||
29 | private ImageView mIvBack; | 29 | private ImageView mIvBack; |
30 | - private TextView mTvUsername, mTvQuestionnaire, mTvActiveCoupons, | 30 | + private TextView mTvUsername, mTvActiveCoupons, |
31 | - mTvActiveRewards; | 31 | + mTvActiveRewards, mTvUserBadge; |
32 | private ConstraintLayout mClActiveCoupons, mClActiveRewards; | 32 | private ConstraintLayout mClActiveCoupons, mClActiveRewards; |
33 | - private LinearLayout mLlAnalysisButton; | 33 | + private LinearLayout mLlAnalysisButton, mLlQuestionnaire, mLlUserBadge; |
34 | 34 | ||
35 | // =========================================================== | 35 | // =========================================================== |
36 | // Methods for/from SuperClass/Interfaces | 36 | // Methods for/from SuperClass/Interfaces |
... | @@ -44,12 +44,14 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { | ... | @@ -44,12 +44,14 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { |
44 | mIvBack = findViewById(R.id.iv_back); | 44 | mIvBack = findViewById(R.id.iv_back); |
45 | // mTvAnalysisButton = findViewById(R.id.rl_analysis_row).findViewById(R.id.cl_chart_info).findViewById(R.id.tv_analysis_details); | 45 | // mTvAnalysisButton = findViewById(R.id.rl_analysis_row).findViewById(R.id.cl_chart_info).findViewById(R.id.tv_analysis_details); |
46 | mTvUsername = findViewById(R.id.tv_name); | 46 | mTvUsername = findViewById(R.id.tv_name); |
47 | -// mTvQuestionnaire = findViewById(R.id.cl_loyalty_info_banner).findViewById(R.id.tv_questionnaire); | 47 | + mLlQuestionnaire = findViewById(R.id.ll_user_questionnaire); |
48 | + mLlUserBadge = findViewById(R.id.ll_user_badge); | ||
48 | mClActiveCoupons = findViewById(R.id.cl_loyalty_coupon); | 49 | mClActiveCoupons = findViewById(R.id.cl_loyalty_coupon); |
49 | mTvActiveCoupons = findViewById(R.id.tv_active_coupons); | 50 | mTvActiveCoupons = findViewById(R.id.tv_active_coupons); |
50 | mClActiveRewards = findViewById(R.id.cl_loyalty_rewards); | 51 | mClActiveRewards = findViewById(R.id.cl_loyalty_rewards); |
51 | mTvActiveRewards = findViewById(R.id.tv_active_rewards); | 52 | mTvActiveRewards = findViewById(R.id.tv_active_rewards); |
52 | mLlAnalysisButton = findViewById(R.id.ll_analysis); | 53 | mLlAnalysisButton = findViewById(R.id.ll_analysis); |
54 | + mTvUserBadge = findViewById(R.id.tv_type); | ||
53 | 55 | ||
54 | initViews(); | 56 | initViews(); |
55 | } | 57 | } |
... | @@ -70,7 +72,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { | ... | @@ -70,7 +72,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { |
70 | startActivity(intent); | 72 | startActivity(intent); |
71 | return; | 73 | return; |
72 | } | 74 | } |
73 | - if (view.getId() == R.id.tv_questionnaire) { | 75 | + if (view.getId() == R.id.ll_user_questionnaire) { |
74 | CampaignList cl = WarplyManagerHelper.getUniqueCampaignList().get("more_for_you"); | 76 | CampaignList cl = WarplyManagerHelper.getUniqueCampaignList().get("more_for_you"); |
75 | Campaign camp = null; | 77 | Campaign camp = null; |
76 | if (cl != null) { | 78 | if (cl != null) { |
... | @@ -104,13 +106,25 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { | ... | @@ -104,13 +106,25 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { |
104 | // =========================================================== | 106 | // =========================================================== |
105 | 107 | ||
106 | private void initViews() { | 108 | private void initViews() { |
107 | - if (WarplyManagerHelper.getConsumer() != null) | 109 | + if (WarplyManagerHelper.getConsumer() != null) { |
108 | mTvUsername.setText(String.format(getResources().getString(R.string.cos_profile_loyalty_name), | 110 | mTvUsername.setText(String.format(getResources().getString(R.string.cos_profile_loyalty_name), |
109 | WarplyManagerHelper.getConsumer().getFirstName(), WarplyManagerHelper.getConsumer().getLastName())); | 111 | WarplyManagerHelper.getConsumer().getFirstName(), WarplyManagerHelper.getConsumer().getLastName())); |
110 | 112 | ||
113 | + if (WarplyManagerHelper.getConsumer().getProfileMetadata() != null) { | ||
114 | + boolean answered = WarplyManagerHelper.getConsumer().getProfileMetadata().optBoolean("answered", false); | ||
115 | + if (answered) { | ||
116 | + //TODO: put badge also | ||
117 | + mLlUserBadge.setVisibility(View.VISIBLE); | ||
118 | + } else | ||
119 | + mLlQuestionnaire.setVisibility(View.VISIBLE); | ||
120 | + } else { | ||
121 | + mLlQuestionnaire.setVisibility(View.VISIBLE); | ||
122 | + } | ||
123 | + } | ||
124 | + | ||
111 | mIvBack.setOnClickListener(this); | 125 | mIvBack.setOnClickListener(this); |
112 | // mTvAnalysisButton.setOnClickListener(this); | 126 | // mTvAnalysisButton.setOnClickListener(this); |
113 | -// mTvQuestionnaire.setOnClickListener(this); | 127 | + mLlQuestionnaire.setOnClickListener(this); |
114 | mTvActiveCoupons.setText(String.format(getResources().getString(R.string.cos_active_coupons), String.valueOf(WarplyManagerHelper.getCouponList().size()))); | 128 | mTvActiveCoupons.setText(String.format(getResources().getString(R.string.cos_active_coupons), String.valueOf(WarplyManagerHelper.getCouponList().size()))); |
115 | mClActiveCoupons.setOnClickListener(this); | 129 | mClActiveCoupons.setOnClickListener(this); |
116 | //TODO: change the parameter, for testing purposes only | 130 | //TODO: change the parameter, for testing purposes only | ... | ... |
1 | +/* | ||
2 | + * Copyright 2010-2013 Warply Ltd. All rights reserved. | ||
3 | + * | ||
4 | + * Redistribution and use in source and binary forms, without modification, are | ||
5 | + * permitted provided that the following conditions are met: | ||
6 | + * | ||
7 | + * 1. Redistributions of source code must retain the above copyright notice, | ||
8 | + * this list of conditions and the following disclaimer. | ||
9 | + * | ||
10 | + * 2. Redistributions in binary form must reproduce the above copyright notice, | ||
11 | + * this list of conditions and the following disclaimer in the documentation | ||
12 | + * and/or other materials provided with the distribution. | ||
13 | + * | ||
14 | + * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR | ||
15 | + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
16 | + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | ||
17 | + * EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
18 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
19 | + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | ||
20 | + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
21 | + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
22 | + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
23 | + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
24 | + */ | ||
25 | + | ||
26 | +package ly.warp.sdk.io.callbacks; | ||
27 | + | ||
28 | +public interface WarplyHealthCallback { | ||
29 | + | ||
30 | + void onStepCount(long stepsCount); | ||
31 | +} |
... | @@ -8,156 +8,18 @@ import java.util.ArrayList; | ... | @@ -8,156 +8,18 @@ import java.util.ArrayList; |
8 | 8 | ||
9 | public class LoyaltyContextualOfferModel { | 9 | public class LoyaltyContextualOfferModel { |
10 | private String sessionId; //Needed for Interest/Accept/Reject | 10 | private String sessionId; //Needed for Interest/Accept/Reject |
11 | - private String interactionPoint; | ||
12 | - private String offerCode; //Offer Id. Needed for Interest/Accept/Reject | ||
13 | - private String treatmentCode; //Needed for Interest/Accept/Reject | ||
14 | private ArrayList<String> eligibleAssets; //Array of the eligible assets for this offer | 11 | private ArrayList<String> eligibleAssets; //Array of the eligible assets for this offer |
15 | - private String title; //title for tile and detail view | 12 | + private String id; |
16 | - private String description; //detail view description | ||
17 | - private String shortDescription; //tile description | ||
18 | - private String price; // offer price | ||
19 | - private String discount; // offer discount | ||
20 | - private String termsAndConditions; | ||
21 | - private String offerType; //neo, inform | ||
22 | - private String offerType1; //sms, data, voice | ||
23 | - private String offerType2; //sms, data, voice, pre2post | ||
24 | - private String offerType3; //sms, data, voice | ||
25 | - private String imageUrl; //Tile image | ||
26 | - private String squareImageUrl; //Home contextual image | ||
27 | - private String bigImageUrl; //Detail view image | ||
28 | - private String tapOverType; //REDIRECT_TO_EXTERNAL,REDIRECT_TO_INTERNAL,DETAILED_PAGE | ||
29 | - private String tapOverUrl; //for surveys | ||
30 | - private String balancesDuration; //package duration for data,sms,voice | ||
31 | - //denotes data gift | ||
32 | - private String balancesDataType; | ||
33 | - private String balancesDataValue; | ||
34 | - //denotes voice gift | ||
35 | - private String balancesVoiceType; | ||
36 | - private String balancesVoiceValue; | ||
37 | - //denotes sms gift | ||
38 | - private String balancesSmsType; | ||
39 | - private String balancesSmsValue; | ||
40 | - private boolean surveyFlag; //If true the offer is survey | ||
41 | - private String carouselPriority; //Carousel Position | ||
42 | - private String acceptButtonText; //button wording | ||
43 | 13 | ||
44 | public String getSessionId() { | 14 | public String getSessionId() { |
45 | return sessionId; | 15 | return sessionId; |
46 | } | 16 | } |
47 | 17 | ||
48 | - public String getInteractionPoint() { | ||
49 | - return interactionPoint; | ||
50 | - } | ||
51 | - | ||
52 | - public String getOfferCode() { | ||
53 | - return offerCode; | ||
54 | - } | ||
55 | - | ||
56 | - public String getTreatmentCode() { | ||
57 | - return treatmentCode; | ||
58 | - } | ||
59 | - | ||
60 | public ArrayList<String> getEligibleAssets() { | 18 | public ArrayList<String> getEligibleAssets() { |
61 | return eligibleAssets; | 19 | return eligibleAssets; |
62 | } | 20 | } |
63 | 21 | ||
64 | - public String getTitle() { | 22 | + public String getId() { |
65 | - return title; | 23 | + return id; |
66 | - } | ||
67 | - | ||
68 | - public String getDescription() { | ||
69 | - return description; | ||
70 | - } | ||
71 | - | ||
72 | - public String getShortDescription() { | ||
73 | - return shortDescription; | ||
74 | - } | ||
75 | - | ||
76 | - public String getPrice() { | ||
77 | - return price; | ||
78 | - } | ||
79 | - | ||
80 | - public String getDiscount() { | ||
81 | - return discount; | ||
82 | - } | ||
83 | - | ||
84 | - public String getTermsAndConditions() { | ||
85 | - return termsAndConditions; | ||
86 | - } | ||
87 | - | ||
88 | - public String getOfferType() { | ||
89 | - return offerType; | ||
90 | - } | ||
91 | - | ||
92 | - public String getOfferType1() { | ||
93 | - return offerType1; | ||
94 | - } | ||
95 | - | ||
96 | - public String getOfferType2() { | ||
97 | - return offerType2; | ||
98 | - } | ||
99 | - | ||
100 | - public String getOfferType3() { | ||
101 | - return offerType3; | ||
102 | - } | ||
103 | - | ||
104 | - public String getImageUrl() { | ||
105 | - return imageUrl; | ||
106 | - } | ||
107 | - | ||
108 | - public String getSquareImageUrl() { | ||
109 | - return squareImageUrl; | ||
110 | - } | ||
111 | - | ||
112 | - public String getBigImageUrl() { | ||
113 | - return bigImageUrl; | ||
114 | - } | ||
115 | - | ||
116 | - public String getTapOverType() { | ||
117 | - return tapOverType; | ||
118 | - } | ||
119 | - | ||
120 | - public String getTapOverUrl() { | ||
121 | - return tapOverUrl; | ||
122 | - } | ||
123 | - | ||
124 | - public String getBalancesDuration() { | ||
125 | - return balancesDuration; | ||
126 | - } | ||
127 | - | ||
128 | - public String getBalancesDataType() { | ||
129 | - return balancesDataType; | ||
130 | - } | ||
131 | - | ||
132 | - public String getBalancesDataValue() { | ||
133 | - return balancesDataValue; | ||
134 | - } | ||
135 | - | ||
136 | - public String getBalancesVoiceType() { | ||
137 | - return balancesVoiceType; | ||
138 | - } | ||
139 | - | ||
140 | - public String getBalancesVoiceValue() { | ||
141 | - return balancesVoiceValue; | ||
142 | - } | ||
143 | - | ||
144 | - public String getBalancesSmsType() { | ||
145 | - return balancesSmsType; | ||
146 | - } | ||
147 | - | ||
148 | - public String getBalancesSmsValue() { | ||
149 | - return balancesSmsValue; | ||
150 | - } | ||
151 | - | ||
152 | - public boolean isSurveyFlag() { | ||
153 | - return surveyFlag; | ||
154 | - } | ||
155 | - | ||
156 | - public String getCarouselPriority() { | ||
157 | - return carouselPriority; | ||
158 | - } | ||
159 | - | ||
160 | - public String getAcceptButtonText() { | ||
161 | - return acceptButtonText; | ||
162 | } | 24 | } |
163 | } | 25 | } | ... | ... |
... | @@ -42,11 +42,28 @@ import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; | ... | @@ -42,11 +42,28 @@ import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; |
42 | */ | 42 | */ |
43 | 43 | ||
44 | public class WarplyManagerHelper { | 44 | public class WarplyManagerHelper { |
45 | + | ||
46 | + // =========================================================== | ||
47 | + // Constants | ||
48 | + // =========================================================== | ||
49 | + | ||
50 | + // =========================================================== | ||
51 | + // Fields | ||
52 | + // =========================================================== | ||
53 | + | ||
45 | private static Consumer mConsumer; | 54 | private static Consumer mConsumer; |
46 | private static HashMap<String, CampaignList> mUniqueCampaignList = new HashMap<String, CampaignList>(); | 55 | private static HashMap<String, CampaignList> mUniqueCampaignList = new HashMap<String, CampaignList>(); |
47 | private static CouponList mCouponList = new CouponList(); | 56 | private static CouponList mCouponList = new CouponList(); |
48 | private static CouponsetsList mCouponsetsList = new CouponsetsList(); | 57 | private static CouponsetsList mCouponsetsList = new CouponsetsList(); |
49 | 58 | ||
59 | + // =========================================================== | ||
60 | + // Methods for/from SuperClass/Interfaces | ||
61 | + // =========================================================== | ||
62 | + | ||
63 | + // =========================================================== | ||
64 | + // Methods | ||
65 | + // =========================================================== | ||
66 | + | ||
50 | public static String constructCampaignUrl(Campaign item) { | 67 | public static String constructCampaignUrl(Campaign item) { |
51 | item.setNew(false); | 68 | item.setNew(false); |
52 | String url = item.getIndexUrl() | 69 | String url = item.getIndexUrl() |
... | @@ -127,4 +144,8 @@ public class WarplyManagerHelper { | ... | @@ -127,4 +144,8 @@ public class WarplyManagerHelper { |
127 | public static void setCouponsets(CouponsetsList couponsets) { | 144 | public static void setCouponsets(CouponsetsList couponsets) { |
128 | mCouponsetsList = couponsets; | 145 | mCouponsetsList = couponsets; |
129 | } | 146 | } |
147 | + | ||
148 | + // =========================================================== | ||
149 | + // Inner and Anonymous Classes | ||
150 | + // =========================================================== | ||
130 | } | 151 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | +package ly.warp.sdk.utils.managers; | ||
2 | + | ||
3 | +import android.content.Context; | ||
4 | +import android.hardware.Sensor; | ||
5 | +import android.hardware.SensorEvent; | ||
6 | +import android.hardware.SensorEventListener; | ||
7 | +import android.hardware.SensorManager; | ||
8 | + | ||
9 | +import ly.warp.sdk.io.callbacks.WarplyHealthCallback; | ||
10 | + | ||
11 | +/** | ||
12 | + * Created by Panagiotis Triantafyllou on 27/Απρ/2022. | ||
13 | + * @guide http://www.gadgetsaint.com/android/create-pedometer-step-counter-android/#.Weg2KmiCyM8 | ||
14 | + */ | ||
15 | +public class WarplyHealthManager implements SensorEventListener { | ||
16 | + | ||
17 | + // =========================================================== | ||
18 | + // Constants | ||
19 | + // =========================================================== | ||
20 | + | ||
21 | + // =========================================================== | ||
22 | + // Fields | ||
23 | + // =========================================================== | ||
24 | + | ||
25 | + private long mSteps = 0; | ||
26 | + private static SensorManager mSensorManager; | ||
27 | + private static Sensor mSensor; | ||
28 | + private static WarplyHealthManager mWarplyHealthManagerInstance; | ||
29 | + private static final int ACCEL_RING_SIZE = 50; | ||
30 | + private static final int VEL_RING_SIZE = 10; | ||
31 | + // change this threshold according to your sensitivity preferences | ||
32 | + private static final float STEP_THRESHOLD = 20f; | ||
33 | + private static final int STEP_DELAY_NS = 250000000; | ||
34 | + private int accelRingCounter = 0; | ||
35 | + private float[] accelRingX = new float[ACCEL_RING_SIZE]; | ||
36 | + private float[] accelRingY = new float[ACCEL_RING_SIZE]; | ||
37 | + private float[] accelRingZ = new float[ACCEL_RING_SIZE]; | ||
38 | + private int velRingCounter = 0; | ||
39 | + private float[] velRing = new float[VEL_RING_SIZE]; | ||
40 | + private long lastStepTimeNs = 0; | ||
41 | + private float oldVelocityEstimate = 0; | ||
42 | + | ||
43 | + //TODO: if we want to send the steps back to an activity/fragment/service etc | ||
44 | +// private WarplyHealthCallback healthCallback; | ||
45 | + | ||
46 | + // =========================================================== | ||
47 | + // Methods for/from SuperClass/Interfaces | ||
48 | + // =========================================================== | ||
49 | + | ||
50 | + @Override | ||
51 | + public void onSensorChanged(SensorEvent sensorEvent) { | ||
52 | + if (sensorEvent.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { | ||
53 | + updateSteps( | ||
54 | + sensorEvent.timestamp, | ||
55 | + sensorEvent.values[0], | ||
56 | + sensorEvent.values[1], | ||
57 | + sensorEvent.values[2]); | ||
58 | + } | ||
59 | + } | ||
60 | + | ||
61 | + @Override | ||
62 | + public void onAccuracyChanged(Sensor sensor, int i) { | ||
63 | + | ||
64 | + } | ||
65 | + | ||
66 | + // =========================================================== | ||
67 | + // Methods | ||
68 | + // =========================================================== | ||
69 | + | ||
70 | + public static WarplyHealthManager getInstance(Context context) { | ||
71 | + if (mWarplyHealthManagerInstance == null) { | ||
72 | + mWarplyHealthManagerInstance = new WarplyHealthManager(); | ||
73 | + mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); | ||
74 | + mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); | ||
75 | + } | ||
76 | + return mWarplyHealthManagerInstance; | ||
77 | + } | ||
78 | + | ||
79 | + public void registerStepSensor() { | ||
80 | + mSensorManager.registerListener(mWarplyHealthManagerInstance, mSensor, SensorManager.SENSOR_DELAY_GAME); | ||
81 | + } | ||
82 | + | ||
83 | + public void unregisterStepSensor() { | ||
84 | + mSensorManager.unregisterListener(mWarplyHealthManagerInstance); | ||
85 | + } | ||
86 | + | ||
87 | + private void updateSteps(long timeNs, float x, float y, float z) { | ||
88 | + float[] currentAccel = new float[3]; | ||
89 | + currentAccel[0] = x; | ||
90 | + currentAccel[1] = y; | ||
91 | + currentAccel[2] = z; | ||
92 | + | ||
93 | + // First step is to update our guess of where the global z vector is. | ||
94 | + accelRingCounter++; | ||
95 | + accelRingX[accelRingCounter % ACCEL_RING_SIZE] = currentAccel[0]; | ||
96 | + accelRingY[accelRingCounter % ACCEL_RING_SIZE] = currentAccel[1]; | ||
97 | + accelRingZ[accelRingCounter % ACCEL_RING_SIZE] = currentAccel[2]; | ||
98 | + | ||
99 | + float[] worldZ = new float[3]; | ||
100 | + worldZ[0] = sum(accelRingX) / Math.min(accelRingCounter, ACCEL_RING_SIZE); | ||
101 | + worldZ[1] = sum(accelRingY) / Math.min(accelRingCounter, ACCEL_RING_SIZE); | ||
102 | + worldZ[2] = sum(accelRingZ) / Math.min(accelRingCounter, ACCEL_RING_SIZE); | ||
103 | + | ||
104 | + float normalization_factor = norm(worldZ); | ||
105 | + | ||
106 | + worldZ[0] = worldZ[0] / normalization_factor; | ||
107 | + worldZ[1] = worldZ[1] / normalization_factor; | ||
108 | + worldZ[2] = worldZ[2] / normalization_factor; | ||
109 | + | ||
110 | + float currentZ = dot(worldZ, currentAccel) - normalization_factor; | ||
111 | + velRingCounter++; | ||
112 | + velRing[velRingCounter % VEL_RING_SIZE] = currentZ; | ||
113 | + | ||
114 | + float velocityEstimate = sum(velRing); | ||
115 | + | ||
116 | + if (velocityEstimate > STEP_THRESHOLD | ||
117 | + && oldVelocityEstimate <= STEP_THRESHOLD | ||
118 | + && (timeNs - lastStepTimeNs > STEP_DELAY_NS)) { | ||
119 | + //TODO: if we want to send the steps back to an activity/fragment/service etc | ||
120 | + mSteps++; | ||
121 | +// healthCallback.onStepCount(mSteps); | ||
122 | + lastStepTimeNs = timeNs; | ||
123 | + } | ||
124 | + oldVelocityEstimate = velocityEstimate; | ||
125 | + } | ||
126 | + | ||
127 | + private float sum(float[] array) { | ||
128 | + float retval = 0; | ||
129 | + for (float v : array) { | ||
130 | + retval += v; | ||
131 | + } | ||
132 | + return retval; | ||
133 | + } | ||
134 | + | ||
135 | + private float[] cross(float[] arrayA, float[] arrayB) { | ||
136 | + float[] retArray = new float[3]; | ||
137 | + retArray[0] = arrayA[1] * arrayB[2] - arrayA[2] * arrayB[1]; | ||
138 | + retArray[1] = arrayA[2] * arrayB[0] - arrayA[0] * arrayB[2]; | ||
139 | + retArray[2] = arrayA[0] * arrayB[1] - arrayA[1] * arrayB[0]; | ||
140 | + return retArray; | ||
141 | + } | ||
142 | + | ||
143 | + private float norm(float[] array) { | ||
144 | + float retval = 0; | ||
145 | + for (float v : array) { | ||
146 | + retval += v * v; | ||
147 | + } | ||
148 | + return (float) Math.sqrt(retval); | ||
149 | + } | ||
150 | + | ||
151 | + private float dot(float[] a, float[] b) { | ||
152 | + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; | ||
153 | + } | ||
154 | + | ||
155 | + private float[] normalize(float[] a) { | ||
156 | + float[] retval = new float[a.length]; | ||
157 | + float norm = norm(a); | ||
158 | + for (int i = 0; i < a.length; i++) { | ||
159 | + retval[i] = a[i] / norm; | ||
160 | + } | ||
161 | + return retval; | ||
162 | + } | ||
163 | + | ||
164 | + // =========================================================== | ||
165 | + // Inner and Anonymous Classes | ||
166 | + // =========================================================== | ||
167 | +} |
... | @@ -50,6 +50,7 @@ import android.webkit.WebView; | ... | @@ -50,6 +50,7 @@ import android.webkit.WebView; |
50 | import android.webkit.WebViewClient; | 50 | import android.webkit.WebViewClient; |
51 | import android.widget.Toast; | 51 | import android.widget.Toast; |
52 | 52 | ||
53 | +import org.greenrobot.eventbus.EventBus; | ||
53 | import org.json.JSONArray; | 54 | import org.json.JSONArray; |
54 | import org.json.JSONException; | 55 | import org.json.JSONException; |
55 | import org.json.JSONObject; | 56 | import org.json.JSONObject; |
... | @@ -66,6 +67,7 @@ import ly.warp.sdk.utils.WarplyProperty; | ... | @@ -66,6 +67,7 @@ import ly.warp.sdk.utils.WarplyProperty; |
66 | import ly.warp.sdk.utils.WarplyUrlHandler; | 67 | import ly.warp.sdk.utils.WarplyUrlHandler; |
67 | import ly.warp.sdk.utils.constants.WarpConstants; | 68 | import ly.warp.sdk.utils.constants.WarpConstants; |
68 | import ly.warp.sdk.utils.managers.WarplyAnalyticsManager; | 69 | import ly.warp.sdk.utils.managers.WarplyAnalyticsManager; |
70 | +import ly.warp.sdk.utils.managers.WarplyEventBusManager; | ||
69 | 71 | ||
70 | public class WarpView extends WebView { | 72 | public class WarpView extends WebView { |
71 | 73 | ||
... | @@ -362,10 +364,13 @@ public class WarpView extends WebView { | ... | @@ -362,10 +364,13 @@ public class WarpView extends WebView { |
362 | public class JSInterface { | 364 | public class JSInterface { |
363 | @JavascriptInterface | 365 | @JavascriptInterface |
364 | public void sendMessage(String message) { | 366 | public void sendMessage(String message) { |
365 | - Intent intent = new Intent(android.content.Intent.ACTION_SEND); | 367 | +// Intent intent = new Intent(android.content.Intent.ACTION_SEND); |
366 | - intent.setType("text/plain"); | 368 | +// intent.setType("text/plain"); |
367 | - intent.putExtra(android.content.Intent.EXTRA_TEXT, message); | 369 | +// intent.putExtra(android.content.Intent.EXTRA_TEXT, message); |
368 | - getContext().startActivity(Intent.createChooser(intent, "Άνοιγμα με")); | 370 | +// getContext().startActivity(Intent.createChooser(intent, "Άνοιγμα με")); |
371 | + | ||
372 | + if (message.contains("event")) | ||
373 | + EventBus.getDefault().post(new WarplyEventBusManager(message)); | ||
369 | } | 374 | } |
370 | } | 375 | } |
371 | 376 | ... | ... |
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | + <stroke | ||
4 | + android:width="1.5dp" | ||
5 | + android:color="@color/cos_dark_blue" /> | ||
6 | + | ||
7 | + <corners | ||
8 | + android:topLeftRadius="15dp" | ||
9 | + android:topRightRadius="15dp" | ||
10 | + android:bottomLeftRadius="15dp" | ||
11 | + android:bottomRightRadius="15dp"/> | ||
12 | + <solid android:color="@android:color/transparent" /> | ||
13 | +</shape> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -160,28 +160,28 @@ | ... | @@ -160,28 +160,28 @@ |
160 | android:layout_height="50dp" | 160 | android:layout_height="50dp" |
161 | android:layout_marginHorizontal="32dp" | 161 | android:layout_marginHorizontal="32dp" |
162 | android:layout_marginTop="64dp" | 162 | android:layout_marginTop="64dp" |
163 | - android:background="@drawable/button_border_dark_blue" | 163 | + android:background="@drawable/button_border_grey" |
164 | android:gravity="center" | 164 | android:gravity="center" |
165 | android:orientation="horizontal" | 165 | android:orientation="horizontal" |
166 | app:layout_constraintEnd_toEndOf="parent" | 166 | app:layout_constraintEnd_toEndOf="parent" |
167 | app:layout_constraintStart_toStartOf="parent" | 167 | app:layout_constraintStart_toStartOf="parent" |
168 | app:layout_constraintTop_toBottomOf="@+id/textView17"> | 168 | app:layout_constraintTop_toBottomOf="@+id/textView17"> |
169 | 169 | ||
170 | - <ImageView | 170 | + <!-- <ImageView--> |
171 | - android:layout_width="34dp" | 171 | + <!-- android:layout_width="34dp"--> |
172 | - android:layout_height="25dp" | 172 | + <!-- android:layout_height="25dp"--> |
173 | - android:layout_marginRight="15dp" | 173 | + <!-- android:layout_marginRight="15dp"--> |
174 | - android:adjustViewBounds="true" | 174 | + <!-- android:adjustViewBounds="true"--> |
175 | - android:src="@drawable/gift_icon" /> | 175 | + <!-- android:src="@drawable/gift_icon" />--> |
176 | 176 | ||
177 | <TextView | 177 | <TextView |
178 | android:layout_width="wrap_content" | 178 | android:layout_width="wrap_content" |
179 | android:layout_height="wrap_content" | 179 | android:layout_height="wrap_content" |
180 | android:gravity="center" | 180 | android:gravity="center" |
181 | android:text="Κάντο δώρο!" | 181 | android:text="Κάντο δώρο!" |
182 | - android:textColor="@color/white" | 182 | + android:textColor="@color/cos_green6" |
183 | - android:textSize="17dp" | 183 | + android:textFontWeight="600" |
184 | - android:textStyle="bold" /> | 184 | + android:textSize="17dp" /> |
185 | </LinearLayout> | 185 | </LinearLayout> |
186 | 186 | ||
187 | <!-- <LinearLayout--> | 187 | <!-- <LinearLayout--> | ... | ... |
... | @@ -51,35 +51,61 @@ | ... | @@ -51,35 +51,61 @@ |
51 | app:layout_constraintLeft_toLeftOf="parent" | 51 | app:layout_constraintLeft_toLeftOf="parent" |
52 | app:layout_constraintTop_toTopOf="parent" /> | 52 | app:layout_constraintTop_toTopOf="parent" /> |
53 | 53 | ||
54 | - <TextView | ||
55 | - android:id="@+id/tv_name" | ||
56 | - android:layout_width="wrap_content" | ||
57 | - android:layout_height="wrap_content" | ||
58 | - android:layout_marginStart="8dp" | ||
59 | - android:layout_marginTop="6dp" | ||
60 | - android:maxLines="1" | ||
61 | - android:textColor="@color/grey" | ||
62 | - app:layout_constraintLeft_toRightOf="@+id/iv_profile_photo" | ||
63 | - app:layout_constraintTop_toTopOf="@+id/iv_profile_photo" | ||
64 | - tools:text="Test Name" /> | ||
65 | - | ||
66 | <LinearLayout | 54 | <LinearLayout |
67 | android:layout_width="wrap_content" | 55 | android:layout_width="wrap_content" |
68 | android:layout_height="wrap_content" | 56 | android:layout_height="wrap_content" |
69 | - android:layout_marginStart="8dp" | 57 | + android:orientation="vertical" |
70 | - android:layout_marginBottom="10dp" | ||
71 | - android:background="@drawable/shape_cos_gradient" | ||
72 | - android:gravity="center" | ||
73 | - android:paddingHorizontal="4dp" | ||
74 | app:layout_constraintBottom_toBottomOf="@+id/iv_profile_photo" | 58 | app:layout_constraintBottom_toBottomOf="@+id/iv_profile_photo" |
75 | - app:layout_constraintLeft_toRightOf="@+id/iv_profile_photo"> | 59 | + app:layout_constraintStart_toEndOf="@+id/iv_profile_photo" |
60 | + app:layout_constraintTop_toTopOf="@+id/iv_profile_photo"> | ||
76 | 61 | ||
77 | <TextView | 62 | <TextView |
78 | - android:id="@+id/tv_type" | 63 | + android:id="@+id/tv_name" |
64 | + android:layout_width="wrap_content" | ||
65 | + android:layout_height="wrap_content" | ||
66 | + android:layout_marginStart="8dp" | ||
67 | + android:layout_marginBottom="4dp" | ||
68 | + android:maxLines="1" | ||
69 | + android:textColor="@color/grey" | ||
70 | + tools:text="Test Name" /> | ||
71 | + | ||
72 | + <LinearLayout | ||
73 | + android:id="@+id/ll_user_badge" | ||
79 | android:layout_width="wrap_content" | 74 | android:layout_width="wrap_content" |
80 | android:layout_height="wrap_content" | 75 | android:layout_height="wrap_content" |
81 | - android:text="@string/cos_profile_type" | 76 | + android:layout_marginStart="8dp" |
82 | - android:textColor="@android:color/white" /> | 77 | + android:background="@drawable/shape_cos_gradient" |
78 | + android:gravity="center" | ||
79 | + android:paddingHorizontal="4dp" | ||
80 | + android:visibility="gone"> | ||
81 | + | ||
82 | + <TextView | ||
83 | + android:id="@+id/tv_type" | ||
84 | + android:layout_width="wrap_content" | ||
85 | + android:layout_height="wrap_content" | ||
86 | + android:textColor="@android:color/white" | ||
87 | + tools:text="@string/cos_profile_type" /> | ||
88 | + </LinearLayout> | ||
89 | + | ||
90 | + <LinearLayout | ||
91 | + android:id="@+id/ll_user_questionnaire" | ||
92 | + android:layout_width="wrap_content" | ||
93 | + android:layout_height="wrap_content" | ||
94 | + android:layout_marginStart="8dp" | ||
95 | + android:background="@drawable/shape_cos_transparent_rounded3" | ||
96 | + android:gravity="center" | ||
97 | + android:paddingHorizontal="8dp" | ||
98 | + android:paddingVertical="4dp" | ||
99 | + android:visibility="gone"> | ||
100 | + | ||
101 | + <TextView | ||
102 | + android:id="@+id/tv_questionnaire" | ||
103 | + android:layout_width="wrap_content" | ||
104 | + android:layout_height="wrap_content" | ||
105 | + android:text="@string/cos_profile_questionnaire" | ||
106 | + android:textColor="@color/cos_dark_blue" | ||
107 | + android:textFontWeight="600" /> | ||
108 | + </LinearLayout> | ||
83 | </LinearLayout> | 109 | </LinearLayout> |
84 | </androidx.constraintlayout.widget.ConstraintLayout> | 110 | </androidx.constraintlayout.widget.ConstraintLayout> |
85 | 111 | ... | ... |
... | @@ -37,4 +37,5 @@ | ... | @@ -37,4 +37,5 @@ |
37 | <color name="cos_cyan3">#2EB2B9</color> | 37 | <color name="cos_cyan3">#2EB2B9</color> |
38 | <color name="grey4">#F3F3F3</color> | 38 | <color name="grey4">#F3F3F3</color> |
39 | <color name="grey_tr3">#7DF2F2F2</color> | 39 | <color name="grey_tr3">#7DF2F2F2</color> |
40 | + <color name="cos_dark_blue">#355168</color> | ||
40 | </resources> | 41 | </resources> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -54,6 +54,7 @@ | ... | @@ -54,6 +54,7 @@ |
54 | <string name="cos_annual">12Μηνο</string> | 54 | <string name="cos_annual">12Μηνο</string> |
55 | <string name="cos_analysis2">Αναλυτικά</string> | 55 | <string name="cos_analysis2">Αναλυτικά</string> |
56 | <string name="euro">€</string> | 56 | <string name="euro">€</string> |
57 | + <string name="cos_profile_questionnaire">+ Ερωτηματολόγιο</string> | ||
57 | 58 | ||
58 | <string-array name="coupons_array"> | 59 | <string-array name="coupons_array"> |
59 | <item>Κουπόνια</item> | 60 | <item>Κουπόνια</item> | ... | ... |
-
Please register or login to post a comment