Panagiotis Triantafyllou

cosmote intent dl fixes

......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4.6rc63'
PUBLISH_VERSION = '4.5.4.6rc64'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -22,6 +22,7 @@ import android.view.WindowManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
......@@ -90,6 +91,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
private String mStartTimestamp = "", mStopTimestamp = "";
private final int RECORDS_INTERVAL = 5000;
private EditText mEtLimit, mEtSampleTime;
private RelativeLayout mRlMainScroll;
// ===========================================================
......@@ -105,6 +107,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
mIvBack = findViewById(R.id.iv_telematics_close);
mLlTripButton = findViewById(R.id.ll_activate_button);
mLlTripButton.setOnClickListener(this);
mLlTripButton.setOnTouchListener(mTripTouchListener);
mTvTripButton = findViewById(R.id.tv_trip_button);
mLlTelematicsMain = findViewById(R.id.ll_telematics_main);
mTvSensorData = findViewById(R.id.tv_sensor_data);
......@@ -116,6 +119,8 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
mTvTouchCount = findViewById(R.id.tv_touch);
mEtLimit = findViewById(R.id.et_acceleration);
mEtSampleTime = findViewById(R.id.et_save);
mRlMainScroll = findViewById(R.id.rl_main_scroll);
mRlMainScroll.setOnTouchListener(mScrollTouchListener);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
previousLocation = null;
......@@ -200,6 +205,8 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
}
if (view.getId() == R.id.ll_activate_button) {
if (mIsTripStarted) {
mEtLimit.setEnabled(true);
mEtSampleTime.setEnabled(true);
unregisterSensor();
stopLocationUpdates();
initViews();
......@@ -210,6 +217,8 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
Snackbar.make(mLlTelematicsMain, "Please fill the Cut off field", Snackbar.LENGTH_SHORT).show();
return;
}
mEtLimit.setEnabled(false);
mEtSampleTime.setEnabled(false);
mTouchHandler = new Handler();
mTouchRunnable = new Runnable() {
@Override
......@@ -292,28 +301,45 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
// return super.onTouchEvent(event);
if (mIsTripStarted) {
// touchCount++;
// mTvTouchCount.setText(String.valueOf(touchCount));
// return true;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
touchCount++;
mTvTouchCount.setText(String.valueOf(touchCount));
mTouchHandler.post(mTouchRunnable);
return true;
case MotionEvent.ACTION_UP:
mTouchHandler.removeCallbacks(mTouchRunnable);
return true;
}
return false;
}
return false;
}
// @Override
// public boolean dispatchTouchEvent(MotionEvent event) {
// if (mIsTripStarted) {
// switch (event.getAction()) {
// case MotionEvent.ACTION_DOWN:
// touchCount++;
// mTvTouchCount.setText(String.valueOf(touchCount));
// mTouchHandler.post(mTouchRunnable);
// return true;
// case MotionEvent.ACTION_UP:
// mTouchHandler.removeCallbacks(mTouchRunnable);
// return true;
// }
// }
// return super.dispatchTouchEvent(event);
// }
// @Override
// public boolean onTouchEvent(MotionEvent event) {
//// return super.onTouchEvent(event);
// if (mIsTripStarted) {
//// touchCount++;
//// mTvTouchCount.setText(String.valueOf(touchCount));
//// return true;
//
// switch (event.getAction()) {
// case MotionEvent.ACTION_DOWN:
// touchCount++;
// mTvTouchCount.setText(String.valueOf(touchCount));
// mTouchHandler.post(mTouchRunnable);
// return true;
// case MotionEvent.ACTION_UP:
// mTouchHandler.removeCallbacks(mTouchRunnable);
// return true;
// }
// return false;
// }
// return false;
// }
// ===========================================================
// Methods
......@@ -495,6 +521,39 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
}
}
private final View.OnTouchListener mTripTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (mIsTripStarted) {
if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
mTouchHandler.removeCallbacks(mTouchRunnable);
onClick(view);
return true;
}
}
return false;
}
};
private final View.OnTouchListener mScrollTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (mIsTripStarted) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
touchCount++;
mTvTouchCount.setText(String.valueOf(touchCount));
mTouchHandler.post(mTouchRunnable);
return true;
case MotionEvent.ACTION_UP:
mTouchHandler.removeCallbacks(mTouchRunnable);
return true;
}
}
return false;
}
};
// // Low-pass filter function using Exponential Moving Average (EMA)
// private float lowPassFilter(float currentValue) {
// float filteredValue = alpha * currentValue + (1 - alpha) * previousFilteredValue;
......
......@@ -43,6 +43,7 @@ import android.net.http.SslError;
import android.os.Build;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.webkit.GeolocationPermissions.Callback;
import android.webkit.JavascriptInterface;
import android.webkit.SslErrorHandler;
......@@ -75,6 +76,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.LinkedHashMap;
......@@ -107,6 +109,7 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
private static final String URL_ACTION_RSMS = "rsms";
private static final String URL_ACTION_MAIL = "mailto";
private static final String URL_ACTION_MARKET = "market";
private static final String URL_ACTION_INTENT = "intent";
private static final String URL_ACTION_MARKET_AUTHORITY = "play.google.com";
private static final String TAG_STEPS_WORKER = "ly.warp.sdk.services.WarplyHealthService";
......@@ -789,6 +792,21 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
getContext().startActivity(intent);
return true;
} else if (scheme.equalsIgnoreCase(URL_ACTION_INTENT)) {
try {
Intent intent = Intent.parseUri(strUrl, Intent.URI_INTENT_SCHEME);
// String fallbackUrl = intent.getStringExtra("browser_fallback_url");
String data = intent.getData().toString();
if (!TextUtils.isEmpty(data)) {
// view.loadUrl(fallbackUrl);
Uri webpage = Uri.parse(data);
Intent intentWebpage = new Intent(Intent.ACTION_VIEW, webpage);
getContext().startActivity(intentWebpage);
return true;
}
} catch (URISyntaxException e) {
return true;
}
}
return false;
}
......