Panagiotis Triantafyllou

new login implementation with JWT, new logout, optimizations

...@@ -36,9 +36,10 @@ public class SplashActivity extends BaseActivity { ...@@ -36,9 +36,10 @@ public class SplashActivity extends BaseActivity {
36 @Override 36 @Override
37 public void onWarplyReady() { 37 public void onWarplyReady() {
38 if (!WarplyDBHelper.getInstance(SplashActivity.this).isTableNotEmpty("auth")) { 38 if (!WarplyDBHelper.getInstance(SplashActivity.this).isTableNotEmpty("auth")) {
39 - WarplyManager.getCosmoteUser(new WarplyCosmoteUserRequest() 39 + //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons
40 - .setGuid("7000023717"), //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons, prod 6006552990, prod 6005892749, live 3000184910,prod 7000070282 40 + //prod 6006552990, prod 6005892749, live 3000184910,prod 7000070282
41 - mLoginReceiver); 41 + WarplyManager.getCosmoteUser("7000000833", mLoginReceiver);
42 +// WarplyManager.verifyTicket("", "7000000833", mLoginReceiver);
42 } else { 43 } else {
43 startNextActivity(); 44 startNextActivity();
44 } 45 }
......
...@@ -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.5.4r18' 5 + PUBLISH_VERSION = '4.5.5.4r19'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
...@@ -112,6 +112,9 @@ dependencies { ...@@ -112,6 +112,9 @@ dependencies {
112 112
113 //------------------------------ Lifecycle -----------------------------// 113 //------------------------------ Lifecycle -----------------------------//
114 implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" 114 implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
115 +
116 + //------------------------------ Retrofit Logs -----------------------------//
117 +// implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
115 } 118 }
116 119
117 // In every export please update the version number 120 // In every export please update the version number
......
...@@ -18,6 +18,8 @@ import androidx.recyclerview.widget.LinearLayoutManager; ...@@ -18,6 +18,8 @@ import androidx.recyclerview.widget.LinearLayoutManager;
18 import androidx.recyclerview.widget.RecyclerView; 18 import androidx.recyclerview.widget.RecyclerView;
19 import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; 19 import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
20 20
21 +import org.json.JSONObject;
22 +
21 import java.util.ArrayList; 23 import java.util.ArrayList;
22 24
23 import ly.warp.sdk.R; 25 import ly.warp.sdk.R;
...@@ -120,6 +122,10 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip ...@@ -120,6 +122,10 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
120 if (view.getId() == R.id.rl_driving_history) { 122 if (view.getId() == R.id.rl_driving_history) {
121 Intent intent = new Intent(getContext(), TelematicsHistoryActivity.class); 123 Intent intent = new Intent(getContext(), TelematicsHistoryActivity.class);
122 startActivity(intent); 124 startActivity(intent);
125 + return;
126 + }
127 + if (view.getId() == R.id.iv_settings) {
128 + WarplyManager.logout(mLogoutReceiver);
123 } 129 }
124 } 130 }
125 131
...@@ -152,4 +158,16 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip ...@@ -152,4 +158,16 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
152 Toast.makeText(getActivity(), "Coupons Error", Toast.LENGTH_SHORT).show(); 158 Toast.makeText(getActivity(), "Coupons Error", Toast.LENGTH_SHORT).show();
153 } 159 }
154 }; 160 };
161 +
162 + private final CallbackReceiver<JSONObject> mLogoutReceiver = new CallbackReceiver<JSONObject>() {
163 + @Override
164 + public void onSuccess(JSONObject result) {
165 + Toast.makeText(getActivity(), "LOGOUT SUCCESS", Toast.LENGTH_SHORT).show();
166 + }
167 +
168 + @Override
169 + public void onFailure(int errorCode) {
170 + Toast.makeText(getActivity(), "LOGOUT ERROR", Toast.LENGTH_SHORT).show();
171 + }
172 + };
155 } 173 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -47,7 +47,12 @@ public class ApiClient { ...@@ -47,7 +47,12 @@ public class ApiClient {
47 } 47 }
48 48
49 private static OkHttpClient getClient() { 49 private static OkHttpClient getClient() {
50 + /* Logs Enabled */
51 +// HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
52 +// interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
53 +
50 return new OkHttpClient.Builder() 54 return new OkHttpClient.Builder()
55 +// .addInterceptor(interceptor) // Logs Enabled
51 .connectTimeout(30, TimeUnit.SECONDS) 56 .connectTimeout(30, TimeUnit.SECONDS)
52 .writeTimeout(30, TimeUnit.SECONDS) 57 .writeTimeout(30, TimeUnit.SECONDS)
53 .readTimeout(30, TimeUnit.SECONDS) 58 .readTimeout(30, TimeUnit.SECONDS)
......
...@@ -44,6 +44,39 @@ public interface ApiService { ...@@ -44,6 +44,39 @@ public interface ApiService {
44 @Header(WarpConstants.HEADER_SIGNATURE) String signature); 44 @Header(WarpConstants.HEADER_SIGNATURE) String signature);
45 45
46 @Headers("Content-Type: application/json") 46 @Headers("Content-Type: application/json")
47 + @POST("/partners/oauth/{appUuid}/token")
48 + Call<ResponseBody> cosmoteUser(@Path("appUuid") String appUuid,
49 + @Body RequestBody request,
50 + @Header(WarpConstants.HEADER_DATE) String timeStamp,
51 + @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
52 + @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId,
53 + @Header(WarpConstants.HEADER_CHANNEL) String channel,
54 + @Header(WarpConstants.HEADER_WEB_ID) String webId,
55 + @Header(WarpConstants.HEADER_SIGNATURE) String signature,
56 + @Header(WarpConstants.HEADER_AUTHORIZATION) String basic);
57 +
58 + @Headers("Content-Type: application/json")
59 + @POST("/partners/cosmote/verify")
60 + Call<ResponseBody> verifyUser(@Body RequestBody request,
61 + @Header(WarpConstants.HEADER_DATE) String timeStamp,
62 + @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
63 + @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId,
64 + @Header(WarpConstants.HEADER_CHANNEL) String channel,
65 + @Header(WarpConstants.HEADER_WEB_ID) String webId,
66 + @Header(WarpConstants.HEADER_SIGNATURE) String signature);
67 +
68 + @Headers("Content-Type: application/json")
69 + @POST("/oauth/{appUuid}/logout")
70 + Call<ResponseBody> logoutUser(@Path("appUuid") String appUuid,
71 + @Body RequestBody request,
72 + @Header(WarpConstants.HEADER_DATE) String timeStamp,
73 + @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
74 + @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId,
75 + @Header(WarpConstants.HEADER_CHANNEL) String channel,
76 + @Header(WarpConstants.HEADER_WEB_ID) String webId,
77 + @Header(WarpConstants.HEADER_SIGNATURE) String signature);
78 +
79 + @Headers("Content-Type: application/json")
47 @POST("/oauth/{appUuid}/context") 80 @POST("/oauth/{appUuid}/context")
48 Call<ResponseBody> getCouponsets(@Path("appUuid") String appUuid, 81 Call<ResponseBody> getCouponsets(@Path("appUuid") String appUuid,
49 @Body RequestBody request, 82 @Body RequestBody request,
......