Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kuring-70 common:util, common:ui_util 모듈 분리 #73

Merged
merged 5 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ android {
}

dependencies {
implementation project(":common:util")
implementation project(":common:ui_util")

implementation libs.androidx.core.ktx
implementation libs.androidx.appcompat
Expand Down
71 changes: 0 additions & 71 deletions app/src/main/java/com/ku_stacks/ku_ring/di/NetworkModule.kt
Original file line number Diff line number Diff line change
@@ -1,89 +1,18 @@
package com.ku_stacks.ku_ring.di

import com.ku_stacks.ku_ring.BuildConfig
import com.ku_stacks.ku_ring.BuildConfig.API_BASE_URL
import com.ku_stacks.ku_ring.data.api.*
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import javax.inject.Named
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object NetworkModule {

@Provides
@Singleton
@Named("Default")
fun provideOkHttpClient(): OkHttpClient {
return OkHttpClient.Builder()
.addInterceptor(HttpLoggingInterceptor().apply {
level = if (BuildConfig.DEBUG) {
HttpLoggingInterceptor.Level.BODY
} else {
HttpLoggingInterceptor.Level.NONE
}
})
.addInterceptor(HeaderInterceptor())
.build()
}

@Provides
@Singleton
@Named("Default")
fun provideRetrofit(@Named("Default") okHttpClient: OkHttpClient): Retrofit {
return Retrofit.Builder()
.client(okHttpClient)
.baseUrl(API_BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
.build()
}

@Provides
@Singleton
@Named("Sendbird")
fun provideSendbirdOkHttpClient(): OkHttpClient {
return OkHttpClient.Builder()
.addInterceptor { chain ->
val newRequest = chain
.request()
.newBuilder()
.addHeader("Content-Type", "application/json; charset=utf-8")
.addHeader("Api-Token", BuildConfig.SENDBIRD_API_TOKEN)
.build()
chain.proceed(newRequest)
}
.addInterceptor(HttpLoggingInterceptor().apply {
level = if (BuildConfig.DEBUG) {
HttpLoggingInterceptor.Level.BODY
} else {
HttpLoggingInterceptor.Level.NONE
}
})
.build()
}

@Provides
@Singleton
@Named("Sendbird")
fun provideSendbirdRetrofit(@Named("Sendbird") okHttpClient: OkHttpClient): Retrofit {
val url = "https://api-${BuildConfig.SENDBIRD_APP_ID}.sendbird.com/v3/"
return Retrofit.Builder()
.client(okHttpClient)
.baseUrl(url)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
.build()
}

@Provides
@Singleton
fun provideNoticeService(@Named("Default") retrofit: Retrofit): NoticeService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.ku_stacks.ku_ring.data.db.DepartmentDao
import com.ku_stacks.ku_ring.data.db.NoticeDao
import com.ku_stacks.ku_ring.data.db.PushDao
import com.ku_stacks.ku_ring.repository.*
import com.ku_stacks.ku_ring.util.IODispatcher
import com.ku_stacks.ku_ring.util.PreferenceUtil
import dagger.Module
import dagger.Provides
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.ku_stacks.ku_ring.repository

import androidx.paging.*
import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
import androidx.paging.map
import androidx.paging.rxjava3.cachedIn
import androidx.paging.rxjava3.flowable
import com.ku_stacks.ku_ring.data.api.NoticeClient
Expand All @@ -10,22 +13,23 @@ import com.ku_stacks.ku_ring.data.mapper.toEntity
import com.ku_stacks.ku_ring.data.mapper.toNoticeList
import com.ku_stacks.ku_ring.data.model.Notice
import com.ku_stacks.ku_ring.data.source.NoticePagingSource
import com.ku_stacks.ku_ring.di.IODispatcher
import com.ku_stacks.ku_ring.util.DateUtil
import com.ku_stacks.ku_ring.util.IODispatcher
import com.ku_stacks.ku_ring.util.PreferenceUtil
import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.core.Flowable
import io.reactivex.rxjava3.schedulers.Schedulers
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.reactive.asPublisher
import kotlinx.coroutines.withContext
import timber.log.Timber
import javax.inject.Inject

@OptIn(ExperimentalPagingApi::class)
@OptIn(ExperimentalCoroutinesApi::class)
class NoticeRepositoryImpl @Inject constructor(
private val noticeClient: NoticeClient,
private val noticeDao: NoticeDao,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import com.ku_stacks.ku_ring.R
import com.ku_stacks.ku_ring.databinding.ActivityChatBinding
import com.ku_stacks.ku_ring.ui.chat.ui_model.ReceivedMessageUiModel
import com.ku_stacks.ku_ring.ui.chat.ui_model.SentMessageUiModel
import com.ku_stacks.ku_ring.ui.dialogs.ChatActionDialog
import com.ku_stacks.ku_ring.util.makeDialog
import com.ku_stacks.ku_ring.util.modified_external_library.RecyclerViewPager
import com.ku_stacks.ku_ring.util.showToast
import com.ku_stacks.ku_ring.ui_util.dialogs.ChatActionDialog
import com.ku_stacks.ku_ring.ui_util.makeDialog
import com.ku_stacks.ku_ring.ui_util.modified_external_library.RecyclerViewPager
import com.ku_stacks.ku_ring.ui_util.showToast
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import com.ku_stacks.ku_ring.R
import com.ku_stacks.ku_ring.data.api.FeedbackClient
import com.ku_stacks.ku_ring.data.api.request.FeedbackRequest
import com.ku_stacks.ku_ring.repository.UserRepository
import com.ku_stacks.ku_ring.ui.SingleLiveEvent
import com.ku_stacks.ku_ring.ui.chat.ui_model.ChatUiModel
import com.ku_stacks.ku_ring.ui.chat.ui_model.ReceivedMessageUiModel
import com.ku_stacks.ku_ring.ui.chat.ui_model.SentMessageUiModel
import com.ku_stacks.ku_ring.ui.chat.ui_model.toAdminMessageUiModel
import com.ku_stacks.ku_ring.ui.chat.ui_model.toChatUiModelList
import com.ku_stacks.ku_ring.ui.chat.ui_model.toReceivedMessageUiModel
import com.ku_stacks.ku_ring.ui.chat.ui_model.toSentMessageUiModel
import com.ku_stacks.ku_ring.ui_util.SingleLiveEvent
import com.ku_stacks.ku_ring.util.PreferenceUtil
import com.sendbird.android.SendbirdChat
import com.sendbird.android.channel.BaseChannel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.ku_stacks.ku_ring.ui.chat.viewholder

import com.ku_stacks.ku_ring.adapter.visibleIf
import com.ku_stacks.ku_ring.databinding.ItemChatAdminBinding
import com.ku_stacks.ku_ring.ui.chat.ui_model.AdminMessageUiModel
import com.ku_stacks.ku_ring.ui_util.visibleIf

class AdminViewHolder(
private val binding: ItemChatAdminBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import android.text.Spanned
import android.text.style.BackgroundColorSpan
import android.text.style.StyleSpan
import com.ku_stacks.ku_ring.R
import com.ku_stacks.ku_ring.adapter.visibleIf
import com.ku_stacks.ku_ring.databinding.ItemChatReceiveBinding
import com.ku_stacks.ku_ring.ui.chat.ui_model.ReceivedMessageUiModel
import com.ku_stacks.ku_ring.ui_util.visibleIf
import com.sendbird.android.SendbirdChat

class ReceiveViewHolder(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.ku_stacks.ku_ring.ui.chat.viewholder

import com.ku_stacks.ku_ring.adapter.visibleIf
import com.ku_stacks.ku_ring.databinding.ItemChatSendBinding
import com.ku_stacks.ku_ring.ui.chat.ui_model.SentMessageUiModel
import com.ku_stacks.ku_ring.ui_util.visibleIf

class SendViewHolder(
private val binding: ItemChatSendBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.ku_stacks.ku_ring.R
import com.ku_stacks.ku_ring.databinding.ActivityFeedbackBinding
import com.ku_stacks.ku_ring.util.modified_external_library.AppearanceAnimator
import com.ku_stacks.ku_ring.util.showToast
import com.ku_stacks.ku_ring.ui_util.modified_external_library.AppearanceAnimator
import com.ku_stacks.ku_ring.ui_util.showToast
import dagger.hilt.android.AndroidEntryPoint
import net.yslibrary.android.keyboardvisibilityevent.KeyboardVisibilityEvent

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.ku_stacks.ku_ring.R
import com.ku_stacks.ku_ring.analytics.EventAnalytics
import com.ku_stacks.ku_ring.data.api.FeedbackClient
import com.ku_stacks.ku_ring.data.api.request.FeedbackRequest
import com.ku_stacks.ku_ring.ui.SingleLiveEvent
import com.ku_stacks.ku_ring.ui_util.SingleLiveEvent
import dagger.hilt.android.lifecycle.HiltViewModel
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.disposables.CompositeDisposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.ku_stacks.ku_ring.R
import com.ku_stacks.ku_ring.data.model.WebViewNotice
import com.ku_stacks.ku_ring.databinding.ActivityMainBinding
import com.ku_stacks.ku_ring.ui.notice_webview.NoticeWebActivity
import com.ku_stacks.ku_ring.util.showToast
import com.ku_stacks.ku_ring.ui_util.showToast
import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import com.google.android.gms.common.api.ApiException
import com.ku_stacks.ku_ring.R
import com.ku_stacks.ku_ring.databinding.FragmentCampusBinding
import com.ku_stacks.ku_ring.navigator.KuringNavigator
import com.ku_stacks.ku_ring.ui_util.makeDialog
import com.ku_stacks.ku_ring.util.PreferenceUtil
import com.ku_stacks.ku_ring.util.makeDialog
import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber
import javax.inject.Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
import com.ku_stacks.ku_ring.R
import com.ku_stacks.ku_ring.repository.SendbirdRepository
import com.ku_stacks.ku_ring.ui.SingleLiveEvent
import com.ku_stacks.ku_ring.ui_util.SingleLiveEvent
import com.ku_stacks.ku_ring.util.PreferenceUtil
import com.sendbird.android.SendbirdChat
import com.sendbird.android.params.UserUpdateParams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import android.graphics.Color
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.ku_stacks.ku_ring.R
import com.ku_stacks.ku_ring.adapter.textColorGrayIf
import com.ku_stacks.ku_ring.adapter.visibleIf
import com.ku_stacks.ku_ring.data.model.Notice
import com.ku_stacks.ku_ring.databinding.ItemNoticeBinding
import com.ku_stacks.ku_ring.ui_util.textColorGrayIf
import com.ku_stacks.ku_ring.ui_util.visibleIf

class NoticeViewHolder(
private val binding: ItemNoticeBinding,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.ku_stacks.ku_ring.R
import com.ku_stacks.ku_ring.data.model.Staff
import com.ku_stacks.ku_ring.databinding.DialogStaffBottomSheetBinding
import com.ku_stacks.ku_ring.util.showToast
import com.ku_stacks.ku_ring.ui_util.showToast

class StaffBottomSheet : BottomSheetDialogFragment() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import com.ku_stacks.ku_ring.databinding.ActivityNotificationBinding
import com.ku_stacks.ku_ring.navigator.KuringNavigator
import com.ku_stacks.ku_ring.ui.my_notification.ui_model.PushContentUiModel
import com.ku_stacks.ku_ring.ui.notice_webview.NoticeWebActivity
import com.ku_stacks.ku_ring.util.makeDialog
import com.ku_stacks.ku_ring.ui_util.makeDialog
import com.yeonkyu.HoldableSwipeHelper.HoldableSwipeHandler
import com.yeonkyu.HoldableSwipeHelper.SwipeButtonAction
import dagger.hilt.android.AndroidEntryPoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.ku_stacks.ku_ring.R
import com.ku_stacks.ku_ring.data.model.Notice
import com.ku_stacks.ku_ring.databinding.ActivityNoticeStorageBinding
import com.ku_stacks.ku_ring.ui.notice_webview.NoticeWebActivity
import com.ku_stacks.ku_ring.util.makeDialog
import com.ku_stacks.ku_ring.ui_util.makeDialog
import com.yeonkyu.HoldableSwipeHelper.HoldableSwipeHandler
import com.yeonkyu.HoldableSwipeHelper.SwipeButtonAction
import dagger.hilt.android.AndroidEntryPoint
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/com/ku_stacks/ku_ring/util/FcmUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.ku_stacks.ku_ring.data.db.NoticeDao
import com.ku_stacks.ku_ring.data.db.NoticeEntity
import com.ku_stacks.ku_ring.data.db.PushDao
import com.ku_stacks.ku_ring.data.db.PushEntity
import com.ku_stacks.ku_ring.di.IODispatcher
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
app:layout_constraintTop_toTopOf="parent"
/>

<com.ku_stacks.ku_ring.customview.ClearableEditText
<com.ku_stacks.ku_ring.ui_util.customview.ClearableEditText
android:id="@+id/search_department_et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_search.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
app:layout_constraintEnd_toEndOf="parent"
tools:text="검색" />

<com.ku_stacks.ku_ring.customview.ClearableEditText
<com.ku_stacks.ku_ring.ui_util.customview.ClearableEditText
android:id="@+id/search_keyword_et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions common/ui_util/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
46 changes: 46 additions & 0 deletions common/ui_util/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
}

android {
namespace 'com.ku_stacks.ku_ring.ui_util'
compileSdk 33

defaultConfig {
minSdk 24

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
viewBinding {
enabled = true
}
dataBinding {
enabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {
implementation libs.androidx.core.ktx
implementation libs.androidx.appcompat
implementation libs.android.material
implementation libs.androidx.constraintlayout

// Timber
implementation libs.timber
}
Empty file.
21 changes: 21 additions & 0 deletions common/ui_util/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
4 changes: 4 additions & 0 deletions common/ui_util/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest>

</manifest>
Loading
Loading