Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaozhan committed Jun 27, 2022
2 parents 1815b88 + dcd54b2 commit 04f8ada
Show file tree
Hide file tree
Showing 76 changed files with 1,287 additions and 168 deletions.
1 change: 1 addition & 0 deletions .github/auto_assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addAssignees: author
12 changes: 1 addition & 11 deletions .github/workflows/board.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,7 @@ jobs:
status_value: "🚧 In Progress"

- name: 'Move PR to "🏗 PR Review"'
if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'review_requested')
uses: leonsteinhaeuser/[email protected]
with:
gh_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
organization: Oztechan
project_id: 2
resource_node_id: ${{ github.event.pull_request.node_id }}
status_value: "🏗 PR Review"

- name: 'Move PR to "🏗 PR Review"'
if: github.event_name == 'pull_request' && github.event.action == 'ready_for_review'
if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'ready_for_review')
uses: leonsteinhaeuser/[email protected]
with:
gh_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
Expand Down
23 changes: 19 additions & 4 deletions .github/workflows/dependency.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,35 @@ jobs:
with:
fetch-depth: 0

- name: Adding secret files
run: |
mkdir android/src/release
echo "${{ secrets.RELEASE_GOOGLE_SERVICES_JSON_ASC }}" > google-services.json.asc
gpg -d --passphrase "${{ secrets.SECRET_PASSWORD }}" --batch google-services.json.asc > android/src/release/google-services.json
mkdir android/src/debug
echo "${{ secrets.DEBUG_GOOGLE_SERVICES_JSON_ASC }}" > google-services.json.asc
gpg -d --passphrase "${{ secrets.SECRET_PASSWORD }}" --batch google-services.json.asc > android/src/debug/google-services.json
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Run dependencyUpdates Task
run: ./gradlew dependencyUpdates --parallel
- name: Run dependencyUpdates and buildHealth tasks
run: ./gradlew dependencyUpdates buildHealth --parallel

- name: Upload dependencies report
- name: Upload Dependency Updates report
uses: actions/upload-artifact@v2
with:
name: report.txt
name: dependency-updates
path: build/dependencyUpdates/report.txt

- name: Upload Build Healt Report
uses: actions/upload-artifact@v2
with:
name: build-health
path: build/reports/dependency-analysis/build-health-report.txt

- name: Set Job Status
id: status
run: echo "::set-output name=status::success"
Expand Down
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,3 @@
.cxx
local.properties
secret.properties

# Xcode
*.xcworkspacedata
*.xcuserstate
*.xcscheme
xcschememanagement.plist
*.xcbkptlist
8 changes: 5 additions & 3 deletions ad/src/google/kotlin/com/oztechan/ccc/ad/AdManagerImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ class AdManagerImpl : AdManager {
width.toFloat()
}

