Showing
4 changed files
with
108 additions
and
24 deletions
... | @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' | ... | @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' |
2 | 2 | ||
3 | ext { | 3 | ext { |
4 | PUBLISH_GROUP_ID = 'ly.warp' | 4 | PUBLISH_GROUP_ID = 'ly.warp' |
5 | - PUBLISH_VERSION = '4.5.4.6rc63' | 5 | + PUBLISH_VERSION = '4.5.4.6rc64' |
6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' | 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' |
7 | } | 7 | } |
8 | 8 | ... | ... |
... | @@ -22,6 +22,7 @@ import android.view.WindowManager; | ... | @@ -22,6 +22,7 @@ import android.view.WindowManager; |
22 | import android.widget.EditText; | 22 | import android.widget.EditText; |
23 | import android.widget.ImageView; | 23 | import android.widget.ImageView; |
24 | import android.widget.LinearLayout; | 24 | import android.widget.LinearLayout; |
25 | +import android.widget.RelativeLayout; | ||
25 | import android.widget.TextView; | 26 | import android.widget.TextView; |
26 | 27 | ||
27 | import androidx.annotation.NonNull; | 28 | import androidx.annotation.NonNull; |
... | @@ -90,6 +91,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener | ... | @@ -90,6 +91,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener |
90 | private String mStartTimestamp = "", mStopTimestamp = ""; | 91 | private String mStartTimestamp = "", mStopTimestamp = ""; |
91 | private final int RECORDS_INTERVAL = 5000; | 92 | private final int RECORDS_INTERVAL = 5000; |
92 | private EditText mEtLimit, mEtSampleTime; | 93 | private EditText mEtLimit, mEtSampleTime; |
94 | + private RelativeLayout mRlMainScroll; | ||
93 | 95 | ||
94 | 96 | ||
95 | // =========================================================== | 97 | // =========================================================== |
... | @@ -105,6 +107,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener | ... | @@ -105,6 +107,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener |
105 | mIvBack = findViewById(R.id.iv_telematics_close); | 107 | mIvBack = findViewById(R.id.iv_telematics_close); |
106 | mLlTripButton = findViewById(R.id.ll_activate_button); | 108 | mLlTripButton = findViewById(R.id.ll_activate_button); |
107 | mLlTripButton.setOnClickListener(this); | 109 | mLlTripButton.setOnClickListener(this); |
110 | + mLlTripButton.setOnTouchListener(mTripTouchListener); | ||
108 | mTvTripButton = findViewById(R.id.tv_trip_button); | 111 | mTvTripButton = findViewById(R.id.tv_trip_button); |
109 | mLlTelematicsMain = findViewById(R.id.ll_telematics_main); | 112 | mLlTelematicsMain = findViewById(R.id.ll_telematics_main); |
110 | mTvSensorData = findViewById(R.id.tv_sensor_data); | 113 | mTvSensorData = findViewById(R.id.tv_sensor_data); |
... | @@ -116,6 +119,8 @@ public class TelematicsActivity extends Activity implements View.OnClickListener | ... | @@ -116,6 +119,8 @@ public class TelematicsActivity extends Activity implements View.OnClickListener |
116 | mTvTouchCount = findViewById(R.id.tv_touch); | 119 | mTvTouchCount = findViewById(R.id.tv_touch); |
117 | mEtLimit = findViewById(R.id.et_acceleration); | 120 | mEtLimit = findViewById(R.id.et_acceleration); |
118 | mEtSampleTime = findViewById(R.id.et_save); | 121 | mEtSampleTime = findViewById(R.id.et_save); |
122 | + mRlMainScroll = findViewById(R.id.rl_main_scroll); | ||
123 | + mRlMainScroll.setOnTouchListener(mScrollTouchListener); | ||
119 | 124 | ||
120 | locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); | 125 | locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); |
121 | previousLocation = null; | 126 | previousLocation = null; |
... | @@ -200,6 +205,8 @@ public class TelematicsActivity extends Activity implements View.OnClickListener | ... | @@ -200,6 +205,8 @@ public class TelematicsActivity extends Activity implements View.OnClickListener |
200 | } | 205 | } |
201 | if (view.getId() == R.id.ll_activate_button) { | 206 | if (view.getId() == R.id.ll_activate_button) { |
202 | if (mIsTripStarted) { | 207 | if (mIsTripStarted) { |
208 | + mEtLimit.setEnabled(true); | ||
209 | + mEtSampleTime.setEnabled(true); | ||
203 | unregisterSensor(); | 210 | unregisterSensor(); |
204 | stopLocationUpdates(); | 211 | stopLocationUpdates(); |
205 | initViews(); | 212 | initViews(); |
... | @@ -210,6 +217,8 @@ public class TelematicsActivity extends Activity implements View.OnClickListener | ... | @@ -210,6 +217,8 @@ public class TelematicsActivity extends Activity implements View.OnClickListener |
210 | Snackbar.make(mLlTelematicsMain, "Please fill the Cut off field", Snackbar.LENGTH_SHORT).show(); | 217 | Snackbar.make(mLlTelematicsMain, "Please fill the Cut off field", Snackbar.LENGTH_SHORT).show(); |
211 | return; | 218 | return; |
212 | } | 219 | } |
220 | + mEtLimit.setEnabled(false); | ||
221 | + mEtSampleTime.setEnabled(false); | ||
213 | mTouchHandler = new Handler(); | 222 | mTouchHandler = new Handler(); |
214 | mTouchRunnable = new Runnable() { | 223 | mTouchRunnable = new Runnable() { |
215 | @Override | 224 | @Override |
... | @@ -292,28 +301,45 @@ public class TelematicsActivity extends Activity implements View.OnClickListener | ... | @@ -292,28 +301,45 @@ public class TelematicsActivity extends Activity implements View.OnClickListener |
292 | } | 301 | } |
293 | } | 302 | } |
294 | 303 | ||
295 | - @Override | 304 | +// @Override |
296 | - public boolean onTouchEvent(MotionEvent event) { | 305 | +// public boolean dispatchTouchEvent(MotionEvent event) { |
297 | -// return super.onTouchEvent(event); | 306 | +// if (mIsTripStarted) { |
298 | - if (mIsTripStarted) { | 307 | +// switch (event.getAction()) { |
308 | +// case MotionEvent.ACTION_DOWN: | ||
299 | // touchCount++; | 309 | // touchCount++; |
300 | // mTvTouchCount.setText(String.valueOf(touchCount)); | 310 | // mTvTouchCount.setText(String.valueOf(touchCount)); |
311 | +// mTouchHandler.post(mTouchRunnable); | ||
301 | // return true; | 312 | // return true; |
313 | +// case MotionEvent.ACTION_UP: | ||
314 | +// mTouchHandler.removeCallbacks(mTouchRunnable); | ||
315 | +// return true; | ||
316 | +// } | ||
317 | +// } | ||
318 | +// return super.dispatchTouchEvent(event); | ||
319 | +// } | ||
302 | 320 | ||
303 | - switch (event.getAction()) { | 321 | +// @Override |
304 | - case MotionEvent.ACTION_DOWN: | 322 | +// public boolean onTouchEvent(MotionEvent event) { |
305 | - touchCount++; | 323 | +//// return super.onTouchEvent(event); |
306 | - mTvTouchCount.setText(String.valueOf(touchCount)); | 324 | +// if (mIsTripStarted) { |
307 | - mTouchHandler.post(mTouchRunnable); | 325 | +//// touchCount++; |
308 | - return true; | 326 | +//// mTvTouchCount.setText(String.valueOf(touchCount)); |
309 | - case MotionEvent.ACTION_UP: | 327 | +//// return true; |
310 | - mTouchHandler.removeCallbacks(mTouchRunnable); | 328 | +// |
311 | - return true; | 329 | +// switch (event.getAction()) { |
312 | - } | 330 | +// case MotionEvent.ACTION_DOWN: |
313 | - return false; | 331 | +// touchCount++; |
314 | - } | 332 | +// mTvTouchCount.setText(String.valueOf(touchCount)); |
315 | - return false; | 333 | +// mTouchHandler.post(mTouchRunnable); |
316 | - } | 334 | +// return true; |
335 | +// case MotionEvent.ACTION_UP: | ||
336 | +// mTouchHandler.removeCallbacks(mTouchRunnable); | ||
337 | +// return true; | ||
338 | +// } | ||
339 | +// return false; | ||
340 | +// } | ||
341 | +// return false; | ||
342 | +// } | ||
317 | 343 | ||
318 | // =========================================================== | 344 | // =========================================================== |
319 | // Methods | 345 | // Methods |
... | @@ -495,6 +521,39 @@ public class TelematicsActivity extends Activity implements View.OnClickListener | ... | @@ -495,6 +521,39 @@ public class TelematicsActivity extends Activity implements View.OnClickListener |
495 | } | 521 | } |
496 | } | 522 | } |
497 | 523 | ||
524 | + private final View.OnTouchListener mTripTouchListener = new View.OnTouchListener() { | ||
525 | + @Override | ||
526 | + public boolean onTouch(View view, MotionEvent motionEvent) { | ||
527 | + if (mIsTripStarted) { | ||
528 | + if (motionEvent.getAction() == MotionEvent.ACTION_UP) { | ||
529 | + mTouchHandler.removeCallbacks(mTouchRunnable); | ||
530 | + onClick(view); | ||
531 | + return true; | ||
532 | + } | ||
533 | + } | ||
534 | + return false; | ||
535 | + } | ||
536 | + }; | ||
537 | + | ||
538 | + private final View.OnTouchListener mScrollTouchListener = new View.OnTouchListener() { | ||
539 | + @Override | ||
540 | + public boolean onTouch(View view, MotionEvent motionEvent) { | ||
541 | + if (mIsTripStarted) { | ||
542 | + switch (motionEvent.getAction()) { | ||
543 | + case MotionEvent.ACTION_DOWN: | ||
544 | + touchCount++; | ||
545 | + mTvTouchCount.setText(String.valueOf(touchCount)); | ||
546 | + mTouchHandler.post(mTouchRunnable); | ||
547 | + return true; | ||
548 | + case MotionEvent.ACTION_UP: | ||
549 | + mTouchHandler.removeCallbacks(mTouchRunnable); | ||
550 | + return true; | ||
551 | + } | ||
552 | + } | ||
553 | + return false; | ||
554 | + } | ||
555 | + }; | ||
556 | + | ||
498 | // // Low-pass filter function using Exponential Moving Average (EMA) | 557 | // // Low-pass filter function using Exponential Moving Average (EMA) |
499 | // private float lowPassFilter(float currentValue) { | 558 | // private float lowPassFilter(float currentValue) { |
500 | // float filteredValue = alpha * currentValue + (1 - alpha) * previousFilteredValue; | 559 | // float filteredValue = alpha * currentValue + (1 - alpha) * previousFilteredValue; | ... | ... |
... | @@ -43,6 +43,7 @@ import android.net.http.SslError; | ... | @@ -43,6 +43,7 @@ import android.net.http.SslError; |
43 | import android.os.Build; | 43 | import android.os.Build; |
44 | import android.text.TextUtils; | 44 | import android.text.TextUtils; |
45 | import android.util.AttributeSet; | 45 | import android.util.AttributeSet; |
46 | +import android.util.Log; | ||
46 | import android.webkit.GeolocationPermissions.Callback; | 47 | import android.webkit.GeolocationPermissions.Callback; |
47 | import android.webkit.JavascriptInterface; | 48 | import android.webkit.JavascriptInterface; |
48 | import android.webkit.SslErrorHandler; | 49 | import android.webkit.SslErrorHandler; |
... | @@ -75,6 +76,7 @@ import org.json.JSONException; | ... | @@ -75,6 +76,7 @@ import org.json.JSONException; |
75 | import org.json.JSONObject; | 76 | import org.json.JSONObject; |
76 | 77 | ||
77 | import java.io.UnsupportedEncodingException; | 78 | import java.io.UnsupportedEncodingException; |
79 | +import java.net.URISyntaxException; | ||
78 | import java.net.URLDecoder; | 80 | import java.net.URLDecoder; |
79 | import java.util.HashMap; | 81 | import java.util.HashMap; |
80 | import java.util.LinkedHashMap; | 82 | import java.util.LinkedHashMap; |
... | @@ -107,6 +109,7 @@ public class WarpView extends WebView implements DefaultLifecycleObserver { | ... | @@ -107,6 +109,7 @@ public class WarpView extends WebView implements DefaultLifecycleObserver { |
107 | private static final String URL_ACTION_RSMS = "rsms"; | 109 | private static final String URL_ACTION_RSMS = "rsms"; |
108 | private static final String URL_ACTION_MAIL = "mailto"; | 110 | private static final String URL_ACTION_MAIL = "mailto"; |
109 | private static final String URL_ACTION_MARKET = "market"; | 111 | private static final String URL_ACTION_MARKET = "market"; |
112 | + private static final String URL_ACTION_INTENT = "intent"; | ||
110 | private static final String URL_ACTION_MARKET_AUTHORITY = "play.google.com"; | 113 | private static final String URL_ACTION_MARKET_AUTHORITY = "play.google.com"; |
111 | private static final String TAG_STEPS_WORKER = "ly.warp.sdk.services.WarplyHealthService"; | 114 | private static final String TAG_STEPS_WORKER = "ly.warp.sdk.services.WarplyHealthService"; |
112 | 115 | ||
... | @@ -789,6 +792,21 @@ public class WarpView extends WebView implements DefaultLifecycleObserver { | ... | @@ -789,6 +792,21 @@ public class WarpView extends WebView implements DefaultLifecycleObserver { |
789 | Intent intent = new Intent(Intent.ACTION_VIEW, webpage); | 792 | Intent intent = new Intent(Intent.ACTION_VIEW, webpage); |
790 | getContext().startActivity(intent); | 793 | getContext().startActivity(intent); |
791 | return true; | 794 | return true; |
795 | + } else if (scheme.equalsIgnoreCase(URL_ACTION_INTENT)) { | ||
796 | + try { | ||
797 | + Intent intent = Intent.parseUri(strUrl, Intent.URI_INTENT_SCHEME); | ||
798 | +// String fallbackUrl = intent.getStringExtra("browser_fallback_url"); | ||
799 | + String data = intent.getData().toString(); | ||
800 | + if (!TextUtils.isEmpty(data)) { | ||
801 | +// view.loadUrl(fallbackUrl); | ||
802 | + Uri webpage = Uri.parse(data); | ||
803 | + Intent intentWebpage = new Intent(Intent.ACTION_VIEW, webpage); | ||
804 | + getContext().startActivity(intentWebpage); | ||
805 | + return true; | ||
806 | + } | ||
807 | + } catch (URISyntaxException e) { | ||
808 | + return true; | ||
809 | + } | ||
792 | } | 810 | } |
793 | return false; | 811 | return false; |
794 | } | 812 | } | ... | ... |
... | @@ -40,11 +40,17 @@ | ... | @@ -40,11 +40,17 @@ |
40 | </androidx.constraintlayout.widget.ConstraintLayout> | 40 | </androidx.constraintlayout.widget.ConstraintLayout> |
41 | 41 | ||
42 | <ScrollView | 42 | <ScrollView |
43 | - android:fillViewport="true" | ||
44 | android:layout_width="wrap_content" | 43 | android:layout_width="wrap_content" |
45 | android:layout_height="match_parent"> | 44 | android:layout_height="match_parent"> |
46 | 45 | ||
46 | + <LinearLayout | ||
47 | + android:layout_width="match_parent" | ||
48 | + android:layout_height="wrap_content" | ||
49 | + android:background="@color/cos_light_grey3" | ||
50 | + android:orientation="vertical"> | ||
51 | + | ||
47 | <RelativeLayout | 52 | <RelativeLayout |
53 | + android:id="@+id/rl_main_scroll" | ||
48 | android:layout_width="match_parent" | 54 | android:layout_width="match_parent" |
49 | android:layout_height="match_parent" | 55 | android:layout_height="match_parent" |
50 | android:background="@color/cos_light_grey3" | 56 | android:background="@color/cos_light_grey3" |
... | @@ -152,8 +158,8 @@ | ... | @@ -152,8 +158,8 @@ |
152 | android:layout_below="@+id/tv_avg" | 158 | android:layout_below="@+id/tv_avg" |
153 | android:layout_alignParentEnd="true" | 159 | android:layout_alignParentEnd="true" |
154 | android:layout_marginTop="24dp" | 160 | android:layout_marginTop="24dp" |
155 | - android:paddingEnd="24dp" | ||
156 | android:layout_marginEnd="24dp" | 161 | android:layout_marginEnd="24dp" |
162 | + android:paddingEnd="24dp" | ||
157 | android:text="Touch Count" | 163 | android:text="Touch Count" |
158 | android:textColor="@color/blue_dark" | 164 | android:textColor="@color/blue_dark" |
159 | android:textSize="16sp" /> | 165 | android:textSize="16sp" /> |
... | @@ -201,8 +207,8 @@ | ... | @@ -201,8 +207,8 @@ |
201 | android:layout_height="wrap_content" | 207 | android:layout_height="wrap_content" |
202 | android:layout_below="@+id/tv_records" | 208 | android:layout_below="@+id/tv_records" |
203 | android:layout_alignParentStart="true" | 209 | android:layout_alignParentStart="true" |
204 | - android:layout_marginTop="24dp" | ||
205 | android:layout_marginStart="24dp" | 210 | android:layout_marginStart="24dp" |
211 | + android:layout_marginTop="24dp" | ||
206 | android:hint="Cut off in m/s^2" | 212 | android:hint="Cut off in m/s^2" |
207 | android:inputType="phone" | 213 | android:inputType="phone" |
208 | android:textColor="@color/blue_dark" | 214 | android:textColor="@color/blue_dark" |
... | @@ -215,12 +221,13 @@ | ... | @@ -215,12 +221,13 @@ |
215 | android:layout_height="wrap_content" | 221 | android:layout_height="wrap_content" |
216 | android:layout_below="@+id/tv_records" | 222 | android:layout_below="@+id/tv_records" |
217 | android:layout_alignParentEnd="true" | 223 | android:layout_alignParentEnd="true" |
218 | - android:paddingEnd="24dp" | ||
219 | android:layout_marginTop="24dp" | 224 | android:layout_marginTop="24dp" |
220 | android:hint="Sample Interval in ms" | 225 | android:hint="Sample Interval in ms" |
221 | android:inputType="phone" | 226 | android:inputType="phone" |
227 | + android:paddingEnd="24dp" | ||
222 | android:textColor="@color/blue_dark" | 228 | android:textColor="@color/blue_dark" |
223 | android:textSize="16sp" /> | 229 | android:textSize="16sp" /> |
230 | + </RelativeLayout> | ||
224 | 231 | ||
225 | <LinearLayout | 232 | <LinearLayout |
226 | android:id="@+id/ll_activate_button" | 233 | android:id="@+id/ll_activate_button" |
... | @@ -244,6 +251,6 @@ | ... | @@ -244,6 +251,6 @@ |
244 | android:textColor="@color/blue_dark" | 251 | android:textColor="@color/blue_dark" |
245 | android:textSize="16sp" /> | 252 | android:textSize="16sp" /> |
246 | </LinearLayout> | 253 | </LinearLayout> |
247 | - </RelativeLayout> | 254 | + </LinearLayout> |
248 | </ScrollView> | 255 | </ScrollView> |
249 | </LinearLayout> | 256 | </LinearLayout> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment