Panagiotis Triantafyllou

sdk optimizations

...@@ -2,25 +2,15 @@ package warp.ly.android_sdk.activities; ...@@ -2,25 +2,15 @@ package warp.ly.android_sdk.activities;
2 2
3 import android.content.Intent; 3 import android.content.Intent;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 -import android.widget.Toast;
6 -
7 -import org.json.JSONObject;
8 5
9 import java.util.Timer; 6 import java.util.Timer;
10 import java.util.TimerTask; 7 import java.util.TimerTask;
11 8
12 import ly.warp.sdk.Warply; 9 import ly.warp.sdk.Warply;
13 import ly.warp.sdk.activities.BaseFragmentActivity; 10 import ly.warp.sdk.activities.BaseFragmentActivity;
14 -import ly.warp.sdk.db.WarplyDBHelper;
15 -import ly.warp.sdk.io.callbacks.CallbackReceiver;
16 import ly.warp.sdk.io.callbacks.SimpleCallbackReceiver; 11 import ly.warp.sdk.io.callbacks.SimpleCallbackReceiver;
17 import ly.warp.sdk.io.callbacks.WarplyReadyCallback; 12 import ly.warp.sdk.io.callbacks.WarplyReadyCallback;
18 -import ly.warp.sdk.io.request.WarplyConsumerRequest;
19 -import ly.warp.sdk.io.request.WarplyCosmoteUserRequest;
20 -import ly.warp.sdk.io.request.WarplyLoginRequest;
21 -import ly.warp.sdk.io.request.WarplyVerifyTicketRequest;
22 import ly.warp.sdk.utils.WarplyInitializer; 13 import ly.warp.sdk.utils.WarplyInitializer;
23 -import ly.warp.sdk.utils.managers.WarplyManager;
24 import warp.ly.android_sdk.R; 14 import warp.ly.android_sdk.R;
25 15
26 public class SplashActivity extends BaseActivity { 16 public class SplashActivity extends BaseActivity {
...@@ -35,15 +25,8 @@ public class SplashActivity extends BaseActivity { ...@@ -35,15 +25,8 @@ public class SplashActivity extends BaseActivity {
35 mWarplyInitializer = Warply.getInitializer(this, new WarplyReadyCallback() { 25 mWarplyInitializer = Warply.getInitializer(this, new WarplyReadyCallback() {
36 @Override 26 @Override
37 public void onWarplyReady() { 27 public void onWarplyReady() {
38 - if (!WarplyDBHelper.getInstance(SplashActivity.this).isTableNotEmpty("auth")) {
39 - //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons
40 - //prod 6006552990, prod 6005892749, live 3000184910,prod 7000070282, live 3000136179
41 - WarplyManager.getCosmoteUser("7000001053", mLoginReceiver);
42 -// WarplyManager.verifyTicket("", "7000023699", mLoginReceiver);
43 - } else {
44 startNextActivity(); 28 startNextActivity();
45 } 29 }
46 - }
47 30
48 @Override 31 @Override
49 public void onWarplyInitTimeOut() { 32 public void onWarplyInitTimeOut() {
...@@ -93,19 +76,4 @@ public class SplashActivity extends BaseActivity { ...@@ -93,19 +76,4 @@ public class SplashActivity extends BaseActivity {
93 }, MIN_SPLASH_TIME); 76 }, MIN_SPLASH_TIME);
94 } 77 }
95 } 78 }
96 -
97 - private final CallbackReceiver<JSONObject> mLoginReceiver = new CallbackReceiver<JSONObject>() {
98 - @Override
99 - public void onSuccess(JSONObject result) {
100 - if (result != null && result.optInt("status") == 1) {
101 - startNextActivity();
102 - }
103 - }
104 -
105 - @Override
106 - public void onFailure(int errorCode) {
107 -// startNextActivity();
108 - Toast.makeText(SplashActivity.this, "LOGIN ERROR", Toast.LENGTH_SHORT).show();
109 - }
110 - };
111 } 79 }
......
...@@ -19,6 +19,7 @@ import com.google.android.material.navigation.NavigationBarView; ...@@ -19,6 +19,7 @@ import com.google.android.material.navigation.NavigationBarView;
19 import java.util.ArrayList; 19 import java.util.ArrayList;
20 20
21 import ly.warp.sdk.R; 21 import ly.warp.sdk.R;
22 +import ly.warp.sdk.db.WarplyDBHelper;
22 import ly.warp.sdk.fragments.HomeFragment; 23 import ly.warp.sdk.fragments.HomeFragment;
23 import ly.warp.sdk.fragments.LoyaltyFragment; 24 import ly.warp.sdk.fragments.LoyaltyFragment;
24 import ly.warp.sdk.fragments.MyRewardsFragment; 25 import ly.warp.sdk.fragments.MyRewardsFragment;
...@@ -53,9 +54,11 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation ...@@ -53,9 +54,11 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
53 54
54 mBottomNavigationView = findViewById(R.id.bt_tabs); 55 mBottomNavigationView = findViewById(R.id.bt_tabs);
55 56
57 + if (WarplyDBHelper.getInstance(this).isTableNotEmpty("auth")) {
56 WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver); 58 WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
57 WarplyManager.getCampaigns(mCampaignsCallback); 59 WarplyManager.getCampaigns(mCampaignsCallback);
58 WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback); 60 WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback);
61 + }
59 62
60 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { 63 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
61 if (!hasNotificationPermission()) { 64 if (!hasNotificationPermission()) {
......
...@@ -40,7 +40,7 @@ public class WarplyDBHelper extends SQLiteOpenHelper { ...@@ -40,7 +40,7 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
40 } 40 }
41 41
42 private static final String DB_NAME = "warply.db"; 42 private static final String DB_NAME = "warply.db";
43 - private static final int DB_VERSION = 10; 43 + private static final int DB_VERSION = 12;
44 private static final String KEY_CIPHER = "tn#mpOl3v3Dy1pr@W"; 44 private static final String KEY_CIPHER = "tn#mpOl3v3Dy1pr@W";
45 45
46 //------------------------------ Fields -----------------------------// 46 //------------------------------ Fields -----------------------------//
...@@ -154,6 +154,19 @@ public class WarplyDBHelper extends SQLiteOpenHelper { ...@@ -154,6 +154,19 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
154 return mDb; 154 return mDb;
155 } 155 }
156 156
157 + private SQLiteDatabase getReadableDb() {
158 + if (mDb == null)
159 + mDb = getReadableDatabase(KEY_CIPHER);
160 + return mDb;
161 + }
162 +
163 + private void closeDb() {
164 + if (mDb != null && mDb.isOpen()) {
165 + mDb.close();
166 + mDb = null;
167 + }
168 + }
169 +
157 @Override 170 @Override
158 public void onCreate(SQLiteDatabase db) { 171 public void onCreate(SQLiteDatabase db) {
159 db.execSQL(CREATE_TABLE_REQUESTS); 172 db.execSQL(CREATE_TABLE_REQUESTS);
...@@ -215,28 +228,37 @@ public class WarplyDBHelper extends SQLiteOpenHelper { ...@@ -215,28 +228,37 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
215 public synchronized void clearTable(String tableName) { 228 public synchronized void clearTable(String tableName) {
216 SQLiteDatabase db = getDb(); 229 SQLiteDatabase db = getDb();
217 db.delete(tableName, null, null); 230 db.delete(tableName, null, null);
231 +
232 + closeDb();
218 } 233 }
219 234
220 public synchronized void insert(String tableName, ContentValues values) { 235 public synchronized void insert(String tableName, ContentValues values) {
221 SQLiteDatabase db = getDb(); 236 SQLiteDatabase db = getDb();
222 db.insert(tableName, null, values); 237 db.insert(tableName, null, values);
238 +
239 + closeDb();
223 } 240 }
224 241
225 public synchronized void update(String tableName, ContentValues values) { 242 public synchronized void update(String tableName, ContentValues values) {
226 SQLiteDatabase db = getDb(); 243 SQLiteDatabase db = getDb();
227 db.update(tableName, values, null, null); 244 db.update(tableName, values, null, null);
245 +
246 + closeDb();
228 } 247 }
229 248
230 public synchronized boolean isTableNotEmpty(String tableName) { 249 public synchronized boolean isTableNotEmpty(String tableName) {
231 - Cursor cursor = getDb().rawQuery("SELECT COUNT(*) FROM " + tableName, 250 + Cursor cursor = getReadableDb().rawQuery("SELECT COUNT(*) FROM " + tableName,
232 null); 251 null);
233 if (cursor != null && cursor.moveToFirst()) { 252 if (cursor != null && cursor.moveToFirst()) {
234 boolean isNotEmpty = cursor.getInt(0) > 0; 253 boolean isNotEmpty = cursor.getInt(0) > 0;
235 cursor.close(); 254 cursor.close();
255 + closeDb();
236 return isNotEmpty; 256 return isNotEmpty;
237 - } else 257 + } else {
258 + closeDb();
238 return false; 259 return false;
239 } 260 }
261 + }
240 262
241 //------------------------------ Auth -----------------------------// 263 //------------------------------ Auth -----------------------------//
242 public synchronized void saveClientAccess(String clientId, String clientSecret) { 264 public synchronized void saveClientAccess(String clientId, String clientSecret) {
...@@ -266,24 +288,30 @@ public class WarplyDBHelper extends SQLiteOpenHelper { ...@@ -266,24 +288,30 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
266 @Nullable 288 @Nullable
267 public synchronized String getAuthValue(String columnName) { 289 public synchronized String getAuthValue(String columnName) {
268 String columnValue = ""; 290 String columnValue = "";
269 - Cursor cursor = getDb().query(TABLE_AUTH, new String[]{columnName}, null, null, null, null, null); 291 + Cursor cursor = getReadableDb().query(TABLE_AUTH, new String[]{columnName}, null, null, null, null, null);
270 if (cursor != null && cursor.moveToFirst()) { 292 if (cursor != null && cursor.moveToFirst()) {
271 cursor.moveToFirst(); 293 cursor.moveToFirst();
272 columnValue = cursor.getString(cursor.getColumnIndex(columnName)); 294 columnValue = cursor.getString(cursor.getColumnIndex(columnName));
273 cursor.close(); 295 cursor.close();
274 } 296 }
297 +
298 + closeDb();
299 +
275 return columnValue; 300 return columnValue;
276 } 301 }
277 302
278 @Nullable 303 @Nullable
279 public synchronized String getClientValue(String columnName) { 304 public synchronized String getClientValue(String columnName) {
280 String columnValue = ""; 305 String columnValue = "";
281 - Cursor cursor = getDb().query(TABLE_CLIENT, new String[]{columnName}, null, null, null, null, null); 306 + Cursor cursor = getReadableDb().query(TABLE_CLIENT, new String[]{columnName}, null, null, null, null, null);
282 if (cursor != null && cursor.moveToFirst()) { 307 if (cursor != null && cursor.moveToFirst()) {
283 cursor.moveToFirst(); 308 cursor.moveToFirst();
284 columnValue = cursor.getString(cursor.getColumnIndex(columnName)); 309 columnValue = cursor.getString(cursor.getColumnIndex(columnName));
285 cursor.close(); 310 cursor.close();
286 } 311 }
312 +
313 + closeDb();
314 +
287 return columnValue; 315 return columnValue;
288 } 316 }
289 317
...@@ -297,24 +325,21 @@ public class WarplyDBHelper extends SQLiteOpenHelper { ...@@ -297,24 +325,21 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
297 325
298 //------------------------------ Api requests -----------------------------// 326 //------------------------------ Api requests -----------------------------//
299 public synchronized Cursor getAllRequests() { 327 public synchronized Cursor getAllRequests() {
300 - 328 + return getReadableDb().query(TABLE_REQUESTS,
301 - return getDb().query(TABLE_REQUESTS,
302 new String[]{KEY_REQUESTS_ID, 329 new String[]{KEY_REQUESTS_ID,
303 KEY_REQUESTS_MICROAPP, KEY_REQUESTS_ENTITY}, null, null, null, null, 330 KEY_REQUESTS_MICROAPP, KEY_REQUESTS_ENTITY}, null, null, null, null,
304 KEY_REQUESTS_DATE_ADDED + " asc", "20"); 331 KEY_REQUESTS_DATE_ADDED + " asc", "20");
305 } 332 }
306 333
307 public synchronized Cursor getAllPushRequests() { 334 public synchronized Cursor getAllPushRequests() {
308 - 335 + return getReadableDb().query(TABLE_PUSH_REQUESTS,
309 - return getDb().query(TABLE_PUSH_REQUESTS,
310 new String[]{KEY_REQUESTS_ID, 336 new String[]{KEY_REQUESTS_ID,
311 KEY_REQUESTS_MICROAPP, KEY_REQUESTS_ENTITY}, null, null, null, null, 337 KEY_REQUESTS_MICROAPP, KEY_REQUESTS_ENTITY}, null, null, null, null,
312 KEY_REQUESTS_DATE_ADDED + " asc", "20"); 338 KEY_REQUESTS_DATE_ADDED + " asc", "20");
313 } 339 }
314 340
315 public synchronized Cursor getAllPushAckRequests() { 341 public synchronized Cursor getAllPushAckRequests() {
316 - 342 + return getReadableDb().query(TABLE_PUSH_ACK_REQUESTS,
317 - return getDb().query(TABLE_PUSH_ACK_REQUESTS,
318 new String[]{KEY_REQUESTS_ID, 343 new String[]{KEY_REQUESTS_ID,
319 KEY_REQUESTS_MICROAPP, KEY_REQUESTS_ENTITY}, null, null, null, null, 344 KEY_REQUESTS_MICROAPP, KEY_REQUESTS_ENTITY}, null, null, null, null,
320 KEY_REQUESTS_DATE_ADDED + " asc", "20"); 345 KEY_REQUESTS_DATE_ADDED + " asc", "20");
...@@ -375,7 +400,6 @@ public class WarplyDBHelper extends SQLiteOpenHelper { ...@@ -375,7 +400,6 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
375 } 400 }
376 401
377 public synchronized void deleteRequests(Long... ids) { 402 public synchronized void deleteRequests(Long... ids) {
378 -
379 StringBuilder strFilter = new StringBuilder(); 403 StringBuilder strFilter = new StringBuilder();
380 for (int i = 0; i < ids.length; i++) { 404 for (int i = 0; i < ids.length; i++) {
381 if (i > 0) { 405 if (i > 0) {
...@@ -386,10 +410,11 @@ public class WarplyDBHelper extends SQLiteOpenHelper { ...@@ -386,10 +410,11 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
386 strFilter.append(ids[i]); 410 strFilter.append(ids[i]);
387 } 411 }
388 getDb().delete(TABLE_REQUESTS, strFilter.toString(), null); 412 getDb().delete(TABLE_REQUESTS, strFilter.toString(), null);
413 +
414 + closeDb();
389 } 415 }
390 416
391 public synchronized void deletePushRequests(Long... ids) { 417 public synchronized void deletePushRequests(Long... ids) {
392 -
393 StringBuilder strFilter = new StringBuilder(); 418 StringBuilder strFilter = new StringBuilder();
394 for (int i = 0; i < ids.length; i++) { 419 for (int i = 0; i < ids.length; i++) {
395 if (i > 0) { 420 if (i > 0) {
...@@ -400,10 +425,11 @@ public class WarplyDBHelper extends SQLiteOpenHelper { ...@@ -400,10 +425,11 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
400 strFilter.append(ids[i]); 425 strFilter.append(ids[i]);
401 } 426 }
402 getDb().delete(TABLE_PUSH_REQUESTS, strFilter.toString(), null); 427 getDb().delete(TABLE_PUSH_REQUESTS, strFilter.toString(), null);
428 +
429 + closeDb();
403 } 430 }
404 431
405 public synchronized void deletePushAckRequests(Long... ids) { 432 public synchronized void deletePushAckRequests(Long... ids) {
406 -
407 StringBuilder strFilter = new StringBuilder(); 433 StringBuilder strFilter = new StringBuilder();
408 for (int i = 0; i < ids.length; i++) { 434 for (int i = 0; i < ids.length; i++) {
409 if (i > 0) { 435 if (i > 0) {
...@@ -414,45 +440,55 @@ public class WarplyDBHelper extends SQLiteOpenHelper { ...@@ -414,45 +440,55 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
414 strFilter.append(ids[i]); 440 strFilter.append(ids[i]);
415 } 441 }
416 getDb().delete(TABLE_PUSH_ACK_REQUESTS, strFilter.toString(), null); 442 getDb().delete(TABLE_PUSH_ACK_REQUESTS, strFilter.toString(), null);
443 +
444 + closeDb();
417 } 445 }
418 446
419 public synchronized boolean isForceRequestsExist() { 447 public synchronized boolean isForceRequestsExist() {
420 - Cursor cursor = getDb().query(TABLE_REQUESTS, null, KEY_REQUESTS_FORCE + "=1", 448 + Cursor cursor = getReadableDb().query(TABLE_REQUESTS, null, KEY_REQUESTS_FORCE + "=1",
421 null, null, null, null); 449 null, null, null, null);
422 boolean result = false; 450 boolean result = false;
423 if (cursor != null) { 451 if (cursor != null) {
424 result = cursor.getCount() > 0; 452 result = cursor.getCount() > 0;
425 cursor.close(); 453 cursor.close();
426 } 454 }
455 +
456 + closeDb();
457 +
427 return result; 458 return result;
428 } 459 }
429 460
430 public synchronized boolean isForcePushRequestsExist() { 461 public synchronized boolean isForcePushRequestsExist() {
431 - Cursor cursor = getDb().query(TABLE_PUSH_REQUESTS, null, KEY_REQUESTS_FORCE + "=1", 462 + Cursor cursor = getReadableDb().query(TABLE_PUSH_REQUESTS, null, KEY_REQUESTS_FORCE + "=1",
432 null, null, null, null); 463 null, null, null, null);
433 boolean result = false; 464 boolean result = false;
434 if (cursor != null) { 465 if (cursor != null) {
435 result = cursor.getCount() > 0; 466 result = cursor.getCount() > 0;
436 cursor.close(); 467 cursor.close();
437 } 468 }
469 +
470 + closeDb();
471 +
438 return result; 472 return result;
439 } 473 }
440 474
441 public synchronized boolean isForcePushAckRequestsExist() { 475 public synchronized boolean isForcePushAckRequestsExist() {
442 - Cursor cursor = getDb().query(TABLE_PUSH_ACK_REQUESTS, null, KEY_REQUESTS_FORCE + "=1", 476 + Cursor cursor = getReadableDb().query(TABLE_PUSH_ACK_REQUESTS, null, KEY_REQUESTS_FORCE + "=1",
443 null, null, null, null); 477 null, null, null, null);
444 boolean result = false; 478 boolean result = false;
445 if (cursor != null) { 479 if (cursor != null) {
446 result = cursor.getCount() > 0; 480 result = cursor.getCount() > 0;
447 cursor.close(); 481 cursor.close();
448 } 482 }
483 +
484 + closeDb();
485 +
449 return result; 486 return result;
450 } 487 }
451 488
452 //------------------------------ Tags -----------------------------// 489 //------------------------------ Tags -----------------------------//
453 public synchronized void saveTags(String[] tags) { 490 public synchronized void saveTags(String[] tags) {
454 if (tags != null && tags.length > 0) { 491 if (tags != null && tags.length > 0) {
455 -
456 try { 492 try {
457 getDb().beginTransaction(); 493 getDb().beginTransaction();
458 ContentValues values = new ContentValues(); 494 ContentValues values = new ContentValues();
...@@ -464,11 +500,14 @@ public class WarplyDBHelper extends SQLiteOpenHelper { ...@@ -464,11 +500,14 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
464 getDb().setTransactionSuccessful(); 500 getDb().setTransactionSuccessful();
465 501
466 } catch (SQLException e) { 502 } catch (SQLException e) {
503 + closeDb();
467 if (WarpConstants.DEBUG) { 504 if (WarpConstants.DEBUG) {
468 e.printStackTrace(); 505 e.printStackTrace();
469 } 506 }
470 } finally { 507 } finally {
471 getDb().endTransaction(); 508 getDb().endTransaction();
509 +
510 + closeDb();
472 } 511 }
473 } 512 }
474 } 513 }
...@@ -505,6 +544,7 @@ public class WarplyDBHelper extends SQLiteOpenHelper { ...@@ -505,6 +544,7 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
505 strFilter.append("'"); 544 strFilter.append("'");
506 } 545 }
507 getDb().delete(TABLE_TAGS, strFilter.toString(), null); 546 getDb().delete(TABLE_TAGS, strFilter.toString(), null);
547 + closeDb();
508 } 548 }
509 549
510 public synchronized void removeAllTags() { 550 public synchronized void removeAllTags() {
...@@ -515,7 +555,7 @@ public class WarplyDBHelper extends SQLiteOpenHelper { ...@@ -515,7 +555,7 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
515 public synchronized String[] getTags() { 555 public synchronized String[] getTags() {
516 556
517 List<String> tags = null; 557 List<String> tags = null;
518 - Cursor cursor = getDb().query(TABLE_TAGS, null, null, null, null, null, null); 558 + Cursor cursor = getReadableDb().query(TABLE_TAGS, null, null, null, null, null, null);
519 if (cursor != null) { 559 if (cursor != null) {
520 560
521 tags = new ArrayList<>(cursor.getCount()); 561 tags = new ArrayList<>(cursor.getCount());
...@@ -525,6 +565,9 @@ public class WarplyDBHelper extends SQLiteOpenHelper { ...@@ -525,6 +565,9 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
525 } 565 }
526 cursor.close(); 566 cursor.close();
527 } 567 }
568 +
569 + closeDb();
570 +
528 return tags != null ? tags.toArray(new String[tags.size()]) : null; 571 return tags != null ? tags.toArray(new String[tags.size()]) : null;
529 } 572 }
530 573
......
...@@ -5,6 +5,7 @@ import android.os.Bundle; ...@@ -5,6 +5,7 @@ import android.os.Bundle;
5 import android.view.LayoutInflater; 5 import android.view.LayoutInflater;
6 import android.view.View; 6 import android.view.View;
7 import android.view.ViewGroup; 7 import android.view.ViewGroup;
8 +import android.widget.EditText;
8 import android.widget.ImageView; 9 import android.widget.ImageView;
9 import android.widget.LinearLayout; 10 import android.widget.LinearLayout;
10 import android.widget.RelativeLayout; 11 import android.widget.RelativeLayout;
...@@ -12,10 +13,7 @@ import android.widget.TextView; ...@@ -12,10 +13,7 @@ import android.widget.TextView;
12 import android.widget.Toast; 13 import android.widget.Toast;
13 14
14 import androidx.annotation.NonNull; 15 import androidx.annotation.NonNull;
15 -import androidx.constraintlayout.widget.ConstraintLayout;
16 import androidx.fragment.app.Fragment; 16 import androidx.fragment.app.Fragment;
17 -import androidx.recyclerview.widget.LinearLayoutManager;
18 -import androidx.recyclerview.widget.RecyclerView;
19 import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; 17 import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
20 18
21 import org.json.JSONObject; 19 import org.json.JSONObject;
...@@ -23,28 +21,24 @@ import org.json.JSONObject; ...@@ -23,28 +21,24 @@ import org.json.JSONObject;
23 import java.util.ArrayList; 21 import java.util.ArrayList;
24 22
25 import ly.warp.sdk.R; 23 import ly.warp.sdk.R;
26 -import ly.warp.sdk.activities.ActiveCouponsActivity;
27 -import ly.warp.sdk.activities.BaseFragmentActivity;
28 import ly.warp.sdk.activities.TelematicsActivity; 24 import ly.warp.sdk.activities.TelematicsActivity;
29 import ly.warp.sdk.activities.TelematicsHistoryActivity; 25 import ly.warp.sdk.activities.TelematicsHistoryActivity;
30 -import ly.warp.sdk.activities.WarpViewActivity; 26 +import ly.warp.sdk.db.WarplyDBHelper;
31 import ly.warp.sdk.io.callbacks.CallbackReceiver; 27 import ly.warp.sdk.io.callbacks.CallbackReceiver;
32 import ly.warp.sdk.io.models.Campaign; 28 import ly.warp.sdk.io.models.Campaign;
33 import ly.warp.sdk.io.models.CouponList; 29 import ly.warp.sdk.io.models.CouponList;
34 import ly.warp.sdk.io.models.UnifiedCoupon; 30 import ly.warp.sdk.io.models.UnifiedCoupon;
35 -import ly.warp.sdk.io.request.WarplyGetCampaignsRequest;
36 import ly.warp.sdk.utils.WarplyManagerHelper; 31 import ly.warp.sdk.utils.WarplyManagerHelper;
37 import ly.warp.sdk.utils.managers.WarplyManager; 32 import ly.warp.sdk.utils.managers.WarplyManager;
38 -import ly.warp.sdk.views.adapters.HomeCampaignAdapter;
39 33
40 public class HomeFragment extends Fragment implements View.OnClickListener, SwipeRefreshLayout.OnRefreshListener { 34 public class HomeFragment extends Fragment implements View.OnClickListener, SwipeRefreshLayout.OnRefreshListener {
41 35
42 - private RelativeLayout mOptionOne, mOptionTwo, mOptionThree, mRlDriving, mRlDrivingHistory; 36 + private RelativeLayout mOptionOne, mOptionTwo, mOptionThree, mRlDriving,
43 - private LinearLayout mLlBillPayment; 37 + mRlDrivingHistory, mPbLoading;
44 - private TextView mTvUsername, mTvActiveCoupons; 38 + private TextView mTvUsername;
45 - private ConstraintLayout mClActiveCoupons;
46 - private ImageView mIvStepsActivity;
47 private SwipeRefreshLayout mSwipeRefresh; 39 private SwipeRefreshLayout mSwipeRefresh;
40 + private EditText mEtGuid;
41 + private LinearLayout mLlAuthLogin, mLlAuthLogout;
48 42
49 @Override 43 @Override
50 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 44 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
...@@ -74,17 +68,6 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip ...@@ -74,17 +68,6 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
74 mOptionThreeText.setText("1"); 68 mOptionThreeText.setText("1");
75 mOptionThreeImage.setImageResource(R.drawable.tv_option); 69 mOptionThreeImage.setImageResource(R.drawable.tv_option);
76 70
77 - mClActiveCoupons = view.findViewById(R.id.cl_coupon);
78 - mTvActiveCoupons = mClActiveCoupons.findViewById(R.id.tv_active_coupons);
79 - mTvActiveCoupons.setText(String.format(getResources().getString(R.string.cos_active_coupons), String.valueOf(WarplyManagerHelper.getCouponList().size())));
80 - mClActiveCoupons.setOnClickListener(this);
81 -
82 - mLlBillPayment = view.findViewById(R.id.ll_bill_payment);
83 - mLlBillPayment.setOnClickListener(this);
84 -
85 - mIvStepsActivity = view.findViewById(R.id.iv_settings);
86 - mIvStepsActivity.setOnClickListener(this);
87 -
88 mTvUsername = view.findViewById(R.id.welcome_user_txt); 71 mTvUsername = view.findViewById(R.id.welcome_user_txt);
89 if (WarplyManagerHelper.getConsumer() != null) 72 if (WarplyManagerHelper.getConsumer() != null)
90 mTvUsername.setText(String.format(getResources().getString(R.string.welcome_user), 73 mTvUsername.setText(String.format(getResources().getString(R.string.welcome_user),
...@@ -94,6 +77,25 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip ...@@ -94,6 +77,25 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
94 mRlDriving.setOnClickListener(this); 77 mRlDriving.setOnClickListener(this);
95 mRlDrivingHistory = view.findViewById(R.id.rl_driving_history); 78 mRlDrivingHistory = view.findViewById(R.id.rl_driving_history);
96 mRlDrivingHistory.setOnClickListener(this); 79 mRlDrivingHistory.setOnClickListener(this);
80 +
81 + mPbLoading = view.findViewById(R.id.pb_loading);
82 + mPbLoading.setOnTouchListener((v, event) -> true);
83 +
84 + mEtGuid = view.findViewById(R.id.et_login);
85 + mLlAuthLogin = view.findViewById(R.id.ll_auth_login);
86 + mLlAuthLogin.setOnClickListener(this);
87 + mLlAuthLogout = view.findViewById(R.id.ll_auth_logout);
88 + mLlAuthLogout.setOnClickListener(this);
89 +
90 + if (!WarplyDBHelper.getInstance(getActivity()).isTableNotEmpty("auth")) {
91 + mLlAuthLogout.setVisibility(View.GONE);
92 + mLlAuthLogin.setVisibility(View.VISIBLE);
93 + mEtGuid.setVisibility(View.VISIBLE);
94 + } else {
95 + mEtGuid.setVisibility(View.GONE);
96 + mLlAuthLogin.setVisibility(View.GONE);
97 + mLlAuthLogout.setVisibility(View.VISIBLE);
98 + }
97 } 99 }
98 100
99 @Override 101 @Override
...@@ -111,12 +113,6 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip ...@@ -111,12 +113,6 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
111 113
112 @Override 114 @Override
113 public void onClick(View view) { 115 public void onClick(View view) {
114 - if (view.getId() == R.id.cl_coupon) {
115 - Intent intent = new Intent(getContext(), ActiveCouponsActivity.class);
116 - intent.putExtra("couponlist", WarplyManagerHelper.getCouponList());
117 - startActivity(intent);
118 - return;
119 - }
120 if (view.getId() == R.id.rl_driving) { 116 if (view.getId() == R.id.rl_driving) {
121 Intent intent = new Intent(getContext(), TelematicsActivity.class); 117 Intent intent = new Intent(getContext(), TelematicsActivity.class);
122 startActivity(intent); 118 startActivity(intent);
...@@ -127,7 +123,15 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip ...@@ -127,7 +123,15 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
127 startActivity(intent); 123 startActivity(intent);
128 return; 124 return;
129 } 125 }
130 - if (view.getId() == R.id.iv_settings) { 126 + if (view.getId() == R.id.ll_auth_login) {
127 + //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons
128 + //prod 6006552990, prod 6005892749, live 3000184910,prod 7000070282, live 3000136179
129 + mPbLoading.setVisibility(View.VISIBLE);
130 + WarplyManager.getCosmoteUser(mEtGuid.getText().toString(), mLoginReceiver);
131 + return;
132 + }
133 + if (view.getId() == R.id.ll_auth_logout) {
134 + mPbLoading.setVisibility(View.VISIBLE);
131 WarplyManager.logout(mLogoutReceiver); 135 WarplyManager.logout(mLogoutReceiver);
132 } 136 }
133 } 137 }
...@@ -177,12 +181,38 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip ...@@ -177,12 +181,38 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
177 private final CallbackReceiver<JSONObject> mLogoutReceiver = new CallbackReceiver<JSONObject>() { 181 private final CallbackReceiver<JSONObject> mLogoutReceiver = new CallbackReceiver<JSONObject>() {
178 @Override 182 @Override
179 public void onSuccess(JSONObject result) { 183 public void onSuccess(JSONObject result) {
184 + mPbLoading.setVisibility(View.GONE);
185 + mLlAuthLogout.setVisibility(View.GONE);
186 + mLlAuthLogin.setVisibility(View.VISIBLE);
187 + mEtGuid.setVisibility(View.VISIBLE);
180 Toast.makeText(getActivity(), "LOGOUT SUCCESS", Toast.LENGTH_SHORT).show(); 188 Toast.makeText(getActivity(), "LOGOUT SUCCESS", Toast.LENGTH_SHORT).show();
181 } 189 }
182 190
183 @Override 191 @Override
184 public void onFailure(int errorCode) { 192 public void onFailure(int errorCode) {
193 + mPbLoading.setVisibility(View.GONE);
185 Toast.makeText(getActivity(), "LOGOUT ERROR", Toast.LENGTH_SHORT).show(); 194 Toast.makeText(getActivity(), "LOGOUT ERROR", Toast.LENGTH_SHORT).show();
186 } 195 }
187 }; 196 };
197 +
198 + private final CallbackReceiver<JSONObject> mLoginReceiver = new CallbackReceiver<JSONObject>() {
199 + @Override
200 + public void onSuccess(JSONObject result) {
201 + mPbLoading.setVisibility(View.GONE);
202 + mLlAuthLogin.setVisibility(View.GONE);
203 + mEtGuid.setVisibility(View.GONE);
204 + mLlAuthLogout.setVisibility(View.VISIBLE);
205 + if (result != null && result.optInt("status") == 1) {
206 + WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
207 + WarplyManager.getCampaigns(mCampaignsCallback);
208 + WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback);
209 + }
210 + }
211 +
212 + @Override
213 + public void onFailure(int errorCode) {
214 + mPbLoading.setVisibility(View.GONE);
215 + Toast.makeText(getActivity(), "LOGIN ERROR", Toast.LENGTH_SHORT).show();
216 + }
217 + };
188 } 218 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
25 25
26 package ly.warp.sdk.io.callbacks; 26 package ly.warp.sdk.io.callbacks;
27 27
28 -import org.json.JSONException;
29 import org.json.JSONObject; 28 import org.json.JSONObject;
30 29
31 import ly.warp.sdk.Warply; 30 import ly.warp.sdk.Warply;
...@@ -42,6 +41,8 @@ import ly.warp.sdk.utils.WarpUtils; ...@@ -42,6 +41,8 @@ import ly.warp.sdk.utils.WarpUtils;
42 41
43 import static ly.warp.sdk.Warply.getWarplyContext; 42 import static ly.warp.sdk.Warply.getWarplyContext;
44 43
44 +import android.text.TextUtils;
45 +
45 public class VolleyTransformer implements Listener<JSONObject>, ErrorListener { 46 public class VolleyTransformer implements Listener<JSONObject>, ErrorListener {
46 47
47 public VolleyTransformer(CallbackReceiver<JSONObject> listener) { 48 public VolleyTransformer(CallbackReceiver<JSONObject> listener) {
...@@ -81,30 +82,42 @@ public class VolleyTransformer implements Listener<JSONObject>, ErrorListener { ...@@ -81,30 +82,42 @@ public class VolleyTransformer implements Listener<JSONObject>, ErrorListener {
81 @Override 82 @Override
82 public void onResponse(JSONObject response) { 83 public void onResponse(JSONObject response) {
83 if (response != null) { 84 if (response != null) {
84 - if (response.optJSONObject("context") != null) { 85 + JSONObject contextObj = response.optJSONObject("context");
85 - if (response.optJSONObject("context").optJSONObject("device_status") != null) { 86 + if (contextObj != null) {
86 - WarpUtils.setIsWarped(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optBoolean("warped")); 87 + JSONObject deviceStatusObj = contextObj.optJSONObject("device_status");
87 -// WarpUtils.setDeviceToken(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optString("device_token")); 88 +
88 -// WarpUtils.setHasApplicationInfo(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optBoolean("application_info_saved")); 89 + if (deviceStatusObj != null) {
89 - WarpUtils.setDeviceId(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optString("device_id")); 90 + WarpUtils.setIsWarped(getWarplyContext(), deviceStatusObj.optBoolean("warped"));
90 - WarpUtils.setIsDeviceIdSaved(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optBoolean("device_id_saved")); 91 + WarpUtils.setDeviceId(getWarplyContext(), deviceStatusObj.optString("device_id"));
91 -// WarpUtils.setIsDeviceInfoSaved(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optBoolean("device_info_saved")); 92 + WarpUtils.setIsDeviceIdSaved(getWarplyContext(), deviceStatusObj.optBoolean("device_id_saved"));
92 - if (response.optJSONObject("context").optJSONObject("device_status").optJSONObject("application_info") != null) { 93 +
93 - WarpUtils.setAppDataObject(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optJSONObject("application_info")); 94 + JSONObject applicationInfoObj = deviceStatusObj.optJSONObject("application_info");
94 - WarpUtils.setSDKVersion(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optJSONObject("application_info").optString("sdk_version")); 95 + if (applicationInfoObj != null) {
95 - WarpUtils.setAppVersion(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optJSONObject("application_info").optString("app_version")); 96 + WarpUtils.setAppDataObject(getWarplyContext(), applicationInfoObj);
96 - } 97 + WarpUtils.setSDKVersion(getWarplyContext(), applicationInfoObj.optString("sdk_version"));
97 - if (response.optJSONObject("context").optJSONObject("device_status").optJSONObject("device_info") != null) { 98 + WarpUtils.setAppVersion(getWarplyContext(), applicationInfoObj.optString("app_version"));
98 - WarpUtils.setDeviceInfoObject(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optJSONObject("device_info")); 99 + }
99 - WarpUtils.setOSVersion(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optJSONObject("device_info").optString("os_version")); 100 +
100 - WarpUtils.setDeviceBrand(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optJSONObject("device_info").optString("manufacturer")); 101 + JSONObject deviceInfoObj = deviceStatusObj.optJSONObject("device_info");
101 - WarpUtils.setCarrierName(getWarplyContext(), response.optJSONObject("context").optJSONObject("device_status").optJSONObject("device_info").optString("carrier_name")); 102 + if (deviceInfoObj != null) {
102 - } 103 + WarpUtils.setDeviceInfoObject(getWarplyContext(), deviceInfoObj);
103 - } 104 + WarpUtils.setOSVersion(getWarplyContext(), deviceInfoObj.optString("os_version"));
104 - if (response.optJSONObject("context").optJSONObject("application_data") != null) { 105 + WarpUtils.setDeviceBrand(getWarplyContext(), deviceInfoObj.optString("manufacturer"));
105 - WarpUtils.setIsAPPDATAENABLED(getWarplyContext(), response.optJSONObject("context").optJSONObject("application_data").optBoolean("APPLICATION_DATA_ENABLED")); 106 + WarpUtils.setCarrierName(getWarplyContext(), deviceInfoObj.optString("carrier_name"));
106 - WarpUtils.setIsDEVICEINFOENABLED(getWarplyContext(), response.optJSONObject("context").optJSONObject("application_data").optBoolean("DEVICE_INFO_ENABLED")); 107 + }
107 - WarpUtils.setIsLIFECYCLEANALYTICSENABLED(getWarplyContext(), response.optJSONObject("context").optJSONObject("application_data").optBoolean("LIFECYCLE_ANALYTICS_ENABLED", true)); 108 + }
109 +
110 + JSONObject applicationDataObj = contextObj.optJSONObject("application_data");
111 + if (applicationDataObj != null) {
112 + WarpUtils.setIsAPPDATAENABLED(getWarplyContext(), applicationDataObj.optBoolean("APPLICATION_DATA_ENABLED"));
113 + WarpUtils.setIsDEVICEINFOENABLED(getWarplyContext(), applicationDataObj.optBoolean("DEVICE_INFO_ENABLED"));
114 + WarpUtils.setIsLIFECYCLEANALYTICSENABLED(getWarplyContext(), applicationDataObj.optBoolean("LIFECYCLE_ANALYTICS_ENABLED", true));
115 + if (applicationDataObj.has("AUTHENTICATION")) {
116 + String jwtAuth = applicationDataObj.optString("AUTHENTICATION", "");
117 + WarpUtils.setIsJWTEnabled(getWarplyContext(), !TextUtils.isEmpty(jwtAuth) && jwtAuth.equals("JWT"));
118 + } else {
119 + WarpUtils.setIsJWTEnabled(getWarplyContext(), false);
120 + }
108 } 121 }
109 } 122 }
110 } 123 }
......
...@@ -77,6 +77,17 @@ public interface ApiService { ...@@ -77,6 +77,17 @@ public interface ApiService {
77 @Header(WarpConstants.HEADER_SIGNATURE) String signature); 77 @Header(WarpConstants.HEADER_SIGNATURE) String signature);
78 78
79 @Headers("Content-Type: application/json") 79 @Headers("Content-Type: application/json")
80 + @POST("/user/v5/{appUuid}/logout")
81 + Call<ResponseBody> logoutUserJwt(@Path("appUuid") String appUuid,
82 + @Body RequestBody request,
83 + @Header(WarpConstants.HEADER_DATE) String timeStamp,
84 + @Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
85 + @Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId,
86 + @Header(WarpConstants.HEADER_CHANNEL) String channel,
87 + @Header(WarpConstants.HEADER_WEB_ID) String webId,
88 + @Header(WarpConstants.HEADER_SIGNATURE) String signature);
89 +
90 + @Headers("Content-Type: application/json")
80 @POST("/oauth/{appUuid}/context") 91 @POST("/oauth/{appUuid}/context")
81 Call<ResponseBody> getCouponsets(@Path("appUuid") String appUuid, 92 Call<ResponseBody> getCouponsets(@Path("appUuid") String appUuid,
82 @Body RequestBody request, 93 @Body RequestBody request,
......
...@@ -159,6 +159,8 @@ public class WarpUtils { ...@@ -159,6 +159,8 @@ public class WarpUtils {
159 + "steps"; 159 + "steps";
160 private static final String PREFERENCES_KEY_STEPS_MANUALLY_STOPPED = PREFERENCES_PREFIX 160 private static final String PREFERENCES_KEY_STEPS_MANUALLY_STOPPED = PREFERENCES_PREFIX
161 + "steps_manually_stopped"; 161 + "steps_manually_stopped";
162 + private static final String PREFERENCES_KEY_JWT_ENABLED = PREFERENCES_PREFIX
163 + + "jwt_enabled";
162 164
163 private static SharedPreferences _prefs; 165 private static SharedPreferences _prefs;
164 166
...@@ -639,6 +641,17 @@ public class WarpUtils { ...@@ -639,6 +641,17 @@ public class WarpUtils {
639 editor.apply(); 641 editor.apply();
640 } 642 }
641 643
644 + public static boolean isJWTEnabled(Context context) {
645 + SharedPreferences prefs = getPreferences(context);
646 + return prefs.getBoolean(PREFERENCES_KEY_JWT_ENABLED, true);
647 + }
648 +
649 + public static void setIsJWTEnabled(Context context, boolean jwtEnabled) {
650 + SharedPreferences.Editor editor = getPreferences(context).edit();
651 + editor.putBoolean(PREFERENCES_KEY_JWT_ENABLED, jwtEnabled);
652 + editor.apply();
653 + }
654 +
642 public static JSONObject getAppDataObject(Context context) { 655 public static JSONObject getAppDataObject(Context context) {
643 SharedPreferences prefs = getPreferences(context); 656 SharedPreferences prefs = getPreferences(context);
644 try { 657 try {
......
...@@ -595,12 +595,30 @@ public class WarplyManager { ...@@ -595,12 +595,30 @@ public class WarplyManager {
595 String webId = WarpUtils.getWebId(Warply.getWarplyContext()); 595 String webId = WarpUtils.getWebId(Warply.getWarplyContext());
596 596
597 Map<String, Object> jsonParams = new ArrayMap<>(); 597 Map<String, Object> jsonParams = new ArrayMap<>();
598 + if (WarpUtils.isJWTEnabled(Warply.getWarplyContext())) {
598 jsonParams.put("access_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token")); 599 jsonParams.put("access_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token"));
599 jsonParams.put("refresh_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token")); 600 jsonParams.put("refresh_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token"));
601 + } else {
602 + jsonParams.put("token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token"));
603 + jsonParams.put("client_id", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id"));
604 + jsonParams.put("client_secret", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret"));
605 + }
600 606
601 RequestBody loginRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParams)).toString()); 607 RequestBody loginRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParams)).toString());
602 608
603 - Call<ResponseBody> logoutCall = service.logoutUser( 609 + Call<ResponseBody> logoutCall = WarpUtils.isJWTEnabled(Warply.getWarplyContext()) ?
610 + service.logoutUserJwt(
611 + WarplyProperty.getAppUuid(Warply.getWarplyContext()),
612 + loginRequest,
613 + timeStamp,
614 + "android:" + Warply.getWarplyContext().getPackageName(),
615 + new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(),
616 + "mobile",
617 + webId,
618 + WarpUtils.produceSignature(apiKey + timeStamp)
619 + )
620 + :
621 + service.logoutUser(
604 WarplyProperty.getAppUuid(Warply.getWarplyContext()), 622 WarplyProperty.getAppUuid(Warply.getWarplyContext()),
605 loginRequest, 623 loginRequest,
606 timeStamp, 624 timeStamp,
......
...@@ -5,16 +5,17 @@ ...@@ -5,16 +5,17 @@
5 xmlns:tools="http://schemas.android.com/tools" 5 xmlns:tools="http://schemas.android.com/tools"
6 android:id="@+id/sw_refresh" 6 android:id="@+id/sw_refresh"
7 android:layout_width="match_parent" 7 android:layout_width="match_parent"
8 - android:layout_height="match_parent"> 8 + android:layout_height="match_parent"
9 + android:background="@color/cos_skyblue2">
9 10
10 <ScrollView 11 <ScrollView
11 android:layout_width="match_parent" 12 android:layout_width="match_parent"
12 android:layout_height="match_parent" 13 android:layout_height="match_parent"
13 - android:background="@android:color/white"> 14 + android:background="@color/cos_skyblue2">
14 15
15 <RelativeLayout 16 <RelativeLayout
16 android:layout_width="match_parent" 17 android:layout_width="match_parent"
17 - android:layout_height="match_parent"> 18 + android:layout_height="wrap_content">
18 19
19 <androidx.constraintlayout.widget.ConstraintLayout 20 <androidx.constraintlayout.widget.ConstraintLayout
20 android:id="@+id/rl_header" 21 android:id="@+id/rl_header"
...@@ -22,7 +23,7 @@ ...@@ -22,7 +23,7 @@
22 android:layout_height="wrap_content" 23 android:layout_height="wrap_content"
23 android:background="@android:color/white" 24 android:background="@android:color/white"
24 android:paddingHorizontal="16dp" 25 android:paddingHorizontal="16dp"
25 - android:paddingTop="16dp"> 26 + android:paddingTop="8dp">
26 27
27 <de.hdodenhof.circleimageview.CircleImageView 28 <de.hdodenhof.circleimageview.CircleImageView
28 android:id="@+id/user_img" 29 android:id="@+id/user_img"
...@@ -100,14 +101,86 @@ ...@@ -100,14 +101,86 @@
100 android:layout_width="wrap_content" 101 android:layout_width="wrap_content"
101 android:layout_height="wrap_content" 102 android:layout_height="wrap_content"
102 android:layout_below="@+id/rl_header" 103 android:layout_below="@+id/rl_header"
103 - android:background="@drawable/home_bg"> 104 + android:background="@color/cos_skyblue2"
105 + android:paddingBottom="48dp">
106 +
107 + <RelativeLayout
108 + android:id="@+id/rl_auth_view"
109 + android:layout_width="match_parent"
110 + android:layout_height="70dp"
111 + android:layout_marginHorizontal="8dp"
112 + android:layout_marginTop="24dp"
113 + android:layout_marginBottom="16dp"
114 + android:background="@drawable/shape_cos_white">
115 +
116 + <EditText
117 + android:id="@+id/et_login"
118 + android:layout_width="180dp"
119 + android:layout_height="wrap_content"
120 + android:layout_alignParentStart="true"
121 + android:layout_centerVertical="true"
122 + android:layout_marginStart="16dp"
123 + android:hint="@string/cos_hint"
124 + android:inputType="number"
125 + android:textColor="@color/blue_dark"
126 + android:textSize="20sp"
127 + android:textStyle="bold"
128 + android:visibility="gone"
129 + tools:visibility="visible"/>
130 +
131 + <LinearLayout
132 + android:id="@+id/ll_auth_login"
133 + android:layout_width="140dp"
134 + android:layout_height="45dp"
135 + android:layout_alignParentEnd="true"
136 + android:layout_centerVertical="true"
137 + android:layout_marginEnd="16dp"
138 + android:background="@drawable/selector_button_green"
139 + android:gravity="center"
140 + android:orientation="horizontal"
141 + android:visibility="gone">
142 +
143 + <TextView
144 + android:id="@+id/button_login"
145 + android:layout_width="wrap_content"
146 + android:layout_height="wrap_content"
147 + android:gravity="center"
148 + android:includeFontPadding="false"
149 + android:text="@string/cos_login_text"
150 + android:textColor="@color/white"
151 + android:textSize="16sp" />
152 + </LinearLayout>
153 +
154 + <LinearLayout
155 + android:id="@+id/ll_auth_logout"
156 + android:layout_width="140dp"
157 + android:layout_height="45dp"
158 + android:layout_alignParentEnd="true"
159 + android:layout_centerVertical="true"
160 + android:layout_marginEnd="16dp"
161 + android:background="@drawable/selector_button_green"
162 + android:gravity="center"
163 + android:orientation="horizontal"
164 + android:visibility="gone">
165 +
166 + <TextView
167 + android:id="@+id/button_logout"
168 + android:layout_width="wrap_content"
169 + android:layout_height="wrap_content"
170 + android:gravity="center"
171 + android:includeFontPadding="false"
172 + android:text="@string/cos_logout_text"
173 + android:textColor="@color/white"
174 + android:textSize="16sp" />
175 + </LinearLayout>
176 + </RelativeLayout>
104 177
105 <RelativeLayout 178 <RelativeLayout
106 android:id="@+id/rl_driving" 179 android:id="@+id/rl_driving"
107 android:layout_width="match_parent" 180 android:layout_width="match_parent"
108 android:layout_height="70dp" 181 android:layout_height="70dp"
182 + android:layout_below="@+id/rl_auth_view"
109 android:layout_marginHorizontal="8dp" 183 android:layout_marginHorizontal="8dp"
110 - android:layout_marginTop="50dp"
111 android:layout_marginBottom="16dp" 184 android:layout_marginBottom="16dp"
112 android:background="@drawable/shape_cos_white"> 185 android:background="@drawable/shape_cos_white">
113 186
...@@ -138,8 +211,8 @@ ...@@ -138,8 +211,8 @@
138 android:layout_below="@+id/rl_driving" 211 android:layout_below="@+id/rl_driving"
139 android:layout_marginHorizontal="8dp" 212 android:layout_marginHorizontal="8dp"
140 android:layout_marginBottom="16dp" 213 android:layout_marginBottom="16dp"
141 - android:visibility="gone" 214 + android:background="@drawable/shape_cos_white"
142 - android:background="@drawable/shape_cos_white"> 215 + android:visibility="visible">
143 216
144 <TextView 217 <TextView
145 android:layout_width="wrap_content" 218 android:layout_width="wrap_content"
...@@ -160,171 +233,32 @@ ...@@ -160,171 +233,32 @@
160 android:src="@drawable/cosmote_one" /> 233 android:src="@drawable/cosmote_one" />
161 </RelativeLayout> 234 </RelativeLayout>
162 235
163 - <LinearLayout
164 - android:id="@+id/rl_home_coupons"
165 - android:layout_width="match_parent"
166 - android:layout_height="wrap_content"
167 - android:layout_below="@+id/rl_driving_history"
168 - android:visibility="gone">
169 -
170 - <androidx.recyclerview.widget.RecyclerView
171 - android:id="@+id/rv_home_coupons"
172 - android:layout_width="match_parent"
173 - android:layout_height="wrap_content"
174 - android:clipToPadding="false"
175 - android:orientation="horizontal"
176 - android:paddingStart="10dp"
177 - android:paddingEnd="10dp" />
178 - </LinearLayout>
179 -
180 <include 236 <include
181 android:id="@+id/rl_home_info_widget" 237 android:id="@+id/rl_home_info_widget"
182 layout="@layout/info_widget" 238 layout="@layout/info_widget"
183 android:layout_width="match_parent" 239 android:layout_width="match_parent"
184 android:layout_height="wrap_content" 240 android:layout_height="wrap_content"
185 - android:layout_below="@id/rl_home_coupons" 241 + android:layout_below="@id/rl_driving_history"
186 android:layout_marginHorizontal="8dp" /> 242 android:layout_marginHorizontal="8dp" />
187 243
188 - <androidx.constraintlayout.widget.ConstraintLayout 244 + <RelativeLayout
189 - android:id="@+id/cl_coupon" 245 + android:id="@+id/pb_loading"
190 - android:layout_width="match_parent"
191 - android:layout_height="140dp"
192 - android:layout_below="@+id/rl_home_info_widget"
193 - android:layout_marginTop="24dp"
194 - android:background="@drawable/ic_coupon_background">
195 -
196 - <LinearLayout
197 - android:layout_width="wrap_content"
198 - android:layout_height="wrap_content"
199 - android:layout_marginStart="40dp"
200 - android:orientation="vertical"
201 - app:layout_constraintBottom_toBottomOf="parent"
202 - app:layout_constraintStart_toStartOf="parent"
203 - app:layout_constraintTop_toTopOf="parent">
204 -
205 - <TextView
206 - android:id="@+id/tv_active_coupons"
207 - android:layout_width="wrap_content"
208 - android:layout_height="wrap_content"
209 - android:layout_marginBottom="8dp"
210 - android:textColor="#3A5266"
211 - android:textFontWeight="600"
212 - android:textSize="16sp"
213 - tools:text="@string/cos_active_coupons" />
214 -
215 - <TextView
216 - android:layout_width="wrap_content"
217 - android:layout_height="wrap_content"
218 - android:layout_marginTop="8dp"
219 - android:text="Δες τα όλα ->"
220 - android:textColor="#3A5266" />
221 - </LinearLayout>
222 -
223 - <ImageView
224 - android:layout_width="90dp"
225 - android:layout_height="90dp"
226 - android:layout_marginEnd="32dp"
227 - android:src="@drawable/ic_gifts_for_you"
228 - app:layout_constraintBottom_toBottomOf="parent"
229 - app:layout_constraintEnd_toEndOf="parent"
230 - app:layout_constraintTop_toTopOf="parent" />
231 - </androidx.constraintlayout.widget.ConstraintLayout>
232 -
233 - <TextView
234 - android:id="@+id/hsv_title"
235 - android:layout_width="match_parent"
236 - android:layout_height="40dp"
237 - android:layout_below="@+id/cl_coupon"
238 - android:layout_marginTop="24dp"
239 - android:background="@android:color/white"
240 - android:paddingHorizontal="25dp"
241 - android:paddingTop="10dp"
242 - android:text="Βρες γρήγορα"
243 - android:textColor="#3C464F" />
244 -
245 - <HorizontalScrollView
246 - android:id="@+id/ll_add"
247 - android:layout_width="match_parent"
248 - android:layout_height="110dp"
249 - android:layout_below="@id/hsv_title"
250 - android:background="@android:color/white"
251 - android:paddingBottom="15dp"
252 - android:scrollbars="none">
253 -
254 - <LinearLayout
255 - android:layout_width="match_parent"
256 - android:layout_height="match_parent"
257 - android:divider="@drawable/divider"
258 - android:showDividers="middle">
259 -
260 - <LinearLayout
261 - android:id="@+id/ll_bill_payment"
262 - android:layout_width="150dp"
263 - android:layout_height="match_parent"
264 - android:gravity="center"
265 - android:orientation="vertical"
266 - android:paddingHorizontal="10dp">
267 -
268 - <ImageView
269 - android:layout_width="50dp"
270 - android:layout_height="50dp"
271 - android:src="@drawable/doc" />
272 -
273 - <TextView
274 android:layout_width="match_parent" 246 android:layout_width="match_parent"
275 - android:layout_height="40dp"
276 - android:gravity="center"
277 - android:scrollHorizontally="true"
278 - android:text="Πληρωμή λογαριασμού"
279 - android:textAlignment="center"
280 - android:textColor="#3C464F" />
281 - </LinearLayout>
282 -
283 - <LinearLayout
284 - android:layout_width="150dp"
285 android:layout_height="match_parent" 247 android:layout_height="match_parent"
286 - android:gravity="center" 248 + android:layout_centerInParent="true"
287 - android:orientation="vertical" 249 + android:background="@android:color/transparent"
288 - android:paddingHorizontal="10dp"> 250 + android:visibility="gone"
289 - 251 + tools:visibility="visible"
290 - <ImageView 252 + android:translationZ="100dp">
291 - android:layout_width="50dp" 253 +
292 - android:layout_height="50dp" 254 + <ProgressBar
293 - android:src="@drawable/message" /> 255 + android:layout_width="48dp"
294 - 256 + android:layout_height="48dp"
295 - <TextView 257 + android:layout_centerInParent="true"
296 - android:layout_width="match_parent" 258 + android:indeterminate="true"
297 - android:layout_height="40dp" 259 + android:indeterminateTint="@color/cos_green5"
298 - android:gravity="center" 260 + android:indeterminateTintMode="src_atop" />
299 - android:scrollHorizontally="true" 261 + </RelativeLayout>
300 - android:text="Υποστήριξη"
301 - android:textAlignment="center"
302 - android:textColor="#3C464F" />
303 - </LinearLayout>
304 -
305 - <LinearLayout
306 - android:layout_width="150dp"
307 - android:layout_height="match_parent"
308 - android:gravity="center"
309 - android:orientation="vertical"
310 - android:paddingHorizontal="10dp">
311 -
312 - <ImageView
313 - android:layout_width="50dp"
314 - android:layout_height="50dp"
315 - android:src="@drawable/doc" />
316 -
317 - <TextView
318 - android:layout_width="match_parent"
319 - android:layout_height="40dp"
320 - android:gravity="center"
321 - android:scrollHorizontally="true"
322 - android:text="Πληρωμή λογαριασμού"
323 - android:textAlignment="center"
324 - android:textColor="#3C464F" />
325 - </LinearLayout>
326 - </LinearLayout>
327 - </HorizontalScrollView>
328 </RelativeLayout> 262 </RelativeLayout>
329 </RelativeLayout> 263 </RelativeLayout>
330 </ScrollView> 264 </ScrollView>
......
...@@ -213,6 +213,7 @@ ...@@ -213,6 +213,7 @@
213 <string name="lbl_take_photo_decline">Άκυρο</string> 213 <string name="lbl_take_photo_decline">Άκυρο</string>
214 <string name="lbl_gps_enabled">Θέλετε να ενεργοποιήσετε το GPS;</string> 214 <string name="lbl_gps_enabled">Θέλετε να ενεργοποιήσετε το GPS;</string>
215 <string name="cos_telematics">Safe Driving</string> 215 <string name="cos_telematics">Safe Driving</string>
216 + <string name="cos_hint">GUID</string>
216 <string name="cos_telematics_metrics">Ανάλυση</string> 217 <string name="cos_telematics_metrics">Ανάλυση</string>
217 <string name="cos_dlg_start_trip">Έναρξη</string> 218 <string name="cos_dlg_start_trip">Έναρξη</string>
218 <string name="cos_dlg_stop_trip">Παύση</string> 219 <string name="cos_dlg_stop_trip">Παύση</string>
...@@ -244,6 +245,8 @@ ...@@ -244,6 +245,8 @@
244 <string name="cos_vouchers_info_title_disabled">Διαθέσιμο υπόλοιπο</string> 245 <string name="cos_vouchers_info_title_disabled">Διαθέσιμο υπόλοιπο</string>
245 <string name="cos_vouchers_info_title_disabled_en">Available balance</string> 246 <string name="cos_vouchers_info_title_disabled_en">Available balance</string>
246 <string name="cos_coupons_header">Κουπόνια</string> 247 <string name="cos_coupons_header">Κουπόνια</string>
248 + <string name="cos_login_text">Σύνδεση</string>
249 + <string name="cos_logout_text">Αποσύνδεση</string>
247 250
248 <string-array name="coupons_array"> 251 <string-array name="coupons_array">
249 <item>Κουπόνια</item> 252 <item>Κουπόνια</item>
......