diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/appupdate/AppUpdateActivity.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/appupdate/AppUpdateActivity.java index cc711aa7..6f1f9eb6 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/appupdate/AppUpdateActivity.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/appupdate/AppUpdateActivity.java @@ -1,15 +1,156 @@ package com.gmeremit.online.gmeremittance_native.appupdate; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.pm.ActivityInfo; +import android.content.pm.ResolveInfo; +import android.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.view.View; +import android.view.Window; +import android.widget.Button; +import android.widget.TextView; import com.gmeremit.online.gmeremittance_native.R; -public class AppUpdateActivity extends AppCompatActivity { +import java.util.List; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class AppUpdateActivity extends AppCompatActivity implements View.OnClickListener { + + @BindView(R.id.not_now_view) + View notNowView; + + @BindView(R.id.gmeTextViewDetail) + TextView updateMessageBody; + + @BindView(R.id.btn_update) + Button btnUpdate; + + + public static final String APP_UPDATE_MESSAGE = "bundleKeyAppUpdateMessage"; + public static final String APP_PLAY_STORE_BUILD_NUMBER = "bundleKeyPlayStoreBuildNumber"; + public static final String APP_UPDATE_IS_FORCE_UPDATE = "bundleKeyIsForceUpdate"; + + private boolean isForcedUpdate = false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_app_update); + ButterKnife.bind(this); + initialize(); + performDefaultAction(savedInstanceState); + } + + private void initialize() { + + } + + private void performDefaultAction(Bundle savedInstanceState) { + if (savedInstanceState == null) { + try { + String message = getIntent().getStringExtra(APP_UPDATE_MESSAGE); + String buildNumber = getIntent().getStringExtra(APP_PLAY_STORE_BUILD_NUMBER); + isForcedUpdate = getIntent().getBooleanExtra(APP_UPDATE_IS_FORCE_UPDATE, false); + + notNowView.setVisibility(isForcedUpdate ? View.INVISIBLE : View.VISIBLE); + + if (message != null && message.length() > 0) + updateMessageBody.setText(message); + + } catch (Exception e) { + + } + } + } + + @Override + public void onBackPressed() { + if (!isForcedUpdate) + super.onBackPressed(); + else { + moveTaskToBack(true); + android.os.Process.killProcess(android.os.Process.myPid()); + System.exit(1); + } } + + @Override + protected void onStart() { + super.onStart(); + btnUpdate.setOnClickListener(this); + notNowView.setOnClickListener(this); + } + + @Override + protected void onStop() { + super.onStop(); + btnUpdate.setOnClickListener(null); + notNowView.setOnClickListener(null); + } + + @Override + public void onClick(View v) { + switch (v.getId()) { + + case R.id.btn_update: + gotoPlayStore(); + break; + + case R.id.not_now_view: + onBackPressed(); + break; + } + } + + private void gotoPlayStore() { + String appId = this.getPackageName(); + Intent rateIntent = new Intent(Intent.ACTION_VIEW, + Uri.parse("market://details?id=" + appId)); + boolean marketFound = false; + + // find all applications able to handle our rateIntent + final List otherApps = this.getPackageManager() + .queryIntentActivities(rateIntent, 0); + for (ResolveInfo otherApp : otherApps) { + // look for Google Play application + if (otherApp.activityInfo.applicationInfo.packageName + .equals("com.android.vending")) { + + ActivityInfo otherAppActivity = otherApp.activityInfo; + ComponentName componentName = new ComponentName( + otherAppActivity.applicationInfo.packageName, + otherAppActivity.name + ); + // make sure it does NOT open in the stack of your activity + rateIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + // task reparenting if needed + rateIntent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); + // if the Google Play was already open in a search result + // this make sure it still go to the app page you requested + rateIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + // this make sure only the Google Play app is allowed to + // intercept the intent + rateIntent.setComponent(componentName); + this.startActivity(rateIntent); + marketFound = true; + break; + + } + } + + // if GP not present on device, open web browser + if (!marketFound) { + Intent webIntent = new Intent(Intent.ACTION_VIEW, + Uri.parse("https://play.google.com/store/apps/details?id=" + appId)); + this.startActivity(webIntent); + } + } + + } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/model/AppUpdateModel.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/model/AppUpdateModel.java new file mode 100644 index 00000000..6ae6e812 --- /dev/null +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/model/AppUpdateModel.java @@ -0,0 +1,64 @@ +package com.gmeremit.online.gmeremittance_native.homeV2.model; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class AppUpdateModel { + + @SerializedName("OS") + @Expose + private String oS; + @SerializedName("Build") + @Expose + private String build; + @SerializedName("Version") + @Expose + private String version; + @SerializedName("Critical") + @Expose + private String critical; + @SerializedName("Info") + @Expose + private String info; + + public String getOS() { + return oS; + } + + public void setOS(String oS) { + this.oS = oS; + } + + public String getBuild() { + return build; + } + + public void setBuild(String build) { + this.build = build; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getCritical() { + return critical; + } + + public void setCritical(String critical) { + this.critical = critical; + } + + public String getInfo() { + return info; + } + + public void setInfo(String info) { + this.info = info; + } + +} diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/model/UserInfoModelV2.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/model/UserInfoModelV2.java index b7f63e26..af837463 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/model/UserInfoModelV2.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/model/UserInfoModelV2.java @@ -3,6 +3,8 @@ package com.gmeremit.online.gmeremittance_native.homeV2.model; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; +import java.util.List; + public class UserInfoModelV2 { @@ -109,6 +111,10 @@ public class UserInfoModelV2 { @Expose protected Object data; + @SerializedName("appUpdate") + @Expose + private List appUpdate = null; + public String getUserId() { return userId; } @@ -380,4 +386,12 @@ public class UserInfoModelV2 { public void setPennyTestStatus(String pennyTestStatus) { this.pennyTestStatus = pennyTestStatus; } + + public List getAppUpdate() { + return appUpdate; + } + + public void setAppUpdate(List appUpdate) { + this.appUpdate = appUpdate; + } } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2Presenter.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2Presenter.java index 6a5f46f4..2692c22c 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2Presenter.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2Presenter.java @@ -2,10 +2,12 @@ package com.gmeremit.online.gmeremittance_native.homeV2.presenter; import android.util.Log; +import com.gmeremit.online.gmeremittance_native.BuildConfig; import com.gmeremit.online.gmeremittance_native.GmeApplication; import com.gmeremit.online.gmeremittance_native.base.BasePresenter; import com.gmeremit.online.gmeremittance_native.customwidgets.CustomAlertDialog; import com.gmeremit.online.gmeremittance_native.homeV2.gateway.HomeV2Gateway; +import com.gmeremit.online.gmeremittance_native.homeV2.model.AppUpdateModel; import com.gmeremit.online.gmeremittance_native.homeV2.model.UserInfoModelV2; import com.gmeremit.online.gmeremittance_native.utils.Constants; import com.gmeremit.online.gmeremittance_native.utils.https.SessionExpiredException; @@ -76,7 +78,7 @@ public class HomeV2Presenter extends BasePresenter implements HomeV2PresenterInt // String pennyTestTitle = "Verify your Bank Account"; // String pennyTestMessage = "Please complete your primary bank account verification process."; // view.showPennyTestViewIfRequired(true,pennyTestTitle,pennyTestMessage); - view.showKYCVerifiedIfRequired(true, kycMessage, kycTitle, true,null); + view.showKYCVerifiedIfRequired(true, kycMessage, kycTitle, true, null); // gateway.updateSubmittedKycInCache(true); // gateway.updateVerifiedUserInCache(false); @@ -88,7 +90,7 @@ public class HomeV2Presenter extends BasePresenter implements HomeV2PresenterInt gateway.updateVerifiedUserInCache(false); String pennyTestTitle = "Continue the registration process"; String pennyTestMessage = "Please verify your primary bank account to complete the registration."; - view.showKYCVerifiedIfRequired(false,"","",true,()->view.showPennyTestViewIfRequired(true,pennyTestTitle,pennyTestMessage)); + view.showKYCVerifiedIfRequired(false, "", "", true, () -> view.showPennyTestViewIfRequired(true, pennyTestTitle, pennyTestMessage)); // view.showPennyTestViewIfRequired(true,pennyTestTitle,pennyTestMessage); } @@ -190,10 +192,18 @@ public class HomeV2Presenter extends BasePresenter implements HomeV2PresenterInt if (homeFragmentRelatedSubject != null) homeFragmentRelatedSubject.onNext(new HomeFragmentRelatedData(shouldShowKYCView, kycMessage, kycTitle, disableKYCViewClick, fullName, userInfoModelV2.getYearlyLimit(), - userInfoModelV2.getRewardPoint(), isPennyTestPending&&!shouldShowKYCView, hasRequestedPennyTest, + userInfoModelV2.getRewardPoint(), isPennyTestPending && !shouldShowKYCView, hasRequestedPennyTest, pennyTestTitle, pennyTestMessage)); view.showWithdrawView(userInfoModelV2.isVerified()); + + AppUpdateModel androidAppUpdateModel = null; + if (userInfoModelV2.getAppUpdate() != null) + for (AppUpdateModel model : userInfoModelV2.getAppUpdate()) { + if (model.getOS().equalsIgnoreCase("ANDROID")) + androidAppUpdateModel = model; + } + checkIfUpdateIsRequired(androidAppUpdateModel); } @@ -215,6 +225,22 @@ public class HomeV2Presenter extends BasePresenter implements HomeV2PresenterInt } } + private void checkIfUpdateIsRequired(AppUpdateModel androidAppUpdateModel) { + if (androidAppUpdateModel == null) + return; + try { + int playStoreBuildNumber = Integer.parseInt(androidAppUpdateModel.getBuild()); + if (playStoreBuildNumber > BuildConfig.VERSION_CODE) { + if (androidAppUpdateModel.getInfo() != null && androidAppUpdateModel.getInfo().length() < 1) + androidAppUpdateModel.setInfo(null); + boolean isForceUpdate = androidAppUpdateModel.getCritical().equalsIgnoreCase("Y"); + view.showUpdateScreen(androidAppUpdateModel.getBuild(), androidAppUpdateModel.getInfo(), isForceUpdate); + } + } catch (Exception e) { + return; + } + } + public class HomeFragmentRelatedData { private boolean shouldShowKycView; diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2PresenterInterface.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2PresenterInterface.java index 1bb10054..d161937a 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2PresenterInterface.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2PresenterInterface.java @@ -37,5 +37,7 @@ public interface HomeV2PresenterInterface extends BasePresenterInterface { void showWithdrawView(Boolean action); void showPennyTestViewIfRequired(boolean showView, String pennyTestTitle, String pennyTestMessage); + + void showUpdateScreen(String build, String info,boolean isForcedUpdate); } } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/view/HomeActivityV2.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/view/HomeActivityV2.java index 1e7bc70a..43b6d370 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/view/HomeActivityV2.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/view/HomeActivityV2.java @@ -32,7 +32,6 @@ import com.gmeremit.online.gmeremittance_native.homeV2.HomeParentViewContractV2; import com.gmeremit.online.gmeremittance_native.homeV2.presenter.HomeV2Presenter; import com.gmeremit.online.gmeremittance_native.homeV2.presenter.HomeV2PresenterInterface; import com.gmeremit.online.gmeremittance_native.int_notification.view.IntNotificationView; -import com.gmeremit.online.gmeremittance_native.kycV2.view.pennytest.PennyTestActivity; import com.gmeremit.online.gmeremittance_native.load_more.view.LoadMoreActivity; import com.gmeremit.online.gmeremittance_native.recipientV2.view.recipientlisting.RecipientListingV2Activity; import com.gmeremit.online.gmeremittance_native.settings.view.SettingsView; @@ -271,13 +270,11 @@ public class HomeActivityV2 extends BaseActivity implements HomeParentViewContra @Override public void showWalletStatment() { -// String unverifiedMessage = presenter.checkIfUserVerified(); -// if (unverifiedMessage == null) -// startActivity(new Intent(getApplicationContext(), WalletStatementV2Activity.class)); -// else -// showPopUpMessage(unverifiedMessage, CustomAlertDialog.AlertType.ALERT, null); - - startActivity(new Intent(HomeActivityV2.this,AppUpdateActivity.class)); + String unverifiedMessage = presenter.checkIfUserVerified(); + if (unverifiedMessage == null) + startActivity(new Intent(getApplicationContext(), WalletStatementV2Activity.class)); + else + showPopUpMessage(unverifiedMessage, CustomAlertDialog.AlertType.ALERT, null); } @@ -319,9 +316,6 @@ public class HomeActivityV2 extends BaseActivity implements HomeParentViewContra @Override public void showInfoInDrawer(String fullname, String email, String balance, String walletNumber, String bankName, String contact) { - //TODO -// bankName="Kwangju Bank(KJ)-034"; -// balance="19,000,000"; TextView txtUserName = nav_drawer.findViewById(R.id.txt_user_name); TextView txtUserEmail = nav_drawer.findViewById(R.id.txt_user_email); @@ -366,6 +360,19 @@ public class HomeActivityV2 extends BaseActivity implements HomeParentViewContra ((HomeFragmentV2) currentFragment).showPennyTestViewIfRequired(showView, pennyTestMessage,pennyTestTitle); } + @Override + public void showUpdateScreen(String build, String info, boolean isForceUpdate) { + new Handler().postDelayed(()->{ + Intent intent=new Intent(HomeActivityV2.this,AppUpdateActivity.class); + intent.putExtra(AppUpdateActivity.APP_UPDATE_MESSAGE,info); + intent.putExtra(AppUpdateActivity.APP_PLAY_STORE_BUILD_NUMBER,build); + intent.putExtra(AppUpdateActivity.APP_UPDATE_IS_FORCE_UPDATE,isForceUpdate); + startActivity(intent); + },500); + + + } + @Override public void performLogout() { presenter.clearAllData(); diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/loginV2/model/LoginModelV2.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/loginV2/model/LoginModelV2.java index 8c566fd7..49eda052 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/loginV2/model/LoginModelV2.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/loginV2/model/LoginModelV2.java @@ -380,4 +380,5 @@ public class LoginModelV2 { public void setPennyTestStatus(String pennyTestStatus) { this.pennyTestStatus = pennyTestStatus; } + } diff --git a/app/src/main/res/layout/activity_app_update.xml b/app/src/main/res/layout/activity_app_update.xml index 61b06e8a..c8226516 100644 --- a/app/src/main/res/layout/activity_app_update.xml +++ b/app/src/main/res/layout/activity_app_update.xml @@ -31,7 +31,7 @@ app:layout_constraintBottom_toTopOf="@+id/gmeTextView" app:layout_constraintTop_toBottomOf="@+id/imageView4" app:layout_constraintVertical_bias="0.0" - app:layout_constraintVertical_chainStyle="packed" /> + app:layout_constraintVertical_chainStyle="spread_inside" /> @@ -75,7 +74,7 @@ app:layout_constraintTop_toBottomOf="@+id/gmeTextViewDetail">