Panagiotis Triantafyllou

new login implementation with JWT, new logout, optimizations

......@@ -36,9 +36,10 @@ public class SplashActivity extends BaseActivity {
@Override
public void onWarplyReady() {
if (!WarplyDBHelper.getInstance(SplashActivity.this).isTableNotEmpty("auth")) {
WarplyManager.getCosmoteUser(new WarplyCosmoteUserRequest()
.setGuid("7000023717"), //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons, prod 6006552990, prod 6005892749, live 3000184910,prod 7000070282
mLoginReceiver);
//6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons
//prod 6006552990, prod 6005892749, live 3000184910,prod 7000070282
WarplyManager.getCosmoteUser("7000000833", mLoginReceiver);
// WarplyManager.verifyTicket("", "7000000833", mLoginReceiver);
} else {
startNextActivity();
}
......
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.5.4r18'
PUBLISH_VERSION = '4.5.5.4r19'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......@@ -112,6 +112,9 @@ dependencies {
//------------------------------ Lifecycle -----------------------------//
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
//------------------------------ Retrofit Logs -----------------------------//
// implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
}
// In every export please update the version number
......
......@@ -18,6 +18,8 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import org.json.JSONObject;
import java.util.ArrayList;
import ly.warp.sdk.R;
......@@ -120,6 +122,10 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
if (view.getId() == R.id.rl_driving_history) {
Intent intent = new Intent(getContext(), TelematicsHistoryActivity.class);
startActivity(intent);
return;
}
if (view.getId() == R.id.iv_settings) {
WarplyManager.logout(mLogoutReceiver);
}
}
......@@ -152,4 +158,16 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
Toast.makeText(getActivity(), "Coupons Error", Toast.LENGTH_SHORT).show();
}
};
private final CallbackReceiver<JSONObject> mLogoutReceiver = new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
Toast.makeText(getActivity(), "LOGOUT SUCCESS", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(int errorCode) {
Toast.makeText(getActivity(), "LOGOUT ERROR", Toast.LENGTH_SHORT).show();
}
};
}
\ No newline at end of file
......
......@@ -47,7 +47,12 @@ public class ApiClient {
}
private static OkHttpClient getClient() {
/* Logs Enabled */
// HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
// interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
return new OkHttpClient.Builder()
// .addInterceptor(interceptor) // Logs Enabled
.connectTimeout(30, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
......
......@@ -44,6 +44,39 @@ public interface ApiService {
@Header(WarpConstants.HEADER_SIGNATURE) String signature);
@Headers("Content-Type: application/json")
@POST("/partners/oauth/{appUuid}/token")
Call<ResponseBody> cosmoteUser(@Path("appUuid") String appUuid,
@Body RequestBody request,
@Header(WarpConstants.HEADER_DATE) String timeStamp,
@Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
@Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId,
@Header(WarpConstants.HEADER_CHANNEL) String channel,
@Header(WarpConstants.HEADER_WEB_ID) String webId,
@Header(WarpConstants.HEADER_SIGNATURE) String signature,
@Header(WarpConstants.HEADER_AUTHORIZATION) String basic);
@Headers("Content-Type: application/json")
@POST("/partners/cosmote/verify")
Call<ResponseBody> verifyUser(@Body RequestBody request,
@Header(WarpConstants.HEADER_DATE) String timeStamp,
@Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
@Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId,
@Header(WarpConstants.HEADER_CHANNEL) String channel,
@Header(WarpConstants.HEADER_WEB_ID) String webId,
@Header(WarpConstants.HEADER_SIGNATURE) String signature);
@Headers("Content-Type: application/json")
@POST("/oauth/{appUuid}/logout")
Call<ResponseBody> logoutUser(@Path("appUuid") String appUuid,
@Body RequestBody request,
@Header(WarpConstants.HEADER_DATE) String timeStamp,
@Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
@Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId,
@Header(WarpConstants.HEADER_CHANNEL) String channel,
@Header(WarpConstants.HEADER_WEB_ID) String webId,
@Header(WarpConstants.HEADER_SIGNATURE) String signature);
@Headers("Content-Type: application/json")
@POST("/oauth/{appUuid}/context")
Call<ResponseBody> getCouponsets(@Path("appUuid") String appUuid,
@Body RequestBody request,
......