Skip to content

Commit

Permalink
Merge pull request #37 from beomjo/1.0.1/release-merge-into-master-br…
Browse files Browse the repository at this point in the history
…anch

* Release branch merge into main branch
  • Loading branch information
beomjo authored Jul 6, 2021
2 parents 7bc4567 + b72866e commit 2931f0f
Show file tree
Hide file tree
Showing 49 changed files with 210 additions and 500 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
local.properties
.idea/gradle.xml
.idea/vcs.xml
.idea
2 changes: 1 addition & 1 deletion .idea/compiler.xml

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

2 changes: 1 addition & 1 deletion .idea/misc.xml

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

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ You can hear sounds that can help you study, concentrate, and sleep.
- Architecture
- MVVM Architecture (View - DataBinding - ViewModel - Model)
- Repository pattern
- [Dagger 2](https://dagger.dev/dev-guide) - dependency injection.
- [Dagger Hilt](https://dagger.dev/hilt/) - dependency injection.
- Firebase - FireStore, Storage
- [Glide](https://github.com/bumptech/glide) - loading images.
Expand Down
51 changes: 45 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,37 @@ plugins {
id 'com.google.gms.google-services'
id 'kotlin-parcelize'
id 'com.google.firebase.crashlytics'
id 'scabbard.gradle'
id 'dagger.hilt.android.plugin'
}

class Version {
static final String FILE_NAME = 'version.properties'
int code
String name
}

def loadConfigFile(String fileName) {
String projPath = getProjectDir().getPath() + "/config"
Properties prop = new Properties()
FileInputStream fis
try {
fis = new FileInputStream(projPath + "/" + fileName)
prop.load(fis)
} catch (IOException e) {
System.out.println(e.toString())
}
return prop
}

def getVersionProperty() {
Properties prop = loadConfigFile(Version.FILE_NAME)

Version version = new Version()
version.code = prop.getProperty("version.code", "1").toInteger()
version.name = prop.getProperty("version.name", "1")

return version
}

android {
Expand All @@ -16,15 +47,18 @@ android {
storeFile file('../keystore/upload-key.jks')
}
}

compileSdkVersion versions.compile_sdk_version
buildToolsVersion versions.build_tool_version

Version version = getVersionProperty()

defaultConfig {
applicationId "com.beomjo.whitenoise"
minSdkVersion versions.min_sdk_version
targetSdkVersion versions.target_sdk_version
versionCode 1
versionName "1.0.0"
versionCode version.code
versionName version.name

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -46,6 +80,11 @@ android {
buildFeatures {
dataBinding true
}
scabbard {
enabled true
failOnError true
fullBindingGraphValidation true
}
}

dependencies {
Expand All @@ -59,17 +98,17 @@ dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.4.3'
implementation 'com.google.firebase:firebase-crashlytics'

implementation deps.dagger2.android
kapt deps.dagger2.compiler
implementation deps.hilt.android
kapt deps.hilt.compiler

implementation "com.github.skydoves:bindables:1.0.5"
implementation 'com.facebook.shimmer:shimmer:0.5.0'

implementation 'androidx.media:media:1.2.1'
implementation 'androidx.media:media:1.3.1'

testImplementation deps.test.arch.core
testImplementation deps.test.androidx_test_core
testImplementation deps.test.coroutine_test
testImplementation deps.test.mockk
testImplementation "org.jetbrains.kotlin:kotlin-reflect:1.4.31"
testImplementation "org.jetbrains.kotlin:kotlin-reflect:1.5.10"
}
2 changes: 2 additions & 0 deletions app/config/version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version.code=2021070901
version.name=1.0.1
26 changes: 26 additions & 0 deletions app/release_note.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Features
*




# Changes
*



# Bug Fixes
* [#31] 트랙 재생, 멈춤시 진동, 알림 오는현상 수정
* 알림채널 우선순위 LOW로 변경
* [#32] 홈화면 Pull to Refersh시 shimmer가 뒤쪽에 표시되는 현상 수정
* [#26] 디바이스 가로회전 막음처리



# Add
*



# Deprecations
*
15 changes: 11 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,25 @@
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/Theme.WhiteNoisePlayer">
<activity android:name=".ui.splash.SplashActivity">
<activity
android:name=".ui.splash.SplashActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.auth.LoginActivity" />
<activity android:name=".ui.main.MainActivity" />
<activity
android:name=".ui.auth.LoginActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ui.main.MainActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ui.player.PlayerActivity"
android:launchMode="singleTop" />
android:launchMode="singleTop"
android:screenOrientation="portrait" />

<service
android:name=".ui.player.PlayerService"
Expand Down
10 changes: 4 additions & 6 deletions app/src/main/java/com/beomjo/whitenoise/WhiteNoiseApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ package com.beomjo.whitenoise
import android.app.Application
import com.beomjo.compilation.util.LogUtil
import com.beomjo.whitenoise.common.WhiteNoseConfig
import com.beomjo.whitenoise.di.AppComponent
import com.beomjo.whitenoise.di.DaggerAppComponent
import com.beomjo.whitenoise.ui.player.NotificationManager
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
open class WhiteNoiseApp : Application() {
val appComponent: AppComponent by lazy {
DaggerAppComponent.factory().create(applicationContext)
}

override fun onCreate() {
super.onCreate()
LogUtil.init(WhiteNoseConfig())
com.beomjo.whitenoise.ui.player.NotificationManager.createNotificationChannel(this)
NotificationManager.createNotificationChannel(this)
}
}
53 changes: 15 additions & 38 deletions app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt
Original file line number Diff line number Diff line change
@@ -1,62 +1,32 @@
package com.beomjo.whitenoise.base

import android.annotation.SuppressLint
import android.os.Bundle
import android.view.WindowManager
import android.widget.Toast
import androidx.annotation.LayoutRes
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ViewModelProvider
import com.beomjo.whitenoise.factory.ViewModelFactory
import com.beomjo.whitenoise.ui.common.ProgressDialogFragment
import com.skydoves.bindables.BindingActivity
import javax.inject.Inject
import kotlin.reflect.KClass

abstract class BaseActivity<T : ViewDataBinding>(
@LayoutRes contentLayoutId: Int,
private vararg var viewModels: KClass<out BaseViewModel>,
) : BindingActivity<T>(contentLayoutId), LifecycleOwner {

@Inject
lateinit var viewModelFactory: ViewModelFactory

val viewModelImpl: MutableList<BaseViewModel> = mutableListOf()

protected var progressDialog: ProgressDialogFragment? = null

protected inline fun <reified T : BaseViewModel> getViewModel(): Lazy<T> {
inline fun <reified T : BaseViewModel> getViewModel(): Lazy<T> {
return lazy {
viewModelImpl.find { it is T }?.let { it as T }
?: kotlin.run { throw IllegalStateException("Can't find [${T::class.java.simpleName}] type ViewModel") }
}
}

protected fun setStatusBarColor(color: Int) {
if (!isFinishing) {
val window = window
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.statusBarColor = color
ViewModelProvider(this)
.get(T::class.java)
.apply { observeViewModel(this) }
}
}

@SuppressLint("MissingSuperCall")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
inject()
createViewModels()
bindingLifeCycleOwner()
observeViewModel()
}

abstract fun inject()

private fun createViewModels() {
for (vm in viewModels) {
viewModelImpl.add(ViewModelProvider(this, viewModelFactory).get(vm.javaObjectType))
}
}

private fun bindingLifeCycleOwner() {
Expand All @@ -65,13 +35,20 @@ abstract class BaseActivity<T : ViewDataBinding>(
}
}

private fun observeViewModel() {
for (vm in viewModelImpl) {
observeToast(vm)
observeProgress(vm)
protected fun setStatusBarColor(color: Int) {
if (!isFinishing) {
val window = window
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.statusBarColor = color
}
}

fun observeViewModel(viewModel: BaseViewModel) {
observeToast(viewModel)
observeProgress(viewModel)
}

private fun observeToast(vm: BaseViewModel) {
vm.toast.observe(this) { event ->
event.getContentIfNotHandled()?.let { msg ->
Expand Down
44 changes: 15 additions & 29 deletions app/src/main/java/com/beomjo/whitenoise/base/BaseDialogFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,30 @@ import androidx.databinding.ViewDataBinding
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ViewModelProvider
import com.beomjo.whitenoise.factory.ViewModelFactory
import androidx.lifecycle.ViewModelStoreOwner
import com.skydoves.bindables.BindingDialogFragment
import javax.inject.Inject
import kotlin.reflect.KClass

abstract class BaseDialogFragment<B : ViewDataBinding>(
@LayoutRes private val contentLayoutId: Int,
private vararg var viewModels: KClass<out BaseViewModel>,
) : BindingDialogFragment<B>(contentLayoutId), LifecycleOwner {

@Inject
lateinit var viewModelFactory: ViewModelFactory
abstract val viewModelProvideOwner: ViewModelStoreOwner

val viewModelImpl: MutableList<BaseViewModel> = mutableListOf()

protected inline fun <reified T : BaseViewModel> getViewModel(): Lazy<T> {
inline fun <reified T : BaseViewModel> getViewModel(): Lazy<T> {
return lazy {
viewModelImpl.find { it is T }?.let { it as T }
?: kotlin.run { throw IllegalStateException("Can't find [${T::class.java.simpleName}] type ViewModel") }
ViewModelProvider(viewModelProvideOwner)
.get(T::class.java)
.apply { observeViewModel(this) }
}
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
savedInstanceState: Bundle?,
): View {
return super.onCreateView(inflater, container, savedInstanceState).apply {
inject()
createViewModels()
bindingLifeCycleOwner()
bindingToast()
}
}

abstract fun inject()

private fun createViewModels() {
for (vm in viewModels) {
viewModelImpl.add(ViewModelProvider(this, viewModelFactory).get(vm.javaObjectType))
}
}

Expand All @@ -59,12 +43,14 @@ abstract class BaseDialogFragment<B : ViewDataBinding>(
}
}

private fun bindingToast() {
for (vm in viewModelImpl) {
vm.toast.observe(this) { event ->
event.getContentIfNotHandled()?.let { msg ->
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show()
}
fun observeViewModel(viewModel: BaseViewModel) {
observeToast(viewModel)
}

private fun observeToast(vm: BaseViewModel) {
vm.toast.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled()?.let { msg ->
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show()
}
}
}
Expand Down
Loading

0 comments on commit 2931f0f

Please sign in to comment.