mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-03-29 03:03:05 -04:00
Refactor and cleanup (#850)
* Move google play check to extension * Extract launching bug report dialog * Add missing extension for fdroid flavor
This commit is contained in:
@@ -12,12 +12,6 @@ import com.google.android.gms.common.ConnectionResult
|
||||
import com.google.android.gms.common.GoogleApiAvailabilityLight
|
||||
import com.suddenh4x.ratingdialog.AppRating
|
||||
|
||||
fun isGooglePlayAvailable(context: Context): Boolean {
|
||||
val a = GoogleApiAvailabilityLight.getInstance()
|
||||
val r = a.isGooglePlayServicesAvailable(context)
|
||||
return r != ConnectionResult.SERVICE_MISSING && r != ConnectionResult.SERVICE_INVALID
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by kevinh on 1/4/15.
|
||||
*/
|
||||
@@ -55,7 +49,8 @@ open class GeeksvilleApplication : Application(), Logging {
|
||||
|
||||
/** Ask user to rate in play store */
|
||||
fun askToRate(activity: AppCompatActivity) {
|
||||
if (!isGooglePlayAvailable(this)) return
|
||||
if (!isGooglePlayAvailable()) return
|
||||
|
||||
exceptionReporter { // we don't want to crash our app because of bugs in this optional feature
|
||||
AppRating.Builder(activity)
|
||||
.setMinimumLaunchTimes(10) // default is 5, 3 means app is launched 3 or more times
|
||||
@@ -76,3 +71,12 @@ open class GeeksvilleApplication : Application(), Logging {
|
||||
isAnalyticsAllowed = isAnalyticsAllowed
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.isGooglePlayAvailable(): Boolean {
|
||||
return GoogleApiAvailabilityLight.getInstance()
|
||||
.isGooglePlayServicesAvailable(this)
|
||||
.let {
|
||||
it != ConnectionResult.SERVICE_MISSING &&
|
||||
it != ConnectionResult.SERVICE_INVALID
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user