Preyea Regmi
6 years ago
8 changed files with 273 additions and 19 deletions
-
143app/src/main/java/com/gmeremit/online/gmeremittance_native/appupdate/AppUpdateActivity.java
-
64app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/model/AppUpdateModel.java
-
14app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/model/UserInfoModelV2.java
-
32app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2Presenter.java
-
2app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/presenter/HomeV2PresenterInterface.java
-
29app/src/main/java/com/gmeremit/online/gmeremittance_native/homeV2/view/HomeActivityV2.java
-
1app/src/main/java/com/gmeremit/online/gmeremittance_native/loginV2/model/LoginModelV2.java
-
7app/src/main/res/layout/activity_app_update.xml
@ -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); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
@ -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; |
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue