From 830a13f2789e3bea68e859a0d285b53f6fbd0e6d Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 25 Aug 2018 13:55:49 +0000 Subject: [PATCH] Connect billing client for Play store installs only --- .../main/java/eu/faircode/email/ActivityView.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index 93f21c9251..52b9a40b4d 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -83,7 +83,7 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack private DrawerLayout drawerLayout; private ListView drawerList; private ActionBarDrawerToggle drawerToggle; - private BillingClient billingClient; + private BillingClient billingClient = null; private boolean newIntent = false; @@ -314,8 +314,10 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack } }.load(this, new Bundle()); - billingClient = BillingClient.newBuilder(this).setListener(this).build(); - billingClient.startConnection(billingClientStateListener); + if (Helper.isPlayStoreInstall(this)) { + billingClient = BillingClient.newBuilder(this).setListener(this).build(); + billingClient.startConnection(billingClientStateListener); + } checkIntent(getIntent()); } @@ -360,7 +362,7 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack getSupportFragmentManager().popBackStack("unified", 0); } - if (billingClient.isReady()) + if (billingClient != null && billingClient.isReady()) queryPurchases(); } @@ -379,7 +381,8 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack @Override protected void onDestroy() { - billingClient.endConnection(); + if (billingClient != null) + billingClient.endConnection(); super.onDestroy(); }