Skip to content

Commit

Permalink
Merge branch 'Development'
Browse files Browse the repository at this point in the history
  • Loading branch information
5hahryar committed May 17, 2022
2 parents bd90a5c + 139c313 commit 81dda0f
Show file tree
Hide file tree
Showing 99 changed files with 3,228 additions and 1,619 deletions.
3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ plugins {
id 'kotlin-android'
}
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 31
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.shahryar.cryptoprice"
minSdkVersion 21
targetSdkVersion 31
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.2.0"

Expand All @@ -33,7 +32,7 @@ android {
}

composeOptions {
kotlinCompilerExtensionVersion '1.0.1'
kotlinCompilerExtensionVersion '1.1.1'
}

kotlinOptions {
Expand All @@ -56,8 +55,9 @@ dependencies {
def nav_version = "2.3.5"
def version_retrofit = "2.9.0"
def version_moshi = "1.11.0"
def room_version = "2.3.0"
def room_version = "2.4.0"

implementation project(":shared")
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'
Expand All @@ -71,6 +71,7 @@ dependencies {

// Compose
implementation 'androidx.activity:activity-compose:1.4.0'
implementation "androidx.navigation:navigation-compose:2.4.0-rc01"
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0'
implementation 'androidx.compose.material:material:1.0.4'
implementation 'androidx.compose.animation:animation:1.0.4'
Expand Down Expand Up @@ -102,8 +103,9 @@ dependencies {
implementation "androidx.datastore:datastore-preferences:1.0.0"

//Koin
implementation "io.insert-koin:koin-core:3.1.2"
implementation "io.insert-koin:koin-android:3.1.2"
implementation "io.insert-koin:koin-core:3.1.5"
implementation "io.insert-koin:koin-android:3.1.5"
implementation "io.insert-koin:koin-androidx-compose:3.1.5"

testImplementation 'junit:junit:4.13.2'
testImplementation "androidx.test.ext:junit-ktx:1.1.3"
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.CryptoPrice">
<activity android:name=".widgets.WidgetConfigureActivity"
<activity android:name="com.shahryar.cryptoprice.ui.widgets.WidgetConfigureActivity"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
</intent-filter>
</activity>
<activity android:name=".main.MainActivity"
<activity android:name="com.shahryar.cryptoprice.ui.main.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -27,7 +27,7 @@
</intent-filter>
</activity>

<receiver android:name=".widgets.CryptoPriceWidgetProviderSmall"
<receiver android:name="com.shahryar.cryptoprice.ui.widgets.CryptoPriceWidgetProviderSmall"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
Expand All @@ -37,7 +37,7 @@
android:name="android.appwidget.provider"
android:resource="@xml/widget_small" />
</receiver>
<receiver android:name=".widgets.CryptoPriceWidgetProviderMedium"
<receiver android:name="com.shahryar.cryptoprice.ui.widgets.CryptoPriceWidgetProviderMedium"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
Expand All @@ -47,7 +47,7 @@
android:name="android.appwidget.provider"
android:resource="@xml/widget_medium" />
</receiver>
<receiver android:name=".widgets.CryptoPriceWidgetProviderLarge"
<receiver android:name="com.shahryar.cryptoprice.ui.widgets.CryptoPriceWidgetProviderLarge"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
package com.shahryar.cryptoprice

import android.app.Application
import android.content.Context
import android.util.Log
import com.shahryar.cryptoprice.core.di.cryptoPriceModules
import com.shahryar.shared.data.CryptoPriceSettings
import com.shahryar.shared.di.initKoin
import org.koin.android.ext.koin.androidContext
import org.koin.core.context.startKoin

class CryptoPriceApplication: Application() {

companion object {
//TODO: Fix these
var context: Context = CryptoPriceApplication.context
var apiKey: String = ""
}
open class CryptoPriceApplication: Application() {

override fun onCreate() {
super.onCreate()

context = applicationContext

startKoin {
initKoin {
androidContext(applicationContext)
modules(cryptoPriceModules)
}

CryptoPriceSettings.observeToken { token ->
Log.d("OBS", "is empty: ${token.isNullOrEmpty()}")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.shahryar.cryptoprice.core.base

import androidx.lifecycle.ViewModel

open class BaseViewModel: ViewModel() {
var toastMessage = SingleLiveEvent<String>()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.shahryar.cryptoprice.core.base
/*
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import android.util.Log
import androidx.annotation.MainThread
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import java.util.concurrent.atomic.AtomicBoolean

/**
* A lifecycle-aware observable that sends only new updates after subscription, used for events like
* navigation and Snackbar messages.
*
*
* This avoids a common problem with events: on configuration change (like rotation) an update
* can be emitted if the observer is active. This LiveData only calls the observable if there's an
* explicit call to setValue() or call().
*
*
* Note that only one observer is going to be notified of changes.
*/
class SingleLiveEvent<T> : MutableLiveData<T>() {
private val pending = AtomicBoolean(false)
@MainThread
override fun observe(owner: LifecycleOwner, observer: Observer<in T>) {
if (hasActiveObservers()) {
Log.w(TAG, "Multiple observers registered but only one will be notified of changes.")
}
// Observe the internal MutableLiveData
super.observe(owner, Observer { t ->
if (pending.compareAndSet(true, false)) {
observer.onChanged(t)
}
})
}

@MainThread
override fun setValue(t: T?) {
pending.set(true)
super.setValue(t)
}
/**
* Used for cases where T is Void, to make calls cleaner.
*/
@MainThread
fun call() {
value = null
}
companion object {
private val TAG = "SingleLiveEvent"
}
}

This file was deleted.

This file was deleted.

33 changes: 0 additions & 33 deletions app/src/main/java/com/shahryar/cryptoprice/core/common/Utils.kt

This file was deleted.

30 changes: 4 additions & 26 deletions app/src/main/java/com/shahryar/cryptoprice/core/di/Modules.kt
Original file line number Diff line number Diff line change
@@ -1,35 +1,13 @@
package com.shahryar.cryptoprice.core.di

import android.content.Context
import androidx.datastore.preferences.preferencesDataStore
import com.shahryar.cryptoprice.data.repository.Repository
import com.shahryar.cryptoprice.data.repository.RepositoryImpl
import com.shahryar.cryptoprice.data.source.local.LocalDataSourceImpl
import com.shahryar.cryptoprice.data.source.local.getDatabase
import com.shahryar.cryptoprice.data.repository.preferences.UserPreferencesRepository
import com.shahryar.cryptoprice.data.source.remote.ApiService
import com.shahryar.cryptoprice.data.source.remote.RemoteDataSourceImpl
import com.shahryar.cryptoprice.prices.viewmodel.PriceViewModel
import com.shahryar.cryptoprice.settings.SettingsViewModel
import com.shahryar.cryptoprice.widgets.WidgetConfigureViewModel
import org.koin.android.ext.koin.androidApplication
import org.koin.android.ext.koin.androidContext
import com.shahryar.cryptoprice.ui.prices.PriceViewModel
import com.shahryar.cryptoprice.ui.settings.SettingsViewModel
import com.shahryar.cryptoprice.ui.widgets.WidgetConfigureViewModel
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module

private val Context.dataStore by preferencesDataStore("USER_PREFERENCES")

val mainModule = module {
single { androidApplication().dataStore }
single { UserPreferencesRepository(get()) }
single<Repository> {
RepositoryImpl(
RemoteDataSourceImpl(ApiService.priceApi, get()),
LocalDataSourceImpl(getDatabase(androidContext()).currencyDao)
)
}

viewModel { (PriceViewModel(get(), get())) }
viewModel { (PriceViewModel(get())) }
viewModel { SettingsViewModel(get()) }
viewModel { WidgetConfigureViewModel(get()) }
}
Expand Down
71 changes: 0 additions & 71 deletions app/src/main/java/com/shahryar/cryptoprice/data/model/Data.kt

This file was deleted.

Loading

0 comments on commit 81dda0f

Please sign in to comment.