Showing
4 changed files
with
100 additions
and
23 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()) { |
299 | -// touchCount++; | 308 | +// case MotionEvent.ACTION_DOWN: |
300 | -// mTvTouchCount.setText(String.valueOf(touchCount)); | 309 | +// touchCount++; |
301 | -// return true; | 310 | +// mTvTouchCount.setText(String.valueOf(touchCount)); |
302 | - | 311 | +// mTouchHandler.post(mTouchRunnable); |
303 | - switch (event.getAction()) { | 312 | +// return true; |
304 | - case MotionEvent.ACTION_DOWN: | 313 | +// case MotionEvent.ACTION_UP: |
305 | - touchCount++; | 314 | +// mTouchHandler.removeCallbacks(mTouchRunnable); |
306 | - mTvTouchCount.setText(String.valueOf(touchCount)); | 315 | +// return true; |
307 | - mTouchHandler.post(mTouchRunnable); | 316 | +// } |
308 | - return true; | 317 | +// } |
309 | - case MotionEvent.ACTION_UP: | 318 | +// return super.dispatchTouchEvent(event); |
310 | - mTouchHandler.removeCallbacks(mTouchRunnable); | 319 | +// } |
311 | - return true; | 320 | + |
312 | - } | 321 | +// @Override |
313 | - return false; | 322 | +// public boolean onTouchEvent(MotionEvent event) { |
314 | - } | 323 | +//// return super.onTouchEvent(event); |
315 | - return false; | 324 | +// if (mIsTripStarted) { |
316 | - } | 325 | +//// touchCount++; |
326 | +//// mTvTouchCount.setText(String.valueOf(touchCount)); | ||
327 | +//// return true; | ||
328 | +// | ||
329 | +// switch (event.getAction()) { | ||
330 | +// case MotionEvent.ACTION_DOWN: | ||
331 | +// touchCount++; | ||
332 | +// mTvTouchCount.setText(String.valueOf(touchCount)); | ||
333 | +// mTouchHandler.post(mTouchRunnable); | ||
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 | } | ... | ... |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment