Browse Source

In app update completed

master
Preyea Regmi 6 years ago
parent
commit
6afb81894c
  1. 143
      app/src/main/java/com/gmeremit/online/gmeremittance_native/appupdate/AppUpdateActivity.java
  2. 64
      app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/model/AppUpdateModel.java
  3. 14
      app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/model/UserInfoModelV2.java
  4. 32
      app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2Presenter.java
  5. 2
      app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2PresenterInterface.java
  6. 29
      app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/view/HomeActivityV2.java
  7. 1
      app/src/main/java/com/gmeremit/online/gmeremittance_native/loginV2/model/LoginModelV2.java
  8. 7
      app/src/main/res/layout/activity_app_update.xml

143
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<ResolveInfo> 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);
}
}
}

64
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;
}
}

14
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<AppUpdateModel> appUpdate = null;
public String getUserId() {
return userId;
}
@ -380,4 +386,12 @@ public class UserInfoModelV2 {
public void setPennyTestStatus(String pennyTestStatus) {
this.pennyTestStatus = pennyTestStatus;
}
public List<AppUpdateModel> getAppUpdate() {
return appUpdate;
}
public void setAppUpdate(List<AppUpdateModel> appUpdate) {
this.appUpdate = appUpdate;
}
}

32
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;

2
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);
}
}

29
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();

1
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;
}
}

7
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" />
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView
android:id="@+id/gmeTextView"
@ -59,9 +59,8 @@
android:paddingTop="5dp"
android:paddingEnd="20dp"
android:paddingBottom="15dp"
android:text="The current version of this app is no longer supported. We apologize for any inconvenience we may have caused you."
android:text="This version of the app is out of date and will stop working soon. To keep using GME, please install the latest update."
android:textSize="14sp"
app:layout_constraintBottom_toTopOf="@+id/frameLayout2"
app:layout_constraintTop_toBottomOf="@+id/gmeTextView"
app:txtfontName="@string/regular" />
@ -75,7 +74,7 @@
app:layout_constraintTop_toBottomOf="@+id/gmeTextViewDetail">
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeButton
android:id="@+id/btn_login"
android:id="@+id/btn_update"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"

Loading…
Cancel
Save