|
@@ -15,38 +15,32 @@
|
|
* GNU Affero General Public License for more details.
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
+ * along with this program. If not, see <http:></http:>//www.gnu.org/licenses/>.
|
|
*/
|
|
*/
|
|
|
|
+package com.owncloud.android.utils
|
|
|
|
|
|
-package com.owncloud.android.utils;
|
|
|
|
|
|
+import android.app.Activity
|
|
|
|
+import android.util.Log
|
|
|
|
+import com.google.android.gms.common.ConnectionResult
|
|
|
|
+import com.google.android.gms.common.GoogleApiAvailability
|
|
|
|
|
|
-import android.app.Activity;
|
|
|
|
-import android.util.Log;
|
|
|
|
|
|
+object GooglePlayUtils {
|
|
|
|
+ private const val PLAY_SERVICES_RESOLUTION_REQUEST = 9000
|
|
|
|
+ private const val TAG = "GooglePlayUtils"
|
|
|
|
|
|
-import com.google.android.gms.common.ConnectionResult;
|
|
|
|
-import com.google.android.gms.common.GoogleApiAvailability;
|
|
|
|
-
|
|
|
|
-public final class GooglePlayUtils {
|
|
|
|
- private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
|
|
|
|
- private static final String TAG = "GooglePlayUtils";
|
|
|
|
-
|
|
|
|
- private GooglePlayUtils() {
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static boolean checkPlayServices(Activity activity) {
|
|
|
|
- GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
|
|
|
|
- int resultCode = apiAvailability.isGooglePlayServicesAvailable(activity);
|
|
|
|
|
|
+ @JvmStatic
|
|
|
|
+ fun checkPlayServices(activity: Activity): Boolean {
|
|
|
|
+ val apiAvailability = GoogleApiAvailability.getInstance()
|
|
|
|
+ val resultCode = apiAvailability.isGooglePlayServicesAvailable(activity)
|
|
if (resultCode != ConnectionResult.SUCCESS) {
|
|
if (resultCode != ConnectionResult.SUCCESS) {
|
|
if (apiAvailability.isUserResolvableError(resultCode)) {
|
|
if (apiAvailability.isUserResolvableError(resultCode)) {
|
|
- apiAvailability.getErrorDialog(activity, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
|
|
|
|
- .show();
|
|
|
|
|
|
+ apiAvailability.getErrorDialog(activity, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)?.show()
|
|
} else {
|
|
} else {
|
|
- Log.i(TAG, "This device is not supported.");
|
|
|
|
- activity.finish();
|
|
|
|
|
|
+ Log.i(TAG, "This device is not supported.")
|
|
|
|
+ activity.finish()
|
|
}
|
|
}
|
|
- return false;
|
|
|
|
|
|
+ return false
|
|
}
|
|
}
|
|
- return true;
|
|
|
|
|
|
+ return true
|
|
}
|
|
}
|
|
-
|
|
|
|
-}
|
|
|
|
|
|
+}
|