mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
GooglePlayUtils: convert to Kotlin, fix spotbugs
Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
abf14b52cf
commit
d63d22d066
1 changed files with 19 additions and 25 deletions
|
@ -15,38 +15,32 @@
|
|||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* 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 (apiAvailability.isUserResolvableError(resultCode)) {
|
||||
apiAvailability.getErrorDialog(activity, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
|
||||
.show();
|
||||
apiAvailability.getErrorDialog(activity, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)?.show()
|
||||
} 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
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue