-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
70 changed files
with
2,365 additions
and
1,101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
[ | ||
{ | ||
"name": "Google Search Suggestions new design", | ||
"author": "Nail Sadykov", | ||
"flags": [ | ||
{ | ||
"tag": "45369077", | ||
"type": "bool", | ||
"value": "1" | ||
} | ||
], | ||
"package": "com.google.android.libraries.search.googleapp.device#com.google.android.googlequicksearchbox", | ||
"isArchive": false | ||
}, | ||
{ | ||
"name": "Proofreading mode in GBoard", | ||
"author": "GApps Flags & Leaks", | ||
"flags": [ | ||
{ | ||
"tag": "writing_helper", | ||
"type": "bool", | ||
"value": "1" | ||
}, | ||
{ | ||
"tag": "writing_helper_enable_free_chat", | ||
"type": "bool", | ||
"value": "1" | ||
}, | ||
{ | ||
"tag": "writing_helper_chip_shown_as_candidate", | ||
"type": "bool", | ||
"value": "1" | ||
} | ||
], | ||
"package": "com.google.android.inputmethod.latin#com.google.android.inputmethod.latin", | ||
"isArchive": false | ||
}, | ||
{ | ||
"name": "\"Undo\" button in GBoard", | ||
"author": "GApps Flags & Leaks", | ||
"flags": [ | ||
{ | ||
"tag": "undo_access_point", | ||
"type": "bool", | ||
"value": "1" | ||
} | ||
], | ||
"package": "com.google.android.inputmethod.latin#com.google.android.inputmethod.latin", | ||
"isArchive": false | ||
}, | ||
{ | ||
"name": "Enable transparent statusBar in dialer", | ||
"author": "Nail Sadykov", | ||
"flags": [ | ||
{ | ||
"tag": "45372787", | ||
"type": "bool", | ||
"value": "1" | ||
} | ||
], | ||
"package": "com.google.android.dialer.directboot", | ||
"isArchive": false | ||
}, | ||
{ | ||
"name": "Enable docs scanner in Drive", | ||
"author": "Nail Sadykov", | ||
"flags": [ | ||
{ | ||
"tag": "MlkitScanningUiFeature__enable_mlkit_scanning_ui", | ||
"type": "bool", | ||
"value": "1" | ||
} | ||
], | ||
"package": "com.google.apps.drive.android#com.google.android.apps.docs", | ||
"isArchive": false | ||
}, | ||
{ | ||
"name": "Enable MD3 style in Android Auto", | ||
"author": "Nail Sadykov", | ||
"flags": [ | ||
{ | ||
"tag": "SystemUi__material_you_settings_enabled", | ||
"type": "bool", | ||
"value": "1" | ||
} | ||
], | ||
"package": "com.google.android.projection.gearhead", | ||
"isArchive": false | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/src/main/java/ua/polodarb/gmsflags/data/remote/DefaultConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package ua.polodarb.gmsflags.data.remote | ||
|
||
import android.util.Log | ||
import io.ktor.client.HttpClientConfig | ||
import io.ktor.client.plugins.HttpTimeout | ||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation | ||
import io.ktor.client.plugins.logging.LogLevel | ||
import io.ktor.client.plugins.logging.Logger | ||
import io.ktor.client.plugins.logging.Logging | ||
import io.ktor.serialization.kotlinx.json.json | ||
import kotlinx.serialization.json.Json | ||
import ua.polodarb.gmsflags.BuildConfig | ||
|
||
fun HttpClientConfig<*>.setConfig(tag: String) { | ||
install(Logging) { this.setConfig(tag = tag) } | ||
install(ContentNegotiation) { this.setConfig() } | ||
install(HttpTimeout) { this.setConfig() } | ||
} | ||
|
||
private fun Logging.Config.setConfig(tag: String) { | ||
this.level = if (BuildConfig.DEBUG) LogLevel.ALL else LogLevel.NONE | ||
this.logger = object: Logger { | ||
override fun log(message: String) { | ||
Log.e(tag, message) | ||
} | ||
} | ||
} | ||
|
||
private fun ContentNegotiation.Config.setConfig() { | ||
this.json(json = Json { | ||
ignoreUnknownKeys = true | ||
isLenient = true | ||
}) | ||
} | ||
|
||
private const val TIMEOUT = 5000L | ||
|
||
private fun HttpTimeout.HttpTimeoutCapabilityConfiguration.setConfig() { | ||
requestTimeoutMillis = TIMEOUT | ||
connectTimeoutMillis = TIMEOUT | ||
socketTimeoutMillis = TIMEOUT | ||
} |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/ua/polodarb/gmsflags/data/remote/Resource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package ua.polodarb.gmsflags.data.remote | ||
|
||
sealed class Resource<T>(val data: T? = null, val message: String? = null) { | ||
class Success<T>(data: T) : Resource<T>(data) | ||
class Error<T>(exception: Exception? = null, data: T? = null) : | ||
Resource<T>(data, exception?.message) | ||
} |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/ua/polodarb/gmsflags/data/remote/flags/FlagsApiService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package ua.polodarb.gmsflags.data.remote.flags | ||
|
||
import ua.polodarb.gmsflags.data.remote.Resource | ||
import ua.polodarb.gmsflags.data.remote.flags.dto.SuggestedFlagInfo | ||
|
||
interface FlagsApiService { | ||
suspend fun getSuggestedFlags(): Resource<List<SuggestedFlagInfo>> | ||
} | ||
|
||
|
37 changes: 37 additions & 0 deletions
37
app/src/main/java/ua/polodarb/gmsflags/data/remote/flags/FlagsApiServiceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package ua.polodarb.gmsflags.data.remote.flags | ||
|
||
import io.ktor.client.HttpClient | ||
import io.ktor.client.call.body | ||
import io.ktor.client.engine.HttpClientEngine | ||
import io.ktor.client.plugins.defaultRequest | ||
import io.ktor.client.request.get | ||
import io.ktor.client.request.url | ||
import kotlinx.serialization.json.Json | ||
import ua.polodarb.gmsflags.BuildConfig | ||
import ua.polodarb.gmsflags.data.remote.Resource | ||
import ua.polodarb.gmsflags.data.remote.flags.dto.SuggestedFlagInfo | ||
import ua.polodarb.gmsflags.data.remote.setConfig | ||
|
||
private const val BASE_URL = "https://raw.githubusercontent.com/polodarb/GMS-Flags/" | ||
private const val ASSETS_PATH = "/app/src/main/assets/" | ||
private const val LOG_TAG = "FlagsApiService" | ||
|
||
class FlagsApiServiceImpl( | ||
engine: HttpClientEngine | ||
): FlagsApiService { | ||
private val client = HttpClient(engine) { | ||
this.setConfig(LOG_TAG) | ||
defaultRequest { | ||
url(BASE_URL + (if (BuildConfig.DEBUG) "develop" else "master") + ASSETS_PATH) | ||
} | ||
} | ||
|
||
override suspend fun getSuggestedFlags(): Resource<List<SuggestedFlagInfo>> { | ||
return try { | ||
val response: String = client.get { url("suggestedFlags.json") }.body() | ||
Resource.Success(Json.decodeFromString(response)) | ||
} catch (e: Exception) { | ||
Resource.Error(e) | ||
} | ||
} | ||
} |
Oops, something went wrong.