|
|
@ -1,8 +1,12 @@ |
|
|
|
package com.gmeremit.online.gmeremittance_native.static_pages.view; |
|
|
|
|
|
|
|
import android.content.ComponentName; |
|
|
|
import android.content.Context; |
|
|
|
import android.content.Intent; |
|
|
|
import android.content.pm.ActivityInfo; |
|
|
|
import android.content.pm.PackageInfo; |
|
|
|
import android.content.pm.PackageManager; |
|
|
|
import android.content.pm.ResolveInfo; |
|
|
|
import android.net.Uri; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.support.annotation.Nullable; |
|
|
@ -11,11 +15,14 @@ import android.view.View; |
|
|
|
import android.widget.ImageView; |
|
|
|
import android.widget.TextView; |
|
|
|
|
|
|
|
import com.gmeremit.online.gmeremittance_native.BuildConfig; |
|
|
|
import com.gmeremit.online.gmeremittance_native.R; |
|
|
|
import com.gmeremit.online.gmeremittance_native.static_pages.StaticPagesContract; |
|
|
|
import com.gmeremit.online.gmeremittance_native.static_pages.presenter.StaticPagesPresenter; |
|
|
|
import com.gmeremit.online.gmeremittance_native.utils.Utils; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import butterknife.BindView; |
|
|
|
import butterknife.ButterKnife; |
|
|
|
import butterknife.OnClick; |
|
|
@ -53,17 +60,59 @@ public class AboutGME extends AppCompatActivity implements StaticPagesContract.I |
|
|
|
private void init() { |
|
|
|
ButterKnife.bind(this); |
|
|
|
|
|
|
|
try { |
|
|
|
PackageInfo pinfo = getPackageManager().getPackageInfo(getPackageName(), 0); |
|
|
|
String version = String.valueOf(pinfo.versionName); |
|
|
|
txt_app_version.setText(version); |
|
|
|
} catch (PackageManager.NameNotFoundException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
String version = BuildConfig.VERSION_NAME; |
|
|
|
String versionCode=" ("+BuildConfig.VERSION_CODE+")"; |
|
|
|
txt_app_version.setText(version+versionCode); |
|
|
|
|
|
|
|
|
|
|
|
presenter = new StaticPagesPresenter(this); |
|
|
|
} |
|
|
|
|
|
|
|
public static void openAppRating(Context context) { |
|
|
|
// you can also use BuildConfig.APPLICATION_ID |
|
|
|
String appId = context.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 = context.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); |
|
|
|
context.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)); |
|
|
|
context.startActivity(webIntent); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@OnClick({R.id.iv_back, R.id.btn_check_update, R.id.iv_fb, R.id.iv_linkedin}) |
|
|
|
public void onClick(View view) { |
|
|
|
|
|
|
@ -72,7 +121,7 @@ public class AboutGME extends AppCompatActivity implements StaticPagesContract.I |
|
|
|
finish(); |
|
|
|
break; |
|
|
|
case R.id.btn_check_update: |
|
|
|
|
|
|
|
openAppRating(this); |
|
|
|
break; |
|
|
|
case R.id.iv_fb: |
|
|
|
presenter.onLinkClicked(FACEBOOK); |
|
|
|