GooglePlayUtils: convert to Kotlin, fix spotbugs

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey Vilas 2022-03-18 13:58:08 +01:00
parent abf14b52cf
commit d63d22d066
No known key found for this signature in database
GPG key ID: 2585783189A62105

View file

@ -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
}
}
}