From 1abc9459b5338ad688503f167cf646f4f4d9cb23 Mon Sep 17 00:00:00 2001 From: "k.bastrykina" Date: Wed, 31 Jul 2024 19:08:27 +0700 Subject: [PATCH 1/2] ALCO-666. Add fun get online check settings from impl database --- api/build.gradle | 2 +- .../api/provider/settings/SettingsContract.kt | 26 ++++++--- .../egais/api/query/settings/SettingsQuery.kt | 56 +++++++++++++++++++ 3 files changed, 76 insertions(+), 8 deletions(-) diff --git a/api/build.gradle b/api/build.gradle index 33b3fbf..130db29 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -11,7 +11,7 @@ android { minSdkVersion 22 targetSdkVersion 29 versionCode 800 - versionName "0.0.8" + versionName "0.0.8-ALCO-666" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/api/src/main/java/ru/evotor/egais/api/provider/settings/SettingsContract.kt b/api/src/main/java/ru/evotor/egais/api/provider/settings/SettingsContract.kt index 26a7168..a36d17d 100644 --- a/api/src/main/java/ru/evotor/egais/api/provider/settings/SettingsContract.kt +++ b/api/src/main/java/ru/evotor/egais/api/provider/settings/SettingsContract.kt @@ -14,6 +14,10 @@ internal object SettingsContract { const val CLOUD_SYNCHRONIZATION_COLUMN_NAME = "CLOUD_SYNCHRONIZATION" const val BEER_TAPS_ENABLED_COLUMN_NAME = "BEER_TAPS" const val EXCISE_ALCOHOL_ON_TAP_ENABLED_COLUMN_NAME = "EXCISE_ALCOHOL_ON_TAP" + const val X_API_KEY_COLUMN_NAME = "X_API_KEY" + const val ONLINE_CHECK_ENABLED_COLUMN_NAME = "ONLINE_CHECK_ENABLED" + const val ONLINE_CHECK_SELL_MARK_SETTINGS_ENABLED_COLUMN_NAME = "CODES_CHECK_SELL_MARK_SETTINGS_ENABLED" + const val ONLINE_CHECK_BIND_KEG_SETTINGS_ENABLED_COLUMN_NAME = "CODES_CHECK_BIND_KEG_SETTINGS_ENABLED" const val BEER_TAPS_SETTINGS_CODES_CHECK_ENABLED_COLUMN_NAME = "beerTapsSettingsCodesCheckEnabled" const val BEER_TAPS_SETTINGS_X_API_KEY_COLUMN_NAME = "beerTapsSettingsXApiKey" const val BEER_TAPS_SETTINGS_INN_FROM_BEER_TAPS_COLUMN_NAME = "beerTapsSettingsInnFromBeerTaps" @@ -25,19 +29,27 @@ internal object SettingsContract { private const val CLOUD_SYNCHRONIZATION_PATH = "CloudSynchronization" private const val BEER_TAPS_ENABLED_PATH = "BeerTapsEnabled" private const val EXCISE_ALCOHOL_ON_TAP_ENABLED_PATH = "ExciseAlcoholOnTapEnabled" - private const val CODES_CHECK_ENABLED_PATH= "CodesCheckEnabled" + private const val CODES_CHECK_ENABLED_PATH = "CodesCheckEnabled" + private const val ONLINE_CHECK_ENABLED_PATH = "OnlineCheckEnabled" + private const val ONLINE_CHECK_SELL_MARK_SETTINGS_ENABLED_PATH = "OnlineCheckSellMarkEnabled" + private const val ONLINE_CHECK_BIND_KEG_SETTINGS_ENABLED_PATH = "OnlineCheckBindKegEnabled" private const val X_API_KEY_PATH = "XApiKey" private const val INN_FROM_BEER_TAPS_PATH = "InnFromBeerTaps" private val BASE_URI: Uri = Uri.parse("content://$AUTHORITY") private val BASE_URI_FROM_EGAIS_UI: Uri = Uri.parse("content://$AUTHORITY_EGAIS_UI") val ALCOHOL_CONTROL_TYPE_URI: Uri = Uri.withAppendedPath(BASE_URI, ALCOHOL_CONTROL_TYPE_PATH) - val ALCOHOL_ENABLED_URI: Uri = Uri.withAppendedPath(BASE_URI, ALCOHOL_ENABLED_PATH) - val LINK_EGAIS_COMMODITY_URI: Uri = Uri.withAppendedPath(BASE_URI, LINK_EGAIS_COMMODITY_PATH) - val UTM_SYNCHRONIZATION_URI: Uri = Uri.withAppendedPath(BASE_URI, UTM_SYNCHRONIZATION_PATH) - val CLOUD_SYNCHRONIZATION_URI: Uri = Uri.withAppendedPath(BASE_URI, CLOUD_SYNCHRONIZATION_PATH) - val BEER_TAPS_ENABLED_URI: Uri = Uri.withAppendedPath(BASE_URI, BEER_TAPS_ENABLED_PATH) - val EXCISE_ALCOHOL_ON_TAP_ENABLED_URI: Uri = Uri.withAppendedPath(BASE_URI, EXCISE_ALCOHOL_ON_TAP_ENABLED_PATH) + val ALCOHOL_ENABLED_URI: Uri = Uri.withAppendedPath(BASE_URI, ALCOHOL_ENABLED_PATH) + val LINK_EGAIS_COMMODITY_URI: Uri = Uri.withAppendedPath(BASE_URI, LINK_EGAIS_COMMODITY_PATH) + val UTM_SYNCHRONIZATION_URI: Uri = Uri.withAppendedPath(BASE_URI, UTM_SYNCHRONIZATION_PATH) + val CLOUD_SYNCHRONIZATION_URI: Uri = Uri.withAppendedPath(BASE_URI, CLOUD_SYNCHRONIZATION_PATH) + val BEER_TAPS_ENABLED_URI: Uri = Uri.withAppendedPath(BASE_URI, BEER_TAPS_ENABLED_PATH) + val EXCISE_ALCOHOL_ON_TAP_ENABLED_URI: Uri = Uri.withAppendedPath(BASE_URI, EXCISE_ALCOHOL_ON_TAP_ENABLED_PATH) + val ONLINE_CHECK_ENABLED_FROM_IMPL_URI: Uri = Uri.withAppendedPath(BASE_URI, ONLINE_CHECK_ENABLED_PATH) + val ONLINE_CHECK_SELL_MARK_SETTINGS_ENABLED_FROM_IMPL_URI: Uri = Uri.withAppendedPath(BASE_URI, ONLINE_CHECK_SELL_MARK_SETTINGS_ENABLED_PATH) + val ONLINE_CHECK_BIND_KEG_SETTINGS_ENABLED_FROM_IMPL_URI: Uri = Uri.withAppendedPath(BASE_URI, ONLINE_CHECK_BIND_KEG_SETTINGS_ENABLED_PATH) + val X_API_KEY_FROM_IMPL_URI: Uri = Uri.withAppendedPath(BASE_URI, X_API_KEY_PATH) + val CODES_CHECK_ENABLED_URI: Uri = Uri.withAppendedPath(BASE_URI_FROM_EGAIS_UI, CODES_CHECK_ENABLED_PATH) val X_API_KEY_URI: Uri = Uri.withAppendedPath(BASE_URI_FROM_EGAIS_UI, X_API_KEY_PATH) val INN_FROM_BEER_TAPS_URI: Uri = Uri.withAppendedPath(BASE_URI_FROM_EGAIS_UI, INN_FROM_BEER_TAPS_PATH) diff --git a/api/src/main/java/ru/evotor/egais/api/query/settings/SettingsQuery.kt b/api/src/main/java/ru/evotor/egais/api/query/settings/SettingsQuery.kt index a710ec7..f95a551 100644 --- a/api/src/main/java/ru/evotor/egais/api/query/settings/SettingsQuery.kt +++ b/api/src/main/java/ru/evotor/egais/api/query/settings/SettingsQuery.kt @@ -155,4 +155,60 @@ class SettingsQuery { cursor.getString(cursor.getColumnIndex(SettingsContract.BEER_TAPS_SETTINGS_INN_FROM_BEER_TAPS_COLUMN_NAME)) } } + + fun getXApiKeyFromImpl(context: Context): String? { + return context.contentResolver.query( + SettingsContract.X_API_KEY_FROM_IMPL_URI, + null, + null, + null, + null + ) + ?.use { cursor -> + cursor.moveToFirst() + cursor.getString(cursor.getColumnIndex(SettingsContract.X_API_KEY_COLUMN_NAME)) + } + } + + fun isOnlineCheckEnabled(context: Context): String? { + return context.contentResolver.query( + SettingsContract.ONLINE_CHECK_ENABLED_FROM_IMPL_URI, + null, + null, + null, + null + ) + ?.use { cursor -> + cursor.moveToFirst() + cursor.getString(cursor.getColumnIndex(SettingsContract.ONLINE_CHECK_ENABLED_COLUMN_NAME)) + } + } + + fun isOnlineCheckSellMarkEnabled(context: Context): String? { + return context.contentResolver.query( + SettingsContract.ONLINE_CHECK_SELL_MARK_SETTINGS_ENABLED_FROM_IMPL_URI, + null, + null, + null, + null + ) + ?.use { cursor -> + cursor.moveToFirst() + cursor.getString(cursor.getColumnIndex(SettingsContract.ONLINE_CHECK_SELL_MARK_SETTINGS_ENABLED_COLUMN_NAME)) + } + } + + fun isOnlineCheckBindKegEnabled(context: Context): String? { + return context.contentResolver.query( + SettingsContract.ONLINE_CHECK_BIND_KEG_SETTINGS_ENABLED_FROM_IMPL_URI, + null, + null, + null, + null + ) + ?.use { cursor -> + cursor.moveToFirst() + cursor.getString(cursor.getColumnIndex(SettingsContract.ONLINE_CHECK_BIND_KEG_SETTINGS_ENABLED_COLUMN_NAME)) + } + } } \ No newline at end of file From 9bc7b748eb938d29d61f4074a9ed88f70a867a7d Mon Sep 17 00:00:00 2001 From: "k.bastrykina" Date: Wed, 31 Jul 2024 19:28:58 +0700 Subject: [PATCH 2/2] ALCO-666. Fix fun return type --- api/build.gradle | 2 +- .../egais/api/query/settings/SettingsQuery.kt | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/api/build.gradle b/api/build.gradle index 130db29..a15a5cd 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -11,7 +11,7 @@ android { minSdkVersion 22 targetSdkVersion 29 versionCode 800 - versionName "0.0.8-ALCO-666" + versionName "0.0.8-ALCO-666-1" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/api/src/main/java/ru/evotor/egais/api/query/settings/SettingsQuery.kt b/api/src/main/java/ru/evotor/egais/api/query/settings/SettingsQuery.kt index f95a551..b643b6e 100644 --- a/api/src/main/java/ru/evotor/egais/api/query/settings/SettingsQuery.kt +++ b/api/src/main/java/ru/evotor/egais/api/query/settings/SettingsQuery.kt @@ -170,7 +170,7 @@ class SettingsQuery { } } - fun isOnlineCheckEnabled(context: Context): String? { + fun isOnlineCheckEnabled(context: Context): Boolean { return context.contentResolver.query( SettingsContract.ONLINE_CHECK_ENABLED_FROM_IMPL_URI, null, @@ -181,10 +181,11 @@ class SettingsQuery { ?.use { cursor -> cursor.moveToFirst() cursor.getString(cursor.getColumnIndex(SettingsContract.ONLINE_CHECK_ENABLED_COLUMN_NAME)) - } + ?.toBoolean() + } ?: false } - fun isOnlineCheckSellMarkEnabled(context: Context): String? { + fun isOnlineCheckSellMarkEnabled(context: Context): Boolean { return context.contentResolver.query( SettingsContract.ONLINE_CHECK_SELL_MARK_SETTINGS_ENABLED_FROM_IMPL_URI, null, @@ -195,10 +196,11 @@ class SettingsQuery { ?.use { cursor -> cursor.moveToFirst() cursor.getString(cursor.getColumnIndex(SettingsContract.ONLINE_CHECK_SELL_MARK_SETTINGS_ENABLED_COLUMN_NAME)) - } + ?.toBoolean() + } ?: false } - fun isOnlineCheckBindKegEnabled(context: Context): String? { + fun isOnlineCheckBindKegEnabled(context: Context): Boolean { return context.contentResolver.query( SettingsContract.ONLINE_CHECK_BIND_KEG_SETTINGS_ENABLED_FROM_IMPL_URI, null, @@ -209,6 +211,7 @@ class SettingsQuery { ?.use { cursor -> cursor.moveToFirst() cursor.getString(cursor.getColumnIndex(SettingsContract.ONLINE_CHECK_BIND_KEG_SETTINGS_ENABLED_COLUMN_NAME)) - } + ?.toBoolean() + } ?: false } } \ No newline at end of file