Browse Source

Fix #221

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 6 years ago
parent
commit
0fcc3a7fea

+ 5 - 0
app/src/generic/java/com/nextcloud/talk/utils/ClosedInterfaceImpl.java

@@ -28,4 +28,9 @@ public class ClosedInterfaceImpl implements ClosedInterface {
     public void providerInstallerInstallIfNeededAsync() {
     public void providerInstallerInstallIfNeededAsync() {
         // does absolutely nothing :)
         // does absolutely nothing :)
     }
     }
+
+    @Override
+    public boolean isGooglePlayServicesAvailable() {
+        return false;
+    }
 }
 }

+ 3 - 3
app/src/gplay/java/com/nextcloud/talk/utils/ClosedInterfaceImpl.java

@@ -39,9 +39,9 @@ public class ClosedInterfaceImpl implements ClosedInterface, ProviderInstallList
 
 
     @Override
     @Override
     public boolean isGooglePlayServicesAvailable() {
     public boolean isGooglePlayServicesAvailable() {
-        GoogleApiAvailability api = GoogleApiAvailability.getInstance();
-        int code = api.isGooglePlayServicesAvailable(NextcloudTalkApplication.getSharedApplication().getApplicationContext());
-        return code == ConnectionResult.SUCCESS;
+        GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
+        int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(context);
+        return resultCode == ConnectionResult.SUCCESS;
     }
     }
 
 
     @Override
     @Override

+ 9 - 2
app/src/main/java/com/nextcloud/talk/controllers/AccountVerificationController.java

@@ -46,10 +46,11 @@ import com.nextcloud.talk.models.json.generic.Status;
 import com.nextcloud.talk.models.json.rooms.RoomsOverall;
 import com.nextcloud.talk.models.json.rooms.RoomsOverall;
 import com.nextcloud.talk.models.json.userprofile.UserProfileOverall;
 import com.nextcloud.talk.models.json.userprofile.UserProfileOverall;
 import com.nextcloud.talk.utils.ApiUtils;
 import com.nextcloud.talk.utils.ApiUtils;
-import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder;
+import com.nextcloud.talk.utils.ClosedInterfaceImpl;
 import com.nextcloud.talk.utils.bundle.BundleKeys;
 import com.nextcloud.talk.utils.bundle.BundleKeys;
 import com.nextcloud.talk.utils.database.user.UserUtils;
 import com.nextcloud.talk.utils.database.user.UserUtils;
 import com.nextcloud.talk.utils.preferences.AppPreferences;
 import com.nextcloud.talk.utils.preferences.AppPreferences;
+import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder;
 
 
 import org.greenrobot.eventbus.EventBus;
 import org.greenrobot.eventbus.EventBus;
 import org.greenrobot.eventbus.Subscribe;
 import org.greenrobot.eventbus.Subscribe;
@@ -261,7 +262,13 @@ public class AccountVerificationController extends BaseController {
                     public void onNext(UserEntity userEntity) {
                     public void onNext(UserEntity userEntity) {
                         internalAccountId = userEntity.getId();
                         internalAccountId = userEntity.getId();
 
 
-                        registerForPush();
+                        if (new ClosedInterfaceImpl().isGooglePlayServicesAvailable()) {
+                            registerForPush();
+                        } else {
+                            getActivity().runOnUiThread(() -> progressText.setText(progressText.getText().toString() + "\n" +
+                                    getResources().getString(R.string.nc_push_disabled)));
+                            fetchAndStoreCapabilities();
+                        }
                     }
                     }
 
 
                     @Override
                     @Override

+ 1 - 0
app/src/main/java/com/nextcloud/talk/interfaces/ClosedInterface.java

@@ -22,4 +22,5 @@ package com.nextcloud.talk.interfaces;
 
 
 public interface ClosedInterface {
 public interface ClosedInterface {
     void providerInstallerInstallIfNeededAsync();
     void providerInstallerInstallIfNeededAsync();
+    boolean isGooglePlayServicesAvailable();
 }
 }