adSize = AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(
context,
(adWidthPixels / resources.displayMetrics.density).toInt()
setAdSize(
AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(
context,
(adWidthPixels / resources.displayMetrics.density).toInt()
)
)
adUnitId = adId
adListener = object : AdListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class CalculatorFragment : BaseVBFragment<FragmentCalculatorBinding>() {
}
CalculatorEffect.MaximumInput -> showSnack(
requireView(),
R.string.max_input
R.string.text_max_input
)
CalculatorEffect.OpenBar -> navigate(
R.id.calculatorFragment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class SettingsFragment : BaseVBFragment<FragmentSettingsBinding>() {
with(it) {
binding.loadingView.visibleIf(loading)
binding.itemCurrencies.settingsItemValue.text = requireContext().getString(
R.string.settings_item_currencies_value,
R.string.settings_active_item_value,
activeCurrencyCount
)
binding.itemTheme.settingsItemValue.text = appThemeType.typeName
Expand Down Expand Up @@ -184,6 +184,7 @@ class SettingsFragment : BaseVBFragment<FragmentSettingsBinding>() {
requireView(),
R.string.txt_ads_already_disabled
)
SettingsEffect.OpenWatchers -> TODO("No Android implementation yet")
}
}.launchIn(viewLifecycleOwner.lifecycleScope)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ package com.oztechan.ccc.backend.util

fun ClassLoader.getResourceByName(
source: String
) = getResource(source)?.readText() ?: ""
) = getResource(source)?.readText().orEmpty()
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/ProjectSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import java.io.File
object ProjectSettings {

private const val MAYOR_VERSION = 2
private const val MINOR_VERSION = 6
private const val MINOR_VERSION = 7

// git rev-list --first-parent --count master +1
private const val VERSION_DIF = 713
private const val VERSION_DIF = 728
private const val BASE_VERSION_CODE = 316

const val PROJECT_ID = "com.oztechan.ccc"
Expand Down
24 changes: 12 additions & 12 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

@Suppress("SpellCheckingInspection")
object Versions {
const val KOTLIN = "1.6.21"
const val KSP = "$KOTLIN-1.0.5"
const val ANDROID_GRADLE_PLUGIN = "7.1.3"
const val ANDROID_MATERIAL = "1.6.0"
const val CONSTRAINT_LAYOUT = "2.1.3"
const val KOTLIN = "1.7.0"
const val KSP = "$KOTLIN-1.0.6"
const val ANDROID_GRADLE_PLUGIN = "7.2.1"
const val ANDROID_MATERIAL = "1.6.1"
const val CONSTRAINT_LAYOUT = "2.1.4"
const val KTOR = "1.6.8"
const val LOG_BACK = "1.2.11"
const val KOIN = "3.1.6"
Expand All @@ -17,8 +17,8 @@ object Versions {
const val FIREBASE_REMOTE_CONFIG = "21.1.0"
const val DESUGARING = "1.1.5"
const val GSM = "4.3.10"
const val CRASHLYTICS = "2.8.1"
const val ADMOB = "20.6.0"
const val CRASHLYTICS = "2.9.0"
const val ADMOB = "21.0.0"
const val NAVIGATION = "2.3.5"
const val PLAY_CORE = "1.10.3"
const val KOTLIN_X_DATE_TIME = "0.3.2"
Expand All @@ -27,15 +27,15 @@ object Versions {
const val LEAK_CANARY = "2.9.1"
const val SQL_DELIGHT = "1.5.3"
const val LIFECYCLE = "2.4.1"
const val MOKO_RESOURCES = "0.19.1"
const val MOKO_RESOURCES = "0.20.1"
const val DEPENDENCY_UPDATES = "0.42.0"
const val BUILD_HEALTH = "1.1.0"
const val BUILD_KONFIG = "0.11.0"
const val BUILD_HEALTH = "1.5.0"
const val BUILD_KONFIG = "0.12.0"
const val WORK_RUNTIME = "2.7.1"
const val SPLASH_SCREEN = "1.0.0-alpha02"
const val KOVER = "0.5.0"
const val KOVER = "0.5.1"
const val ROOT_BEER = "0.1.0"
const val MOCKATIVE = "1.1.4"
const val MOCKATIVE = "1.2.5"
const val SCOPE_MOB = "2.1.5"
const val PARSER_MOB = "1.1.6"
const val BASE_MOB = "2.1.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package com.oztechan.ccc.client.util

import com.oztechan.ccc.client.viewmodel.watchers.WatchersData
import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
import java.util.Locale
Expand All @@ -25,3 +26,8 @@ actual fun Double.getFormatted(): String {
decimalFormat = "$decimalFormat#"
return DecimalFormat(decimalFormat, symbols).format(this)
}

actual fun Double.removeScientificNotation() = DecimalFormat("#.#").apply {
maximumFractionDigits = WatchersData.MAXIMUM_INPUT
decimalFormatSymbols = DecimalFormatSymbols.getInstance(Locale.ENGLISH)
}.format(this)
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
package com.oztechan.ccc.client.di.module

import com.oztechan.ccc.client.di.viewModelDefinition
import com.oztechan.ccc.client.helper.SessionManager
import com.oztechan.ccc.client.helper.SessionManagerImpl
import com.oztechan.ccc.client.manager.background.BackgroundManager
import com.oztechan.ccc.client.manager.background.BackgroundManagerImpl
import com.oztechan.ccc.client.manager.session.SessionManager
import com.oztechan.ccc.client.manager.session.SessionManagerImpl
import com.oztechan.ccc.client.viewmodel.adremove.AdRemoveViewModel
import com.oztechan.ccc.client.viewmodel.calculator.CalculatorViewModel
import com.oztechan.ccc.client.viewmodel.currencies.CurrenciesViewModel
import com.oztechan.ccc.client.viewmodel.main.MainViewModel
import com.oztechan.ccc.client.viewmodel.selectcurrency.SelectCurrencyViewModel
import com.oztechan.ccc.client.viewmodel.settings.SettingsViewModel
import com.oztechan.ccc.client.viewmodel.watchers.WatchersViewModel
import com.oztechan.ccc.config.ConfigManager
import com.oztechan.ccc.config.ConfigManagerImpl
import org.koin.dsl.module

var clientModule = module {
viewModelDefinition { SettingsViewModel(get(), get(), get(), get(), get()) }
viewModelDefinition { SettingsViewModel(get(), get(), get(), get(), get(), get()) }
viewModelDefinition { MainViewModel(get(), get(), get()) }
viewModelDefinition { CurrenciesViewModel(get(), get(), get()) }
viewModelDefinition { CalculatorViewModel(get(), get(), get(), get(), get()) }
viewModelDefinition { SelectCurrencyViewModel(get()) }
viewModelDefinition { AdRemoveViewModel(get()) }
viewModelDefinition { WatchersViewModel(get(), get()) }

single<ConfigManager> { ConfigManagerImpl() }
single<SessionManager> { SessionManagerImpl(get(), get()) }
single<BackgroundManager> { BackgroundManagerImpl(get(), get()) }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.oztechan.ccc.client.manager.background

interface BackgroundManager {
fun shouldSendNotification(): Boolean
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.oztechan.ccc.client.manager.background

import co.touchlab.kermit.Logger
import com.oztechan.ccc.client.util.getConversionByName
import com.oztechan.ccc.common.api.repo.ApiRepository
import com.oztechan.ccc.common.db.watcher.WatcherRepository
import kotlinx.coroutines.runBlocking

class BackgroundManagerImpl(
private val watchersRepository: WatcherRepository,
private val apiRepository: ApiRepository
) : BackgroundManager {

init {
Logger.d { "BackgroundManagerImpl init" }
}

@Suppress("LabeledExpression", "TooGenericExceptionCaught")
override fun shouldSendNotification() = try {
Logger.d { "BackgroundManagerImpl shouldSendNotification" }

runBlocking {
watchersRepository.getWatchers().forEach { watcher ->
apiRepository
.getRatesByBackend(watcher.base)
.rates
.getConversionByName(watcher.target)
?.let { conversionRate ->
when {
watcher.isGreater && conversionRate > watcher.rate -> return@runBlocking true
!watcher.isGreater && conversionRate < watcher.rate -> return@runBlocking true
}
}
}
return@runBlocking false
}
} catch (e: Exception) {
Logger.w { "BackgroundManagerImpl shouldSendNotification error: $e" }
false
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.oztechan.ccc.client.helper
package com.oztechan.ccc.client.manager.session

interface SessionManager {
fun shouldShowBannerAd(): Boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.oztechan.ccc.client.helper
package com.oztechan.ccc.client.manager.session

import com.github.submob.scopemob.mapTo
import com.github.submob.scopemob.whether
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.oztechan.ccc.client.mapper

import com.oztechan.ccc.client.util.removeScientificNotation
import com.oztechan.ccc.common.model.Watcher
import com.oztechan.ccc.client.model.Watcher as WatcherUIModel

fun Watcher.toUIModel() = WatcherUIModel(
id = id,
base = base,
target = target,
isGreater = isGreater,
rate = rate.removeScientificNotation()
)

fun List<Watcher>.toUIModelList() = map {
it.toUIModel()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.oztechan.ccc.client.model

data class Watcher(
val id: Long,
val base: String,
val target: String,
val isGreater: Boolean,
val rate: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import com.oztechan.ccc.common.model.Rates

expect fun Double.getFormatted(): String

expect fun Double.removeScientificNotation(): String

fun Rates?.calculateResult(name: String, input: String?) = this
?.whetherNot { input.isNullOrEmpty() }
?.getConversionByName(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.github.submob.scopemob.mapTo
import com.github.submob.scopemob.whether
import com.github.submob.scopemob.whetherNot
import com.oztechan.ccc.client.base.BaseSEEDViewModel
import com.oztechan.ccc.client.helper.SessionManager
import com.oztechan.ccc.client.manager.session.SessionManager
import com.oztechan.ccc.client.mapper.toRates
import com.oztechan.ccc.client.mapper.toTodayResponse
import com.oztechan.ccc.client.mapper.toUIModelList
Expand Down Expand Up @@ -90,9 +90,8 @@ class CalculatorViewModel(
.launchIn(clientScope)
}

private fun getRates() = data.rates?.let { rates ->
calculateConversions(rates)
_state.update(rateState = RateState.Cached(rates.date))
private fun getRates() = data.rates?.let {
calculateConversions(it, RateState.Cached(it.date))
} ?: clientScope.launch {
runCatching { apiRepository.getRatesByBackend(settingsRepository.currentBase) }
.onFailure(::getRatesFailed)
Expand All @@ -102,8 +101,7 @@ class CalculatorViewModel(
private fun getRatesSuccess(currencyResponse: CurrencyResponse) = currencyResponse
.toRates().let {
data.rates = it
calculateConversions(it)
_state.update(rateState = RateState.Online(it.date))
calculateConversions(it, RateState.Online(it.date))
}.also {
offlineRatesRepository.insertOfflineRates(currencyResponse.toTodayResponse())
}
Expand All @@ -112,9 +110,8 @@ class CalculatorViewModel(
Logger.w(t) { "CalculatorViewModel getRatesFailed" }
offlineRatesRepository.getOfflineRatesByBase(
settingsRepository.currentBase
)?.let { offlineRates ->
calculateConversions(offlineRates)
_state.update(rateState = RateState.Offline(offlineRates.date))
)?.let {
calculateConversions(it, RateState.Offline(it.date))
} ?: clientScope.launch {
Logger.w(Exception("No offline rates")) { this@CalculatorViewModel::class.simpleName.toString() }

Expand Down Expand Up @@ -153,10 +150,11 @@ class CalculatorViewModel(
}
}

private fun calculateConversions(rates: Rates?) = _state.update(
private fun calculateConversions(rates: Rates, rateState: RateState) = _state.update(
currencyList = _state.value.currencyList.onEach {
it.rate = rates.calculateResult(it.name, _state.value.output)
},
rateState = rateState,
loading = false
)

Expand All @@ -166,7 +164,7 @@ class CalculatorViewModel(
_state.update(
base = newBase,
input = _state.value.input,
symbol = currencyRepository.getCurrencyByName(newBase)?.symbol ?: ""
symbol = currencyRepository.getCurrencyByName(newBase)?.symbol.orEmpty()
)
}

Expand Down
Loading

0 comments on commit 04f8ada

Please sign in to comment.